hikyuu 2.6.8.5__py3-none-win_amd64.whl → 2.6.9__py3-none-win_amd64.whl

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (176) hide show
  1. hikyuu/__init__.py +5 -11
  2. hikyuu/__init__.pyi +37 -12
  3. hikyuu/analysis/__init__.pyi +26 -0
  4. hikyuu/analysis/analysis.pyi +27 -1
  5. hikyuu/core.py +2 -0
  6. hikyuu/core.pyi +28 -2
  7. hikyuu/cpp/arrow.dll +0 -0
  8. hikyuu/cpp/boost_date_time-mt.dll +0 -0
  9. hikyuu/cpp/boost_serialization-mt.dll +0 -0
  10. hikyuu/cpp/boost_system-mt.dll +0 -0
  11. hikyuu/cpp/boost_wserialization-mt.dll +0 -0
  12. hikyuu/cpp/core310.pyd +0 -0
  13. hikyuu/cpp/core310.pyi +446 -9
  14. hikyuu/cpp/core311.pyd +0 -0
  15. hikyuu/cpp/core311.pyi +446 -9
  16. hikyuu/cpp/core312.pyd +0 -0
  17. hikyuu/cpp/core312.pyi +446 -9
  18. hikyuu/cpp/core313.pyd +0 -0
  19. hikyuu/cpp/core313.pyi +446 -9
  20. hikyuu/cpp/core39.pyd +0 -0
  21. hikyuu/cpp/core39.pyi +446 -9
  22. hikyuu/cpp/hikyuu.dll +0 -0
  23. hikyuu/cpp/hikyuu.lib +0 -0
  24. hikyuu/cpp/i18n/zh_CN/hikyuu.mo +0 -0
  25. hikyuu/cpp/msvcp140-a118642f3ae8774fb9dc223e15c4a52e.dll +0 -0
  26. hikyuu/cpp/parquet.dll +0 -0
  27. hikyuu/cpp/sqlite3.dll +0 -0
  28. hikyuu/data/clickhouse_upgrade/createdb.sql +105 -105
  29. hikyuu/data/common.py +3 -3
  30. hikyuu/data/common_clickhouse.py +1 -1
  31. hikyuu/data/download_block.py +318 -0
  32. hikyuu/data/em_block_to_clickhouse.py +26 -74
  33. hikyuu/data/em_block_to_mysql.py +25 -75
  34. hikyuu/data/em_block_to_sqlite.py +26 -78
  35. hikyuu/data/hku_config_template.py +3 -3
  36. hikyuu/data/pytdx_to_clickhouse.py +15 -11
  37. hikyuu/data/pytdx_to_h5.py +6 -2
  38. hikyuu/data/pytdx_to_mysql.py +5 -1
  39. hikyuu/data/pytdx_weight_to_clickhouse.py +1 -1
  40. hikyuu/data/pytdx_weight_to_mysql.py +1 -1
  41. hikyuu/data/pytdx_weight_to_sqlite.py +1 -1
  42. hikyuu/data/zh_bond10_to_clickhouse.py +1 -1
  43. hikyuu/draw/drawplot/bokeh_draw.pyi +33 -8
  44. hikyuu/draw/drawplot/echarts_draw.pyi +33 -8
  45. hikyuu/draw/drawplot/matplotlib_draw.py +4 -74
  46. hikyuu/draw/drawplot/matplotlib_draw.pyi +33 -8
  47. hikyuu/examples/notebook/Demo/Demo1.ipynb +48 -33
  48. hikyuu/extend.py +0 -1
  49. hikyuu/extend.pyi +30 -5
  50. hikyuu/fetcher/stock/zh_block_em.py +50 -18
  51. hikyuu/gui/HikyuuTDX.py +81 -30
  52. hikyuu/gui/data/CollectSpotThread.py +1 -1
  53. hikyuu/gui/data/EscapetimeThread.py +8 -14
  54. hikyuu/gui/data/ImportBlockInfoTask.py +3 -10
  55. hikyuu/gui/data/MainWindow.py +1168 -715
  56. hikyuu/gui/data/SchedImportThread.py +2 -2
  57. hikyuu/gui/data/UsePytdxImportToH5Thread.py +3 -3
  58. hikyuu/gui/data/UseQmtImportToH5Thread.py +2 -2
  59. hikyuu/gui/data/UseTdxImportToH5Thread.py +3 -3
  60. hikyuu/gui/data/tool.py +32 -25
  61. hikyuu/gui/dataserver.py +5 -3
  62. hikyuu/hub.pyi +6 -6
  63. hikyuu/include/hikyuu/DataType.h +4 -16
  64. hikyuu/include/hikyuu/KData.h +6 -3
  65. hikyuu/include/hikyuu/KDataPrivatedBufferImp.h +1 -1
  66. hikyuu/include/hikyuu/KDataSharedBufferImp.h +1 -1
  67. hikyuu/include/hikyuu/KQuery.h +2 -2
  68. hikyuu/include/hikyuu/Stock.h +3 -0
  69. hikyuu/include/hikyuu/StockManager.h +13 -3
  70. hikyuu/include/hikyuu/data_driver/BaseInfoDriver.h +8 -0
  71. hikyuu/include/hikyuu/data_driver/BlockInfoDriver.h +6 -0
  72. hikyuu/include/hikyuu/data_driver/KDataDriver.h +26 -1
  73. hikyuu/include/hikyuu/data_driver/base_info/mysql/MySQLBaseInfoDriver.h +1 -1
  74. hikyuu/include/hikyuu/data_driver/base_info/sqlite/SQLiteBaseInfoDriver.h +1 -1
  75. hikyuu/include/hikyuu/data_driver/block_info/mysql/MySQLBlockInfoDriver.h +2 -1
  76. hikyuu/include/hikyuu/data_driver/block_info/qianlong/QLBlockInfoDriver.h +2 -1
  77. hikyuu/include/hikyuu/data_driver/block_info/sqlite/SQLiteBlockInfoDriver.h +2 -1
  78. hikyuu/include/hikyuu/data_driver/kdata/DoNothingKDataDriver.h +1 -1
  79. hikyuu/include/hikyuu/data_driver/kdata/cvs/KDataTempCsvDriver.h +1 -1
  80. hikyuu/include/hikyuu/data_driver/kdata/hdf5/H5KDataDriver.h +1 -1
  81. hikyuu/include/hikyuu/data_driver/kdata/mysql/MySQLKDataDriver.h +1 -1
  82. hikyuu/include/hikyuu/data_driver/kdata/sqlite/SQLiteKDataDriver.h +1 -1
  83. hikyuu/include/hikyuu/data_driver/kdata/tdx/TdxKDataDriver.h +1 -1
  84. hikyuu/include/hikyuu/hikyuu.h +1 -1
  85. hikyuu/include/hikyuu/indicator/build_in.h +1 -0
  86. hikyuu/include/hikyuu/indicator/crt/CYCLE.h +4 -4
  87. hikyuu/include/hikyuu/indicator/crt/HSL.h +2 -2
  88. hikyuu/include/hikyuu/indicator/crt/QUANTILE_TRUNC.h +30 -0
  89. hikyuu/include/hikyuu/indicator/crt/TURNOVER.h +1 -0
  90. hikyuu/include/hikyuu/indicator/crt/ZSCORE.h +2 -2
  91. hikyuu/include/hikyuu/indicator/imp/IQuantileTrunc.h +25 -0
  92. hikyuu/include/hikyuu/misc.h +38 -0
  93. hikyuu/include/hikyuu/plugin/dataserver.h +2 -1
  94. hikyuu/include/hikyuu/plugin/extind.h +37 -0
  95. hikyuu/include/hikyuu/plugin/interface/DataServerPluginInterface.h +2 -2
  96. hikyuu/include/hikyuu/plugin/interface/ExtendIndicatorsPluginInterface.h +12 -0
  97. hikyuu/include/hikyuu/strategy/RunSystemInStrategy.h +3 -0
  98. hikyuu/include/hikyuu/trade_manage/Performance.h +4 -4
  99. hikyuu/include/hikyuu/trade_manage/TradeManagerBase.h +10 -1
  100. hikyuu/include/hikyuu/trade_sys/moneymanager/imp/FixedCapitalFundsMM.h +0 -4
  101. hikyuu/include/hikyuu/trade_sys/multifactor/MultiFactorBase.h +36 -3
  102. hikyuu/include/hikyuu/trade_sys/multifactor/NormalizeBase.h +125 -0
  103. hikyuu/include/hikyuu/trade_sys/multifactor/ScoresFilterBase.h +125 -0
  104. hikyuu/include/hikyuu/trade_sys/multifactor/build_in.h +3 -0
  105. hikyuu/include/hikyuu/trade_sys/multifactor/buildin_norm.h +36 -0
  106. hikyuu/include/hikyuu/trade_sys/multifactor/buildin_scfilter.h +51 -0
  107. hikyuu/include/hikyuu/trade_sys/multifactor/filter/GroupSCFilter.h +24 -0
  108. hikyuu/include/hikyuu/trade_sys/multifactor/filter/IgnoreLessOrEqualValueSCFilter.h +24 -0
  109. hikyuu/include/hikyuu/trade_sys/multifactor/filter/IgnoreNanSCFilter.h +24 -0
  110. hikyuu/include/hikyuu/trade_sys/multifactor/filter/MinAmountPercentSCFilter.h +25 -0
  111. hikyuu/include/hikyuu/trade_sys/multifactor/filter/PriceSCFilter.h +24 -0
  112. hikyuu/include/hikyuu/trade_sys/multifactor/filter/TopNSCFilter.h +24 -0
  113. hikyuu/include/hikyuu/trade_sys/multifactor/filter/__init__.py +1 -0
  114. hikyuu/include/hikyuu/trade_sys/multifactor/imp/EqualWeightMultiFactor.h +1 -1
  115. hikyuu/include/hikyuu/trade_sys/multifactor/imp/ICIRMultiFactor.h +1 -1
  116. hikyuu/include/hikyuu/trade_sys/multifactor/imp/ICMultiFactor.h +1 -1
  117. hikyuu/include/hikyuu/trade_sys/multifactor/imp/WeightMultiFactor.h +1 -1
  118. hikyuu/include/hikyuu/trade_sys/multifactor/normalize/NormMinMax.h +23 -0
  119. hikyuu/include/hikyuu/trade_sys/multifactor/normalize/NormQuantile.h +28 -0
  120. hikyuu/include/hikyuu/trade_sys/multifactor/normalize/NormQuantileUniform.h +28 -0
  121. hikyuu/include/hikyuu/trade_sys/multifactor/normalize/NormZScore.h +25 -0
  122. hikyuu/include/hikyuu/trade_sys/multifactor/normalize/__init__.py +1 -0
  123. hikyuu/include/hikyuu/trade_sys/multifactor/normalize/quantile_trunc.h +16 -0
  124. hikyuu/include/hikyuu/trade_sys/portfolio/Portfolio.h +7 -0
  125. hikyuu/include/hikyuu/trade_sys/portfolio/imp/SimplePortfolio.h +7 -0
  126. hikyuu/include/hikyuu/trade_sys/portfolio/imp/WithoutAFPortfolio.h +7 -0
  127. hikyuu/include/hikyuu/trade_sys/selector/SelectorBase.h +49 -0
  128. hikyuu/include/hikyuu/trade_sys/selector/build_in.h +1 -0
  129. hikyuu/include/hikyuu/trade_sys/selector/crt/SE_MultiFactor2.h +40 -0
  130. hikyuu/include/hikyuu/trade_sys/selector/imp/MultiFactorSelector.h +0 -3
  131. hikyuu/include/hikyuu/trade_sys/selector/imp/MultiFactorSelector2.h +49 -0
  132. hikyuu/include/hikyuu/trade_sys/selector/imp/logic/OperatorSelector.h +1 -1
  133. hikyuu/include/hikyuu/trade_sys/selector/imp/logic/OperatorValueSelector.h +1 -1
  134. hikyuu/include/hikyuu/trade_sys/signal/imp/BandSignal2.h +0 -4
  135. hikyuu/include/hikyuu/trade_sys/signal/imp/logic/AddValueSignal.h +2 -2
  136. hikyuu/include/hikyuu/trade_sys/signal/imp/logic/DivValueSignal.h +2 -2
  137. hikyuu/include/hikyuu/trade_sys/signal/imp/logic/MulValueSignal.h +2 -2
  138. hikyuu/include/hikyuu/trade_sys/signal/imp/logic/OperatorSignal.h +1 -1
  139. hikyuu/include/hikyuu/trade_sys/signal/imp/logic/OperatorValueSignal.h +4 -4
  140. hikyuu/include/hikyuu/trade_sys/signal/imp/logic/SubValueSignal.h +2 -2
  141. hikyuu/include/hikyuu/trade_sys/system/System.h +14 -1
  142. hikyuu/include/hikyuu/utilities/SpendTimer.h +17 -7
  143. hikyuu/include/hikyuu/utilities/arithmetic.h +45 -0
  144. hikyuu/include/hikyuu/utilities/db_connect/mysql/MySQLConnect.h +1 -1
  145. hikyuu/include/hikyuu/utilities/db_connect/mysql/MySQLStatement.h +1 -1
  146. hikyuu/include/hikyuu/utilities/db_connect/sqlite/SQLiteConnect.h +1 -1
  147. hikyuu/include/hikyuu/utilities/db_connect/sqlite/SQLiteStatement.h +1 -1
  148. hikyuu/include/hikyuu/utilities/plugin/PluginLoader.h +4 -1
  149. hikyuu/include/hikyuu/version.h +4 -4
  150. hikyuu/plugin/backtest.dll +0 -0
  151. hikyuu/plugin/clickhousedriver.dll +0 -0
  152. hikyuu/plugin/dataserver.dll +0 -0
  153. hikyuu/plugin/device.dll +0 -0
  154. hikyuu/plugin/extind.dll +0 -0
  155. hikyuu/plugin/hkuextra.dll +0 -0
  156. hikyuu/plugin/hkuviews.dll +0 -0
  157. hikyuu/plugin/import2hdf5.dll +0 -0
  158. hikyuu/plugin/tmreport.dll +0 -0
  159. hikyuu/trade_manage/__init__.pyi +33 -8
  160. hikyuu/trade_manage/trade.pyi +33 -8
  161. hikyuu/util/__init__.pyi +2 -2
  162. hikyuu/util/singleton.pyi +1 -1
  163. {hikyuu-2.6.8.5.dist-info → hikyuu-2.6.9.dist-info}/METADATA +13 -14
  164. {hikyuu-2.6.8.5.dist-info → hikyuu-2.6.9.dist-info}/RECORD +167 -149
  165. {hikyuu-2.6.8.5.dist-info → hikyuu-2.6.9.dist-info}/top_level.txt +2 -1
  166. hikyuu/data_driver/__init__.py +0 -49
  167. hikyuu/data_driver/jqdata_data_driver.py +0 -277
  168. hikyuu/data_driver/pytdx_data_driver.py +0 -292
  169. hikyuu/fetcher/stock/zh_stock_a_huatai.py +0 -51
  170. hikyuu/fetcher/stock/zh_stock_a_pytdx.py +0 -129
  171. hikyuu/gui/data/CollectToMemThread.py +0 -123
  172. hikyuu/gui/data/CollectToMySQLThread.py +0 -178
  173. hikyuu/gui/start_huatai_insight.py +0 -510
  174. hikyuu/tools/update_block_info.py +0 -168
  175. {hikyuu-2.6.8.5.dist-info → hikyuu-2.6.9.dist-info}/WHEEL +0 -0
  176. {hikyuu-2.6.8.5.dist-info → hikyuu-2.6.9.dist-info}/entry_points.txt +0 -0
