Query on python build coding

how can i get previous trading day by using current date

Hi @Kiran_Thomas ,

The following code snippet retrieves the historical data as a pandas dataframe:

hist_data = self.get_historical_data(instrument)

You may print the dataframe as follows:


You can use the timestamp column to retrieve the previous day’s data from this dataframe.


if i am backtesting for a period 25/10/2023 9.15 to 3.15 , to execute my entry logic i need candle data from 24/10/2023 in code , what code will fetch that


Hi @Kiran_Thomas

This code snippet:
hist_data = self.get_historical_data(instrument)

should help you get the candle data for 24/10/2023.

Try to use the timestamp column from the hist_data dataframe to extract the data for the date you want.

Check if this stackoverflow post helps you to understand how to extract data using timestamps.

Hope this helps.