Skip to content

Instantly share code, notes, and snippets.

View FrederikBussler's full-sized avatar

Frederik Bussler FrederikBussler

View GitHub Profile
| Name | Time | Deaths |
|---------------|--------------|------------------------------|
| Spanish Flu | 1918-1919 | 40-50M |
| Asian Flu | 1957-1958 | 1.1M |
| Hong Kong Flu | 1968-1970 | 1M |
| HIV/AIDS | 1981-present | 25-35M |
| Swine Flu | 2009-2010 | 200,000 |
| SARS | 2002-2003 | 770 |
| Ebola | 2014-2016 | 11,000 |
| MERS | 2015-present | 912 |
strats = ['returns'] # 19
for col in cols: # 20
strat = 'strategy_%s' % col.split('_')[1] # 21
df[strat] = df[col].shift(1) * df['returns'] # 22
strats.append(strat) # 23
df[strats].dropna().cumsum().apply(np.exp).plot() # 24
df['returns'] = np.log(df['closeAsk'] / df['closeAsk'].shift(1)) # 12
cols = [] # 13
for momentum in [15, 30, 60, 120]: # 14
col = 'position_%s' % momentum # 15
df[col] = np.sign(df['returns'].rolling(momentum).mean()) # 16
cols.append(col) # 17
data = oanda.get_history(instrument='EUR_USD', # our instrument
start='2016-12-08', # start data
end='2016-12-10', # end date
granularity='M1') # minute bars # 7
import pandas as pd # get your dependencies
df = pd.read_csv(‘example.csv’) # read the data
df.head(1) # look at the data and make sure you’re changing the right column
df.rename(columns={'oldName': 'newName'}, inplace=True) # rename the column