hikyuu 2.6.6__py3-none-win_amd64.whl → 2.6.7__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 (105) hide show
  1. hikyuu/__init__.py +10 -0
  2. hikyuu/__init__.pyi +567 -560
  3. hikyuu/analysis/__init__.pyi +539 -519
  4. hikyuu/analysis/analysis.pyi +540 -520
  5. hikyuu/core.pyi +541 -521
  6. hikyuu/cpp/__init__.pyi +2 -2
  7. hikyuu/cpp/core310.pyd +0 -0
  8. hikyuu/cpp/core310.pyi +1041 -859
  9. hikyuu/cpp/core311.pyd +0 -0
  10. hikyuu/cpp/core311.pyi +1041 -859
  11. hikyuu/cpp/core312.pyd +0 -0
  12. hikyuu/cpp/core312.pyi +1041 -859
  13. hikyuu/cpp/core313.pyd +0 -0
  14. hikyuu/cpp/core313.pyi +1041 -857
  15. hikyuu/cpp/core39.pyd +0 -0
  16. hikyuu/cpp/core39.pyi +1041 -859
  17. hikyuu/cpp/hikyuu.dll +0 -0
  18. hikyuu/cpp/hikyuu.lib +0 -0
  19. hikyuu/cpp/i18n/zh_CN/__init__.py +0 -0
  20. hikyuu/cpp/i18n/zh_CN/hikyuu.mo +0 -0
  21. hikyuu/cpp/sqlite3.dll +0 -0
  22. hikyuu/data/common_clickhouse.py +0 -47
  23. hikyuu/data/tdx_to_h5.py +1 -1
  24. hikyuu/draw/__init__.pyi +1 -1
  25. hikyuu/draw/drawplot/__init__.pyi +9 -9
  26. hikyuu/draw/drawplot/bokeh_draw.pyi +556 -551
  27. hikyuu/draw/drawplot/common.pyi +1 -1
  28. hikyuu/draw/drawplot/echarts_draw.py +9 -8
  29. hikyuu/draw/drawplot/echarts_draw.pyi +558 -553
  30. hikyuu/draw/drawplot/matplotlib_draw.py +3 -3
  31. hikyuu/draw/drawplot/matplotlib_draw.pyi +568 -563
  32. hikyuu/draw/elder.pyi +11 -11
  33. hikyuu/draw/kaufman.py +1 -1
  34. hikyuu/draw/kaufman.pyi +18 -18
  35. hikyuu/draw/volume.pyi +10 -10
  36. hikyuu/examples/notebook/000-Index.ipynb +1 -1
  37. hikyuu/examples/notebook/001-overview.ipynb +78 -63
  38. hikyuu/examples/notebook/002-HowToGetStock.ipynb +259 -40
  39. hikyuu/examples/notebook/003-HowToGetKDataAndDraw.ipynb +49 -41
  40. hikyuu/examples/notebook/004-IndicatorOverview.ipynb +29 -29
  41. hikyuu/examples/notebook/005-Drawplot.ipynb +66 -37
  42. hikyuu/examples/notebook/006-TradeManager.ipynb +808 -61
  43. hikyuu/examples/notebook/007-SystemDetails.ipynb +23 -23
  44. hikyuu/examples/notebook/009-RealData.ipynb +3 -3
  45. hikyuu/examples/notebook/010-Portfolio.ipynb +761 -122
  46. hikyuu/extend.py +15 -100
  47. hikyuu/extend.pyi +551 -567
  48. hikyuu/gui/HikyuuTDX.py +2 -4
  49. hikyuu/gui/data/MainWindow.py +185 -174
  50. hikyuu/hub.pyi +6 -6
  51. hikyuu/include/hikyuu/DataType.h +1 -10
  52. hikyuu/include/hikyuu/KQuery.h +22 -28
  53. hikyuu/include/hikyuu/MarketInfo.h +1 -1
  54. hikyuu/include/hikyuu/Stock.h +15 -3
  55. hikyuu/include/hikyuu/StockManager.h +4 -3
  56. hikyuu/include/hikyuu/StockTypeInfo.h +6 -0
  57. hikyuu/include/hikyuu/TransRecord.h +2 -8
  58. hikyuu/include/hikyuu/doc.h +4 -0
  59. hikyuu/include/hikyuu/indicator/Indicator.h +37 -0
  60. hikyuu/include/hikyuu/lang.h +27 -0
  61. hikyuu/include/hikyuu/plugin/KDataToHdf5Importer.h +6 -1
  62. hikyuu/include/hikyuu/plugin/hkuextra.h +56 -0
  63. hikyuu/include/hikyuu/plugin/interface/HkuExtraPluginInterface.h +38 -0
  64. hikyuu/include/hikyuu/plugin/interface/ImportKDataToHdf5PluginInterface.h +10 -1
  65. hikyuu/include/hikyuu/plugin/interface/plugins.h +2 -0
  66. hikyuu/include/hikyuu/python/pybind_utils.h +9 -0
  67. hikyuu/include/hikyuu/trade_manage/TradeRecord.h +1 -1
  68. hikyuu/include/hikyuu/utilities/config.h +0 -2
  69. hikyuu/include/hikyuu/utilities/os.h +3 -0
  70. hikyuu/include/hikyuu/utilities/plugin/PluginLoader.h +2 -1
  71. hikyuu/include/hikyuu/version.h +4 -4
  72. hikyuu/include/hikyuu/view/MarketView.h +59 -0
  73. hikyuu/indicator/__init__.py +0 -1
  74. hikyuu/indicator/indicator.py +14 -53
  75. hikyuu/plugin/backtest.dll +0 -0
  76. hikyuu/plugin/clickhousedriver.dll +0 -0
  77. hikyuu/plugin/dataserver.dll +0 -0
  78. hikyuu/plugin/device.dll +0 -0
  79. hikyuu/plugin/extind.dll +0 -0
  80. hikyuu/plugin/hkuextra.dll +0 -0
  81. hikyuu/plugin/import2hdf5.dll +0 -0
  82. hikyuu/plugin/tmreport.dll +0 -0
  83. hikyuu/test/test_init.py +59 -0
  84. hikyuu/test/test_real_tdx_import.py +336 -0
  85. hikyuu/test/test_tdx_import.py +315 -0
  86. hikyuu/test/test_tdx_real_data_import.py +281 -0
  87. hikyuu/trade_manage/__init__.pyi +556 -551
  88. hikyuu/trade_manage/broker.pyi +3 -3
  89. hikyuu/trade_manage/broker_easytrader.pyi +1 -1
  90. hikyuu/trade_manage/trade.py +4 -65
  91. hikyuu/trade_manage/trade.pyi +556 -563
  92. hikyuu/trade_sys/__init__.py +11 -0
  93. hikyuu/util/__init__.pyi +0 -1
  94. hikyuu/util/singleton.pyi +1 -1
  95. {hikyuu-2.6.6.dist-info → hikyuu-2.6.7.dist-info}/METADATA +6 -4
  96. {hikyuu-2.6.6.dist-info → hikyuu-2.6.7.dist-info}/RECORD +102 -95
  97. {hikyuu-2.6.6.dist-info → hikyuu-2.6.7.dist-info}/top_level.txt +2 -1
  98. hikyuu/cpp/i18n/zh_CN.mo +0 -0
  99. hikyuu/include/hikyuu/utilities/mo/mo.h +0 -64
  100. hikyuu/indicator/talib_wrap.py +0 -1273
  101. /hikyuu/include/hikyuu/utilities/{mo/moFileReader.h → moFileReader.h} +0 -0
  102. /hikyuu/include/hikyuu/{utilities/mo → view}/__init__.py +0 -0
  103. {hikyuu-2.6.6.dist-info → hikyuu-2.6.7.dist-info}/LICENSE +0 -0
  104. {hikyuu-2.6.6.dist-info → hikyuu-2.6.7.dist-info}/WHEEL +0 -0
  105. {hikyuu-2.6.6.dist-info → hikyuu-2.6.7.dist-info}/entry_points.txt +0 -0
