Newbie here how to Get previous day close any example please.
Thanks
Sai
Hello @saisaigraph
You can use Dhan Python library and dhan.historical_minute_charts
function.
This will get you historical daily OHLC data. From that, you can take close
value.
Hope this helps!
not helpful… sorry… can u give code example please…
simple example i am asking but no response so far… not sure what to think… we work in very fast pace international environments and this is not good guys… i hope you guys are making a note. Sorry.
Hello @saisaigraph
If you are looking for specific support here from Dhan team, then community might not be the best place, as threads can get missed by community members. You can rather reach out to our support team at help@dhan.co.
For your query, here’s the python function:
dhan.historical_minute_charts(symbol,exchange_segment,instrument_type,expiry_code,from_date,to_date)
For previous day close, you can use ‘from_date’ and ‘to_date’ accordingly.
Hi
I am not getting any data for the below call, please help.
dhan.historical_minute_charts(
symbol=symbol, #‘TCS’,
exchange_segment=‘NSE_EQ’,
instrument_type=‘EQUITY’,
expiry_code=0,
from_date=str(prev_day.date()) , #‘2023-10-12’
to_date=str(end_date.date()) #‘2023-10-12’
)
Thanks
Sai
Hello @saisaigraph
Over here, the start date (from_date) and end date (to_date) are non-inclusive, which means you have to enter D-1 and D+1 date values to fetch data for that particular date ‘D’.
Modified per ur suggestion but still not getting
Here is the latest code:
prev_day_str = str(prev_day.date())
end_day_str = str(datetime.datetime.now().date())
historical_mins_data = dhan.historical_minute_charts(
symbol=symbol, #‘TCS’,
exchange_segment=‘NSE_EQ’,
instrument_type=‘EQUITY’,
expiry_code=0,
from_date= prev_day_str, #‘2023-10-12’
to_date=end_day_str #‘2023-10-13’
)
Please advise.
Thanks
Sai
Hello @saisaigraph
Do try with dates as 2023-10-11 and 2023-10-13. Also, what is the error message that you were getting in earlier case?