mirror of
https://gitee.com/fasiondog/hikyuu.git
synced 2024-12-04 12:57:45 +08:00
remove getBorrowStockCost、getReturnStockCost
This commit is contained in:
parent
52f143efa9
commit
79b37b28b8
@ -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;
|
||||
|
||||
|
@ -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;
|
||||
}
|
||||
|
@ -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;
|
||||
|
@ -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);
|
||||
|
@ -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
|
||||
|
@ -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])
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user