Build an EMA-based signal strategy
Previously, you implemented an SMA-based signal strategy. However, you are wondering whether the EMA (exponential moving average) indicator is a better choice since it is more sensitive to recent price movement. You also would like to leverage the talib
library to calculate the indicator. After switching to an EMA-based signal strategy, you will perform a similar backtest using the Apple stock price data.
The bt
and talib
packages have been imported for you. Also, the historical price data of the Apple stock has been preloaded in price_data
.
Cet exercice fait partie du cours
Financial Trading in Python
Exercice interactif pratique
Essayez cet exercice en complétant cet exemple de code.
# Calculate the EMA
ema['Close'] = ____(price_data['Close'], ____)