Idirect-Tech / Breeze-Python-SDK

The official Python client library for the ICICI Securities trading APIs
MIT License
60 stars 30 forks source link

Incorrect closing Data. #42

Open shwapd04 opened 1 year ago

shwapd04 commented 1 year ago

Getting incorect closing data for many scripts. One example I am giving below. ***close data is very the actual value on that day was

Date Close
06/06/2023 15:30:00 284.93

{'exchange_code': 'NSE', 'exchange_stock_code': 'KANSAINER', 'isec_stock_code': 'KANNER', 'isec_token': '1196', 'company name': 'KANSAI NEROLAC PAINTS', 'isec_token_level1': '4.1!1196', 'isec_token_level2': '4.2!1196'} {'Error': None, 'Status': 200, 'Success': [{'close': 428.25, 'datetime': '2023-06-05 00:00:00', 'exchange_code': 'NSE', 'high': 431.4, 'low': 425.35, 'open': 430.1, 'stock_code': 'KANNER', 'volume': 108015}]} 428.25

def getClosingPrice(stockcode,stockdate): stockname=breeze.get_names(exchange_code = 'NSE',stock_code = stockcode)
print(stockname) icicistockcode=stockname['isec_stock_code'] historical_data = breeze.get_historical_data_v2(interval="1day", from_date='2023-06-05T00:00:00.000Z', to_date='2023-06-05T00:00:00.000Z', stock_code=icicistockcode, exchange_code="NSE", product_type="cash") print(historical_data)

Extract the closing price from the historical data.

#closing_price = historical_data["Success"][0]["close"]
return closing_price

iso_date = datetime.datetime.strptime('2022-08-01', "%Y-%m-%d").isoformat() + ".000Z"

iso_date='2023-06-05T00:00:00.000Z' closing_price=getClosingPrice('KANSAINER',iso_date) print(closing_price)

Rounak40 commented 11 months ago

The day you posted as actual value is 06/06/2023 15:30:00 But you are fetching 05/06/2023 in your code Change the date in your code. It should work then.