what is wrong with my futures request for BTC and ES?

Jwan622
Jwan622 Newcomer
edited March 10 in TRTH

This is giving me a 200 but I'm not getting any futures data.

Where can I get a list of futures contracts and the months and the RIC btw? Where can I get this list?

This is my code. I'm getting a 200 but no order book data for this futures.

def get_tick_history(ticker, query_start_date, query_end_date):
    json_blob = {
        "ExtractionRequest": {
            "@odata.type": "#DataScope.Select.Api.Extractions.ExtractionRequests.TickHistoryMarketDepthExtractionRequest",
            "IdentifierList": {
                "@odata.type": "#DataScope.Select.Api.Extractions.ExtractionRequests.InstrumentIdentifierList",
                "InstrumentIdentifiers": [{
                    "Identifier": f"{ticker}",
                    "IdentifierType": "Ric",
                }],
                "ValidationOptions": {
                    "AllowHistoricalInstruments": "true"
                },
                "UseUserPreferencesForValidationOptions": "false",
            },
            "Condition": {
                "View": "RawMarketByPrice",
                "MessageTimeStampIn": "GmtUtc",
                "ReportDateRangeType": "Range",
                "DisplaySourceRIC": "true",
                "DateRangeTimeZone": "UTC",
                "QueryStartDate": query_start_date,
                "QueryEndDate": query_end_date,
            },
        }
    }
    post_url = URL_BASE + "/Extractions/ExtractRaw"
    request_response = post_request_with_auth(post_url, REFINITIV_AUTH_TOKEN, json_blob)

    job_id = request_response.json()["JobId"]
    logger.info("Starting CSV download...")

    data_response = requests.get(URL_BASE + f"/Extractions/RawExtractionResults('{job_id}')/$value", headers = {
        "Authorization": f"Token {REFINITIV_AUTH_TOKEN}"
    }, stream = True)

    data_response.raise_for_status()

    return data_response

# Example usage:
if __name__ == "__main__":
    # intraday_data = get_embargo_info("FCX")
    # if intraday_data:
    #     print(json.dumps(intraday_data, indent=4))

    # get_sp500()
    get_tick_history("BTCc1", "2025-03-01T09:30:00Z", "2025-03-06T16:00:00Z")

Answers

  • Jirapongse
    Jirapongse ✭✭✭✭✭

    @Jwan622

    Thank you for reaching out to us.

    You need to check the Notes in the response. I got this one.

     "Notes": [        "Extraction Services Version 18.3.1.48082 (0d5e6bbb8e4a), Built Jan 10 2025 19:16:51\nUser ID: 9008895\nExtraction ID: 2000000878088820\nCorrelation ID: CiD/9008895/AAAAAA.094f1e321bbaead7/RA\nSchedule: 0x094f1e321bcaead7 (ID = 0x0000000000000000)\nInput List (1 items):  (ID = 0x094f1e321bcaead7) Created: 03/10/2025 PM 03:27:59 Last Modified: 03/10/2025 PM 03:27:59\nReport Template: _OnD_0x094f1e321bcaead7 (ID = 0x094f1e321bdaead7) Created: 03/10/2025 PM 03:27:58 Last Modified: 03/10/2025 PM 03:27:58\nSchedule dispatched via message queue (0x094f1e321bcaead7)\nSchedule Time: 03/10/2025 PM 03:27:59\nProcessing started at 03/10/2025 PM 03:27:59\nProcessing completed successfully at 03/10/2025 PM 03:27:59\nExtraction finished at 03/10/2025 AM 08:27:59 UTC, with servers: xc81xkeuq13\nInstrument <RIC,BTCc1> expanded to 0 RICS.\n\n\nReport suppressed because there are no instruments\n"    ]

    If I changed the View to "LegacyLevel2", I can extract the data properly.

    BTCc1 may not support the RawMarketByPrice. Please contact the Tick History support team directly via MyAccount to verify the data.

  • Jwan622
    Jwan622 Newcomer

    This works for 0#1YM: but not for 0#1ES or 0#1NQ.

    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?

  • Jirapongse
    Jirapongse ✭✭✭✭✭

    @Jwan622

    0#1ES and 0#1NQ are invalid RICs.

    Typically, you can check the Notes in the response for the problem.

     "Notes": [        "All identifiers were invalid.  No extraction performed."    ],

    Please contact the Tick History support team directly via MyAccount for the RICs that can provide the futures market depth data for Nasdaq and S&P.