refactor(Project): move out load_data to utils, rename fetch_data to run_fetch_data, got classifiers to work (#38)

This commit is contained in:
Mark Aron Szulyovszky
2021-12-17 17:41:50 +01:00
committed by GitHub
parent cc7061b456
commit 0963df2087
94 changed files with 9704 additions and 84787 deletions
+4
View File
@@ -21,6 +21,10 @@ jobs:
# WANDB_API_KEY: ${{ secrets.WANDB_API_KEY }}
run: |
pytest --junit-xml pytest.xml
- name: Run pipeline
shell: bash -l {0}
run: |
python run_pipeline.py
- name: Upload Unit Test Results
if: always()
uses: actions/upload-artifact@v2
+1 -1
View File
@@ -9,7 +9,7 @@ from pytorch_forecasting.metrics import QuantileLoss
import sys
sys.path.insert(0, '..')
from load_data import load_files
from utils.load_data import load_files
print("success")
+1 -1
View File
@@ -8,7 +8,7 @@ from pytorch_forecasting.metrics import QuantileLoss
import sys
sys.path.insert(0, '..')
from load_data import load_files
from utils.load_data import load_files
print("success")
+1 -1
View File
@@ -10,7 +10,7 @@ warnings.filterwarnings("ignore")
import sys
sys.path.insert(0, '..')
from load_data import load_files
from utils.load_data import load_files
+1 -1
View File
@@ -1,6 +1,6 @@
#%% Import all the stuff, load data, define constants
from sklearn.utils import shuffle
from load_data import load_files, create_target_classes
from utils.load_data import load_files, create_target_classes
import pandas as pd
from tensorflow import keras
from utils.normalize import normalize
+1 -1
View File
@@ -2,7 +2,7 @@
from sklearnex import patch_sklearn
patch_sklearn()
from load_data import create_target_cum_forward_returns, create_target_classes, load_files
from utils.load_data import create_target_cum_forward_returns, create_target_classes, load_files
from sktime.forecasting.model_selection import temporal_train_test_split
from sklearn.metrics import accuracy_score
from sklearn.metrics import confusion_matrix
@@ -2,7 +2,7 @@
from sklearnex import patch_sklearn
patch_sklearn()
from load_data import create_target_classes, load_files
from utils.load_data import create_target_classes, load_files
from sktime.forecasting.model_selection import temporal_train_test_split
from sklearn.metrics import accuracy_score
from sklearn.metrics import confusion_matrix
@@ -122,7 +122,7 @@ for model_name, create_model in models_to_try:
retrain_every = retrain_every
)
evaluate_predictions(model_name, y_train, preds, sliding_window_size)
evaluate_predictions(model_name, y_train, preds)
#%%
+1 -1
View File
@@ -1,5 +1,5 @@
#%% Import all the stuff, load data, define constants
from load_data import load_files, create_target_classes
from utils.load_data import load_files, create_target_classes
import pandas as pd
import numpy as np
from utils.sktime import from_df_to_sktime_data
+1 -1
View File
@@ -1,6 +1,6 @@
#%% Import all the stuff, load data, define constants
from sklearn.utils import shuffle
from load_data import load_files, create_target_cum_forward_returns
from utils.load_data import load_files, create_target_cum_forward_returns
import pandas as pd
from tensorflow import keras
from utils.normalize import normalize
+1 -1
View File
@@ -1,4 +1,4 @@
from load_data import load_files
from utils.load_data import load_files
import pandas as pd
# from tensorflow import keras
from utils.normalize import normalize
-1502
View File
File diff suppressed because it is too large Load Diff
-1502
View File
File diff suppressed because it is too large Load Diff
-1502
View File
File diff suppressed because it is too large Load Diff
-1502
View File
File diff suppressed because it is too large Load Diff
-1502
View File
File diff suppressed because it is too large Load Diff
-1502
View File
File diff suppressed because it is too large Load Diff
+5 -5
View File
@@ -1,8 +1,4 @@
time,high,low,open,close
2017-11-04,0.0243,0.02172,0.0223,0.02194
2017-11-05,0.02283,0.02062,0.02194,0.02069
2017-11-06,0.02324,0.01949,0.02069,0.02185
2017-11-07,0.02379,0.02145,0.02185,0.02209
2017-11-08,0.02754,0.02204,0.02209,0.02509
2017-11-09,0.03493,0.02396,0.02509,0.03223
2017-11-10,0.03014,0.02639,0.03223,0.02639
@@ -1499,4 +1495,8 @@ time,high,low,open,close
2021-12-10,1.332,1.208,1.291,1.211
2021-12-11,1.361,1.192,1.211,1.352
2021-12-12,1.414,1.321,1.352,1.347
2021-12-13,1.357,1.234,1.347,1.234
2021-12-13,1.357,1.203,1.347,1.225
2021-12-14,1.283,1.201,1.225,1.267
2021-12-15,1.331,1.206,1.267,1.311
2021-12-16,1.33,1.237,1.311,1.24
2021-12-17,1.258,1.185,1.24,1.2
1 time high low open close
2017-11-04 0.0243 0.02172 0.0223 0.02194
2017-11-05 0.02283 0.02062 0.02194 0.02069
2017-11-06 0.02324 0.01949 0.02069 0.02185
2017-11-07 0.02379 0.02145 0.02185 0.02209
2 2017-11-08 0.02754 0.02204 0.02209 0.02509
3 2017-11-09 0.03493 0.02396 0.02509 0.03223
4 2017-11-10 0.03014 0.02639 0.03223 0.02639
1495 2021-12-10 1.332 1.208 1.291 1.211
1496 2021-12-11 1.361 1.192 1.211 1.352
1497 2021-12-12 1.414 1.321 1.352 1.347
1498 2021-12-13 1.357 1.234 1.203 1.347 1.234 1.225
1499 2021-12-14 1.283 1.201 1.225 1.267
1500 2021-12-15 1.331 1.206 1.267 1.311
1501 2021-12-16 1.33 1.237 1.311 1.24
1502 2021-12-17 1.258 1.185 1.24 1.2
-1502
View File
File diff suppressed because it is too large Load Diff
+1502
View File
File diff suppressed because it is too large Load Diff
-1502
View File
File diff suppressed because it is too large Load Diff
-1502
View File
File diff suppressed because it is too large Load Diff
-1502
View File
File diff suppressed because it is too large Load Diff
-1502
View File
File diff suppressed because it is too large Load Diff
-1502
View File
File diff suppressed because it is too large Load Diff
-1502
View File
File diff suppressed because it is too large Load Diff
-1502
View File
File diff suppressed because it is too large Load Diff
+5 -5
View File
@@ -1,8 +1,4 @@
time,high,low,open,close
2017-11-04,1.695,1.385,1.461,1.638
2017-11-05,1.617,1.452,1.637,1.52
2017-11-06,1.692,1.464,1.52,1.573
2017-11-07,1.824,1.498,1.573,1.795
2017-11-08,2.045,1.768,1.795,2.029
2017-11-09,2.126,1.95,2.029,2.052
2017-11-10,1.906,1.656,2.052,1.826
@@ -1499,4 +1495,8 @@ time,high,low,open,close
2021-12-10,595.23,551.16,570.89,553.52
2021-12-11,573.17,542.58,553.52,564.19
2021-12-12,574.92,559.75,564.19,570.73
2021-12-13,572.4,523.14,570.73,523.5
2021-12-13,572.4,511.32,570.73,521.07
2021-12-14,535.88,510.3,521.07,528.6
2021-12-15,546.91,501.89,528.6,541.28
2021-12-16,545.44,524.97,541.28,526.08
2021-12-17,536.0,511.39,526.08,514.07
1 time high low open close
2017-11-04 1.695 1.385 1.461 1.638
2017-11-05 1.617 1.452 1.637 1.52
2017-11-06 1.692 1.464 1.52 1.573
2017-11-07 1.824 1.498 1.573 1.795
2 2017-11-08 2.045 1.768 1.795 2.029
3 2017-11-09 2.126 1.95 2.029 2.052
4 2017-11-10 1.906 1.656 2.052 1.826
1495 2021-12-10 595.23 551.16 570.89 553.52
1496 2021-12-11 573.17 542.58 553.52 564.19
1497 2021-12-12 574.92 559.75 564.19 570.73
1498 2021-12-13 572.4 523.14 511.32 570.73 523.5 521.07
1499 2021-12-14 535.88 510.3 521.07 528.6
1500 2021-12-15 546.91 501.89 528.6 541.28
1501 2021-12-16 545.44 524.97 541.28 526.08
1502 2021-12-17 536.0 511.39 526.08 514.07
-1502
View File
File diff suppressed because it is too large Load Diff
-1502
View File
File diff suppressed because it is too large Load Diff
-1502
View File
File diff suppressed because it is too large Load Diff
-1502
View File
File diff suppressed because it is too large Load Diff
-1502
View File
File diff suppressed because it is too large Load Diff
-1502
View File
File diff suppressed because it is too large Load Diff
-1502
View File
File diff suppressed because it is too large Load Diff
-1502
View File
File diff suppressed because it is too large Load Diff
-1502
View File
File diff suppressed because it is too large Load Diff
-1502
View File
File diff suppressed because it is too large Load Diff
+5 -5
View File
@@ -1,8 +1,4 @@
time,high,low,open,close
2017-11-04,7492.24,6957.84,7146.98,7363.8
2017-11-05,7599.44,7284.33,7363.8,7389.55
2017-11-06,7429.7,6934.73,7389.55,6959.23
2017-11-07,7222.37,6957.8,6959.27,7102.75
2017-11-08,7869.1,7026.97,7102.23,7444.36
2017-11-09,7457.12,7040.83,7444.36,7129.59
2017-11-10,7318.97,6406.05,7129.59,6565.8
@@ -1499,4 +1495,8 @@ time,high,low,open,close
2021-12-10,50047.85,46989.42,47593.85,47191.14
2021-12-11,49504.07,46829.85,47191.14,49398.4
2021-12-12,50807.75,48689.25,49398.4,50109.99
2021-12-13,50215.42,47054.11,50109.99,47070.27
2021-12-13,50215.42,45800.52,50109.99,46731.03
2021-12-14,48665.63,46320.4,46731.03,48387.69
2021-12-15,49499.91,46562.1,48387.69,48885.05
2021-12-16,49451.4,47546.15,48885.05,47635.92
2021-12-17,48004.37,45585.05,47635.92,45727.16
1 time high low open close
2017-11-04 7492.24 6957.84 7146.98 7363.8
2017-11-05 7599.44 7284.33 7363.8 7389.55
2017-11-06 7429.7 6934.73 7389.55 6959.23
2017-11-07 7222.37 6957.8 6959.27 7102.75
2 2017-11-08 7869.1 7026.97 7102.23 7444.36
3 2017-11-09 7457.12 7040.83 7444.36 7129.59
4 2017-11-10 7318.97 6406.05 7129.59 6565.8
1495 2021-12-10 50047.85 46989.42 47593.85 47191.14
1496 2021-12-11 49504.07 46829.85 47191.14 49398.4
1497 2021-12-12 50807.75 48689.25 49398.4 50109.99
1498 2021-12-13 50215.42 47054.11 45800.52 50109.99 47070.27 46731.03
1499 2021-12-14 48665.63 46320.4 46731.03 48387.69
1500 2021-12-15 49499.91 46562.1 48387.69 48885.05
1501 2021-12-16 49451.4 47546.15 48885.05 47635.92
1502 2021-12-17 48004.37 45585.05 47635.92 45727.16
-1502
View File
File diff suppressed because it is too large Load Diff
-1502
View File
File diff suppressed because it is too large Load Diff
-1502
View File
File diff suppressed because it is too large Load Diff
-1502
View File
File diff suppressed because it is too large Load Diff
-1502
View File
File diff suppressed because it is too large Load Diff
+5 -5
View File
@@ -1,8 +1,4 @@
time,high,low,open,close
2017-11-04,0.0,0.0,0.0,0.0
2017-11-05,0.0,0.0,0.0,0.0
2017-11-06,0.0,0.0,0.0,0.0
2017-11-07,0.0,0.0,0.0,0.0
2017-11-08,0.0,0.0,0.0,0.0
2017-11-09,0.0,0.0,0.0,0.0
2017-11-10,0.0,0.0,0.0,0.0
@@ -1499,4 +1495,8 @@ time,high,low,open,close
2021-12-10,28.43,25.7,26.95,26.42
2021-12-11,28.18,25.83,26.42,27.8
2021-12-12,30.01,27.34,27.8,29.59
2021-12-13,29.86,26.31,29.59,26.31
2021-12-13,29.86,25.56,29.59,25.96
2021-12-14,26.69,25.01,25.96,26.21
2021-12-15,28.04,24.28,26.21,27.16
2021-12-16,27.84,25.83,27.16,26.02
2021-12-17,26.21,24.2,26.02,24.49
1 time high low open close
2017-11-04 0.0 0.0 0.0 0.0
2017-11-05 0.0 0.0 0.0 0.0
2017-11-06 0.0 0.0 0.0 0.0
2017-11-07 0.0 0.0 0.0 0.0
2 2017-11-08 0.0 0.0 0.0 0.0
3 2017-11-09 0.0 0.0 0.0 0.0
4 2017-11-10 0.0 0.0 0.0 0.0
1495 2021-12-10 28.43 25.7 26.95 26.42
1496 2021-12-11 28.18 25.83 26.42 27.8
1497 2021-12-12 30.01 27.34 27.8 29.59
1498 2021-12-13 29.86 26.31 25.56 29.59 26.31 25.96
1499 2021-12-14 26.69 25.01 25.96 26.21
1500 2021-12-15 28.04 24.28 26.21 27.16
1501 2021-12-16 27.84 25.83 27.16 26.02
1502 2021-12-17 26.21 24.2 26.02 24.49
+1502
View File
File diff suppressed because it is too large Load Diff
-1502
View File
File diff suppressed because it is too large Load Diff
-1502
View File
File diff suppressed because it is too large Load Diff
-1502
View File
File diff suppressed because it is too large Load Diff
-1502
View File
File diff suppressed because it is too large Load Diff
-1502
View File
File diff suppressed because it is too large Load Diff
-1502
View File
File diff suppressed because it is too large Load Diff
-1502
View File
File diff suppressed because it is too large Load Diff
-1502
View File
File diff suppressed because it is too large Load Diff
+5 -5
View File
@@ -1,8 +1,4 @@
time,high,low,open,close
2017-11-04,304.65,294.05,304.51,300.04
2017-11-05,302.16,287.68,299.26,295.8
2017-11-06,306.8,292.26,296.22,296.82
2017-11-07,303.76,287.45,296.82,291.84
2017-11-08,319.2,290.55,291.84,307.35
2017-11-09,329.21,305.84,307.35,319.66
2017-11-10,324.22,288.96,319.67,296.86
@@ -1499,4 +1495,8 @@ time,high,low,open,close
2021-12-10,4229.29,3890.33,4111.92,3902.49
2021-12-11,4099.04,3835.8,3902.49,4088.68
2021-12-12,4179.55,3990.11,4088.68,4135.31
2021-12-13,4144.68,3769.76,4135.31,3776.88
2021-12-13,4144.68,3672.91,4135.31,3785.08
2021-12-14,3882.64,3687.79,3785.08,3862.18
2021-12-15,4095.28,3651.32,3862.18,4020.19
2021-12-16,4113.2,3953.97,4020.19,3957.03
2021-12-17,3994.8,3701.56,3957.03,3746.81
1 time high low open close
2017-11-04 304.65 294.05 304.51 300.04
2017-11-05 302.16 287.68 299.26 295.8
2017-11-06 306.8 292.26 296.22 296.82
2017-11-07 303.76 287.45 296.82 291.84
2 2017-11-08 319.2 290.55 291.84 307.35
3 2017-11-09 329.21 305.84 307.35 319.66
4 2017-11-10 324.22 288.96 319.67 296.86
1495 2021-12-10 4229.29 3890.33 4111.92 3902.49
1496 2021-12-11 4099.04 3835.8 3902.49 4088.68
1497 2021-12-12 4179.55 3990.11 4088.68 4135.31
1498 2021-12-13 4144.68 3769.76 3672.91 4135.31 3776.88 3785.08
1499 2021-12-14 3882.64 3687.79 3785.08 3862.18
1500 2021-12-15 4095.28 3651.32 3862.18 4020.19
1501 2021-12-16 4113.2 3953.97 4020.19 3957.03
1502 2021-12-17 3994.8 3701.56 3957.03 3746.81
-1502
View File
File diff suppressed because it is too large Load Diff
+5 -5
View File
@@ -1,8 +1,4 @@
time,high,low,open,close
2017-11-04,0.0,0.0,0.0,0.0
2017-11-05,0.0,0.0,0.0,0.0
2017-11-06,0.0,0.0,0.0,0.0
2017-11-07,0.0,0.0,0.0,0.0
2017-11-08,0.0,0.0,0.0,0.0
2017-11-09,0.0,0.0,0.0,0.0
2017-11-10,0.0,0.0,0.0,0.0
@@ -1499,4 +1495,8 @@ time,high,low,open,close
2021-12-10,41.35,37.45,37.53,39.91
2021-12-11,40.54,38.67,39.91,40.4
2021-12-12,40.56,38.74,40.4,39.77
2021-12-13,40.07,36.67,39.77,36.7
2021-12-13,40.07,35.27,39.77,35.89
2021-12-14,37.31,35.27,35.89,36.76
2021-12-15,38.92,35.64,36.76,38.22
2021-12-16,38.54,36.95,38.22,37.21
2021-12-17,39.0,35.71,37.21,35.9
1 time high low open close
2017-11-04 0.0 0.0 0.0 0.0
2017-11-05 0.0 0.0 0.0 0.0
2017-11-06 0.0 0.0 0.0 0.0
2017-11-07 0.0 0.0 0.0 0.0
2 2017-11-08 0.0 0.0 0.0 0.0
3 2017-11-09 0.0 0.0 0.0 0.0
4 2017-11-10 0.0 0.0 0.0 0.0
1495 2021-12-10 41.35 37.45 37.53 39.91
1496 2021-12-11 40.54 38.67 39.91 40.4
1497 2021-12-12 40.56 38.74 40.4 39.77
1498 2021-12-13 40.07 36.67 35.27 39.77 36.7 35.89
1499 2021-12-14 37.31 35.27 35.89 36.76
1500 2021-12-15 38.92 35.64 36.76 38.22
1501 2021-12-16 38.54 36.95 38.22 37.21
1502 2021-12-17 39.0 35.71 37.21 35.9
+4
View File
@@ -1027,3 +1027,7 @@ time,open,high,low,close,volume
2021-12-08,166.51,166.96,166.28,166.9,4288935.0
2021-12-09,166.54,166.58,165.65,165.88,4913771.0
2021-12-10,166.72,166.915,166.18,166.58,6450614.0
2021-12-13,166.9,167.255,166.67,167.0,6610673.0
2021-12-14,165.34,166.14,165.16,165.44,8637879.0
2021-12-15,165.27,166.4,163.8,166.15,14231184.0
2021-12-16,167.01,168.18,166.94,168.16,11186197.0
1 time open high low close volume
1027 2021-12-08 166.51 166.96 166.28 166.9 4288935.0
1028 2021-12-09 166.54 166.58 165.65 165.88 4913771.0
1029 2021-12-10 166.72 166.915 166.18 166.58 6450614.0
1030 2021-12-13 166.9 167.255 166.67 167.0 6610673.0
1031 2021-12-14 165.34 166.14 165.16 165.44 8637879.0
1032 2021-12-15 165.27 166.4 163.8 166.15 14231184.0
1033 2021-12-16 167.01 168.18 166.94 168.16 11186197.0
+1032 -1028
View File
File diff suppressed because it is too large Load Diff
-1502
View File
File diff suppressed because it is too large Load Diff
-1502
View File
File diff suppressed because it is too large Load Diff
-1502
View File
File diff suppressed because it is too large Load Diff
+5 -5
View File
@@ -1,8 +1,4 @@
time,high,low,open,close
2017-11-04,56.12,54.62,55.98,54.83
2017-11-05,55.45,54.43,54.84,54.6
2017-11-06,55.79,53.43,54.6,54.5
2017-11-07,63.49,54.47,54.5,60.52
2017-11-08,64.07,59.59,60.52,62.38
2017-11-09,66.9,61.59,62.38,64.15
2017-11-10,65.75,56.02,64.15,58.99
@@ -1499,4 +1495,8 @@ time,high,low,open,close
2021-12-10,159.86,147.79,151.5,148.53
2021-12-11,159.56,145.85,148.53,158.0
2021-12-12,162.91,153.39,158.0,159.1
2021-12-13,159.94,146.87,159.1,146.97
2021-12-13,159.94,142.82,159.1,144.66
2021-12-14,151.95,143.05,144.66,150.55
2021-12-15,155.05,141.77,150.55,153.58
2021-12-16,156.64,148.61,153.58,148.81
2021-12-17,150.31,141.35,148.81,142.71
1 time high low open close
2017-11-04 56.12 54.62 55.98 54.83
2017-11-05 55.45 54.43 54.84 54.6
2017-11-06 55.79 53.43 54.6 54.5
2017-11-07 63.49 54.47 54.5 60.52
2 2017-11-08 64.07 59.59 60.52 62.38
3 2017-11-09 66.9 61.59 62.38 64.15
4 2017-11-10 65.75 56.02 64.15 58.99
1495 2021-12-10 159.86 147.79 151.5 148.53
1496 2021-12-11 159.56 145.85 148.53 158.0
1497 2021-12-12 162.91 153.39 158.0 159.1
1498 2021-12-13 159.94 146.87 142.82 159.1 146.97 144.66
1499 2021-12-14 151.95 143.05 144.66 150.55
1500 2021-12-15 155.05 141.77 150.55 153.58
1501 2021-12-16 156.64 148.61 153.58 148.81
1502 2021-12-17 150.31 141.35 148.81 142.71
+4
View File
@@ -1027,3 +1027,7 @@ time,open,high,low,close,volume
2021-12-08,398.17,399.82,396.22,399.61,39204041.0
2021-12-09,398.35,400.2,393.5299,393.73,49973714.0
2021-12-10,396.62,398.28,393.36,398.01,52545767.0
2021-12-13,398.0,398.325,391.88,392.26,50166410.0
2021-12-14,387.3,390.09,383.63,388.2,75199181.0
2021-12-15,387.94,397.4198,383.88,397.05,73858028.0
2021-12-16,398.04,398.475,385.21,386.84,82591368.0
1 time open high low close volume
1027 2021-12-08 398.17 399.82 396.22 399.61 39204041.0
1028 2021-12-09 398.35 400.2 393.5299 393.73 49973714.0
1029 2021-12-10 396.62 398.28 393.36 398.01 52545767.0
1030 2021-12-13 398.0 398.325 391.88 392.26 50166410.0
1031 2021-12-14 387.3 390.09 383.63 388.2 75199181.0
1032 2021-12-15 387.94 397.4198 383.88 397.05 73858028.0
1033 2021-12-16 398.04 398.475 385.21 386.84 82591368.0
-1502
View File
File diff suppressed because it is too large Load Diff
-1502
View File
File diff suppressed because it is too large Load Diff
-1502
View File
File diff suppressed because it is too large Load Diff
-1502
View File
File diff suppressed because it is too large Load Diff
-1502
View File
File diff suppressed because it is too large Load Diff
+5 -5
View File
@@ -1,8 +1,4 @@
time,high,low,open,close
2017-11-04,0.0,0.0,0.0,0.0
2017-11-05,0.0,0.0,0.0,0.0
2017-11-06,0.0,0.0,0.0,0.0
2017-11-07,0.0,0.0,0.0,0.0
2017-11-08,0.0,0.0,0.0,0.0
2017-11-09,0.0,0.0,0.0,0.0
2017-11-10,0.0,0.0,0.0,0.0
@@ -1499,4 +1495,8 @@ time,high,low,open,close
2021-12-10,184.56,167.31,181.41,167.65
2021-12-11,173.8,161.48,167.65,172.08
2021-12-12,176.87,167.8,172.08,173.0
2021-12-13,173.0,155.92,173.0,156.29
2021-12-13,173.0,148.1,173.0,155.15
2021-12-14,163.17,149.67,155.15,161.43
2021-12-15,183.17,156.91,161.43,178.55
2021-12-16,189.3,174.51,178.55,176.92
2021-12-17,182.47,168.15,176.92,169.95
1 time high low open close
2017-11-04 0.0 0.0 0.0 0.0
2017-11-05 0.0 0.0 0.0 0.0
2017-11-06 0.0 0.0 0.0 0.0
2017-11-07 0.0 0.0 0.0 0.0
2 2017-11-08 0.0 0.0 0.0 0.0
3 2017-11-09 0.0 0.0 0.0 0.0
4 2017-11-10 0.0 0.0 0.0 0.0
1495 2021-12-10 184.56 167.31 181.41 167.65
1496 2021-12-11 173.8 161.48 167.65 172.08
1497 2021-12-12 176.87 167.8 172.08 173.0
1498 2021-12-13 173.0 155.92 148.1 173.0 156.29 155.15
1499 2021-12-14 163.17 149.67 155.15 161.43
1500 2021-12-15 183.17 156.91 161.43 178.55
1501 2021-12-16 189.3 174.51 178.55 176.92
1502 2021-12-17 182.47 168.15 176.92 169.95
-1502
View File
File diff suppressed because it is too large Load Diff
+4
View File
@@ -1027,3 +1027,7 @@ time,open,high,low,close,volume
2021-12-08,468.7,470.0,466.83,469.52,72238777.0
2021-12-09,468.15,469.6291,466.14,466.35,61272568.0
2021-12-10,469.23,470.9,466.51,470.74,77159757.0
2021-12-13,470.19,470.56,466.27,466.57,87724680.0
2021-12-14,463.09,465.74,460.25,463.36,97264128.0
2021-12-15,463.42,470.86,460.74,470.6,116899251.0
2021-12-16,472.57,472.87,464.8,466.45,116568626.0
1 time open high low close volume
1027 2021-12-08 468.7 470.0 466.83 469.52 72238777.0
1028 2021-12-09 468.15 469.6291 466.14 466.35 61272568.0
1029 2021-12-10 469.23 470.9 466.51 470.74 77159757.0
1030 2021-12-13 470.19 470.56 466.27 466.57 87724680.0
1031 2021-12-14 463.09 465.74 460.25 463.36 97264128.0
1032 2021-12-15 463.42 470.86 460.74 470.6 116899251.0
1033 2021-12-16 472.57 472.87 464.8 466.45 116568626.0
+1502
View File
File diff suppressed because it is too large Load Diff
+1032 -1028
View File
File diff suppressed because it is too large Load Diff
-1502
View File
File diff suppressed because it is too large Load Diff
+5 -5
View File
@@ -1,8 +1,4 @@
time,high,low,open,close
2017-11-04,0.0026,0.00215,0.00217,0.00218
2017-11-05,0.00255,0.00215,0.00218,0.00248
2017-11-06,0.00248,0.00182,0.00248,0.00183
2017-11-07,0.00234,0.00183,0.00183,0.00231
2017-11-08,0.00247,0.00215,0.00231,0.00236
2017-11-09,0.00246,0.00225,0.00236,0.00243
2017-11-10,0.00243,0.002,0.00243,0.00228
@@ -1499,4 +1495,8 @@ time,high,low,open,close
2021-12-10,0.09305,0.08754,0.08872,0.08778
2021-12-11,0.0919,0.08668,0.08778,0.09154
2021-12-12,0.09245,0.08986,0.09154,0.09109
2021-12-13,0.09156,0.08604,0.09109,0.08606
2021-12-13,0.09156,0.08423,0.09109,0.08504
2021-12-14,0.08775,0.0839,0.08504,0.08716
2021-12-15,0.08887,0.08298,0.08716,0.08758
2021-12-16,0.08818,0.08529,0.08758,0.08542
2021-12-17,0.08601,0.07859,0.08542,0.07927
1 time high low open close
2017-11-04 0.0026 0.00215 0.00217 0.00218
2017-11-05 0.00255 0.00215 0.00218 0.00248
2017-11-06 0.00248 0.00182 0.00248 0.00183
2017-11-07 0.00234 0.00183 0.00183 0.00231
2 2017-11-08 0.00247 0.00215 0.00231 0.00236
3 2017-11-09 0.00246 0.00225 0.00236 0.00243
4 2017-11-10 0.00243 0.002 0.00243 0.00228
1495 2021-12-10 0.09305 0.08754 0.08872 0.08778
1496 2021-12-11 0.0919 0.08668 0.08778 0.09154
1497 2021-12-12 0.09245 0.08986 0.09154 0.09109
1498 2021-12-13 0.09156 0.08604 0.08423 0.09109 0.08606 0.08504
1499 2021-12-14 0.08775 0.0839 0.08504 0.08716
1500 2021-12-15 0.08887 0.08298 0.08716 0.08758
1501 2021-12-16 0.08818 0.08529 0.08758 0.08542
1502 2021-12-17 0.08601 0.07859 0.08542 0.07927
-1502
View File
File diff suppressed because it is too large Load Diff
-1502
View File
File diff suppressed because it is too large Load Diff
+5 -5
View File
@@ -1,8 +1,4 @@
time,high,low,open,close
2017-11-04,0.0,0.0,0.0,0.0
2017-11-05,0.0,0.0,0.0,0.0
2017-11-06,0.0,0.0,0.0,0.0
2017-11-07,0.0,0.0,0.0,0.0
2017-11-08,0.0,0.0,0.0,0.0
2017-11-09,0.0,0.0,0.0,0.0
2017-11-10,0.0,0.0,0.0,0.0
@@ -1499,4 +1495,8 @@ time,high,low,open,close
2021-12-10,16.53,15.12,16.2,15.16
2021-12-11,16.74,14.97,15.16,15.88
2021-12-12,16.2,15.28,15.88,16.03
2021-12-13,16.09,14.44,16.03,14.47
2021-12-13,16.09,13.77,16.03,14.16
2021-12-14,15.08,13.93,14.16,15.0
2021-12-15,15.51,14.17,15.0,15.2
2021-12-16,15.37,14.36,15.2,14.42
2021-12-17,14.58,13.68,14.42,13.86
1 time high low open close
2017-11-04 0.0 0.0 0.0 0.0
2017-11-05 0.0 0.0 0.0 0.0
2017-11-06 0.0 0.0 0.0 0.0
2017-11-07 0.0 0.0 0.0 0.0
2 2017-11-08 0.0 0.0 0.0 0.0
3 2017-11-09 0.0 0.0 0.0 0.0
4 2017-11-10 0.0 0.0 0.0 0.0
1495 2021-12-10 16.53 15.12 16.2 15.16
1496 2021-12-11 16.74 14.97 15.16 15.88
1497 2021-12-12 16.2 15.28 15.88 16.03
1498 2021-12-13 16.09 14.44 13.77 16.03 14.47 14.16
1499 2021-12-14 15.08 13.93 14.16 15.0
1500 2021-12-15 15.51 14.17 15.0 15.2
1501 2021-12-16 15.37 14.36 15.2 14.42
1502 2021-12-17 14.58 13.68 14.42 13.86
+1502
View File
File diff suppressed because it is too large Load Diff
-1502
View File
File diff suppressed because it is too large Load Diff
-1502
View File
File diff suppressed because it is too large Load Diff
-1502
View File
File diff suppressed because it is too large Load Diff
-1502
View File
File diff suppressed because it is too large Load Diff
-1502
View File
File diff suppressed because it is too large Load Diff
+5 -5
View File
@@ -1,8 +1,4 @@
time,high,low,open,close
2017-11-04,0.2061,0.2001,0.2059,0.2015
2017-11-05,0.2033,0.1984,0.2014,0.1997
2017-11-06,0.2067,0.1981,0.1997,0.2013
2017-11-07,0.2065,0.1993,0.2013,0.2055
2017-11-08,0.2235,0.2031,0.2055,0.2167
2017-11-09,0.2218,0.2126,0.2167,0.2154
2017-11-10,0.2185,0.1988,0.2154,0.2033
@@ -1499,4 +1495,8 @@ time,high,low,open,close
2021-12-10,0.8823,0.7938,0.8594,0.7994
2021-12-11,0.844,0.7857,0.7994,0.8387
2021-12-12,0.8565,0.81,0.8387,0.8404
2021-12-13,0.8444,0.7938,0.8404,0.7948
2021-12-13,0.8444,0.7615,0.8404,0.7819
2021-12-14,0.8215,0.7734,0.7819,0.8117
2021-12-15,0.8398,0.7781,0.8117,0.8273
2021-12-16,0.8364,0.8038,0.8273,0.8054
2021-12-17,0.832,0.7766,0.8054,0.7831
1 time high low open close
2017-11-04 0.2061 0.2001 0.2059 0.2015
2017-11-05 0.2033 0.1984 0.2014 0.1997
2017-11-06 0.2067 0.1981 0.1997 0.2013
2017-11-07 0.2065 0.1993 0.2013 0.2055
2 2017-11-08 0.2235 0.2031 0.2055 0.2167
3 2017-11-09 0.2218 0.2126 0.2167 0.2154
4 2017-11-10 0.2185 0.1988 0.2154 0.2033
1495 2021-12-10 0.8823 0.7938 0.8594 0.7994
1496 2021-12-11 0.844 0.7857 0.7994 0.8387
1497 2021-12-12 0.8565 0.81 0.8387 0.8404
1498 2021-12-13 0.8444 0.7938 0.7615 0.8404 0.7948 0.7819
1499 2021-12-14 0.8215 0.7734 0.7819 0.8117
1500 2021-12-15 0.8398 0.7781 0.8117 0.8273
1501 2021-12-16 0.8364 0.8038 0.8273 0.8054
1502 2021-12-17 0.832 0.7766 0.8054 0.7831
+1502
View File
File diff suppressed because it is too large Load Diff
-26
View File
@@ -1,26 +0,0 @@
#%%
import pandas as pd
from utils.get_prices import get_crypto_price_crypto_compare, get_stock_price_av
from itertools import combinations
#%%
crypto_tickers = ["BTC", "ETH", "BNB", "ADA", "SOL", "XRP", "DOT", "LTC", "UNI", "TRX", "FIL", "USD"]
etf_tickers = ["GLD", "IEF", "TLT", "SPY", "QQQ"]
tickers = crypto_tickers + etf_tickers
#%%
for ticker in etf_tickers:
print("Fetching ", ticker)
df = get_stock_price_av(ticker, "2017-11-10")
df.to_csv(f"data/{ticker}.csv", index=True)
crypto_ticker_pairs = list(combinations(crypto_tickers, 2))
for src_ticker, trg_ticker in crypto_ticker_pairs:
print("Fetching ", src_ticker, trg_ticker)
df = get_crypto_price_crypto_compare(src_ticker, trg_ticker, 1500)
df.to_csv(f"data/{src_ticker}_{trg_ticker}.csv", index=True)
# %%
+22
View File
@@ -0,0 +1,22 @@
#%%
import pandas as pd
from utils.get_prices import get_crypto_price_crypto_compare, get_stock_price_av
#%%
crypto_tickers = ["BTC", "ETH", "BNB", "ADA", "SOL", "XRP", "DOT", "LTC", "UNI", "TRX", "XLM", "BCH", "FIL", "ETC", "THETA", "XTZ"]
etf_tickers = ["GLD", "IEF", "TLT", "SPY", "QQQ"]
#%%
for ticker in etf_tickers:
print("Fetching ", ticker)
df = get_stock_price_av(ticker, "2017-11-10")
df.to_csv(f"data/{ticker}.csv", index=True)
for src_ticker in crypto_tickers:
print("Fetching ", src_ticker, "USD")
df = get_crypto_price_crypto_compare(src_ticker, "USD", 1500)
df.to_csv(f"data/{src_ticker}_USD.csv", index=True)
+20 -19
View File
@@ -1,7 +1,7 @@
from sklearnex import patch_sklearn
patch_sklearn()
from load_data import get_crypto_assets, get_etf_assets, load_data
from utils.load_data import get_crypto_assets, get_etf_assets, load_data
import pandas as pd
import numpy as np
@@ -19,43 +19,44 @@ from training.pipeline import run_single_asset_trainig_pipeline
# Parameters
regression_models = [
('Lasso', Lasso(alpha=1.0, max_iter=10000)),
('Ridge', Ridge(alpha=1.0)),
# ('Lasso', Lasso(alpha=0.1, max_iter=1000)),
('Ridge', Ridge(alpha=0.1)),
('BayesianRidge', BayesianRidge()),
('KNN', KNeighborsRegressor(n_neighbors=15)),
# ('AB', AdaBoostRegressor()),
('KNN', KNeighborsRegressor(n_neighbors=25)),
# ('AB', AdaBoostRegressor(random_state=1)),
# ('LR', LinearRegression(n_jobs=-1)),
# ('MLP', MLPRegressor(hidden_layer_sizes=(100,20), max_iter=1000)),
# ('RF', RandomForestRegressor(n_jobs=-1)),
# ('SVR', SVR(kernel='rbf', C=1e3, gamma=0.1))
]
ensemble_model = [('Ensemble - Lasso', Lasso(alpha=1.0, max_iter=10000, positive=True))]
regression_ensemble_model = [('Ensemble - Ridge', Ridge(alpha=0.1))]
classification_models = [
('LR', LogisticRegression(n_jobs=-1)),
# ('LDA', LinearDiscriminantAnalysis()),
# ('KNN', KNeighborsClassifier()),
# ('CART', DecisionTreeClassifier()),
# ('NB', GaussianNB()),
('LDA', LinearDiscriminantAnalysis()),
('KNN', KNeighborsClassifier()),
('CART', DecisionTreeClassifier()),
('NB', GaussianNB()),
# ('AB', AdaBoostClassifier()),
# ('RF', RandomForestClassifier(n_jobs=-1))
]
classification_ensemble_model = [('Ensemble - CART', DecisionTreeClassifier())]
path = 'data/'
all_assets = get_crypto_assets(path)
sliding_window_size = 200
retrain_every = 100
scaler = 'none' # 'normalize' 'minmax' 'standardize' 'none'
sliding_window_size = 150
retrain_every = 20
scaler = 'minmax' # 'normalize' 'minmax' 'standardize' 'none'
include_original_data_in_ensemble = True
method = 'regression'
method = 'classification'
data_parameters = dict(path=path,
target_asset_lags= [1,2,3,4,5,6,8,10,15],
load_other_assets= True,
load_other_assets= False,
other_asset_lags= [],
log_returns= True,
add_date_features= True,
add_date_features= False,
own_technical_features= 'level2',
other_technical_features= 'none',
exogenous_features= 'none',
@@ -101,10 +102,10 @@ for asset in all_assets:
ensemble_result, ensemble_preds = run_single_asset_trainig_pipeline(
ticker_to_predict = asset,
X = ensemble_X,
y = target_returns,
y = y,
target_returns = target_returns,
models = ensemble_model,
method = 'regression',
models = regression_ensemble_model if method == 'regression' else classification_ensemble_model,
method = method,
sliding_window_size = sliding_window_size,
retrain_every = retrain_every,
scaler = scaler
-1
View File
@@ -1,4 +1,3 @@
import pytest
import numpy as np
import pandas as pd
from training.walk_forward import walk_forward_train_test
-1
View File
@@ -50,7 +50,6 @@ def run_single_asset_trainig_pipeline(
model_name = model_name,
target_returns = target_returns,
y_pred = preds,
sliding_window_size = sliding_window_size,
method = method,
)
column_name = ticker_to_predict + "_" + model_name
+4 -6
View File
@@ -5,7 +5,7 @@ from utils.helpers import get_first_valid_return_index
import pandas as pd
import numpy as np
def backtest(returns: pd.Series, signal: pd.Series, transaction_cost = 0.01) -> pd.Series:
def backtest(returns: pd.Series, signal: pd.Series, transaction_cost = 0.00) -> pd.Series:
delta_pos = signal.diff(1).abs().fillna(0.)
costs = transaction_cost * delta_pos
return (signal * returns) - costs
@@ -36,20 +36,18 @@ def evaluate_predictions(
model_name: str,
target_returns: pd.Series,
y_pred: pd.Series,
sliding_window_size: int,
method: Literal['classification', 'regression']
) -> pd.Series:
# ignore the predictions until we see a non-zero returns (and definitely skip the first sliding_window_size)
first_nonzero_return = get_first_valid_return_index(target_returns)
evaluate_from = first_nonzero_return + sliding_window_size + 1
first_nonzero_return = max(get_first_valid_return_index(target_returns), get_first_valid_return_index(y_pred))
evaluate_from = first_nonzero_return + 1
target_returns = pd.Series(target_returns[evaluate_from:])
if method == 'regression':
# if there are lots of zeros in the ground truth returns, probably something is wrong, but we can tolerate a couple of days of missing data.
is_zero = target_returns[target_returns == 0]
assert len(is_zero) < 15
# we can't deal with 0 returns, so we'll just remap the few examples to 0.0001
target_returns = target_returns.apply(lambda x: 0.0001 if x == 0 else x)
y_pred = pd.Series(y_pred[evaluate_from:])
df = __preprocess(target_returns, y_pred, method)
+2 -2
View File
@@ -1,6 +1,6 @@
from typing import Literal
import pandas as pd
import numpy as np
def get_first_valid_return_index(series: pd.Series) -> int:
first_nonzero_return = np.where(np.logical_and(series != 0, np.logical_not(np.isnan(series))))[0][0]
return first_nonzero_return
return np.where(np.logical_and(series != 0, np.logical_not(np.isnan(series))))[0][0]
+1 -1
View File
@@ -187,7 +187,7 @@ def __create_target_classes(df: pd.DataFrame, source_column: str, period: int, n
assert period > 0
def get_class_binary(x):
return 0 if x <= 0.0 else 1
return -1 if x <= 0.0 else 1
def get_class_threeway(x):
bins = pd.qcut(df[source_column], 4, duplicates='raise', retbins=True)[1]