@@ -0,0 +1,51 @@
1
+ /*
2
+ * Copyright (c) 2025 hikyuu.org
3
+ *
4
+ * Created on: 2025-10-13
5
+ * Author: fasiondog
6
+ */
7
+
8
+ #pragma once
9
+
10
+ #include "ScoresFilterBase.h"
11
+
12
+ namespace hku {
13
+
14
+ /**
15
+ * @ingroup MultiFactor
16
+ * @{
17
+ */
18
+
19
+ ScoresFilterPtr HKU_API SCFilter_IgnoreNan();
20
+
21
+ ScoresFilterPtr HKU_API SCFilter_LessOrEqualValue(double value = 0.0);
22
+
23
+ ScoresFilterPtr HKU_API SCFilter_TopN(int topn = 10);
24
+
25
+ /**
26
+ * 过滤掉成交金额在评分列表末尾百分比范围内的截面
27
+ * @note
28
+ * 和传入的截面评分列表顺序相关,如果是降序,过滤的是成交金额较小的系统评分记录;反之,则是金额较大的系统评分记录
29
+ * @param min_amount_percent_limit 最小成交金额百分比限制
30
+ * @return ScoresFilterPtr
31
+ */
32
+ ScoresFilterPtr HKU_API SCFilter_AmountLimit(double min_amount_percent_limit = 0.1);
33
+
34
+ /**
35
+ * 筛选指定分组的截面
36
+ * @param group 分组数量
37
+ * @param group_index 分组索引,从0开始
38
+ * @return ScoresFilterPtr
39
+ */
40
+ ScoresFilterPtr HKU_API SCFilter_Group(int group = 10, int group_index = 0);
41
+
42
+ /**
43
+ * 筛选指定价格范围 [min_price, max_price] 内的截面
44
+ * @param min_price 最低价格
45
+ * @param max_price 最高价格
46
+ * @return ScoresFilterPtr
47
+ */
48
+ ScoresFilterPtr HKU_API SCFilter_Price(double min_price = 10., double max_price = 100000.);
49
+
50
+ /* @} */
51
+ } // namespace hku
@@ -0,0 +1,24 @@
1
+ /*
2
+ * Copyright (c) 2025 hikyuu.org
3
+ *
4
+ * Created on: 2025-10-13
5
+ * Author: fasiondog
6
+ */
7
+
8
+ #pragma once
9
+
10
+ #include "../ScoresFilterBase.h"
11
+
12
+ namespace hku {
13
+
14
+ class HKU_API GroupSCFilter : public ScoresFilterBase {
15
+ SCORESFILTER_IMP(GroupSCFilter)
16
+ SCORESFILTER_NO_PRIVATE_MEMBER_SERIALIZATION
17
+
18
+ public:
19
+ GroupSCFilter();
20
+ virtual ~GroupSCFilter() override = default;
21
+ virtual void _checkParam(const string& name) const override;
22
+ };
23
+
24
+ } // namespace hku
@@ -0,0 +1,24 @@
1
+ /*
2
+ * Copyright (c) 2025 hikyuu.org
3
+ *
4
+ * Created on: 2025-10-14
5
+ * Author: fasiondog
6
+ */
7
+
8
+ #pragma once
9
+
10
+ #include "../ScoresFilterBase.h"
11
+
12
+ namespace hku {
13
+
14
+ class HKU_API IgnoreLessOrEqualValueSCFilter : public ScoresFilterBase {
15
+ SCORESFILTER_IMP(IgnoreLessOrEqualValueSCFilter)
16
+ SCORESFILTER_NO_PRIVATE_MEMBER_SERIALIZATION
17
+
18
+ public:
19
+ IgnoreLessOrEqualValueSCFilter();
20
+ virtual ~IgnoreLessOrEqualValueSCFilter() override = default;
21
+ virtual void _checkParam(const string& name) const override;
22
+ };
23
+
24
+ } // namespace hku
@@ -0,0 +1,24 @@
1
+ /*
2
+ * Copyright (c) 2025 hikyuu.org
3
+ *
4
+ * Created on: 2025-10-14
5
+ * Author: fasiondog
6
+ */
7
+
8
+ #pragma once
9
+
10
+ #include "../ScoresFilterBase.h"
11
+
12
+ namespace hku {
13
+
14
+ class HKU_API IgnoreNanSCFilter : public ScoresFilterBase {
15
+ SCORESFILTER_IMP(IgnoreNanSCFilter)
16
+ SCORESFILTER_NO_PRIVATE_MEMBER_SERIALIZATION
17
+
18
+ public:
19
+ IgnoreNanSCFilter();
20
+ virtual ~IgnoreNanSCFilter() override = default;
21
+ virtual void _checkParam(const string& name) const override;
22
+ };
23
+
24
+ } // namespace hku
@@ -0,0 +1,25 @@
1
+ /*
2
+ * Copyright (c) 2025 hikyuu.org
3
+ *
4
+ * Created on: 2025-10-13
5
+ * Author: fasiondog
6
+ */
7
+
8
+ #pragma once
9
+
10
+ #include "../ScoresFilterBase.h"
11
+
12
+ namespace hku {
13
+
14
+ class HKU_API MinAmountPercentSCFilter : public ScoresFilterBase {
15
+ SCORESFILTER_IMP(MinAmountPercentSCFilter)
16
+ SCORESFILTER_NO_PRIVATE_MEMBER_SERIALIZATION
17
+
18
+ public:
19
+ MinAmountPercentSCFilter();
20
+ virtual ~MinAmountPercentSCFilter() override = default;
21
+
22
+ virtual void _checkParam(const string& name) const override;
23
+ };
24
+
25
+ } // namespace hku
@@ -0,0 +1,24 @@
1
+ /*
2
+ * Copyright (c) 2025 hikyuu.org
3
+ *
4
+ * Created on: 2025-10-13
5
+ * Author: fasiondog
6
+ */
7
+
8
+ #pragma once
9
+
10
+ #include "../ScoresFilterBase.h"
11
+
12
+ namespace hku {
13
+
14
+ class HKU_API PriceSCFilter : public ScoresFilterBase {
15
+ SCORESFILTER_IMP(PriceSCFilter)
16
+ SCORESFILTER_NO_PRIVATE_MEMBER_SERIALIZATION
17
+
18
+ public:
19
+ PriceSCFilter();
20
+ virtual ~PriceSCFilter() override = default;
21
+ virtual void _checkParam(const string& name) const override;
22
+ };
23
+
24
+ } // namespace hku
@@ -0,0 +1,24 @@
1
+ /*
2
+ * Copyright (c) 2025 hikyuu.org
3
+ *
4
+ * Created on: 2025-10-14
5
+ * Author: fasiondog
6
+ */
7
+
8
+ #pragma once
9
+
10
+ #include "../ScoresFilterBase.h"
11
+
12
+ namespace hku {
13
+
14
+ class HKU_API TopNSCFilter : public ScoresFilterBase {
15
+ SCORESFILTER_IMP(TopNSCFilter)
16
+ SCORESFILTER_NO_PRIVATE_MEMBER_SERIALIZATION
17
+
18
+ public:
19
+ TopNSCFilter();
20
+ virtual ~TopNSCFilter() override = default;
21
+ virtual void _checkParam(const string& name) const override;
22
+ };
23
+
24
+ } // namespace hku
@@ -20,7 +20,7 @@ public:
20
20
  EqualWeightMultiFactor(const vector<Indicator>& inds, const StockList& stks,
21
21
  const KQuery& query, const Stock& ref_stk, int ic_n, bool spearman,
22
22
  int mode, bool save_all_factors);
