mirror of
https://gitee.com/fasiondog/hikyuu.git
synced 2024-11-30 10:59:43 +08:00
update
This commit is contained in:
parent
526bc05893
commit
bf83d17635
@ -213,7 +213,7 @@ void AllocateFundsBase::_adjust_without_running(const Datetime& date,
|
||||
|
||||
// 如果是运行中系统,不使用计算的权重,更新累积权重和
|
||||
if (running_set.find(iter->sys) != running_set.cend()) {
|
||||
FundsRecord sub_funds = m_tm->getFunds(m_query.kType());
|
||||
FundsRecord sub_funds = m_tm->getFunds(date, m_query.kType());
|
||||
price_t sub_total_funds =
|
||||
funds.cash + funds.market_value + funds.borrow_asset - funds.short_market_value;
|
||||
sum_weight += sub_total_funds / total_funds;
|
||||
@ -314,7 +314,7 @@ SystemWeightList AllocateFundsBase::_adjust_with_running(
|
||||
//-----------------------------------------------------------------
|
||||
// 获取当前总资产市值,计算需保留的资产
|
||||
int precision = m_shadow_tm->getParam<int>("precision");
|
||||
FundsRecord funds = m_tm->getFunds(m_query.kType());
|
||||
FundsRecord funds = m_tm->getFunds(date, m_query.kType());
|
||||
price_t total_funds =
|
||||
funds.cash + funds.market_value + funds.borrow_asset - funds.short_market_value;
|
||||
price_t reserve_funds = roundEx(total_funds * m_reserve_percent, precision);
|
||||
@ -325,7 +325,7 @@ SystemWeightList AllocateFundsBase::_adjust_with_running(
|
||||
if (running_set.find(iter->sys) != running_set.cend()) {
|
||||
TMPtr sub_tm = iter->sys->getTM();
|
||||
const KQuery& query = iter->sys->getTO().getQuery();
|
||||
FundsRecord sub_funds = sub_tm->getFunds(query.kType());
|
||||
FundsRecord sub_funds = sub_tm->getFunds(date, query.kType());
|
||||
price_t sub_total_funds = sub_funds.cash + sub_funds.market_value +
|
||||
sub_funds.borrow_asset - sub_funds.short_market_value;
|
||||
price_t sub_will_funds = total_funds * iter->weight;
|
||||
@ -394,7 +394,7 @@ SystemWeightList AllocateFundsBase::_adjust_with_running(
|
||||
if (running_set.find(iter->sys) != running_set.cend()) {
|
||||
auto sub_tm = iter->sys->getTM();
|
||||
const KQuery& query = iter->sys->getTO().getQuery();
|
||||
FundsRecord sub_funds = sub_tm->getFunds(query.kType());
|
||||
FundsRecord sub_funds = sub_tm->getFunds(date, query.kType());
|
||||
price_t sub_total_funds = sub_funds.cash + sub_funds.market_value +
|
||||
sub_funds.borrow_asset - sub_funds.short_market_value;
|
||||
|
||||
|
@ -243,6 +243,7 @@ void Portfolio::_runMoment(const Datetime& date, bool adjust) {
|
||||
for (auto& sys : m_delay_adjust_sys_list) {
|
||||
auto tr = sys.sys->sellForce(date, sys.weight, PART_PORTFOLIO);
|
||||
if (!tr.isNull()) {
|
||||
HKU_INFO_IF(trace, "[PF] Delay adjust sell: {}", tr);
|
||||
m_tm->addTradeRecord(tr);
|
||||
|
||||
// 卖出后,尝试将资金取出转移至影子总账户
|
||||
@ -277,10 +278,18 @@ void Portfolio::_runMoment(const Datetime& date, bool adjust) {
|
||||
m_shadow_tm->checkin(date, cash);
|
||||
HKU_INFO_IF(trace, "Collect the scraps cash ({:<.2f}) from {}, current cash: {}", cash,
|
||||
running_sys->name(), m_shadow_tm->currentCash());
|
||||
if (position.number == 0) {
|
||||
m_tmp_will_remove_sys.emplace_back(running_sys, 0.);
|
||||
}
|
||||
}
|
||||
|
||||
if (position.number == 0) {
|
||||
m_tmp_will_remove_sys.emplace_back(running_sys, 0.);
|
||||
HKU_INFO_IF(trace, "[PF] Recycle running sys: {}", running_sys->name());
|
||||
}
|
||||
}
|
||||
|
||||
if (trace) {
|
||||
auto funds = m_tm->getFunds(date, m_query.kType());
|
||||
HKU_INFO("[PF] total funds: {}, cash: {}, market_value: {}",
|
||||
funds.cash + funds.market_value, funds.cash, funds.market_value);
|
||||
}
|
||||
|
||||
// 依据待移除列表将系统从运行中系统列表里删除
|
||||
|
Loading…
Reference in New Issue
Block a user