remove getBorrowStockCost、getReturnStockCost

This commit is contained in:
fasiondog 2022-08-30 01:16:02 +08:00
parent 52f143efa9
commit 79b37b28b8
6 changed files with 22 additions and 101 deletions

View File

@ -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;

View File

@ -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;
}

View File

@ -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;

View File

@ -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);

View File

@ -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

View File

@ -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])