23
- virtual ~EqualWeightMultiFactor() = default;
23
+ virtual ~EqualWeightMultiFactor() override = default;
24
24
  };
25
25
 
26
26
  } // namespace hku
@@ -20,7 +20,7 @@ public:
20
20
  ICIRMultiFactor(const IndicatorList& inds, const StockList& stks, const KQuery& query,
21
21
  const Stock& ref_stk, int ic_n, int ic_rolling_n, bool spearman, int mode,
22
22
  bool save_all_factors);
23
- virtual ~ICIRMultiFactor() = default;
23
+ virtual ~ICIRMultiFactor() override = default;
24
24
 
25
25
  virtual void _checkParam(const string& name) const override;
26
26
  };
@@ -20,7 +20,7 @@ public:
20
20
  ICMultiFactor(const IndicatorList& inds, const StockList& stks, const KQuery& query,
21
21
  const Stock& ref_stk, int ic_n, int ic_rolling_n, bool spearman, int mode,
22
22
  bool save_all_factors);
23
- virtual ~ICMultiFactor() = default;
23
+ virtual ~ICMultiFactor() override = default;
24
24
 
25
25
  virtual void _checkParam(const string& name) const override;
26
26
  };
@@ -22,7 +22,7 @@ public:
22
22
  WeightMultiFactor(const vector<Indicator>& inds, const PriceList& weights,
23
23
  const StockList& stks, const KQuery& query, const Stock& ref_stk, int ic_n,
24
24
  bool spearman, int mode, bool save_all_factors);
