hikyuu 2.7.3__py3-none-manylinux2014_aarch64.whl → 2.7.6__py3-none-manylinux2014_aarch64.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 (216) hide show
  1. hikyuu/__init__.py +3 -1
  2. hikyuu/__init__.pyi +9 -8
  3. hikyuu/analysis/__init__.pyi +1 -0
  4. hikyuu/analysis/analysis.pyi +2 -1
  5. hikyuu/core.pyi +3 -2
  6. hikyuu/cpp/core310.pyi +80 -46
  7. hikyuu/cpp/core310.so +0 -0
  8. hikyuu/cpp/core311.pyi +80 -46
  9. hikyuu/cpp/core311.so +0 -0
  10. hikyuu/cpp/core312.pyi +80 -46
  11. hikyuu/cpp/core312.so +0 -0
  12. hikyuu/cpp/core313.pyi +80 -46
  13. hikyuu/cpp/core313.so +0 -0
  14. hikyuu/cpp/libhikyuu.so +0 -0
  15. hikyuu/cpp/libmimalloc.so +0 -0
  16. hikyuu/cpp/libmimalloc.so.3 +0 -0
  17. hikyuu/cpp/libmimalloc.so.3.1 +0 -0
  18. hikyuu/data/clickhouse_upgrade/0002.sql +9 -0
  19. hikyuu/data/common_mysql.py +1 -1
  20. hikyuu/data/em_block_to_mysql.py +16 -4
  21. hikyuu/data/em_block_to_sqlite.py +16 -4
  22. hikyuu/data/hku_config_template.py +1 -1
  23. hikyuu/data/mysql_upgrade/0030.sql +3 -0
  24. hikyuu/data/pytdx_to_h5.py +2 -2
  25. hikyuu/data/pytdx_to_mysql.py +5 -5
  26. hikyuu/data/sqlite_upgrade/0030.sql +5 -0
  27. hikyuu/draw/__init__.pyi +1 -1
  28. hikyuu/draw/drawplot/__init__.pyi +1 -1
  29. hikyuu/draw/drawplot/bokeh_draw.pyi +7 -6
  30. hikyuu/draw/drawplot/echarts_draw.pyi +7 -6
  31. hikyuu/draw/drawplot/matplotlib_draw.py +19 -11
  32. hikyuu/draw/drawplot/matplotlib_draw.pyi +7 -6
  33. hikyuu/examples/notebook/001-overview.ipynb +112 -78
  34. hikyuu/examples/notebook/004-IndicatorOverview.ipynb +52 -65
  35. hikyuu/examples/notebook/006-TradeManager.ipynb +402 -291
  36. hikyuu/examples/notebook/008-Pickle.ipynb +25 -17
  37. hikyuu/examples/notebook/009-RealData.ipynb +36 -38
  38. hikyuu/examples/notebook/Demo/Demo2.ipynb +146 -116
  39. hikyuu/extend.pyi +2 -1
  40. hikyuu/gui/data/UseTdxImportToH5Thread.py +4 -2
  41. hikyuu/gui/start_qmt.py +1 -1
  42. hikyuu/hub.pyi +6 -6
  43. hikyuu/include/hikyuu/Block.h +9 -9
  44. hikyuu/include/hikyuu/HistoryFinanceInfo.h +3 -3
  45. hikyuu/include/hikyuu/KData.h +51 -28
  46. hikyuu/include/hikyuu/KDataImp.h +12 -7
  47. hikyuu/include/hikyuu/KDataPrivatedBufferImp.h +13 -7
  48. hikyuu/include/hikyuu/KDataSharedBufferImp.h +8 -6
  49. hikyuu/include/hikyuu/KQuery.h +11 -11
  50. hikyuu/include/hikyuu/KRecord.h +1 -1
  51. hikyuu/include/hikyuu/MarketInfo.h +10 -10
  52. hikyuu/include/hikyuu/Stock.h +30 -30
  53. hikyuu/include/hikyuu/StockManager.h +11 -10
  54. hikyuu/include/hikyuu/StockTypeInfo.h +9 -9
  55. hikyuu/include/hikyuu/StockWeight.h +9 -9
  56. hikyuu/include/hikyuu/TimeLineRecord.h +1 -1
  57. hikyuu/include/hikyuu/TransRecord.h +1 -1
  58. hikyuu/include/hikyuu/data_driver/BlockInfoDriver.h +6 -0
  59. hikyuu/include/hikyuu/data_driver/KDataDriver.h +4 -3
  60. hikyuu/include/hikyuu/indicator/IndParam.h +1 -1
  61. hikyuu/include/hikyuu/indicator/Indicator.h +56 -27
  62. hikyuu/include/hikyuu/indicator/Indicator2InImp.h +0 -4
  63. hikyuu/include/hikyuu/indicator/IndicatorImp.h +146 -73
  64. hikyuu/include/hikyuu/indicator/crt/CONTEXT.h +11 -1
  65. hikyuu/include/hikyuu/indicator/crt/IC.h +19 -14
  66. hikyuu/include/hikyuu/indicator/crt/ICIR.h +4 -7
  67. hikyuu/include/hikyuu/indicator/imp/IAbs.h +1 -0
  68. hikyuu/include/hikyuu/indicator/imp/IAcos.h +1 -0
  69. hikyuu/include/hikyuu/indicator/imp/IAd.h +0 -2
  70. hikyuu/include/hikyuu/indicator/imp/IAdvance.h +3 -0
  71. hikyuu/include/hikyuu/indicator/imp/IAma.h +3 -0
  72. hikyuu/include/hikyuu/indicator/imp/IAsin.h +1 -0
  73. hikyuu/include/hikyuu/indicator/imp/IAtan.h +1 -0
  74. hikyuu/include/hikyuu/indicator/imp/IAtr.h +2 -3
  75. hikyuu/include/hikyuu/indicator/imp/IBackset.h +2 -4
  76. hikyuu/include/hikyuu/indicator/imp/IBlockSetNum.h +3 -0
  77. hikyuu/include/hikyuu/indicator/imp/ICeil.h +1 -0
  78. hikyuu/include/hikyuu/indicator/imp/IContext.h +0 -3
  79. hikyuu/include/hikyuu/indicator/imp/ICorr.h +3 -0
  80. hikyuu/include/hikyuu/indicator/imp/ICos.h +1 -0
  81. hikyuu/include/hikyuu/indicator/imp/ICost.h +0 -2
  82. hikyuu/include/hikyuu/indicator/imp/ICount.h +2 -1
  83. hikyuu/include/hikyuu/indicator/imp/ICval.h +1 -4
  84. hikyuu/include/hikyuu/indicator/imp/ICycle.h +0 -2
  85. hikyuu/include/hikyuu/indicator/imp/IDecline.h +3 -0
  86. hikyuu/include/hikyuu/indicator/imp/IDevsq.h +4 -1
  87. hikyuu/include/hikyuu/indicator/imp/IDiff.h +1 -0
  88. hikyuu/include/hikyuu/indicator/imp/IDma.h +2 -0
  89. hikyuu/include/hikyuu/indicator/imp/IDropna.h +0 -4
  90. hikyuu/include/hikyuu/indicator/imp/IEma.h +3 -1
  91. hikyuu/include/hikyuu/indicator/imp/IEvery.h +5 -1
  92. hikyuu/include/hikyuu/indicator/imp/IExist.h +5 -1
  93. hikyuu/include/hikyuu/indicator/imp/IExp.h +1 -0
  94. hikyuu/include/hikyuu/indicator/imp/IFilter.h +4 -5
  95. hikyuu/include/hikyuu/indicator/imp/IFinance.h +1 -2
  96. hikyuu/include/hikyuu/indicator/imp/IFloor.h +1 -0
  97. hikyuu/include/hikyuu/indicator/imp/IHhvbars.h +5 -1
  98. hikyuu/include/hikyuu/indicator/imp/IHighLine.h +5 -1
  99. hikyuu/include/hikyuu/indicator/imp/IHsl.h +0 -2
  100. hikyuu/include/hikyuu/indicator/imp/IIc.h +3 -6
  101. hikyuu/include/hikyuu/indicator/imp/IInBlock.h +1 -2
  102. hikyuu/include/hikyuu/indicator/imp/IIntpart.h +1 -0
  103. hikyuu/include/hikyuu/indicator/imp/IIsInf.h +1 -0
  104. hikyuu/include/hikyuu/indicator/imp/IIsInfa.h +1 -0
  105. hikyuu/include/hikyuu/indicator/imp/IIsLastBar.h +0 -1
  106. hikyuu/include/hikyuu/indicator/imp/IIsNa.h +1 -0
  107. hikyuu/include/hikyuu/indicator/imp/IJumpDown.h +1 -0
  108. hikyuu/include/hikyuu/indicator/imp/IJumpUp.h +1 -0
  109. hikyuu/include/hikyuu/indicator/imp/IKData.h +1 -2
  110. hikyuu/include/hikyuu/indicator/imp/ILiuTongPan.h +0 -2
  111. hikyuu/include/hikyuu/indicator/imp/ILn.h +1 -0
  112. hikyuu/include/hikyuu/indicator/imp/ILog.h +1 -0
  113. hikyuu/include/hikyuu/indicator/imp/ILowLine.h +5 -1
  114. hikyuu/include/hikyuu/indicator/imp/ILowLineBars.h +5 -1
  115. hikyuu/include/hikyuu/indicator/imp/IMa.h +6 -1
  116. hikyuu/include/hikyuu/indicator/imp/IMacd.h +2 -0
  117. hikyuu/include/hikyuu/indicator/imp/INot.h +1 -0
  118. hikyuu/include/hikyuu/indicator/imp/IPow.h +3 -1
  119. hikyuu/include/hikyuu/indicator/imp/IQuantileTrunc.h +1 -0
  120. hikyuu/include/hikyuu/indicator/imp/IRecover.h +3 -0
  121. hikyuu/include/hikyuu/indicator/imp/IRef.h +3 -1
  122. hikyuu/include/hikyuu/indicator/imp/IResult.h +1 -0
  123. hikyuu/include/hikyuu/indicator/imp/IReverse.h +1 -0
  124. hikyuu/include/hikyuu/indicator/imp/IRoc.h +6 -1
  125. hikyuu/include/hikyuu/indicator/imp/IRocp.h +5 -1
  126. hikyuu/include/hikyuu/indicator/imp/IRocr.h +5 -1
  127. hikyuu/include/hikyuu/indicator/imp/IRocr100.h +5 -1
  128. hikyuu/include/hikyuu/indicator/imp/IRound.h +1 -0
  129. hikyuu/include/hikyuu/indicator/imp/IRoundDown.h +1 -0
  130. hikyuu/include/hikyuu/indicator/imp/IRoundUp.h +1 -0
  131. hikyuu/include/hikyuu/indicator/imp/ISaftyLoss.h +1 -0
  132. hikyuu/include/hikyuu/indicator/imp/ISign.h +1 -0
  133. hikyuu/include/hikyuu/indicator/imp/ISin.h +1 -0
  134. hikyuu/include/hikyuu/indicator/imp/ISlope.h +5 -1
  135. hikyuu/include/hikyuu/indicator/imp/ISma.h +2 -0
  136. hikyuu/include/hikyuu/indicator/imp/ISpearman.h +3 -0
  137. hikyuu/include/hikyuu/indicator/imp/ISqrt.h +1 -0
  138. hikyuu/include/hikyuu/indicator/imp/IStdev.h +5 -1
  139. hikyuu/include/hikyuu/indicator/imp/IStdp.h +5 -1
  140. hikyuu/include/hikyuu/indicator/imp/ISum.h +6 -1
  141. hikyuu/include/hikyuu/indicator/imp/ITan.h +1 -0
  142. hikyuu/include/hikyuu/indicator/imp/ITime.h +1 -2
  143. hikyuu/include/hikyuu/indicator/imp/ITimeLine.h +0 -2
  144. hikyuu/include/hikyuu/indicator/imp/ITr.h +1 -2
  145. hikyuu/include/hikyuu/indicator/imp/IVar.h +5 -1
  146. hikyuu/include/hikyuu/indicator/imp/IVarp.h +5 -1
  147. hikyuu/include/hikyuu/indicator/imp/IVigor.h +0 -2
  148. hikyuu/include/hikyuu/indicator/imp/IWma.h +5 -1
  149. hikyuu/include/hikyuu/indicator/imp/IZongGuBen.h +1 -2
  150. hikyuu/include/hikyuu/indicator_talib/imp/TaAdosc.h +0 -2
  151. hikyuu/include/hikyuu/indicator_talib/imp/TaSar.h +0 -2
  152. hikyuu/include/hikyuu/indicator_talib/imp/TaSarext.h +0 -4
  153. hikyuu/include/hikyuu/indicator_talib/imp/TaStoch.h +0 -3
  154. hikyuu/include/hikyuu/indicator_talib/imp/TaStochf.h +0 -2
  155. hikyuu/include/hikyuu/indicator_talib/imp/TaUltosc.h +0 -2
  156. hikyuu/include/hikyuu/indicator_talib/imp/ta_defines.h +2 -4
  157. hikyuu/include/hikyuu/indicator_talib/imp/ta_imp.h +70 -90
  158. hikyuu/include/hikyuu/plugin/hkuextra.h +2 -0
  159. hikyuu/include/hikyuu/plugin/interface/HkuExtraPluginInterface.h +2 -0
  160. hikyuu/include/hikyuu/python/pybind_utils.h +22 -5
  161. hikyuu/include/hikyuu/trade_manage/TradeCostBase.h +5 -3
  162. hikyuu/include/hikyuu/trade_manage/TradeManagerBase.h +9 -2
  163. hikyuu/include/hikyuu/trade_sys/allocatefunds/AllocateFundsBase.h +8 -3
  164. hikyuu/include/hikyuu/trade_sys/condition/ConditionBase.h +5 -2
  165. hikyuu/include/hikyuu/trade_sys/environment/EnvironmentBase.h +6 -2
  166. hikyuu/include/hikyuu/trade_sys/moneymanager/MoneyManagerBase.h +5 -2
  167. hikyuu/include/hikyuu/trade_sys/multifactor/MultiFactorBase.h +23 -19
  168. hikyuu/include/hikyuu/trade_sys/multifactor/NormalizeBase.h +6 -3
  169. hikyuu/include/hikyuu/trade_sys/multifactor/ScoresFilterBase.h +5 -2
  170. hikyuu/include/hikyuu/trade_sys/multifactor/crt/MF_EqualWeight.h +3 -3
  171. hikyuu/include/hikyuu/trade_sys/multifactor/crt/MF_ICIRWeight.h +4 -4
  172. hikyuu/include/hikyuu/trade_sys/multifactor/crt/MF_ICWeight.h +4 -4
  173. hikyuu/include/hikyuu/trade_sys/multifactor/crt/MF_Weight.h +4 -4
  174. hikyuu/include/hikyuu/trade_sys/portfolio/Portfolio.h +5 -2
  175. hikyuu/include/hikyuu/trade_sys/profitgoal/ProfitGoalBase.h +4 -2
  176. hikyuu/include/hikyuu/trade_sys/selector/SelectorBase.h +12 -2
  177. hikyuu/include/hikyuu/trade_sys/selector/crt/SE_MultiFactor.h +1 -1
  178. hikyuu/include/hikyuu/trade_sys/selector/crt/SE_MultiFactor2.h +1 -1
  179. hikyuu/include/hikyuu/trade_sys/selector/imp/MultiFactorSelector.h +1 -0
  180. hikyuu/include/hikyuu/trade_sys/selector/imp/MultiFactorSelector2.h +1 -0
  181. hikyuu/include/hikyuu/trade_sys/selector/imp/optimal/OptimalSelectorBase.h +0 -2
  182. hikyuu/include/hikyuu/trade_sys/selector/imp/optimal/PerformanceOptimalSelector.h +0 -4
  183. hikyuu/include/hikyuu/trade_sys/signal/SignalBase.h +5 -2
  184. hikyuu/include/hikyuu/trade_sys/slippage/SlippageBase.h +5 -2
  185. hikyuu/include/hikyuu/trade_sys/stoploss/StoplossBase.h +5 -2
  186. hikyuu/include/hikyuu/trade_sys/system/System.h +5 -2
  187. hikyuu/include/hikyuu/utilities/LruCache.h +299 -0
  188. hikyuu/include/hikyuu/utilities/arithmetic.h +2 -2
  189. hikyuu/include/hikyuu/utilities/omp_macro.h +25 -0
  190. hikyuu/include/hikyuu/utilities/plugin/PluginManager.h +5 -0
  191. hikyuu/include/hikyuu/utilities/thread/GlobalStealThreadPool.h +72 -19
  192. hikyuu/include/hikyuu/utilities/thread/GlobalThreadPool.h +0 -4
  193. hikyuu/include/hikyuu/utilities/thread/ThreadPool.h +0 -4
  194. hikyuu/include/hikyuu/utilities/thread/algorithm.h +286 -0
  195. hikyuu/include/hikyuu/version.h +4 -4
  196. hikyuu/plugin/libbacktest.so +0 -0
  197. hikyuu/plugin/libcheckdata.so +0 -0
  198. hikyuu/plugin/libclickhousedriver.so +0 -0
  199. hikyuu/plugin/libdataserver.so +0 -0
  200. hikyuu/plugin/libdataserver_parquet.so +0 -0
  201. hikyuu/plugin/libdevice.so +0 -0
  202. hikyuu/plugin/libextind.so +0 -0
  203. hikyuu/plugin/libhkuextra.so +0 -0
  204. hikyuu/plugin/libimport2ch.so +0 -0
  205. hikyuu/plugin/libimport2hdf5.so +0 -0
  206. hikyuu/plugin/libimport2mysql.so +0 -0
  207. hikyuu/plugin/libtmreport.so +0 -0
  208. hikyuu/test/Indicator.py +1 -2
  209. hikyuu/trade_manage/__init__.pyi +7 -6
  210. hikyuu/trade_manage/trade.pyi +7 -6
  211. hikyuu/util/singleton.pyi +1 -1
  212. {hikyuu-2.7.3.dist-info → hikyuu-2.7.6.dist-info}/METADATA +1 -1
  213. {hikyuu-2.7.3.dist-info → hikyuu-2.7.6.dist-info}/RECORD +216 -208
  214. {hikyuu-2.7.3.dist-info → hikyuu-2.7.6.dist-info}/WHEEL +0 -0
  215. {hikyuu-2.7.3.dist-info → hikyuu-2.7.6.dist-info}/entry_points.txt +0 -0
  216. {hikyuu-2.7.3.dist-info → hikyuu-2.7.6.dist-info}/top_level.txt +0 -0
