hikyuu 2.6.7__py3-none-win_amd64.whl → 2.6.8.2__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 (131) hide show
  1. hikyuu/__init__.py +6 -2
  2. hikyuu/__init__.pyi +37 -10
  3. hikyuu/analysis/__init__.pyi +24 -0
  4. hikyuu/analysis/analysis.pyi +25 -1
  5. hikyuu/core.pyi +26 -2
  6. hikyuu/cpp/concrt140.dll +0 -0
  7. hikyuu/cpp/core310.pyd +0 -0
  8. hikyuu/cpp/core310.pyi +419 -31
  9. hikyuu/cpp/core311.pyd +0 -0
  10. hikyuu/cpp/core311.pyi +419 -31
  11. hikyuu/cpp/core312.pyd +0 -0
  12. hikyuu/cpp/core312.pyi +419 -31
  13. hikyuu/cpp/core313.pyd +0 -0
  14. hikyuu/cpp/core313.pyi +419 -31
  15. hikyuu/cpp/core39.pyd +0 -0
  16. hikyuu/cpp/core39.pyi +419 -31
  17. hikyuu/cpp/hikyuu.dll +0 -0
  18. hikyuu/cpp/hikyuu.lib +0 -0
  19. hikyuu/cpp/hku_hdf5.dll +0 -0
  20. hikyuu/cpp/hku_hdf5_cpp.dll +0 -0
  21. hikyuu/cpp/hku_hdf5_hl.dll +0 -0
  22. hikyuu/cpp/hku_hdf5_hl_cpp.dll +0 -0
  23. hikyuu/cpp/i18n/zh_CN/hikyuu.mo +0 -0
  24. hikyuu/cpp/msvcp140.dll +0 -0
  25. hikyuu/cpp/msvcp140_1.dll +0 -0
  26. hikyuu/cpp/msvcp140_2.dll +0 -0
  27. hikyuu/cpp/msvcp140_atomic_wait.dll +0 -0
  28. hikyuu/cpp/msvcp140_codecvt_ids.dll +0 -0
  29. hikyuu/cpp/sqlite3.dll +0 -0
  30. hikyuu/cpp/vcruntime140.dll +0 -0
  31. hikyuu/cpp/vcruntime140_1.dll +0 -0
  32. hikyuu/draw/__init__.pyi +1 -1
  33. hikyuu/draw/drawplot/bokeh_draw.pyi +33 -8
  34. hikyuu/draw/drawplot/echarts_draw.pyi +33 -8
  35. hikyuu/draw/drawplot/matplotlib_draw.pyi +33 -8
  36. hikyuu/extend.py +19 -0
  37. hikyuu/extend.pyi +27 -3
  38. hikyuu/hub.pyi +6 -6
  39. hikyuu/include/hikyuu/DataType.h +2 -2
  40. hikyuu/include/hikyuu/KData.h +91 -25
  41. hikyuu/include/hikyuu/KDataImp.h +31 -46
  42. hikyuu/include/hikyuu/KDataPrivatedBufferImp.h +73 -0
  43. hikyuu/include/hikyuu/KDataSharedBufferImp.h +69 -0
  44. hikyuu/include/hikyuu/KQuery.h +16 -4
  45. hikyuu/include/hikyuu/KRecord.h +4 -1
  46. hikyuu/include/hikyuu/Stock.h +10 -4
  47. hikyuu/include/hikyuu/StockManager.h +11 -3
  48. hikyuu/include/hikyuu/TransRecord.h +2 -2
  49. hikyuu/include/hikyuu/data_driver/KDataDriver.h +5 -0
  50. hikyuu/include/hikyuu/doc.h +2 -2
  51. hikyuu/include/hikyuu/global/GlobalSpotAgent.h +8 -0
  52. hikyuu/include/hikyuu/global/agent/SpotAgent.h +12 -7
  53. hikyuu/include/hikyuu/indicator/Indicator.h +11 -0
  54. hikyuu/include/hikyuu/indicator/Indicator2InImp.h +9 -0
  55. hikyuu/include/hikyuu/indicator/IndicatorImp.h +83 -15
  56. hikyuu/include/hikyuu/indicator/build_in.h +1 -0
  57. hikyuu/include/hikyuu/indicator/crt/AMA.h +2 -1
  58. hikyuu/include/hikyuu/indicator/crt/ATR.h +1 -1
  59. hikyuu/include/hikyuu/indicator/crt/CONTEXT.h +2 -0
  60. hikyuu/include/hikyuu/indicator/crt/CYCLE.h +3 -0
  61. hikyuu/include/hikyuu/indicator/crt/DMA.h +1 -1
  62. hikyuu/include/hikyuu/indicator/crt/IC.h +14 -6
  63. hikyuu/include/hikyuu/indicator/crt/ICIR.h +8 -4
  64. hikyuu/include/hikyuu/indicator/crt/INSUM.h +2 -0
  65. hikyuu/include/hikyuu/indicator/crt/PRICELIST.h +2 -0
  66. hikyuu/include/hikyuu/indicator/crt/REFX.h +25 -0
  67. hikyuu/include/hikyuu/indicator/crt/SLICE.h +4 -4
  68. hikyuu/include/hikyuu/indicator/crt/SPEARMAN.h +3 -2
  69. hikyuu/include/hikyuu/indicator/imp/IContext.h +5 -0
  70. hikyuu/include/hikyuu/indicator/imp/ICval.h +6 -0
  71. hikyuu/include/hikyuu/indicator/imp/IDropna.h +9 -0
  72. hikyuu/include/hikyuu/indicator/imp/IIc.h +2 -1
  73. hikyuu/include/hikyuu/indicator/imp/IPriceList.h +1 -0
  74. hikyuu/include/hikyuu/indicator/imp/IRefX.h +23 -0
  75. hikyuu/include/hikyuu/plugin/backtest.h +2 -0
  76. hikyuu/include/hikyuu/plugin/extind.h +45 -0
  77. hikyuu/include/hikyuu/plugin/hkuextra.h +21 -0
  78. hikyuu/include/hikyuu/plugin/interface/HkuExtraPluginInterface.h +16 -0
  79. hikyuu/include/hikyuu/plugin/interface/TMReportPluginInterface.h +1 -0
  80. hikyuu/include/hikyuu/python/pybind_utils.h +27 -11
  81. hikyuu/include/hikyuu/trade_manage/Performance.h +0 -1
  82. hikyuu/include/hikyuu/trade_manage/TradeCostBase.h +5 -0
  83. hikyuu/include/hikyuu/trade_manage/TradeManager.h +4 -0
  84. hikyuu/include/hikyuu/trade_manage/TradeManagerBase.h +10 -1
  85. hikyuu/include/hikyuu/trade_sys/allocatefunds/AllocateFundsBase.h +5 -0
  86. hikyuu/include/hikyuu/trade_sys/condition/ConditionBase.h +5 -0
  87. hikyuu/include/hikyuu/trade_sys/environment/EnvironmentBase.h +5 -0
  88. hikyuu/include/hikyuu/trade_sys/moneymanager/MoneyManagerBase.h +5 -0
  89. hikyuu/include/hikyuu/trade_sys/multifactor/MultiFactorBase.h +6 -3
  90. hikyuu/include/hikyuu/trade_sys/portfolio/Portfolio.h +4 -0
  91. hikyuu/include/hikyuu/trade_sys/profitgoal/ProfitGoalBase.h +5 -0
  92. hikyuu/include/hikyuu/trade_sys/selector/SelectorBase.h +5 -2
  93. hikyuu/include/hikyuu/trade_sys/signal/SignalBase.h +5 -0
  94. hikyuu/include/hikyuu/trade_sys/slippage/SlippageBase.h +5 -0
  95. hikyuu/include/hikyuu/trade_sys/stoploss/StoplossBase.h +6 -1
  96. hikyuu/include/hikyuu/trade_sys/system/System.h +5 -0
  97. hikyuu/include/hikyuu/utilities/datetime/Datetime.h +2 -2
  98. hikyuu/include/hikyuu/utilities/os.h +4 -0
  99. hikyuu/include/hikyuu/utilities/thread/GlobalMQStealThreadPool.h +1 -1
  100. hikyuu/include/hikyuu/utilities/thread/GlobalMQThreadPool.h +1 -1
  101. hikyuu/include/hikyuu/utilities/thread/GlobalThreadPool.h +1 -1
  102. hikyuu/include/hikyuu/utilities/thread/MQThreadPool.h +1 -1
  103. hikyuu/include/hikyuu/version.h +4 -4
  104. hikyuu/include/hikyuu/views/arrow_common.h +38 -0
  105. hikyuu/include/hikyuu/views/arrow_views.h +117 -0
  106. hikyuu/indicator/indicator.py +4 -5
  107. hikyuu/plugin/backtest.dll +0 -0
  108. hikyuu/plugin/clickhousedriver.dll +0 -0
  109. hikyuu/plugin/dataserver.dll +0 -0
  110. hikyuu/plugin/device.dll +0 -0
  111. hikyuu/plugin/extind.dll +0 -0
  112. hikyuu/plugin/hkuextra.dll +0 -0
  113. hikyuu/plugin/import2hdf5.dll +0 -0
  114. hikyuu/plugin/tmreport.dll +0 -0
  115. hikyuu/strategy/strategy_demo1.py +1 -1
  116. hikyuu/test/test_init.py +19 -19
  117. hikyuu/trade_manage/__init__.pyi +32 -7
  118. hikyuu/trade_manage/trade.py +6 -0
  119. hikyuu/trade_manage/trade.pyi +32 -7
  120. hikyuu/trade_sys/__init__.py +4 -0
  121. hikyuu/util/__init__.pyi +1 -1
  122. hikyuu/util/singleton.pyi +1 -1
  123. {hikyuu-2.6.7.dist-info → hikyuu-2.6.8.2.dist-info}/METADATA +15 -3
  124. {hikyuu-2.6.7.dist-info → hikyuu-2.6.8.2.dist-info}/RECORD +128 -125
  125. {hikyuu-2.6.7.dist-info → hikyuu-2.6.8.2.dist-info}/WHEEL +1 -1
  126. {hikyuu-2.6.7.dist-info → hikyuu-2.6.8.2.dist-info}/top_level.txt +1 -1
  127. hikyuu/include/hikyuu/view/MarketView.h +0 -59
  128. hikyuu/setup.py +0 -104
  129. hikyuu-2.6.7.dist-info/LICENSE +0 -201
  130. /hikyuu/include/hikyuu/{view → views}/__init__.py +0 -0
  131. {hikyuu-2.6.7.dist-info → hikyuu-2.6.8.2.dist-info}/entry_points.txt +0 -0