25
- virtual ~WeightMultiFactor() = default;
25
+ virtual ~WeightMultiFactor() override = default;
26
26
 
27
27
  private:
28
28
  PriceList m_weights; // 每个指标权重,与输入 inds 列表等长
@@ -0,0 +1,23 @@
1
+ /*
2
+ * Copyright (c) 2025 hikyuu.org
3
+ *
4
+ * Created on: 2025-10-03
5
+ * Author: fasiondog
6
+ */
7
+
8
+ #pragma once
9
+
10
+ #include "../NormalizeBase.h"
11
+
12
+ namespace hku {
13
+
14
+ class NormMinMax : public NormalizeBase {
15
+ NORMALIZE_IMP(NormMinMax)
16
+ NORMALIZE_NO_PRIVATE_MEMBER_SERIALIZATION
17
+
18
+ public:
19
+ NormMinMax();
20
+ virtual ~NormMinMax() override;
21
+ };
22
+
23
+ } // namespace hku
@@ -0,0 +1,28 @@
1
+ /*
2
+ * Copyright (c) 2025 hikyuu.org
3
+ *
4
+ * Created on: 2025-10-03
5
+ * Author: fasiondog
6
+ */
7
+
8
+ #pragma once
9
+
10
+ #include "../NormalizeBase.h"
11
+
12
+ namespace hku {
13
+
14
+ /*
15
+ * 分位数均匀分布标准化
16
+ */
17
+ class NormQuantile : public NormalizeBase {
18
+ NORMALIZE_IMP(NormQuantile)
19
+ NORMALIZE_NO_PRIVATE_MEMBER_SERIALIZATION
20
+
21
+ public:
22
+ NormQuantile();
23
+ NormQuantile(double quantile_min, double quantile_max);
24
+ virtual ~NormQuantile() override;
25
+ virtual void _checkParam(const string& name) const override;
26
+ };
27
+
28
+ } // namespace hku
@@ -0,0 +1,28 @@
1
+ /*
2
+ * Copyright (c) 2025 hikyuu.org
3
+ *
4
+ * Created on: 2025-10-03
5
+ * Author: fasiondog
6
+ */
7
+
8
+ #pragma once
9
+
10
+ #include "../NormalizeBase.h"
11
+
12
+ namespace hku {
13
+
14
+ /*
15
+ * 分位数均匀分布标准化
16
+ */
17
+ class NormQuantileUniform : public NormalizeBase {
18
+ NORMALIZE_IMP(NormQuantileUniform)
19
+ NORMALIZE_NO_PRIVATE_MEMBER_SERIALIZATION
20
+
21
+ public:
22
+ NormQuantileUniform();
23
+ NormQuantileUniform(double quantile_min, double quantile_max);
24
+ virtual ~NormQuantileUniform() override;
25
+ virtual void _checkParam(const string& name) const override;
26
+ };
27
+
28
+ } // namespace hku
@@ -0,0 +1,25 @@
1
+ /*
2
+ * Copyright (c) 2025 hikyuu.org
3
+ *
4
+ * Created on: 2025-10-03
5
+ * Author: fasiondog
6
+ */
7
+
8
+ #pragma once
9
+
10
+ #include "../NormalizeBase.h"
11
+
12
+ namespace hku {
13
+
14
+ class NormZScore : public NormalizeBase {
15
+ NORMALIZE_IMP(NormZScore)
16
+ NORMALIZE_NO_PRIVATE_MEMBER_SERIALIZATION
17
+
18
+ public:
19
+ NormZScore();
20
+ NormZScore(bool outExtreme, double nsigma, bool recursive);
21
+ virtual ~NormZScore() override;
22
+ virtual void _checkParam(const string& name) const override;
23
+ };
24
+
25
+ } // namespace hku
@@ -0,0 +1,16 @@
1
+ /*
2
+ * Copyright (c) 2025 hikyuu.org
3
+ *
4
+ * Created on: 2025-10-15
5
+ * Author: fasiondog
6
+ */
7
+
8
+ #pragma once
9
+
10
+ #include "hikyuu/DataType.h"
11
+
12
+ namespace hku {
13
+
14
+ PriceList quantile_trunc(const PriceList &src, double quantile_min, double quantile_max);
15
+
16
+ }
@@ -105,6 +105,13 @@ public:
105
105
 
