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
apiVersion: apps/v1 | |
kind: Deployment | |
metadata: | |
labels: | |
service: storagenode | |
name: storagenode | |
namespace: storj | |
spec: | |
replicas: 1 | |
selector: |
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 getDecision(dfrow): | |
if dfrow['trend_aroon_ind'] <= 10.0: | |
if dfrow['volatility_dcp'] <= 0.69: | |
if dfrow['volatility_dcp'] <= 0.46: | |
return 0 | |
else: # if dfrow['volatility_dcp'] > 0.46 | |
if dfrow['trend_aroon_down'] <= 34.0: | |
return 1 | |
else: # if dfrow['trend_aroon_down'] > 34.0 | |
return 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
from sklearn.tree import _tree | |
def tree_to_code(tree, feature_names): | |
tree_ = tree.tree_ | |
feature_name = [ | |
feature_names[i] if i != _tree.TREE_UNDEFINED else "undefined!" | |
for i in tree_.feature | |
] | |
feature_names = [f.replace(" ", "_")[:-5] for f in feature_names] | |
print("def getDecision(dfrow):") |
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 graphviz | |
dot_data = export_graphviz(clf, out_file=None, | |
feature_names=X.columns, | |
class_names=["sell", "buy"], | |
filled=True, rounded=True, | |
special_characters=True) | |
graph = graphviz.Source(dot_data) | |
graph |
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 tqdm import tqdm | |
bestDepth = -1 | |
bestLeafes = -1 | |
bestLookback = -1 | |
bestDepthWin = -9999 | |
collection = [] | |
# explicitly force a max of 20 to prevent overfitting | |
for depth in tqdm([100,70,50,40,30,20,15]): | |
for leafes in [100,70,50,40,30,20,15]: |
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
bigDf = [] | |
for ticker in ["CWEG.L", "IWDA.AS", "EEM", "AAPL", "MSFT", "GOOG", "TSLA", 'AMD', 'AMZN', 'DG', "ETH-USD", "BTC-USD"]: | |
print("geddin stock: " + ticker) | |
tmp = getData(ticker = ticker, start = date(2010,1,1)) | |
tmp = getTrend(tmp) | |
bigDf.append(tmp) | |
bigDf = pd.concat(bigDf) | |
bigDf.shape |
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 import metrics, DecisionTreeClassifier | |
X, Y = df.drop(["signal"], axis=1), df["signal"] | |
clf = DecisionTreeClassifier() | |
clf.fit(X, Y) | |
preds = clf.predict(X) | |
print(metrics.classification_report(Y, preds)) | |
print(metrics.confusion_matrix(Y, preds)) |
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 random import random | |
class FakeModel: | |
def predict(self, X): | |
# random decision for demo purposes | |
preds = [] | |
for i in range(len(X)): | |
if random() > .5: | |
preds.append(1) | |
else: | |
preds.append(-1) |
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 oneRun(model): | |
global X | |
bestLookbackWin = -9999 | |
bestLookbackPortfolio = [] | |
money = startMoney | |
nrStocks = 0 | |
portfolio = [] | |
for i in range(len(X)): | |
prednow = model.predict(X.iloc[i])[0] | |
print("prednow is, " , prednow) |
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
startMoney = 10000 | |
COMMISSION = 0.00025 # interactive brokers commission | |
howmany = startMoney / msft.iloc[0]["Adj Close"] | |
win = howmany * msft.iloc[-1]["Adj Close"] - startMoney | |
days = (msft.index[-1] - msft.index[0]).days | |
print("with just holding you would have made %.2f$" % win) | |
winPerMonth = win / (days / 30) | |
winPctPerYear = winPerMonth * 12 / startMoney * 100 |
NewerOlder