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
.
This exercise is part of the course
Financial Trading in Python
Hands-on interactive exercise
Have a go at this exercise by completing this sample code.
# Calculate the EMA
ema['Close'] = ____(price_data['Close'], ____)