@@ -13,12 +13,10 @@ namespace hku {
13
13
 
14
14
  class TaStochf : public IndicatorImp {
15
15
  INDICATOR_IMP(TaStochf)
16
- INDICATOR_NEED_CONTEXT
17
16
  INDICATOR_IMP_NO_PRIVATE_MEMBER_SERIALIZATION
18
17
 
19
18
  public:
20
19
  TaStochf();
21
- explicit TaStochf(const KData&, int fastk_n, int fastd_n, int fastd_matype);
22
20
  virtual ~TaStochf() = default;
23
21
  virtual void _checkParam(const string& name) const override;
24
22
  };
@@ -13,12 +13,10 @@ namespace hku {
13
13
 
14
14
  class TaUltosc : public IndicatorImp {
15
15
  INDICATOR_IMP(TaUltosc)
16
- INDICATOR_NEED_CONTEXT
17
16
  INDICATOR_IMP_NO_PRIVATE_MEMBER_SERIALIZATION
18
17
 
19
18
  public:
20
19
  TaUltosc();
21
- explicit TaUltosc(const KData&, int n1, int n2, int n3);
22
20
  virtual ~TaUltosc() = default;
23
21
  virtual void _checkParam(const string& name) const override;
24
22
  };
@@ -22,7 +22,8 @@
22
22
 
23
23
  #define TA_IN1_OUT_DYN_DEF(func) \
24
24
  class Cls_##func : public IndicatorImp { \
25
- INDICATOR_IMP_SUPPORT_DYNAMIC_STEP(Cls_##func) \
25
+ INDICATOR_IMP(Cls_##func) \
26
+ INDICATOR_IMP_SUPPORT_DYNAMIC_CYCLE \
26
27
  INDICATOR_IMP_NO_PRIVATE_MEMBER_SERIALIZATION \
27
28
  \
28
29
  public: \
@@ -56,7 +57,6 @@
56
57
  #define TA_K_OUT_DEF(func) \
57
58
  class Cls_##func : public IndicatorImp { \
58
59
  INDICATOR_IMP(Cls_##func) \
59
- INDICATOR_NEED_CONTEXT \
60
60
  INDICATOR_IMP_NO_PRIVATE_MEMBER_SERIALIZATION \
61
61
  public: \
62
62
  Cls_##func(); \
@@ -67,7 +67,6 @@
67
67
  #define TA_K_OUT_N_DEF(func) \
68
68
  class Cls_##func : public IndicatorImp { \
69
69
  INDICATOR_IMP(Cls_##func) \
70
- INDICATOR_NEED_CONTEXT \
71
70
  INDICATOR_IMP_NO_PRIVATE_MEMBER_SERIALIZATION \
72
71
  public: \
73
72
  Cls_##func(); \
@@ -79,7 +78,6 @@
79
78
  #define TA_K_OUT_P_D_DEF(func) \
80
79
  class Cls_##func : public IndicatorImp { \
81
80
  INDICATOR_IMP(Cls_##func) \
82
- INDICATOR_NEED_CONTEXT \
83
81
  INDICATOR_IMP_NO_PRIVATE_MEMBER_SERIALIZATION \
84
82
  public: \
85
83
  Cls_##func(); \
@@ -113,7 +113,7 @@
113
113
  \
114
114
  void Cls_##func::_dyn_run_one_step(const Indicator &ind, size_t curPos, size_t step) { \
115
115
  int back = func_lookback(step); \
116
- HKU_IF_RETURN(back<0 || back + ind.discard()> curPos, void()); \
116
+ HKU_IF_RETURN(back < 0 || back + ind.discard() > curPos, void()); \
117
117
  \
118
118
  std::unique_ptr<double[]> buf = std::make_unique<double[]>(curPos); \
119
119
  auto const *src = ind.data(); \
@@ -181,7 +181,7 @@
181
181
  \
182
182
  void Cls_##func::_dyn_run_one_step(const Indicator &ind, size_t curPos, size_t step) { \
183
183
  int back = func_lookback(step); \
184
- HKU_IF_RETURN(back<0 || back + ind.discard()> curPos, void()); \
184
+ HKU_IF_RETURN(back < 0 || back + ind.discard() > curPos, void()); \
185
185
  \
186
186
  std::unique_ptr<int[]> buf = std::make_unique<int[]>(curPos); \
187
187
  auto const *src = ind.data(); \
@@ -283,7 +283,7 @@
283
283
  \
284
284
  void Cls_##func::_dyn_run_one_step(const Indicator &ind, size_t curPos, size_t step) { \
285
285
  int back = func_lookback(step); \
286
- HKU_IF_RETURN(back<0 || back + ind.discard()> curPos, void()); \
286
+ HKU_IF_RETURN(back < 0 || back + ind.discard() > curPos, void()); \
287
287
  \
288
288
  std::unique_ptr<int[]> buf = std::make_unique<int[]>(2 * curPos); \
289
289
  int *buf0 = buf.get(); \
@@ -350,7 +350,7 @@
350
350
  \
351
351
  void Cls_##func::_dyn_run_one_step(const Indicator &ind, size_t curPos, size_t step) { \
352
352
  int back = func_lookback(step); \
353
- HKU_IF_RETURN(back<0 || back + ind.discard()> curPos, void()); \
353
+ HKU_IF_RETURN(back < 0 || back + ind.discard() > curPos, void()); \
354
354
  \
355
355
  std::unique_ptr<double[]> buf = std::make_unique<double[]>(2 * curPos); \
356
356
  double *dst0 = buf.get(); \
@@ -418,7 +418,7 @@
418
418
  \
419
419
  void Cls_##func::_dyn_run_one_step(const Indicator &ind, size_t curPos, size_t step) { \
420
420
  int back = func_lookback(step); \
421
- HKU_IF_RETURN(back<0 || back + ind.discard()> curPos, void()); \
421
+ HKU_IF_RETURN(back < 0 || back + ind.discard() > curPos, void()); \
422
422
  \
423
423
  std::unique_ptr<double[]> buf = std::make_unique<double[]>(3 * curPos); \
424
424
  double *dst0 = buf.get(); \
@@ -558,11 +558,8 @@
558
558
  }
559
559
 
560
560
  #define TA_OHLC_OUT1_IMP(func, func_lookback) \
561
- Cls_##func::Cls_##func() : IndicatorImp(#func, 1) {} \
562
- \
563
- Cls_##func::Cls_##func(const KData &k) : IndicatorImp(#func, 1) { \
564
- setParam<KData>("kdata", k); \
565
- Cls_##func::_calculate(Indicator()); \
561
+ Cls_##func::Cls_##func() : IndicatorImp(#func, 1) { \
562
+ m_need_context = true; \
566
563
  } \
567
564
  \
568
565
  void Cls_##func::_calculate(const Indicator &data) { \
@@ -607,15 +604,14 @@
607
604
  } \
608
605
  \
609
606
  Indicator HKU_API func(const KData &k) { \
610
- return Indicator(make_shared<Cls_##func>(k)); \
607
+ auto p = make_shared<Cls_##func>(); \
608
+ p->setContext(k); \
609
+ return Indicator(p); \
611
610
  }
612
611
 
613
612
  #define TA_OHLC_OUT1_INT_IMP(func, func_lookback) \
614
- Cls_##func::Cls_##func() : IndicatorImp(#func, 1) {} \
615
- \
616
- Cls_##func::Cls_##func(const KData &k) : IndicatorImp(#func, 1) { \
617
- setParam<KData>("kdata", k); \
618
- Cls_##func::_calculate(Indicator()); \
613
+ Cls_##func::Cls_##func() : IndicatorImp(#func, 1) { \
614
+ m_need_context = true; \
619
615
  } \
620
616
  \
621
617
  void Cls_##func::_calculate(const Indicator &data) { \
@@ -665,21 +661,18 @@
665
661
  } \
666
662
  \
667
663
  Indicator HKU_API func(const KData &k) { \
668
- return Indicator(make_shared<Cls_##func>(k)); \
664
+ auto p = make_shared<Cls_##func>(); \
665
+ p->setContext(k); \
666
+ return Indicator(p); \
669
667
  }
670
668
 
671
669
  #define TA_OHLC_OUT1_INT_P1_D_IMP(func, func_lookback, param1, param1_value, param1_min, \
672
670
  param1_max) \
673
671
  Cls_##func::Cls_##func() : IndicatorImp(#func, 1) { \
672
+ m_need_context = true; \
674
673
  setParam<double>(#param1, param1_value); \
675
674
  } \
676
675
  \
677
- Cls_##func::Cls_##func(const KData &k, double p) : IndicatorImp(#func, 1) { \
678
- setParam<KData>("kdata", k); \
679
- setParam<double>(#param1, p); \
680
- Cls_##func::_calculate(Indicator()); \
681
- } \
682
- \
683
676
  void Cls_##func::_checkParam(const string &name) const { \
684
677
  if (name == #param1) { \
685
678
  double p = getParam<double>(#param1); \
@@ -737,15 +730,15 @@
737
730
  } \
738
731
  \
739
732
  Indicator HKU_API func(const KData &k, double p) { \
740
- return Indicator(make_shared<Cls_##func>(k, p)); \
733
+ auto ptr = make_shared<Cls_##func>(); \
734
+ ptr->setParam<double>(#param1, p); \
735
+ ptr->setContext(k); \
736
+ return Indicator(ptr); \
741
737
  }
742
738
 
743
739
  #define TA_HLCV_OUT1_IMP(func, func_lookback) \
744
- Cls_##func::Cls_##func() : IndicatorImp(#func, 1) {} \
745
- \
746
- Cls_##func::Cls_##func(const KData &k) : IndicatorImp(#func, 1) { \
747
- setParam<KData>("kdata", k); \
748
- Cls_##func::_calculate(Indicator()); \
740
+ Cls_##func::Cls_##func() : IndicatorImp(#func, 1) { \
741
+ m_need_context = true; \
749
742
  } \
750
743
  \
751
744
  void Cls_##func::_calculate(const Indicator &data) { \
@@ -790,15 +783,14 @@
790
783
  } \
791
784
  \
792
785
  Indicator HKU_API func(const KData &k) { \
793
- return Indicator(make_shared<Cls_##func>(k)); \
786
+ auto ptr = make_shared<Cls_##func>(); \
787
+ ptr->setContext(k); \
788
+ return Indicator(ptr); \
794
789
  }
795
790
 
796
791
  #define TA_HL_OUT1_IMP(func, func_lookback) \
797
- Cls_##func::Cls_##func() : IndicatorImp(#func, 1) {} \
798
- \
799
- Cls_##func::Cls_##func(const KData &k) : IndicatorImp(#func, 1) { \
800
- setParam<KData>("kdata", k); \
801
- Cls_##func::_calculate(Indicator()); \
792
+ Cls_##func::Cls_##func() : IndicatorImp(#func, 1) { \
793
+ m_need_context = true; \
802
794
  } \
803
795
  \
804
796
  void Cls_##func::_calculate(const Indicator &data) { \
@@ -838,15 +830,14 @@
838
830
  } \
839
831
  \
840
832
  Indicator HKU_API func(const KData &k) { \
841
- return Indicator(make_shared<Cls_##func>(k)); \
833
+ auto ptr = make_shared<Cls_##func>(); \
834
+ ptr->setContext(k); \
835
+ return Indicator(ptr); \
842
836
  }
843
837
 
844
838
  #define TA_CV_OUT1_IMP(func, func_lookback) \
845
- Cls_##func::Cls_##func() : IndicatorImp(#func, 1) {} \
846
- \
847
- Cls_##func::Cls_##func(const KData &k) : IndicatorImp(#func, 1) { \
848
- setParam<KData>("kdata", k); \
849
- Cls_##func::_calculate(Indicator()); \
839
+ Cls_##func::Cls_##func() : IndicatorImp(#func, 1) { \
840
+ m_need_context = true; \
850
841
  } \
851
842
  \
852
843
  void Cls_##func::_calculate(const Indicator &data) { \
@@ -886,15 +877,14 @@
886
877
  } \
887
878
  \
888
879
  Indicator HKU_API func(const KData &k) { \
889
- return Indicator(make_shared<Cls_##func>(k)); \
880
+ auto ptr = make_shared<Cls_##func>(); \
881
+ ptr->setContext(k); \
882
+ return Indicator(ptr); \
890
883
  }
891
884
 
892
885
  #define TA_HLC_OUT1_IMP(func, func_lookback) \
893
- Cls_##func::Cls_##func() : IndicatorImp(#func, 1) {} \
894
- \
895
- Cls_##func::Cls_##func(const KData &k) : IndicatorImp(#func, 1) { \
896
- setParam<KData>("kdata", k); \
897
- Cls_##func::_calculate(Indicator()); \
886
+ Cls_##func::Cls_##func() : IndicatorImp(#func, 1) { \
887
+ m_need_context = true; \
898
888
  } \
899
889
  \
900
890
  void Cls_##func::_calculate(const Indicator &data) { \
@@ -936,20 +926,17 @@
936
926
  } \
937
927
  \
938
928
  Indicator HKU_API func(const KData &k) { \
939
- return Indicator(make_shared<Cls_##func>(k)); \
929
+ auto ptr = make_shared<Cls_##func>(); \
930
+ ptr->setContext(k); \
931
+ return Indicator(ptr); \
940
932
  }
941
933
 
942
934
  #define TA_HLC_OUT1_N_IMP(func, func_lookback, period, period_min, period_max) \
943
935
  Cls_##func::Cls_##func() : IndicatorImp(#func, 1) { \
936
+ m_need_context = true; \
944
937
  setParam<int>("n", period); \
945
938
  } \
946
939
  \
947
- Cls_##func::Cls_##func(const KData &k, int n) : IndicatorImp(#func, 1) { \
948
- setParam<KData>("kdata", k); \
949
- setParam<int>("n", n); \
950
- Cls_##func::_calculate(Indicator()); \
951
- } \
952
- \
953
940
  void Cls_##func::_checkParam(const string &name) const { \
