mirror of
https://gitee.com/fasiondog/hikyuu.git
synced 2024-12-03 12:27:48 +08:00
update
This commit is contained in:
parent
b0ac545632
commit
c597dda913
@ -255,13 +255,16 @@ void Portfolio::run(const KQuery& query, int adjust_cycle, bool force, const str
|
|||||||
|
|
||||||
void Portfolio::_runOnMode(const DatetimeList& datelist, int adjust_cycle, const string& mode) {
|
void Portfolio::_runOnMode(const DatetimeList& datelist, int adjust_cycle, const string& mode) {
|
||||||
if ("week" == mode) {
|
if ("week" == mode) {
|
||||||
Datetime cur_cycle_end;
|
Datetime cur_cycle_end = datelist.front().nextWeek();
|
||||||
for (size_t i = 0, total = datelist.size(); i < total; i++) {
|
for (size_t i = 0, total = datelist.size(); i < total; i++) {
|
||||||
const auto& date = datelist[i];
|
const auto& date = datelist[i];
|
||||||
bool adjust = (date.dayOfWeek() == adjust_cycle);
|
bool adjust = (date.dayOfWeek() == adjust_cycle);
|
||||||
if (adjust) {
|
if (adjust) {
|
||||||
cur_cycle_end = date.nextWeek();
|
cur_cycle_end = date.nextWeek();
|
||||||
}
|
}
|
||||||
|
if (cur_cycle_end > datelist.back()) {
|
||||||
|
cur_cycle_end = datelist.back() + Seconds(1);
|
||||||
|
}
|
||||||
_runMoment(date, cur_cycle_end, adjust);
|
_runMoment(date, cur_cycle_end, adjust);
|
||||||
}
|
}
|
||||||
} else if ("month" == mode) {
|
} else if ("month" == mode) {
|
||||||
@ -291,10 +294,20 @@ void Portfolio::_runOnModeDelayToTradingDay(const DatetimeList& datelist, int ad
|
|||||||
const string& mode) {
|
const string& mode) {
|
||||||
std::set<Datetime> date_set;
|
std::set<Datetime> date_set;
|
||||||
if ("week" == mode) {
|
if ("week" == mode) {
|
||||||
|
Datetime cur_adjust_date = Datetime::min();
|
||||||
Datetime cur_cycle_end;
|
Datetime cur_cycle_end;
|
||||||
for (size_t i = 0, total = datelist.size(); i < total; i++) {
|
for (size_t i = 0, total = datelist.size(); i < total; i++) {
|
||||||
const auto& date = datelist[i];
|
const auto& date = datelist[i];
|
||||||
bool adjust = (date.dayOfWeek() == adjust_cycle);
|
Datetime need_adjust_date = date.startOfWeek() + Days(adjust_cycle - 1);
|
||||||
|
bool adjust = false;
|
||||||
|
if (date == need_adjust_date) {
|
||||||
|
adjust = true;
|
||||||
|
cur_adjust_date = date;
|
||||||
|
} else if (date > cur_adjust_date) {
|
||||||
|
adjust = true;
|
||||||
|
cur_adjust_date = date;
|
||||||
|
}
|
||||||
|
|
||||||
if (adjust) {
|
if (adjust) {
|
||||||
cur_cycle_end = date.nextWeek();
|
cur_cycle_end = date.nextWeek();
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user