Skip to content

Commit

Permalink
system 支持复权 (continue)
Browse files Browse the repository at this point in the history
  • Loading branch information
fasiondog committed Jan 27, 2022
1 parent cb5123e commit 7ccfc2e
Show file tree
Hide file tree
Showing 4 changed files with 234 additions and 154 deletions.
14 changes: 10 additions & 4 deletions hikyuu_cpp/hikyuu/trade_sys/allocatefunds/AllocateFundsBase.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -137,8 +137,11 @@ void AllocateFundsBase::_adjust_with_running(const Datetime& date, const SystemL
for (auto iter = running_list.begin(); iter != running_list.end(); ++iter) {
const SYSPtr& sys = *iter;
if (selected_sets.find(sys) == selected_sets.end()) {
KRecord record = sys->getTO().getKRecord(date);
TradeRecord tr = sys->_sell(record, PART_ALLOCATEFUNDS);
KData kdata = sys->getTO();
size_t pos = kdata.getPos(date);
KRecord record = kdata.getKRecord(date);
KRecord srcRecord = kdata.getStock().getKRecord(kdata.startPos() + pos);
TradeRecord tr = sys->_sell(record, srcRecord, PART_ALLOCATEFUNDS);
if (!tr.isNull()) {
m_tm->addTradeRecord(tr);
}
Expand Down Expand Up @@ -174,8 +177,11 @@ void AllocateFundsBase::_adjust_with_running(const Datetime& date, const SystemL
} else if (selected_running_sets.find(iter->getSYS()) != selected_running_sets.end()) {
// 超出最大允许运行数且属于正在运行的子系统,则尝试清仓并回收资金
auto sys = iter->getSYS();
KRecord record = sys->getTO().getKRecord(date);
auto tr = sys->_sell(record, PART_ALLOCATEFUNDS);
KData kdata = sys->getTO();
size_t pos = kdata.getPos(date);
KRecord record = kdata.getKRecord(date);
KRecord srcRecord = kdata.getStock().getKRecord(kdata.startPos() + pos);
auto tr = sys->_sell(record, srcRecord, PART_ALLOCATEFUNDS);
if (!tr.isNull()) {
m_tm->addTradeRecord(tr);
}
Expand Down
Loading

0 comments on commit 7ccfc2e

Please sign in to comment.