Skip to content

Instantly share code, notes, and snippets.

@mlivingston40
Last active November 7, 2017 21:34
Show Gist options
  • Save mlivingston40/35adab8d17fe17e549a813961ccbe048 to your computer and use it in GitHub Desktop.
Save mlivingston40/35adab8d17fe17e549a813961ccbe048 to your computer and use it in GitHub Desktop.
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