hikyuu 2.6.6__py3-none-win_amd64.whl → 2.6.8__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 (175) hide show
  1. hikyuu/__init__.py +16 -2
  2. hikyuu/__init__.pyi +658 -627
  3. hikyuu/analysis/__init__.pyi +563 -519
  4. hikyuu/analysis/analysis.pyi +583 -541
  5. hikyuu/core.pyi +565 -521
  6. hikyuu/cpp/__init__.pyi +2 -2
  7. hikyuu/cpp/concrt140.dll +0 -0
  8. hikyuu/cpp/core310.pyd +0 -0
  9. hikyuu/cpp/core310.pyi +1424 -865
  10. hikyuu/cpp/core311.pyd +0 -0
  11. hikyuu/cpp/core311.pyi +1424 -865
  12. hikyuu/cpp/core312.pyd +0 -0
  13. hikyuu/cpp/core312.pyi +1424 -865
  14. hikyuu/cpp/core313.pyd +0 -0
  15. hikyuu/cpp/core313.pyi +1424 -863
  16. hikyuu/cpp/core39.pyd +0 -0
  17. hikyuu/cpp/core39.pyi +1424 -865
  18. hikyuu/cpp/hikyuu.dll +0 -0
  19. hikyuu/cpp/hikyuu.lib +0 -0
  20. hikyuu/cpp/hku_hdf5.dll +0 -0
  21. hikyuu/cpp/hku_hdf5_cpp.dll +0 -0
  22. hikyuu/cpp/hku_hdf5_hl.dll +0 -0
  23. hikyuu/cpp/hku_hdf5_hl_cpp.dll +0 -0
  24. hikyuu/cpp/i18n/zh_CN/__init__.py +0 -0
  25. hikyuu/cpp/i18n/zh_CN/hikyuu.mo +0 -0
  26. hikyuu/cpp/msvcp140.dll +0 -0
  27. hikyuu/cpp/msvcp140_1.dll +0 -0
  28. hikyuu/cpp/msvcp140_2.dll +0 -0
  29. hikyuu/cpp/msvcp140_atomic_wait.dll +0 -0
  30. hikyuu/cpp/msvcp140_codecvt_ids.dll +0 -0
  31. hikyuu/cpp/sqlite3.dll +0 -0
  32. hikyuu/cpp/vcruntime140.dll +0 -0
  33. hikyuu/cpp/vcruntime140_1.dll +0 -0
  34. hikyuu/data/common_clickhouse.py +0 -47
  35. hikyuu/data/tdx_to_h5.py +1 -1
  36. hikyuu/draw/drawplot/__init__.pyi +32 -37
  37. hikyuu/draw/drawplot/bokeh_draw.pyi +651 -632
  38. hikyuu/draw/drawplot/common.pyi +3 -4
  39. hikyuu/draw/drawplot/echarts_draw.py +9 -8
  40. hikyuu/draw/drawplot/echarts_draw.pyi +598 -567
  41. hikyuu/draw/drawplot/matplotlib_draw.py +3 -3
  42. hikyuu/draw/drawplot/matplotlib_draw.pyi +872 -874
  43. hikyuu/draw/elder.pyi +19 -20
  44. hikyuu/draw/kaufman.py +1 -1
  45. hikyuu/draw/kaufman.pyi +18 -18
  46. hikyuu/draw/volume.pyi +10 -10
  47. hikyuu/examples/notebook/000-Index.ipynb +1 -1
  48. hikyuu/examples/notebook/001-overview.ipynb +78 -63
  49. hikyuu/examples/notebook/002-HowToGetStock.ipynb +259 -40
  50. hikyuu/examples/notebook/003-HowToGetKDataAndDraw.ipynb +49 -41
  51. hikyuu/examples/notebook/004-IndicatorOverview.ipynb +29 -29
  52. hikyuu/examples/notebook/005-Drawplot.ipynb +66 -37
  53. hikyuu/examples/notebook/006-TradeManager.ipynb +808 -61
  54. hikyuu/examples/notebook/007-SystemDetails.ipynb +23 -23
  55. hikyuu/examples/notebook/009-RealData.ipynb +3 -3
  56. hikyuu/examples/notebook/010-Portfolio.ipynb +761 -122
  57. hikyuu/extend.py +32 -98
  58. hikyuu/extend.pyi +597 -593
  59. hikyuu/gui/HikyuuTDX.py +2 -4
  60. hikyuu/gui/data/MainWindow.py +185 -174
  61. hikyuu/hub.pyi +69 -67
  62. hikyuu/include/hikyuu/DataType.h +3 -12
  63. hikyuu/include/hikyuu/KData.h +83 -25
  64. hikyuu/include/hikyuu/KDataImp.h +31 -46
  65. hikyuu/include/hikyuu/KDataPrivatedBufferImp.h +73 -0
  66. hikyuu/include/hikyuu/KDataSharedBufferImp.h +69 -0
  67. hikyuu/include/hikyuu/KQuery.h +38 -32
  68. hikyuu/include/hikyuu/KRecord.h +4 -1
  69. hikyuu/include/hikyuu/MarketInfo.h +1 -1
  70. hikyuu/include/hikyuu/Stock.h +24 -6
  71. hikyuu/include/hikyuu/StockManager.h +15 -6
  72. hikyuu/include/hikyuu/StockTypeInfo.h +6 -0
  73. hikyuu/include/hikyuu/TransRecord.h +2 -8
  74. hikyuu/include/hikyuu/data_driver/KDataDriver.h +5 -0
  75. hikyuu/include/hikyuu/doc.h +4 -0
  76. hikyuu/include/hikyuu/global/GlobalSpotAgent.h +8 -0
  77. hikyuu/include/hikyuu/global/agent/SpotAgent.h +12 -7
  78. hikyuu/include/hikyuu/indicator/Indicator.h +48 -0
  79. hikyuu/include/hikyuu/indicator/Indicator2InImp.h +9 -0
  80. hikyuu/include/hikyuu/indicator/IndicatorImp.h +83 -15
  81. hikyuu/include/hikyuu/indicator/build_in.h +1 -0
  82. hikyuu/include/hikyuu/indicator/crt/AMA.h +2 -1
  83. hikyuu/include/hikyuu/indicator/crt/ATR.h +1 -1
  84. hikyuu/include/hikyuu/indicator/crt/CONTEXT.h +2 -0
  85. hikyuu/include/hikyuu/indicator/crt/CYCLE.h +3 -0
  86. hikyuu/include/hikyuu/indicator/crt/DMA.h +1 -1
  87. hikyuu/include/hikyuu/indicator/crt/IC.h +14 -6
  88. hikyuu/include/hikyuu/indicator/crt/ICIR.h +8 -4
  89. hikyuu/include/hikyuu/indicator/crt/INSUM.h +2 -0
  90. hikyuu/include/hikyuu/indicator/crt/PRICELIST.h +2 -0
  91. hikyuu/include/hikyuu/indicator/crt/REFX.h +25 -0
  92. hikyuu/include/hikyuu/indicator/crt/SLICE.h +4 -4
  93. hikyuu/include/hikyuu/indicator/crt/SPEARMAN.h +3 -2
  94. hikyuu/include/hikyuu/indicator/imp/IContext.h +5 -0
  95. hikyuu/include/hikyuu/indicator/imp/ICval.h +6 -0
  96. hikyuu/include/hikyuu/indicator/imp/IDropna.h +9 -0
  97. hikyuu/include/hikyuu/indicator/imp/IIc.h +2 -1
  98. hikyuu/include/hikyuu/indicator/imp/IPriceList.h +1 -0
  99. hikyuu/include/hikyuu/indicator/imp/IRefX.h +23 -0
  100. hikyuu/include/hikyuu/lang.h +27 -0
  101. hikyuu/include/hikyuu/plugin/KDataToHdf5Importer.h +6 -1
  102. hikyuu/include/hikyuu/plugin/backtest.h +2 -0
  103. hikyuu/include/hikyuu/plugin/extind.h +45 -0
  104. hikyuu/include/hikyuu/plugin/hkuextra.h +77 -0
  105. hikyuu/include/hikyuu/plugin/interface/HkuExtraPluginInterface.h +54 -0
  106. hikyuu/include/hikyuu/plugin/interface/ImportKDataToHdf5PluginInterface.h +10 -1
  107. hikyuu/include/hikyuu/plugin/interface/TMReportPluginInterface.h +1 -0
  108. hikyuu/include/hikyuu/plugin/interface/plugins.h +2 -0
  109. hikyuu/include/hikyuu/python/pybind_utils.h +28 -11
  110. hikyuu/include/hikyuu/trade_manage/Performance.h +0 -1
  111. hikyuu/include/hikyuu/trade_manage/TradeCostBase.h +5 -0
  112. hikyuu/include/hikyuu/trade_manage/TradeManager.h +4 -0
  113. hikyuu/include/hikyuu/trade_manage/TradeManagerBase.h +10 -1
  114. hikyuu/include/hikyuu/trade_manage/TradeRecord.h +1 -1
  115. hikyuu/include/hikyuu/trade_sys/allocatefunds/AllocateFundsBase.h +5 -0
  116. hikyuu/include/hikyuu/trade_sys/condition/ConditionBase.h +5 -0
  117. hikyuu/include/hikyuu/trade_sys/environment/EnvironmentBase.h +5 -0
  118. hikyuu/include/hikyuu/trade_sys/moneymanager/MoneyManagerBase.h +5 -0
  119. hikyuu/include/hikyuu/trade_sys/multifactor/MultiFactorBase.h +6 -3
  120. hikyuu/include/hikyuu/trade_sys/portfolio/Portfolio.h +4 -0
  121. hikyuu/include/hikyuu/trade_sys/profitgoal/ProfitGoalBase.h +5 -0
  122. hikyuu/include/hikyuu/trade_sys/selector/SelectorBase.h +5 -2
  123. hikyuu/include/hikyuu/trade_sys/signal/SignalBase.h +5 -0
  124. hikyuu/include/hikyuu/trade_sys/slippage/SlippageBase.h +5 -0
  125. hikyuu/include/hikyuu/trade_sys/stoploss/StoplossBase.h +6 -1
  126. hikyuu/include/hikyuu/trade_sys/system/System.h +5 -0
  127. hikyuu/include/hikyuu/utilities/config.h +0 -2
  128. hikyuu/include/hikyuu/utilities/datetime/Datetime.h +2 -2
  129. hikyuu/include/hikyuu/utilities/os.h +7 -0
  130. hikyuu/include/hikyuu/utilities/plugin/PluginLoader.h +2 -1
  131. hikyuu/include/hikyuu/utilities/thread/GlobalMQStealThreadPool.h +1 -1
  132. hikyuu/include/hikyuu/utilities/thread/GlobalMQThreadPool.h +1 -1
  133. hikyuu/include/hikyuu/utilities/thread/GlobalThreadPool.h +1 -1
  134. hikyuu/include/hikyuu/utilities/thread/MQThreadPool.h +1 -1
  135. hikyuu/include/hikyuu/version.h +4 -4
  136. hikyuu/include/hikyuu/views/arrow_common.h +38 -0
  137. hikyuu/include/hikyuu/views/arrow_views.h +117 -0
  138. hikyuu/indicator/__init__.py +0 -1
  139. hikyuu/indicator/indicator.py +17 -57
  140. hikyuu/plugin/backtest.dll +0 -0
  141. hikyuu/plugin/clickhousedriver.dll +0 -0
  142. hikyuu/plugin/dataserver.dll +0 -0
  143. hikyuu/plugin/device.dll +0 -0
  144. hikyuu/plugin/extind.dll +0 -0
  145. hikyuu/plugin/hkuextra.dll +0 -0
  146. hikyuu/plugin/import2hdf5.dll +0 -0
  147. hikyuu/plugin/tmreport.dll +0 -0
  148. hikyuu/strategy/strategy_demo1.py +1 -1
  149. hikyuu/test/test_init.py +73 -14
  150. hikyuu/test/test_real_tdx_import.py +336 -0
  151. hikyuu/test/test_tdx_import.py +315 -0
  152. hikyuu/test/test_tdx_real_data_import.py +281 -0
  153. hikyuu/trade_manage/__init__.pyi +583 -553
  154. hikyuu/trade_manage/broker.pyi +19 -18
  155. hikyuu/trade_manage/broker_easytrader.pyi +6 -4
  156. hikyuu/trade_manage/broker_mail.pyi +22 -24
  157. hikyuu/trade_manage/trade.py +10 -65
  158. hikyuu/trade_manage/trade.pyi +583 -565
  159. hikyuu/trade_sys/__init__.py +15 -0
  160. hikyuu/util/__init__.pyi +0 -1
  161. hikyuu/util/check.pyi +17 -15
  162. hikyuu/util/mylog.pyi +8 -7
  163. hikyuu/util/notebook.pyi +9 -11
  164. hikyuu/util/singleton.pyi +8 -6
  165. {hikyuu-2.6.6.dist-info → hikyuu-2.6.8.dist-info}/METADATA +8 -4
  166. {hikyuu-2.6.6.dist-info → hikyuu-2.6.8.dist-info}/RECORD +172 -160
  167. {hikyuu-2.6.6.dist-info → hikyuu-2.6.8.dist-info}/top_level.txt +2 -1
  168. hikyuu/cpp/i18n/zh_CN.mo +0 -0
  169. hikyuu/include/hikyuu/utilities/mo/mo.h +0 -64
  170. hikyuu/indicator/talib_wrap.py +0 -1273
  171. /hikyuu/include/hikyuu/utilities/{mo/moFileReader.h → moFileReader.h} +0 -0
  172. /hikyuu/include/hikyuu/{utilities/mo → views}/__init__.py +0 -0
  173. {hikyuu-2.6.6.dist-info → hikyuu-2.6.8.dist-info}/LICENSE +0 -0
  174. {hikyuu-2.6.6.dist-info → hikyuu-2.6.8.dist-info}/WHEEL +0 -0
  175. {hikyuu-2.6.6.dist-info → hikyuu-2.6.8.dist-info}/entry_points.txt +0 -0