hikyuu/hub.pyi CHANGED
@@ -28,11 +28,11 @@ import sys as sys
28
28
  import typing
29
29
  __all__: list = ['add_remote_hub', 'add_local_hub', 'update_hub', 'remove_hub', 'build_hub', 'help_part', 'get_part', 'get_part_list', 'get_hub_path', 'get_part_info', 'get_part_module', 'print_part_info', 'get_hub_name_list', 'get_part_name_list', 'get_current_hub', 'search_part']
30
30
  class ConfigModel(sqlalchemy.orm.decl_api.Base):
31
- __mapper__: typing.ClassVar[sqlalchemy.orm.mapper.Mapper] # value = <Mapper at 0x1fc04455310; ConfigModel>
31
+ __mapper__: typing.ClassVar[sqlalchemy.orm.mapper.Mapper] # value = <Mapper at 0x2b0b2e13af0; ConfigModel>
32
32
  __table__: typing.ClassVar[sqlalchemy.sql.schema.Table] # value = Table('hub_config', MetaData(), Column('id', Integer(), table=<hub_config>, primary_key=True, nullable=False, default=Sequence('config_id_seq', metadata=MetaData())), Column('key', String(), table=<hub_config>), Column('value', String(), table=<hub_config>), schema=None)
33
33
  __table_args__: typing.ClassVar[tuple] # value = (UniqueConstraint(Column('key', String(), table=<hub_config>)))
