From 200864087582dd65ae2cbf88d2700bbae1915129 Mon Sep 17 00:00:00 2001 From: fasiondog Date: Thu, 15 Aug 2024 13:48:06 +0800 Subject: [PATCH] =?UTF-8?q?=E8=A1=A5=E5=85=85=E6=B3=A8=E9=87=8A=E8=AF=B4?= =?UTF-8?q?=E6=98=8E?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- hikyuu/strategy/strategy.py | 4 ++-- hikyuu_cpp/hikyuu/strategy/Strategy.h | 7 +++++-- 2 files changed, 7 insertions(+), 4 deletions(-) diff --git a/hikyuu/strategy/strategy.py b/hikyuu/strategy/strategy.py index 5a0f54e3..4cd8d76e 100644 --- a/hikyuu/strategy/strategy.py +++ b/hikyuu/strategy/strategy.py @@ -3,7 +3,7 @@ # cp936 from hikyuu import Strategy, Query, Datetime, TimeDelta, Seconds, Minutes -from hikyuu import StockManager +from hikyuu import sm def on_change(stk, spot): @@ -16,11 +16,11 @@ def on_spot(rev_time): def my_func(): print("calculate:", Datetime.now()) - sm = StockManager.instance() for s in sm: print(s) +# 注意:每一个Strategy 只能作为独立进程执行,即 python xxx.py 的方式执行! # 以 Strategy 方式运行示例 if __name__ == '__main__': s = Strategy(['sh600000', 'sz000001'], [Query.MIN, Query.DAY]) diff --git a/hikyuu_cpp/hikyuu/strategy/Strategy.h b/hikyuu_cpp/hikyuu/strategy/Strategy.h index 7b2563f8..e5154129 100644 --- a/hikyuu_cpp/hikyuu/strategy/Strategy.h +++ b/hikyuu_cpp/hikyuu/strategy/Strategy.h @@ -86,8 +86,6 @@ public: void runDailyAt(std::function&& func, const TimeDelta& delta, bool ignoreHoliday = true); - void start(); - /** * 正确数据发生变化调用,即接收到相应行情数据变更 * @note 通常用于调试 @@ -102,6 +100,11 @@ public: */ void onReceivedSpot(std::function&& recievedFucn); + /** + * 启动策略执行,必须在已注册相关处理函数后执行 + */ + void start(); + private: string m_name; string m_config_file;