106
106
  virtual void _readyForRun() {}
107
107
  virtual void _runMoment(const Datetime& date, const Datetime& nextCycle, bool adjust) {}
108
+ virtual void _runMomentOnOpen(const Datetime& date, const Datetime& nextCycle, bool adjust) {}
109
+ virtual void _runMomentOnClose(const Datetime& date, const Datetime& nextCycle, bool adjust) {}
110
+
111
+ /**
112
+ * 回测完成后,返回最后一天交易记录,以及需要延迟的买入和卖出延迟请求
113
+ */
114
+ virtual json lastSuggestion() const;
108
115
 
109
116
  private:
110
117
  void initParam();
@@ -28,6 +28,13 @@ public:
28
28
  SimplePortfolio(const TradeManagerPtr& tm, const SelectorPtr& se, const AFPtr& af);
29
29
  virtual ~SimplePortfolio();
30
30
 
31
+ virtual void _runMomentOnOpen(const Datetime& date, const Datetime& nextCycle,
32
+ bool adjust) override;
33
+ virtual void _runMomentOnClose(const Datetime& date, const Datetime& nextCycle,
34
+ bool adjust) override;
35
+
36
+ virtual json lastSuggestion() const override;
37
+
31
38
  private:
32
39
  SystemList m_dlist_sys_list; // 因证券退市,无法执行卖出的系统(资产全部损失)
