Open Imbernoulli opened 1 year ago
Maybe you can try setting the executor parameter verbose
to True
. code reference
port_analysis_config = {
"executor": {
"class": "SimulatorExecutor",
"module_path": "qlib.backtest.executor",
"kwargs": {
"time_per_step": "day",
"generate_portfolio_metrics": True,
"verbose": True,
},
},
"strategy": {
...
},
"backtest": {
...
},
}
usage in config file (.yaml
)
---
qlib_init:
...
task:
model:
...
dataset:
...
record:
- class: SignalRecord
module_path: qlib.workflow.record_temp
kwargs:
...
- class: PortAnaRecord
module_path: qlib.workflow.record_temp
kwargs:
config:
executor:
class: SimulatorExecutor
module_path: qlib.backtest.executor
kwargs:
time_per_step: day
generate_portfolio_metrics: True
verbose: True
strategy:
...
backtest:
...
Thank you for your reply.
I add executor: class: SimulatorExecutor module_path: qlib.backtest.executor kwargs: time_per_step: day generate_portfolio_metrics: True verbose: True
to port_analysis_config: &port_analysis_config
and it works.
🌟 Feature Description
In some modes, transaction detail will be showed as output, like:
[I 2017-03-08 00:00:00]: buy SH601919,price 0.38,amount 5516124.0033530545.deal amount 5516124.0083530545.factor 0.06366799771785736.value 2114227.46.cash 20360177.33
.However, in the most general modes, daily trade in deep learning mode, it is not showed.
Actually, this is not because these things are not generated in this nodes, in the following codes, if I delete the
if
and always run the following code, above items will be in the output.if self.verbose: print( "[I {:%Y-%m-%d %H:%M:%S}]: {} {}, price {:.2f}, amount {}, deal_amount {}, factor {}, " "value {:.2f}, cash {:.2f}.".format( trade_start_time, "sell" if order.direction == Order.SELL else "buy", order.stock_id, trade_price, order.amount, order.deal_amount, order.factor, trade_val, self.trade_account.get_cash(), ), )
However, in the config file, there is no choice to control whether these will be in the output. We can't beautifully config whether this will be shown in the output, or be saved in other format. If these details is saved, it will add a lot to the reliability of the analysis.