Hi team,
If I want to extract data only for a paticular day in a week, for example data of past 20 Mondays only. Do we have a provision for that?
Regards,
Kashish Jain
There is no api that filters by day of week. But doing this is straightforward with pandas datetime index dayofweek attribute. Query data.history for daily bars and then filter for the target day of week, See example below for Mondays (dayofweek==0):
px = data.history(asset,['close','open'],20*5,'1d')
px = px[px.index.dayofweek==0]
Note: daily bar length 20*5 translates to roughly 20 business weeks, it should be close to 20 mondays but not guaranteed to be exactly 20.