From 79b37b28b82937260ae2776c72af5301905edfe4 Mon Sep 17 00:00:00 2001 From: fasiondog Date: Tue, 30 Aug 2022 01:16:02 +0800 Subject: [PATCH] =?UTF-8?q?remove=20getBorrowStockCost=E3=80=81getReturnSt?= =?UTF-8?q?ockCost?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../hikyuu/trade_manage/TradeCostBase.h | 26 --------------- .../hikyuu/trade_manage/TradeManager.cpp | 22 +++++++++++++ .../hikyuu/trade_manage/TradeManagerBase.h | 28 ---------------- .../hikyuu/trade_manage/imp/TradeCostStub.h | 11 ------- hikyuu_pywrap/trade_manage/_TradeCost.cpp | 33 ------------------- hikyuu_pywrap/trade_manage/_TradeManager.cpp | 3 -- 6 files changed, 22 insertions(+), 101 deletions(-) diff --git a/hikyuu_cpp/hikyuu/trade_manage/TradeCostBase.h b/hikyuu_cpp/hikyuu/trade_manage/TradeCostBase.h index 5093d0fb..1194d061 100644 --- a/hikyuu_cpp/hikyuu/trade_manage/TradeCostBase.h +++ b/hikyuu_cpp/hikyuu/trade_manage/TradeCostBase.h @@ -64,32 +64,6 @@ public: virtual CostRecord getSellCost(const Datetime& datetime, const Stock& stock, price_t price, double num) const = 0; - /** - * 计算融劵借入成本 - * @param datetime 融劵日期 - * @param stock 借入的对象 - * @param price 每股价格 - * @param num 借入的数量 - */ - virtual CostRecord getBorrowStockCost(const Datetime& datetime, const Stock& stock, - price_t price, double num) const { - return CostRecord(); - } - - /** - * 计算融劵归还成本 - * @param borrow_datetime 借入日期 - * @param return_datetime 归还日期 - * @param stock 归还的对象 - * @param price 归还时每股价格 - * @param num 归还的数量 - */ - virtual CostRecord getReturnStockCost(const Datetime& borrow_datetime, - const Datetime& return_datetime, const Stock& stock, - price_t price, double num) const { - return CostRecord(); - } - /** 继承子类必须实现私有变量的克隆接口 */ virtual TradeCostPtr _clone() = 0; diff --git a/hikyuu_cpp/hikyuu/trade_manage/TradeManager.cpp b/hikyuu_cpp/hikyuu/trade_manage/TradeManager.cpp index bbb87adb..4d28c2ec 100644 --- a/hikyuu_cpp/hikyuu/trade_manage/TradeManager.cpp +++ b/hikyuu_cpp/hikyuu/trade_manage/TradeManager.cpp @@ -1247,6 +1247,28 @@ void TradeManager::_saveAction(const TradeRecord& record) { << record.planPrice << sep << record.from << ")"; break; + case BUSINESS_BORROW_CASH: + buf << my_tm << "borrowCash(Datetime('" << record.datetime.str() << "'), " + << record.realPrice << ")"; + break; + + case BUSINESS_RETURN_CASH: + buf << my_tm << "returnCash(Datetime('" << record.datetime.str() << "'), " + << record.realPrice << ")"; + break; + + case BUSINESS_BORROW_STOCK: + buf << my_tm << "borrowStock(Datetime('" << record.datetime.str() << "'), " + << "sm['" << record.stock.market_code() << "'], " << record.realPrice << sep + << record.number << ")"; + break; + + case BUSINESS_RETURN_STOCK: + buf << my_tm << "returnStock(Datetime('" << record.datetime.str() << "'), " + << "sm['" << record.stock.market_code() << "'], " << record.realPrice << sep + << record.number << ")"; + break; + default: break; } diff --git a/hikyuu_cpp/hikyuu/trade_manage/TradeManagerBase.h b/hikyuu_cpp/hikyuu/trade_manage/TradeManagerBase.h index 54fbec5e..624b298b 100644 --- a/hikyuu_cpp/hikyuu/trade_manage/TradeManagerBase.h +++ b/hikyuu_cpp/hikyuu/trade_manage/TradeManagerBase.h @@ -96,34 +96,6 @@ public: return m_costfunc ? m_costfunc->getSellCost(datetime, stock, price, num) : CostRecord(); } - /** - * 计算融劵借入成本 - * @param datetime 融劵日期 - * @param stock 借入的对象 - * @param price 每股价格 - * @param num 借入的数量 - */ - CostRecord getBorrowStockCost(const Datetime& datetime, const Stock& stock, price_t price, - double num) { - return m_costfunc ? m_costfunc->getBorrowStockCost(datetime, stock, price, num) - : CostRecord(); - } - - /** - * 计算融劵归还成本 - * @param borrow_datetime 借入日期 - * @param return_datetime 归还日期 - * @param stock 归还的对象 - * @param price 归还时每股价格 - * @param num 归还的数量 - */ - CostRecord getReturnStockCost(const Datetime& borrow_datetime, const Datetime& return_datetime, - const Stock& stock, price_t price, double num) { - return m_costfunc ? m_costfunc->getReturnStockCost(borrow_datetime, return_datetime, stock, - price, num) - : CostRecord(); - } - /** 从哪个时刻开始启动订单代理进行下单操作 */ Datetime getBrokerLastDatetime() const { return m_broker_last_datetime; diff --git a/hikyuu_cpp/hikyuu/trade_manage/imp/TradeCostStub.h b/hikyuu_cpp/hikyuu/trade_manage/imp/TradeCostStub.h index 6ae7eaf8..917a51cf 100644 --- a/hikyuu_cpp/hikyuu/trade_manage/imp/TradeCostStub.h +++ b/hikyuu_cpp/hikyuu/trade_manage/imp/TradeCostStub.h @@ -31,17 +31,6 @@ public: return CostRecord(0, 0, 0, 20, 20); } - virtual CostRecord getBorrowStockCost(const Datetime& datetime, const Stock& stock, - price_t price, double num) const override { - return CostRecord(0, 0, 0, 50, 50); - } - - virtual CostRecord getReturnStockCost(const Datetime& borrow_datetime, - const Datetime& return_datetime, const Stock& stock, - price_t price, double num) const override { - return CostRecord(0, 0, 0, 60, 60); - } - /** 子类私有变量克隆接口 */ virtual TradeCostPtr _clone() override { return TradeCostPtr(new TradeCostStub); diff --git a/hikyuu_pywrap/trade_manage/_TradeCost.cpp b/hikyuu_pywrap/trade_manage/_TradeCost.cpp index 7e12d6f6..e10e7b70 100644 --- a/hikyuu_pywrap/trade_manage/_TradeCost.cpp +++ b/hikyuu_pywrap/trade_manage/_TradeCost.cpp @@ -30,35 +30,6 @@ public: TradeCostPtr _clone() { return this->get_override("_clone")(); } - - CostRecord getBorrowStockCost(const Datetime& datetime, const Stock& stock, price_t price, - double num) const { - if (override getBorrowStockCost = get_override("getBorrowStockCost")) { - return getBorrowStockCost(datetime, stock, price, num); - } - return TradeCostBase::getBorrowStockCost(datetime, stock, price, num); - } - - CostRecord default_getBorrowStockCost(const Datetime& datetime, const Stock& stock, - price_t price, double num) const { - return this->TradeCostBase::getBorrowStockCost(datetime, stock, price, num); - } - - CostRecord getReturnStockCost(const Datetime& borrow_datetime, const Datetime& return_datetime, - const Stock& stock, price_t price, double num) const { - if (override getReturnStockCost = get_override("getReturnStockCost")) { - return getReturnStockCost(borrow_datetime, return_datetime, stock, price, num); - } - return TradeCostBase::getReturnStockCost(borrow_datetime, return_datetime, stock, price, - num); - } - - CostRecord default_getReturnStockCost(const Datetime& borrow_datetime, - const Datetime& return_datetime, const Stock& stock, - price_t price, double num) const { - return this->TradeCostBase::getReturnStockCost(borrow_datetime, return_datetime, stock, - price, num); - } }; void export_TradeCost() { @@ -121,10 +92,6 @@ void export_TradeCost() { :return: 交易成本记录 :rtype: CostRecord)") - //.def("getBorrowStockCost", &TradeCostBase::getBorrowStockCost, - //&TradeCostWrap::default_getBorrowStockCost) .def("getReturnStockCost", - //&TradeCostBase::getReturnStockCost, &TradeCostWrap::default_getReturnStockCost) - .def("_clone", pure_virtual(&TradeCostBase::_clone), "【重载接口】子类克隆接口") #if HKU_PYTHON_SUPPORT_PICKLE diff --git a/hikyuu_pywrap/trade_manage/_TradeManager.cpp b/hikyuu_pywrap/trade_manage/_TradeManager.cpp index c43a6b24..defdfba5 100644 --- a/hikyuu_pywrap/trade_manage/_TradeManager.cpp +++ b/hikyuu_pywrap/trade_manage/_TradeManager.cpp @@ -169,9 +169,6 @@ void export_TradeManager() { :param float num: 卖出数量 :rtype: CostRecord)") - //.def("getBorrowStockCost", &TradeManager::getBorrowStockCost) - //.def("getReturnStockCost", &TradeManager::getReturnStockCost) - .def("cash", &TradeManagerBase::cash, (arg("datetime"), arg("ktype") = KQuery::DAY), R"(cash(self, datetime[, ktype=Query.KType.DAY])