Dear all,
is there a way to get various month end price percentage change with respect to the opening price of the year? I tested the below but unable to do so. So far I am able to get the DataFrame of data but unable to retrieve the value within to calculate percentage change.
jan_start_p = get_pricing('SPY', start_date='2018-01-02', end_date='2018-01-02', symbol_reference_date=None,
frequency='daily', fields=None, handle_missing='raise', start_offset=0)
jan_open = jan_start_p['open_price']
end_jan_p = get_pricing('SPY', start_date='2018-01-31', end_date='2018-01-31', symbol_reference_date=None,
frequency='daily', fields=None, handle_missing='raise', start_offset=0)
end_jan = end_jan_p['close_price']
end_jan_change = (end_jan / jan_open - 1)*100
end_jan_change
output: 2018-01-02 00:00:00+00:00 NaN
2018-01-31 00:00:00+00:00 NaN
dtype: float64
Appreciate your advice. Thank you.
Regards,
MH