Skip to content

Commit

Permalink
System支持复权
Browse files Browse the repository at this point in the history
  • Loading branch information
fasiondog committed Jan 28, 2022
1 parent 7ccfc2e commit 25984a6
Show file tree
Hide file tree
Showing 3 changed files with 110 additions and 162 deletions.
11 changes: 7 additions & 4 deletions hikyuu_cpp/hikyuu/trade_sys/allocatefunds/AllocateFundsBase.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -281,7 +281,10 @@ void AllocateFundsBase::_adjust_with_running(const Datetime& date, const SystemL

// 计算并卖出部分股票以获取剩下需要返还的资金
Stock stock = sys->getStock();
KRecord k = sys->getTO().getKRecord(date);
KData kdata = sys->getTO();
size_t pos = kdata.getPos(date);
KRecord k = kdata.getKRecord(pos);
KRecord srcK = stock.getKRecord(kdata.startPos() + pos);
PositionRecord position = tm->getPosition(stock);
if (position.number > 0) {
TradeRecord tr;
Expand All @@ -290,14 +293,14 @@ void AllocateFundsBase::_adjust_with_running(const Datetime& date, const SystemL
size_t(need_sell_num / stock.minTradeNumber()) * stock.minTradeNumber();
if (position.number <= need_sell_num) {
// 如果当前持仓数小于等于需要卖出的数量,则全部卖出
tr = sys->_sellForce(k, position.number, PART_ALLOCATEFUNDS);
tr = sys->_sellForce(k, srcK, position.number, PART_ALLOCATEFUNDS);
} else {
if (position.number - need_sell_num >= stock.minTradeNumber()) {
// 如果按需要卖出数量卖出后,可能剩余的数量大于等于最小交易数则按需要卖出的数量卖出
tr = sys->_sellForce(k, need_sell_num, PART_ALLOCATEFUNDS);
tr = sys->_sellForce(k, srcK, need_sell_num, PART_ALLOCATEFUNDS);
} else {
// 如果按需要卖出的数量卖出后,剩余的持仓数小于最小交易数量则全部卖出
tr = sys->_sellForce(k, position.number, PART_ALLOCATEFUNDS);
tr = sys->_sellForce(k, srcK, position.number, PART_ALLOCATEFUNDS);
}
}
if (!tr.isNull()) {
Expand Down
Loading

0 comments on commit 25984a6

Please sign in to comment.