I tried to get historical daily data on 9/11/2024 at 4AM. The historical data is being only shown till 9/9/2024.
my code
def get_upstox_data(ticker,start,end):
url = f’https://api.upstox.com/v2/historical-candle/{ticker}/day/{end}/{start}’
headers = {
‘Accept’: ‘application/json’
}response = requests.get(url, headers=headers) if response.status_code == 200: # Do something with the response data (e.g., print it) return pd.DataFrame(response.json()['data']['candles']).sort_values(by=0) else: # Print an error message if the request was not successful print(f"Error: {response.status_code} - {response.text}") return None
sample_df = get_upstox_data(‘NSE_EQ|INE825A01020’,‘2024-01-01’,‘2024-12-31’)
Sample response:
4 | 2024-09-03T00:00:00+05:30 | 491.00 | 497.00 | 486.10 | 490.05 | 214501 | 0 |
---|---|---|---|---|---|---|---|
3 | 2024-09-04T00:00:00+05:30 | 491.00 | 497.25 | 487.05 | 488.75 | 175234 | 0 |
2 | 2024-09-05T00:00:00+05:30 | 494.50 | 497.10 | 485.00 | 488.25 | 205990 | 0 |
1 | 2024-09-06T00:00:00+05:30 | 492.00 | 500.00 | 481.95 | 483.40 | 341022 | 0 |
0 | 2024-09-09T00:00:00+05:30 | 498.00 | 498.95 | 478.05 | 493.50 | 296735 | 0 |