hikyuu 2.6.8.4__py3-none-manylinux2014_x86_64.whl → 2.6.9__py3-none-manylinux2014_x86_64.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 (196) hide show
  1. hikyuu/__init__.py +5 -12
  2. hikyuu/__init__.pyi +612 -587
  3. hikyuu/analysis/__init__.pyi +589 -563
  4. hikyuu/analysis/analysis.pyi +590 -564
  5. hikyuu/core.py +2 -0
  6. hikyuu/core.pyi +591 -565
  7. hikyuu/cpp/__init__.pyi +2 -2
  8. hikyuu/cpp/core310.pyi +446 -13
  9. hikyuu/cpp/core310.so +0 -0
  10. hikyuu/cpp/core311.pyi +440 -13
  11. hikyuu/cpp/core311.so +0 -0
  12. hikyuu/cpp/core312.pyi +440 -13
  13. hikyuu/cpp/core312.so +0 -0
  14. hikyuu/cpp/core313.pyi +446 -13
  15. hikyuu/cpp/core313.so +0 -0
  16. hikyuu/cpp/i18n/zh_CN/hikyuu.mo +0 -0
  17. hikyuu/cpp/libboost_charconv-mt.so +0 -0
  18. hikyuu/cpp/libboost_charconv-mt.so.1.88.0 +0 -0
  19. hikyuu/cpp/libboost_chrono-mt.so +0 -0
  20. hikyuu/cpp/libboost_chrono-mt.so.1.88.0 +0 -0
  21. hikyuu/cpp/libboost_date_time-mt.so +0 -0
  22. hikyuu/cpp/libboost_date_time-mt.so.1.88.0 +0 -0
  23. hikyuu/cpp/libboost_serialization-mt.so +0 -0
  24. hikyuu/cpp/libboost_serialization-mt.so.1.88.0 +0 -0
  25. hikyuu/cpp/libboost_system-mt.so +0 -0
  26. hikyuu/cpp/libboost_system-mt.so.1.88.0 +0 -0
  27. hikyuu/cpp/libboost_thread-mt.so +0 -0
  28. hikyuu/cpp/libboost_thread-mt.so.1.88.0 +0 -0
  29. hikyuu/cpp/libboost_wserialization-mt.so +0 -0
  30. hikyuu/cpp/libboost_wserialization-mt.so.1.88.0 +0 -0
  31. hikyuu/cpp/libhikyuu.so +0 -0
  32. hikyuu/cpp/libsqlite3.so +0 -0
  33. hikyuu/data/clickhouse_upgrade/createdb.sql +105 -105
  34. hikyuu/data/common.py +3 -3
  35. hikyuu/data/common_clickhouse.py +1 -1
  36. hikyuu/data/download_block.py +318 -0
  37. hikyuu/data/em_block_to_clickhouse.py +26 -74
  38. hikyuu/data/em_block_to_mysql.py +25 -75
  39. hikyuu/data/em_block_to_sqlite.py +26 -78
  40. hikyuu/data/hku_config_template.py +3 -3
  41. hikyuu/data/pytdx_to_clickhouse.py +15 -11
  42. hikyuu/data/pytdx_to_h5.py +6 -2
  43. hikyuu/data/pytdx_to_mysql.py +5 -1
  44. hikyuu/data/pytdx_weight_to_clickhouse.py +1 -1
  45. hikyuu/data/pytdx_weight_to_mysql.py +1 -1
  46. hikyuu/data/pytdx_weight_to_sqlite.py +1 -1
  47. hikyuu/data/zh_bond10_to_clickhouse.py +1 -1
  48. hikyuu/draw/drawplot/__init__.pyi +8 -8
  49. hikyuu/draw/drawplot/bokeh_draw.pyi +603 -578
  50. hikyuu/draw/drawplot/common.pyi +1 -1
  51. hikyuu/draw/drawplot/echarts_draw.pyi +605 -580
  52. hikyuu/draw/drawplot/matplotlib_draw.py +4 -74
  53. hikyuu/draw/drawplot/matplotlib_draw.pyi +615 -590
  54. hikyuu/draw/elder.pyi +11 -11
  55. hikyuu/draw/kaufman.pyi +18 -18
  56. hikyuu/draw/volume.pyi +10 -10
  57. hikyuu/examples/notebook/Demo/Demo1.ipynb +48 -33
  58. hikyuu/extend.pyi +599 -573
  59. hikyuu/fetcher/stock/zh_block_em.py +50 -18
  60. hikyuu/gui/HikyuuTDX.py +81 -30
  61. hikyuu/gui/data/CollectSpotThread.py +1 -1
  62. hikyuu/gui/data/EscapetimeThread.py +8 -14
  63. hikyuu/gui/data/ImportBlockInfoTask.py +3 -10
  64. hikyuu/gui/data/MainWindow.py +1168 -715
  65. hikyuu/gui/data/SchedImportThread.py +2 -2
  66. hikyuu/gui/data/UsePytdxImportToH5Thread.py +3 -3
  67. hikyuu/gui/data/UseQmtImportToH5Thread.py +2 -2
  68. hikyuu/gui/data/UseTdxImportToH5Thread.py +3 -3
  69. hikyuu/gui/data/tool.py +32 -25
  70. hikyuu/gui/dataserver.py +5 -3
  71. hikyuu/hub.pyi +6 -6
  72. hikyuu/include/hikyuu/DataType.h +4 -16
  73. hikyuu/include/hikyuu/KData.h +6 -3
  74. hikyuu/include/hikyuu/KDataPrivatedBufferImp.h +1 -1
  75. hikyuu/include/hikyuu/KDataSharedBufferImp.h +1 -1
  76. hikyuu/include/hikyuu/KQuery.h +2 -2
  77. hikyuu/include/hikyuu/Stock.h +3 -0
  78. hikyuu/include/hikyuu/StockManager.h +13 -3
  79. hikyuu/include/hikyuu/config.h +3 -0
  80. hikyuu/include/hikyuu/data_driver/BaseInfoDriver.h +8 -0
  81. hikyuu/include/hikyuu/data_driver/BlockInfoDriver.h +6 -0
  82. hikyuu/include/hikyuu/data_driver/KDataDriver.h +26 -1
  83. hikyuu/include/hikyuu/data_driver/base_info/mysql/MySQLBaseInfoDriver.h +1 -1
  84. hikyuu/include/hikyuu/data_driver/base_info/sqlite/SQLiteBaseInfoDriver.h +1 -1
  85. hikyuu/include/hikyuu/data_driver/block_info/mysql/MySQLBlockInfoDriver.h +2 -1
  86. hikyuu/include/hikyuu/data_driver/block_info/qianlong/QLBlockInfoDriver.h +2 -1
  87. hikyuu/include/hikyuu/data_driver/block_info/sqlite/SQLiteBlockInfoDriver.h +2 -1
  88. hikyuu/include/hikyuu/data_driver/kdata/DoNothingKDataDriver.h +1 -1
  89. hikyuu/include/hikyuu/data_driver/kdata/cvs/KDataTempCsvDriver.h +1 -1
  90. hikyuu/include/hikyuu/data_driver/kdata/hdf5/H5KDataDriver.h +1 -1
  91. hikyuu/include/hikyuu/data_driver/kdata/mysql/MySQLKDataDriver.h +1 -1
  92. hikyuu/include/hikyuu/data_driver/kdata/sqlite/SQLiteKDataDriver.h +1 -1
  93. hikyuu/include/hikyuu/data_driver/kdata/tdx/TdxKDataDriver.h +1 -1
  94. hikyuu/include/hikyuu/hikyuu.h +1 -1
  95. hikyuu/include/hikyuu/indicator/build_in.h +1 -0
  96. hikyuu/include/hikyuu/indicator/crt/CYCLE.h +4 -4
  97. hikyuu/include/hikyuu/indicator/crt/HSL.h +2 -2
  98. hikyuu/include/hikyuu/indicator/crt/QUANTILE_TRUNC.h +30 -0
  99. hikyuu/include/hikyuu/indicator/crt/TURNOVER.h +1 -0
  100. hikyuu/include/hikyuu/indicator/crt/ZSCORE.h +2 -2
  101. hikyuu/include/hikyuu/indicator/imp/IQuantileTrunc.h +25 -0
  102. hikyuu/include/hikyuu/misc.h +38 -0
  103. hikyuu/include/hikyuu/plugin/dataserver.h +2 -1
  104. hikyuu/include/hikyuu/plugin/extind.h +37 -0
  105. hikyuu/include/hikyuu/plugin/hkuextra.h +0 -18
  106. hikyuu/include/hikyuu/plugin/hkuviews.h +36 -0
  107. hikyuu/include/hikyuu/plugin/interface/DataServerPluginInterface.h +2 -2
  108. hikyuu/include/hikyuu/plugin/interface/ExtendIndicatorsPluginInterface.h +12 -0
  109. hikyuu/include/hikyuu/plugin/interface/HkuExtraPluginInterface.h +0 -14
  110. hikyuu/include/hikyuu/plugin/interface/HkuViewsPluginInterface.h +34 -0
  111. hikyuu/include/hikyuu/plugin/interface/plugins.h +8 -1
  112. hikyuu/include/hikyuu/python/pybind_utils.h +6 -1
  113. hikyuu/include/hikyuu/strategy/RunSystemInStrategy.h +3 -0
  114. hikyuu/include/hikyuu/trade_manage/Performance.h +4 -4
  115. hikyuu/include/hikyuu/trade_manage/TradeManagerBase.h +10 -1
  116. hikyuu/include/hikyuu/trade_sys/moneymanager/imp/FixedCapitalFundsMM.h +0 -4
  117. hikyuu/include/hikyuu/trade_sys/multifactor/MultiFactorBase.h +36 -3
  118. hikyuu/include/hikyuu/trade_sys/multifactor/NormalizeBase.h +125 -0
  119. hikyuu/include/hikyuu/trade_sys/multifactor/ScoresFilterBase.h +125 -0
  120. hikyuu/include/hikyuu/trade_sys/multifactor/build_in.h +3 -0
  121. hikyuu/include/hikyuu/trade_sys/multifactor/buildin_norm.h +36 -0
  122. hikyuu/include/hikyuu/trade_sys/multifactor/buildin_scfilter.h +51 -0
  123. hikyuu/include/hikyuu/trade_sys/multifactor/filter/GroupSCFilter.h +24 -0
  124. hikyuu/include/hikyuu/trade_sys/multifactor/filter/IgnoreLessOrEqualValueSCFilter.h +24 -0
  125. hikyuu/include/hikyuu/trade_sys/multifactor/filter/IgnoreNanSCFilter.h +24 -0
  126. hikyuu/include/hikyuu/trade_sys/multifactor/filter/MinAmountPercentSCFilter.h +25 -0
  127. hikyuu/include/hikyuu/trade_sys/multifactor/filter/PriceSCFilter.h +24 -0
  128. hikyuu/include/hikyuu/trade_sys/multifactor/filter/TopNSCFilter.h +24 -0
  129. hikyuu/include/hikyuu/trade_sys/multifactor/filter/__init__.py +1 -0
  130. hikyuu/include/hikyuu/trade_sys/multifactor/imp/EqualWeightMultiFactor.h +1 -1
  131. hikyuu/include/hikyuu/trade_sys/multifactor/imp/ICIRMultiFactor.h +1 -1
  132. hikyuu/include/hikyuu/trade_sys/multifactor/imp/ICMultiFactor.h +1 -1
  133. hikyuu/include/hikyuu/trade_sys/multifactor/imp/WeightMultiFactor.h +1 -1
  134. hikyuu/include/hikyuu/trade_sys/multifactor/normalize/NormMinMax.h +23 -0
  135. hikyuu/include/hikyuu/trade_sys/multifactor/normalize/NormQuantile.h +28 -0
  136. hikyuu/include/hikyuu/trade_sys/multifactor/normalize/NormQuantileUniform.h +28 -0
  137. hikyuu/include/hikyuu/trade_sys/multifactor/normalize/NormZScore.h +25 -0
  138. hikyuu/include/hikyuu/trade_sys/multifactor/normalize/__init__.py +1 -0
  139. hikyuu/include/hikyuu/trade_sys/multifactor/normalize/quantile_trunc.h +16 -0
  140. hikyuu/include/hikyuu/trade_sys/portfolio/Portfolio.h +7 -0
  141. hikyuu/include/hikyuu/trade_sys/portfolio/imp/SimplePortfolio.h +7 -0
  142. hikyuu/include/hikyuu/trade_sys/portfolio/imp/WithoutAFPortfolio.h +7 -0
  143. hikyuu/include/hikyuu/trade_sys/selector/SelectorBase.h +49 -0
  144. hikyuu/include/hikyuu/trade_sys/selector/build_in.h +1 -0
  145. hikyuu/include/hikyuu/trade_sys/selector/crt/SE_MultiFactor2.h +40 -0
  146. hikyuu/include/hikyuu/trade_sys/selector/imp/MultiFactorSelector.h +0 -3
  147. hikyuu/include/hikyuu/trade_sys/selector/imp/MultiFactorSelector2.h +49 -0
  148. hikyuu/include/hikyuu/trade_sys/selector/imp/logic/OperatorSelector.h +1 -1
  149. hikyuu/include/hikyuu/trade_sys/selector/imp/logic/OperatorValueSelector.h +1 -1
  150. hikyuu/include/hikyuu/trade_sys/signal/imp/BandSignal2.h +0 -4
  151. hikyuu/include/hikyuu/trade_sys/signal/imp/logic/AddValueSignal.h +2 -2
  152. hikyuu/include/hikyuu/trade_sys/signal/imp/logic/DivValueSignal.h +2 -2
  153. hikyuu/include/hikyuu/trade_sys/signal/imp/logic/MulValueSignal.h +2 -2
  154. hikyuu/include/hikyuu/trade_sys/signal/imp/logic/OperatorSignal.h +1 -1
  155. hikyuu/include/hikyuu/trade_sys/signal/imp/logic/OperatorValueSignal.h +4 -4
  156. hikyuu/include/hikyuu/trade_sys/signal/imp/logic/SubValueSignal.h +2 -2
  157. hikyuu/include/hikyuu/trade_sys/system/System.h +14 -1
  158. hikyuu/include/hikyuu/utilities/SpendTimer.h +17 -7
  159. hikyuu/include/hikyuu/utilities/arithmetic.h +55 -0
  160. hikyuu/include/hikyuu/utilities/db_connect/mysql/MySQLConnect.h +1 -1
  161. hikyuu/include/hikyuu/utilities/db_connect/mysql/MySQLStatement.h +1 -1
  162. hikyuu/include/hikyuu/utilities/db_connect/sqlite/SQLiteConnect.h +1 -1
  163. hikyuu/include/hikyuu/utilities/db_connect/sqlite/SQLiteStatement.h +1 -1
  164. hikyuu/include/hikyuu/utilities/plugin/PluginLoader.h +4 -1
  165. hikyuu/include/hikyuu/version.h +4 -4
  166. hikyuu/plugin/libbacktest.so +0 -0
  167. hikyuu/plugin/libclickhousedriver.so +0 -0
  168. hikyuu/plugin/libdataserver.so +0 -0
  169. hikyuu/plugin/libdevice.so +0 -0
  170. hikyuu/plugin/libextind.so +0 -0
  171. hikyuu/plugin/libhkuextra.so +0 -0
  172. hikyuu/plugin/libhkuviews.so +0 -0
  173. hikyuu/plugin/libimport2hdf5.so +0 -0
  174. hikyuu/plugin/libtmreport.so +0 -0
  175. hikyuu/trade_manage/__init__.pyi +603 -578
  176. hikyuu/trade_manage/broker.pyi +3 -3
  177. hikyuu/trade_manage/broker_easytrader.pyi +1 -1
  178. hikyuu/trade_manage/trade.pyi +603 -578
  179. hikyuu/util/__init__.pyi +2 -2
  180. hikyuu/util/singleton.pyi +1 -1
  181. {hikyuu-2.6.8.4.dist-info → hikyuu-2.6.9.dist-info}/METADATA +13 -13
  182. {hikyuu-2.6.8.4.dist-info → hikyuu-2.6.9.dist-info}/RECORD +185 -156
  183. {hikyuu-2.6.8.4.dist-info → hikyuu-2.6.9.dist-info}/top_level.txt +2 -1
  184. hikyuu/cpp/core39.pyi +0 -14385
  185. hikyuu/cpp/core39.so +0 -0
  186. hikyuu/data_driver/__init__.py +0 -49
  187. hikyuu/data_driver/jqdata_data_driver.py +0 -277
  188. hikyuu/data_driver/pytdx_data_driver.py +0 -292
  189. hikyuu/fetcher/stock/zh_stock_a_huatai.py +0 -51
  190. hikyuu/fetcher/stock/zh_stock_a_pytdx.py +0 -129
  191. hikyuu/gui/data/CollectToMemThread.py +0 -123
  192. hikyuu/gui/data/CollectToMySQLThread.py +0 -178
  193. hikyuu/gui/start_huatai_insight.py +0 -510
  194. hikyuu/tools/update_block_info.py +0 -168
  195. {hikyuu-2.6.8.4.dist-info → hikyuu-2.6.9.dist-info}/WHEEL +0 -0
  196. {hikyuu-2.6.8.4.dist-info → hikyuu-2.6.9.dist-info}/entry_points.txt +0 -0
