fix(Labelling): didn't forward shift forward returns previously, introduced major lookahead bias (#249)

* fix(Labelling): didn't forward shift forward returns previously, introduced major lookahead bias

* fix(Baseline): use the same config
This commit is contained in:
Mark Aron Szulyovszky
2022-03-15 19:12:40 +01:00
committed by GitHub
parent 7deeb2de01
commit 2606639cc2
3 changed files with 7 additions and 12 deletions
+5 -5
View File
@@ -23,16 +23,16 @@ def get_default_config() -> RawConfig:
assets=["fivemin_crypto"],
target_asset="BTCUSDT",
other_assets=[],
exogenous_data=[],
exogenous_data=["daily_glassnode"],
load_non_target_asset=True,
own_features=["level_1"],
own_features=["level_2"],
other_features=["z_score"],
exogenous_features=[],
exogenous_features=["z_score"],
directional_models=classification_models,
meta_models=meta_models,
event_filter="cusum_vol",
event_filter_multiplier=3.5,
remove_overlapping_events=True,
remove_overlapping_events=False,
labeling="two_class",
forecasting_horizon=10,
transaction_costs=0.002,
@@ -74,7 +74,7 @@ def get_minimal_config() -> RawConfig:
event_filter_multiplier=3.5,
remove_overlapping_events=False,
labeling="two_class",
forecasting_horizon=10,
forecasting_horizon=1,
transaction_costs=0.002,
save_models=True,
ensembling_method="voting_soft",
+1 -3
View File
@@ -8,9 +8,7 @@ import numpy as np
def create_forward_returns(series: pd.Series, period: int) -> ForwardReturnSeries:
assert period > 0
indexer = pd.api.indexers.FixedForwardWindowIndexer(window_size=period)
forward_returns = series.rolling(window=indexer).sum()
return forward_returns
return series.rolling(window=indexer).sum().shift(-1)
def purge_overlapping_events(events: EventsDataFrame) -> EventsDataFrame:
+1 -4
View File
@@ -1,6 +1,3 @@
from re import S
from typing import Optional
from sklearn.model_selection import train_test_split
from config.types import Config, RawConfig
@@ -65,5 +62,5 @@ def run_sklearn_training(config: Config):
if __name__ == "__main__":
run_sklearn_pipeline(
raw_config=get_minimal_config(),
raw_config=get_default_config(),
)