mirror of
https://github.com/microsoft/qlib.git
synced 2026-07-17 17:34:35 +08:00
simplify signal parameter
This commit is contained in:
@@ -53,6 +53,9 @@ Below is a typical config file of ``qrun``.
|
|||||||
kwargs:
|
kwargs:
|
||||||
topk: 50
|
topk: 50
|
||||||
n_drop: 5
|
n_drop: 5
|
||||||
|
signal:
|
||||||
|
- <MODEL>
|
||||||
|
- <DATASET>
|
||||||
backtest:
|
backtest:
|
||||||
limit_threshold: 0.095
|
limit_threshold: 0.095
|
||||||
account: 100000000
|
account: 100000000
|
||||||
@@ -240,6 +243,9 @@ The following script is the configuration of `backtest` and the `strategy` used
|
|||||||
kwargs:
|
kwargs:
|
||||||
topk: 50
|
topk: 50
|
||||||
n_drop: 5
|
n_drop: 5
|
||||||
|
signal:
|
||||||
|
- <MODEL>
|
||||||
|
- <DATASET>
|
||||||
backtest:
|
backtest:
|
||||||
limit_threshold: 0.095
|
limit_threshold: 0.095
|
||||||
account: 100000000
|
account: 100000000
|
||||||
|
|||||||
@@ -36,8 +36,9 @@ port_analysis_config: &port_analysis_config
|
|||||||
class: TopkDropoutStrategy
|
class: TopkDropoutStrategy
|
||||||
module_path: qlib.contrib.strategy
|
module_path: qlib.contrib.strategy
|
||||||
kwargs:
|
kwargs:
|
||||||
model: <MODEL>
|
signal:
|
||||||
dataset: <DATASET>
|
- <MODEL>
|
||||||
|
- <DATASET>
|
||||||
topk: 50
|
topk: 50
|
||||||
n_drop: 5
|
n_drop: 5
|
||||||
backtest:
|
backtest:
|
||||||
|
|||||||
@@ -28,8 +28,9 @@ port_analysis_config: &port_analysis_config
|
|||||||
class: TopkDropoutStrategy
|
class: TopkDropoutStrategy
|
||||||
module_path: qlib.contrib.strategy
|
module_path: qlib.contrib.strategy
|
||||||
kwargs:
|
kwargs:
|
||||||
model: <MODEL>
|
signal:
|
||||||
dataset: <DATASET>
|
- <MODEL>
|
||||||
|
- <DATASET>
|
||||||
topk: 50
|
topk: 50
|
||||||
n_drop: 5
|
n_drop: 5
|
||||||
backtest:
|
backtest:
|
||||||
@@ -86,4 +87,4 @@ task:
|
|||||||
- class: PortAnaRecord
|
- class: PortAnaRecord
|
||||||
module_path: qlib.workflow.record_temp
|
module_path: qlib.workflow.record_temp
|
||||||
kwargs:
|
kwargs:
|
||||||
config: *port_analysis_config
|
config: *port_analysis_config
|
||||||
|
|||||||
@@ -14,8 +14,9 @@ port_analysis_config: &port_analysis_config
|
|||||||
class: TopkDropoutStrategy
|
class: TopkDropoutStrategy
|
||||||
module_path: qlib.contrib.strategy
|
module_path: qlib.contrib.strategy
|
||||||
kwargs:
|
kwargs:
|
||||||
model: <MODEL>
|
signal:
|
||||||
dataset: <DATASET>
|
- <MODEL>
|
||||||
|
- <DATASET>
|
||||||
topk: 50
|
topk: 50
|
||||||
n_drop: 5
|
n_drop: 5
|
||||||
backtest:
|
backtest:
|
||||||
|
|||||||
@@ -21,8 +21,9 @@ port_analysis_config: &port_analysis_config
|
|||||||
class: TopkDropoutStrategy
|
class: TopkDropoutStrategy
|
||||||
module_path: qlib.contrib.strategy
|
module_path: qlib.contrib.strategy
|
||||||
kwargs:
|
kwargs:
|
||||||
model: <MODEL>
|
signal:
|
||||||
dataset: <DATASET>
|
- <MODEL>
|
||||||
|
- <DATASET>
|
||||||
topk: 50
|
topk: 50
|
||||||
n_drop: 5
|
n_drop: 5
|
||||||
backtest:
|
backtest:
|
||||||
|
|||||||
@@ -14,8 +14,9 @@ port_analysis_config: &port_analysis_config
|
|||||||
class: TopkDropoutStrategy
|
class: TopkDropoutStrategy
|
||||||
module_path: qlib.contrib.strategy
|
module_path: qlib.contrib.strategy
|
||||||
kwargs:
|
kwargs:
|
||||||
model: <MODEL>
|
signal:
|
||||||
dataset: <DATASET>
|
- <MODEL>
|
||||||
|
- <DATASET>
|
||||||
topk: 50
|
topk: 50
|
||||||
n_drop: 5
|
n_drop: 5
|
||||||
backtest:
|
backtest:
|
||||||
|
|||||||
@@ -21,8 +21,9 @@ port_analysis_config: &port_analysis_config
|
|||||||
class: TopkDropoutStrategy
|
class: TopkDropoutStrategy
|
||||||
module_path: qlib.contrib.strategy
|
module_path: qlib.contrib.strategy
|
||||||
kwargs:
|
kwargs:
|
||||||
model: <MODEL>
|
signal:
|
||||||
dataset: <DATASET>
|
- <MODEL>
|
||||||
|
- <DATASET>
|
||||||
topk: 50
|
topk: 50
|
||||||
n_drop: 5
|
n_drop: 5
|
||||||
backtest:
|
backtest:
|
||||||
@@ -100,4 +101,4 @@ task:
|
|||||||
- class: PortAnaRecord
|
- class: PortAnaRecord
|
||||||
module_path: qlib.workflow.record_temp
|
module_path: qlib.workflow.record_temp
|
||||||
kwargs:
|
kwargs:
|
||||||
config: *port_analysis_config
|
config: *port_analysis_config
|
||||||
|
|||||||
@@ -35,8 +35,9 @@ port_analysis_config: &port_analysis_config
|
|||||||
class: TopkDropoutStrategy
|
class: TopkDropoutStrategy
|
||||||
module_path: qlib.contrib.strategy
|
module_path: qlib.contrib.strategy
|
||||||
kwargs:
|
kwargs:
|
||||||
model: <MODEL>
|
signal:
|
||||||
dataset: <DATASET>
|
- <MODEL>
|
||||||
|
- <DATASET>
|
||||||
topk: 50
|
topk: 50
|
||||||
n_drop: 5
|
n_drop: 5
|
||||||
backtest:
|
backtest:
|
||||||
@@ -94,4 +95,4 @@ task:
|
|||||||
- class: PortAnaRecord
|
- class: PortAnaRecord
|
||||||
module_path: qlib.workflow.record_temp
|
module_path: qlib.workflow.record_temp
|
||||||
kwargs:
|
kwargs:
|
||||||
config: *port_analysis_config
|
config: *port_analysis_config
|
||||||
|
|||||||
@@ -28,8 +28,9 @@ port_analysis_config: &port_analysis_config
|
|||||||
class: TopkDropoutStrategy
|
class: TopkDropoutStrategy
|
||||||
module_path: qlib.contrib.strategy
|
module_path: qlib.contrib.strategy
|
||||||
kwargs:
|
kwargs:
|
||||||
model: <MODEL>
|
signal:
|
||||||
dataset: <DATASET>
|
- <MODEL>
|
||||||
|
- <DATASET>
|
||||||
topk: 50
|
topk: 50
|
||||||
n_drop: 5
|
n_drop: 5
|
||||||
backtest:
|
backtest:
|
||||||
|
|||||||
@@ -36,8 +36,9 @@ port_analysis_config: &port_analysis_config
|
|||||||
class: TopkDropoutStrategy
|
class: TopkDropoutStrategy
|
||||||
module_path: qlib.contrib.strategy
|
module_path: qlib.contrib.strategy
|
||||||
kwargs:
|
kwargs:
|
||||||
model: <MODEL>
|
signal:
|
||||||
dataset: <DATASET>
|
- <MODEL>
|
||||||
|
- <DATASET>
|
||||||
topk: 50
|
topk: 50
|
||||||
n_drop: 5
|
n_drop: 5
|
||||||
backtest:
|
backtest:
|
||||||
|
|||||||
@@ -28,8 +28,9 @@ port_analysis_config: &port_analysis_config
|
|||||||
class: TopkDropoutStrategy
|
class: TopkDropoutStrategy
|
||||||
module_path: qlib.contrib.strategy
|
module_path: qlib.contrib.strategy
|
||||||
kwargs:
|
kwargs:
|
||||||
model: <MODEL>
|
signal:
|
||||||
dataset: <DATASET>
|
- <MODEL>
|
||||||
|
- <DATASET>
|
||||||
topk: 50
|
topk: 50
|
||||||
n_drop: 5
|
n_drop: 5
|
||||||
backtest:
|
backtest:
|
||||||
@@ -85,4 +86,4 @@ task:
|
|||||||
- class: PortAnaRecord
|
- class: PortAnaRecord
|
||||||
module_path: qlib.workflow.record_temp
|
module_path: qlib.workflow.record_temp
|
||||||
kwargs:
|
kwargs:
|
||||||
config: *port_analysis_config
|
config: *port_analysis_config
|
||||||
|
|||||||
@@ -36,8 +36,9 @@ port_analysis_config: &port_analysis_config
|
|||||||
class: TopkDropoutStrategy
|
class: TopkDropoutStrategy
|
||||||
module_path: qlib.contrib.strategy
|
module_path: qlib.contrib.strategy
|
||||||
kwargs:
|
kwargs:
|
||||||
model: <MODEL>
|
signal:
|
||||||
dataset: <DATASET>
|
- <MODEL>
|
||||||
|
- <DATASET>
|
||||||
topk: 50
|
topk: 50
|
||||||
n_drop: 5
|
n_drop: 5
|
||||||
backtest:
|
backtest:
|
||||||
|
|||||||
@@ -28,8 +28,9 @@ port_analysis_config: &port_analysis_config
|
|||||||
class: TopkDropoutStrategy
|
class: TopkDropoutStrategy
|
||||||
module_path: qlib.contrib.strategy
|
module_path: qlib.contrib.strategy
|
||||||
kwargs:
|
kwargs:
|
||||||
model: <MODEL>
|
signal:
|
||||||
dataset: <DATASET>
|
- <MODEL>
|
||||||
|
- <DATASET>
|
||||||
topk: 50
|
topk: 50
|
||||||
n_drop: 5
|
n_drop: 5
|
||||||
backtest:
|
backtest:
|
||||||
@@ -85,4 +86,4 @@ task:
|
|||||||
- class: PortAnaRecord
|
- class: PortAnaRecord
|
||||||
module_path: qlib.workflow.record_temp
|
module_path: qlib.workflow.record_temp
|
||||||
kwargs:
|
kwargs:
|
||||||
config: *port_analysis_config
|
config: *port_analysis_config
|
||||||
|
|||||||
@@ -14,8 +14,9 @@ port_analysis_config: &port_analysis_config
|
|||||||
class: TopkDropoutStrategy
|
class: TopkDropoutStrategy
|
||||||
module_path: qlib.contrib.strategy
|
module_path: qlib.contrib.strategy
|
||||||
kwargs:
|
kwargs:
|
||||||
model: <MODEL>
|
signal:
|
||||||
dataset: <DATASET>
|
- <MODEL>
|
||||||
|
- <DATASET>
|
||||||
topk: 50
|
topk: 50
|
||||||
n_drop: 5
|
n_drop: 5
|
||||||
backtest:
|
backtest:
|
||||||
|
|||||||
@@ -33,6 +33,9 @@ port_analysis_config: &port_analysis_config
|
|||||||
kwargs:
|
kwargs:
|
||||||
topk: 50
|
topk: 50
|
||||||
n_drop: 5
|
n_drop: 5
|
||||||
|
signal:
|
||||||
|
- <MODEL>
|
||||||
|
- <DATASET>
|
||||||
backtest:
|
backtest:
|
||||||
verbose: False
|
verbose: False
|
||||||
limit_threshold: 0.095
|
limit_threshold: 0.095
|
||||||
@@ -80,4 +83,4 @@ task:
|
|||||||
- class: PortAnaRecord
|
- class: PortAnaRecord
|
||||||
module_path: qlib.workflow.record_temp
|
module_path: qlib.workflow.record_temp
|
||||||
kwargs:
|
kwargs:
|
||||||
config: *port_analysis_config
|
config: *port_analysis_config
|
||||||
|
|||||||
@@ -21,8 +21,9 @@ port_analysis_config: &port_analysis_config
|
|||||||
class: TopkDropoutStrategy
|
class: TopkDropoutStrategy
|
||||||
module_path: qlib.contrib.strategy
|
module_path: qlib.contrib.strategy
|
||||||
kwargs:
|
kwargs:
|
||||||
model: <MODEL>
|
signal:
|
||||||
dataset: <DATASET>
|
- <MODEL>
|
||||||
|
- <DATASET>
|
||||||
topk: 50
|
topk: 50
|
||||||
n_drop: 5
|
n_drop: 5
|
||||||
backtest:
|
backtest:
|
||||||
@@ -76,4 +77,4 @@ task:
|
|||||||
- class: PortAnaRecord
|
- class: PortAnaRecord
|
||||||
module_path: qlib.workflow.record_temp
|
module_path: qlib.workflow.record_temp
|
||||||
kwargs:
|
kwargs:
|
||||||
config: *port_analysis_config
|
config: *port_analysis_config
|
||||||
|
|||||||
@@ -29,8 +29,9 @@ port_analysis_config: &port_analysis_config
|
|||||||
class: TopkDropoutStrategy
|
class: TopkDropoutStrategy
|
||||||
module_path: qlib.contrib.strategy
|
module_path: qlib.contrib.strategy
|
||||||
kwargs:
|
kwargs:
|
||||||
model: <MODEL>
|
signal:
|
||||||
dataset: <DATASET>
|
- <MODEL>
|
||||||
|
- <DATASET>
|
||||||
topk: 50
|
topk: 50
|
||||||
n_drop: 5
|
n_drop: 5
|
||||||
backtest:
|
backtest:
|
||||||
|
|||||||
@@ -31,8 +31,9 @@ port_analysis_config: &port_analysis_config
|
|||||||
class: TopkDropoutStrategy
|
class: TopkDropoutStrategy
|
||||||
module_path: qlib.contrib.strategy
|
module_path: qlib.contrib.strategy
|
||||||
kwargs:
|
kwargs:
|
||||||
model: <MODEL>
|
signal:
|
||||||
dataset: <DATASET>
|
- <MODEL>
|
||||||
|
- <DATASET>
|
||||||
topk: 50
|
topk: 50
|
||||||
n_drop: 5
|
n_drop: 5
|
||||||
backtest:
|
backtest:
|
||||||
|
|||||||
@@ -28,8 +28,9 @@ port_analysis_config: &port_analysis_config
|
|||||||
class: TopkDropoutStrategy
|
class: TopkDropoutStrategy
|
||||||
module_path: qlib.contrib.strategy
|
module_path: qlib.contrib.strategy
|
||||||
kwargs:
|
kwargs:
|
||||||
model: <MODEL>
|
signal:
|
||||||
dataset: <DATASET>
|
- <MODEL>
|
||||||
|
- <DATASET>
|
||||||
topk: 50
|
topk: 50
|
||||||
n_drop: 5
|
n_drop: 5
|
||||||
backtest:
|
backtest:
|
||||||
|
|||||||
@@ -36,8 +36,9 @@ port_analysis_config: &port_analysis_config
|
|||||||
class: TopkDropoutStrategy
|
class: TopkDropoutStrategy
|
||||||
module_path: qlib.contrib.strategy
|
module_path: qlib.contrib.strategy
|
||||||
kwargs:
|
kwargs:
|
||||||
model: <MODEL>
|
signal:
|
||||||
dataset: <DATASET>
|
- <MODEL>
|
||||||
|
- <DATASET>
|
||||||
topk: 50
|
topk: 50
|
||||||
n_drop: 5
|
n_drop: 5
|
||||||
backtest:
|
backtest:
|
||||||
|
|||||||
@@ -28,8 +28,9 @@ port_analysis_config: &port_analysis_config
|
|||||||
class: TopkDropoutStrategy
|
class: TopkDropoutStrategy
|
||||||
module_path: qlib.contrib.strategy
|
module_path: qlib.contrib.strategy
|
||||||
kwargs:
|
kwargs:
|
||||||
model: <MODEL>
|
signal:
|
||||||
dataset: <DATASET>
|
- <MODEL>
|
||||||
|
- <DATASET>
|
||||||
topk: 50
|
topk: 50
|
||||||
n_drop: 5
|
n_drop: 5
|
||||||
backtest:
|
backtest:
|
||||||
|
|||||||
@@ -41,8 +41,9 @@ port_analysis_config: &port_analysis_config
|
|||||||
class: TopkDropoutStrategy
|
class: TopkDropoutStrategy
|
||||||
module_path: qlib.contrib.strategy
|
module_path: qlib.contrib.strategy
|
||||||
kwargs:
|
kwargs:
|
||||||
model: <MODEL>
|
signal:
|
||||||
dataset: <DATASET>
|
- <MODEL>
|
||||||
|
- <DATASET>
|
||||||
topk: 50
|
topk: 50
|
||||||
n_drop: 5
|
n_drop: 5
|
||||||
backtest:
|
backtest:
|
||||||
@@ -98,4 +99,4 @@ task:
|
|||||||
- class: PortAnaRecord
|
- class: PortAnaRecord
|
||||||
module_path: qlib.workflow.record_temp
|
module_path: qlib.workflow.record_temp
|
||||||
kwargs:
|
kwargs:
|
||||||
config: *port_analysis_config
|
config: *port_analysis_config
|
||||||
|
|||||||
@@ -29,8 +29,9 @@ port_analysis_config: &port_analysis_config
|
|||||||
class: TopkDropoutStrategy
|
class: TopkDropoutStrategy
|
||||||
module_path: qlib.contrib.strategy
|
module_path: qlib.contrib.strategy
|
||||||
kwargs:
|
kwargs:
|
||||||
model: <MODEL>
|
signal:
|
||||||
dataset: <DATASET>
|
- <MODEL>
|
||||||
|
- <DATASET>
|
||||||
topk: 50
|
topk: 50
|
||||||
n_drop: 5
|
n_drop: 5
|
||||||
backtest:
|
backtest:
|
||||||
@@ -85,4 +86,4 @@ task:
|
|||||||
- class: PortAnaRecord
|
- class: PortAnaRecord
|
||||||
module_path: qlib.workflow.record_temp
|
module_path: qlib.workflow.record_temp
|
||||||
kwargs:
|
kwargs:
|
||||||
config: *port_analysis_config
|
config: *port_analysis_config
|
||||||
|
|||||||
@@ -28,8 +28,9 @@ port_analysis_config: &port_analysis_config
|
|||||||
class: TopkDropoutStrategy
|
class: TopkDropoutStrategy
|
||||||
module_path: qlib.contrib.strategy
|
module_path: qlib.contrib.strategy
|
||||||
kwargs:
|
kwargs:
|
||||||
model: <MODEL>
|
signal:
|
||||||
dataset: <DATASET>
|
- <MODEL>
|
||||||
|
- <DATASET>
|
||||||
topk: 50
|
topk: 50
|
||||||
n_drop: 5
|
n_drop: 5
|
||||||
backtest:
|
backtest:
|
||||||
|
|||||||
@@ -30,8 +30,9 @@ port_analysis_config: &port_analysis_config
|
|||||||
class: TopkDropoutStrategy
|
class: TopkDropoutStrategy
|
||||||
module_path: qlib.contrib.strategy
|
module_path: qlib.contrib.strategy
|
||||||
kwargs:
|
kwargs:
|
||||||
model: <MODEL>
|
signal:
|
||||||
dataset: <DATASET>
|
- <MODEL>
|
||||||
|
- <DATASET>
|
||||||
topk: 50
|
topk: 50
|
||||||
n_drop: 5
|
n_drop: 5
|
||||||
backtest:
|
backtest:
|
||||||
@@ -94,4 +95,4 @@ task:
|
|||||||
- class: PortAnaRecord
|
- class: PortAnaRecord
|
||||||
module_path: qlib.workflow.record_temp
|
module_path: qlib.workflow.record_temp
|
||||||
kwargs:
|
kwargs:
|
||||||
config: *port_analysis_config
|
config: *port_analysis_config
|
||||||
|
|||||||
@@ -16,8 +16,9 @@ port_analysis_config: &port_analysis_config
|
|||||||
class: TopkDropoutStrategy
|
class: TopkDropoutStrategy
|
||||||
module_path: qlib.contrib.strategy
|
module_path: qlib.contrib.strategy
|
||||||
kwargs:
|
kwargs:
|
||||||
model: <MODEL>
|
signal:
|
||||||
dataset: <DATASET>
|
- <MODEL>
|
||||||
|
- <DATASET>
|
||||||
topk: 50
|
topk: 50
|
||||||
n_drop: 5
|
n_drop: 5
|
||||||
backtest:
|
backtest:
|
||||||
|
|||||||
@@ -57,8 +57,9 @@ port_analysis_config: &port_analysis_config
|
|||||||
class: TopkDropoutStrategy
|
class: TopkDropoutStrategy
|
||||||
module_path: qlib.contrib.strategy
|
module_path: qlib.contrib.strategy
|
||||||
kwargs:
|
kwargs:
|
||||||
model: <MODEL>
|
signal:
|
||||||
dataset: <DATASET>
|
- <MODEL>
|
||||||
|
- <DATASET>
|
||||||
topk: 50
|
topk: 50
|
||||||
n_drop: 5
|
n_drop: 5
|
||||||
backtest:
|
backtest:
|
||||||
|
|||||||
@@ -51,8 +51,9 @@ port_analysis_config: &port_analysis_config
|
|||||||
class: TopkDropoutStrategy
|
class: TopkDropoutStrategy
|
||||||
module_path: qlib.contrib.strategy
|
module_path: qlib.contrib.strategy
|
||||||
kwargs:
|
kwargs:
|
||||||
model: <MODEL>
|
signal:
|
||||||
dataset: <DATASET>
|
- <MODEL>
|
||||||
|
- <DATASET>
|
||||||
topk: 50
|
topk: 50
|
||||||
n_drop: 5
|
n_drop: 5
|
||||||
backtest:
|
backtest:
|
||||||
|
|||||||
@@ -51,8 +51,9 @@ port_analysis_config: &port_analysis_config
|
|||||||
class: TopkDropoutStrategy
|
class: TopkDropoutStrategy
|
||||||
module_path: qlib.contrib.strategy
|
module_path: qlib.contrib.strategy
|
||||||
kwargs:
|
kwargs:
|
||||||
model: <MODEL>
|
signal:
|
||||||
dataset: <DATASET>
|
- <MODEL>
|
||||||
|
- <DATASET>
|
||||||
topk: 50
|
topk: 50
|
||||||
n_drop: 5
|
n_drop: 5
|
||||||
backtest:
|
backtest:
|
||||||
|
|||||||
@@ -28,8 +28,9 @@ port_analysis_config: &port_analysis_config
|
|||||||
class: TopkDropoutStrategy
|
class: TopkDropoutStrategy
|
||||||
module_path: qlib.contrib.strategy
|
module_path: qlib.contrib.strategy
|
||||||
kwargs:
|
kwargs:
|
||||||
model: <MODEL>
|
signal:
|
||||||
dataset: <DATASET>
|
- <MODEL>
|
||||||
|
- <DATASET>
|
||||||
topk: 50
|
topk: 50
|
||||||
n_drop: 5
|
n_drop: 5
|
||||||
backtest:
|
backtest:
|
||||||
|
|||||||
@@ -28,8 +28,9 @@ port_analysis_config: &port_analysis_config
|
|||||||
class: TopkDropoutStrategy
|
class: TopkDropoutStrategy
|
||||||
module_path: qlib.contrib.strategy
|
module_path: qlib.contrib.strategy
|
||||||
kwargs:
|
kwargs:
|
||||||
model: <MODEL>
|
signal:
|
||||||
dataset: <DATASET>
|
- <MODEL>
|
||||||
|
- <DATASET>
|
||||||
topk: 50
|
topk: 50
|
||||||
n_drop: 5
|
n_drop: 5
|
||||||
backtest:
|
backtest:
|
||||||
|
|||||||
@@ -36,8 +36,9 @@ port_analysis_config: &port_analysis_config
|
|||||||
class: TopkDropoutStrategy
|
class: TopkDropoutStrategy
|
||||||
module_path: qlib.contrib.strategy
|
module_path: qlib.contrib.strategy
|
||||||
kwargs:
|
kwargs:
|
||||||
model: <MODEL>
|
signal:
|
||||||
dataset: <DATASET>
|
- <MODEL>
|
||||||
|
- <DATASET>
|
||||||
topk: 50
|
topk: 50
|
||||||
n_drop: 5
|
n_drop: 5
|
||||||
backtest:
|
backtest:
|
||||||
|
|||||||
@@ -28,8 +28,9 @@ port_analysis_config: &port_analysis_config
|
|||||||
class: TopkDropoutStrategy
|
class: TopkDropoutStrategy
|
||||||
module_path: qlib.contrib.strategy
|
module_path: qlib.contrib.strategy
|
||||||
kwargs:
|
kwargs:
|
||||||
model: <MODEL>
|
signal:
|
||||||
dataset: <DATASET>
|
- <MODEL>
|
||||||
|
- <DATASET>
|
||||||
topk: 50
|
topk: 50
|
||||||
n_drop: 5
|
n_drop: 5
|
||||||
backtest:
|
backtest:
|
||||||
|
|||||||
@@ -14,8 +14,9 @@ port_analysis_config: &port_analysis_config
|
|||||||
class: TopkDropoutStrategy
|
class: TopkDropoutStrategy
|
||||||
module_path: qlib.contrib.strategy
|
module_path: qlib.contrib.strategy
|
||||||
kwargs:
|
kwargs:
|
||||||
model: <MODEL>
|
signal:
|
||||||
dataset: <DATASET>
|
- <MODEL>
|
||||||
|
- <DATASET>
|
||||||
topk: 50
|
topk: 50
|
||||||
n_drop: 5
|
n_drop: 5
|
||||||
backtest:
|
backtest:
|
||||||
|
|||||||
@@ -21,8 +21,9 @@ port_analysis_config: &port_analysis_config
|
|||||||
class: TopkDropoutStrategy
|
class: TopkDropoutStrategy
|
||||||
module_path: qlib.contrib.strategy
|
module_path: qlib.contrib.strategy
|
||||||
kwargs:
|
kwargs:
|
||||||
model: <MODEL>
|
signal:
|
||||||
dataset: <DATASET>
|
- <MODEL>
|
||||||
|
- <DATASET>
|
||||||
topk: 50
|
topk: 50
|
||||||
n_drop: 5
|
n_drop: 5
|
||||||
backtest:
|
backtest:
|
||||||
|
|||||||
@@ -153,8 +153,7 @@ class NestedDecisionExecutionWorkflow:
|
|||||||
"class": "TopkDropoutStrategy",
|
"class": "TopkDropoutStrategy",
|
||||||
"module_path": "qlib.contrib.strategy.signal_strategy",
|
"module_path": "qlib.contrib.strategy.signal_strategy",
|
||||||
"kwargs": {
|
"kwargs": {
|
||||||
"model": model,
|
"signal": (model, dataset),
|
||||||
"dataset": dataset,
|
|
||||||
"topk": 50,
|
"topk": 50,
|
||||||
"n_drop": 5,
|
"n_drop": 5,
|
||||||
},
|
},
|
||||||
@@ -191,8 +190,7 @@ class NestedDecisionExecutionWorkflow:
|
|||||||
"class": "TopkDropoutStrategy",
|
"class": "TopkDropoutStrategy",
|
||||||
"module_path": "qlib.contrib.strategy.signal_strategy",
|
"module_path": "qlib.contrib.strategy.signal_strategy",
|
||||||
"kwargs": {
|
"kwargs": {
|
||||||
"model": model,
|
"signal": (model, dataset),
|
||||||
"dataset": dataset,
|
|
||||||
"topk": 50,
|
"topk": 50,
|
||||||
"n_drop": 5,
|
"n_drop": 5,
|
||||||
},
|
},
|
||||||
|
|||||||
@@ -33,8 +33,7 @@ if __name__ == "__main__":
|
|||||||
"class": "TopkDropoutStrategy",
|
"class": "TopkDropoutStrategy",
|
||||||
"module_path": "qlib.contrib.strategy.signal_strategy",
|
"module_path": "qlib.contrib.strategy.signal_strategy",
|
||||||
"kwargs": {
|
"kwargs": {
|
||||||
"model": model,
|
"signal": (model, dataset),
|
||||||
"dataset": dataset,
|
|
||||||
"topk": 50,
|
"topk": 50,
|
||||||
"n_drop": 5,
|
"n_drop": 5,
|
||||||
},
|
},
|
||||||
|
|||||||
@@ -1,6 +1,7 @@
|
|||||||
# Copyright (c) Microsoft Corporation.
|
# Copyright (c) Microsoft Corporation.
|
||||||
# Licensed under the MIT License.
|
# Licensed under the MIT License.
|
||||||
from typing import Union
|
from qlib.utils import init_instance_by_config
|
||||||
|
from typing import Dict, List, Text, Tuple, Union
|
||||||
from ..model.base import BaseModel
|
from ..model.base import BaseModel
|
||||||
from ..data.dataset import Dataset
|
from ..data.dataset import Dataset
|
||||||
from ..data.dataset.utils import convert_index_format
|
from ..data.dataset.utils import convert_index_format
|
||||||
@@ -14,7 +15,7 @@ class Signal(metaclass=abc.ABCMeta):
|
|||||||
Some trading strategy make decisions based on other prediction signals
|
Some trading strategy make decisions based on other prediction signals
|
||||||
The signals may comes from different sources(e.g. prepared data, online prediction from model and dataset)
|
The signals may comes from different sources(e.g. prepared data, online prediction from model and dataset)
|
||||||
|
|
||||||
This
|
This interface is tries to provide unified interface for those different sources
|
||||||
"""
|
"""
|
||||||
|
|
||||||
@abc.abstractmethod
|
@abc.abstractmethod
|
||||||
@@ -79,3 +80,23 @@ class ModelSignal(SignalWCache):
|
|||||||
"""
|
"""
|
||||||
# TODO: this method is not included in the framework and could be refactor later
|
# TODO: this method is not included in the framework and could be refactor later
|
||||||
raise NotImplementedError("_update_model is not implemented!")
|
raise NotImplementedError("_update_model is not implemented!")
|
||||||
|
|
||||||
|
|
||||||
|
def create_signal_from(
|
||||||
|
obj: Union[Signal, Tuple[BaseModel, Dataset], List, Dict, Text, pd.Series, pd.DataFrame]
|
||||||
|
) -> Signal:
|
||||||
|
"""
|
||||||
|
create signal from diverse information
|
||||||
|
This method will choose the right method to create a signal based on `obj`
|
||||||
|
Please refer to the code below.
|
||||||
|
"""
|
||||||
|
if isinstance(obj, Signal):
|
||||||
|
return obj
|
||||||
|
elif isinstance(obj, (tuple, list)):
|
||||||
|
return ModelSignal(*obj)
|
||||||
|
elif isinstance(obj, (dict, str)):
|
||||||
|
return init_instance_by_config(obj)
|
||||||
|
elif isinstance(obj, (pd.DataFrame, pd.Series)):
|
||||||
|
return SignalWCache(signal=obj)
|
||||||
|
else:
|
||||||
|
raise NotImplementedError(f"This type of signal is not supported")
|
||||||
|
|||||||
@@ -1,6 +1,8 @@
|
|||||||
|
# Copyright (c) Microsoft Corporation.
|
||||||
|
# Licensed under the MIT License.
|
||||||
import copy
|
import copy
|
||||||
from qlib.backtest.signal import ModelSignal, Signal, SignalWCache
|
from qlib.backtest.signal import Signal, create_signal_from
|
||||||
from typing import Union
|
from typing import Dict, List, Text, Tuple, Union
|
||||||
from qlib.data.dataset import Dataset
|
from qlib.data.dataset import Dataset
|
||||||
from qlib.model.base import BaseModel
|
from qlib.model.base import BaseModel
|
||||||
from qlib.backtest.position import Position
|
from qlib.backtest.position import Position
|
||||||
@@ -25,9 +27,7 @@ class TopkDropoutStrategy(BaseStrategy):
|
|||||||
*,
|
*,
|
||||||
topk,
|
topk,
|
||||||
n_drop,
|
n_drop,
|
||||||
model: BaseModel = None,
|
signal: Union[Signal, Tuple[BaseModel, Dataset], List, Dict, Text, pd.Series, pd.DataFrame],
|
||||||
dataset: Dataset = None,
|
|
||||||
signal: Union[pd.DataFrame, pd.Series] = None,
|
|
||||||
method_sell="bottom",
|
method_sell="bottom",
|
||||||
method_buy="top",
|
method_buy="top",
|
||||||
risk_degree=0.95,
|
risk_degree=0.95,
|
||||||
@@ -45,6 +45,9 @@ class TopkDropoutStrategy(BaseStrategy):
|
|||||||
the number of stocks in the portfolio.
|
the number of stocks in the portfolio.
|
||||||
n_drop : int
|
n_drop : int
|
||||||
number of stocks to be replaced in each trading date.
|
number of stocks to be replaced in each trading date.
|
||||||
|
signal :
|
||||||
|
the information to describe a signal. Please refer to the docs of `qlib.backtest.signal.create_signal_from`
|
||||||
|
the decision of the strategy will base on the given signal
|
||||||
method_sell : str
|
method_sell : str
|
||||||
dropout method_sell, random/bottom.
|
dropout method_sell, random/bottom.
|
||||||
method_buy : str
|
method_buy : str
|
||||||
@@ -79,8 +82,7 @@ class TopkDropoutStrategy(BaseStrategy):
|
|||||||
self.risk_degree = risk_degree
|
self.risk_degree = risk_degree
|
||||||
self.hold_thresh = hold_thresh
|
self.hold_thresh = hold_thresh
|
||||||
self.only_tradable = only_tradable
|
self.only_tradable = only_tradable
|
||||||
assert signal is not None or dataset is not None and model is not None
|
self.signal: Signal = create_signal_from(signal)
|
||||||
self.signal: Signal = ModelSignal(model=model, dataset=dataset) if signal is None else SignalWCache(signal)
|
|
||||||
|
|
||||||
def get_risk_degree(self, trade_step=None):
|
def get_risk_degree(self, trade_step=None):
|
||||||
"""get_risk_degree
|
"""get_risk_degree
|
||||||
@@ -251,9 +253,7 @@ class WeightStrategyBase(BaseStrategy):
|
|||||||
def __init__(
|
def __init__(
|
||||||
self,
|
self,
|
||||||
*,
|
*,
|
||||||
model: BaseModel = None,
|
signal: Union[Signal, Tuple[BaseModel, Dataset], List, Dict, Text, pd.Series, pd.DataFrame],
|
||||||
dataset: Dataset = None,
|
|
||||||
signal: Union[pd.DataFrame, pd.Series] = None,
|
|
||||||
order_generator_cls_or_obj=OrderGenWInteract,
|
order_generator_cls_or_obj=OrderGenWInteract,
|
||||||
trade_exchange=None,
|
trade_exchange=None,
|
||||||
level_infra=None,
|
level_infra=None,
|
||||||
@@ -261,6 +261,9 @@ class WeightStrategyBase(BaseStrategy):
|
|||||||
**kwargs,
|
**kwargs,
|
||||||
):
|
):
|
||||||
"""
|
"""
|
||||||
|
signal :
|
||||||
|
the information to describe a signal. Please refer to the docs of `qlib.backtest.signal.create_signal_from`
|
||||||
|
the decision of the strategy will base on the given signal
|
||||||
trade_exchange : Exchange
|
trade_exchange : Exchange
|
||||||
exchange that provides market info, used to deal order and generate report
|
exchange that provides market info, used to deal order and generate report
|
||||||
- If `trade_exchange` is None, self.trade_exchange will be set with common_infra
|
- If `trade_exchange` is None, self.trade_exchange will be set with common_infra
|
||||||
@@ -276,8 +279,8 @@ class WeightStrategyBase(BaseStrategy):
|
|||||||
self.order_generator = order_generator_cls_or_obj()
|
self.order_generator = order_generator_cls_or_obj()
|
||||||
else:
|
else:
|
||||||
self.order_generator = order_generator_cls_or_obj
|
self.order_generator = order_generator_cls_or_obj
|
||||||
assert signal is not None or dataset is not None and model is not None
|
|
||||||
self.signal: Signal = ModelSignal(model=model, dataset=dataset) if signal is None else SignalWCache(signal)
|
self.signal: Signal = create_signal_from(signal)
|
||||||
|
|
||||||
def get_risk_degree(self, trade_step=None):
|
def get_risk_degree(self, trade_step=None):
|
||||||
"""get_risk_degree
|
"""get_risk_degree
|
||||||
|
|||||||
@@ -146,8 +146,7 @@ def backtest_analysis(pred, rid, uri_path: str = None):
|
|||||||
"class": "TopkDropoutStrategy",
|
"class": "TopkDropoutStrategy",
|
||||||
"module_path": "qlib.contrib.strategy.signal_strategy",
|
"module_path": "qlib.contrib.strategy.signal_strategy",
|
||||||
"kwargs": {
|
"kwargs": {
|
||||||
"model": model,
|
"signal": (model, dataset),
|
||||||
"dataset": dataset,
|
|
||||||
"topk": 50,
|
"topk": 50,
|
||||||
"n_drop": 5,
|
"n_drop": 5,
|
||||||
},
|
},
|
||||||
|
|||||||
Reference in New Issue
Block a user