@@ -15,8 +15,18 @@ void export_StrategeContext(py::module& m) {
15
15
py::class_<StrategyContext>(m, " StrategyContext" , " 策略上下文" )
16
16
.def (py::init<>())
17
17
.def (py::init<const vector<string>&>())
18
- .def (py::init<const vector<string>&, const vector<KQuery::KType>&>(), py::arg (" stock_list" ),
19
- py::arg (" ktype_list" ))
18
+ .def (py::init<const vector<string>&, const vector<KQuery::KType>&,
19
+ const unordered_map<string, int >&>(),
20
+ py::arg (" stock_list" ), py::arg (" ktype_list" ),
21
+ py::arg (" preload_num" ) = unordered_map<string, int >(),
22
+ R"( __init__(self, stock_list, ktype_list, [preload_num={}])
23
+
24
+ 创建策略上下文
25
+
26
+ :param stock_list: 需要加载的证券代码列表,如:["sz000001", "sz000002"], 如包含 'ALL', 表示加载全部
27
+ :param ktype_list: 需要加载的K线类型列表, 如:["day", "min"], 未指定时取全局配置文件中配置的默认值
28
+ :param preload_num: 预加载数量,默认为空,如:{"min_max": 100, "day_max": 200}. 未指定时取全局配置文件中配置的默认值
29
+ :return: 策略上下文对象)" )
20
30
21
31
.def (" __str__" , &StrategyContext::str)
22
32
.def (" __repr__" , &StrategyContext::str)
@@ -29,6 +39,8 @@ void export_StrategeContext(py::module& m) {
29
39
&StrategyContext::setStockCodeList, py::return_value_policy::copy, " 股票代码列表" )
30
40
.def_property (" ktype_list" , py::overload_cast<>(&StrategyContext::getKTypeList, py::const_),
31
41
&StrategyContext::setKTypeList, py::return_value_policy::copy, " 需要的K线类型" )
42
+ .def_property (" preload_num" , py::overload_cast<>(&StrategyContext::getPreloadNum, py::const_),
43
+ &StrategyContext::setPreloadNum, py::return_value_policy::copy, " 预加载数量" )
32
44
33
45
.def (" empty" , &StrategyContext::empty, " 上下文证券代码列表是否为空" );
34
46
}
0 commit comments