hikyuu 2.6.8.5__py3-none-win_amd64.whl → 2.7.0__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 (201) hide show
  1. hikyuu/__init__.py +31 -16
  2. hikyuu/__init__.pyi +610 -590
  3. hikyuu/analysis/__init__.pyi +584 -563
  4. hikyuu/analysis/analysis.pyi +585 -564
  5. hikyuu/core.py +2 -0
  6. hikyuu/core.pyi +586 -565
  7. hikyuu/cpp/__init__.pyi +2 -2
  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 +501 -104
  14. hikyuu/cpp/core311.pyd +0 -0
  15. hikyuu/cpp/core311.pyi +501 -104
  16. hikyuu/cpp/core312.pyd +0 -0
  17. hikyuu/cpp/core312.pyi +501 -104
  18. hikyuu/cpp/core313.pyd +0 -0
  19. hikyuu/cpp/core313.pyi +501 -104
  20. hikyuu/cpp/hikyuu.dll +0 -0
  21. hikyuu/cpp/hikyuu.lib +0 -0
  22. hikyuu/cpp/i18n/zh_CN/hikyuu.mo +0 -0
  23. hikyuu/data/clickhouse_upgrade/createdb.sql +105 -105
  24. hikyuu/data/common.py +3 -3
  25. hikyuu/data/common_clickhouse.py +1 -1
  26. hikyuu/data/download_block.py +351 -0
  27. hikyuu/data/em_block_to_clickhouse.py +26 -74
  28. hikyuu/data/em_block_to_mysql.py +25 -75
  29. hikyuu/data/em_block_to_sqlite.py +26 -78
  30. hikyuu/data/hku_config_template.py +3 -3
  31. hikyuu/data/pytdx_to_clickhouse.py +15 -11
  32. hikyuu/data/pytdx_to_h5.py +6 -2
  33. hikyuu/data/pytdx_to_mysql.py +5 -1
  34. hikyuu/data/pytdx_weight_to_clickhouse.py +1 -1
  35. hikyuu/data/pytdx_weight_to_mysql.py +1 -1
  36. hikyuu/data/pytdx_weight_to_sqlite.py +1 -1
  37. hikyuu/data/zh_bond10_to_clickhouse.py +1 -1
  38. hikyuu/draw/drawplot/__init__.pyi +8 -8
  39. hikyuu/draw/drawplot/bokeh_draw.pyi +600 -580
  40. hikyuu/draw/drawplot/common.pyi +1 -1
  41. hikyuu/draw/drawplot/echarts_draw.pyi +602 -582
  42. hikyuu/draw/drawplot/matplotlib_draw.py +4 -74
  43. hikyuu/draw/drawplot/matplotlib_draw.pyi +612 -592
  44. hikyuu/draw/elder.pyi +11 -11
  45. hikyuu/draw/kaufman.pyi +18 -18
  46. hikyuu/draw/volume.pyi +10 -10
  47. hikyuu/examples/notebook/Demo/Demo1.ipynb +48 -33
  48. hikyuu/extend.py +0 -8
  49. hikyuu/extend.pyi +594 -574
  50. hikyuu/fetcher/stock/zh_block_em.py +12 -40
  51. hikyuu/gui/HikyuuTDX.py +99 -31
  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 +1196 -717
  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/gui/images/liandongxiaopu.png +0 -0
  63. hikyuu/hub.pyi +6 -6
  64. hikyuu/include/hikyuu/DataType.h +4 -16
  65. hikyuu/include/hikyuu/KData.h +6 -3
  66. hikyuu/include/hikyuu/KDataPrivatedBufferImp.h +1 -1
  67. hikyuu/include/hikyuu/KDataSharedBufferImp.h +1 -1
  68. hikyuu/include/hikyuu/KQuery.h +2 -2
  69. hikyuu/include/hikyuu/Stock.h +4 -1
  70. hikyuu/include/hikyuu/StockManager.h +13 -3
  71. hikyuu/include/hikyuu/config.h +0 -3
  72. hikyuu/include/hikyuu/data_driver/BaseInfoDriver.h +8 -0
  73. hikyuu/include/hikyuu/data_driver/BlockInfoDriver.h +6 -0
  74. hikyuu/include/hikyuu/data_driver/KDataDriver.h +26 -1
  75. hikyuu/include/hikyuu/data_driver/base_info/mysql/MySQLBaseInfoDriver.h +1 -1
  76. hikyuu/include/hikyuu/data_driver/base_info/sqlite/SQLiteBaseInfoDriver.h +1 -1
  77. hikyuu/include/hikyuu/data_driver/block_info/mysql/MySQLBlockInfoDriver.h +2 -1
  78. hikyuu/include/hikyuu/data_driver/block_info/qianlong/QLBlockInfoDriver.h +2 -1
  79. hikyuu/include/hikyuu/data_driver/block_info/sqlite/SQLiteBlockInfoDriver.h +2 -1
  80. hikyuu/include/hikyuu/data_driver/kdata/DoNothingKDataDriver.h +1 -1
  81. hikyuu/include/hikyuu/data_driver/kdata/cvs/KDataTempCsvDriver.h +1 -1
  82. hikyuu/include/hikyuu/data_driver/kdata/hdf5/H5KDataDriver.h +1 -1
  83. hikyuu/include/hikyuu/data_driver/kdata/mysql/MySQLKDataDriver.h +1 -1
  84. hikyuu/include/hikyuu/data_driver/kdata/sqlite/SQLiteKDataDriver.h +1 -1
  85. hikyuu/include/hikyuu/data_driver/kdata/tdx/TdxKDataDriver.h +1 -1
  86. hikyuu/include/hikyuu/hikyuu.h +1 -1
  87. hikyuu/include/hikyuu/indicator/build_in.h +1 -0
  88. hikyuu/include/hikyuu/indicator/crt/CYCLE.h +4 -4
  89. hikyuu/include/hikyuu/indicator/crt/HSL.h +2 -2
  90. hikyuu/include/hikyuu/indicator/crt/QUANTILE_TRUNC.h +30 -0
  91. hikyuu/include/hikyuu/indicator/crt/TURNOVER.h +1 -0
  92. hikyuu/include/hikyuu/indicator/crt/ZSCORE.h +2 -2
  93. hikyuu/include/hikyuu/indicator/imp/IQuantileTrunc.h +25 -0
  94. hikyuu/include/hikyuu/misc.h +38 -0
  95. hikyuu/include/hikyuu/plugin/dataserver.h +2 -1
  96. hikyuu/include/hikyuu/plugin/device.h +10 -0
  97. hikyuu/include/hikyuu/plugin/extind.h +37 -0
  98. hikyuu/include/hikyuu/plugin/interface/DataServerPluginInterface.h +2 -2
  99. hikyuu/include/hikyuu/plugin/interface/DevicePluginInterface.h +2 -0
  100. hikyuu/include/hikyuu/plugin/interface/ExtendIndicatorsPluginInterface.h +12 -0
  101. hikyuu/include/hikyuu/plugin/interface/plugins.h +0 -5
  102. hikyuu/include/hikyuu/python/pybind_utils.h +0 -12
  103. hikyuu/include/hikyuu/strategy/RunSystemInStrategy.h +3 -0
  104. hikyuu/include/hikyuu/trade_manage/Performance.h +4 -4
  105. hikyuu/include/hikyuu/trade_manage/TradeManagerBase.h +10 -1
  106. hikyuu/include/hikyuu/trade_sys/moneymanager/imp/FixedCapitalFundsMM.h +0 -4
  107. hikyuu/include/hikyuu/trade_sys/multifactor/MultiFactorBase.h +36 -3
  108. hikyuu/include/hikyuu/trade_sys/multifactor/NormalizeBase.h +125 -0
  109. hikyuu/include/hikyuu/trade_sys/multifactor/ScoresFilterBase.h +125 -0
  110. hikyuu/include/hikyuu/trade_sys/multifactor/build_in.h +3 -0
  111. hikyuu/include/hikyuu/trade_sys/multifactor/buildin_norm.h +36 -0
  112. hikyuu/include/hikyuu/trade_sys/multifactor/buildin_scfilter.h +51 -0
  113. hikyuu/include/hikyuu/trade_sys/multifactor/filter/GroupSCFilter.h +24 -0
  114. hikyuu/include/hikyuu/trade_sys/multifactor/filter/IgnoreLessOrEqualValueSCFilter.h +24 -0
  115. hikyuu/include/hikyuu/trade_sys/multifactor/filter/IgnoreNanSCFilter.h +24 -0
  116. hikyuu/include/hikyuu/trade_sys/multifactor/filter/MinAmountPercentSCFilter.h +25 -0
  117. hikyuu/include/hikyuu/trade_sys/multifactor/filter/PriceSCFilter.h +24 -0
  118. hikyuu/include/hikyuu/trade_sys/multifactor/filter/TopNSCFilter.h +24 -0
  119. hikyuu/include/hikyuu/trade_sys/multifactor/imp/EqualWeightMultiFactor.h +1 -1
  120. hikyuu/include/hikyuu/trade_sys/multifactor/imp/ICIRMultiFactor.h +1 -1
  121. hikyuu/include/hikyuu/trade_sys/multifactor/imp/ICMultiFactor.h +1 -1
  122. hikyuu/include/hikyuu/trade_sys/multifactor/imp/WeightMultiFactor.h +1 -1
  123. hikyuu/include/hikyuu/trade_sys/multifactor/normalize/NormMinMax.h +23 -0
  124. hikyuu/include/hikyuu/trade_sys/multifactor/normalize/NormQuantile.h +28 -0
  125. hikyuu/include/hikyuu/trade_sys/multifactor/normalize/NormQuantileUniform.h +28 -0
  126. hikyuu/include/hikyuu/trade_sys/multifactor/normalize/NormZScore.h +25 -0
  127. hikyuu/include/hikyuu/trade_sys/multifactor/normalize/__init__.py +1 -0
  128. hikyuu/include/hikyuu/trade_sys/multifactor/normalize/quantile_trunc.h +16 -0
  129. hikyuu/include/hikyuu/trade_sys/portfolio/Portfolio.h +7 -0
  130. hikyuu/include/hikyuu/trade_sys/portfolio/imp/SimplePortfolio.h +7 -0
  131. hikyuu/include/hikyuu/trade_sys/portfolio/imp/WithoutAFPortfolio.h +7 -0
  132. hikyuu/include/hikyuu/trade_sys/selector/SelectorBase.h +49 -0
  133. hikyuu/include/hikyuu/trade_sys/selector/build_in.h +1 -0
  134. hikyuu/include/hikyuu/trade_sys/selector/crt/SE_MultiFactor2.h +40 -0
  135. hikyuu/include/hikyuu/trade_sys/selector/imp/MultiFactorSelector.h +0 -3
  136. hikyuu/include/hikyuu/trade_sys/selector/imp/MultiFactorSelector2.h +49 -0
  137. hikyuu/include/hikyuu/trade_sys/selector/imp/logic/OperatorSelector.h +1 -1
  138. hikyuu/include/hikyuu/trade_sys/selector/imp/logic/OperatorValueSelector.h +1 -1
  139. hikyuu/include/hikyuu/trade_sys/signal/imp/BandSignal2.h +0 -4
  140. hikyuu/include/hikyuu/trade_sys/signal/imp/logic/AddValueSignal.h +2 -2
  141. hikyuu/include/hikyuu/trade_sys/signal/imp/logic/DivValueSignal.h +2 -2
  142. hikyuu/include/hikyuu/trade_sys/signal/imp/logic/MulValueSignal.h +2 -2
  143. hikyuu/include/hikyuu/trade_sys/signal/imp/logic/OperatorSignal.h +1 -1
  144. hikyuu/include/hikyuu/trade_sys/signal/imp/logic/OperatorValueSignal.h +4 -4
  145. hikyuu/include/hikyuu/trade_sys/signal/imp/logic/SubValueSignal.h +2 -2
  146. hikyuu/include/hikyuu/trade_sys/slippage/build_in.h +5 -1
  147. hikyuu/include/hikyuu/trade_sys/slippage/crt/SP_LogNormal.h +22 -0
  148. hikyuu/include/hikyuu/trade_sys/slippage/crt/SP_Normal.h +22 -0
  149. hikyuu/include/hikyuu/trade_sys/slippage/crt/SP_TruncNormal.h +25 -0
  150. hikyuu/include/hikyuu/trade_sys/slippage/crt/SP_Uniform.h +23 -0
  151. hikyuu/include/hikyuu/trade_sys/slippage/imp/LogNormalSlippage.h +28 -0
  152. hikyuu/include/hikyuu/trade_sys/slippage/imp/NormalSlippage.h +28 -0
  153. hikyuu/include/hikyuu/trade_sys/slippage/imp/TruncNormalSlippage.h +28 -0
  154. hikyuu/include/hikyuu/trade_sys/slippage/imp/UniformSlippage.h +24 -0
  155. hikyuu/include/hikyuu/trade_sys/system/System.h +14 -1
  156. hikyuu/include/hikyuu/utilities/SpendTimer.h +17 -7
  157. hikyuu/include/hikyuu/utilities/arithmetic.h +45 -0
  158. hikyuu/include/hikyuu/utilities/db_connect/mysql/MySQLConnect.h +1 -1
  159. hikyuu/include/hikyuu/utilities/db_connect/mysql/MySQLStatement.h +1 -1
  160. hikyuu/include/hikyuu/utilities/db_connect/sqlite/SQLiteConnect.h +1 -1
  161. hikyuu/include/hikyuu/utilities/db_connect/sqlite/SQLiteStatement.h +1 -1
  162. hikyuu/include/hikyuu/utilities/plugin/PluginLoader.h +4 -1
  163. hikyuu/include/hikyuu/version.h +5 -5
  164. hikyuu/plugin/backtest.dll +0 -0
  165. hikyuu/plugin/clickhousedriver.dll +0 -0
  166. hikyuu/plugin/dataserver.dll +0 -0
  167. hikyuu/plugin/dataserver_parquet.dll +0 -0
  168. hikyuu/plugin/device.dll +0 -0
  169. hikyuu/plugin/extind.dll +0 -0
  170. hikyuu/plugin/hkuextra.dll +0 -0
  171. hikyuu/plugin/import2hdf5.dll +0 -0
  172. hikyuu/plugin/tmreport.dll +0 -0
  173. hikyuu/trade_manage/__init__.pyi +600 -580
  174. hikyuu/trade_manage/broker.pyi +3 -3
  175. hikyuu/trade_manage/broker_easytrader.pyi +1 -1
  176. hikyuu/trade_manage/trade.py +0 -2
  177. hikyuu/trade_manage/trade.pyi +600 -580
  178. hikyuu/util/__init__.pyi +2 -2
  179. hikyuu/util/singleton.pyi +1 -1
  180. {hikyuu-2.6.8.5.dist-info → hikyuu-2.7.0.dist-info}/METADATA +36 -33
  181. {hikyuu-2.6.8.5.dist-info → hikyuu-2.7.0.dist-info}/RECORD +185 -168
  182. {hikyuu-2.6.8.5.dist-info → hikyuu-2.7.0.dist-info}/top_level.txt +2 -2
  183. hikyuu/cpp/core39.pyd +0 -0
  184. hikyuu/cpp/core39.pyi +0 -14381
  185. hikyuu/data_driver/__init__.py +0 -49
  186. hikyuu/data_driver/jqdata_data_driver.py +0 -277
  187. hikyuu/data_driver/pytdx_data_driver.py +0 -292
  188. hikyuu/fetcher/stock/zh_stock_a_huatai.py +0 -51
  189. hikyuu/fetcher/stock/zh_stock_a_pytdx.py +0 -129
  190. hikyuu/gui/data/CollectToMemThread.py +0 -123
  191. hikyuu/gui/data/CollectToMySQLThread.py +0 -178
  192. hikyuu/gui/start_huatai_insight.py +0 -510
  193. hikyuu/include/hikyuu/plugin/hkuviews.h +0 -36
  194. hikyuu/include/hikyuu/plugin/interface/HkuViewsPluginInterface.h +0 -34
  195. hikyuu/include/hikyuu/views/arrow_common.h +0 -38
  196. hikyuu/include/hikyuu/views/arrow_views.h +0 -117
  197. hikyuu/plugin/hkuviews.dll +0 -0
  198. hikyuu/tools/update_block_info.py +0 -168
  199. /hikyuu/include/hikyuu/{views → trade_sys/multifactor/filter}/__init__.py +0 -0
  200. {hikyuu-2.6.8.5.dist-info → hikyuu-2.7.0.dist-info}/WHEEL +0 -0
  201. {hikyuu-2.6.8.5.dist-info → hikyuu-2.7.0.dist-info}/entry_points.txt +0 -0
