From 3097c2b454c30cc253be9980c931113b2a12c295 Mon Sep 17 00:00:00 2001 From: fasiondog Date: Wed, 28 Aug 2024 12:55:45 +0800 Subject: [PATCH] =?UTF-8?q?=E5=8F=96=E6=B6=88=E6=8E=A5=E6=94=B6=E8=A1=8C?= =?UTF-8?q?=E6=83=85=E6=95=B0=E6=8D=AE=E6=97=B6=E7=9A=84=E5=BC=80=E9=97=AD?= =?UTF-8?q?=E5=B8=82=E6=97=B6=E9=97=B4=E9=99=90=E5=88=B6=EF=BC=8C=E6=9C=89?= =?UTF-8?q?=E8=A1=8C=E6=83=85=E6=8E=A8=E9=80=81=E7=AB=AF=E8=87=AA=E8=A1=8C?= =?UTF-8?q?=E6=8E=A7=E5=88=B6?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- hikyuu_cpp/hikyuu/global/GlobalSpotAgent.cpp | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/hikyuu_cpp/hikyuu/global/GlobalSpotAgent.cpp b/hikyuu_cpp/hikyuu/global/GlobalSpotAgent.cpp index 2a6637ff..1ebca6fd 100644 --- a/hikyuu_cpp/hikyuu/global/GlobalSpotAgent.cpp +++ b/hikyuu_cpp/hikyuu/global/GlobalSpotAgent.cpp @@ -38,7 +38,7 @@ static string getSpotMarketCode(const SpotRecord& spot) { static void updateStockDayData(const SpotRecord& spot) { Stock stk = StockManager::instance().getStock(getSpotMarketCode(spot)); HKU_IF_RETURN(stk.isNull(), void()); - HKU_IF_RETURN(!stk.isTransactionTime(spot.datetime), void()); + // HKU_IF_RETURN(!stk.isTransactionTime(spot.datetime), void()); KRecord krecord(Datetime(spot.datetime.year(), spot.datetime.month(), spot.datetime.day()), spot.open, spot.high, spot.low, spot.close, spot.amount, spot.volume); stk.realtimeUpdate(krecord, KQuery::DAY); @@ -47,7 +47,7 @@ static void updateStockDayData(const SpotRecord& spot) { static void updateStockDayUpData(const SpotRecord& spot, KQuery::KType ktype) { Stock stk = StockManager::instance().getStock(getSpotMarketCode(spot)); HKU_IF_RETURN(stk.isNull(), void()); - HKU_IF_RETURN(!stk.isTransactionTime(spot.datetime), void()); + // HKU_IF_RETURN(!stk.isTransactionTime(spot.datetime), void()); std::function endOfPhase; std::function startOfPhase; @@ -87,6 +87,8 @@ static void updateStockDayUpData(const SpotRecord& spot, KQuery::KType ktype) { } KRecord last_record = stk.getKRecord(total - 1, ktype); + HKU_IF_RETURN(!last_record.isValid(), void()); + if (spot_end_of_phase > last_record.datetime) { // 如果当前的日期大于最后记录的日期,则为新增数据,直接更新并返回 stk.realtimeUpdate(KRecord(spot_end_of_phase, spot.open, spot.high, spot.low, spot.close, @@ -119,7 +121,7 @@ static void updateStockDayUpData(const SpotRecord& spot, KQuery::KType ktype) { static void updateStockMinData(const SpotRecord& spot, KQuery::KType ktype) { Stock stk = StockManager::instance().getStock(getSpotMarketCode(spot)); HKU_IF_RETURN(stk.isNull(), void()); - HKU_IF_RETURN(!stk.isTransactionTime(spot.datetime), void()); + // HKU_IF_RETURN(!stk.isTransactionTime(spot.datetime), void()); TimeDelta gap; if (KQuery::MIN == ktype) {