954
941
  if (name == "n") { \
955
942
  int n = getParam<int>("n"); \
@@ -1001,20 +988,18 @@
1001
988
  } \
1002
989
  \
1003
990
  Indicator HKU_API func(const KData &k, int n) { \
1004
- return Indicator(make_shared<Cls_##func>(k, n)); \
991
+ auto p = make_shared<Cls_##func>(); \
992
+ p->setParam<int>("n", n); \
993
+ p->setContext(k); \
994
+ return Indicator(p); \
1005
995
  }
1006
996
 
1007
997
  #define TA_HLCV_OUT1_N_IMP(func, func_lookback, period, period_min, period_max) \
1008
998
  Cls_##func::Cls_##func() : IndicatorImp(#func, 1) { \
999
+ m_need_context = true; \
1009
1000
  setParam<int>("n", period); \
1010
1001
  } \
1011
1002
  \
1012
- Cls_##func::Cls_##func(const KData &k, int n) : IndicatorImp(#func, 1) { \
1013
- setParam<KData>("kdata", k); \
1014
- setParam<int>("n", n); \
1015
- Cls_##func::_calculate(Indicator()); \
1016
- } \
1017
- \
1018
1003
  void Cls_##func::_checkParam(const string &name) const { \
1019
1004
  if (name == "n") { \
1020
1005
  int n = getParam<int>("n"); \
@@ -1069,20 +1054,18 @@
1069
1054
  } \
