How to select previous trading day closing price of Banknifty Futures

instrument = alice.get_instrument_by_symbol(‘NFO’, ‘BANKNIFTY29FEB24F’)
print(instrument)

from_datetime = datetime.datetime(2024, 2, 12) # From last 5 days
to_datetime = datetime.datetime(2024, 2, 12) # To now
interval = “D” # [“1”, “D”]

historical_data = alice.get_historical(instrument, from_datetime, to_datetime, interval)
print(historical_data)

last_close_price = historical_data[‘close’].iloc[-1]
print(“Closing Price of the Last Minute:”, last_close_price)

Store the closing price for later use

closeprice = last_close_price

Now you can use ‘stored_close_price’ in your subsequent code

print(“Closing Price:”, closeprice)