@@ -0,0 +1,77 @@
1
+ /*
2
+ * Copyright (c) 2025 hikyuu.org
3
+ *
4
+ * Created on: 2025-08-06
5
+ * Author: fasiondog
6
+ */
7
+
8
+ #pragma once
9
+
10
+ #include <arrow/api.h>
11
+ #include "hikyuu/Stock.h"
12
+ #include "hikyuu/indicator/Indicator.h"
13
+
14
+ namespace hku {
15
+
16
+ /**
17
+ * @brief 注册扩展 K 线类型, 按时间合成
18
+ * @param ktype 扩展 K 线类型
19
+ * @param basetype 对应的基础 K 线类型
20
+ * @param minutes 每根K线所包含的分钟数
21
+ * @param getPhaseEnd 获取K线所属的阶段结束时间
22
+ */
23
+ void HKU_API registerExtraKType(const string& ktype, const string& basetype, int32_t minutes,
24
+ std::function<Datetime(const Datetime&)> getPhaseEnd);
25
+
26
+ /**
27
+ * 注册K线扩展类型,按 bar 数量合成
28
+ * @param ktype 扩展 K 线类型
29
+ * @param basetype 对应的基础 K 线类型
30
+ * @param nbars 每根K线所包含的基础K线数
31
+ */
32
+ void HKU_API registerExtraKType(const string& ktype, const string& basetype, int32_t nbars);
33
+
34
+ /**
35
+ * 释放扩展K线
36
+ * @note 某些情况下,注册扩展K线时,使用了 python 定义的周期结束日期转换函数,退出时可能引起 python
37
+ * GIL 报错,需手工提前释放扩展K线
38
+ */
39
+ void HKU_API releaseExtraKType();
40
+
41
+ //-------------------------------
42
+ // 以下函数为内部使用,无需引出
43
+ //-------------------------------
44
+
45
+ bool isExtraKType(const string& ktype);
46
+
47
+ int32_t getKTypeExtraMinutes(const string& ktype);
48
+
49
+ std::vector<string> getExtraKTypeList();
50
+
51
+ KRecordList getExtraKRecordList(const Stock& stk, const KQuery& query);
52
+
53
+ size_t getStockExtraCount(const Stock& stk, const string& ktype);
54
+
55
+ bool getStockExtraIndexRange(const Stock& stk, const KQuery& query, size_t& out_start,
56
+ size_t& out_end);
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
+
77
+ } // namespace hku
@@ -0,0 +1,54 @@
1
+ /*
2
+ * Copyright (c) 2025 hikyuu.org
3
+ *
4
+ * Created on: 2025-05-19
5
+ * Author: fasiondog
6
+ */
7
+
8
+ #pragma once
9
+
10
+ #include <arrow/api.h>
11
+ #include "hikyuu/utilities/plugin/PluginBase.h"
12
+
13
+ namespace hku {
14
+
15
+ class HkuExtraPluginInterface : public PluginBase {
16
+ public:
17
+ HkuExtraPluginInterface() = default;
18
+ virtual ~HkuExtraPluginInterface() = default;
19
+
20
+ virtual void registerKTypeExtra(const string& ktype, const string& basetype, int32_t minutes,
21
+ std::function<Datetime(const Datetime&)> getPhaseEnd) = 0;
22
+
23
+ virtual void releaseKExtra() = 0;
24
+
25
+ virtual bool isExtraKType(const string& ktype) = 0;
26
+
27
+ virtual std::vector<string> getExtraKTypeList() = 0;
28
+
29
+ virtual int32_t getKTypeExtraMinutes(const string& ktype) = 0;
30
+
31
+ virtual KRecordList getExtraKRecordList(const Stock& stk, const KQuery& query) = 0;
32
+
33
+ virtual size_t getStockExtraCount(const Stock& stk, const string& ktype) = 0;
34
+
35
+ virtual bool getStockExtraIndexRange(const Stock& stk, const KQuery& query, size_t& out_start,
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;
52
+ };
53
+
54
+ } // namespace hku
@@ -9,6 +9,8 @@
9
9
 
10
10
  #include "hikyuu/KRecord.h"
11
11
  #include "hikyuu/KQuery.h"
12
+ #include "hikyuu/TimeLineRecord.h"
13
+ #include "hikyuu/TransRecord.h"
12
14
  #include "hikyuu/utilities/plugin/PluginBase.h"
13
15
 
14
16
  namespace hku {
@@ -18,7 +20,8 @@ public:
18
20
  ImportKDataToHdf5PluginInterface() = default;
19
21
  virtual ~ImportKDataToHdf5PluginInterface() = default;
20
22
 
21
- virtual bool setConfig(const string& datapath, const vector<string>& markets) = 0;
23
+ virtual bool setConfig(const string& datapath, const vector<string>& markets,
24
+ const vector<string>& ktypes) = 0;
22
25
 
23
26
  virtual Datetime getLastDatetime(const string& market, const string& code,
24
27
  const KQuery::KType& ktype) = 0;
@@ -26,6 +29,12 @@ public:
26
29
  virtual void addKRecordList(const string& market, const string& code,
27
30
  const vector<KRecord>& krecords, const KQuery::KType& ktype) = 0;
28
31
 
32
+ virtual void addTimeLineList(const string& market, const string& code,
33
+ const TimeLineList& timeline) = 0;
34
+
35
+ virtual void addTransList(const string& market, const string& code,
36
+ const TransRecordList& translist) = 0;
37
+
29
38
  virtual void updateIndex(const string& market, const string& code,
30
39
  const KQuery::KType& ktype) = 0;
31
40
 
@@ -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 "ExtendIndicatorsPluginInterface.h"
15
15
  #include "TMReportPluginInterface.h"
16
16
  #include "DataDriverPluginInterface.h"
17
+ #include "HkuExtraPluginInterface.h"
17
18
 
18
19
  namespace hku {
19
20
 
@@ -24,5 +25,6 @@ namespace hku {
24
25
  #define HKU_PLUGIN_EXTEND_INDICATOR "extind"
25
26
  #define HKU_PLUGIN_TMREPORT "tmreport"
26
27
  #define HKU_PLUGIN_CLICKHOUSE_DRIVER "clickhousedriver"
28
+ #define HKU_PLUGIN_HKU_EXTRA "hkuextra"
27
29
 
28
30
  }
@@ -54,10 +54,11 @@ std::vector<T> python_bytes_to_vector(const py::bytes& obj) {
54
54
 
55
55
  template <typename T>
56
56
  std::vector<T> python_list_to_vector(const py::sequence& obj) {
57
+ // 如果 len(obj) 长度为零,即使类型不是所期望的也可能成功,但无风险
57
58
  auto total = len(obj);
58
59
  std::vector<T> vect(total);
59
60
  for (auto i = 0; i < total; ++i) {
60
- vect[i] = obj[i].cast<T>();
61
+ vect[i] = py::cast<T>(obj[i]);
61
62
  }
62
63
  return vect;
63
64
  }
@@ -86,16 +87,23 @@ std::string to_py_str(const T& item) {
86
87
  // 直接使用 pybind11 重载 _clone,在 C++ 中会丢失 python 中的类型
87
88
  // 参考:https://github.com/pybind/pybind11/issues/1049 进行修改
88
89
  // 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); \
90
+ #define PY_CLONE(pyclassname, classname) \
91
+ public: \
92
+ std::shared_ptr<classname> _clone() override { \
93
+ if (isPythonObject()) { \
94
+ py::gil_scoped_acquire acquire; \
95
+ auto self = py::cast(this); \
96
+ auto cloned = self.attr("_clone")(); \
97
+ auto keep_python_state_alive = std::make_shared<py::object>(cloned); \
98
+ auto ptr = cloned.cast<pyclassname*>(); \
99
+ return std::shared_ptr<classname>(keep_python_state_alive, ptr); \
100
+ } \
101
+ return this->_clone(); \
102
+ } \
103
+ \
104
+ protected: \
105
+ inline bool isPythonObject() const override { \
106
+ return true; \
99
107
  }
100
108
 
101
109
  // 用于检查已 py::object 方式传递的函数参数个数是否符合预期
@@ -106,6 +114,15 @@ inline bool check_pyfunction_arg_num(py::object& func, size_t arg_num) {
106
114
  return len(params) == arg_num;
107
115
  }
108
116
 
117
+ /*
118
+ * 将utf8编码的字符串转换为utf32编码
119
+ * @param utf8_str 待转换的字符串
120
+ * @param out 存储转换结果的数组(需自行预先分配内存)
121
+ * @param out_len out数组的长度
122
+ * @return 实际转码点数
123
+ */
124
+ size_t utf8_to_utf32(const std::string& utf8_str, int32_t* out, size_t out_len) noexcept;
125
+
109
126
  } // namespace hku
110
127
 
111
128
  #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; // 成本算法
@@ -84,7 +84,7 @@ public:
84
84
  price_t stoploss; ///< 止损价
85
85
  price_t cash; ///< 现金余额
86
86
  SystemPart from; ///< 辅助记录交易系统部件,区别是哪个部件发出的指示,Null<int>()表示无效
87
- string remark; ///< 备注
87
+ string remark; ///< 备注(最大100编码字符)
88
88
 
89
89
  #if HKU_SUPPORT_SERIALIZATION
90
90
  private:
@@ -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);
@@ -28,8 +28,6 @@
28
28
  #define HKU_USE_SPDLOG_ASYNC_LOGGER 0
29
29
  #define HKU_LOG_ACTIVE_LEVEL 2
30
30
 
31
- #define HKU_ENABLE_MO 1
32
-
33
31
  #define HKU_ENABLE_HTTP_CLIENT 1
34
32
  #define HKU_ENABLE_HTTP_CLIENT_SSL 0
35
33
  #define HKU_ENABLE_HTTP_CLIENT_ZIP 0
@@ -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
  * 转化为字符串,供打印阅读,格式:
@@ -105,4 +105,11 @@ std::string HKU_UTILS_API getPlatform();
105
105
  /** 获取当前CPU架构名称 */
106
106
  std::string HKU_UTILS_API getCpuArch();
107
107
 
108
+ /** 获取当前系统语言名称(全部小写返回) */
109
+ std::string HKU_UTILS_API getSystemLanguage();
110
+
111
+ uint64_t HKU_UTILS_API getMemoryMaxSize();
112
+
113
+ uint64_t HKU_UTILS_API getMemoryIdleSize();
114
+
108
115
  } // namespace hku
@@ -46,7 +46,8 @@ public:
46
46
 
47
47
  bool load(const std::string& pluginname) noexcept {
48
48
  std::string filename = getFileName(pluginname);
49
- HKU_WARN_IF_RETURN(!existFile(filename), false, "file({}) not exist!", filename);
49
+ // HKU_WARN_IF_RETURN(!existFile(filename), false, "file({}) not exist!", filename);
50
+ HKU_DEBUG_IF_RETURN(!existFile(filename), false, "file({}) not exist!", filename);
50
51
 
51
52
  #if HKU_OS_WINDOWS
52
53
  m_handle = LoadLibrary(HKU_PATH(filename).c_str());
@@ -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 {