qlib_init:
    provider_uri: "~/.qlib/qlib_data/eurusd_1min_data"
    region: cn

market: &market eurusd
benchmark: &benchmark EURUSD

data_handler_config: &data_handler_config
    start_time: {{ train_start | default("2008-01-01", true) }}
    end_time: {{ test_end | default("null", true) }}
    instruments: *market
    data_loader:
        class: NestedDataLoader
        kwargs:
            dataloader_l:
                - class: qlib.contrib.data.loader.Alpha158DL
                  kwargs:
                    config:
                        label: 
                            - ["Ref($close, -2)/Ref($close, -1) - 1"]
                            - ["LABEL0"]
                        feature:
                            - {{ feature_expressions }}
                            - {{ feature_names }}
                - class: qlib.data.dataset.loader.StaticDataLoader
                  kwargs:
                    config: "combined_factors_df.parquet"
    
    infer_processors:
        - class: RobustZScoreNorm
          kwargs:
              fields_group: feature
              clip_outlier: true
              fit_start_time: {{ train_start | default("2008-01-01", true) }}
              fit_end_time: {{ train_end | default("2014-12-31", true) }}
        - class: Fillna
          kwargs:
              fields_group: feature
    learn_processors:
        - class: DropnaLabel
          kwargs:
              fields_group: label

port_analysis_config: &port_analysis_config
    strategy:
        class: TopkDropoutStrategy
        module_path: qlib.contrib.strategy
        kwargs:
            signal: <PRED>
            topk: 1
            n_drop: 0
    backtest:
        start_time: {{ test_start | default("2017-01-01", true) }}
        end_time: {{ test_end | default("null", true) }}
        account: 100000000
        benchmark: *benchmark
        exchange_kwargs:
            limit_threshold: 0.0
            deal_price: close
            open_cost: 0.0005
            close_cost: 0.0015
            min_cost: 0

task:
    model:
        class: GeneralPTNN
        module_path: qlib.contrib.model.pytorch_general_nn
        kwargs:
            n_epochs: {{ n_epochs }}
            lr: {{ lr }}
            early_stop: {{ early_stop }}
            batch_size: {{ batch_size }}
            weight_decay: {{ weight_decay }}
            metric: loss
            loss: mse
            n_jobs: 20
            GPU: 0
            pt_model_uri: "model.model_cls"
            pt_model_kwargs: {
                "num_features": {{ num_features }}{% if num_timesteps %}, "num_timesteps": {{ num_timesteps }}{% endif %}
            }
    dataset:
        class: {{ dataset_cls | default("DatasetH") }}
        module_path: qlib.data.dataset
        kwargs:
            handler:
                class: DataHandlerLP
                module_path: qlib.contrib.data.handler
                kwargs: *data_handler_config
            segments:
                train: [{{ train_start | default("2008-01-01", true) }}, {{ train_end | default("2014-12-31", true) }}]
                valid: [{{ valid_start | default("2015-01-01", true) }}, {{ valid_end | default("2016-12-31", true) }}]
                test: [{{ test_start | default("2017-01-01", true) }}, {{ test_end | default("null", true) }}]
            {% if step_len %}step_len: {{ step_len }}{% endif %}
    record: 
        - class: SignalRecord
          module_path: qlib.workflow.record_temp
          kwargs: 
            model: <MODEL>
            dataset: <DATASET>
        - class: SigAnaRecord
          module_path: qlib.workflow.record_temp
          kwargs: 
            ana_long_short: False
            ann_scaler: 252
        - class: PortAnaRecord
          module_path: qlib.workflow.record_temp
          kwargs: 
            config: *port_analysis_config
