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:
Result:
Thanks in advance,
@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) -1df
@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
Thanks for your time.
It doesn't work. The reason is: "The field TR.PricePctChg1D is not available as timeseries."