1070
1055
  \
1071
1056
  Indicator HKU_API func(const KData &k, int n) { \
1072
- return Indicator(make_shared<Cls_##func>(k, n)); \
1057
+ auto p = make_shared<Cls_##func>(); \
1058
+ p->setParam<int>("n", n); \
1059
+ p->setContext(k); \
1060
+ return Indicator(p); \
1073
1061
  }
1074
1062
 
1075
1063
  #define TA_HL_OUT1_N_IMP(func, func_lookback, period, period_min, period_max) \
1076
1064
  Cls_##func::Cls_##func() : IndicatorImp(#func, 1) { \
1065
+ m_need_context = true; \
1077
1066
  setParam<int>("n", period); \
1078
1067
  } \
1079
1068
  \
1080
- Cls_##func::Cls_##func(const KData &k, int n) : IndicatorImp(#func, 1) { \
1081
- setParam<KData>("kdata", k); \
1082
- setParam<int>("n", n); \
1083
- Cls_##func::_calculate(Indicator()); \
1084
- } \
1085
- \
1086
1069
  void Cls_##func::_checkParam(const string &name) const { \
1087
1070
  if (name == "n") { \
1088
1071
  int n = getParam<int>("n"); \
@@ -1131,20 +1114,18 @@
1131
1114
  } \
