Historic Data monthly data having multiple rows with same month

Hi Folks,

Using historic API here. Noticed that there are monthly rows with same month
image

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)

Any explanation here?

@Sourabh_Garg, we have successfully replicated the issue on our end and have forwarded the details to the relevant team.

Thank you.

1 Like

Hi,

Though I have switched to resampling of daily dataframe in pandas to create weekly and monthly data, which has reduced my count of fetching data from API also. Daily data also has duplicated rows, unlike above issue the whole rows was duplicate, easier to remove from my end.

If possible please update on the issue. These issue which are data related can go deep into your and our systems.

Thanks

Thank you for bringing this to our attention. We have informed the relevant team and will keep the thread updated with any progress.

1 Like