This file contains hidden or 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 pandas as pd | |
| oc = pd.DataFrame([line.strip('\n').split(',') for line in open('../../Downloads/quotedata.dat')]) | |
| oc.head() | |
| oc.columns = oc.loc[2, :] | |
| oc = oc.loc[3:] | |
| oc['Calls K'] = oc.apply(lambda x: float(x['Calls'][-6:-2])/10, axis=1) | |
| oc['Puts K'] = oc.apply(lambda x: float(x['Puts'][-6:-2])/10, axis=1) |
This file contains hidden or 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 alpaca_trade_api as tradeapi | |
| import time | |
| import datetime | |
| from datetime import timedelta | |
| from pytz import timezone | |
| tz = timezone('EST') | |
| import numpy as np | |
| import pandas as pd |
This file contains hidden or 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 alpaca_trade_api as tradeapi | |
| import time | |
| import datetime | |
| from datetime import timedelta | |
| from pytz import timezone | |
| tz = timezone('EST') | |
| api = tradeapi.REST('your key', | |
| 'your secret', | |
| 'https://paper-api.alpaca.markets') |
This file contains hidden or 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
| from sklearn.qda import QDA | |
| #from sklearn.ensemble import RandomForestRegressor | |
| from sklearn import preprocessing | |
| import numpy as np | |
| import pandas as pd | |
| def initialize(context): | |
| context.assets = sid(8554) # Trade SPY | |
| context.model = QDA() | |
| context.lookback = 5 # Look back |
NewerOlder