33
40
  SystemWeightList m_delay_adjust_sys_list; // 延迟调仓卖出的系统列表
@@ -25,6 +25,13 @@ public:
25
25
  WithoutAFPortfolio(const TradeManagerPtr& tm, const SelectorPtr& se);
26
26
  virtual ~WithoutAFPortfolio();
27
27
 
28
+ virtual void _runMomentOnOpen(const Datetime& date, const Datetime& nextCycle,
29
+ bool adjust) override;
30
+ virtual void _runMomentOnClose(const Datetime& date, const Datetime& nextCycle,
31
+ bool adjust) override;
32
+
33
+ virtual json lastSuggestion() const override;
34
+
28
35
  private:
29
36
  void initParam();
30
37
  void _runMomentWithoutAFNotForceSell(const Datetime& date, const Datetime& nextCycle,
@@ -13,10 +13,13 @@
13
13
  #include "../../KData.h"
14
14
  #include "../../utilities/Parameter.h"
15
15
  #include "hikyuu/trade_sys/allocatefunds/AllocateFundsBase.h"
16
+ #include "hikyuu/trade_sys/multifactor/MultiFactorBase.h"
16
17
  #include "SystemWeight.h"
17
18
 
18
19
  namespace hku {
19
20
 
21
+ class HKU_API Portfolio;
22
+
20
23
  /**
21
24
  * 交易对象选择模块
22
25
  * @ingroup Selector
@@ -44,6 +47,15 @@ public:
44
47
  /** 设置算法名称 */
45
48
  void name(const string& name);
46
49
 
50
+ using PFPtr = shared_ptr<Portfolio>;
51
+ PFPtr getPF() const {
52
+ return m_pf.lock();
53
+ }
54
+
55
+ void setPF(const PFPtr& pf) {
56
+ m_pf = pf;
57
+ }
58
+
47
59
  /**
48
60
  * 添加备选股票及其交易策略原型
49
61
  * @param stock 备选股票
@@ -132,6 +144,25 @@ public:
132
144
 
133
145
  virtual string str() const;
134
146
 
147
+ public:
148
+ //------------------------------------------------------------------------
149
+ // 和 MF 相关的 Selector 才有用,放在这里主要为了 SEPtr 可以直接获取 MF 相关信息
150
+ // 非 MF 相关的 Selecter 无用
151
+ //------------------------------------------------------------------------
152
+ MFPtr getMF() const {
153
+ return m_mf;
154
+ }
155
+
156
+ ScoresFilterPtr getScoresFilter() const {
157
+ return m_sc_filter;
158
+ }
159
+
160
+ /** 设置截面评分记录过滤,仅用于 MF 相关的 Selector,从 MF 获取 Score 列表时进行过滤 */
161
+ void setScoresFilter(const ScoresFilterPtr& filter);
162
+
163
+ /** 在已有过滤基础上追加过滤,仅用于 MF 相关的 Selector,从 MF 获取 Score 列表时进行过滤 */
164
+ void addScoresFilter(const ScoresFilterPtr& filter);
165
+
135
166
  protected:
136
167
  virtual bool isPythonObject() const {
137
168
  return false;
@@ -140,6 +171,10 @@ protected:
140
171
  private:
141
172
  void initParam();
142
173
 
174
+ protected:
175
+ ScoresFilterPtr m_sc_filter;
176
+ MFPtr m_mf;
177
+
143
178
  protected:
144
179
  string m_name;
145
180
  bool m_calculated{false}; // 是否已计算过
@@ -150,6 +185,8 @@ protected:
150
185
  SystemList m_pro_sys_list; // 原型系统列表
151
186
  SystemList m_real_sys_list; // PF组合中实际运行的系统,有PF执行时设定,顺序与原型列表一一对应
152
187
 
188
+ std::weak_ptr<Portfolio> m_pf; // 仅存储不序列化,对 PF 的引用
189
+
153
190
  //============================================
154
191
  // 序列化支持
155
192
  //============================================
@@ -161,6 +198,8 @@ private:
161
198
  ar& BOOST_SERIALIZATION_NVP(m_name);
162
199
  ar& BOOST_SERIALIZATION_NVP(m_params);
163
200
  ar& BOOST_SERIALIZATION_NVP(m_pro_sys_list);
201
+ ar& BOOST_SERIALIZATION_NVP(m_sc_filter);
202
+ ar& BOOST_SERIALIZATION_NVP(m_mf);
164
203
  }
165
204
 
166
205
  template <class Archive>
@@ -168,6 +207,8 @@ private:
168
207
  ar& BOOST_SERIALIZATION_NVP(m_name);
169
208
  ar& BOOST_SERIALIZATION_NVP(m_params);
170
209
  ar& BOOST_SERIALIZATION_NVP(m_pro_sys_list);
210
+ ar& BOOST_SERIALIZATION_NVP(m_sc_filter);
211
+ ar& BOOST_SERIALIZATION_NVP(m_mf);
171
212
  }
172
213
 
173
214
  BOOST_SERIALIZATION_SPLIT_MEMBER()
@@ -238,6 +279,14 @@ inline const SystemList& SelectorBase::getProtoSystemList() const {
238
279
  return m_pro_sys_list;
239
280
  }
240
281
 
282
+ inline void SelectorBase::setScoresFilter(const ScoresFilterPtr& filter) {
283
+ m_sc_filter = filter;
284
+ }
285
+
286
+ inline void SelectorBase::addScoresFilter(const ScoresFilterPtr& filter) {
287
+ m_sc_filter = m_sc_filter | filter;
288
+ }
289
+
241
290
  } /* namespace hku */
