From ed7f4d2b969c73ab2268be1dfc6e46312b74b4ac Mon Sep 17 00:00:00 2001 From: fasiondog Date: Sun, 25 Aug 2024 21:58:20 +0800 Subject: [PATCH] =?UTF-8?q?=E5=AF=B9=E4=B8=8A=E4=B8=8B=E6=96=87=E4=B8=AD?= =?UTF-8?q?=E7=9A=84K=E7=BA=BF=E7=B1=BB=E5=9E=8B=E5=92=8C=E5=85=B6?= =?UTF-8?q?=E9=A2=84=E5=8A=A0=E8=BD=BD=E5=8F=82=E6=95=B0=E8=BF=9B=E8=A1=8C?= =?UTF-8?q?=E6=A3=80=E6=9F=A5=EF=BC=8C=E5=B9=B6=E7=BB=99=E5=87=BA=E8=AD=A6?= =?UTF-8?q?=E5=91=8A?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- hikyuu_cpp/hikyuu/strategy/Strategy.cpp | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/hikyuu_cpp/hikyuu/strategy/Strategy.cpp b/hikyuu_cpp/hikyuu/strategy/Strategy.cpp index 58803124..4a9e6a90 100644 --- a/hikyuu_cpp/hikyuu/strategy/Strategy.cpp +++ b/hikyuu_cpp/hikyuu/strategy/Strategy.cpp @@ -74,6 +74,17 @@ void Strategy::_init() { // 初始化 hikyuu_init(m_config_file, false, m_context); + + // 对上下文中的K线类型和其预加载参数进行检查,并给出警告 + const auto& ktypes = m_context.getKTypeList(); + const auto& preload_params = sm.getPreloadParameter(); + for (const auto& ktype : ktypes) { + std::string low_ktype = ktype; + to_lower(low_ktype); + HKU_ERROR_IF(!preload_params.tryGet(low_ktype, false), + "The K-line type in the context is not configured to be preloaded!"); + } + } else { m_context = sm.getStrategyContext(); }