@@ -4,97 +4,51 @@
4
4
  # Create on: 20240102
5
5
  # Author: fasiondog
6
6
 
7
- from concurrent.futures import ThreadPoolExecutor
8
- from hikyuu.data.common import MARKET, get_stk_code_name_list
7
+
9
8
  from hikyuu.util import *
10
9
  from hikyuu.fetcher.stock.zh_block_em import *
10
+ from hikyuu.data.download_block import *
11
11
 
12
12
 
13
13
  @spend_time
14
- def em_import_block_to_sqlite(connect, code_market_dict, categorys=('行业板块', '概念板块', '地域板块', '指数板块')):
15
- all_block_info = {}
16
-
17
- with ThreadPoolExecutor(4) as executor:
18
- if '行业板块' in categorys:
19
- t1 = executor.submit(get_all_hybk_info, code_market_dict)
20
-
21
- if '概念板块' in categorys:
22
- t2 = executor.submit(get_all_gnbk_info, code_market_dict)
23
-
24
- if '地域板块' in categorys:
25
- t3 = executor.submit(get_all_dybk_info, code_market_dict)
26
-
27
- if '指数板块' in categorys:
28
- t4 = executor.submit(get_all_zsbk_info, code_market_dict)
29
-
30
- success_fetch_hy = False
31
- if '行业板块' in categorys:
32
- x = t1.result()
33
- hku_info("获取行业板块信息完毕")
34
- if x:
35
- all_block_info["行业板块"] = x
36
- success_fetch_hy = True
37
-
38
- success_fetch_gn = False
39
- if '概念板块' in categorys:
40
- x = t2.result()
41
- hku_info("获取概念板块信息完毕")
42
- if x:
43
- all_block_info["概念板块"] = x
44
- success_fetch_gn = True
45
-
46
- success_fetch_dy = False
47
- if '地域板块' in categorys:
48
- x = t3.result()
49
- hku_info("获取地域板块信息完毕")
50
- if x:
51
- all_block_info["地域板块"] = x
52
- success_fetch_dy = True
53
-
54
- success_fetch_zs = False
55
- if '指数板块' in categorys:
56
- x = t4.result()
57
- hku_info("获取指数板块信息完毕")
58
- if x:
59
- all_block_info["指数板块"] = x
60
- success_fetch_zs = True
61
-
62
- blks = []
63
- if success_fetch_hy:
64
- blks.append('行业板块')
65
- if success_fetch_gn:
66
- blks.append('概念板块')
67
- if success_fetch_dy:
68
- blks.append('地域板块')
69
- if success_fetch_zs:
70
- blks.append('指数板块')
71
-
72
- print(blks)
14
+ def em_import_block_to_sqlite(connect):
15
+ download_block_info()
16
+
17
+ blocks_info = read_block_from_path()
18
+ blks = blocks_info['block']
19
+ blks_info = blocks_info['block_info']
73
20
 
