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?