question

Upvotes
Accepted
1 1 3 7

I am stuck while trying TRTH Python code. How can I get help in this?

tick-history-rest-apirest-api
icon clock
10 |1500

Up to 2 attachments (including images) can be used with a maximum of 5.0 MiB each and 10.0 MiB total.

@sreedhanya.kavunkara, please tell us exactly:

  • What code you are using (is this an existing sample, or something you made). If it is your own code, or if you modified an existing sample, then please post it as an attachment.
  • What makes you say it is "stuck". What are the symptoms or error messages you observe ?

1 Answer

Upvotes
Accepted
13.7k 26 8 12

@sreedhanya.kavunkara,

You want to pull end of day data (TRADE_DATE and LAST_PRICE) for around 25000 RICs everyday.

How to identify the API call that delivers the fields you want

You can use the data dictionary to identify which calls deliver the fields you want. In sheet Field Descriptions, search in column Field Name for Last, and you will see that the Elektron Timeseries call delivers it. It also delivers a Trade Date.

A call can be done On Demand or be scheduled. These 2 approaches are described in the Tutorials Introduction.

The Elektron TimeSeries call

The Elektron Timeseries call delivers End of Day data. REST API Tutorial 7 describes this call and its parameters, done using an On Demand request, with the 2 fields you are interested in (and a few more). You can refer to the API Reference Tree for additional information on the parameters (you must first select the appropriate call in the first parameter's dropdown, i.e. ElektronTimeSeriesExtractionRequest).

Implement the call in your Python code

We do not have a Python sample for this call, but it would be easy for you to make one, using the TRTH_OnDemand_IntradayBars sample (available in the downloads) as a starting point. In step 2 you need to implement a way to populate the InstrumentIdentifiers array. You must change the requestBody to do an Elektron Timeseries call, with your parameters. As you have 25k instruments, delete step 4. Step 5 will save the data to file. Step 6 can be deleted as well, it is purely cosmetic.

icon clock
10 |1500

Up to 2 attachments (including images) can be used with a maximum of 5.0 MiB each and 10.0 MiB total.

@sreedhanya.kavunkara, a new version of the on demand Python sample is available under the downloads tab. It has been enhanced to manage an eventual initial HTTP 200 response (which is rare but could happen, as you saw when changing the type of request). Hope this helps.

Click below to post an Idea Post Idea