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 couchbase.subdocument as SD | |
from couchbase.bucket import Bucket | |
# Connecting to DB | |
cb = Bucket('couchbase:///www', username = 'user_arsh',password='Amber252556!@') | |
# Creating DB | |
cb.upsert('55',{'55':[{'text':'text','user_id':'user_id','created_at':'created_at','time':'time'}]}) # only run once |
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
#!/usr/bin/python | |
# required imports | |
import requests | |
class TradeClient(object): | |
""" Client for tradidng through WebAPI | |
""" | |
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
""" | |
Important notes about model | |
Training Machine-Learning model is trained every Monday (I found that if I train my model every-day it shows less returns) | |
Trading is happening after each 10 minutes | |
Machine_learning Model: | |
I am using two independent Features: '5 minutes price change' and '15 minutes price change' |
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
# Use the previous 10 bars' movements to predict the next movement. | |
# Use a random forest classifier. More here: http://scikit-learn.org/stable/user_guide.html | |
#from sklearn.ensemble import RandomForestRegressor | |
import numpy as np | |
from sklearn.qda import QDA | |
def initialize(context): | |
context.security = sid(8554) # Trade SPY |
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
# Use the previous 10 bars' movements to predict the next movement. | |
# Use a random forest classifier. More here: http://scikit-learn.org/stable/user_guide.html | |
#from sklearn.ensemble import RandomForestRegressor | |
import numpy as np | |
from sklearn.linear_model import LogisticRegression | |
def initialize(context): | |
context.security = sid(8554) # Trade SPY | |
context.model = LogisticRegression() |
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
# Use the previous 10 bars' movements to predict the next movement. | |
# Use a random forest classifier. More here: http://scikit-learn.org/stable/user_guide.html | |
from sklearn.ensemble import RandomForestRegressor | |
import numpy as np | |
def initialize(context): | |
context.security = sid(8554) # Trade SPY | |
context.model = RandomForestRegressor() |
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
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 |
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
def getDiff(symbol,hours): | |
""" function to calculate Daily Returns | |
ohlc4 = (open+high+low+close)/4 | |
""" | |
delta = ohlc4_today(symbol)-ohlc_yesterday(hours) | |
return delta/ohlc_yesterday(hours) | |
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
from scipy.interpolate import interp1d | |
x= [1,2,3,4] | |
y = [1,2,12,25] | |
#x2 = np.arange(4,20) | |
#x2=[4,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20] | |
y21 = np.arange(0,9,100) | |
x2 = [4,4.5,4.8,5.5,6,9,10,11,12,13,14,15,18,18.5,19,19.5,21] | |
y2=[1,2,4,6,7,9,9,9,9,9,9,9,7,6,4,2,1] | |
#x = np.linspace(0, 10, num=11, endpoint=True) | |
#y = np.cos(-x**2/9.0) |
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
'xrd55u92qftq' | |
import requests | |
import os | |
os.chdir('/home/metal-machine/hello/') | |
pdf_files = os.listdir(".") | |
for pdf_file in pdf_files: | |
print pdf_file | |
files = {'f': (pdf_file, open(pdf_file, 'rb'))} | |
#response = requests.post("https://pdftables.com/api?key=xrd55u92qftq&format=xlsx-single", files=files) |