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 ...
Get Test-Driven Python Development now with the O’Reilly learning platform.
O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.