This works for 0#1YM: but not for 0#1ES: or 0#1NQ or 0#ES or 0#NQ or 0#.ES
def get_chain_ric_market_depth(futures_ric, query_start_date, query_end_date):
"""
Example futures ric: 0#1YM:
"""
json_blob = {
"ExtractionRequest": {
"@odata.type": "#DataScope.Select.Api.Extractions.ExtractionRequests.TickHistoryMarketDepthExtractionRequest",
"IdentifierList": {
"@odata.type": "#DataScope.Select.Api.Extractions.ExtractionRequests.InstrumentIdentifierList",
"InstrumentIdentifiers": [
{
"Identifier": futures_ric,
"IdentifierType": "ChainRIC"
}
]
},
"Condition": {
"View": "RawMarketByPrice",
"MessageTimeStampIn": "GmtUtc",
"ReportDateRangeType": "Range",
"QueryStartDate": query_start_date,
"QueryEndDate": query_end_date,
"DisplaySourceRIC": True
}
}
}
post_url = URL_BASE + "/Extractions/ExtractRaw"
response = requests.post(post_url, headers = {
"Authorization": f"Token {REFINITIV_AUTH_TOKEN}",
"Content-Type": "application/json"
}, json = json_blob)
if response.status_code != 200:
raise ValueError(f"Failed to fetch tick data: {response.status_code} - {response.text}")
job_id = response.json().get("JobId")
if not job_id:
raise ValueError("No JobId returned. Check request parameters.")
# Fetch extracted data
data_url = f"{URL_BASE}/Extractions/RawExtractionResults('{job_id}')/$value"
data_response = requests.get(data_url, headers = {
"Authorization": f"Token {REFINITIV_AUTH_TOKEN}"
}, stream = True)
data_response.raise_for_status()
return data_response
How do I get futures market depth data for Nasdaq and S&P?