1132
1115
  \
1133
1116
  Indicator HKU_API func(const KData &k, int n) { \
1134
- return Indicator(make_shared<Cls_##func>(k, n)); \
1117
+ auto p = make_shared<Cls_##func>(); \
1118
+ p->setParam<int>("n", n); \
1119
+ p->setContext(k); \
1120
+ return Indicator(p); \
1135
1121
  }
1136
1122
 
1137
1123
  #define TA_HL_OUT2_N_IMP(func, func_lookback, period, period_min, period_max) \
1138
1124
  Cls_##func::Cls_##func() : IndicatorImp(#func, 2) { \
1125
+ m_need_context = true; \
1139
1126
  setParam<int>("n", period); \
1140
1127
  } \
1141
1128
  \
1142
- Cls_##func::Cls_##func(const KData &k, int n) : IndicatorImp(#func, 2) { \
1143
- setParam<KData>("kdata", k); \
1144
- setParam<int>("n", n); \
1145
- Cls_##func::_calculate(Indicator()); \
1146
- } \
1147
- \
1148
1129
  void Cls_##func::_checkParam(const string &name) const { \
1149
1130
  if (name == "n") { \
1150
1131
  int n = getParam<int>("n"); \
@@ -1195,20 +1176,18 @@
1195
1176
  } \
