mirror of
https://gitee.com/fasiondog/hikyuu.git
synced 2024-11-30 02:48:57 +08:00
update notebook examples and fixed
This commit is contained in:
parent
4f15153b03
commit
a06253014e
@ -274,4 +274,4 @@ class jqdataKDataDriver(KDataDriver):
|
||||
#hku_param = sm.getHikyuuParameter()
|
||||
|
||||
#切换K线数据驱动,重新初始化
|
||||
#sm.init(base_param, block_param, jqdata_param, preload_param, hku_param)
|
||||
#sm.init(base_param, block_param, jqdata_param, preload_param, hku_param, StrategyContext())
|
||||
|
@ -289,4 +289,4 @@ class PytdxKDataDriver(KDataDriver):
|
||||
#hku_param = sm.get_hikyuu_parameter()
|
||||
|
||||
#切换K线数据驱动,重新初始化
|
||||
#sm.init(base_param, block_param, tdx_param, preload_param, hku_param)
|
||||
#sm.init(base_param, block_param, tdx_param, preload_param, hku_param, StrategyContext())
|
||||
|
@ -113,6 +113,21 @@ def SL_FixedValue(*args, **kwargs):
|
||||
#--------------------------------------------------------------------
|
||||
|
||||
|
||||
@deprecated_attr(
|
||||
{
|
||||
'getParam': 'get_param',
|
||||
'setParam': 'set_param',
|
||||
'haveParam': 'have_param',
|
||||
'_allocateWeight': '_allocate_weight',
|
||||
}
|
||||
)
|
||||
def AllocateFundsBase_getattr(self, name):
|
||||
return getattr(self, name)
|
||||
|
||||
|
||||
AllocateFundsBase.__getattr__ = AllocateFundsBase_getattr
|
||||
|
||||
|
||||
@deprecated_attr({'size': '__len__', 'get': '__getitem__'})
|
||||
def Block_getattr(self, name):
|
||||
return getattr(self, name)
|
||||
|
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
@ -125,7 +125,7 @@ for p in kdata_config:
|
||||
|
||||
#set_log_level(LOG_LEVEL.INFO)
|
||||
sm = StockManager.instance()
|
||||
sm.init(base_param, block_param, kdata_param, preload_param, hku_param)
|
||||
sm.init(base_param, block_param, kdata_param, preload_param, hku_param, StrategyContext())
|
||||
set_log_level(LOG_LEVEL.INFO)
|
||||
|
||||
# 启动行情接收代理
|
||||
|
@ -74,7 +74,7 @@ void hikyuu_init(const string& config_file_name, bool ignore_preload) {
|
||||
}
|
||||
|
||||
StockManager& sm = StockManager::instance();
|
||||
sm.init(baseParam, blockParam, kdataParam, preloadParam, hkuParam);
|
||||
sm.init(baseParam, blockParam, kdataParam, preloadParam, hkuParam, StrategyContext());
|
||||
}
|
||||
|
||||
string getVersion() {
|
||||
|
@ -32,7 +32,7 @@ public:
|
||||
}
|
||||
|
||||
SystemWeightList _allocateWeight(const Datetime& date, const SystemList& se_list) {
|
||||
return this->get_override("_allocateWeight")(date, se_list);
|
||||
return this->get_override("_allocate_weight")(date, se_list);
|
||||
}
|
||||
|
||||
AFPtr _clone() {
|
||||
@ -69,15 +69,15 @@ void export_AllocateFunds() {
|
||||
.def(self_ns::str(self))
|
||||
.def(self_ns::repr(self))
|
||||
.add_property("name", af_get_name, af_set_name)
|
||||
.def("getParam", &AllocateFundsBase::getParam<boost::any>)
|
||||
.def("setParam", &AllocateFundsBase::setParam<object>)
|
||||
.def("haveParam", &AllocateFundsBase::haveParam)
|
||||
.def("get_param", &AllocateFundsBase::getParam<boost::any>)
|
||||
.def("set_param", &AllocateFundsBase::setParam<object>)
|
||||
.def("have_param", &AllocateFundsBase::haveParam)
|
||||
|
||||
.def("reset", &AllocateFundsBase::reset)
|
||||
.def("clone", &AllocateFundsBase::clone)
|
||||
.def("_reset", &AllocateFundsBase::_reset, &AllocateFundsBaseWrap::default_reset)
|
||||
.def("_clone", pure_virtual(&AllocateFundsBase::_clone))
|
||||
.def("_allocateWeight", pure_virtual(&AllocateFundsBase::_allocateWeight))
|
||||
.def("_allocate_weight", pure_virtual(&AllocateFundsBase::_allocateWeight))
|
||||
#if HKU_PYTHON_SUPPORT_PICKLE
|
||||
.def_pickle(name_init_pickle_suite<AllocateFundsBase>())
|
||||
#endif
|
||||
|
@ -19,7 +19,7 @@ public:
|
||||
MoneyManagerWrap(const string& name) : MoneyManagerBase(name) {}
|
||||
|
||||
void buyNotify(const TradeRecord& record) {
|
||||
if (override buyNotify = this->get_override("buyNotify")) {
|
||||
if (override buyNotify = this->get_override("buy_notify")) {
|
||||
buyNotify(record);
|
||||
return;
|
||||
}
|
||||
@ -31,7 +31,7 @@ public:
|
||||
}
|
||||
|
||||
void sellNotify(const TradeRecord& record) {
|
||||
if (override sellNotify = this->get_override("sellNotify")) {
|
||||
if (override sellNotify = this->get_override("sell_notify")) {
|
||||
sellNotify(record);
|
||||
return;
|
||||
}
|
||||
@ -44,7 +44,7 @@ public:
|
||||
|
||||
double _getSellNumber(const Datetime& datetime, const Stock& stock, price_t price, price_t risk,
|
||||
SystemPart from) {
|
||||
if (override _getSellNumber = this->get_override("_getSellNumber")) {
|
||||
if (override _getSellNumber = this->get_override("_get_sell_num")) {
|
||||
return _getSellNumber(datetime, stock, price, risk, from);
|
||||
}
|
||||
return MoneyManagerBase::_getSellNumber(datetime, stock, price, risk, from);
|
||||
@ -57,12 +57,12 @@ public:
|
||||
|
||||
double _getBuyNumber(const Datetime& datetime, const Stock& stock, price_t price, price_t risk,
|
||||
SystemPart from) {
|
||||
return this->get_override("_getBuyNumber")(datetime, stock, price, risk, from);
|
||||
return this->get_override("_get_buy_num")(datetime, stock, price, risk, from);
|
||||
}
|
||||
|
||||
double _getSellShortNumber(const Datetime& datetime, const Stock& stock, price_t price,
|
||||
price_t risk, SystemPart from) {
|
||||
if (override _getSellShortNumber = this->get_override("_getSellShortNumber")) {
|
||||
if (override _getSellShortNumber = this->get_override("_get_sell_short_num")) {
|
||||
return _getSellShortNumber(datetime, stock, price, risk, from);
|
||||
}
|
||||
return MoneyManagerBase::_getSellShortNumber(datetime, stock, price, risk, from);
|
||||
@ -75,7 +75,7 @@ public:
|
||||
|
||||
double getBuyShortNumber(const Datetime& datetime, const Stock& stock, price_t price,
|
||||
price_t risk, SystemPart from) {
|
||||
if (override _getBuyShortNumber = this->get_override("_getBuyShortNumber")) {
|
||||
if (override _getBuyShortNumber = this->get_override("_get_buy_short_number")) {
|
||||
return _getBuyShortNumber(datetime, stock, price, risk, from);
|
||||
}
|
||||
return MoneyManagerBase::_getBuyShortNumber(datetime, stock, price, risk, from);
|
||||
@ -151,7 +151,7 @@ void export_MoneyManager() {
|
||||
:param value: 参数值
|
||||
:raises logic_error: Unsupported type! 不支持的参数类型)")
|
||||
|
||||
.def("haveParam", &MoneyManagerBase::haveParam, "是否存在指定参数")
|
||||
.def("have_param", &MoneyManagerBase::haveParam, "是否存在指定参数")
|
||||
|
||||
.def("reset", &MoneyManagerBase::reset, "复位操作")
|
||||
.def("clone", &MoneyManagerBase::clone, "克隆操作")
|
||||
|
@ -40,7 +40,7 @@ public:
|
||||
}
|
||||
|
||||
void buyNotify(const TradeRecord& tr) {
|
||||
if (override buy_notify = this->get_override("buyNotify")) {
|
||||
if (override buy_notify = this->get_override("buy_notify")) {
|
||||
buy_notify(tr);
|
||||
return;
|
||||
}
|
||||
@ -53,7 +53,7 @@ public:
|
||||
}
|
||||
|
||||
void sellNotify(const TradeRecord& tr) {
|
||||
if (override sell_notify = this->get_override("sellNotify")) {
|
||||
if (override sell_notify = this->get_override("sell_notify")) {
|
||||
sell_notify(tr);
|
||||
return;
|
||||
}
|
||||
@ -66,11 +66,11 @@ public:
|
||||
}
|
||||
|
||||
price_t getGoal(const Datetime& datetime, price_t price) {
|
||||
return this->get_override("getGoal")(datetime, price);
|
||||
return this->get_override("get_goal")(datetime, price);
|
||||
}
|
||||
|
||||
price_t getShortGoal(const Datetime& datetime, price_t price) {
|
||||
if (override getShortGoal = get_override("getShortGoal")) {
|
||||
if (override getShortGoal = get_override("get_short_goal")) {
|
||||
return getShortGoal(datetime, price);
|
||||
}
|
||||
return ProfitGoalBase::getShortGoal(datetime, price);
|
||||
|
@ -41,11 +41,11 @@ public:
|
||||
}
|
||||
|
||||
price_t getRealBuyPrice(const Datetime& datetime, price_t price) {
|
||||
return this->get_override("getRealBuyPrice")(datetime, price);
|
||||
return this->get_override("get_real_buy_price")(datetime, price);
|
||||
}
|
||||
|
||||
price_t getRealSellPrice(const Datetime& datetime, price_t price) {
|
||||
return this->get_override("getRealSellPrice")(datetime, price);
|
||||
return this->get_override("get_real_sell_price")(datetime, price);
|
||||
}
|
||||
};
|
||||
|
||||
|
@ -40,11 +40,11 @@ public:
|
||||
}
|
||||
|
||||
price_t getPrice(const Datetime& datetime, price_t price) {
|
||||
return this->get_override("getPrice")(datetime, price);
|
||||
return this->get_override("get_price")(datetime, price);
|
||||
}
|
||||
|
||||
price_t getShortPrice(const Datetime& datetime, price_t price) {
|
||||
if (override getShortPrice = get_override("getShortPrice")) {
|
||||
if (override getShortPrice = get_override("get_short_price")) {
|
||||
return getShortPrice(datetime, price);
|
||||
}
|
||||
return StoplossBase::getShortPrice(datetime, price);
|
||||
|
Loading…
Reference in New Issue
Block a user