34
34
  __tablename__: typing.ClassVar[str] = 'hub_config'
35
- _sa_class_manager: typing.ClassVar[sqlalchemy.orm.instrumentation.ClassManager] # value = <ClassManager of <class 'hikyuu.hub.ConfigModel'> at 1fc046b1590>
35
+ _sa_class_manager: typing.ClassVar[sqlalchemy.orm.instrumentation.ClassManager] # value = <ClassManager of <class 'hikyuu.hub.ConfigModel'> at 2b0b2e14ef0>
36
36
  def __init__(self, **kwargs):
37
37
  """
38
38
  A simple constructor that allows initialization from kwargs.
@@ -109,11 +109,11 @@ class HubManager:
109
109
  def print_part_info(self, name):
110
110
  ...
111
111
  class HubModel(sqlalchemy.orm.decl_api.Base):
112
- __mapper__: typing.ClassVar[sqlalchemy.orm.mapper.Mapper] # value = <Mapper at 0x1fc04693590; HubModel>
112
+ __mapper__: typing.ClassVar[sqlalchemy.orm.mapper.Mapper] # value = <Mapper at 0x2b0b2e13c70; HubModel>
113
113
  __table__: typing.ClassVar[sqlalchemy.sql.schema.Table] # value = Table('hub_repo', MetaData(), Column('id', Integer(), table=<hub_repo>, primary_key=True, nullable=False, default=Sequence('remote_id_seq', metadata=MetaData())), Column('name', String(), table=<hub_repo>), Column('hub_type', String(), table=<hub_repo>), Column('local_base', String(), table=<hub_repo>), Column('local', String(), table=<hub_repo>), Column('url', String(), table=<hub_repo>), Column('branch', String(), table=<hub_repo>), schema=None)
114
114
  __table_args__: typing.ClassVar[tuple] # value = (UniqueConstraint(Column('name', String(), table=<hub_repo>)))
115
115
  __tablename__: typing.ClassVar[str] = 'hub_repo'
116
- _sa_class_manager: typing.ClassVar[sqlalchemy.orm.instrumentation.ClassManager] # value = <ClassManager of <class 'hikyuu.hub.HubModel'> at 1fc046c9ef0>
116
+ _sa_class_manager: typing.ClassVar[sqlalchemy.orm.instrumentation.ClassManager] # value = <ClassManager of <class 'hikyuu.hub.HubModel'> at 2b0b2e429a0>
117
117
  def __init__(self, **kwargs):
118
118
  """
119
119
  A simple constructor that allows initialization from kwargs.
@@ -146,11 +146,11 @@ class ModuleConflictError(Exception):
146
146
  def __str__(self):
147
147
  ...
148
148
  class PartModel(sqlalchemy.orm.decl_api.Base):
149
- __mapper__: typing.ClassVar[sqlalchemy.orm.mapper.Mapper] # value = <Mapper at 0x1fc0322b3b0; PartModel>
149
+ __mapper__: typing.ClassVar[sqlalchemy.orm.mapper.Mapper] # value = <Mapper at 0x2b0b2e507c0; PartModel>
150
150
  __table__: typing.ClassVar[sqlalchemy.sql.schema.Table] # value = Table('hub_part', MetaData(), Column('id', Integer(), table=<hub_part>, primary_key=True, nullable=False, default=Sequence('part_id_seq', metadata=MetaData())), Column('hub_name', String(), table=<hub_part>), Column('part', String(), table=<hub_part>), Column('name', String(), table=<hub_part>), Column('author', String(), table=<hub_part>), Column('version', String(), table=<hub_part>), Column('doc', String(), table=<hub_part>), Column('module_name', String(), table=<hub_part>), Column('label', String(), table=<hub_part>), schema=None)
