When do CSVs become available for download for all exchanges? I'm download ticker order book ric

Jwan622
Jwan622 Newcomer
edited February 26 in TRTH

Hi I'm making requests to download TickHistoryMarketDepth data.

"ExtractionRequest": {    "@odata.type": "#DataScope.Select.Api.Extractions.ExtractionRequests.TickHistoryMarketDepthExtractionRequest",    "IdentifierList": {        "@odata.type": "#DataScope.Select.Api.Extractions.ExtractionRequests.InstrumentIdentifierList",        "InstrumentIdentifiers": [{            "Identifier": f"{ticker}",            "IdentifierType": "Ric",        }],

When does this data become available for all exchanges? I'm making a post request to post_url = URL_BASE + "/Extractions/ExtractRaw".

The exchanges I'm trying to download ticker data from are suffixes = [".NYO", ".ARC", ".ITC", ".DEX", ".BAT"]I notice if I download too early, the csvs aren't there or are empty. If I'm trying to download data for 2025-02-24… when should I start the download process?

Answers

  • Hello @Jwan622

    There is an embargo for every exchange. Tickhistory can not release data for that exchange, until the exchange mandated embargo time has passed; which is typically few minutes or hours after trading end.

    You can see some of the embargo information for an instrument in the IntraDayPricingExtraction request.

    {
      "ExtractionRequest": {
        "@odata.type": "#ThomsonReuters.Dss.Api.Extractions.ExtractionRequests.IntradayPricingExtractionRequest",
        "ContentFieldNames": [
          "Exchange Code",
          "File Code",
          "PE Code",
          "Real Time Permitted",
          "Exchange Requiring Embargo",
          "Embargo Times",
          "Embargo Window",
          "Current Embargo Delay",
          "Maximum Embargo Delay",
          "Instrument Snap Time",
          "Last Update Time"
        ],
        "IdentifierList": {
          "@odata.type": "#ThomsonReuters.Dss.Api.Extractions.ExtractionRequests.InstrumentIdentifierList",  
          "InstrumentIdentifiers": [
          	{ "Identifier": "VOD.L", "IdentifierType": "Ric" }
          ]
        },
        "Condition": { "ScalableCurrency": true }
      }
    }
    
  • Jwan622
    Jwan622 Newcomer

    that doesn't seem to work. Could you take a look at this code?


    # Base API URL (Update with the correct endpoint)URL_BASE = "https://selectapi.datascope.refinitiv.com/RestApi/v1"REFINITIV_AUTH_TOKEN = get_cached_refinitiv_auth_token() # Replace with valid authentication tokendef get_embargo_info(ticker="VOD.L"): logger.info(f"Fetching embargo information for {ticker}...") # Construct request payload json_blob = { "ExtractionRequest": { "@odata.type": "#ThomsonReuters.Dss.Api.Extractions.ExtractionRequests.IntradayPricingExtractionRequest", "ContentFieldNames": [ "Exchange Code", "File Code", "PE Code", "Real Time Permitted", "Exchange Requiring Embargo", "Embargo Times", "Embargo Window", "Current Embargo Delay", "Maximum Embargo Delay", "Instrument Snap Time", "Last Update Time" ], "IdentifierList": { "@odata.type": "#ThomsonReuters.Dss.Api.Extractions.ExtractionRequests.InstrumentIdentifierList", "InstrumentIdentifiers": [{"Identifier": ticker, "IdentifierType": "Ric"}] }, "Condition": {"ScalableCurrency": True} } } # API endpoint for extraction request post_url = f"{URL_BASE}/Extractions/ExtractRaw" # Send the request response = requests.post( post_url, headers={"Authorization": f"Token {REFINITIV_AUTH_TOKEN}", "Content-Type": "application/json"}, json=json_blob ) # Check if request was successful if response.status_code == 200: embargo_data = response.json() logger.info(f"Embargo info retrieved successfully for {ticker}.") return embargo_data else: logger.error(f"Failed to fetch embargo data. Status Code: {response.status_code}, Response: {response.text}") return None# Example callif __name__ == "__main__": embargo_info = get_embargo_info("VOD.L") if embargo_info: print(json.dumps(embargo_info, indent=4))


    I am getting thsi error:

    Failed to fetch embargo data. Status Code: 400, Response: {"error":{"message":"Malformed request payload: Unexpected @odata.type 'DataScope.Select.Api.Extractions.ExtractionRequests.ThomsonReuters.Dss.Api.Extractions.ExtractionRequests.IntradayPricingExtractionRequest' in payload"}}

  • Jwan622
    Jwan622 Newcomer

    that doesn't seem to work. Could you take a look at this code?# Base API URL (Update with the correct endpoint)URL_BASE = "https://selectapi.datascope.refinitiv.com/RestApi/v1"REFINITIV_AUTH_TOKEN = get_cached_refinitiv_auth_token() # Replace with valid authentication tokendef get_embargo_info(ticker="VOD.L"): logger.info(f"Fetching embargo information for {ticker}...") # Construct request payload json_blob = { "ExtractionRequest": { "@odata.type": "#ThomsonReuters.Dss.Api.Extractions.ExtractionRequests.IntradayPricingExtractionRequest", "ContentFieldNames": [ "Exchange Code", "File Code", "PE Code", "Real Time Permitted", "Exchange Requiring Embargo", "Embargo Times", "Embargo Window", "Current Embargo Delay", "Maximum Embargo Delay", "Instrument Snap Time", "Last Update Time" ], "IdentifierList": { "@odata.type": "#ThomsonReuters.Dss.Api.Extractions.ExtractionRequests.InstrumentIdentifierList", "InstrumentIdentifiers": [{"Identifier": ticker, "IdentifierType": "Ric"}] }, "Condition": {"ScalableCurrency": True} } } # API endpoint for extraction request post_url = f"{URL_BASE}/Extractions/ExtractRaw" # Send the request response = requests.post( post_url, headers={"Authorization": f"Token {REFINITIV_AUTH_TOKEN}", "Content-Type": "application/json"}, json=json_blob ) # Check if request was successful if response.status_code == 200: embargo_data = response.json() logger.info(f"Embargo info retrieved successfully for {ticker}.") return embargo_data else: logger.error(f"Failed to fetch embargo data. Status Code: {response.status_code}, Response: {response.text}") return None# Example callif __name__ == "__main__": embargo_info = get_embargo_info("VOD.L") if embargo_info: print(json.dumps(embargo_info, indent=4))

    I am getting this error:

    Failed to fetch embargo data. Status Code: 400, Response: {"error":{"message":"Malformed request payload: Unexpected @odata.type 'DataScope.Select.Api.Extractions.ExtractionRequests.ThomsonReuters.Dss.Api.Extractions.ExtractionRequests.IntradayPricingExtractionRequest' in payload"}}

  • Jwan622
    Jwan622 Newcomer
    edited February 25

    @Gurpreet that doesn't seem to work. Could you take a look at this code?

    import requests

    URL_BASE = "https://selectapi.datascope.refinitiv.com/RestApi/v1" REFINITIV_AUTH_TOKEN = get_cached_refinitiv_auth_token()

    def get_embargo_info(ticker="VOD.L"): logger.info(f"Fetching embargo information for {ticker}...")

    # Construct request payload json_blob = { "ExtractionRequest": { "@odata.type": "#ThomsonReuters.Dss.Api.Extractions.ExtractionRequests.IntradayPricingExtractionRequest", "ContentFieldNames": [ "Exchange Code", "File Code", "PE Code", "Real Time Permitted", "Exchange Requiring Embargo", "Embargo Times", "Embargo Window", "Current Embargo Delay", "Maximum Embargo Delay", "Instrument Snap Time", "Last Update Time" ], "IdentifierList": { "@odata.type": "#ThomsonReuters.Dss.Api.Extractions.ExtractionRequests.InstrumentIdentifierList", "InstrumentIdentifiers": [{"Identifier": ticker, "IdentifierType": "Ric"}] }, "Condition": {"ScalableCurrency": True} } } # API endpoint for extraction request post_url = f"{URL_BASE}/Extractions/ExtractRaw" # Send the request response = requests.post( post_url, headers={"Authorization": f"Token {REFINITIV_AUTH_TOKEN}", "Content-Type": "application/json"}, json=json_blob ) # Check if request was successful if response.status_code == 200: embargo_data = response.json() logger.info(f"Embargo info retrieved successfully for {ticker}.") return embargo_data else: logger.error(f"Failed to fetch embargo data. Status Code: {response.status_code}, Response: {response.text}") return None


    if name == "main": embargo_info = get_embargo_info("VOD.L") if embargo_info: print(json.dumps(embargo_info, indent=4))
  • Request:

    {
      "ExtractionRequest": {
        "@odata.type": "#DataScope.Select.Api.Extractions.ExtractionRequests.IntradayPricingExtractionRequest",
        "ContentFieldNames": [
          "Exchange Code",
          "File Code",
          "PE Code",
          "Real Time Permitted",
          "Exchange Requiring Embargo",
          "Embargo Times",
          "Embargo Window",
          "Current Embargo Delay",
          "Maximum Embargo Delay",
          "Instrument Snap Time",
          "Last Update Time"
        ],
        "IdentifierList": {
          "@odata.type": "#DataScope.Select.Api.Extractions.ExtractionRequests.InstrumentIdentifierList",
          "InstrumentIdentifiers": [{
              "Identifier": "VOD.L",
              "IdentifierType": "Ric"
            }
          ]
        },
        "Condition": {
          "ScalableCurrency": "true"
        }
      }
    }
    
    

    Response:

    {
      "@odata.context": "https://selectapi.datascope.refinitiv.com/RestApi/v1/$metadata#DataScope.Select.Api.Extractions.ExtractionRequests.ExtractionResult",
      "Contents": [{
          "IdentifierType": "Ric",
          "Identifier": "VOD.L",
          "Exchange Code": "LSE",
          "File Code": "691",
          "PE Code": "5625",
          "Real Time Permitted": "N",
          "Exchange Requiring Embargo": "LDI (LSE LEVEL 1 DOMESTIC AND INTERNATIONAL - PDA ONLY), LSE1D (LONDON SE UK MARKET L1), LSE2D (LONDON SE DOMESTIC L1 L2)",
          "Embargo Times": "Monday-Friday 03:00:00 AM-11:30:00 AM",
          "Embargo Window": null,
          "Current Embargo Delay": 0,
          "Maximum Embargo Delay": 15,
          "Instrument Snap Time": "25/02/2025 05:50:30 PM",
          "Last Update Time": "25/02/2025 03:10:37 PM"
        }
      ],
      "Notes": [...]
    }
    
  • Jirapongse
    Jirapongse ✭✭✭✭✭

    The code should handle response.status_code == 202 which indicates the the extraction is still in-progress.

    Please refer to the REST API Tutorial 3: On Demand intraday extraction, embargo tutorial in the Embargo section.

  • Jwan622
    Jwan622 Newcomer
    edited February 26

    It's a post request right?

    URL_BASE = "https://selectapi.datascope.refinitiv.com/RestApi/v1"
    REFINITIV_AUTH_TOKEN = get_cached_refinitiv_auth_token()
    
    
    def get_intraday_data(ticker: str):
    """
    Fetch intraday pricing data for a given ticker.
    Logs when request is accepted (202) but does not poll.
    Matches the exact request format from the Refinitiv Customer Service Engineer.
    """
    logger.info(f"Fetching intraday data for {ticker}...")
    
    
    # API endpoint (matches Customer Service Engineer's request)
    post_url = f"{URL_BASE}/Extractions/ExtractWithNotes"
    
    # Construct request payload
    json_blob = {
        "ExtractionRequest": {
            "@odata.type": "#DataScope.Select.Api.Extractions.ExtractionRequests.IntradayPricingExtractionRequest",
            "ContentFieldNames": [
                "Exchange Code",
                "File Code",
                "PE Code",
                "Real Time Permitted",
                "Exchange Requiring Embargo",
                "Embargo Times",
                "Embargo Window",
                "Current Embargo Delay",
                "Maximum Embargo Delay",
                "Instrument Snap Time",
                "Last Update Time"
                ],
            "IdentifierList": {
                "@odata.type": "#DataScope.Select.Api.Extractions.ExtractionRequests.InstrumentIdentifierList",
                    "InstrumentIdentifiers": [{
                      "Identifier": "VOD.L",
                      "IdentifierType": "Ric"
                    }
                ]
            },
            "Condition": {
                "ScalableCurrency": "true"
            }
        }
    }
    
    
    # Send request
    response = requests.post(
        post_url,
        headers={
            "Authorization": f"Token {REFINITIV_AUTH_TOKEN}",
            "Content-Type": "application/json",
            "Prefer": "respond-async"
        },
        json=json_blob
    )
    
    # If successful, return the extracted data
    if response.status_code == 200:
        intraday_data = response.json()
        logger.info(f"Intraday data retrieved successfully for {ticker}.")
        return intraday_data
    
    # If request is still processing, log and return None
    elif response.status_code == 202:
        logger.info(f"Request for {ticker} is being processed (202 Accepted). Data is not yet available.")
        return None
    
    # Log other errors
    else:
        logger.error(f"Failed to fetch intraday data for {ticker}. Status Code: {response.status_code}, Response: {response.text}")
        return None
    
    
    # Example usage:
    if __name__ == "__main__":
        intraday_data = get_intraday_data("SPX500")
        if intraday_data:
            print(json.dumps(intraday_data, indent=4))
    
    

    My response is this:

    INFO:main:Fetching intraday data for SPX500...
    ERROR:main:Failed to fetch intraday data for SPX500. Status Code: 403, Response: {"error":{"message":"No permission for template "IntradayPricingReportTemplate"."}}


    does that mean I have to upgrade my API key?

    the whole point of this is to see if I can download the market order book right? Is there a general time of day when the books are all ready for download? Around 6pm EST right? My api key needs to be upgraded to see if I can download the order book it seems right?

  • Jwan622
    Jwan622 Newcomer

    I get this resopnse

    INFO:main:Fetching intraday data for SPX500...
    ERROR:main:Failed to fetch intraday data for SPX500. Status Code: 403, Response: {"error":{"message":"No permission for template "IntradayPricingReportTemplate"."}}

  • {"error":{"message":"No permission for template "IntradayPricingReportTemplate"."}}

    You will need to speak with your LSEG account manager to get entitlements for these report templates.