Skip to content

Commit 9f6c613

Browse files
committed
fix(trade): TradeManager 在保存交易动作记录时,增加了对 m_costfunc 是否为空的判断
1 parent 0f019f7 commit 9f6c613

File tree

1 file changed

+7
-3
lines changed

1 file changed

+7
-3
lines changed

hikyuu_cpp/hikyuu/trade_manage/TradeManager.cpp

+7-3
Original file line numberDiff line numberDiff line change
@@ -1547,9 +1547,13 @@ void TradeManager::_saveAction(const TradeRecord& record) {
15471547
switch (record.business) {
15481548
case BUSINESS_INIT:
15491549
buf << "my_tm = crtTM(datetime=Datetime('" << record.datetime.str() << "'), "
1550-
<< "initCash=" << record.cash << sep << "costFunc=" << m_costfunc->name() << "("
1551-
<< m_costfunc->getParameter().getNameValueList() << "), " << "name='" << m_name
1552-
<< "'" << ")";
1550+
<< "initCash=" << record.cash << sep << "costFunc=";
1551+
if (m_costfunc) {
1552+
buf << m_costfunc->name() << "(" << m_costfunc->getParameter().getNameValueList()
1553+
<< "), " << "name='" << m_name << "'" << ")";
1554+
} else {
1555+
buf << "TC_Zero()";
1556+
}
15531557
break;
15541558

15551559
case BUSINESS_CHECKIN:

0 commit comments

Comments
 (0)