Hello,
I am a relative newbie to both python and quantopian
I am trying to get a stock series and want to fill in NaN for the non trading days. I am trying the reindex function but it fills NaN for all the days.
Could somebody please guide me?
Thanks,
najmuddin
Code and output is below
Research environment functions
from quantopian.research import prices, symbols
Pandas library: https://pandas.pydata.org/
import pandas as pd
Query historical pricing data for AAPL
aapl_close = prices(
assets=symbols('AAPL'),
start='2017-01-01',
end='2017-01-31'
)
aapl_close.reindex(pd.DatetimeIndex(start='2017-01-01',end='2017-01-31', freq='D'))
Output:
2017-01-01 NaN
2017-01-02 NaN
2017-01-03 NaN
2017-01-04 NaN
2017-01-05 NaN
2017-01-06 NaN
2017-01-07 NaN
2017-01-08 NaN
2017-01-09 NaN
2017-01-10 NaN
2017-01-11 NaN
2017-01-12 NaN