Shoonya-Dev / ShoonyaApi-py

139 stars 130 forks source link

How to pull data for a specific time? #8

Closed gaurav-260 closed 2 years ago

gaurav-260 commented 2 years ago

Say i want to pull any symbol data for 9:35 or 10:20 etc., how do we do that without downloading the entire time series and then filtering? Please help.

Shoonya-Dev commented 2 years ago

an example is provided in tests/test_tpseries.py

for the method get_time_price_series mention starttime to get the same.

gaurav-260 commented 2 years ago

The example provided pulls the entire time series. Is there an option to pull data for specific time - say 9:30:12 (hh:mm:ss)?

Additionally, if we keep the interval as 1min and put the start time and end time 1 min apart, nothing is returned. Please try running the below code and check

strt = datetime.datetime(year = 2022, month = 1, day = 6, hour=9, minute=20, second=0, tzinfo=tz).timestamp()

end = datetime.datetime(year = 2022, month = 1, day = 6, hour=9, minute=21, second=0, tzinfo=tz).timestamp()

Nifty = api.get_time_price_series(exchange='NFO', token='44240',starttime=strt,endtime=end, interval=1)

justlearning-anything commented 1 year ago

@gaurav-260 @Shoonya-Dev Any luck on passing the exact end date? I am trying to get just 1 day worth of data but API is returning maximum amount of data. Kindly suggest how to get just 1 hour data using start and end time? API examples doesn't show that clearly.

amitsomanmusic commented 2 months ago

import time

start_time = time.now() - timedelta(minutes=375) #or time.time() # use your trading days exact time period in minutes in place of 375. 375 is for indian markets 9:15 am - 3:30 pm

for specific time data i think its available only to the resolution of a minute and not seconds.