@@ -7,7 +7,9 @@
7
7
 
8
8
  #pragma once
9
9
 
10
+ #include <arrow/api.h>
10
11
  #include "hikyuu/Stock.h"
12
+ #include "hikyuu/indicator/Indicator.h"
11
13
 
12
14
  namespace hku {
13
15
 
@@ -53,4 +55,23 @@ size_t getStockExtraCount(const Stock& stk, const string& ktype);
53
55
  bool getStockExtraIndexRange(const Stock& stk, const KQuery& query, size_t& out_start,
54
56
  size_t& out_end);
55
57
 
58
+ KDataImpPtr getKDataImp(const Stock& stk, const KQuery& query);
59
+
60
+ //-------------------------------
61
+ // Views 扩展
62
+ //-------------------------------
63
+
64
+ std::shared_ptr<arrow::Table> getIndicatorsViewParallel(const StockList& stks,
65
+ const IndicatorList& inds,
66
+ const KQuery& query, const string& market);
67
+
68
+ std::shared_ptr<arrow::Table> getIndicatorsViewParallel(const StockList& stks,
69
+ const IndicatorList& inds,
70
+ const Datetime& date, size_t cal_len,
71
+ const KQuery::KType& ktype,
72
+ const string& market);
73
+
74
+ std::shared_ptr<arrow::Table> getMarketViewParallel(const StockList& stks, const Datetime& date,
75
+ const string& market);
76
+
56
77
  } // namespace hku
