Workspace Blended Order Book data stream

Hi, I am working on a monitoring tool for SAFEX contracts. I'm trying to pull the blended order book and log the transactions per broker in excel. I'm stuck on the data stream though, I cant find a way to get the data to pull the data from the "BY order" tab seen in Refinitiv Workspace, it keeps pulling from the first tab "best only". Thus, the broker names don't get pulled. They appear in the format of "JSE:broker code". See the screenshot below what i mean by the tabs.
The specific function in the script I have is in the stream, which is seen here:
def setup_stream(contract_code: str, retries: int = 3) -> None:
"""Set up market data stream with BY ORDER view configuration"""
for attempt in range(retries):
try:
# Create fields list for BY ORDER view
fields = [
# Core fields
"OPEN_PRC", "ACVOL_1",
# Venue columns
"VENUE.BID.0.ID", "VENUE.ASK.0.ID", # First row venue
"VENUE.BID.CNT", "VENUE.ASK.CNT", # Count
"VENUE.BID.ACC", "VENUE.ASK.ACC", # AccSize
"VENUE.BID.SZ", "VENUE.ASK.SZ", # Size
"VENUE.BID.PRC", "VENUE.ASK.PRC", # Bid/Ask prices
# Try additional market depth fields
"MARKET_DEPTH",
"ORDER_DEPTH",
"BOOK_DEPTH",
# Row fields
*[f"DEPTH_{i}" for i in range(50)],
# State fields
"VIEW", # Current view
"MODE", # Display mode
"STATE" # Order book state
]
# Set up stream with view configuration
pricing_stream = pricing.Definition(
universe=[f"{contract_code}:BOB", contract_code], # Try BOB suffix
fields=fields,
domain="MARKET_PRICE" # Specify market price domain
).get_stream()
def on_refresh(fields, instrument_name, stream):
logging.info(f"\n{'='*80}")
logging.info(f"REFRESH {instrument_name} - BY ORDER View:")
logging.info(f"{'='*80}")
# Log all fields for debugging
for key, value in sorted(fields.items()):
if value is not None:
logging.info(f"{key:30} | {str(value):>20} | Type: {type(value).__name__}")
process_data(fields, contract_code)
def on_update(fields, instrument_name, stream):
logging.info(f"\n{'-'*80}")
logging.info(f"UPDATE {instrument_name} - BY ORDER View:")
logging.info(f"{'-'*80}")
# Log all changes
for key, value in sorted(fields.items()):
if value is not None:
logging.info(f"{key:30} | {str(value):>20} | Type: {type(value).__name__}")
process_data(fields, contract_code)
pricing_stream.on_refresh(on_refresh)
pricing_stream.on_update(on_update)
# Try to set view before opening stream
pricing_stream.set_attribute("VIEW", "BY_ORDER")
pricing_stream.open()
logging.info(f"Stream opened for {contract_code} with BY ORDER view")
return
except Exception as e:
logging.error(f"Error setting up stream for {contract_code}, attempt {attempt + 1}: {e}")
if attempt < retries - 1:
time_module.sleep(2)
else:
logging.error(f"Failed to set up stream for {contract_code} after {retries} attempts.")
I have attempted multiple ways of getting the stream to open the right tab to no avail. I have attached the full script for reference.
Any assistance will be greatly appreciated.
Answers
-
Thank you for reaching out to us.
I found that the application adds the ":BOB" behind the contract code and subscribes to the fields that are in the Real-Time Dictionary, such as VENUE.BID.0.ID. Does this code work?
pricing_stream = pricing.Definition(
universe=[f"{contract_code}:BOB", contract_code], # Try BOB suffix
fields=fields,
domain="MARKET_PRICE" # Specify market price domain
).get_stream()
# Venue columns
"VENUE.BID.0.ID", "VENUE.ASK.0.ID", # First row venue
"VENUE.BID.CNT", "VENUE.ASK.CNT", # Count
"VENUE.BID.ACC", "VENUE.ASK.ACC", # AccSize
"VENUE.BID.SZ", "VENUE.ASK.SZ", # Size
"VENUE.BID.PRC", "VENUE.ASK.PRC", # Bid/Ask prices
# Try additional market depth fields
"MARKET_DEPTH",
"ORDER_DEPTH",
"BOOK_DEPTH",The "MarketPrice" domain only provides the Level I market information such as trades, indicative quotes, and top-of-book quotes.
To retrieve Level II market by order data, you need to subscribe to the MarketByOrder domain. Please see the Level II subscription in GitHub.
0
Categories
- All Categories
- 3 Polls
- 6 AHS
- 36 Alpha
- 166 App Studio
- 6 Block Chain
- 4 Bot Platform
- 18 Connected Risk APIs
- 47 Data Fusion
- 34 Data Model Discovery
- 685 Datastream
- 1.4K DSS
- 615 Eikon COM
- 5.2K Eikon Data APIs
- 10 Electronic Trading
- Generic FIX
- 7 Local Bank Node API
- 3 Trading API
- 2.9K Elektron
- 1.4K EMA
- 252 ETA
- 556 WebSocket API
- 38 FX Venues
- 14 FX Market Data
- 1 FX Post Trade
- 1 FX Trading - Matching
- 12 FX Trading – RFQ Maker
- 5 Intelligent Tagging
- 2 Legal One
- 23 Messenger Bot
- 3 Messenger Side by Side
- 9 ONESOURCE
- 7 Indirect Tax
- 60 Open Calais
- 275 Open PermID
- 44 Entity Search
- 2 Org ID
- 1 PAM
- PAM - Logging
- 6 Product Insight
- Project Tracking
- ProView
- ProView Internal
- 22 RDMS
- 1.9K Refinitiv Data Platform
- 652 Refinitiv Data Platform Libraries
- 4 LSEG Due Diligence
- LSEG Due Diligence Portal API
- 4 Refinitiv Due Dilligence Centre
- Rose's Space
- 1.2K Screening
- 18 Qual-ID API
- 13 Screening Deployed
- 23 Screening Online
- 12 World-Check Customer Risk Screener
- 1K World-Check One
- 46 World-Check One Zero Footprint
- 45 Side by Side Integration API
- 2 Test Space
- 3 Thomson One Smart
- 10 TR Knowledge Graph
- 151 Transactions
- 143 REDI API
- 1.8K TREP APIs
- 4 CAT
- 27 DACS Station
- 121 Open DACS
- 1.1K RFA
- 104 UPA
- 193 TREP Infrastructure
- 228 TRKD
- 917 TRTH
- 5 Velocity Analytics
- 9 Wealth Management Web Services
- 90 Workspace SDK
- 11 Element Framework
- 5 Grid
- 18 World-Check Data File
- 1 Yield Book Analytics
- 46 中文论坛