Implementing the dual crossover moving average
What we are going to do is to implement a method get_crossover_signal
for the Stock
class. The following are the requirements for the method:
- The method takes a date as a parameter, and returns if there is any crossover on that date
- The method should return
1
if there is a Buy Signal (5-day moving average crosses 10-day moving average from below to above on that date) - The method should return –1 if there is a Sell Signal (5-day moving average crosses 10-day moving average from above to below on that date)
- If there is no crossover, then the method returns 0 (neutral signal)
- The method should only take into account the closing price (the last update for the date), and not the opening or intermediate prices for the date
- If there are no updates for the date, then the method should use the previous closing price
- If there is not enough data to calculate the long-term moving average (we need closing prices for at least 11 days), then the method should...