From ab43f81b270f3ab52b451a6dab6d0c9c5c38cb45 Mon Sep 17 00:00:00 2001 From: fasiondog Date: Mon, 30 Sep 2024 21:06:19 +0800 Subject: [PATCH] =?UTF-8?q?fixed=20demo2=20run=20failed;=20=E4=BC=98?= =?UTF-8?q?=E5=8C=96=E4=B8=8A=E4=B8=8B=E6=96=87=E4=B8=ADktypelist=E4=B8=BA?= =?UTF-8?q?=E7=A9=BA=E6=97=B6=E8=AE=A4=E4=B8=BA=E4=B8=BA=E5=85=A8=E9=83=A8?= =?UTF-8?q?K=E7=BA=BF=E7=B1=BB=E5=9E=8B?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- hikyuu_cpp/hikyuu/strategy/Strategy.cpp | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/hikyuu_cpp/hikyuu/strategy/Strategy.cpp b/hikyuu_cpp/hikyuu/strategy/Strategy.cpp index e5fba940..30be3e05 100644 --- a/hikyuu_cpp/hikyuu/strategy/Strategy.cpp +++ b/hikyuu_cpp/hikyuu/strategy/Strategy.cpp @@ -23,6 +23,8 @@ std::atomic_bool Strategy::ms_keep_running = true; void Strategy::sig_handler(int sig) { if (sig == SIGINT || sig == SIGTERM) { ms_keep_running = false; + auto* scheduler = getScheduler(); + scheduler->stop(); exit(0); } } @@ -56,7 +58,7 @@ Strategy::Strategy(const vector& codeList, const vector& Strategy::Strategy(const StrategyContext& context, const string& name, const string& config_file) : Strategy(name, config_file) { _initParam(); - m_context = m_context; + m_context = context; } Strategy::~Strategy() { @@ -91,7 +93,10 @@ void Strategy::_init() { hikyuu_init(m_config_file, false, m_context); // 对上下文中的K线类型和其预加载参数进行检查,并给出警告 - const auto& ktypes = m_context.getKTypeList(); + auto ktypes = m_context.getKTypeList(); + if (ktypes.empty()) { + ktypes = KQuery::getAllKType(); + } const auto& preload_params = sm.getPreloadParameter(); for (const auto& ktype : ktypes) { std::string low_ktype = ktype; @@ -105,7 +110,6 @@ void Strategy::_init() { } CLS_CHECK(!m_context.getStockCodeList().empty(), "The context does not contain any stocks!"); - CLS_CHECK(!m_context.getKTypeList().empty(), "The K type list was empty!"); // 先将行情接收代理停止,以便后面加入处理函数 stopSpotAgent();