Member-only story
Backtest Entropy Bollinger Band Strategy Using Python with Equities Data Part III
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 –
- In Equity, We do not have different
instrument_token
for different expiry. So, We can backtest the entire dataset! - The code for getting the
price
the stock andhigh
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…