@@ -20,8 +20,8 @@ namespace hku {
20
20
  * @param k 关联的K线数据
21
21
  * @ingroup Indicator
22
22
  */
23
- Indicator HSL(const KData& k);
24
- Indicator HSL();
23
+ Indicator HKU_API HSL(const KData& k);
24
+ Indicator HKU_API HSL();
25
25
 
26
26
  } // namespace hku
27
27
  #endif /* INDICATOR_CRT_HSL_H_ */
@@ -0,0 +1,30 @@
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 "../Indicator.h"
11
+
12
+ namespace hku {
13
+
14
+ /**
15
+ * 使用分位数法则进行数据截断处理
16
+ * @param int n 窗口大小
17
+ * @param quantile_min 最小分位数
18
+ * @param quantile_max 最大分位数
19
+ * @return Indicator
20
+ * @ingroup Indicator
21
+ */
22
+ Indicator HKU_API QUANTILE_TRUNC(int n = 60, double quantile_min = 0.01,
23
+ double quantile_max = 0.99);
24
+
25
+ inline Indicator HKU_API QUANTILE_TRUNC(const Indicator& data, int n = 60,
26
+ double quantile_min = 0.01, double quantile_max = 0.99) {
27
+ return QUANTILE_TRUNC(n, quantile_min, quantile_max)(data);
28
+ }
29
+
30
+ } // namespace hku
@@ -5,6 +5,7 @@
5
5
  * Author: fasiondog
