Last active
November 7, 2017 21:34
-
-
Save mlivingston40/35adab8d17fe17e549a813961ccbe048 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import quandl | |
import pandas as pd | |
class MeanReversion: | |
def __init__(self, security, start_date, end_date, sma_, lma_): | |
self.security = security | |
self.start_date = start_date | |
self.end_date = end_date | |
self.sma_ = sma_ | |
self.lma_ = lma_ | |
self.data = quandl.get("WIKI/{}".format(self.security), | |
start_date=self.start_date, | |
end_date=self.end_date) | |
def moving_average_df(self, ma): | |
return pd.DataFrame(self.data['Adj. Close'].rolling(window=ma, | |
center=False).mean().dropna()) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment