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
hikyuu/hub.pyi CHANGED
@@ -28,22 +28,23 @@ 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
+ __firstlineno__: typing.ClassVar[int] = 39
32
+ __mapper__: typing.ClassVar[sqlalchemy.orm.mapper.Mapper] # value = <Mapper at 0x20a840fd400; ConfigModel>
33
+ __static_attributes__: typing.ClassVar[tuple] = tuple()
32
34
  __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
35
  __table_args__: typing.ClassVar[tuple] # value = (UniqueConstraint(Column('key', String(), table=<hub_config>)))
34
36
  __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>
37
+ _sa_class_manager: typing.ClassVar[sqlalchemy.orm.instrumentation.ClassManager] # value = <ClassManager of <class 'hikyuu.hub.ConfigModel'> at 20a84129450>
36
38
  def __init__(self, **kwargs):
37
39
  """
38
40
  A simple constructor that allows initialization from kwargs.
39
41
 
40
- Sets attributes on the constructed instance using the names and
41
- values in ``kwargs``.
42
+ Sets attributes on the constructed instance using the names and
43
+ values in ``kwargs``.
42
44
 
43
- Only keys that are present as
44
- attributes of the instance's class are allowed. These could be,
45
- for example, any mapped columns or relationships.
46
-
45
+ Only keys that are present as
46
+ attributes of the instance's class are allowed. These could be,
47
+ for example, any mapped columns or relationships.
47
48
  """
48
49
  def __repr__(self):
49
50
  ...
@@ -53,6 +54,8 @@ class HubManager:
53
54
  """
54
55
  策略库管理
55
56
  """
57
+ __firstlineno__: typing.ClassVar[int] = 171
58
+ __static_attributes__: typing.ClassVar[tuple] = ('_scoped_Session', '_session', 'logger', 'remote_cache_dir')
56
59
  _instance: typing.ClassVar[HubManager] # value = <hikyuu.hub.HubManager object>
57
60
  @staticmethod
58
61
  def _get_module(*args, **kwargs):
@@ -109,70 +112,82 @@ class HubManager:
109
112
  def print_part_info(self, name):
110
113
  ...
111
114
  class HubModel(sqlalchemy.orm.decl_api.Base):
112
- __mapper__: typing.ClassVar[sqlalchemy.orm.mapper.Mapper] # value = <Mapper at 0x1fc04693590; HubModel>
115
+ __firstlineno__: typing.ClassVar[int] = 54
116
+ __mapper__: typing.ClassVar[sqlalchemy.orm.mapper.Mapper] # value = <Mapper at 0x20a840ddd10; HubModel>
117
+ __static_attributes__: typing.ClassVar[tuple] = tuple()
113
118
  __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
119
  __table_args__: typing.ClassVar[tuple] # value = (UniqueConstraint(Column('name', String(), table=<hub_repo>)))
115
120
  __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>
121
+ _sa_class_manager: typing.ClassVar[sqlalchemy.orm.instrumentation.ClassManager] # value = <ClassManager of <class 'hikyuu.hub.HubModel'> at 20a84141d60>
117
122
  def __init__(self, **kwargs):
118
123
  """
119
124
  A simple constructor that allows initialization from kwargs.
120
125
 
121
- Sets attributes on the constructed instance using the names and
122
- values in ``kwargs``.
126
+ Sets attributes on the constructed instance using the names and
127
+ values in ``kwargs``.
123
128
 
124
- Only keys that are present as
125
- attributes of the instance's class are allowed. These could be,
126
- for example, any mapped columns or relationships.
127
-
129
+ Only keys that are present as
130
+ attributes of the instance's class are allowed. These could be,
131
+ for example, any mapped columns or relationships.
128
132
  """
129
133
  def __repr__(self):
130
134
  ...
131
135
  def __str__(self):
132
136
  ...
133
137
  class HubNameRepeatError(Exception):
138
+ __firstlineno__: typing.ClassVar[int] = 99
139
+ __static_attributes__: typing.ClassVar[tuple] = ('name')
134
140
  def __init__(self, name):
135
141
  ...
136
142
  def __str__(self):
137
143
  ...
138
144
  class HubNotFoundError(Exception):
145
+ __firstlineno__: typing.ClassVar[int] = 107
146
+ __static_attributes__: typing.ClassVar[tuple] = ('name')
139
147
  def __init__(self, name):
140
148
  ...
141
149
  def __str__(self):
142
150
  ...
143
151
  class ModuleConflictError(Exception):
152
+ __firstlineno__: typing.ClassVar[int] = 115
153
+ __static_attributes__: typing.ClassVar[tuple] = ('conflict_module', 'hub_name', 'hub_path')
144
154
  def __init__(self, hub_name, conflict_module, hub_path):
145
155
  ...
146
156
  def __str__(self):
147
157
  ...
148
158
  class PartModel(sqlalchemy.orm.decl_api.Base):
149
- __mapper__: typing.ClassVar[sqlalchemy.orm.mapper.Mapper] # value = <Mapper at 0x1fc0322b3b0; PartModel>
159
+ __firstlineno__: typing.ClassVar[int] = 75
160
+ __mapper__: typing.ClassVar[sqlalchemy.orm.mapper.Mapper] # value = <Mapper at 0x20a840de5d0; PartModel>
161
+ __static_attributes__: typing.ClassVar[tuple] = tuple()
150
162
  __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
163
  __table_args__: typing.ClassVar[tuple] # value = (UniqueConstraint(Column('name', String(), table=<hub_part>)))
152
164
  __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>
165
+ _sa_class_manager: typing.ClassVar[sqlalchemy.orm.instrumentation.ClassManager] # value = <ClassManager of <class 'hikyuu.hub.PartModel'> at 20a841427b0>
154
166
  def __init__(self, **kwargs):
155
167
  """
156
168
  A simple constructor that allows initialization from kwargs.
157
169
 
158
- Sets attributes on the constructed instance using the names and
159
- values in ``kwargs``.
170
+ Sets attributes on the constructed instance using the names and
171
+ values in ``kwargs``.
160
172
 
161
- Only keys that are present as
162
- attributes of the instance's class are allowed. These could be,
163
- for example, any mapped columns or relationships.
164
-
173
+ Only keys that are present as
174
+ attributes of the instance's class are allowed. These could be,
175
+ for example, any mapped columns or relationships.
165
176
  """
166
177
  def __repr__(self):
167
178
  ...
168
179
  def __str__(self):
169
180
  ...
170
181
  class PartNameError(Exception):
182
+ __firstlineno__: typing.ClassVar[int] = 136
183
+ __static_attributes__: typing.ClassVar[tuple] = ('name')
171
184
  def __init__(self, name):
172
185
  ...
173
186
  def __str__(self):
174
187
  ...
175
188
  class PartNotFoundError(Exception):
189
+ __firstlineno__: typing.ClassVar[int] = 127
190
+ __static_attributes__: typing.ClassVar[tuple] = ('cause', 'name')
176
191
  def __init__(self, name, cause):
177
192
  ...
178
193
  def __str__(self):
@@ -181,34 +196,30 @@ def add_local_hub(name, path):
181
196
  """
182
197
  增加本地数据仓库
183
198
 
184
- :param str name: 仓库名称
185
- :param str path: 本地全路径
186
-
199
+ :param str name: 仓库名称
200
+ :param str path: 本地全路径
187
201
  """
188
202
  def add_remote_hub(name, url, branch = 'main'):
189
203
  """
190
204
  增加远程策略仓库
191
205
 
192
- :param str name: 本地仓库名称(自行起名)
193
- :param str url: git 仓库地址
194
- :param str branch: git 仓库分支
195
-
206
+ :param str name: 本地仓库名称(自行起名)
207
+ :param str url: git 仓库地址
208
+ :param str branch: git 仓库分支
196
209
  """
197
210
  def build_hub(name, cmd = 'buildall'):
198
211
  """
199
212
  构建 cpp 部分 part
200
213
 
201
- :param str name: 仓库名称
202
- :param str cmd: 同仓库下 python setup.py 后的命令参数,如: build -t ind -n cpp_example
203
-
214
+ :param str name: 仓库名称
215
+ :param str cmd: 同仓库下 python setup.py 后的命令参数,如: build -t ind -n cpp_example
204
216
  """
205
217
  def dbsession(func):
206
218
  ...
207
219
  def get_current_hub(*args, **kwargs):
208
220
  """
209
221
  用于在仓库part.py中获取当前所在的仓库名。
210
- 示例: get_current_hub(__file__)
211
-
222
+ 示例: get_current_hub(__file__)
212
223
  """
213
224
  def get_hub_name_list():
214
225
  """
@@ -218,49 +229,43 @@ def get_hub_path(name):
218
229
  """
219
230
  获取仓库所在的本地路径
220
231
 
221
- :param str name: 仓库名
222
-
232
+ :param str name: 仓库名
223
233
  """
224
234
  def get_part(name, *args, **kwargs):
225
235
  """
226
236
  获取指定策略部件
227
237
 
228
- :param str name: 策略部件名称
229
- :param args: 其他部件相关参数
230
- :param kwargs: 其他部件相关参数
231
-
238
+ :param str name: 策略部件名称
239
+ :param args: 其他部件相关参数
240
+ :param kwargs: 其他部件相关参数
232
241
  """
233
242
  def get_part_info(name):
234
243
  """
235
244
  获取策略部件信息
236
245
 
237
- :param str name: 部件名称
238
-
246
+ :param str name: 部件名称
239
247
  """
240
248
  def get_part_list(name_list):
241
249
  """
242
250
 
243
- 获取指定策略部件列表
251
+ 获取指定策略部件列表
244
252
 
245
- :param list name_list: 部件名称列表
246
- :return: 部件列表
247
- :rtype: list
248
-
253
+ :param list name_list: 部件名称列表
254
+ :return: 部件列表
255
+ :rtype: list
249
256
  """
250
257
  def get_part_module(part_name: str):
251
258
  """
252
259
  获取部件模块
253
- :param str part_name: 部件名称
254
- :return: 部件模块
255
- :rtype: module
256
-
260
+ :param str part_name: 部件名称
261
+ :return: 部件模块
262
+ :rtype: module
257
263
  """
258
264
  def get_part_name_list(hub = None, part_type = None):
259
265
  """
260
266
  获取部件名称列表
261
- :param str hub: 仓库名
262
- :param str part_type: 部件类型
263
-
267
+ :param str hub: 仓库名
268
+ :param str part_type: 部件类型
264
269
  """
265
270
  def handle_remove_read_only(func, path, exc):
266
271
  ...
@@ -270,26 +275,23 @@ def remove_hub(name):
270
275
  """
271
276
  删除指定的仓库
272
277
 
273
- :param str name: 仓库名称
274
-
278
+ :param str name: 仓库名称
275
279
  """
276
280
  def search_part(name: str = None, hub: str = None, part_type: str = None, label: str = None):
277
281
  """
278
282
  搜索部件
279
283
 
280
- :param str name: 部件名称
281
- :param str hub: 仓库名
282
- :param str part_type: 部件类型
283
- :param str label: 标签
284
- :return: 部件名称列表
285
- :rtype: list
286
-
284
+ :param str name: 部件名称
285
+ :param str hub: 仓库名
286
+ :param str part_type: 部件类型
287
+ :param str label: 标签
288
+ :return: 部件名称列表
289
+ :rtype: list
287
290
  """
288
291
  def update_hub(name):
289
292
  """
290
293
  更新指定仓库
291
294
 