@@ -7,6 +7,7 @@
7
7
 
8
8
  #pragma once
9
9
 
10
+ #include <arrow/api.h>
10
11
  #include "hikyuu/utilities/plugin/PluginBase.h"
11
12
 
12
13
  namespace hku {
@@ -33,6 +34,21 @@ public:
33
34
 
34
35
  virtual bool getStockExtraIndexRange(const Stock& stk, const KQuery& query, size_t& out_start,
35
36
  size_t& out_end) = 0;
37
+
38
+ virtual KDataImpPtr getKDataImp(const Stock& stk, const KQuery& query) = 0;
39
+
40
+ virtual std::shared_ptr<arrow::Table> getIndicatorsViewParallel(const StockList& stks,
41
+ const IndicatorList& inds,
42
+ const KQuery& query,
43
+ const string& market) = 0;
44
+
45
+ virtual std::shared_ptr<arrow::Table> getIndicatorsViewParallel(
46
+ const StockList& stks, const IndicatorList& inds, const Datetime& date, size_t cal_len,
47
+ const KQuery::KType& ktype, const string& market) = 0;
48
+
49
+ virtual std::shared_ptr<arrow::Table> getMarketViewParallel(const StockList& stks,
50
+ const Datetime& date,
51
+ const string& market) = 0;
36
52
  };