6
6
  */
7
7
 
8
+ #pragma once
8
9
  #include "../Indicator.h"
9
10
 
10
11
  namespace hku {
@@ -12,9 +12,9 @@
12
12
  namespace hku {
13
13
 
14
14
  /**
15
- * 对数据进行ZScore标准化,可选进行极值排除
15
+ * 对数据进行ZScore标准化(3sigma)进行极值处理
16
16
  * @note 非窗口滚动,如需窗口滚动的标准化,直接 (x - MA(x, n)) / STDEV(x, n) 即可
17
- * @param outExtreme 指示剔除极值
17
+ * @param outExtreme 指示剔除极值(即截断极值,超过限制的用限制值替代)
18
18
  * @param nsigma 剔除极值时使用的 nsigma 倍 sigma
19
19
  * @param recursive 是否进行递归剔除极值
20
20
  * @return Indicator
@@ -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 "../Indicator.h"
11
+
12
+ namespace hku {
13
+
14
+ /* 分位数截断处理 */
15
+ class IQuantileTrunc : public IndicatorImp {
16
+ INDICATOR_IMP(IQuantileTrunc)
17
+ INDICATOR_IMP_NO_PRIVATE_MEMBER_SERIALIZATION
18
+
19
+ public:
20
+ IQuantileTrunc();
21
+ virtual ~IQuantileTrunc();
22
+ virtual void _checkParam(const string& name) const override;
23
+ };
24
+
25
+ } // namespace hku
@@ -0,0 +1,38 @@
1
+ /*
2
+ * Copyright (c) 2025 hikyuu.org
3
+ *
4
+ * Created on: 2025-10-17
5
+ * Author: fasiondog
6
+ *
7
+ * 部分杂类函数
8
+ */
9
+
10
+ #pragma once
11
+
12
+ #include "trade_sys/system/System.h"
13
+ #include "trade_sys/portfolio/Portfolio.h"
14
+
15
+ namespace hku {
16
+
17
+ /**
18
+ * @brief 并行运行系统
19
+ * @param system_list 系统列表
20
+ * @param query 系统运行查询条件
21
+ * @param reset 执行前是否依据系统部件共享属性复位
22
+ * @param resetAll 强制复位所有部件
23
+ * @return 各系统Query周期内各时间点的资金列表
24
+ */
25
+ vector<FundsList> HKU_API parallel_run_sys(const SystemList& system_list, const KQuery& query,
26
+ bool reset = true, bool resetAll = false);
27
+
28
+ /**
29
+ * @brief 并行运行组合
30
+ * @param pf_list 组合列表
31
+ * @param query 组合运行查询条件
32
+ * @param force 强制复位
33
+ * @return vector<FundsList>
34
+ */
35
+ vector<FundsList> HKU_API parallel_run_pf(const vector<PFPtr>& pf_list, const KQuery& query,
36
+ bool force = false);
37
+
38
+ } // namespace hku
@@ -14,7 +14,8 @@
14
14
  namespace hku {
15
15
 
16
16
  void HKU_API startDataServer(const std::string& addr = "tcp://0.0.0.0:9201", size_t work_num = 2,
17
- bool save_tick = false, bool buf_tick = false);
17
+ bool save_tick = false, bool buf_tick = false,
18
+ const std::string& parquet_path = std::string());
18
19
 
19
20
  void HKU_API stopDataServer();
20
21
 
@@ -11,6 +11,13 @@
11
11
 
12
12
  namespace hku {
13
13
 
14
+ /**
15
+ * @brief 绑定授权码
16
+ * @param email 邮箱
17
+ * @param active_code 授权码
18
+ */
19
+ void HKU_API bindEmail(const std::string& email, const std::string& active_code);
20
+
14
21
  /**
15
22
  * @brief 激活设备
16
23
  * @param active_code 授权码
@@ -30,4 +37,7 @@ std::string HKU_API fetchTrialLicense(const std::string& email);
30
37
  /** 检查授权是否有效 */
31
38
  bool HKU_API isValidLicense();
32
39
 
40
+ /** 获取授权到期时间 */
41
+ Datetime HKU_API getExpireDate();
42
+
33
43
  } // namespace hku
@@ -191,5 +191,42 @@ Indicator HKU_API AGG_VAR(const Indicator& ind, const KQuery::KType& ktype = KQu
191
191
  Indicator HKU_API AGG_QUANTILE(const Indicator& ind, const KQuery::KType& ktype = KQuery::MIN,
192
192
  bool fill_null = false, int unit = 1, double quantile = 0.75);
193
193
 
194
+ using agg_func_t = std::function<double(const DatetimeList& src_ds, const Indicator::value_t* src,
195
+ size_t group_start, size_t group_last)>;
196
+ Indicator HKU_API AGG_FUNC(const Indicator& ind, agg_func_t agg_func,
197
+ const KQuery::KType& ktype = KQuery::MIN, bool fill_null = false,
198
+ int unit = 1);
199
+
200
+ /**
201
+ * @brief 按周期分组就散
202
+ * @param ktype 指定K线周期
203
+ * @param unit 分组周期单位,默认为1。按 ktype 参数 unit 个周期计算
204
+ * @return Indicator
205
+ */
206
+ #define GROUP_FUNC_DEFINE(group_name) \
207
+ Indicator HKU_API group_name(const Indicator& ind, const KQuery::KType& ktype = KQuery::DAY, \
208
+ int unit = 1);
209
+
210
+ #define GROUP_FUNC_IMP(group_name) \
211
+ Indicator HKU_API group_name(const Indicator& ind, const KQuery::KType& ktype, int unit) { \
212
+ Parameter params; \
213
+ params.set<string>("ktype", ktype); \
214
+ params.set<int>("unit", unit); \
215
+ return getExtIndicator(#group_name, ind, params); \
216
+ }
217
+
218
+ GROUP_FUNC_DEFINE(GROUP_COUNT)
219
+ GROUP_FUNC_DEFINE(GROUP_SUM)
220
+ GROUP_FUNC_DEFINE(GROUP_MEAN)
221
+ GROUP_FUNC_DEFINE(GROUP_PROD)
222
+ GROUP_FUNC_DEFINE(GROUP_MIN)
223
+ GROUP_FUNC_DEFINE(GROUP_MAX)
224
+
225
+ using group_func_t =
226
+ std::function<void(Indicator::value_t* dst, const DatetimeList& src_ds,
227
+ const Indicator::value_t* src, size_t group_start, size_t group_last)>;
228
+ Indicator HKU_API GROUP_FUNC(const Indicator& ind, group_func_t group_func,
229
+ const KQuery::KType& ktype = KQuery::DAY, int unit = 1);
230
+
194
231
  /** @} */
195
232
  } // namespace hku
@@ -16,8 +16,8 @@ public:
16
16
  DataServerPluginInterface() = default;
17
17
  virtual ~DataServerPluginInterface() = default;
18
18
 
19
- virtual void start(const std::string& addr, size_t work_num, bool save_tick,
20
- bool buf_tick) noexcept = 0;
19
+ virtual void start(const std::string& addr, size_t work_num, bool save_tick, bool buf_tick,
20
+ const std::string& parquet_path) noexcept = 0;
21
21
  virtual void stop() noexcept = 0;
22
22
  };
23
23
 
@@ -16,11 +16,13 @@ public:
16
16
  DevicePluginInterface() = default;
17
17
  virtual ~DevicePluginInterface() = default;
18
18
 
19
+ virtual void bind(const std::string& email, const std::string& active_code) noexcept = 0;
19
20
  virtual void activate(const std::string& active_code, bool replace) noexcept = 0;
20
21
  virtual std::string viewLicense() noexcept = 0;
21
22
  virtual void removeLicense() noexcept = 0;
22
23
  virtual std::string fetchTrialLicense(const std::string& email) noexcept = 0;
23
24
  virtual bool isValidLicsense() noexcept = 0;
25
+ virtual Datetime getExpireDate() const noexcept = 0;
24
26
  };