74
21
  if not blks:
75
- return
22
+ return 0
76
23
 
77
24
  hku_info("更新数据库")
78
25
  cur = connect.cursor()
79
- if len(blks) == 1:
80
- sql = f"delete from block where category in ('{blks[0]}')"
81
- else:
82
- sql = f"delete from block where category in {tuple(blks)}"
83
- hku_info(sql)
26
+ sql = f"delete from block where category in {tuple(blks.keys())}"
27
+ cur.execute(sql)
28
+ sql = f"delete from BlockIndex where category in {tuple(blks.keys())}"
84
29
  cur.execute(sql)
85
30
 
86
31
  insert_records = []
87
32
 
88
- for category in all_block_info:
89
- for name in all_block_info[category]:
90
- for code in all_block_info[category][name]:
33
+ for category, blocks in blks.items():
34
+ for name, codes in blocks.items():
35
+ for code in codes:
91
36
  insert_records.append((category, name, code))
92
37
 
93
38
  if insert_records:
94
39
  sql = "insert into block (category, name, market_code) values (?,?,?)"
95
- hku_info(f"insert block records: {len(insert_records)}")
96
40
  cur.executemany(sql, insert_records)
97
41
 
42
+ index_records = []
43
+ for category, blocks in blks_info.items():
44
+ for name, index_code in blocks.items():
45
+ if len(index_code) == 8:
46
+ index_records.append((category, name, index_code))
47
+ if index_records:
48
+ sql = "insert into BlockIndex (category, name, market_code) values (?,?,?)"
49
+ cur.executemany(sql, index_records)
50
+ hku_info(f"insert block index records: {len(index_records)}")
51
+
98
52
  connect.commit()
