Commit Graph

42 Commits

Author SHA1 Message Date
Daniel Szemerey 3084f5e271 Refractor(Main Pipeline): Refractored the two main steps and the data processing. (#156)
* refr: Took out main primary and secondary loops and data processing.

* feat: Tidied the code up.

* feat: Saving models and results now works in a type safe way.

* fix: There was error in the saving function.

* chore: Took out some remaining comments.

* fix: Fixed the previous data checking process.

* feat: Fixed model selection method. I will continue the inference after we merged.

Co-authored-by: Daniel Szemerey <szemereydaniel@gmail.com>
2022-01-12 23:10:18 +01:00
Mark Aron Szulyovszky c611481eb6 refactor(WalkForward): separate train / test functions to help with inference later (#158)
* refactor(WalkForward): separate train / test functions (draft) to potentially help with inference later

* fix(Training): use the new separate train / test functions

* feat(Training): return and pass in scalers that are necessary for inference

* fix(Project): runtime errors

* fix(WalkForward): use the correct `train_from` value

* fix(Tests): for new walk_forward functions()

* refactor(WalkForward): rename `walk_forward_test()` to `walk_forward_inference()`
2022-01-12 14:42:16 +01:00
Mark Aron Szulyovszky 580500a46a feat(Evaluation): adjusted transaction costs to be more realistic 0.3% (#150) 2022-01-11 12:41:02 +01:00
Mark Aron Szulyovszky 73cfc67336 fix(Evaluation): correlation test should work on a per asset level, not per model level (#142)
* fix(Evaluation): correlation test should work on a per asset level, not per model level

* fix(Evaluation): correlations series initalized correctly

* fix(Reporting): don't name the run after the incorrectly supposed model_type

* fix(Reporting): put back send_report_to_wandb() into its original place

* fix(CI): sending reports again in comment
2022-01-10 14:17:06 +01:00
Mark Aron Szulyovszky f5bbc266a4 feat(Reporting): added robustness / correlation test (#138)
* feat(Evaluation): added robustness/correlation test

* feat(Reporting): saving correlations

* fix(Reporting): record correlations properly

* fix(Model): SVC's random seed

* feat(CI): store artifacts
2022-01-09 20:00:03 +01:00
Mark Aron Szulyovszky b1c04afb13 refactor(Naming): use new convention, added Ensemble model parameter back, support multiple Meta-Labeling models (#132)
* refactor(Naming): use `primary_models` & `meta_labeling_models`

* refactor(Naming): using primary * meta_labeling across config and in pipeline

* feat(Pipeline): added back Ensemble models

* fix(Pipeline): compiler error

* fix(Config): typo

* chore(Pipeline): removed unused averaging step

* revert the changes in discretizing

* chore(Pipeline): remove sharpe improvement logging

* fix(Pipeline): ensemble predictions should be a pd.Series instead of a DataFrame

* fix(Pipeline): discard unnecessary ensemble_probabilities

* fix(Pipeline): fixes regarding various meta-labeling ensemble bugs

* fix(Reporting): use the new naming convention

* fix(Reporting): use the right variable

* feat(Sweep): new sweep for ensemble models

* fix(Sweep): config reference

* fix(Config): simplified dev config

* fix(Models): use the faster LR model

* fix(Models): use LGBM in the meta-labeling model for speed

* fix(Selection): always use the first model for feature selection, commented out caching from select_features() as it's close to redundant in terms of speed
2022-01-09 17:21:06 +01:00
Mark Aron Szulyovszky 22b3167cb9 feat(Evaluate): increase transactions costs, to get a more realistic view on performance (#137) 2022-01-09 14:18:20 +01:00
Mark Aron Szulyovszky 34105f7ca1 feat(Evaluation): added minimal transaction costs to penalize higher turnover (#125) 2022-01-07 18:27:24 +01:00
Mark Aron Szulyovszky 9488e92597 feature(MetaLabeling): replaced previous non-functional Ensembling method with Meta-labeling method available for both lvl1 and lvl2 models (#110)
* feature(MetaLabeling): added hacky prototype

* fix(MetaLabeling): drop index until first valid X & y

* fix(MetaLabeling): transform both X & y before feature selection

* fix(MetaLabeling): got feature selection to work

* fix(MetaLabeling): correct values for meta_y

* feat(MetaLabeling): created predictions multiplied by bet sizes

* feat(Pipeline): print out averaged result

* fix(Evaluation): correctly deal with non-discretized data

* fix(Pipeline): use the right column names

* refactor(Pipeline): move out meta-labeling

* refactor(Pipeline): complete refactoring

* feat(CI): post results to PR

* fix(Pipeline): use the correct filename

* chore(Config): removed now redundant feature_selection flag

* feat(Models): added SVC

* fix(Pipeline): accidentally switched two return values

* feat(Sweep): prepared sweep_meta.yaml, moved report_results() into a separate file

* fix(Pipeline): wrong function name

* fix(Sweep): yaml + run_sweep

* fix(Sweep): typo in name

* fix(Reporting): only save averaged results

* feat(MetaLabeling): use optional meta-labeling step for every lvl1 models, before averaging

* feat(Reporting): print out sharpe improvement in meta-labeling step

* fix(Sweep): adjusted config, defaulted to good defaults

* fix(Sweep): adjusted sweep
2022-01-06 16:36:45 +01:00
Mark Aron Szulyovszky 1cd0119589 feat(DataLoader): caching MVP, added ability to use standard scaling for exogenous data, scaling is now also done before feature selection (#105)
* fix(FeatureExtractor): apply log to transform some series to normality

* feat(DataLoader): add ability of not returning returns when they're not needed (exogenous data), applied log to certain features

* feat(FeatureExtractors): added standard scaling for exogenous data

* feat(FeatureSelection): scale data with the passed in scaler before doing feature-selection

* fix(Config): sweep config

* feat(Models): output probability, store it

* feat(Core): added caching to select_features() and load_data()

* fix(Dependencies): added diskcache

* fix(Training): error when creating results DF

* feat(Models): added xgboost, fixed tests

* refactor(Cache): moved hashing to a separate function, created wrapper functions to separate business logic and caching

* fix(Tests): new syntax

* fix(Model): XGboost can't handle -1 class, so we'll use the deprecated label_encoder fornow

* fix(Model): XGBoost config

* feat(Cache): add run_clear_cache script

* fix(Pipeline) accidentally re-instatiating all_predictions for each asset
2022-01-04 11:44:35 +01:00
Mark Aron Szulyovszky 867269df2b feat(Data): added daily_glassnode DataCollection (#99) 2022-01-03 13:57:36 +01:00
Mark Aron Szulyovszky 442915f847 feat(Data): create DataSource, DataCollection, added hourly crypto data (#96)
* feat(Data): create DataSource, DataCollection, added hourly crypto data

* fix(Data): hourly data format, loading & config
2021-12-31 19:04:27 +01:00
Mark Aron Szulyovszky f762ceed2a feat(FeatureExtraction): added fractionally differentiated returns to remove lagged returns (#95)
* feat(FeatureExtraction): added fractionally differentiated returns to remove lagged returns

* fix(Sweep): config

* fix(Sweep): name

* fix(Sweep): grid

* feat(Config): separated sliding_window_size_level1 & sliding_window_size_level2

* feat(Dependencies): added ray, now using it to parallel process feature extraction

* fix(Dependencies): added pip explicitly

* fix(Dependencies): removed ray from root

* fix(Models): average model was probably not taking the right timestamp to average

* feat(Config): separated expanding_window_level1 & expanding_window_level2

* fix(Config): set n_features_to_select to the optimal 30
2021-12-28 22:50:09 +01:00
Mark Aron Szulyovszky cc70d3f907 feat(Selection): added toggleable feature selection step into the pipeline (#83)
* feat(Selection): added prototype feature selection python script

* feat(Utils): added some helpers for the future from Advances in Financial ML book

* feat(Selection): added RFECV

* feat(Selection): added configurable feature selection step into pipeline

* feat(Config): added level_1 & level_2 default config, PCA before feature selection process starts

* feat(Selection): added backup feature selector models if current one can't output feature importance, removed unnecessary array for level-2 models

* fix(Training): deal with zero first value coming out of static models

* feat(Sweep): added feature selection sweep

* fix(Sweep): config problem

* fix(Sweep): config

* chore(Utils): removed unnecessary purged k-fold crossval class

* feat(Config): added dimensionality_reduction as a separate flag

* fix(Sweep): config updated

* fix(Sweep): sweep name

* chore(Config): updated level_2 config to the best performing configuation
2021-12-27 21:59:22 +01:00
Mark Aron Szulyovszky a9b05dbd42 fix(Reporting): use weighted average (with no_of_samples as weights) and only report level-1 OR level-2 model performance (#91)
* fix(Reporting): use weighted average (with no_of_samples as weights) and only report level-1 OR level-2 model performance

* chore(Config): updated sweep config

* fix(Reporting): missing import

* fix(Evaluation): get_first_valid_return_index can deal with zero valid indexes

* fix(Training): increase threshold for skipping assets

* fix(DataLoader): target asset should be always the first column
2021-12-26 12:15:11 +01:00
Daniel Szemerey fc4e59a7d2 feat(Sweep): separated level-1 and level-2 sweep configs, skip assets with too few samples to train on, simplified model mapping (#84)
* feat: Added ensemble models to sweep and configured naming convention.

* fix: Default value was misconfigured.

* feat(Sweep): separated level-1 and level-2 sweep configs, skip assets with too few samples to train on, simplified model mapping

* fix(Sweep): syntax error

* chore(Sweep): set sweep names accordingly

* fix(Sweep): set sliding window

* fix(Sweep): adjusted sweep config

* fix(Sweep): removed invalid feature extractor preset

Co-authored-by: Mark Aron Szulyovszky <mark.szulyovszky@gmail.com>
2021-12-23 23:48:59 +01:00
Mark Aron Szulyovszky eea88103f4 feat(Metrics): added probabilistic sharpe ratio (#82)
* feat(Metrics): added probabilistic sharpe ratio

* Apply suggestions from code review
2021-12-23 17:06:22 +01:00
Mark Aron Szulyovszky 95573eb9dd feat(Data): add option to predict 3 classes (#79)
* feat(Data): add option to predict 3 classes

* feat(Evaluation): added ability to evaluate 3 class predictions

* chore(Config): set sensible config for regression models

* feat(Data): added option to use balanced or imbalanced three-class data

* feat(Evaluate): correctly track "no_of_samples" now that we have three classes

* chore(Sweep): remove probably not useful scaler values from sweep
2021-12-23 13:24:56 +01:00
Mark Aron Szulyovszky b6cd6b14fe feat(Config): feature extractors are enabled one-by-one with a bool, added previous model to model.fit() (#77)
* feat(Config): feature extractors are enabled one-by-one with a bool, added previous model to model.fit()

* fix(Sweep): removed unused `other_features` parameter that fails sweep

* feat(Config): using preset names for defining feature extractors again

* fix(Tests): fixed model stub classes
2021-12-23 10:35:20 +01:00
Mark Aron Szulyovszky 25b64f5a3d refactor(Reporting): only report the last model's results, moved wandb-related functions to reporting (#69)
* refactor(Reporting): only report the last model's results, moved wandb-related functions to `reporting`

* fix(Reporting): use .mean() on axis 1 to retain the metrics, fixed get_model_name()

* fix(Config): sweep file syntax

* fix(Config): changed hyperparameter search method to "bayes"

* chore(Sweep): adjusted sweep config based on the results we saw (removed Momentum as well)

* fix(Sweep): only use classification method for now, we're not yet prepared for regression
2021-12-22 12:04:38 +01:00
Daniel Szemerey 1c1b8b2e54 Feature: Added sweep functionality (#65)
* feat: Parametricized model selection works now.

* feat: Fixed errors. Sweep generates and you can run it, but it gives an error for model.only_columns attribute.

* feat: Factored the wandb management, default config managment and the model_dictionary out of the run_pipeline to a seperate file.

* fix: Took out prints and fixed the mismatch of ensemble models when classifing.

* fix(Models): added StaticMomentum model to the dictionary, hopefully fixed sklearn-ex RandomForestRegressor problem

* fix(Dependencies): pin scikit-learn-ex's version, moved map_model_name_to_function to `models`

* feat(Sweep): added `run_sweep.py` shortcut

* feat(Pipeline): skip training a meta model if array is empty

Co-authored-by: Mark Aron Szulyovszky <mark.szulyovszky@gmail.com>
2021-12-21 17:28:36 +01:00
Mark Aron Szulyovszky 79d84cf0a3 feat(Model): added own Model class, SkLearnModel wrapper and StaticMomentumModel (#61)
* feat(Model): added own `Model` class, SkLearnModel wrapper and StaticMomentumModel

* fix(Tests): added missing Model variable

* fix(Tests): added missing clone method()
2021-12-21 10:30:09 +01:00
Mark Aron Szulyovszky 122b7bb128 feat(Evaluation): added "no_of_samples", "ratio_of_classes" metrics to aid model debugging (#56) 2021-12-20 16:38:44 +01:00
Daniel Szemerey a7414eac23 feature: Added Weights and Biases configuration to the repo. (#48)
* feat: initial wandb configured. Sweep parameters aren't configured yet.

* feat: Wandb logs now results.

* feat: gitignore.

* fix: Took out print()

* feat: Changed default value of wandb to False.

* feat: Added wandb to turn of automatically if there is no environment variable to start it (when we push it). Added environment configuration aswell.

* fix(Dependencies): the package name seems to be python-dotenv

Co-authored-by: Mark Aron Szulyovszky <mark.szulyovszky@gmail.com>
2021-12-20 14:01:14 +01:00
Mark Aron Szulyovszky b456ec3cb7 feat(Data): added feature extractors, and feature extractor presets, removed a bunch of custom arguments from load_data (#42) 2021-12-19 12:14:59 +01:00
Mark Aron Szulyovszky 0963df2087 refactor(Project): move out load_data to utils, rename fetch_data to run_fetch_data, got classifiers to work (#38) 2021-12-17 17:41:50 +01:00
Mark Aron Szulyovszky cc7061b456 feat(Core): ensemble models, correct forward returns calculation, scaling, only train from when asset returns are available, major bug fixed in walk_forward_train_test (#35)
* fix(Core): correct forward returns calculation, classifiers are now working again, only train from when asset returns are available

* feat(Utils): added get_first_valid_return_index()

* feat(Ensemble): return models from `run_whole_pipeline`

* feat(Ensemble): added ensemble step, fixed walk_forward_train_test predictions index confusion,

* chore(Pipeline): remove unnecessary extra ensemble results dataframe

* refactor(Core): removed unnecessary ensemble_train_predict, moved run_single_asset_trainig_pipeline to a separate file

* feat(Training): added scaling on expanding window (the past) to walk_forward_train_test(), now printing out mean sharpe ratio

* feat(CI): added environment.yml file

* chore(Environment): update env.yml

* feat(CI): added testing workflow

* fix(CI): renamed enviroment.yml

* fix(Tests): added missing new parameter to walk_forward_train_test()
2021-12-17 14:32:17 +01:00
Mark Aron Szulyovszky 1eaba0c221 fix(Evaluate): ignore empty data at evaluation time, add backtesting metrics (sharpe, etc), fixed crash when predicting 0.0 (#23)
* fix(Evaluate): ignore empty data at evaluation time, so we don't inflate the model's performance

* refactor(Pipeline): pass in data_loader arguments to the pipeline

* feat(Evaluation): added sharpe, sortino, etc

* fix: Took out the method to fill NaN numbers with 0s. This way in evaluation we can ignore NaN values.

* fix: Fix of the fix added fillna back. Either we root out NaN lines in the very beginning or we stick with the method you created.

Co-authored-by: Daniel Szemerey <szemy2@gmail.com>
2021-12-15 21:11:12 +01:00
Mark Aron Szulyovszky 6440ced32c feat(Tests): added basic unit tests for walk_forward_train_test() (#22)
* feat(Tests): added basic unit tests for walk_forward_train_test()

* fix(Tests): inherit from BaseEstimator, fix index problems in walk_forward_train_test

* fix(WalkForward): predictions were mistakenly removed, oops

* fix(WalkForward): mistakenly re-assiging model
2021-12-15 17:54:03 +01:00
Mark Aron Szulyovszky beb281fc3a feat(Evaluation): created a unified evaluation framework for both regression / classification 2021-12-14 21:25:43 +01:00
Mark Aron Szulyovszky 1ef314c034 fix(WalkForward): major bug where we passed in "window of windows of data" is resolved, refactored walk_forward_train_test() and load_data() 2021-12-14 21:07:03 +01:00
Mark Aron Szulyovszky d047b7417e feat(WalkForward): added regression/classification switch, archived old experiments, wrapped the process into run_whole_pipeline() (#10)
* refactor(WalkForward): cleaned up training & evaluation code

* refactor: added run_whole_pipeline(), moved all previous models to archive
2021-12-14 18:16:17 +01:00
Mark Aron Szulyovszky 7aedb91069 feat(Data): added various data loading config options, walk forward method draft (#9)
* feat(Eval): added format_data_for_backtest()

* feat(Data): added many configurable parameters to load_files to reduce boilerplate and prepare for HPO

* feat(Core): added walk forward method of training/testing

* fix(Model): remove the unnecessary softmax activation from the keras models

* feat(Core): added walk_forward_train_test()
2021-12-01 09:28:24 +01:00
Mark Aron Szulyovszky 6e192ebc8a feat(Models): added a basic sktime model and missing USD crypto currency pairs (#7) 2021-11-17 22:28:34 +01:00
Mark Aron Szulyovszky 3fec439c08 feat(Data): added new derived features + asset pairs for crypto tickers (#6) 2021-11-17 12:07:49 +01:00
Mark Aron Szulyovszky 1d6eed3a94 feat(Core): added the first classification model & the feature necessary (#4)
* feat(Core): added the first classification model & the feature necessary

* feat(Models): added basic transformers model
2021-11-16 10:02:02 +01:00
Mark Aron Szulyovszky 797791d2f4 feat(Forecasting): pytorch-forecasting scaffolding is now working, added narrow data format, fixed missing time column index name (#5)
* feat: Started implementing pytorch-forecasting.

* feat(Forecasting): pytorch-forecasting scaffolding is now working, added narrow data format, fixed missing `time` column index name

Co-authored-by: Daniel Szemerey <szemy2@gmail.com>
2021-11-16 10:00:26 +01:00
Mark Aron Szulyovszky 07302a7541 feat(Models): added MAE & RMSE metrics, fixed NaN & Inf values in data, 2021-11-14 23:50:25 +01:00
Mark Aron Szulyovszky 5f8efc97fa feat(Model): now successfully training the basic LSTM model 2021-11-11 18:29:05 +01:00
Mark Aron Szulyovszky 78b3c07420 feat(Model): trying to get to a model that can train 2021-11-11 17:53:24 +01:00
Mark Aron Szulyovszky 3188aab220 feat(Model): continued with the keras model scaffolding 2021-11-10 14:51:12 +01:00
Mark Aron Szulyovszky 51b7d35660 feat(Data): downloading data for pre-defined tickers 2021-11-09 15:21:22 +01:00