Member-only story

Backtest Entropy Bollinger Band Strategy Using Python with Equities Data Part III

Amit Kumar Ghosh
5 min readAug 29, 2023

--

Let’s jump directly to the discussion from where we had left in the last part. So far We have checked out the trade performance and, analyzed those details with various popular trading metrics to get an overview of the strength of our strategy.

In this part, We will apply the same to Equities data.

Click here to read the First Part

Click here to read the Second Part

The Core Differences

While the main core of the entire strategy and pseudo-code is similar, here are key differences –

  1. In Equity, We do not have different instrument_token for different expiry. So, We can backtest the entire dataset!
  2. The code for getting the price the stock and high of the stock has to be changed and modified to get the equity data instead of derivative data.

So, rewriting the code to get the equity price at the time of trade –

#Price At The Particular Time

import datetime

# Your code here

# Create a function to get the price and high of a stock at a specific time
def get_stock_data(symbol, time):

# Define the start and end date
start_date = pd.Timestamp(time)
end_date = start_date + datetime.timedelta(minutes=5)

# Convert start and end date to string format
from_date = start_date.strftime('%Y-%m-%d %H:%M:%S')


# Fetch historical data for the stock…

--

--

Amit Kumar Ghosh
Amit Kumar Ghosh

Written by Amit Kumar Ghosh

Aloha, I’m Amit Ghosh, a web entrepreneur and avid blogger. Bitten by entrepreneurial bug, I got kicked out from college and ended up being millionaire!

No responses yet