fixed Selector

This commit is contained in:
fasiondog 2020-08-31 23:51:24 +08:00
parent 562e65b21e
commit 0e866a7112
4 changed files with 38 additions and 8 deletions

View File

@ -400,6 +400,20 @@ def Query_getattr(self, name):
Query.__getattr__ = Query_getattr
@deprecated_attr(
{
'getParam': 'get_param',
'setParam': 'set_param',
'haveParam': 'have_param',
'getSelectedSystemList': 'get_selected_system_list',
'addStock': 'add_stock',
'addStockList': 'add_stock_list',
}
)
def SelectorBase_getattr(self, name):
return getattr(self, name)
@deprecated_attr(
{
'getTO': 'to',

View File

@ -296,6 +296,21 @@ def crtSG(func, params={}, name='crtSG'):
return meta_x(name, params)
#------------------------------------------------------------------
# Selector
#------------------------------------------------------------------
def se_add_stock_list(self, stk_list, proto_sys):
result = True
for stk in stk_list:
success = self.add_stock(stk, proto_sys)
if not success:
result = False
break
return result
SelectorBase.add_stock_list = se_add_stock_list
#------------------------------------------------------------------
# slippage
#------------------------------------------------------------------

View File

@ -107,7 +107,7 @@ bool SelectorBase::addStock(const Stock& stock, const SystemPtr& protoSys) {
SYSPtr sys = protoSys->clone();
sys->setStock(stock);
m_sys_list.push_back(sys);
return false;
return true;
}
bool SelectorBase::addStockList(const StockList& stkList, const SystemPtr& protoSys) {

View File

@ -32,7 +32,7 @@ public:
}
SystemList getSelectedSystemList(Datetime date) {
return this->get_override("getSelectedSystemList")(date);
return this->get_override("get_selected_system_list")(date);
}
SelectorPtr _clone() {
@ -51,18 +51,19 @@ void export_Selector() {
.def(init<const string&>())
.def(self_ns::str(self))
.def(self_ns::repr(self))
.add_property("name", sb_get_name, sb_set_name)
.def("getParam", &SelectorBase::getParam<boost::any>)
.def("setParam", &SelectorBase::setParam<object>)
.def("haveParam", &SelectorBase::haveParam)
.def("get_param", &SelectorBase::getParam<boost::any>)
.def("set_param", &SelectorBase::setParam<object>)
.def("have_param", &SelectorBase::haveParam)
.def("reset", &SelectorBase::reset)
.def("clone", &SelectorBase::clone)
.def("_reset", &SelectorBase::_reset, &SelectorWrap::default_reset)
.def("_clone", pure_virtual(&SelectorBase::_clone))
.def("getSelectedSystemList", pure_virtual(&SelectorBase::getSelectedSystemList))
.def("addStock", &SelectorBase::addStock)
.def("addStockList", &SelectorBase::addStockList)
.def("get_selected_system_list", pure_virtual(&SelectorBase::getSelectedSystemList))
.def("add_stock", &SelectorBase::addStock)
//.def("add_stock_list", &SelectorBase::addStockList) // 在python中扩展
.def("clear", &SelectorBase::clear)
#if HKU_PYTHON_SUPPORT_PICKLE
.def_pickle(name_init_pickle_suite<SelectorBase>())