25
27
 
26
28
  } // namespace hku
@@ -21,6 +21,18 @@ public:
21
21
 
22
22
  virtual Indicator getIndicator(const std::string& name, const Indicator& ref_ind,
23
23
  const Parameter& params) const = 0;
24
+
25
+ using agg_func_t =
26
+ std::function<Indicator::value_t(const DatetimeList& src_ds, const Indicator::value_t* src,
27
+ size_t group_start, size_t group_last)>;
28
+ virtual Indicator getAggFuncIndicator(const Indicator& ref_ind, agg_func_t agg_func,
29
+ const Parameter& params) const = 0;
30
+
31
+ using group_func_t =
32
+ std::function<void(Indicator::value_t* dst, const DatetimeList& src_ds,
33
+ const Indicator::value_t* src, size_t group_start, size_t group_last)>;
34
+ virtual Indicator getGroupFuncIndicator(const Indicator& ref_ind, group_func_t group_func,
35
+ const Parameter& params) const = 0;
24
36
  };
25
37
 
26
38
  } // namespace hku
@@ -18,10 +18,6 @@
18
18
  #include "DataDriverPluginInterface.h"
19
19
  #include "HkuExtraPluginInterface.h"
20
20
 
21
- #if HKU_ENABLE_ARROW
22
- #include "HkuViewsPluginInterface.h"
23
- #endif
24
-
25
21
  namespace hku {
26
22
 
27
23
  #define HKU_PLUGIN_BACKTEST "backtest"
@@ -32,6 +28,5 @@ namespace hku {
32
28
  #define HKU_PLUGIN_TMREPORT "tmreport"
33
29
  #define HKU_PLUGIN_CLICKHOUSE_DRIVER "clickhousedriver"
34
30
  #define HKU_PLUGIN_HKU_EXTRA "hkuextra"
35
- #define HKU_PLUGIN_HKU_VIEWS "hkuviews"
36
31
 
37
32
  } // namespace hku
@@ -10,9 +10,6 @@
10
10
  #define HIKYUU_PYTHON_BIND_UTILS_H
11
11
 
12
12
  #include <hikyuu/config.h>
13
- #if HKU_ENABLE_ARROW
14
- #include <arrow/api.h>
15
- #endif
16
13
  #include <pybind11/pybind11.h>
17
14
 
18
15
  #include <pybind11/operators.h>
@@ -127,15 +124,6 @@ inline bool check_pyfunction_arg_num(const py::object& func, size_t arg_num) {
127
124
  */
128
125
  size_t utf8_to_utf32(const std::string& utf8_str, int32_t* out, size_t out_len) noexcept;
129
126
 
130
- #if HKU_ENABLE_ARROW
131
- /*
132
- * 将arrow::Table转换为 pyarrow::Table
133
- * @param table 待转换的arrow::Table
134
- * @return 转换后的py::object
135
- */
136
- py::object to_pyarrow_table(const std::shared_ptr<arrow::Table>& table);
137
- #endif
138
-
139
127
  } // namespace hku
140
128
 
141
129
  #endif // HIKYUU_PYTHON_BIND_UTILS_H
@@ -20,6 +20,9 @@ public:
20
20
 
21
21
  void run(const Stock& stock);
22
22
 
23
+ void runMomentOnOpen(const Stock& stock);
24
+ void runMomentOnClose(const Stock& stock);
25
+
23
26
  private:
24
27
  SYSPtr m_sys;
25
28
  OrderBrokerPtr m_broker;
@@ -6,14 +6,15 @@
6
6
  */
7
7
 
8
8
  #pragma once
9
- #ifndef PERFORMANCE_H_
10
- #define PERFORMANCE_H_
11
9
 
12
- #include <boost/function.hpp>
13
10
  #include "TradeManagerBase.h"
14
11
 
15
12
  namespace hku {
16
13
 
14
+ #if defined(_MSC_VER)
15
+ #pragma warning(disable : 4251)
16
+ #endif
17
+
17
18
  /**
18
19
  * 简单绩效统计
19
20
  * @ingroup Performance
@@ -84,4 +85,3 @@ private:
84
85
  };
85
86
 
86
87
  } /* namespace hku */
87
- #endif /* PERFORMANCE_H_ */
@@ -7,7 +7,6 @@
7
7
 
8
8
  #pragma once
9
9
 
10
- #include "../utilities/Parameter.h"
11
10
  #include "TradeRecord.h"
12
11
  #include "PositionRecord.h"
13
12
  #include "PositionExtInfo.h"
@@ -17,6 +16,7 @@
17
16
  #include "TradeCostBase.h"
18
17
  #include "OrderBrokerBase.h"
19
18
  #include "crt/TC_Zero.h"
19
+ #include "../utilities/Parameter.h"
20
20
 
21
21
  namespace hku {
22
22
 
@@ -825,6 +825,15 @@ inline void TradeManagerBase::paramChanged() {}
825
825
  typedef shared_ptr<TradeManagerBase> TradeManagerPtr;
826
826
  typedef shared_ptr<TradeManagerBase> TMPtr;
827
827
 
828
+ /**
829
+ * 从账户列表中一次性获取资金列表
830
+ * @param tm_list
831
+ * @param ref_dates
832
+ * @return vector<FundsList>
833
+ * @ingroup TradeManagerClass
834
+ */
835
+ vector<FundsList> HKU_API getFundsList(const vector<TMPtr>& tm_list, const DatetimeList& ref_dates);
836
+
828
837
  inline std::ostream& operator<<(std::ostream& os, const TradeManagerBase& tm) {
829
838
  os << tm.str();
830
839
  return os;
@@ -6,8 +6,6 @@
6
6
  */
7
7
 
8
8
  #pragma once
9
- #ifndef TRADE_SYS_MONEYMANAGER_IMP_FIXEDCAPITAL_FUNDS_MM_H_
10
- #define TRADE_SYS_MONEYMANAGER_IMP_FIXEDCAPITAL_FUNDS_MM_H_
11
9
 
12
10
  #include "../MoneyManagerBase.h"
13
11
 
@@ -24,5 +22,3 @@ public:
24
22
  };
25
23
 
26
24
  } /* namespace hku */
27
-
28
- #endif /* TRADE_SYS_MONEYMANAGER_IMP_FIXEDCAPITAL_FUNDS_MM_H_ */
@@ -8,7 +8,8 @@
8
8
  #pragma once
9
9
 
10
10
  #include "hikyuu/KData.h"
11
- #include "ScoreRecord.h"
11
+ #include "ScoresFilterBase.h"
12
+ #include "buildin_norm.h"
12
13
 
13
14
  namespace hku {
14
15
 
@@ -108,6 +109,9 @@ public:
108
109
  ScoreRecordList getScores(const Datetime& date, size_t start, size_t end,
109
110
  std::function<bool(const Datetime&, const ScoreRecord&)>&& filter);
110
111
 
112
+ ScoreRecordList getScores(const Datetime& date, size_t start, size_t end,
113
+ const ScoresFilterPtr& filter);
114
+
111
115
  /** 获取所有截面数据,已按降序排列 */
112
116
  const vector<ScoreRecordList>& getAllScores();
113
117
 
@@ -128,12 +132,29 @@ public:
128
132
  Indicator getICIR(int ir_n, int ic_n = 0);
129
133
 
130
134
  /**
131
- * 获取所有处理过的原始因子值(归一化、标准化)
135
+ * 获取所有处理过的原始因子值(归一化、标准化)。每次都会计算。
132
136
  * @note 考虑到内存占用,该数据没有缓存,一般用与测试或者想查看处理过的原始因子值
133
137
  * @return vector<IndicatorList> stks x inds
134
138
  */
135
139
  vector<IndicatorList> getAllSrcFactors();
136
140
 
141
+ /**
142
+ * 设置因子标准化/归一化操作
143
+ * @param norm 标准化操作
144
+ */
145
+ void setNormalize(NormPtr norm);
146
+
147
+ /**
148
+ * 对指定名称的指标应用特定的标准化/归一化、行业中性化、风格因子中性化操作。
149
+ * @note 标准化操作、行业中性化、风格因子中性化彼此无关,可同时指定也可分开指定。
150
+ * @param name 指标名称
151
+ * @param norm 标准化操作
152
+ * @param category 指标所属板块类别(需要中性化指定)
153
+ * @param style_inds 指标风格列表
154
+ */
155
+ void addSpecialNormalize(const string& name, NormalizePtr norm, const string& category = "",
156
+ const IndicatorList& style_inds = IndicatorList());
157
+
137
158
  void reset();
138
159
 
139
160
  typedef std::shared_ptr<MultiFactorBase> MultiFactorPtr;
@@ -154,7 +175,9 @@ private:
154
175
 
155
176
  void initParam();
156
177
 
157
- protected:
178
+ // 构造每个指标构造行业哑变量,以便进行行业中性化处理
179
+ unordered_map<string, PriceList> _buildDummyIndex();
180
+
158
181
  void _buildIndex(); // 计算完成后创建截面索引
159
182
  void _buildIndexDesc(); // 创建降序排列的索引
160
183
  void _buildIndexAsc(); // 创建升序排列的索引
@@ -178,6 +201,12 @@ protected:
178
201
  vector<ScoreRecordList> m_stk_factor_by_date;
179
202
  Indicator m_ic;
180
203
 
204
+ NormPtr m_norm; // 全局标准化/归一化操作
205
+ unordered_map<string, NormPtr> m_special_norms; // 对特定指标执行特定的标准化操作
206
+ unordered_map<string, string> m_special_category; // 对特定指标执行行业中性化时指定的板块分类
207
+ unordered_map<string, IndicatorList>
208
+ m_special_style_inds; // 对特定指标执行风格因子中性化时指定的风格因子
209
+
181
210
  private:
182
211
  std::mutex m_mutex;
183
212
  bool m_calculated{false};
@@ -197,6 +226,8 @@ private:
197
226
  ar& BOOST_SERIALIZATION_NVP(m_ref_stk);
198
227
  ar& BOOST_SERIALIZATION_NVP(m_query);
199
228
  ar& BOOST_SERIALIZATION_NVP(m_ref_dates);
229
+ ar& BOOST_SERIALIZATION_NVP(m_special_norms);
230
+ ar& BOOST_SERIALIZATION_NVP(m_special_category);
200
231
  // 以下不需要保存,加载后重新计算
201
232
  // ar& BOOST_SERIALIZATION_NVP(m_stk_map);
202
233
  // ar& BOOST_SERIALIZATION_NVP(m_all_factors);
@@ -215,6 +246,8 @@ private:
215
246
  ar& BOOST_SERIALIZATION_NVP(m_ref_stk);
216
247
  ar& BOOST_SERIALIZATION_NVP(m_query);
217
248
  ar& BOOST_SERIALIZATION_NVP(m_ref_dates);
249
+ ar& BOOST_SERIALIZATION_NVP(m_special_norms);
250
+ ar& BOOST_SERIALIZATION_NVP(m_special_category);
218
251
  // ar& BOOST_SERIALIZATION_NVP(m_stk_map);
219
252
  // ar& BOOST_SERIALIZATION_NVP(m_all_factors);
220
253
  // ar& BOOST_SERIALIZATION_NVP(m_date_index);
@@ -0,0 +1,125 @@
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 "hikyuu/utilities/Parameter.h"
11
+
12
+ namespace hku {
13
+
14
+ /**
15
+ * 时间截面数据归一化基类
16
+ */
17
+ class HKU_API NormalizeBase {
18
+ PARAMETER_SUPPORT_WITH_CHECK
19
+
20
+ public:
21
+ NormalizeBase() = default;
22
+ NormalizeBase(const string& name) : m_name(name) {}
23
+
24
+ NormalizeBase(const NormalizeBase& other) : m_params(other.m_params), m_name(other.m_name) {}
25
+
26
+ virtual ~NormalizeBase() = default;
27
+
28
+ /** 获取名称 */
29
+ const string& name() const {
30
+ return m_name;
31
+ }
32
+
33
+ /** 设置名称 */
34
+ void name(const string& name) {
35
+ m_name = name;
36
+ }
37
+
38
+ typedef std::shared_ptr<NormalizeBase> NormPtr;
39
+ NormPtr clone();
40
+
41
+ virtual NormPtr _clone() = 0;
42
+
43
+ virtual PriceList normalize(const PriceList& data) = 0;
44
+
45
+ protected:
46
+ virtual bool isPythonObject() const {
47
+ return false;
48
+ }
49
+
50
+ protected:
51
+ string m_name;
52
+
53
+ //============================================
54
+ // 序列化支持
55
+ //============================================
56
+ #if HKU_SUPPORT_SERIALIZATION
57
+ private:
58
+ friend class boost::serialization::access;
59
+ template <class Archive>
60
+ void save(Archive& ar, const unsigned int version) const {
61
+ ar& BOOST_SERIALIZATION_NVP(m_name);
62
+ ar& BOOST_SERIALIZATION_NVP(m_params);
63
+ }
64
+
65
+ template <class Archive>
66
+ void load(Archive& ar, const unsigned int version) {
67
+ ar& BOOST_SERIALIZATION_NVP(m_name);
68
+ ar& BOOST_SERIALIZATION_NVP(m_params);
69
+ }
70
+
71
+ BOOST_SERIALIZATION_SPLIT_MEMBER()
72
+ #endif /* HKU_SUPPORT_SERIALIZATION */
73
+ };
74
+
75
+ #if HKU_SUPPORT_SERIALIZATION
76
+ BOOST_SERIALIZATION_ASSUME_ABSTRACT(MultiFactorBase)
77
+ #endif
78
+
79
+ #if HKU_SUPPORT_SERIALIZATION
80
+ /**
81
+ * 对于没有私有变量的继承子类,可直接使用该宏定义序列化
82
+ * @code
83
+ * class Drived: public NormalizeBase {
84
+ * NORMALIZE_NO_PRIVATE_MEMBER_SERIALIZATION
85
+ *
86
+ * public:
87
+ * Drived();
88
+ * ...
89
+ * };
90
+ * @endcode
91
+ * @ingroup MultiFactor
92
+ */
93
+ #define NORMALIZE_NO_PRIVATE_MEMBER_SERIALIZATION \
94
+ private: \
95
+ friend class boost::serialization::access; \
96
+ template <class Archive> \
97
+ void serialize(Archive& ar, const unsigned int version) { \
98
+ ar& BOOST_SERIALIZATION_BASE_OBJECT_NVP(NormalizeBase); \
99
+ }
100
+ #else
101
+ #define NORMALIZE_NO_PRIVATE_MEMBER_SERIALIZATION
102
+ #endif
103
+
104
+ typedef std::shared_ptr<NormalizeBase> NormPtr;
105
+ typedef std::shared_ptr<NormalizeBase> NormalizePtr;
106
+
107
+ #define NORMALIZE_IMP(classname) \
108
+ public: \
109
+ virtual NormalizePtr _clone() override { \
110
+ return std::make_shared<classname>(); \
111
+ } \
112
+ PriceList normalize(const PriceList& data) override;
113
+
114
+ HKU_API std::ostream& operator<<(std::ostream&, const NormalizeBase&);
115
+ HKU_API std::ostream& operator<<(std::ostream&, const NormalizePtr&);
116
+
117
+ } // namespace hku
118
+
119
+ #if FMT_VERSION >= 90000
120
+ template <>
121
+ struct fmt::formatter<hku::NormalizeBase> : ostream_formatter {};
122
+
123
+ template <>
124
+ struct fmt::formatter<hku::NormalizePtr> : ostream_formatter {};
125
+ #endif