Gap-up Gap-down different ways calculating returns

Course: Day Trading Strategies for Beginners

Section 6

Lesson 10 (Gap strategy) and 17 (Improved gap strategy)



Hello there,



I've a doubt about the way we're calculating returns before calculating returns of the strategy. In lesson 10 we've calculated returns in the following way:

 

# Returns from today's close to today's open
returns = (data["Adj Close"]  - data["Adj Open"]) / data["Adj Open"]

And after that we calculated the returns of the portfolio:
# Portfolio returns
data["strategy_returns"] = returns * data.positions
Note that we used an approach of calculating returns from today's close to today's open before calculating the portfolio returns.

However in lesson 17 we've changed the approach:
# Calculating returns from today's open to yesterday's close
data['returns'] = (data["Adj Open"]-data["Adj Close"].shift(1)) / data["Adj Close"].shift(1)
And using these returns we calculated standard deviation:
data["std"] = data["returns"].rolling(90).std()

But, at the end, calculating portfolio's returns again we use the same logic used in lesson 10:

# Using lesson's 10 approach: from today's close to today's open
data["strategy_returns"] = (data["Adj Close"] - data["Adj Open"]) / data["Adj Open"] * data.positions

Why is this difference?

Hi Daniel,



So, in the Gap Strategy, there is only one entry condition, gap-up or gap-down. We take a long trade in case of a gap-up and vice versa. However, in the improved gap strategy, we are generating signals by comparing the daily returns of the asset on a close-to-close basis and the 0.25 standard deviation of daily returns. This thing is only for the signal generation part. Now, to calculate the strategy returns, we are using the same thing in both strategies, i.e. multiplying the intraday returns with the positions.



Hope this helps! Please do let me know if you have any other queries.



Thanks,

Akshay

All clear, thank you!