99
53
  cur.close()
100
54
  return len(insert_records)
@@ -111,12 +65,6 @@ if __name__ == "__main__":
111
65
  connect = sqlite3.connect(dest_dir + "/stock.db")
112
66
  create_database(connect)
113
67
 
114
- x = get_stk_code_name_list(MARKET.SH)
115
- code_market_dict = {}
116
- for v in x:
117
- code_market_dict[v["code"]] = MARKET.SH
118
- # print(code_market_dict)
119
-
120
- em_import_block_to_sqlite(connect, code_market_dict, categorys=('地域板块',))
68
+ em_import_block_to_sqlite(connect)
121
69
 
122
70
  connect.close()
@@ -210,8 +210,8 @@ future = False
210
210
  day = True
211
211
  min = True
212
212
  min5 = True
213
- trans = True
214
- time = True
213
+ trans = False
214
+ time = False
215
215
  day_start_date = 1990-12-19
216
216
  min_start_date = 2023-09-19
217
217
  min5_start_date = 2023-09-19
@@ -251,7 +251,7 @@ enable = False
251
251
  enable = False
252
252
  ;tmpdir = D:/stock
253
253
  ;host = 127.0.0.1
254
- :http_port = 8123
254
+ ;http_port = 8123
255
255
  ;port = 9000