37
53
 
38
54
  } // namespace hku
@@ -54,6 +54,7 @@ public:
54
54
  * 以便用于计算当前市值
55
55
  * @param tm 指定的交易管理实例
56
56
  * @param datetime 统计截止时刻
57
+ * @param ktype k线类型
57
58
  */
58
59
  virtual Performance getExtPerformance(const TMPtr& tm, const Datetime& datetime,
59
60
  const KQuery::KType& ktype) = 0;
@@ -14,6 +14,7 @@
14
14
  #include <pybind11/operators.h>
15
15
  #include <pybind11/stl.h>
16
16
  #include <pybind11/numpy.h>
17
+ #include <arrow/api.h>
17
18
  #include <vector>
18
19
  #include <string>
19
20
  #include "convert_any.h"
@@ -54,10 +55,11 @@ std::vector<T> python_bytes_to_vector(const py::bytes& obj) {
54
55
 
55
56
  template <typename T>
56
57
  std::vector<T> python_list_to_vector(const py::sequence& obj) {
58
+ // 如果 len(obj) 长度为零,即使类型不是所期望的也可能成功,但无风险
57
59
  auto total = len(obj);
58
60
  std::vector<T> vect(total);
59
61
  for (auto i = 0; i < total; ++i) {
60
- vect[i] = obj[i].cast<T>();
62
+ vect[i] = py::cast<T>(obj[i]);
61
63
  }
62
64
  return vect;
63
65
  }
@@ -86,16 +88,23 @@ std::string to_py_str(const T& item) {
86
88
  // 直接使用 pybind11 重载 _clone,在 C++ 中会丢失 python 中的类型
87
89
  // 参考:https://github.com/pybind/pybind11/issues/1049 进行修改
88
90
  // PYBIND11_OVERLOAD(IndicatorImpPtr, IndicatorImp, _clone, );
89
- #define PY_CLONE(pyclassname, classname) \
90
- public: \
91
- std::shared_ptr<classname> _clone() override { \
92
- auto self = py::cast(this); \
93
- auto cloned = self.attr("_clone")(); \
94
- \
95
- auto keep_python_state_alive = std::make_shared<py::object>(cloned); \
96
- auto ptr = cloned.cast<pyclassname*>(); \
97
- \
98
- return std::shared_ptr<classname>(keep_python_state_alive, ptr); \
91
+ #define PY_CLONE(pyclassname, classname) \
92
+ public: \
93
+ std::shared_ptr<classname> _clone() override { \
94
+ if (isPythonObject()) { \
95
+ py::gil_scoped_acquire acquire; \
96
+ auto self = py::cast(this); \
97
+ auto cloned = self.attr("_clone")(); \
98
+ auto keep_python_state_alive = std::make_shared<py::object>(cloned); \
99
+ auto ptr = cloned.cast<pyclassname*>(); \
100
+ return std::shared_ptr<classname>(keep_python_state_alive, ptr); \
101
+ } \
102
+ return this->_clone(); \
103
+ } \
104
+ \
105
+ protected: \
106
+ inline bool isPythonObject() const override { \
107
+ return true; \
99
108
  }
100
109
 
101
110
  // 用于检查已 py::object 方式传递的函数参数个数是否符合预期
@@ -115,6 +124,13 @@ inline bool check_pyfunction_arg_num(py::object& func, size_t arg_num) {
115
124
  */
116
125
  size_t utf8_to_utf32(const std::string& utf8_str, int32_t* out, size_t out_len) noexcept;
117
126
 
127
+ /*
128
+ * 将arrow::Table转换为 pyarrow::Table
129
+ * @param table 待转换的arrow::Table
130
+ * @return 转换后的py::object
131
+ */
132
+ py::object to_pyarrow_table(const std::shared_ptr<arrow::Table>& table);
133
+
118
134
  } // namespace hku
119
135
 
120
136
  #endif // HIKYUU_PYTHON_BIND_UTILS_H
@@ -47,7 +47,6 @@ public:
47
47
  /**
48
48
  * 简单的文本统计报告,用于直接输出打印。
49
49
  * @note 只有运行 statistics 后或 Performance 本身为从 TM 获取的结果时才生效
50
- * @param datetime 指定的截止时刻
51
50
  * @return
52
51
  */
53
52
  string report();
@@ -106,6 +106,11 @@ public:
106
106
  /** 继承子类必须实现私有变量的克隆接口 */
107
107
  virtual TradeCostPtr _clone() = 0;
108
108
 
109
+ protected:
110
+ virtual bool isPythonObject() const {
111
+ return false;
112
+ }
113
+
109
114
  private:
110
115
  string m_name;
111
116
 
@@ -225,6 +225,7 @@ public:
225
225
  * @param goalPrice 目标价格
226
226
  * @param planPrice 计划买入价格
227
227
  * @param from 记录是哪个系统部件发出的买入指示
228
+ * @param remark 买入备注
228
229
  * @return 返回对应的交易记录,如果操作失败,business等于BUSINESS_INVALID
229
230
  */
230
231
  virtual TradeRecord buy(const Datetime& datetime, const Stock& stock, price_t realPrice,
@@ -242,6 +243,7 @@ public:
242
243
  * @param goalPrice 新的目标价格
243
244
  * @param planPrice 原计划卖出价格
244
245
  * @param from 记录是哪个系统部件发出的卖出指示
246
+ * @param remark 卖出备注
245
247
  * @return 返回对应的交易记录,如果操作失败,business等于BUSINESS_INVALID
246
248
  */
247
249
  virtual TradeRecord sell(const Datetime& datetime, const Stock& stock, price_t realPrice,
@@ -259,6 +261,7 @@ public:
259
261
  * @param goalPrice 目标价格
260
262
  * @param planPrice 计划卖空价格
261
263
  * @param from 记录是哪个系统部件发出的买入指示
264
+ * @param remark 备注
262
265
  * @return 返回对应的交易记录,如果操作失败,business等于BUSINESS_INVALID
263
266
  */
264
267
  virtual TradeRecord sellShort(const Datetime& datetime, const Stock& stock, price_t realPrice,
@@ -276,6 +279,7 @@ public:
276
279
  * @param goalPrice 目标价格
277
280
  * @param planPrice 计划买入价格
278
281
  * @param from 记录是哪个系统部件发出的卖出指示
282
+ * @param remark 备注
279
283
  * @return 返回对应的交易记录,如果操作失败,business等于BUSINESS_INVALID
280
284
  */
281
285
  virtual TradeRecord buyShort(const Datetime& datetime, const Stock& stock, price_t realPrice,
@@ -521,6 +521,7 @@ public:
521
521
  * @param goalPrice 目标价格
522
522
  * @param planPrice 计划买入价格
523
523
  * @param from 记录是哪个系统部件发出的买入指示
524
+ * @param remark 备注
524
525
  * @return 返回对应的交易记录,如果操作失败,business等于BUSINESS_INVALID
525
526
  */
526
527
  virtual TradeRecord buy(const Datetime& datetime, const Stock& stock, price_t realPrice,
@@ -541,6 +542,7 @@ public:
541
542
  * @param goalPrice 新的目标价格
542
543
  * @param planPrice 原计划卖出价格
543
544
  * @param from 记录是哪个系统部件发出的卖出指示
545
+ * @param remark 卖出备注
544
546
  * @return 返回对应的交易记录,如果操作失败,business等于BUSINESS_INVALID
545
547
  */
546
548
  virtual TradeRecord sell(const Datetime& datetime, const Stock& stock, price_t realPrice,
@@ -561,6 +563,7 @@ public:
561
563
  * @param goalPrice 目标价格
562
564
  * @param planPrice 计划卖空价格
563
565
  * @param from 记录是哪个系统部件发出的买入指示
566
+ * @param remark 备注
564
567
  * @return 返回对应的交易记录,如果操作失败,business等于BUSINESS_INVALID
565
568
  */
566
569
  virtual TradeRecord sellShort(const Datetime& datetime, const Stock& stock, price_t realPrice,
@@ -581,6 +584,7 @@ public:
581
584
  * @param goalPrice 目标价格
582
585
  * @param planPrice 计划买入价格
583
586
  * @param from 记录是哪个系统部件发出的卖出指示
587
+ * @param remark 备注
584
588
  * @return 返回对应的交易记录,如果操作失败,business等于BUSINESS_INVALID
585
589
  */
586
590
  virtual TradeRecord buyShort(const Datetime& datetime, const Stock& stock, price_t realPrice,
@@ -716,13 +720,13 @@ public:
716
720
  * 统计截至某一时刻的系统绩效, datetime必须大于等于lastDatetime,
717
721
  * 以便用于计算当前市值
718
722
  * @param datetime 统计截止时刻
723
+ * @param ktype k线类型
719
724
  */
720
725
  Performance getPerformance(const Datetime& datetime = Datetime::now(),
721
726
  const KQuery::KType& ktype = KQuery::DAY);
722
727
 
723
728
  /**
724
729
  * @brief 获取指定时刻时账户的最大回撤百分比(负数)(仅根据收盘价计算)
725
- * @param tm 指定账户
726
730
  * @param date 指定日期(包含该时刻)
727
731
  * @param ktype k线类型
728
732
  * @return price_t
@@ -765,6 +769,11 @@ public:
765
769
  std::vector<std::pair<Datetime, double>> getProfitPercentYearly(
766
770
  const Datetime& datetime = Datetime::now());
767
771
 
772
+ protected:
773
+ virtual bool isPythonObject() const {
774
+ return false;
775
+ }
776
+
768
777
  protected:
769
778
  string m_name; // 账户名称
770
779
  TradeCostPtr m_costfunc; // 成本算法
@@ -101,6 +101,11 @@ public:
101
101
  static void adjustWeight(SystemWeightList& sw_list, double can_allocate_weight,
102
102
  bool auto_adjust, bool ignore_zero);
103
103
 
104
+ protected:
105
+ virtual bool isPythonObject() const {
106
+ return false;
107
+ }
108
+
104
109
  private:
105
110
  void initParam();
106
111
 
@@ -109,6 +109,11 @@ public:
109
109
  return m_values.cend();
110
110
  }
111
111
 
112
+ protected:
113
+ virtual bool isPythonObject() const {
114
+ return false;
115
+ }
116
+
112
117
  protected:
113
118
  string m_name;
114
119
  KData m_kdata;
@@ -93,6 +93,11 @@ public:
93
93
  /** 子类克隆接口 */
94
94
  virtual EnvironmentPtr _clone() = 0;
95
95
 
96
+ protected:
97
+ virtual bool isPythonObject() const {
98
+ return false;
99
+ }
100
+
96
101
  protected:
97
102
  string m_name;
98
103
  KQuery m_query;
@@ -152,6 +152,11 @@ public:
152
152
  /** 子类克隆私有变量接口 */
153
153
  virtual MoneyManagerPtr _clone() = 0;
154
154
 
155
+ protected:
156
+ virtual bool isPythonObject() const {
157
+ return false;
158
+ }
159
+
155
160
  protected:
156
161
  string m_name;
157
162
  KQuery m_query;
@@ -10,8 +10,6 @@
10
10
  #include "hikyuu/KData.h"
11
11
  #include "ScoreRecord.h"
12
12
 
13
- #define MF_USE_MULTI_THREAD 1
14
-
15
13
  namespace hku {
16
14
 
17
15
  /**
@@ -114,7 +112,7 @@ public:
114
112
  const vector<ScoreRecordList>& getAllScores();
115
113
 
116
114
  /**
117
- * 获取合成因子的IC, 长度与参考日期同
115
+ * 获取合成因子的IC, 长度与参考日期同 (非严格IC模式)
118
116
  * @note ndays 对于使用 IC/ICIR 加权的新因子,最好保持好 ic_n 一致,
119
117
  * 但对于等权计算的新因子,不一定非要使用 ic_n 计算。
120
118
  * 所以,ndays 增加了一个特殊值 0, 表示直接使用 ic_n 参数计算 IC
@@ -145,6 +143,11 @@ public:
145
143
  virtual MultiFactorPtr _clone() = 0;
146
144
  virtual IndicatorList _calculate(const vector<IndicatorList>&) = 0;
147
145
 
146
+ protected:
147
+ virtual bool isPythonObject() const {
148
+ return false;
149
+ }
150
+
148
151
  private:
149
152
  /** 执行计算 */
150
153
  void calculate();
@@ -115,6 +115,10 @@ private:
115
115
  const string& mode);
116
116
 
117
117
  protected:
118
+ virtual bool isPythonObject() const {
119
+ return false;
120
+ }
121
+
118
122
  // 跟踪打印当前TM持仓情况
119
123
  void traceMomentTMAfterRunAtOpen(const Datetime& date);
120
124
  void traceMomentTMAfterRunAtClose(const Datetime& date);
@@ -82,6 +82,11 @@ public:
82
82
  /** 子类计算接口,由setTO调用 */
83
83
  virtual void _calculate() = 0;
84
84
 
85
+ protected:
86
+ virtual bool isPythonObject() const {
87
+ return false;
88
+ }
89
+
85
90
  protected:
86
91
  string m_name;
87
92
  KData m_kdata;
@@ -48,7 +48,6 @@ public:
48
48
  * 添加备选股票及其交易策略原型
49
49
  * @param stock 备选股票
50
50
  * @param protoSys 交易系统策略原型
51
- * @return 如果 protoSys 无效 或 stock 无效,则返回 false, 否则返回 true
52
51
  */
53
52
  void addStock(const Stock& stock, const SystemPtr& protoSys);
54
53
 
@@ -57,7 +56,6 @@ public:
57
56
  * @note 如果存在无效的stock,则自动忽略,不会返回false
58
57
  * @param stkList 备选股票列表
59
58
  * @param protoSys 交易系统策略原型
60
- * @return 如果 protoSys 无效则返回false,否则返回 true
61
59
  */
62
60
  void addStockList(const StockList& stkList, const SystemPtr& protoSys);
63
61
 
@@ -134,6 +132,11 @@ public:
134
132
 
135
133
  virtual string str() const;
136
134
 
135
+ protected:
136
+ virtual bool isPythonObject() const {
137
+ return false;
138
+ }
139
+
137
140
  private:
138
141
  void initParam();
139
142
 
@@ -130,6 +130,11 @@ public:
130
130
  /** 子类计算接口,在setTO中调用 */
131
131
  virtual void _calculate(const KData&) = 0;
132
132
 
133
+ protected:
134
+ virtual bool isPythonObject() const {
135
+ return false;
136
+ }
137
+
133
138
  private:
134
139
  void initParam();
135
140
 
@@ -71,6 +71,11 @@ public:
71
71
  /** 子类计算接口,由setTO调用 */
72
72
  virtual void _calculate() = 0;
73
73
 
74
+ protected:
75
+ virtual bool isPythonObject() const {
76
+ return false;
77
+ }
78
+
74
79
  protected:
75
80
  string m_name;
76
81
  KData m_kdata;
@@ -86,6 +86,11 @@ public:
86
86
  /** 子类计算接口,由setTO调用 */
87
87
  virtual void _calculate() = 0;
88
88
 
89
+ protected:
90
+ virtual bool isPythonObject() const {
91
+ return false;
92
+ }
93
+
89
94
  protected:
90
95
  string m_name;
91
96
  TradeManagerPtr m_tm;
@@ -156,7 +161,7 @@ public: \
156
161
 
157
162
  /**
158
163
  * 客户程序都应使用该指针类型,操作止损策略实例
159
- * @ingroup StopLoss
164
+ * @ingroup Stoploss
160
165
  */
161
166
  typedef shared_ptr<StoplossBase> StoplossPtr;
162
167
  typedef shared_ptr<StoplossBase> STPtr;
@@ -265,6 +265,11 @@ public:
265
265
  // 处理延迟买入请求,仅供 PF 调用
266
266
  virtual TradeRecord pfProcessDelayBuyRequest(const Datetime& date);
267
267
 
268
+ protected:
269
+ virtual bool isPythonObject() const {
270
+ return false;
271
+ }
272
+
268
273
  private:
269
274
  bool _environmentIsValid(const Datetime& datetime);
270
275
  bool _conditionIsValid(const Datetime& datetime);
@@ -193,10 +193,10 @@ public:
193
193
  uint64_t ticks() const noexcept;
194
194
 
195
195
  /** 时间戳,距离1970-01-01 00:00:00的微秒数 */
196
- int64_t timestamp() const noexcept;
196
+ uint64_t timestamp() const noexcept;
197
197
 
198
198
  /** 时间戳,距离1970-01-01 00:00:00的微秒数, 并扣除本地 UTC 偏差时间 */
199
- int64_t timestampUTC() const noexcept;
199
+ uint64_t timestampUTC() const noexcept;
200
200
 
201
201
  /**
202
202
  * 转化为字符串,供打印阅读,格式:
@@ -108,4 +108,8 @@ std::string HKU_UTILS_API getCpuArch();
108
108
  /** 获取当前系统语言名称(全部小写返回) */
109
109
  std::string HKU_UTILS_API getSystemLanguage();
110
110
 
111
+ uint64_t HKU_UTILS_API getMemoryMaxSize();
112
+
113
+ uint64_t HKU_UTILS_API getMemoryIdleSize();
114
+
111
115
  } // namespace hku
@@ -30,7 +30,7 @@ namespace hku {
30
30
 
31
31
  /**
32
32
  * @brief 无集中队列多队列偷取任务池
33
- * @ingroup GlobalMQStealThreadPool
33
+ * @ingroup ThreadPool
34
34
  */
35
35
  #ifdef _MSC_VER
36
36
  class GlobalMQStealThreadPool {
@@ -32,7 +32,7 @@ namespace hku {
32
32
  /**
33
33
  * @brief 全局分布式线程池,只适合程序运行期内一直保持运行的情况
34
34
  * @details
35
- * @ingroup GlobalMQThreadPool
35
+ * @ingroup ThreadPool
36
36
  */
37
37
  #ifdef _MSC_VER
38
38
  class GlobalMQThreadPool {
@@ -35,7 +35,7 @@ namespace hku {
35
35
  * @brief 全局集中式任务队列线程池,任务之间彼此独立不能互相等待
36
36
  * @note 任务运行之间如存在先后顺序,只适合程序运行期内一直保持运行的情况
37
37
  * @details
38
- * @ingroup GlobalThreadPool
38
+ * @ingroup ThreadPool
39
39
  */
40
40
  #ifdef _MSC_VER
41
41
  class GlobalThreadPool {
@@ -33,7 +33,7 @@ namespace hku {
33
33
  * @brief 普通多任务队列线程池,任务之间彼此独立不能互相等待
34
34
  * @note 任务运行之间如存在先后顺序,请使用 StealThreadPool。
35
35
  * @details
36
- * @ingroup MQThreadPool
36
+ * @ingroup ThreadPool
37
37
  */
38
38
  #ifdef _MSC_VER
39
39
  class MQThreadPool {
@@ -12,13 +12,13 @@
12
12
  #define HKU_VERSION_H
13
13
 
14
14
  // clang-format off
15
- #define HKU_VERSION "2.6.7"
15
+ #define HKU_VERSION "2.6.8"
16
16
  #define HKU_VERSION_MAJOR 2
17
17
  #define HKU_VERSION_MINOR 6
18
- #define HKU_VERSION_ALTER 7
19
- #define HKU_VERSION_BUILD 202508150017
18
+ #define HKU_VERSION_ALTER 8
19
+ #define HKU_VERSION_BUILD 202509070200
20
20
  #define HKU_VERSION_MODE "RELEASE"
21
- #define HKU_VERSION_GIT "2.6.7 release.95439630 (RELEASE)"
21
+ #define HKU_VERSION_GIT "2.6.8 master.4be22a77 (RELEASE)"
22
22
  // clang-format on
23
23
 
24
24
  #endif /* HKU_VERSION_H */
@@ -0,0 +1,38 @@
1
+ /*
2
+ * Copyright (c) 2025 hikyuu.org
3
+ *
4
+ * Created on: 2025-08-15
5
+ * Author: fasiondog
6
+ */
7
+
8
+ #pragma once
9
+
10
+ #include <arrow/api.h>
11
+ #include "hikyuu/config.h"
12
+ #include "hikyuu/utilities/osdef.h"
13
+ #include "hikyuu/utilities/Log.h"
14
+
15
+ namespace hku {
16
+
17
+ /**
18
+ * @ingroup Views
19
+ * @{
20
+ */
21
+
22
+ #if HKU_USE_LOW_PRECISION
23
+ #define HKU_ARROW_PRICE_FIELD arrow::float32()
24
+ #define HKU_ARROW_PRICE_BUILDER arrow::FloatBuilder
25
+ #else
26
+ #define HKU_ARROW_PRICE_FIELD arrow::float64()
27
+ #define HKU_ARROW_PRICE_BUILDER arrow::DoubleBuilder
28
+ #endif
29
+
30
+ /**
31
+ * @brief 打印 arrow table
32
+ * @param table
33
+ * @param max_rows
34
+ */
35
+ void printArrowTable(const std::shared_ptr<arrow::Table>& table, int max_rows = 10);
36
+
37
+ /** @} */
38
+ } // namespace hku