1196
1177
  \
1197
1178
  Indicator HKU_API func(const KData &k, int n) { \
1198
- return Indicator(make_shared<Cls_##func>(k, n)); \
1179
+ auto p = make_shared<Cls_##func>(); \
1180
+ p->setParam<int>("n", n); \
1181
+ p->setContext(k); \
1182
+ return Indicator(p); \
1199
1183
  }
1200
1184
 
1201
1185
  #define TA_HLC_OUT3_N_IMP(func, func_lookback, period, period_min, period_max) \
1202
1186
  Cls_##func::Cls_##func() : IndicatorImp(#func, 3) { \
1187
+ m_need_context = true; \
1203
1188
  setParam<int>("n", period); \
1204
1189
  } \
1205
1190
  \
1206
- Cls_##func::Cls_##func(const KData &k, int n) : IndicatorImp(#func, 3) { \
1207
- setParam<KData>("kdata", k); \
1208
- setParam<int>("n", n); \
1209
- Cls_##func::_calculate(Indicator()); \
1210
- } \
1211
- \
1212
1191
  void Cls_##func::_checkParam(const string &name) const { \
1213
1192
  if (name == "n") { \
1214
1193
  int n = getParam<int>("n"); \
@@ -1262,20 +1241,18 @@
1262
1241
  } \