256
256
  ;usr = root
257
257
  ;pwd =
@@ -29,7 +29,7 @@ from pytdx.hq import TDXParams
29
29
 
30
30
  from hikyuu.util import hku_error, hku_debug, hku_run_ignore_exception
31
31
 
32
- from hikyuu import Datetime
32
+ from hikyuu import Datetime, roundEx
33
33
  from hikyuu.data.common import *
34
34
  from hikyuu.data.common_pytdx import to_pytdx_market, pytdx_get_day_trans
35
35
  from hikyuu.data.common_clickhouse import (
@@ -304,6 +304,10 @@ def import_one_stock_data(
304
304
  hku_error("Failed translate datetime: {}, from {}! {}".format(bar, api.ip, e))
305
305
  continue
306
306
 
307
+ if 'open' not in bar or 'high' not in bar or 'low' not in bar or 'close' not in bar or 'vol' not in bar or 'amount' not in bar:
308
+ hku_warn(f"Ignore invalid bar: {bar_datetime}, missing fields!")
309
+ continue
310
+
307
311
  if last_krecord is not None and bar_datetime == last_datetime:
308
312
  if abs(last_krecord[1] - bar["open"]) / last_krecord[1] > 0.01:
309
313
  hku_error(
@@ -325,7 +329,7 @@ def import_one_stock_data(
325
329
  hku_error(
326
330
  f"fetch data from tdx error! {bar_datetime} {ktype} {market}{code} last_krecord amount: {last_krecord[5]}, bar: {bar['amount']*0.001}")
327
331
  return 0
328
- if ktype == 'DAY' and last_krecord[5] != 0.0 and abs(last_krecord[6] - bar["vol"]) / last_krecord[6] > 0.1:
332
+ if ktype == 'DAY' and last_krecord[6] != 0.0 and last_krecord[5] != 0.0 and abs(last_krecord[6] - bar["vol"]) / last_krecord[6] > 0.1:
329
333
  hku_error(
330
334
  f"fetch data from tdx error! {bar_datetime} {ktype} {market}{code} last_krecord count: {last_krecord[6]}, bar: {bar['vol']}")
331
335
  return 0
@@ -343,12 +347,12 @@ def import_one_stock_data(
343
347
  (
344
348
  table[1], table[2],
345
349
  Datetime(bar_datetime).timestamp_utc()//1000000,
346
- bar["open"],
347
- bar["high"],
348
- bar["low"],
349
- bar["close"],
350
- bar["amount"] * 0.001,
351
- bar["vol"]
350
+ int(roundEx(bar["open"], 3)*1000),
351
+ int(roundEx(bar["high"], 3)*1000),
352
+ int(roundEx(bar["low"], 3)*1000),
353
+ int(roundEx(bar["close"], 3)*1000),
354
+ int(roundEx(bar["amount"], 0)),
355
+ int(roundEx(bar["vol"], 3)*1000)
352
356
  # bar['vol'] if stktype == 2 else round(bar['vol'] * 0.01)
353
357
  )
354
358
  )
@@ -592,8 +596,8 @@ def import_on_stock_trans(connect, api, market, stock_record, max_days):
592
596
  (
593
597
  market, code,
594
598
  Datetime(cur_date * 1000000 + minute * 100 + second).timestamp_utc()//1000000,
595
- record["price"],
596
- record["vol"],
599
+ int(roundEx(record["price"], 3) * 1000.0),
600
+ int(record["vol"]),
597
601
  record["buyorsell"],
598
602
  )
599
603
  )
@@ -698,7 +702,7 @@ def import_on_stock_time(connect, api, market, stock_record, max_days):
698
702
  time = 1400
699
703
  try:
700
704
  time_buf.append((market, code, Datetime(this_date + time).timestamp_utc() //
701
- ticks, record['price'], record['vol']))
705
+ ticks, int(roundEx(record['price'], 3) * 1000.0), int(record['vol'])))
702
706
  time += 1
703
707
  except Exception as e:
704
708
  hku_error("Failed trans record {}! {}".format(record, e))
@@ -286,7 +286,7 @@ def import_one_stock_data(connect, api, h5file, market, ktype, stock_record, sta
286
286
  bar_list = get_bars(pytdx_kline_type, pytdx_market, code, n * 800, step)
287
287
  n -= 1
288
288
  if bar_list is None:
289
- print(code, "invalid!!")
289
+ # print(code, "invalid!!")
290
290
  continue
291
291
 
292
292
  for bar in bar_list:
@@ -302,6 +302,10 @@ def import_one_stock_data(connect, api, h5file, market, ktype, stock_record, sta
302
302
  hku_error("Failed translate datetime: {}, from {}! {}".format(bar, api.ip, e))
303
303
  continue
304
304
 
305
+ if 'open' not in bar or 'high' not in bar or 'low' not in bar or 'close' not in bar or 'vol' not in bar or 'amount' not in bar:
306
+ hku_warn(f"Ignore invalid bar: {bar_datetime}, missing fields!")
307
+ continue
308
+
305
309
  if need_check and bar_datetime == last_datetime:
306
310
  # print(f'{bar_datetime} {ktype} {market}{code}')
307
311
  if abs(last_krecord['openPrice']*0.001 - bar["open"]) / (last_krecord['openPrice']*0.001) > 0.02:
@@ -324,7 +328,7 @@ def import_one_stock_data(connect, api, h5file, market, ktype, stock_record, sta
324
328
  hku_error(
325
329
  f"fetch data from tdx error! {bar_datetime} {ktype} {market}{code} last_krecord amount: {last_krecord['transAmount']}, bar: {bar['amount']*0.001}")
326
330
  return 0
327
- if ktype == 'DAY' and last_krecord['transAmount'] != 0.0 and abs(last_krecord['transCount'] - round(bar["vol"])) / last_krecord['transCount'] > 0.1:
331
+ if ktype == 'DAY' and last_krecord['transCount'] != 0.0 and abs(last_krecord['transCount'] - round(bar["vol"])) / last_krecord['transCount'] > 0.1:
328
332
  hku_error(
329
333
  f"fetch data from tdx error! {bar_datetime} {ktype} {market}{code} last_krecord count: {last_krecord['transCount']}, bar: {bar['vol']}")
330
334
  return 0
@@ -348,6 +348,10 @@ def import_one_stock_data(
348
348
  hku_error("Failed translate datetime: {}, from {}! {}".format(bar, api.ip, e))
349
349
  continue
350
350
 
351
+ if 'open' not in bar or 'high' not in bar or 'low' not in bar or 'close' not in bar or 'vol' not in bar or 'amount' not in bar:
352
+ hku_warn(f"Ignore invalid bar: {bar_datetime}, missing fields!")
353
+ continue
354
+
351
355
  if last_krecord is not None and bar_datetime == last_datetime:
352
356
  if abs(last_krecord[1] - bar["open"]) / last_krecord[1] > 0.01:
353
357
  hku_error(
@@ -369,7 +373,7 @@ def import_one_stock_data(
369
373
  hku_error(
370
374
  f"fetch data from tdx error! {bar_datetime} {ktype} {market}{code} last_krecord amount: {last_krecord[5]}, bar: {bar['amount']*0.001}")
371
375
  return 0
372
- if ktype == 'DAY' and last_krecord[5] != 0.0 and abs(last_krecord[6] - bar["vol"]) / last_krecord[6] > 0.1:
376
+ if ktype == 'DAY' and last_krecord[6] != 0.0 and abs(last_krecord[6] - bar["vol"]) / last_krecord[6] > 0.1:
373
377
  hku_error(
374
378
  f"fetch data from tdx error! {bar_datetime} {ktype} {market}{code} last_krecord count: {last_krecord[6]}, bar: {bar['vol']}")
375
379
  return 0
@@ -34,7 +34,7 @@ def pytdx_import_weight_to_clickhouse(pytdx_api, connect, market):
34
34
 
35
35
  total_count = 0
36
36
  update_count = 0
37
- stock_list = connect.query(f"select code from `hku_base`.`stock` where market='{market}' and valid=1")
37
+ stock_list = connect.query(f"select code from `hku_base`.`stock` where market='{market}'")
38
38
  stockid_list = stock_list.result_rows
39
39
 
40
40
  for stockrecord in stockid_list:
@@ -38,7 +38,7 @@ def pytdx_import_weight_to_mysql(pytdx_api, connect, market):
38
38
  pytdx_market = to_pytdx_market(market)
39
39
 
40
40
  total_count = 0
41
- cur.execute("select stockid, code from `hku_base`.`stock` where marketid=%s and valid=1" % (marketid))
41
+ cur.execute("select stockid, code from `hku_base`.`stock` where marketid=%s" % (marketid))
42
42
  stockid_list = [x for x in cur.fetchall()]
43
43
  cur.close()
44
44
 
@@ -35,7 +35,7 @@ def pytdx_import_weight_to_sqlite(pytdx_api, connect, market):
35
35
  pytdx_market = to_pytdx_market(market)
36
36
 
37
37
  total_count = 0
38
- stockid_list = cur.execute("select stockid, code from Stock where marketid=%s and valid=1" % (marketid))
38
+ stockid_list = cur.execute("select stockid, code from Stock where marketid=%s" % (marketid))
39
39
  stockid_list = [x for x in stockid_list]
40
40
  cur.close()
41
41
 
@@ -13,7 +13,7 @@ from hikyuu.util import *
13
13
  def import_zh_bond10_to_clickhouse(connect):
14
14
  sql = "select max(date) from hku_base.zh_bond10"
15
15
  start_date = connect.command(sql)
16
- if type(start_date) == int:
16
+ if start_date == 0:
17
17
  start_date = "19901219"
18
18
  else:
19
19
  last_date = start_date
@@ -1,12 +1,12 @@
1
1
  from __future__ import annotations
2
- from hikyuu.cpp.core39 import ConditionBase
3
- from hikyuu.cpp.core39 import EnvironmentBase
4
- from hikyuu.cpp.core39 import Indicator
5
- from hikyuu.cpp.core39 import KData
6
- from hikyuu.cpp.core39 import Portfolio
7
- from hikyuu.cpp.core39 import SignalBase
8
- from hikyuu.cpp.core39 import System
9
- from hikyuu.cpp.core39 import TradeManager
2
+ from hikyuu.cpp.core310 import ConditionBase
3
+ from hikyuu.cpp.core310 import EnvironmentBase
4
+ from hikyuu.cpp.core310 import Indicator
5
+ from hikyuu.cpp.core310 import KData
6
+ from hikyuu.cpp.core310 import Portfolio
7
+ from hikyuu.cpp.core310 import SignalBase
8
+ from hikyuu.cpp.core310 import System
9
+ from hikyuu.cpp.core310 import TradeManager
10
10
  from hikyuu.draw.drawplot.bokeh_draw import ax_draw_macd as bk_ax_draw_macd
11
11
  from hikyuu.draw.drawplot.bokeh_draw import ax_draw_macd2 as bk_ax_draw_macd2
12
12
  from hikyuu.draw.drawplot.bokeh_draw import create_figure as bk_create_figure