For a deeper look into our Eikon Data API, look into:

Overview |  Quickstart |  Documentation |  Downloads |  Tutorials |  Articles

question

Upvotes
Accepted
3 0 0 5

Retreive historical data for daily price change percent

Hello,

I tried to retrieve historical data for price change percent and price daily. The price part is ok but just last price change percent shows up.

Code:

1626283410320.png

Result:

1626283453274.png

Thanks in advance,

eikoneikon-data-apiworkspaceworkspace-data-apirefinitiv-dataplatform-eikon
1626283410320.png (11.6 KiB)
1626283453274.png (44.5 KiB)
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.

Upvote
Accepted
39.2k 75 11 27

@Fatemeh

The field TR.PricePctChg1D is not available as timeseries. In other words, it only returns the latest value and does not provide any history. See the answer on this thread for explanation how to check whether a field as available as timeseries or not.

Fortunately it's very easy to calculate percent change from the price history using pandas:

df, err = ek.get_data('.SPX',['TR.PriceCloseDate','TR.PriceClose'],
                     {'SDate':'2019-01-01','EDate':'2019-12-31'})
df['Percent Chg'] = df['Price Close']/df['Price Close'].shift(1) -1
df
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.

Thanks a lot.
Upvotes
6.7k 8 6 7

@Fatemeh you are requesting a daily percentage change with a monthly frequency - please try replacing the field with TR.PricePctChg1M

I hope this can help

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.

Thanks for your time.

It doesn't work. The reason is: "The field TR.PricePctChg1D is not available as timeseries."

Click below to post an Idea Post Idea