Hi Folks,
Using historic API here. Noticed that there are monthly rows with same month
Any particular reason why I am getting these? Also any way to fix these, code change or different API or diff param?
Here is the code
from future import print_function
import time
import upstox_client
from upstox_client.rest import ApiException
from pprint import pprint
import pandas as pd
api_instance = upstox_client.HistoryApi()
instrument_key = ‘NSE_EQ|INE144J01027’ # str |
interval = ‘month’ # str |
to_date = ‘2024-09-08’ # str |
from_date = ‘1990-01-01’ # str |
api_version = ‘v2’ # str | API Version Header
try:
api_response = api_instance.get_historical_candle_data1(instrument_key, interval, to_date, from_date, api_version)
except ApiException as e:
print(“Exception when calling HistoryApi->get_historical_candle_data1: %s\n” % e)
data_list = api_response.to_dict()[‘data’][‘candles’]
data_list.reverse()
data_df = pd.DataFrame(data_list)
data_df.rename(columns={0:‘Date’, 1:‘Open’, 2:‘High’, 3:‘Low’, 4:‘Close’, 5:‘Volumn’}, inplace=True)
data_df[‘Date’] = pd.to_datetime(data_df[‘Date’], format=“%Y-%m-%dT%H:%M:%S%z”)
data_df[‘Date’] = data_df[‘Date’].dt.strftime(“%d-%m-%Y”)
data_df = data_df.drop(columns=[6])
data_df.to_csv(‘./20MICRONS.csv’, index=False)