242
291
 
243
292
  #if FMT_VERSION >= 90000
@@ -11,6 +11,7 @@
11
11
 
12
12
  #include "crt/SE_Fixed.h"
13
13
  #include "crt/SE_MultiFactor.h"
14
+ #include "crt/SE_MultiFactor2.h"
14
15
  #include "crt/SE_Logic.h"
15
16
  #include "crt/SE_Optimal.h"
16
17
  #include "crt/SE_Signal.h"
@@ -0,0 +1,40 @@
1
+ /*
2
+ * Copyright (c) 2024 hikyuu.org
3
+ *
4
+ * Created on: 2024-03-30
5
+ * Author: fasiondog
6
+ */
7
+
8
+ #pragma once
9
+
10
+ #include "hikyuu/trade_sys/multifactor/MultiFactorBase.h"
11
+ #include "hikyuu/trade_sys/multifactor/buildin_scfilter.h"
12
+ #include "../SelectorBase.h"
13
+
14
+ namespace hku {
15
+
16
+ /**
17
+ * 基于 MultiFactor 选股算法
18
+ * @return SelectorPtr
19
+ * @ingroup Selector
20
+ */
21
+ SelectorPtr HKU_API SE_MultiFactor2(const MFPtr& mf,
22
+ const ScoresFilterPtr& filter = SCFilter_IgnoreNan());
23
+
24
+ /**
25
+ * 基于 MultiFactor 选股算法
26
+ * @param src_inds 原始因子公式
27
+ * @param ic_n ic 对应的 ic_n 日收益率
28
+ * @param ic_rolling_n 计算滚动 IC (即 IC 的 n 日移动平均)周期
29
+ * @param ref_stk 参照对比证券,未指定时,默认使用 sh000300 沪深300指数
30
+ * @param spearman 默认使用 spearman 计算相关系数,否则为 pearson
31
+ * @param mode "MF_ICIRWeight" | "MF_ICWeight" | "MF_EqualWeight" 因子合成算法名称
32
+ * @return SelectorPtr
33
+ * @ingroup Selector
34
+ */
35
+ SelectorPtr HKU_API SE_MultiFactor2(const IndicatorList& src_inds, int ic_n = 5,
36
+ int ic_rolling_n = 120, const Stock& ref_stk = Stock(),
37
+ bool spearman = true, const string& mode = "MF_ICIRWeight",
38
+ const ScoresFilterPtr& filter = SCFilter_IgnoreNan());
39
+
40
+ } // namespace hku
@@ -7,7 +7,6 @@
7
7
 