292
- :param str name: 仓库名称
293
-
295
+ :param str name: 仓库名称
294
296
  """
295
297
  help_part = print_part_info
@@ -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>
@@ -90,9 +87,9 @@ namespace hku {
90
87
  * @{
91
88
  */
92
89
 
93
- // MSVC 的 __cpluscplus 之在 VS2017 之后才有正确的版本号,且只支持 C++17 及以上, 详见:
90
+ // MSVC 的 __cpluscplus VS2017 之后才有正确的版本号,且只支持 C++17 及以上, 详见:
94
91
  // https://docs.microsoft.com/zh-cn/cpp/build/reference/zc-cplusplus?view=vs-2019
95
- #if defined(_MSC_VER) || __cplusplus < 201103L
92
+ #if CPP_STANDARD < CPP_STANDARD_11
96
93
  #if !defined(int64_t)
97
94
  typedef long long int64_t;
98
95
  #endif
@@ -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;
@@ -57,6 +57,9 @@ public:
57
57
  return getKRecord(datetime);
58
58
  }
59
59
 
60
+ const KRecord& front() const;
61
+ const KRecord& back() const;
62
+
60
63
  /**
61
64
  * 通过当前 KData 获取一个保持数据类型、复权类型不变的新的 KData
62
65
  * @note 新的 KData 并不一定是原 KData 的子集
@@ -65,6 +68,13 @@ public:
65
68
  */
66
69
  KData getKData(const Datetime& start, const Datetime& end) const;
67
70
 
71
+ /**
72
+ * 获取相同时间范围内的其他类型K线数据,如日线下对应的分钟线数据
73
+ * @param ktype
74
+ * @return KData
75
+ */
76
+ KData getKData(const KQuery::KType& ktype) const;
77
+
68
78
  /** 按日期查询对应的索引位置,注:是 KData 中的位置,不是在 Stock 中原始K记录的位置 */
69
79
  size_t getPos(const Datetime& datetime) const;
70
80
 
@@ -110,17 +120,70 @@ public:
110
120
  Indicator amo() const;
111
121
 
112
122
  public:
113
- typedef KRecordList::iterator iterator;
114
- typedef KRecordList::const_iterator const_iterator;
115
- iterator begin();
116
- iterator end();
117
- const_iterator cbegin() const;
118
- const_iterator cend() const;
119
123
  const KRecord* data() const;
120
124
  KRecord* data(); // 谨慎使用(用于强制调整数据)
121
125
 
126
+ // 常量迭代器定义
127
+ class const_iterator {
128
+ public:
129
+ using iterator_category = std::forward_iterator_tag;
130
+ using value_type = const KRecord;
131
+ using difference_type = std::ptrdiff_t;
132
+ using pointer = const KRecord*;
133
+ using reference = const KRecord&;
134
+
135
+ const_iterator(const KData& container, size_t index)
136
+ : container_(container), index_(index) {}
137
+
138
+ reference operator*() const {
139
+ return container_[index_];
140
+ }
141
+ pointer operator->() const {
142
+ return &(container_[index_]);
143
+ }
144
+
145
+ const_iterator& operator++() {
146
+ ++index_;
147
+ return *this;
148
+ }
149
+
150
+ const_iterator operator++(int) {
151
+ const_iterator temp = *this;
152
+ ++index_;
153
+ return temp;
154
+ }
155
+
156
+ bool operator==(const const_iterator& other) const {
157
+ return &container_ == &other.container_ && index_ == other.index_;
158
+ }
159
+
160
+ bool operator!=(const const_iterator& other) const {
161
+ return !(*this == other);
162
+ }
163
+
164
+ private:
165
+ const KData& container_; // 常量引用容器
166
+ size_t index_; // 当前索引
167
+ };
168
+
169
+ using iterator = const_iterator;
170
+
171
+ const_iterator begin() const {
172
+ return const_iterator(*this, 0);
173
+ }
174
+ const_iterator end() const {
175
+ return const_iterator(*this, size());
176
+ }
177
+
178
+ const_iterator cbegin() const {
179
+ return const_iterator(*this, 0);
180
+ }
181
+ const_iterator cend() const {
182
+ return const_iterator(*this, size());
183
+ }
184
+
122
185
  private:
123
- static KRecord ms_null_krecord;
186
+ static shared_ptr<KDataImp> ms_null_kdata_imp;
124
187
 
125
188
  private:
126
189
  KDataImpPtr m_imp;
@@ -177,7 +240,9 @@ KData HKU_API getKData(const string& market_code, int64_t start = 0, int64_t end
177
240
 
178
241
  inline KData::KData(const KData& x) : m_imp(x.m_imp) {}
179
242
 
180
- inline KData::KData(KData&& x) : m_imp(std::move(x.m_imp)) {}
243
+ inline KData::KData(KData&& x) : m_imp(std::move(x.m_imp)) {
244
+ x.m_imp = ms_null_kdata_imp;
245
+ }
181
246
 
182
247
  inline KData& KData::operator=(const KData& x) {
183
248
  if (this == &x)
@@ -190,6 +255,7 @@ inline KData& KData::operator=(KData&& x) {
190
255
  if (this == &x)
191
256
  return *this;
192
257
  m_imp = std::move(x.m_imp);
258
+ x.m_imp = ms_null_kdata_imp;
193
259
  return *this;
194
260
  }
195
261
 
@@ -203,7 +269,7 @@ inline const KRecord& KData::getKRecord(size_t pos) const {
203
269
 
204
270
  inline const KRecord& KData::getKRecord(Datetime datetime) const {
205
271
  size_t pos = getPos(datetime);
206
- return pos != Null<size_t>() ? getKRecord(pos) : ms_null_krecord;
272
+ return pos != Null<size_t>() ? getKRecord(pos) : KRecord::NullKRecord;
207
273
  }
208
274
 
209
275
  inline size_t KData::getPos(const Datetime& datetime) const {
@@ -226,6 +292,14 @@ inline const Stock& KData::getStock() const {
226
292
  return m_imp->getStock();
227
293
  }
228
294
 
295
+ inline const KRecord& KData::front() const {
296
+ return m_imp->front();
297
+ }
298
+
299
+ inline const KRecord& KData::back() const {
300
+ return m_imp->back();
301
+ }
302
+
229
303
  inline size_t KData::startPos() const {
230
304
  return m_imp->startPos();
231
305
  }
@@ -242,22 +316,6 @@ inline bool KData::operator!=(const KData& other) const {
242
316
  return !(*this == other);
243
317
  }
244
318
 
245
- inline KData::iterator KData::begin() {
246
- return m_imp->begin();
247
- }
248
-
249
- inline KData::iterator KData::end() {
250
- return m_imp->end();
251
- }
252
-
253
- inline KData::const_iterator KData::cbegin() const {
254
- return m_imp->cbegin();
255
- }
256
-
257
- inline KData::const_iterator KData::cend() const {
258
- return m_imp->cend();
259
- }
260
-
261
319
  inline const KRecord* KData::data() const {
262
320
  return m_imp->data();
263
321
  }
@@ -1,13 +1,11 @@
1
1
  /*
2
- * KDataImp.h
2
+ * Copyright (c) 2025 hikyuu.org
3
3
  *
4
- * Created on: 2013-2-4
4
+ * Created on: 2025-08-28
5
5
  * Author: fasiondog
6
6
  */
7
7
 
8
8
  #pragma once
9
- #ifndef KDATAIMP_H_
10
- #define KDATAIMP_H_
11
9
 
12
10
  #include "Stock.h"
13
11
 
@@ -15,7 +13,7 @@ namespace hku {
15
13
 
16
14
  class HKU_API KDataImp {
17
15
  public:
18
- KDataImp();
16
+ KDataImp() = default;
19
17
  KDataImp(const Stock& stock, const KQuery& query);
20
18
  virtual ~KDataImp();
21
19
 
@@ -27,72 +25,59 @@ public:
27
25
  return m_stock;
28
26
  }
29
27
 
30
- const KRecord& getKRecord(size_t pos) const {
31
- return m_buffer[pos];
28
+ virtual bool empty() const {
29
+ return true;
32
30
  }
33
31
 
34
- bool empty() const {
35
- return m_buffer.empty();
32
+ virtual size_t size() const {
33
+ return 0;
36
34
  }
37
35
 
38
- size_t size() {
39
- return m_buffer.size();
36
+ virtual size_t startPos() const {
37
+ return 0;
40
38
  }
41
39
 
42
- size_t startPos();
43
- size_t endPos();
44
- size_t lastPos();
45
-
46
- size_t getPos(const Datetime& datetime);
47
-
48
- const KRecord* data() const {
49
- return m_buffer.data();
40
+ virtual size_t endPos() const {
41
+ return 0;
50
42
  }
51
43
 
52
- KRecord* data() {
53
- return m_buffer.data();
44
+ virtual size_t lastPos() const {
45
+ return 0;
54
46
  }
55
47
 
56
- DatetimeList getDatetimeList() const;
48
+ virtual size_t getPos(const Datetime& datetime) const {
49
+ return Null<size_t>();
50
+ }
57
51
 
58
- public:
59
- typedef KRecordList::iterator iterator;
60
- typedef KRecordList::const_iterator const_iterator;
52
+ virtual const KRecord& getKRecord(size_t pos) const {
53
+ return KRecord::NullKRecord;
54
+ }
61
55
 
62
- iterator begin() {
63
- return m_buffer.begin();
56
+ virtual const KRecord& front() const {
57
+ return KRecord::NullKRecord;
64
58
  }
65
59
 
66
- iterator end() {
67
- return m_buffer.end();
60
+ virtual const KRecord& back() const {
61
+ return KRecord::NullKRecord;
68
62
  }
69
63
 
70
- const_iterator cbegin() const {
71
- return m_buffer.cbegin();
64
+ virtual const KRecord* data() const {
65
+ return nullptr;
72
66
  }
73
67
 
74
- const_iterator cend() const {
75
- return m_buffer.cend();
68
+ virtual KRecord* data() {
69
+ return nullptr;
76
70
  }
77
71
 
78
- private:
79
- void _getPosInStock();
80
- void _recoverForward();
81
- void _recoverBackward();
82
- void _recoverEqualForward();
83
- void _recoverEqualBackward();
84
- void _recoverForUpDay();
72
+ virtual DatetimeList getDatetimeList() const {
73
+ return DatetimeList();
74
+ }
85
75
 
86
- private:
87
- KRecordList m_buffer;
76
+ protected:
88
77
  KQuery m_query;
89
78
  Stock m_stock;
90
- size_t m_start;
91
- size_t m_end;
92
- bool m_have_pos_in_stock;
93
79
  };
94
80
 
95
81
  typedef shared_ptr<KDataImp> KDataImpPtr;
96
82
 
97
83
  } /* namespace hku */
98
- #endif /* KDATAIMP_H_ */
@@ -0,0 +1,73 @@
1
+ /*
2
+ * KDataPrivatedBufferImp.h
3
+ *
4
+ * Created on: 2013-2-4
5
+ * Author: fasiondog
6
+ */
7
+
8
+ #pragma once
9
+
10
+ #include "KDataImp.h"
11
+
12
+ namespace hku {
13
+
14
+ class HKU_API KDataPrivatedBufferImp : public KDataImp {
15
+ public:
16
+ KDataPrivatedBufferImp();
17
+ KDataPrivatedBufferImp(const Stock& stock, const KQuery& query);
18
+ virtual ~KDataPrivatedBufferImp();
19
+
20
+ virtual bool empty() const override {
21
+ return m_buffer.empty();
22
+ }
23
+
24
+ virtual size_t size() const override {
25
+ return m_buffer.size();
26
+ }
27
+
28
+ virtual size_t startPos() const override;
29
+ virtual size_t endPos() const override;
30
+ virtual size_t lastPos() const override;
31
+
32
+ virtual size_t getPos(const Datetime& datetime) const override;
33
+
34
+ virtual const KRecord& getKRecord(size_t pos) const override {
35
+ return m_buffer[pos];
36
+ }
37
+
38
+ virtual const KRecord& front() const override {
39
+ return m_buffer.front();
40
+ }
41
+
42
+ virtual const KRecord& back() const override {
43
+ return m_buffer.back();
44
+ }
45
+
46
+ virtual const KRecord* data() const override {
47
+ return m_buffer.data();
48
+ }
49
+
50
+ virtual KRecord* data() override {
51
+ return m_buffer.data();
52
+ }
53
+
54
+ virtual DatetimeList getDatetimeList() const override;
55
+
56
+ private:
57
+ void _getPosInStock() const;
58
+ void _recoverForward();
59
+ void _recoverBackward();
60
+ void _recoverEqualForward();
61
+ void _recoverEqualBackward();
62
+ void _recoverForUpDay();
63
+
64
+ private:
65
+ KRecordList m_buffer;
66
+ mutable size_t m_start{0};
67
+ mutable size_t m_end{0};
68
+ mutable bool m_have_pos_in_stock{false};
69
+ };
70
+
71
+ typedef shared_ptr<KDataPrivatedBufferImp> KDataPrivatedBufferImpPtr;
72
+
73
+ } /* namespace hku */