mirror of
https://github.com/microsoft/qlib.git
synced 2026-07-04 11:30:57 +08:00
Merge branch 'nested_decision_exe' of https://github.com/microsoft/qlib into rl-dummy
This commit is contained in:
@@ -20,7 +20,7 @@ class NestedDecisonExecutionWorkflow:
|
||||
benchmark = "SH000300"
|
||||
data_handler_config = {
|
||||
"start_time": "2008-01-01",
|
||||
"end_time": "2021-05-28",
|
||||
"end_time": "2020-12-31",
|
||||
"fit_start_time": "2008-01-01",
|
||||
"fit_end_time": "2014-12-31",
|
||||
"instruments": market,
|
||||
@@ -54,7 +54,7 @@ class NestedDecisonExecutionWorkflow:
|
||||
"segments": {
|
||||
"train": ("2007-01-01", "2014-12-31"),
|
||||
"valid": ("2015-01-01", "2016-12-31"),
|
||||
"test": ("2020-09-01", "2021-05-28"),
|
||||
"test": ("2020-01-01", "2020-12-31"),
|
||||
},
|
||||
},
|
||||
},
|
||||
@@ -79,12 +79,8 @@ class NestedDecisonExecutionWorkflow:
|
||||
},
|
||||
},
|
||||
"inner_strategy": {
|
||||
"class": "SBBStrategyEMA",
|
||||
"class": "TWAPStrategy",
|
||||
"module_path": "qlib.contrib.strategy.rule_strategy",
|
||||
"kwargs": {
|
||||
"freq": "day",
|
||||
"instruments": market,
|
||||
},
|
||||
},
|
||||
"track_data": True,
|
||||
"generate_report": True,
|
||||
@@ -94,8 +90,8 @@ class NestedDecisonExecutionWorkflow:
|
||||
},
|
||||
},
|
||||
"backtest": {
|
||||
"start_time": "2020-09-20",
|
||||
"end_time": "2021-05-28",
|
||||
"start_time": "2020-01-01",
|
||||
"end_time": "2020-12-31",
|
||||
"account": 100000000,
|
||||
"benchmark": benchmark,
|
||||
"exchange_kwargs": {
|
||||
|
||||
@@ -1,14 +1,21 @@
|
||||
# Copyright (c) Microsoft Corporation.
|
||||
# Licensed under the MIT License.
|
||||
import copy
|
||||
|
||||
from .account import Account
|
||||
from .exchange import Exchange
|
||||
from .executor import BaseExecutor
|
||||
from .backtest import backtest_loop
|
||||
from .backtest import collect_data_loop
|
||||
<<<<<<< HEAD
|
||||
|
||||
from .order import Order
|
||||
from .utils import CommonInfrastructure, TradeCalendarManager
|
||||
=======
|
||||
from .utils import CommonInfrastructure
|
||||
from .order import Order
|
||||
|
||||
>>>>>>> ab97e8248443789ce1e0f90a9b5596e5fee60566
|
||||
from ..strategy.base import BaseStrategy
|
||||
from ..utils import init_instance_by_config
|
||||
from ..log import get_module_logger
|
||||
@@ -101,10 +108,15 @@ def get_strategy_executor(
|
||||
"end_time": end_time,
|
||||
},
|
||||
)
|
||||
|
||||
exchange_kwargs = copy.copy(exchange_kwargs)
|
||||
if "start_time" not in exchange_kwargs:
|
||||
exchange_kwargs["start_time"] = start_time
|
||||
if "end_time" not in exchange_kwargs:
|
||||
exchange_kwargs["end_time"] = end_time
|
||||
trade_exchange = get_exchange(**exchange_kwargs)
|
||||
|
||||
common_infra = CommonInfrastructure(trade_account=trade_account, trade_exchange=trade_exchange)
|
||||
|
||||
trade_strategy = init_instance_by_config(strategy, accept_types=BaseStrategy, common_infra=common_infra)
|
||||
trade_executor = init_instance_by_config(executor, accept_types=BaseExecutor, common_infra=common_infra)
|
||||
|
||||
|
||||
@@ -174,8 +174,8 @@ class Exchange:
|
||||
self.quote = quote_dict
|
||||
|
||||
def _update_limit(self, buy_limit, sell_limit):
|
||||
self.quote["limit_buy"] = ~self.quote["$change"].lt(buy_limit)
|
||||
self.quote["limit_sell"] = ~self.quote["$change"].gt(-sell_limit)
|
||||
self.quote["limit_buy"] = self.quote["$change"].ge(buy_limit)
|
||||
self.quote["limit_sell"] = self.quote["$change"].le(-sell_limit)
|
||||
|
||||
def check_stock_limit(self, stock_id, start_time, end_time, direction=None):
|
||||
"""
|
||||
|
||||
@@ -7,6 +7,7 @@ import warnings
|
||||
import pandas as pd
|
||||
from pathlib import Path
|
||||
from pprint import pprint
|
||||
from typing import Union, List
|
||||
from ..contrib.evaluate import indicator_analysis, risk_analysis, indicator_analysis
|
||||
|
||||
from ..data.dataset import DatasetH
|
||||
@@ -295,7 +296,13 @@ class PortAnaRecord(RecordTemp):
|
||||
artifact_path = "portfolio_analysis"
|
||||
|
||||
def __init__(
|
||||
self, recorder, config, risk_analysis_freq, indicator_analysis_freq, indicator_analysis_method=None, **kwargs
|
||||
self,
|
||||
recorder,
|
||||
config,
|
||||
risk_analysis_freq: Union[List, str] = [],
|
||||
indicator_analysis_freq: Union[List, str] = [],
|
||||
indicator_analysis_method=None,
|
||||
**kwargs,
|
||||
):
|
||||
"""
|
||||
config["strategy"] : dict
|
||||
|
||||
Reference in New Issue
Block a user