151
151
  __table_args__: typing.ClassVar[tuple] # value = (UniqueConstraint(Column('name', String(), table=<hub_part>)))
152
152
  __tablename__: typing.ClassVar[str] = 'hub_part'
153
- _sa_class_manager: typing.ClassVar[sqlalchemy.orm.instrumentation.ClassManager] # value = <ClassManager of <class 'hikyuu.hub.PartModel'> at 1fc046caa80>
153
+ _sa_class_manager: typing.ClassVar[sqlalchemy.orm.instrumentation.ClassManager] # value = <ClassManager of <class 'hikyuu.hub.PartModel'> at 2b0b2e52400>
154
154
  def __init__(self, **kwargs):
155
155
  """
156
156
  A simple constructor that allows initialization from kwargs.
@@ -40,10 +40,7 @@
40
40
  #include "utilities/arithmetic.h"
41
41
  #include "utilities/SpendTimer.h"
42
42
  #include "utilities/config.h"
43
-
44
- #if HKU_ENABLE_MO
45
- #include "utilities/mo/mo.h"
46
- #endif
43
+ #include "lang.h"
47
44
 
48
45
  #if HKU_SUPPORT_SERIALIZATION
49
46
  #include <boost/serialization/nvp.hpp>
@@ -149,12 +146,6 @@ using std::vector;
149
146
  typedef vector<price_t> PriceList;
150
147
  typedef vector<string> StringList;
151
148
 
152
- #if HKU_ENABLE_MO
153
- using mo::_tr;
154
- #else
155
- #define _tr(x) x
156
- #endif
157
-
158
149
  using std::isfinite;
159
150
  using std::isinf;
160
151
  using std::isnan;
@@ -26,56 +26,50 @@ public:
26
26
  INVALID = 2
27
27
  };
28
28
 
29
- /// 查询K线类型:日线/周线等
30
- /*enum KType {
31
- //notes: 如添加新类型,请注意按大小顺序添加,否则可能出错
32
- MIN = 0, ///<1分钟线
33
- MIN5 = 1, ///<5分钟线
34
- MIN15 = 2, ///<15分钟线
35
- MIN30 = 3, ///<30分钟线
36
- MIN60 = 4, ///<60分钟线
37
- DAY = 5, ///<日线
38
- WEEK = 6, ///<周线
39
- MONTH = 7, ///<月线
40
- QUARTER = 8, ///<季线
41
- HALFYEAR = 9, ///<半年线
42
- YEAR = 10, ///<年线
43
-
44
- //BTC扩展
45
- MIN3 = 11, ///<3分钟线
46
- HOUR2 = 12, ///<2小时线
47
- HOUR4 = 13, ///<4小时线
48
- HOUR6 = 14, ///<6小时线
49
- HOUR12 = 15, ///<12小时线
50
- INVALID_KTYPE = 16
51
- };*/
52
29
  typedef string KType;
53
30
 
31
+ // 基础K线类型
54
32
  static const string MIN;
55
33
  static const string MIN5;
56
34
  static const string MIN15;
57
35
  static const string MIN30;
58
36
  static const string MIN60;
37
+ static const string HOUR2;
59
38
  static const string DAY;
60
39
  static const string WEEK;
61
40
  static const string MONTH;
62
41
  static const string QUARTER;
63
42
  static const string HALFYEAR;
64
43
  static const string YEAR;
44
+
45
+ // 扩展K线类型
46
+ static const string DAY3;
47
+ static const string DAY5;
48
+ static const string DAY7;
65
49
  static const string MIN3;
66
- static const string HOUR2;
67
50
  static const string HOUR4;
68
51
  static const string HOUR6;
69
52
  static const string HOUR12;
70
53
  // static const string INVALID_KTYPE;
71
54
 
55
+ /** 判断指定的K线类型是否有效 */
56
+ static bool isValidKType(const string& ktype);
57
+
58
+ /** 判断是否为有效 ktype */
59
+ static bool isBaseKType(const string& ktype);
60
+
61
+ /** 判断是否为扩展 ktype */
62
+ static bool isExtraKType(const string& ktype);
63
+
72
64
  /** 获取所有的 KType */
73
- static const vector<KType>& getAllKType();
65
+ static vector<KType> getBaseKTypeList();
74
66
 
75
- static int32_t getKTypeInMin(KType);
67
+ /** 获取所有扩展 KType */
68
+ static vector<KType> getExtraKTypeList();
76
69
 
77
- /** 判断是否为有效 ktype */
78
- static bool isKType(const string& ktype);
70
+ static int32_t getKTypeInMin(const KType& ktype);
71
+
72
+ static int32_t getBaseKTypeInMin(const KType& ktype);
79
73
 
80
74
  /**
81
75
  * 复权类型
@@ -41,7 +41,7 @@ public:
41
41
  MarketInfo& operator=(const MarketInfo&) = default;
42
42
 
43
43
  MarketInfo(MarketInfo&&);
44
- MarketInfo& operator=(MarketInfo&&);
44
+ MarketInfo& operator=(MarketInfo&&) noexcept;
45
45
 
46
46
  /** 获取市场简称 */
47
47
  const string& market() const {
@@ -230,10 +230,10 @@ public:
230
230
  * 将K线数据做自身缓存
231
231
  * @note 一般不主动调用,谨慎
232
232
  */
233
- void loadKDataToBuffer(KQuery::KType);
233
+ void loadKDataToBuffer(KQuery::KType) const;
234
234
 
235
235
  /** 释放对应的K线缓存 */
236
- void releaseKDataBuffer(KQuery::KType);
236
+ void releaseKDataBuffer(KQuery::KType) const;
237
237
 
238
238
  /** 指定类型的K线数据是否被缓存 */
239
239
  bool isBuffer(KQuery::KType) const;
@@ -258,12 +258,19 @@ private:
258
258
  bool _getIndexRangeByIndex(const KQuery&, size_t& out_start, size_t& out_end) const;
259
259
 
260
260
  // 以下函数属于基础操作添加了读锁
261
- size_t _getCountFromBuffer(KQuery::KType ktype) const;
261
+ size_t _getCountFromBuffer(const KQuery::KType& ktype) const;
262
262
  KRecord _getKRecordFromBuffer(size_t pos, const KQuery::KType& ktype) const;
263
263
  KRecordList _getKRecordListFromBuffer(size_t start_ix, size_t end_ix,
264
264
  KQuery::KType ktype) const;
265
265
  bool _getIndexRangeByDateFromBuffer(const KQuery&, size_t&, size_t&) const;
266
266
 
267
+ KRecordList _getKRecordList(const KQuery& query) const;
268
+
269
+ // 仅供 StockManager 初始化时调用
270
+ void setPreload(vector<KQuery::KType>& preload_ktypes);
271
+
272
+ bool isPreload(KQuery::KType ktype) const;
273
+
267
274
  private:
268
275
  struct HKU_API Data;
269
276
  shared_ptr<Data> m_data;
@@ -295,6 +302,7 @@ struct HKU_API Stock::Data {
295
302
  double m_minTradeNumber;
296
303
  double m_maxTradeNumber;
297
304
 
305
+ std::unordered_set<string> m_ktype_preload; // 记录当前证券的K线数据是否需要预加载
298
306
  unordered_map<string, KRecordList*> pKData;
299
307
  unordered_map<string, std::shared_mutex*> pMutex;
300
308
 
@@ -338,6 +346,10 @@ inline bool Stock::operator!=(const Stock& stock) const {
338
346
  return !(*this == stock);
339
347
  }
340
348
 
349
+ inline bool Stock::isNull() const {
350
+ return !m_data || !m_kdataDriver;
351
+ }
352
+
341
353
  } // namespace hku
342
354
 
343
355
  namespace std {
@@ -22,8 +22,6 @@
22
22
 
23
23
  namespace hku {
24
24
 
25
- typedef vector<string> MarketList;
26
-
27
25
  /**
28
26
  * 证券信息统一管理类
29
27
  * @ingroup StockManage
@@ -126,8 +124,11 @@ public:
126
124
  */
127
125
  StockTypeInfo getStockTypeInfo(uint32_t type) const;
128
126
 
127
+ /** 获取所有证券类型信息 */
128
+ vector<StockTypeInfo> getStockTypeInfoList() const;
129
+
129
130
  /** 获取市场简称列表 */
130
- MarketList getAllMarket() const;
131
+ StringList getAllMarket() const;
131
132
 
132
133
  /**
133
134
  * 获取预定义的板块
@@ -38,6 +38,12 @@ public:
38
38
  StockTypeInfo();
39
39
  StockTypeInfo(uint32_t, const string&, price_t, price_t, int, double, double);
40
40
 
41
+ StockTypeInfo(const StockTypeInfo&) = default;
42
+ StockTypeInfo& operator=(const StockTypeInfo&) = default;
43
+
44
+ StockTypeInfo(StockTypeInfo&&);
45
+ StockTypeInfo& operator=(StockTypeInfo&&) noexcept;
46
+
41
47
  /** 获取证券类型 */
42
48
  uint32_t type() const {
43
49
  return m_type;
@@ -19,19 +19,13 @@ namespace hku {
19
19
  */
20
20
  class HKU_API TransRecord {
21
21
  public:
22
- enum DIRECT {
23
- BUY = 0, /**< 买盘 */
24
- SELL = 1, /**< 卖盘 */
25
- AUCTION = 2 /**< 集合竞价 */
26
- };
27
-
28
22
  Datetime datetime; // 时间
29
23
  price_t price; // 成交均价
30
24
  price_t vol; // 成交量
31
- DIRECT direct; // 买卖盘性质:1--sell 0--buy 2--集合竞价
25
+ int direct; // 买卖盘性质:1--sell 0--buy 2--集合竞价 其他未知
32
26
 
33
27
  TransRecord();
34
- TransRecord(const Datetime& datetime, price_t price, price_t vol, DIRECT);
28
+ TransRecord(const Datetime& datetime, price_t price, price_t vol, int direct);
35
29
 
36
30
  bool isValid() const;
37
31
  };
@@ -156,6 +156,10 @@
156
156
  *
157
157
  * @defgroup ThreadPool Thread Pool 线程池
158
158
  * @ingroup Utilities
159
+ *
160
+ * @defgroup View View数据视图
161
+ * 数据视图, 属于用于显示、打印数据
162
+ * @ingroup View
159
163
  */
160
164
 
161
165
  /**
@@ -205,6 +205,43 @@ public:
205
205
 
206
206
  string str() const;
207
207
 
208
+ public:
209
+ class Iterator {
210
+ private:
211
+ const Indicator& container;
212
+ size_t index;
213
+
214
+ public:
215
+ Iterator(const Indicator& cont, size_t idx) : container(cont), index(idx) {}
216
+
217
+ Iterator& operator++() {
218
+ index++;
219
+ return *this;
220
+ }
221
+
222
+ value_t operator*() const {
223
+ return container.get(index);
224
+ }
225
+
226
+ bool operator!=(const Iterator& other) const {
227
+ return index != other.index;
228
+ }
229
+
230
+ bool operator==(const Iterator& other) const {
231
+ return index == other.index;
232
+ }
233
+ };
234
+
235
+ Iterator begin() const {
236
+ return Iterator(*this, 0);
237
+ }
238
+
239
+ Iterator end() const {
240
+ return Iterator(*this, size());
241
+ }
242
+
243
+ typedef Iterator iterator;
244
+
208
245
  protected:
209
246
  IndicatorImpPtr m_imp;
210
247
 
@@ -0,0 +1,27 @@
1
+ /*
2
+ * Copyright (c) 2025 hikyuu.org
3
+ *
4
+ * Created on: 2025-08-09
5
+ * Author: fasiondog
6
+ */
7
+
8
+ #pragma once
9
+
10
+ #include <string>
11
+
12
+ #ifndef HKU_API
13
+ #define HKU_API
14
+ #endif
15
+
16
+ namespace hku {
17
+
18
+ // 注意仅在 hikyuu 相关项目内部使用,避免对项目造成污染
19
+
20
+ void loadLocalLanguage(const std::string &path = "i8n");
21
+
22
+ std::string HKU_API htr(const char *id);
23
+
24
+ // 按上下文获取翻译
25
+ std::string HKU_API hctr(const char *ctx, const char *id);
26
+
27
+ } // namespace hku
@@ -17,13 +17,18 @@ public:
17
17
  KDataToHdf5Importer();
18
18
  virtual ~KDataToHdf5Importer();
19
19
 
20
- bool setConfig(const string& datapath, const vector<string>& markets = {"SH", "SZ", "BJ"});
20
+ bool setConfig(const string& datapath, const vector<string>& markets = {"SH", "SZ", "BJ"},
21
+ const vector<string>& ktypes = {"DAY", "MIN", "MIN5", "TIMELINE", "TRANSDATA"});
21
22
 
22
23
  Datetime getLastDatetime(const string& market, const string& code, const KQuery::KType& ktype);
23
24
 
24
25
  void addKRecordList(const string& market, const string& code, const vector<KRecord>& krecords,
25
26
  const KQuery::KType& ktype);
26
27
 
28
+ void addTimeLineList(const string& market, const string& code, const TimeLineList& timeline);
29
+
30
+ void addTransList(const string& market, const string& code, const TransRecordList& translist);
31
+
27
32
  void updateIndex(const string& market, const string& code, const KQuery::KType& ktype);
28
33
 
29
34
  void remove(const string& market, const string& code, const KQuery::KType& ktype,
@@ -0,0 +1,56 @@
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 "hikyuu/Stock.h"
11
+
12
+ namespace hku {
13
+
14
+ /**
15
+ * @brief 注册扩展 K 线类型, 按时间合成
16
+ * @param ktype 扩展 K 线类型
17
+ * @param basetype 对应的基础 K 线类型
18
+ * @param minutes 每根K线所包含的分钟数
19
+ * @param getPhaseEnd 获取K线所属的阶段结束时间
20
+ */
21
+ void HKU_API registerExtraKType(const string& ktype, const string& basetype, int32_t minutes,
22
+ std::function<Datetime(const Datetime&)> getPhaseEnd);
23
+
24
+ /**
25
+ * 注册K线扩展类型,按 bar 数量合成
26
+ * @param ktype 扩展 K 线类型
27
+ * @param basetype 对应的基础 K 线类型
28
+ * @param nbars 每根K线所包含的基础K线数
29
+ */
30
+ void HKU_API registerExtraKType(const string& ktype, const string& basetype, int32_t nbars);
31
+
32
+ /**
33
+ * 释放扩展K线
34
+ * @note 某些情况下,注册扩展K线时,使用了 python 定义的周期结束日期转换函数,退出时可能引起 python
35
+ * GIL 报错,需手工提前释放扩展K线
36
+ */
37
+ void HKU_API releaseExtraKType();
38
+
39
+ //-------------------------------
40
+ // 以下函数为内部使用,无需引出
41
+ //-------------------------------
42
+
43
+ bool isExtraKType(const string& ktype);
44
+
45
+ int32_t getKTypeExtraMinutes(const string& ktype);
46
+
47
+ std::vector<string> getExtraKTypeList();
48
+
49
+ KRecordList getExtraKRecordList(const Stock& stk, const KQuery& query);
50
+
51
+ size_t getStockExtraCount(const Stock& stk, const string& ktype);
52
+
53
+ bool getStockExtraIndexRange(const Stock& stk, const KQuery& query, size_t& out_start,
54
+ size_t& out_end);
55
+
56
+ } // namespace hku
@@ -0,0 +1,38 @@
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 "hikyuu/utilities/plugin/PluginBase.h"
11
+
12
+ namespace hku {
13
+
14
+ class HkuExtraPluginInterface : public PluginBase {
15
+ public:
16
+ HkuExtraPluginInterface() = default;
17
+ virtual ~HkuExtraPluginInterface() = default;
18
+
19
+ virtual void registerKTypeExtra(const string& ktype, const string& basetype, int32_t minutes,
20
+ std::function<Datetime(const Datetime&)> getPhaseEnd) = 0;
21
+
22
+ virtual void releaseKExtra() = 0;
23
+
24
+ virtual bool isExtraKType(const string& ktype) = 0;
25
+
26
+ virtual std::vector<string> getExtraKTypeList() = 0;
27
+
28
+ virtual int32_t getKTypeExtraMinutes(const string& ktype) = 0;
29
+
30
+ virtual KRecordList getExtraKRecordList(const Stock& stk, const KQuery& query) = 0;
31
+
32
+ virtual size_t getStockExtraCount(const Stock& stk, const string& ktype) = 0;
33
+
34
+ virtual bool getStockExtraIndexRange(const Stock& stk, const KQuery& query, size_t& out_start,
35
+ size_t& out_end) = 0;
36
+ };
37
+
38
+ } // 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
 
@@ -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
  }
@@ -106,6 +106,15 @@ inline bool check_pyfunction_arg_num(py::object& func, size_t arg_num) {
106
106
  return len(params) == arg_num;
107
107
  }
108
108
 
109
+ /*
110
+ * 将utf8编码的字符串转换为utf32编码
111
+ * @param utf8_str 待转换的字符串
112
+ * @param out 存储转换结果的数组(需自行预先分配内存)
113
+ * @param out_len out数组的长度
114
+ * @return 实际转码点数
115
+ */
116
+ size_t utf8_to_utf32(const std::string& utf8_str, int32_t* out, size_t out_len) noexcept;
117
+
109
118
  } // namespace hku
110
119
 
111
120
  #endif // HIKYUU_PYTHON_BIND_UTILS_H
@@ -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:
@@ -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
@@ -105,4 +105,7 @@ 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
+
108
111
  } // 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());
@@ -12,13 +12,13 @@
12
12
  #define HKU_VERSION_H
13
13
 
14
14
  // clang-format off
15
- #define HKU_VERSION "2.6.6"
15
+ #define HKU_VERSION "2.6.7"
16
16
  #define HKU_VERSION_MAJOR 2
17
17
  #define HKU_VERSION_MINOR 6
18
- #define HKU_VERSION_ALTER 6
19
- #define HKU_VERSION_BUILD 202507291558
18
+ #define HKU_VERSION_ALTER 7
19
+ #define HKU_VERSION_BUILD 202508150017
20
20
  #define HKU_VERSION_MODE "RELEASE"
21
- #define HKU_VERSION_GIT "2.6.6 master.c4a12bf4 (RELEASE)"
21
+ #define HKU_VERSION_GIT "2.6.7 release.95439630 (RELEASE)"
22
22
  // clang-format on
23
23
 
24
24
  #endif /* HKU_VERSION_H */
@@ -0,0 +1,59 @@
1
+ /*
2
+ * Copyright (c) 2025 hikyuu.org
3
+ *
4
+ * Created on: 2025-08-13
5
+ * Author: fasiondog
6
+ */
7
+
8
+ #pragma once
9
+
10
+ #include "hikyuu/Stock.h"
11
+
12
+ namespace hku {
13
+
14
+ /**
15
+ * 实时行情记录(用于显示打印)
16
+ * @ingroup View
17
+ */
18
+ struct HKU_API MarketViewRecord {
19
+ Stock stock; ///< 证券
20
+ Datetime date; ///< 日期
21
+ price_t open{Null<price_t>()}; ///< 开盘价
22
+ price_t high{Null<price_t>()}; ///< 最高价
23
+ price_t low{Null<price_t>()}; ///< 最低价
24
+ price_t close{Null<price_t>()}; ///< 收盘价
25
+ price_t amount{Null<price_t>()}; ///< 成交额
26
+ price_t volume{Null<price_t>()}; ///< 成交量
27
+ price_t yesterday_close{Null<price_t>()}; ///< 昨收价
28
+ price_t turnover{Null<price_t>()}; ///< 换手率(%)
29
+ price_t amplitude{Null<price_t>()}; ///< 振幅(%)
30
+ price_t price_change{Null<price_t>()}; ///< 涨跌幅(%)
31
+ price_t total_market_cap{Null<price_t>()}; ///< 总市值
32
+ price_t circulating_market_cap{Null<price_t>()}; ///< 流通市值
33
+ price_t pe{Null<price_t>()}; ///< 动态市盈率
34
+ price_t pb{Null<price_t>()}; ///< 市净率
35
+ };
36
+
37
+ using MarketView = vector<MarketViewRecord>;
38
+
39
+ /**
40
+ * 获取指定股票集合在指定交易日的行情数据,不包含当日停牌无数据的股票
41
+ * @ingroup View
42
+ * @param stks 股票列表
43
+ * @param date 交易日
44
+ * @param market 市场代码(用于获取交易日历)
45
+ * @return MarketView
46
+ */
47
+ MarketView HKU_API getMarketView(const StockList& stks, const Datetime& date,
48
+ const string& market = "SH");
49
+
50
+ /**
51
+ * 获取指定股票集合在最后交易日的行情数据,不包含当日停牌无数据的股票。如自动接收行情数据,则为实时行情数据
52
+ * @ingroup View
53
+ * @param stks 股票列表
54
+ * @param market 市场代码(用于获取交易日历)
55
+ * @return MarketView
56
+ */
57
+ MarketView HKU_API getMarketView(const StockList& stks, const string& market = "SH");
58
+
59
+ } // namespace hku
@@ -26,4 +26,3 @@
26
26
 
27
27
  from .indicator import *
28
28
  from .pyind import *
29
- from .talib_wrap import *