chore(Linter): reformatted code with black (#211)

* chore(Linter): reformatted code with black

* Create black.yaml
This commit is contained in:
Mark Aron Szulyovszky
2022-02-17 19:22:17 +01:00
committed by GitHub
parent f3fee4a4e1
commit 8dd2d88740
101 changed files with 2595 additions and 2319 deletions
+65 -25
View File
@@ -18,54 +18,94 @@ from training.bet_sizing import bet_sizing_with_meta_model
from training.types import PipelineOutcome
import ray
ray.init()
def run_pipeline(project_name:str, with_wandb: bool, sweep: bool, raw_config: RawConfig) -> tuple[PipelineOutcome, Config]:
def run_pipeline(
project_name: str, with_wandb: bool, sweep: bool, raw_config: RawConfig
) -> tuple[PipelineOutcome, Config]:
wandb, config = __setup_config(project_name, with_wandb, sweep, raw_config)
pipeline_outcome = __run_training(config)
report_results(pipeline_outcome.directional_training.training.stats, pipeline_outcome.get_output_stats(), pipeline_outcome.get_output_weights(), config, wandb, sweep)
pipeline_outcome = __run_training(config)
report_results(
pipeline_outcome.directional_training.training.stats,
pipeline_outcome.get_output_stats(),
pipeline_outcome.get_output_weights(),
config,
wandb,
sweep,
)
save_models(pipeline_outcome, config)
return pipeline_outcome, config
def __setup_config(project_name:str, with_wandb: bool, sweep: bool, raw_config: RawConfig) -> tuple[Optional[object], Config]:
def __setup_config(
project_name: str, with_wandb: bool, sweep: bool, raw_config: RawConfig
) -> tuple[Optional[object], Config]:
wandb = None
if with_wandb:
wandb = launch_wandb(project_name=project_name, default_config=raw_config, sweep=sweep)
if with_wandb:
wandb = launch_wandb(
project_name=project_name, default_config=raw_config, sweep=sweep
)
raw_config = override_config_with_wandb_values(wandb, raw_config)
config = preprocess_config(raw_config)
return wandb, config
def __run_training(config: Config) -> PipelineOutcome:
print("---> Load data, check for validity")
X, returns = load_data(
assets = config.assets,
other_assets = config.other_assets,
exogenous_data = config.exogenous_data,
target_asset = config.target_asset,
load_non_target_asset = config.load_non_target_asset,
own_features = config.own_features,
other_features = config.other_features,
exogenous_features = config.exogenous_features,
assets=config.assets,
other_assets=config.other_assets,
exogenous_data=config.exogenous_data,
target_asset=config.target_asset,
load_non_target_asset=config.load_non_target_asset,
own_features=config.own_features,
other_features=config.other_features,
exogenous_features=config.exogenous_features,
)
assert check_data(X, config) == True, "Data is not valid."
assert check_data(X, config) == True, "Data is not valid."
print("---> Filter for significant events when we want to trade, and label data")
events, X, y, forward_returns = label_data(config.event_filter, config.labeling, X, returns)
events, X, y, forward_returns = label_data(
config.event_filter, config.labeling, X, returns
)
print("---> Train directional models")
directional_training_outcome = train_directional_model(X, y, forward_returns, config, config.directional_model, from_index = None, preloaded_training_step = None)
directional_training_outcome = train_directional_model(
X,
y,
forward_returns,
config,
config.directional_model,
from_index=None,
preloaded_training_step=None,
)
print("---> Run bet sizing on directional model's output")
bet_sizing_outcomes = bet_sizing_with_meta_model(X, directional_training_outcome.training.predictions, y, forward_returns, config.meta_model, config, 'meta', None, None, None)
bet_sizing_outcomes = bet_sizing_with_meta_model(
X,
directional_training_outcome.training.predictions,
y,
forward_returns,
config.meta_model,
config,
"meta",
None,
None,
None,
)
return PipelineOutcome(directional_training_outcome, bet_sizing_outcomes)
if __name__ == '__main__':
run_pipeline(project_name='price-prediction', with_wandb = False, sweep = False, raw_config=get_lightweight_ensemble_config())
if __name__ == "__main__":
run_pipeline(
project_name="price-prediction",
with_wandb=False,
sweep=False,
raw_config=get_lightweight_ensemble_config(),
)