8
8
  #pragma once
9
9
 
10
- #include "hikyuu/trade_sys/multifactor/MultiFactorBase.h"
11
10
  #include "../SelectorBase.h"
12
11
 
13
12
  namespace hku {
@@ -39,7 +38,6 @@ private:
39
38
 
40
39
  private:
41
40
  IndicatorList m_inds;
42
- MFPtr m_mf;
43
41
  unordered_map<Stock, SYSPtr> m_stk_sys_dict;
44
42
 
45
43
  //============================================
@@ -51,7 +49,6 @@ private:
51
49
  void serialize(Archive& ar, const unsigned int version) {
52
50
  ar& BOOST_SERIALIZATION_BASE_OBJECT_NVP(SelectorBase);
53
51
  ar& BOOST_SERIALIZATION_NVP(m_inds);
54
- ar& BOOST_SERIALIZATION_NVP(m_mf);
55
52
  }
56
53
  #endif
57
54
  };
@@ -0,0 +1,49 @@
1
+ /*
2
+ * Copyright (c) 2024 hikyuu.org
3
+ *
4
+ * Created on: 2024-xx-xx
5
+ * Author: fasiondog
6
+ */
7
+
8
+ #pragma once
9
+
10
+ #include "../SelectorBase.h"
11
+
12
+ namespace hku {
13
+
14
+ class MultiFactorSelector2 : public SelectorBase {
15
+ public:
16
+ MultiFactorSelector2();
17
+ MultiFactorSelector2(const MFPtr& mf);
18
+ virtual ~MultiFactorSelector2();
19
+
20
+ virtual void _checkParam(const string& name) const override;
21
+ virtual void _reset() override;
22
+ virtual SelectorPtr _clone() override;
23
+ virtual SystemWeightList _getSelected(Datetime date) override;
24
+ virtual bool isMatchAF(const AFPtr& af) override;
25
+ virtual void _calculate() override;
26
+
27
+ void setIndicators(const IndicatorList& inds) {
28
+ HKU_ASSERT(!inds.empty());
29
+ m_inds = inds;
30
+ }
31
+
32
+ private:
33
+ IndicatorList m_inds;
34
+ unordered_map<Stock, SYSPtr> m_stk_sys_dict;
35
+
36
+ //============================================
37
+ // 序列化支持
38
+ //============================================
39
+ #if HKU_SUPPORT_SERIALIZATION
40
+ friend class boost::serialization::access;
41
+ template <class Archive>
42
+ void serialize(Archive& ar, const unsigned int version) {
43
+ ar& BOOST_SERIALIZATION_BASE_OBJECT_NVP(SelectorBase);
44
+ ar& BOOST_SERIALIZATION_NVP(m_inds);
45
+ }
46
+ #endif
47
+ };
48
+
49
+ } // namespace hku
@@ -85,7 +85,7 @@ public: \
85
85
  classname() : OperatorSelector(name) {} \
86
86
  classname(const SelectorPtr& se1, const SelectorPtr& se2) \
87
87
  : OperatorSelector(name, se1, se2) {} \
88
- virtual ~classname() {} \
88
+ virtual ~classname() override {} \
89
89
  \
90
90
  virtual SystemWeightList _getSelected(Datetime date) override; \
91
91
  \
@@ -66,7 +66,7 @@ private:
66
66
  public: \
67
67
  classname() : OperatorValueSelector(name) {} \
68
68
  classname(const SelectorPtr& se, double value) : OperatorValueSelector(name, se, value) {} \
69
- virtual ~classname() {} \
69
+ virtual ~classname() override {} \
70
70
  \
71
71
  virtual SystemWeightList _getSelected(Datetime date) override; \
72
72
  \