From 74acf9bc8c6f3d61374634db3301a4bf04c591a3 Mon Sep 17 00:00:00 2001 From: fasiondog Date: Sun, 9 Jun 2024 17:39:43 +0800 Subject: [PATCH] =?UTF-8?q?=E8=A1=A5=E5=85=85=E6=B5=8B=E8=AF=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../trade_sys/selector/test_SE_MultiFactor.cpp | 16 +++++++++++++++- 1 file changed, 15 insertions(+), 1 deletion(-) diff --git a/hikyuu_cpp/unit_test/hikyuu/trade_sys/selector/test_SE_MultiFactor.cpp b/hikyuu_cpp/unit_test/hikyuu/trade_sys/selector/test_SE_MultiFactor.cpp index c51fca05..e613b78e 100644 --- a/hikyuu_cpp/unit_test/hikyuu/trade_sys/selector/test_SE_MultiFactor.cpp +++ b/hikyuu_cpp/unit_test/hikyuu/trade_sys/selector/test_SE_MultiFactor.cpp @@ -31,7 +31,7 @@ TEST_CASE("test_SE_MultiFactor") { StockManager& sm = StockManager::instance(); StockList stks{sm["sh600004"], sm["sh600005"], sm["sz000001"], sm["sz000002"]}; Stock ref_stk = sm["sh000001"]; - KQuery query = KQuery(-100); + KQuery query = KQueryByDate(Datetime(20110712), Datetime(20111206)); IndicatorList src_inds{MA(CLOSE()), EMA(CLOSE())}; auto sys = SYS_Simple(crtTM(), MM_Nothing()); @@ -52,6 +52,20 @@ TEST_CASE("test_SE_MultiFactor") { ret->addStockList(stks, sys); auto proto_list = ret->getProtoSystemList(); ret->calculate(proto_list, query); + auto sw_list = ret->getSelected(Datetime(20110712)); + CHECK_EQ(sw_list.size(), 4); + + /** @arg topn = 2 */ + ret = SE_MultiFactor(src_inds, 2, 5, 120, ref_stk); + ret->addStockList(stks, sys); + proto_list = ret->getProtoSystemList(); + ret->calculate(proto_list, query); + sw_list = ret->getSelected(Datetime(20110712)); + CHECK_EQ(sw_list.size(), 2); + + // for (const auto& sw : sw_list) { + // HKU_INFO("{} {}", sw.sys->name(), sw.weight); + // } } //-----------------------------------------------------------------------------