mirror of
https://github.com/webclinic017/drift.git
synced 2026-08-17 04:48:09 +00:00
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:
+5
-5
@@ -23,16 +23,16 @@ def get_default_config() -> RawConfig:
|
|||||||
assets=["fivemin_crypto"],
|
assets=["fivemin_crypto"],
|
||||||
target_asset="BTCUSDT",
|
target_asset="BTCUSDT",
|
||||||
other_assets=[],
|
other_assets=[],
|
||||||
exogenous_data=[],
|
exogenous_data=["daily_glassnode"],
|
||||||
load_non_target_asset=True,
|
load_non_target_asset=True,
|
||||||
own_features=["level_1"],
|
own_features=["level_2"],
|
||||||
other_features=["z_score"],
|
other_features=["z_score"],
|
||||||
exogenous_features=[],
|
exogenous_features=["z_score"],
|
||||||
directional_models=classification_models,
|
directional_models=classification_models,
|
||||||
meta_models=meta_models,
|
meta_models=meta_models,
|
||||||
event_filter="cusum_vol",
|
event_filter="cusum_vol",
|
||||||
event_filter_multiplier=3.5,
|
event_filter_multiplier=3.5,
|
||||||
remove_overlapping_events=True,
|
remove_overlapping_events=False,
|
||||||
labeling="two_class",
|
labeling="two_class",
|
||||||
forecasting_horizon=10,
|
forecasting_horizon=10,
|
||||||
transaction_costs=0.002,
|
transaction_costs=0.002,
|
||||||
@@ -74,7 +74,7 @@ def get_minimal_config() -> RawConfig:
|
|||||||
event_filter_multiplier=3.5,
|
event_filter_multiplier=3.5,
|
||||||
remove_overlapping_events=False,
|
remove_overlapping_events=False,
|
||||||
labeling="two_class",
|
labeling="two_class",
|
||||||
forecasting_horizon=10,
|
forecasting_horizon=1,
|
||||||
transaction_costs=0.002,
|
transaction_costs=0.002,
|
||||||
save_models=True,
|
save_models=True,
|
||||||
ensembling_method="voting_soft",
|
ensembling_method="voting_soft",
|
||||||
|
|||||||
@@ -8,9 +8,7 @@ import numpy as np
|
|||||||
def create_forward_returns(series: pd.Series, period: int) -> ForwardReturnSeries:
|
def create_forward_returns(series: pd.Series, period: int) -> ForwardReturnSeries:
|
||||||
assert period > 0
|
assert period > 0
|
||||||
indexer = pd.api.indexers.FixedForwardWindowIndexer(window_size=period)
|
indexer = pd.api.indexers.FixedForwardWindowIndexer(window_size=period)
|
||||||
|
return series.rolling(window=indexer).sum().shift(-1)
|
||||||
forward_returns = series.rolling(window=indexer).sum()
|
|
||||||
return forward_returns
|
|
||||||
|
|
||||||
|
|
||||||
def purge_overlapping_events(events: EventsDataFrame) -> EventsDataFrame:
|
def purge_overlapping_events(events: EventsDataFrame) -> EventsDataFrame:
|
||||||
|
|||||||
+1
-4
@@ -1,6 +1,3 @@
|
|||||||
from re import S
|
|
||||||
from typing import Optional
|
|
||||||
|
|
||||||
from sklearn.model_selection import train_test_split
|
from sklearn.model_selection import train_test_split
|
||||||
|
|
||||||
from config.types import Config, RawConfig
|
from config.types import Config, RawConfig
|
||||||
@@ -65,5 +62,5 @@ def run_sklearn_training(config: Config):
|
|||||||
|
|
||||||
if __name__ == "__main__":
|
if __name__ == "__main__":
|
||||||
run_sklearn_pipeline(
|
run_sklearn_pipeline(
|
||||||
raw_config=get_minimal_config(),
|
raw_config=get_default_config(),
|
||||||
)
|
)
|
||||||
|
|||||||
Reference in New Issue
Block a user