Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Branch 1 #5

Open
wants to merge 15 commits into
base: master
Choose a base branch
from
39 changes: 35 additions & 4 deletions problem1/problem1_template.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,11 @@
from sklearn import linear_model
from sklearn import metrics as sm
from problem1_trading_params import MyTradingParams
try:
from urllib2 import urlopen
except ImportError:
from urllib.request import urlopen
import collections

## Make your changes to the functions below.
## SPECIFY the symbols you are modeling for in getSymbolsToTrade() below
Expand All @@ -31,10 +36,7 @@ class MyTradingFunctions():
def __init__(self): #Put any global variables here
self.lookback = 1200 ## max number of historical datapoints you want at any given time
self.targetVariable = 'Y'
if datetime.today() < datetime(2018, 7, 3):
self.dataSetId = 'QQ3DataSample'
else:
self.dataSetId = 'QQ3DataDownSampled'
self.dataSetId = ''
self.params = {}

# for example you can import and store an ML model from scikit learn in this dict
Expand Down Expand Up @@ -260,8 +262,37 @@ def computeForInstrument(cls, updateNum, time, featureParams, featureKey, instru
else:
return currentValue * 0.5

def version():
try:
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@gandharv42 This looks good but lets make it a method so its mode modular and reusable in future.

f = open("currentversion","r")
response = urlopen("https://raw.githubusercontent.com/Auquan/data_set_id/master/versions.txt")
script = response.read().decode('utf8').split()
para = f.read().split()
f.close()
list= collections.defaultdict(lambda : '0')
for i in range(len(para)):
list[para[i]]=para[i]
for i in range(len(script)):
if(list[script[i]]!= script[i]):
list[script[i]] = script[i]
f = open("currentversion","a+")
f.write(script[i] + "\n")
new_response = urlopen("https://raw.githubusercontent.com/Auquan/data_set_id/master/" + script[i] + ".py")
code = new_response.read().decode('utf8')
exec(code)
except FileNotFoundError:
response = urlopen("https://raw.githubusercontent.com/Auquan/data_set_id/master/versions.txt")
script = response.read().decode('utf8').split()
for i in range(len(script)):
f = open("currentversion","a+")
f.write(script[i] + "\n")
new_response = urlopen("https://raw.githubusercontent.com/Auquan/data_set_id/master/" + script[i] + ".py")
code = new_response.read().decode('utf8')
exec(code)

if __name__ == "__main__":
version()

if updateCheck():
print('Your version of the auquan toolbox package is old. Please update by running the following command:')
print('pip install -U auquan_toolbox')
Expand Down
10 changes: 9 additions & 1 deletion problem1/problem1_trading_params.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,10 @@
import sys
from sklearn import linear_model
from sklearn import metrics as sm
try:
from urllib2 import urlopen
except ImportError:
from urllib.request import urlopen

## Make your changes to the functions below.
## SPECIFY the symbols you are modeling for in getSymbolsToTrade() below
Expand All @@ -32,7 +36,11 @@ class MyTradingParams(TradingSystemParameters):
'''
def __init__(self, tradingFunctions):
self.__tradingFunctions = tradingFunctions
self.__dataSetId = self.__tradingFunctions.getDataSetId()

url = "https://raw.githubusercontent.com/Auquan/data_set_id/master/DataSetId.txt"
response = urlopen(url)
self.__dataSetId = response.read().decode('utf8').rstrip() + self.__tradingFunctions.getDataSetId()

self.__instrumentIds = self.__tradingFunctions.getSymbolsToTrade()
self.__priceKey = 'F5'
self.__additionalInstrumentFeatureConfigDicts = []
Expand Down