From 8189538924f31ad1fc3d19171c1f70db67908f06 Mon Sep 17 00:00:00 2001 From: fasiondog Date: Thu, 15 Aug 2024 13:48:22 +0800 Subject: [PATCH] =?UTF-8?q?TradeManagerBase=E8=A1=A5=E5=85=85=E5=86=BB?= =?UTF-8?q?=E7=BB=93=E8=B5=84=E9=87=91=E6=8E=A5=E5=8F=A3?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- hikyuu_cpp/hikyuu/trade_manage/TradeManagerBase.h | 7 +++++++ hikyuu_pywrap/trade_manage/_TradeManager.cpp | 8 ++++++++ 2 files changed, 15 insertions(+) diff --git a/hikyuu_cpp/hikyuu/trade_manage/TradeManagerBase.h b/hikyuu_cpp/hikyuu/trade_manage/TradeManagerBase.h index 46f7584d..16d255c3 100644 --- a/hikyuu_cpp/hikyuu/trade_manage/TradeManagerBase.h +++ b/hikyuu_cpp/hikyuu/trade_manage/TradeManagerBase.h @@ -322,6 +322,13 @@ public: return 0.0; } + /** + * 当前冻结现金 + */ + virtual price_t currentFrozen() const { + return 0.0; + } + /** * 获取指定日期的现金 * @note 如果不带日期参数,无法根据权息信息调整持仓 diff --git a/hikyuu_pywrap/trade_manage/_TradeManager.cpp b/hikyuu_pywrap/trade_manage/_TradeManager.cpp index b24d730f..9b65c428 100644 --- a/hikyuu_pywrap/trade_manage/_TradeManager.cpp +++ b/hikyuu_pywrap/trade_manage/_TradeManager.cpp @@ -51,6 +51,10 @@ public: PYBIND11_OVERRIDE_NAME(price_t, TradeManagerBase, "current_cash", currentCash); } + price_t currentFrozen() const override { + PYBIND11_OVERRIDE_NAME(price_t, TradeManagerBase, "current_frozen", currentFrozen); + } + price_t cash(const Datetime& datetime, KQuery::KType ktype) override { PYBIND11_OVERLOAD(price_t, TradeManagerBase, cash, datetime, ktype); } @@ -281,6 +285,10 @@ void export_TradeManager(py::module& m) { 默认情况下,TradeManager会在执行买入/卖出操作时,调用订单代理执行代理的买入/卖出动作,但这样在实盘操作时会存在问题。因为系统在计算信号指示时,需要回溯历史数据才能得到最新的信号,这样TradeManager会在历史时刻就执行买入/卖出操作,此时如果订单代理本身没有对发出买入/卖出指令的时刻进行控制,会导致代理发送错误的指令。此时,需要指定在某一个时刻之后,才允许指定订单代理的买入/卖出操作。属性 brokeLastDatetime 即用于指定该时刻。)") + .def("current_frozen", &TradeManagerBase::currentFrozen, R"(frozen(self) + + 获取当前冻结资金)") + .def("getParam", &TradeManagerBase::getParam, R"(get_param(self, name) 获取指定的参数