1263
1242
  \
1264
1243
  Indicator HKU_API func(const KData &k, int n) { \
1265
- return Indicator(make_shared<Cls_##func>(k, n)); \
1244
+ auto p = make_shared<Cls_##func>(); \
1245
+ p->setParam<int>("n", n); \
1246
+ p->setContext(k); \
1247
+ return Indicator(p); \
1266
1248
  }
1267
1249
 
1268
1250
  #define TA_OC_OUT1_N_IMP(func, func_lookback, period, period_min, period_max) \
1269
1251
  Cls_##func::Cls_##func() : IndicatorImp(#func, 1) { \
1252
+ m_need_context = true; \
1270
1253
  setParam<int>("n", period); \
1271
1254
  } \
1272
1255
  \
1273
- Cls_##func::Cls_##func(const KData &k, int n) : IndicatorImp(#func, 1) { \
1274
- setParam<KData>("kdata", k); \
1275
- setParam<int>("n", n); \
1276
- Cls_##func::_calculate(Indicator()); \
1277
- } \
1278
- \
1279
1256
  void Cls_##func::_checkParam(const string &name) const { \
1280
1257
  if (name == "n") { \
1281
1258
  int n = getParam<int>("n"); \
@@ -1324,5 +1301,8 @@
1324
1301
  } \
1325
1302
  \
1326
1303
  Indicator HKU_API func(const KData &k, int n) { \
1327
- return Indicator(make_shared<Cls_##func>(k, n)); \
1304
+ auto p = make_shared<Cls_##func>(); \
1305
+ p->setParam<int>("n", n); \
1306
+ p->setContext(k); \
1307
+ return Indicator(p); \
1328
1308
  }
@@ -37,6 +37,8 @@ void HKU_API registerExtraKType(const string& ktype, const string& basetype, int
37
37
  */
38
38
  void HKU_API releaseExtraKType();
39
39
 
40
+ void HKU_API enableKDataCache(bool enable);
41
+
40
42
  //-------------------------------
41
43
  // 以下函数为内部使用,无需引出
42
44
  //-------------------------------
@@ -37,6 +37,8 @@ public:
37
37
  virtual KDataImpPtr getKDataImp(const Stock& stk, const KQuery& query) = 0;
38
38
 
39
39
  virtual bool canLazyLoad(const KQuery::KType& ktype) = 0;
40
+
41
+ virtual void enableKDataCache(bool enable) = 0;
40
42
  };
41
43
 
42
44
  } // namespace hku
@@ -10,6 +10,7 @@
10
10
  #define HIKYUU_PYTHON_BIND_UTILS_H
11
11
 
12
12
  #include <hikyuu/config.h>
13
+ #include <hikyuu/Stock.h>
13
14
  #include <pybind11/pybind11.h>
14
15
 
15
16
  #include <pybind11/operators.h>
@@ -100,11 +101,6 @@ public:
100
101
  return std::shared_ptr<classname>(keep_python_state_alive, ptr); \
101
102
  } \
102
103
  return this->_clone(); \
103
- } \
104
- \
105
- public: \
106
- inline bool isPythonObject() const override { \
107
- return true; \
108
104
  }
109
105
 
110
106
  // 用于检查以 py::object 方式传递的函数参数个数是否符合预期
@@ -124,6 +120,27 @@ inline bool check_pyfunction_arg_num(const py::object& func, size_t arg_num) {
124
120
  */
125
121
  size_t utf8_to_utf32(const std::string& utf8_str, int32_t* out, size_t out_len) noexcept;
126
122
 
123
+ // 从 python 对象获取 StockList 列表
124
+ inline StockList get_stock_list_from_python(const py::object& stks) {
125
+ StockList ret;
126
+ HKU_IF_RETURN(stks.is_none(), ret);
127
+
128
+ if (py::isinstance<StockList>(stks)) {
129
+ ret = stks.cast<StockList>();
130
+ } else if (py::isinstance<Block>(stks)) {
131
+ const auto& blk = stks.cast<Block&>();
132
+ ret = blk.getStockList();
133
+ } else if (py::isinstance<StockManager>(stks)) {
134
+ const auto& sm = stks.cast<StockManager&>();
135
+ ret = sm.getStockList();
136
+ } else if (py::isinstance<py::sequence>(stks)) {
137
+ ret = python_list_to_vector<Stock>(stks);
138
+ } else {
139
+ HKU_THROW("Failed get StockList! Input stks must be Block, sm or sequenc(Stock)!");
140
+ }
141
+ return ret;
142
+ }
143
+
127
144
  } // namespace hku
128
145
 
129
146
  #endif // HIKYUU_PYTHON_BIND_UTILS_H
@@ -107,12 +107,13 @@ public:
107
107
  virtual TradeCostPtr _clone() = 0;
108
108
 
109
109
  protected:
110
- virtual bool isPythonObject() const {
111
- return false;
110
+ bool isPythonObject() const noexcept {
111
+ return m_is_python_object;
112
112
  }
113
113
 
114
- private:
114
+ protected:
115
115
  string m_name;
116
+ bool m_is_python_object{false};
116
117
 
117
118
  //============================================
118
119
  // 序列化支持
@@ -123,6 +124,7 @@ private:
123
124
  template <class Archive>
124
125
  void serialize(Archive& ar, const unsigned int version) {
125
126
  ar& BOOST_SERIALIZATION_NVP(m_name);
127
+ ar& BOOST_SERIALIZATION_NVP(m_is_python_object);
126
128
  ar& BOOST_SERIALIZATION_NVP(m_params);
127
129
  }
128
130
  #endif /* HKU_SUPPORT_SERIALIZATION */
@@ -37,6 +37,8 @@ class HKU_API TradeManagerBase : public enable_shared_from_this<TradeManagerBase
37
37
  public:
38
38
  TradeManagerBase() : TradeManagerBase("", TC_Zero()) {}
39
39
 
40
+ explicit TradeManagerBase(const string& name) : TradeManagerBase(name, TC_Zero()) {}
41
+
40
42
  TradeManagerBase(const string& name, const TradeCostPtr& costFunc)
41
43
  : m_name(name), m_costfunc(costFunc), m_broker_last_datetime(Datetime::now()) {
42
44
  setParam<int>("precision", 2); // 计算精度
@@ -169,6 +171,7 @@ public:
169
171
  HKU_CHECK(p, "Invalid ptr from _clone!");
170
172
  p->m_params = m_params;
171
173
  p->m_name = m_name;
174
+ p->m_is_python_object = m_is_python_object;
172
175
  p->m_broker_last_datetime = m_broker_last_datetime;
173
176
  p->m_costfunc = m_costfunc;
174
177
  p->m_broker_list = m_broker_list;
@@ -769,8 +772,8 @@ public:
769
772
  std::vector<std::pair<Datetime, double>> getProfitPercentYearly(
770
773
  const Datetime& datetime = Datetime::now());
771
774
 
772
- virtual bool isPythonObject() const {
773
- return false;
775
+ bool isPythonObject() const noexcept {
776
+ return m_is_python_object;
774
777
  }
775
778
 
776
779
  protected:
@@ -780,6 +783,8 @@ protected:
780
783
  Datetime m_broker_last_datetime; // 订单代理最近一次执行操作的时刻,当前启动运行时间
781
784
  list<OrderBrokerPtr> m_broker_list; // 订单代理列表
782
785
 
786
+ bool m_is_python_object{false};
787
+
783
788
  //============================================
784
789
  // 序列化支持
785
790
  //============================================
@@ -793,6 +798,7 @@ private:
793
798
  ar& BOOST_SERIALIZATION_NVP(m_costfunc);
794
799
  ar& BOOST_SERIALIZATION_NVP(m_broker_last_datetime);
795
800
  ar& BOOST_SERIALIZATION_NVP(m_broker_list);
801
+ ar& BOOST_SERIALIZATION_NVP(m_is_python_object);
796
802
  }
797
803
 
798
804
  template <class Archive>
@@ -802,6 +808,7 @@ private:
802
808
  ar& BOOST_SERIALIZATION_NVP(m_costfunc);
803
809
  ar& BOOST_SERIALIZATION_NVP(m_broker_last_datetime);
804
810
  ar& BOOST_SERIALIZATION_NVP(m_broker_list);
811
+ ar& BOOST_SERIALIZATION_NVP(m_is_python_object);
805
812
  }
806
813
 
807
814
  BOOST_SERIALIZATION_SPLIT_MEMBER()
@@ -101,8 +101,8 @@ public:
101
101
  static void adjustWeight(SystemWeightList& sw_list, double can_allocate_weight,
102
102
  bool auto_adjust, bool ignore_zero);
103
103
 
104
- virtual bool isPythonObject() const {
105
- return false;
104
+ bool isPythonObject() const noexcept {
105
+ return m_is_python_object;
106
106
  }
107
107
 
108
108
  private:
@@ -116,6 +116,9 @@ private:
116
116
  void _adjust_without_running(const Datetime& date, const SystemWeightList& se_list,
117
117
  const std::unordered_set<SYSPtr>& running_list);
118
118
 
119
+ protected:
120
+ bool m_is_python_object{false};
121
+
119
122
  private:
120
123
  string m_name; // 组件名称
121
124
  KQuery m_query; // 查询条件
@@ -130,6 +133,7 @@ private:
130
133
  friend class boost::serialization::access;
131
134
  template <class Archive>
132
135
  void save(Archive& ar, const unsigned int version) const {
136
+ ar& BOOST_SERIALIZATION_NVP(m_is_python_object);
133
137
  ar& BOOST_SERIALIZATION_NVP(m_name);
134
138
  ar& BOOST_SERIALIZATION_NVP(m_params);
135
139
  ar& BOOST_SERIALIZATION_NVP(m_query);
@@ -137,6 +141,7 @@ private:
137
141
 
138
142
  template <class Archive>
139
143
  void load(Archive& ar, const unsigned int version) {
144
+ ar& BOOST_SERIALIZATION_NVP(m_is_python_object);
140
145
  ar& BOOST_SERIALIZATION_NVP(m_name);
141
146
  ar& BOOST_SERIALIZATION_NVP(m_params);
142
147
  ar& BOOST_SERIALIZATION_NVP(m_query);
@@ -147,7 +152,7 @@ private:
147
152
  };
148
153
 
149
154
  #if HKU_SUPPORT_SERIALIZATION
150
- BOOST_SERIALIZATION_ASSUME_ABSTRACT(SelectorBase)
155
+ BOOST_SERIALIZATION_ASSUME_ABSTRACT(AllocateFundsBase)
151
156
  #endif
152
157
 
153
158
  #if HKU_SUPPORT_SERIALIZATION
@@ -109,8 +109,8 @@ public:
109
109
  return m_values.cend();
110
110
  }
111
111
 
112
- virtual bool isPythonObject() const {
113
- return false;
112
+ bool isPythonObject() const noexcept {
113
+ return m_is_python_object;
114
114
  }
115
115
 
116
116
  protected:
@@ -120,6 +120,7 @@ protected:
120
120
  SGPtr m_sg;
121
121
  map<Datetime, size_t> m_date_index;
122
122
  vector<price_t> m_values;
123
+ bool m_is_python_object{false};
123
124
 
124
125
  //============================================
125
126
  // 序列化支持
@@ -133,6 +134,7 @@ private:
133
134
  ar& BOOST_SERIALIZATION_NVP(m_params);
134
135
  ar& BOOST_SERIALIZATION_NVP(m_date_index);
135
136
  ar& BOOST_SERIALIZATION_NVP(m_values);
137
+ ar& BOOST_SERIALIZATION_NVP(m_is_python_object);
136
138
  // m_kdata/m_tm/m_sg是系统运行时临时设置,不需要序列化
137
139
  }
138
140
 
@@ -142,6 +144,7 @@ private:
142
144
  ar& BOOST_SERIALIZATION_NVP(m_params);
143
145
  ar& BOOST_SERIALIZATION_NVP(m_date_index);
144
146
  ar& BOOST_SERIALIZATION_NVP(m_values);
147
+ ar& BOOST_SERIALIZATION_NVP(m_is_python_object);
145
148
  // m_kdata/m_tm/m_sg是系统运行时临时设置,不需要序列化
146
149
  }
147
150