Using Fyers API, the max timeframe I can use is ‘D’ to fetch the history data.
However, I would like to fetch the Weekly and Monthly data as well. How can I achieve that ?
Thanks in advance.
Hi,
There is no option to fetch weekly OHLC data. But the workaround is to fetch the Daily candle data and use pandas library to resample the data for a weekly bases.
ohlc.resample('W').agg({'open': 'first', 'high': 'max', 'low': 'min', 'close': 'last'}).dropna()
Hi @rajesh_newbie,
A separate API is not available for weekly OHLC data. However, the day OHLC is provided to you by using that, you can calculate it on your own.
Hello,
You can use the following.
ohlc_dict = {‘Open’:‘first’,‘High’:‘max’,‘Low’:‘min’,‘Close’: ‘last’}
weekly_df=daily_df.resample(‘W-MON’,closed=‘left’, label=‘left’).apply(ohlc_dict)
This will give you data exactly as Trading View.
Thanks
do we need to convert the date column as well? as it is in EPOCH
Do we need to convert the date column and index it ?
Hi @vijay.wh2tii0n
You fetch the daily data first , now you have the 1 D data
Now do your own calculation for it and make it weekly
I told you logic.
Let say total 5 days are in a week.
So in all 5 days which is the high , it will be high of week
Same for low
And for opening first day candle opening will be opening price
and last day candle closing will be closing price
It is simple.