hikyuu 2.6.8.3__py3-none-manylinux2014_aarch64.whl → 2.7.3__py3-none-manylinux2014_aarch64.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 (280) hide show
  1. hikyuu/__init__.py +55 -23
  2. hikyuu/__init__.pyi +626 -595
  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 +587 -130
  9. hikyuu/cpp/core310.so +0 -0
  10. hikyuu/cpp/core311.pyi +587 -130
  11. hikyuu/cpp/core311.so +0 -0
  12. hikyuu/cpp/core312.pyi +587 -130
  13. hikyuu/cpp/core312.so +0 -0
  14. hikyuu/cpp/core313.pyi +587 -130
  15. hikyuu/cpp/core313.so +0 -0
  16. hikyuu/cpp/i18n/zh_CN/hikyuu.mo +0 -0
  17. hikyuu/cpp/i18n/zh_CN/hikyuu_plugin.mo +0 -0
  18. hikyuu/cpp/libboost_atomic.so +0 -0
  19. hikyuu/cpp/libboost_atomic.so.1.90.0 +0 -0
  20. hikyuu/cpp/libboost_charconv.so +0 -0
  21. hikyuu/cpp/libboost_charconv.so.1.90.0 +0 -0
  22. hikyuu/cpp/libboost_chrono.so +0 -0
  23. hikyuu/cpp/libboost_chrono.so.1.90.0 +0 -0
  24. hikyuu/cpp/libboost_container.so +0 -0
  25. hikyuu/cpp/libboost_container.so.1.90.0 +0 -0
  26. hikyuu/cpp/libboost_date_time.so +0 -0
  27. hikyuu/cpp/libboost_date_time.so.1.90.0 +0 -0
  28. hikyuu/cpp/libboost_locale.so +0 -0
  29. hikyuu/cpp/libboost_locale.so.1.90.0 +0 -0
  30. hikyuu/cpp/libboost_random.so +0 -0
  31. hikyuu/cpp/libboost_random.so.1.90.0 +0 -0
  32. hikyuu/cpp/libboost_serialization.so +0 -0
  33. hikyuu/cpp/libboost_serialization.so.1.90.0 +0 -0
  34. hikyuu/cpp/libboost_thread.so +0 -0
  35. hikyuu/cpp/libboost_thread.so.1.90.0 +0 -0
  36. hikyuu/cpp/libboost_wserialization.so +0 -0
  37. hikyuu/cpp/libboost_wserialization.so.1.90.0 +0 -0
  38. hikyuu/cpp/libhikyuu.so +0 -0
  39. hikyuu/cpp/libhku_hdf5.so +0 -0
  40. hikyuu/cpp/libhku_hdf5.so.200 +0 -0
  41. hikyuu/cpp/libhku_hdf5.so.200.2.0 +0 -0
  42. hikyuu/cpp/libhku_hdf5_cpp.so +0 -0
  43. hikyuu/cpp/libhku_hdf5_cpp.so.200 +0 -0
  44. hikyuu/cpp/libhku_hdf5_cpp.so.200.2.0 +0 -0
  45. hikyuu/cpp/libhku_hdf5_hl.so +0 -0
  46. hikyuu/cpp/libhku_hdf5_hl.so.200 +0 -0
  47. hikyuu/cpp/libhku_hdf5_hl.so.200.1.0 +0 -0
  48. hikyuu/cpp/libhku_hdf5_hl_cpp.so +0 -0
  49. hikyuu/cpp/libhku_hdf5_hl_cpp.so.200 +0 -0
  50. hikyuu/cpp/libhku_hdf5_hl_cpp.so.200.1.0 +0 -0
  51. hikyuu/cpp/libhku_hdf5_tools.so +0 -0
  52. hikyuu/cpp/libhku_hdf5_tools.so.200 +0 -0
  53. hikyuu/cpp/libhku_hdf5_tools.so.200.1.1 +0 -0
  54. hikyuu/cpp/libsqlite3.so +0 -0
  55. hikyuu/data/clickhouse_upgrade/0001.sql +2 -0
  56. hikyuu/data/clickhouse_upgrade/createdb.sql +105 -105
  57. hikyuu/data/common.py +3 -3
  58. hikyuu/data/common_clickhouse.py +1 -3
  59. hikyuu/data/download_block.py +351 -0
  60. hikyuu/data/em_block_to_clickhouse.py +26 -74
  61. hikyuu/data/em_block_to_mysql.py +25 -75
  62. hikyuu/data/em_block_to_sqlite.py +26 -78
  63. hikyuu/data/hku_config_template.py +33 -6
  64. hikyuu/data/mysql_upgrade/0029.sql +2 -0
  65. hikyuu/data/pytdx_to_clickhouse.py +96 -38
  66. hikyuu/data/pytdx_to_h5.py +78 -29
  67. hikyuu/data/pytdx_to_mysql.py +69 -21
  68. hikyuu/data/pytdx_weight_to_clickhouse.py +3 -1
  69. hikyuu/data/pytdx_weight_to_mysql.py +3 -1
  70. hikyuu/data/pytdx_weight_to_sqlite.py +3 -1
  71. hikyuu/data/sqlite_upgrade/0029.sql +4 -0
  72. hikyuu/data/tdx_to_clickhouse.py +2 -2
  73. hikyuu/data/tdx_to_h5.py +11 -11
  74. hikyuu/data/tdx_to_mysql.py +2 -2
  75. hikyuu/data/zh_bond10_to_clickhouse.py +1 -1
  76. hikyuu/draw/__init__.pyi +1 -1
  77. hikyuu/draw/drawplot/__init__.pyi +8 -8
  78. hikyuu/draw/drawplot/bokeh_draw.pyi +610 -583
  79. hikyuu/draw/drawplot/common.pyi +1 -1
  80. hikyuu/draw/drawplot/echarts_draw.pyi +612 -585
  81. hikyuu/draw/drawplot/matplotlib_draw.py +12 -76
  82. hikyuu/draw/drawplot/matplotlib_draw.pyi +623 -596
  83. hikyuu/draw/elder.pyi +11 -11
  84. hikyuu/draw/kaufman.pyi +18 -18
  85. hikyuu/draw/volume.pyi +10 -10
  86. hikyuu/examples/notebook/Demo/Demo1.ipynb +48 -33
  87. hikyuu/extend.py +0 -7
  88. hikyuu/extend.pyi +599 -573
  89. hikyuu/fetcher/stock/zh_block_em.py +12 -40
  90. hikyuu/gui/HikyuuTDX.py +140 -33
  91. hikyuu/gui/data/CollectSpotThread.py +1 -1
  92. hikyuu/gui/data/EscapetimeThread.py +8 -14
  93. hikyuu/gui/data/ImportBlockInfoTask.py +3 -10
  94. hikyuu/gui/data/MainWindow.py +1300 -761
  95. hikyuu/gui/data/SchedImportThread.py +2 -2
  96. hikyuu/gui/data/UsePytdxImportToH5Thread.py +3 -3
  97. hikyuu/gui/data/UseQmtImportToH5Thread.py +2 -2
  98. hikyuu/gui/data/UseTdxImportToH5Thread.py +3 -3
  99. hikyuu/gui/data/tool.py +32 -25
  100. hikyuu/gui/dataserver.py +5 -3
  101. hikyuu/gui/images/liandongxiaopu.png +0 -0
  102. hikyuu/gui/importdata.py +4 -0
  103. hikyuu/hub.pyi +6 -6
  104. hikyuu/include/hikyuu/DataType.h +4 -16
  105. hikyuu/include/hikyuu/KData.h +6 -3
  106. hikyuu/include/hikyuu/KDataPrivatedBufferImp.h +1 -1
  107. hikyuu/include/hikyuu/KDataSharedBufferImp.h +1 -1
  108. hikyuu/include/hikyuu/KQuery.h +2 -2
  109. hikyuu/include/hikyuu/Stock.h +4 -1
  110. hikyuu/include/hikyuu/StockManager.h +29 -4
  111. hikyuu/include/hikyuu/StrategyContext.h +4 -4
  112. hikyuu/include/hikyuu/data_driver/BaseInfoDriver.h +9 -0
  113. hikyuu/include/hikyuu/data_driver/BlockInfoDriver.h +6 -0
  114. hikyuu/include/hikyuu/data_driver/KDataDriver.h +24 -1
  115. hikyuu/include/hikyuu/data_driver/base_info/mysql/MySQLBaseInfoDriver.h +1 -1
  116. hikyuu/include/hikyuu/data_driver/base_info/sqlite/SQLiteBaseInfoDriver.h +1 -1
  117. hikyuu/include/hikyuu/data_driver/block_info/mysql/MySQLBlockInfoDriver.h +2 -1
  118. hikyuu/include/hikyuu/data_driver/block_info/qianlong/QLBlockInfoDriver.h +2 -1
  119. hikyuu/include/hikyuu/data_driver/block_info/sqlite/SQLiteBlockInfoDriver.h +2 -1
  120. hikyuu/include/hikyuu/data_driver/kdata/DoNothingKDataDriver.h +1 -1
  121. hikyuu/include/hikyuu/data_driver/kdata/cvs/KDataTempCsvDriver.h +1 -1
  122. hikyuu/include/hikyuu/data_driver/kdata/hdf5/H5KDataDriver.h +1 -1
  123. hikyuu/include/hikyuu/data_driver/kdata/mysql/MySQLKDataDriver.h +6 -2
  124. hikyuu/include/hikyuu/data_driver/kdata/sqlite/SQLiteKDataDriver.h +2 -2
  125. hikyuu/include/hikyuu/data_driver/kdata/tdx/TdxKDataDriver.h +1 -1
  126. hikyuu/include/hikyuu/global/sysinfo.h +24 -5
  127. hikyuu/include/hikyuu/hikyuu.h +1 -1
  128. hikyuu/include/hikyuu/indicator/IndicatorImp.h +1 -1
  129. hikyuu/include/hikyuu/indicator/build_in.h +1 -0
  130. hikyuu/include/hikyuu/indicator/crt/CYCLE.h +4 -4
  131. hikyuu/include/hikyuu/indicator/crt/HSL.h +2 -2
  132. hikyuu/include/hikyuu/indicator/crt/QUANTILE_TRUNC.h +30 -0
  133. hikyuu/include/hikyuu/indicator/crt/TURNOVER.h +1 -0
  134. hikyuu/include/hikyuu/indicator/crt/ZSCORE.h +2 -2
  135. hikyuu/include/hikyuu/indicator/imp/IQuantileTrunc.h +25 -0
  136. hikyuu/include/hikyuu/lang.h +15 -2
  137. hikyuu/include/hikyuu/misc.h +38 -0
  138. hikyuu/include/hikyuu/plugin/KDataToClickHouseImporter.h +40 -0
  139. hikyuu/include/hikyuu/plugin/KDataToMySQLImporter.h +40 -0
  140. hikyuu/include/hikyuu/plugin/checkdata.h +20 -0
  141. hikyuu/include/hikyuu/plugin/dataserver.h +2 -1
  142. hikyuu/include/hikyuu/plugin/device.h +10 -0
  143. hikyuu/include/hikyuu/plugin/extind.h +40 -0
  144. hikyuu/include/hikyuu/plugin/hkuextra.h +1 -17
  145. hikyuu/include/hikyuu/plugin/interface/CheckDataPluginInterface.h +25 -0
  146. hikyuu/include/hikyuu/plugin/interface/DataServerPluginInterface.h +2 -2
  147. hikyuu/include/hikyuu/plugin/interface/DevicePluginInterface.h +2 -0
  148. hikyuu/include/hikyuu/plugin/interface/ExtendIndicatorsPluginInterface.h +12 -0
  149. hikyuu/include/hikyuu/plugin/interface/HkuExtraPluginInterface.h +1 -13
  150. hikyuu/include/hikyuu/plugin/interface/ImportKDataToClickHousePluginInterface.h +44 -0
  151. hikyuu/include/hikyuu/plugin/interface/ImportKDataToMySQLPluginInterface.h +42 -0
  152. hikyuu/include/hikyuu/plugin/interface/plugins.h +9 -1
  153. hikyuu/include/hikyuu/python/convert_any.h +9 -6
  154. hikyuu/include/hikyuu/python/pybind_utils.h +4 -11
  155. hikyuu/include/hikyuu/strategy/RunSystemInStrategy.h +3 -0
  156. hikyuu/include/hikyuu/strategy/Strategy.h +1 -1
  157. hikyuu/include/hikyuu/trade_manage/Performance.h +4 -4
  158. hikyuu/include/hikyuu/trade_manage/TradeManagerBase.h +10 -2
  159. hikyuu/include/hikyuu/trade_manage/TradeRecord.h +2 -1
  160. hikyuu/include/hikyuu/trade_sys/allocatefunds/AllocateFundsBase.h +0 -1
  161. hikyuu/include/hikyuu/trade_sys/allocatefunds/build_in.h +1 -0
  162. hikyuu/include/hikyuu/trade_sys/allocatefunds/crt/AF_FixedAmount.h +26 -0
  163. hikyuu/include/hikyuu/trade_sys/allocatefunds/imp/FixAmountFunds.h +18 -0
  164. hikyuu/include/hikyuu/trade_sys/condition/ConditionBase.h +0 -1
  165. hikyuu/include/hikyuu/trade_sys/environment/EnvironmentBase.h +0 -1
  166. hikyuu/include/hikyuu/trade_sys/moneymanager/MoneyManagerBase.h +0 -1
  167. hikyuu/include/hikyuu/trade_sys/moneymanager/imp/FixedCapitalFundsMM.h +0 -4
  168. hikyuu/include/hikyuu/trade_sys/multifactor/MultiFactorBase.h +36 -4
  169. hikyuu/include/hikyuu/trade_sys/multifactor/NormalizeBase.h +124 -0
  170. hikyuu/include/hikyuu/trade_sys/multifactor/ScoresFilterBase.h +124 -0
  171. hikyuu/include/hikyuu/trade_sys/multifactor/build_in.h +3 -0
  172. hikyuu/include/hikyuu/trade_sys/multifactor/buildin_norm.h +36 -0
  173. hikyuu/include/hikyuu/trade_sys/multifactor/buildin_scfilter.h +51 -0
  174. hikyuu/include/hikyuu/trade_sys/multifactor/filter/GroupSCFilter.h +24 -0
  175. hikyuu/include/hikyuu/trade_sys/multifactor/filter/IgnoreLessOrEqualValueSCFilter.h +24 -0
  176. hikyuu/include/hikyuu/trade_sys/multifactor/filter/IgnoreNanSCFilter.h +24 -0
  177. hikyuu/include/hikyuu/trade_sys/multifactor/filter/MinAmountPercentSCFilter.h +25 -0
  178. hikyuu/include/hikyuu/trade_sys/multifactor/filter/PriceSCFilter.h +24 -0
  179. hikyuu/include/hikyuu/trade_sys/multifactor/filter/TopNSCFilter.h +24 -0
  180. hikyuu/include/hikyuu/trade_sys/multifactor/imp/EqualWeightMultiFactor.h +1 -1
  181. hikyuu/include/hikyuu/trade_sys/multifactor/imp/ICIRMultiFactor.h +1 -1
  182. hikyuu/include/hikyuu/trade_sys/multifactor/imp/ICMultiFactor.h +1 -1
  183. hikyuu/include/hikyuu/trade_sys/multifactor/imp/WeightMultiFactor.h +1 -1
  184. hikyuu/include/hikyuu/trade_sys/multifactor/normalize/NormMinMax.h +23 -0
  185. hikyuu/include/hikyuu/trade_sys/multifactor/normalize/NormQuantile.h +28 -0
  186. hikyuu/include/hikyuu/trade_sys/multifactor/normalize/NormQuantileUniform.h +28 -0
  187. hikyuu/include/hikyuu/trade_sys/multifactor/normalize/NormZScore.h +25 -0
  188. hikyuu/include/hikyuu/trade_sys/multifactor/normalize/__init__.py +1 -0
  189. hikyuu/include/hikyuu/trade_sys/multifactor/normalize/quantile_trunc.h +16 -0
  190. hikyuu/include/hikyuu/trade_sys/portfolio/Portfolio.h +20 -13
  191. hikyuu/include/hikyuu/trade_sys/portfolio/imp/SimplePortfolio.h +7 -0
  192. hikyuu/include/hikyuu/trade_sys/portfolio/imp/WithoutAFPortfolio.h +7 -0
  193. hikyuu/include/hikyuu/trade_sys/profitgoal/ProfitGoalBase.h +9 -11
  194. hikyuu/include/hikyuu/trade_sys/selector/SelectorBase.h +49 -1
  195. hikyuu/include/hikyuu/trade_sys/selector/build_in.h +1 -0
  196. hikyuu/include/hikyuu/trade_sys/selector/crt/SE_MultiFactor2.h +40 -0
  197. hikyuu/include/hikyuu/trade_sys/selector/imp/MultiFactorSelector.h +0 -3
  198. hikyuu/include/hikyuu/trade_sys/selector/imp/MultiFactorSelector2.h +49 -0
  199. hikyuu/include/hikyuu/trade_sys/selector/imp/logic/OperatorSelector.h +1 -1
  200. hikyuu/include/hikyuu/trade_sys/selector/imp/logic/OperatorValueSelector.h +1 -1
  201. hikyuu/include/hikyuu/trade_sys/signal/SignalBase.h +0 -1
  202. hikyuu/include/hikyuu/trade_sys/signal/imp/BandSignal2.h +0 -4
  203. hikyuu/include/hikyuu/trade_sys/signal/imp/logic/AddValueSignal.h +2 -2
  204. hikyuu/include/hikyuu/trade_sys/signal/imp/logic/DivValueSignal.h +2 -2
  205. hikyuu/include/hikyuu/trade_sys/signal/imp/logic/MulValueSignal.h +2 -2
  206. hikyuu/include/hikyuu/trade_sys/signal/imp/logic/OperatorSignal.h +1 -1
  207. hikyuu/include/hikyuu/trade_sys/signal/imp/logic/OperatorValueSignal.h +4 -4
  208. hikyuu/include/hikyuu/trade_sys/signal/imp/logic/SubValueSignal.h +2 -2
  209. hikyuu/include/hikyuu/trade_sys/slippage/SlippageBase.h +0 -1
  210. hikyuu/include/hikyuu/trade_sys/slippage/build_in.h +5 -1
  211. hikyuu/include/hikyuu/trade_sys/slippage/crt/SP_LogNormal.h +22 -0
  212. hikyuu/include/hikyuu/trade_sys/slippage/crt/SP_Normal.h +22 -0
  213. hikyuu/include/hikyuu/trade_sys/slippage/crt/SP_TruncNormal.h +25 -0
  214. hikyuu/include/hikyuu/trade_sys/slippage/crt/SP_Uniform.h +23 -0
  215. hikyuu/include/hikyuu/trade_sys/slippage/imp/LogNormalSlippage.h +28 -0
  216. hikyuu/include/hikyuu/trade_sys/slippage/imp/NormalSlippage.h +28 -0
  217. hikyuu/include/hikyuu/trade_sys/slippage/imp/TruncNormalSlippage.h +28 -0
  218. hikyuu/include/hikyuu/trade_sys/slippage/imp/UniformSlippage.h +24 -0
  219. hikyuu/include/hikyuu/trade_sys/stoploss/StoplossBase.h +0 -1
  220. hikyuu/include/hikyuu/trade_sys/system/System.h +15 -3
  221. hikyuu/include/hikyuu/utilities/Log.h +6 -7
  222. hikyuu/include/hikyuu/utilities/Parameter.h +17 -0
  223. hikyuu/include/hikyuu/utilities/SpendTimer.h +17 -7
  224. hikyuu/include/hikyuu/utilities/arithmetic.h +55 -0
  225. hikyuu/include/hikyuu/utilities/config.h +28 -0
  226. hikyuu/include/hikyuu/utilities/db_connect/mysql/MySQLConnect.h +1 -1
  227. hikyuu/include/hikyuu/utilities/db_connect/mysql/MySQLStatement.h +1 -1
  228. hikyuu/include/hikyuu/utilities/db_connect/sqlite/SQLiteConnect.h +1 -1
  229. hikyuu/include/hikyuu/utilities/db_connect/sqlite/SQLiteStatement.h +1 -1
  230. hikyuu/include/hikyuu/utilities/plugin/PluginBase.h +17 -2
  231. hikyuu/include/hikyuu/utilities/plugin/PluginLoader.h +4 -1
  232. hikyuu/include/hikyuu/utilities/plugin/PluginManager.h +41 -22
  233. hikyuu/include/hikyuu/utilities/thread/GlobalStealThreadPool.h +1 -2
  234. hikyuu/include/hikyuu/utilities/thread/GlobalThreadPool.h +1 -1
  235. hikyuu/include/hikyuu/utilities/thread/MQStealThreadPool.h +286 -0
  236. hikyuu/include/hikyuu/utilities/thread/MQThreadPool.h +1 -0
  237. hikyuu/include/hikyuu/utilities/thread/StealThreadPool.h +297 -0
  238. hikyuu/include/hikyuu/utilities/thread/ThreadPool.h +1 -0
  239. hikyuu/include/hikyuu/utilities/thread/WorkStealQueue.h +9 -8
  240. hikyuu/include/hikyuu/utilities/thread/algorithm.h +64 -14
  241. hikyuu/include/hikyuu/version.h +5 -5
  242. hikyuu/plugin/libbacktest.so +0 -0
  243. hikyuu/plugin/libcheckdata.so +0 -0
  244. hikyuu/plugin/libclickhousedriver.so +0 -0
  245. hikyuu/plugin/libdataserver.so +0 -0
  246. hikyuu/{cpp/core39.so → plugin/libdataserver_parquet.so} +0 -0
  247. hikyuu/plugin/libdevice.so +0 -0
  248. hikyuu/plugin/libextind.so +0 -0
  249. hikyuu/plugin/libhkuextra.so +0 -0
  250. hikyuu/plugin/libimport2ch.so +0 -0
  251. hikyuu/plugin/libimport2hdf5.so +0 -0
  252. hikyuu/plugin/libimport2mysql.so +0 -0
  253. hikyuu/plugin/libtmreport.so +0 -0
  254. hikyuu/trade_manage/__init__.pyi +607 -582
  255. hikyuu/trade_manage/broker.pyi +3 -3
  256. hikyuu/trade_manage/broker_easytrader.pyi +1 -1
  257. hikyuu/trade_manage/trade.py +0 -2
  258. hikyuu/trade_manage/trade.pyi +607 -582
  259. hikyuu/trade_sys/trade_sys.py +54 -5
  260. hikyuu/util/__init__.pyi +2 -2
  261. hikyuu/util/singleton.pyi +1 -1
  262. {hikyuu-2.6.8.3.dist-info → hikyuu-2.7.3.dist-info}/METADATA +42 -32
  263. {hikyuu-2.6.8.3.dist-info → hikyuu-2.7.3.dist-info}/RECORD +267 -212
  264. {hikyuu-2.6.8.3.dist-info → hikyuu-2.7.3.dist-info}/top_level.txt +2 -2
  265. hikyuu/cpp/core39.pyi +0 -14190
  266. hikyuu/data/pytdx_to_taos.py +0 -736
  267. hikyuu/data_driver/__init__.py +0 -49
  268. hikyuu/data_driver/jqdata_data_driver.py +0 -277
  269. hikyuu/data_driver/pytdx_data_driver.py +0 -292
  270. hikyuu/fetcher/stock/zh_stock_a_huatai.py +0 -51
  271. hikyuu/fetcher/stock/zh_stock_a_pytdx.py +0 -129
  272. hikyuu/gui/data/CollectToMemThread.py +0 -123
  273. hikyuu/gui/data/CollectToMySQLThread.py +0 -178
  274. hikyuu/gui/start_huatai_insight.py +0 -510
  275. hikyuu/include/hikyuu/views/arrow_common.h +0 -38
  276. hikyuu/include/hikyuu/views/arrow_views.h +0 -117
  277. hikyuu/tools/update_block_info.py +0 -168
  278. /hikyuu/include/hikyuu/{views → trade_sys/multifactor/filter}/__init__.py +0 -0
  279. {hikyuu-2.6.8.3.dist-info → hikyuu-2.7.3.dist-info}/WHEEL +0 -0
  280. {hikyuu-2.6.8.3.dist-info → hikyuu-2.7.3.dist-info}/entry_points.txt +0 -0
@@ -23,13 +23,15 @@
23
23
  # SOFTWARE.
24
24
 
25
25
  import sys
26
+ import os
26
27
  import math
27
28
  import datetime
28
29
  import sqlite3
29
30
  from pytdx.hq import TDXParams
31
+ from configparser import ConfigParser
30
32
 
31
33
  from hikyuu.util.mylog import get_default_logger, hku_error, hku_debug
32
- from hikyuu import Datetime
34
+ from hikyuu import Datetime, is_valid_license, KDataToHdf5Importer
33
35
  from hikyuu.data.common import *
34
36
  from hikyuu.data.common_pytdx import to_pytdx_market, pytdx_get_day_trans
35
37
  from hikyuu.data.common_sqlite3 import (
@@ -235,6 +237,7 @@ def guess_5min_n_step(last_datetime):
235
237
  return (n, step)
236
238
 
237
239
 
240
+ @hku_catch(trace=True)
238
241
  def import_one_stock_data(connect, api, h5file, market, ktype, stock_record, startDate=199012191500):
239
242
  market = market.upper()
240
243
  pytdx_market = to_pytdx_market(market)
@@ -246,9 +249,9 @@ def import_one_stock_data(connect, api, h5file, market, ktype, stock_record, sta
246
249
  table = get_h5table(h5file, market, code)
247
250
  if table is None:
248
251
  hku_error("Can't get table({}{})".format(market, code))
249
- return 0
252
+ return (0, True, Datetime())
250
253
 
251
- last_datetime = table[-1]['datetime'] if table.nrows > 0 else startDate
254
+ last_datetime = int(table[-1]['datetime']) if table.nrows > 0 else startDate
252
255
 
253
256
  today = datetime.date.today()
254
257
  if ktype == 'DAY':
@@ -266,10 +269,10 @@ def import_one_stock_data(connect, api, h5file, market, ktype, stock_record, sta
266
269
  pytdx_kline_type = TDXParams.KLINE_TYPE_5MIN
267
270
  today_datetime = (today.year * 10000 + today.month * 100 + today.day) * 10000 + 1500
268
271
  else:
269
- return 0
272
+ return (0, True, Datetime(last_datetime))
270
273
 
271
274
  if today_datetime <= last_datetime:
272
- return 0
275
+ return (0, True, Datetime(last_datetime))
273
276
 
274
277
  get_bars = api.get_index_bars if stktype == STOCKTYPE.INDEX else api.get_security_bars
275
278
 
@@ -286,7 +289,7 @@ def import_one_stock_data(connect, api, h5file, market, ktype, stock_record, sta
286
289
  bar_list = get_bars(pytdx_kline_type, pytdx_market, code, n * 800, step)
287
290
  n -= 1
288
291
  if bar_list is None:
289
- print(code, "invalid!!")
292
+ # print(code, "invalid!!")
290
293
  continue
291
294
 
292
295
  for bar in bar_list:
@@ -302,32 +305,36 @@ def import_one_stock_data(connect, api, h5file, market, ktype, stock_record, sta
302
305
  hku_error("Failed translate datetime: {}, from {}! {}".format(bar, api.ip, e))
303
306
  continue
304
307
 
308
+ 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:
309
+ hku_warn(f"Ignore invalid bar: {bar_datetime}, missing fields!")
310
+ continue
311
+
305
312
  if need_check and bar_datetime == last_datetime:
306
313
  # print(f'{bar_datetime} {ktype} {market}{code}')
307
314
  if abs(last_krecord['openPrice']*0.001 - bar["open"]) / (last_krecord['openPrice']*0.001) > 0.02:
308
315
  hku_error(
309
316
  f"fetch data from tdx error! {bar_datetime} {ktype} {market}{code} last_krecord open: {last_krecord['openPrice']*0.001}, bar: {bar['open']}")
310
- return 0
317
+ return (0, False, Datetime(last_datetime))
311
318
  if abs(last_krecord['highPrice']*0.001 - bar["high"]) / (last_krecord['highPrice']*0.001) > 0.02:
312
319
  hku_error(
313
320
  f"fetch data from tdx error! {bar_datetime} {ktype} {market}{code} last_krecord high: {last_krecord['highPrice']*0.001}, bar: {bar['high']}")
314
- return 0
321
+ return (0, False, Datetime(last_datetime))
315
322
  if abs(last_krecord['lowPrice']*0.001 - bar["low"]) / (last_krecord['lowPrice']*0.001) > 0.02:
316
323
  hku_error(
317
324
  f"fetch data from tdx error! {bar_datetime} {ktype} {market}{code} last_krecord low: {last_krecord['lowPrice']*0.001}, bar: {bar['low']}")
318
- return 0
325
+ return (0, False, Datetime(last_datetime))
319
326
  if abs(last_krecord['closePrice']*0.001 - bar["close"]) / (last_krecord['closePrice']*0.001) > 0.02:
320
327
  hku_error(
321
328
  f"fetch data from tdx error! {bar_datetime} {ktype} {market}{code} last_krecord close: {last_krecord['closePrice']*0.001}, bar: {bar['close']}")
322
- return 0
323
- if ktype == 'DAY' and last_krecord['transAmount'] != 0.0 and abs(last_krecord['transAmount'] - round(bar["amount"]*0.001)) / last_krecord['transAmount'] > 0.1:
329
+ return (0, False, Datetime(last_datetime))
330
+ if ktype == 'DAY' and last_krecord['transAmount'] != 0 and (abs(float(last_krecord['transAmount']) - round(bar["amount"]*0.001))) > 10:
324
331
  hku_error(
325
- f"fetch data from tdx error! {bar_datetime} {ktype} {market}{code} last_krecord amount: {last_krecord['transAmount']}, bar: {bar['amount']*0.001}")
326
- 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:
332
+ f"fetch data from tdx error! {bar_datetime} {ktype} {market}{code} last_krecord amount: {float(last_krecord['transAmount'])}, bar: {round(bar['amount']*0.001)}")
333
+ return (0, False, Datetime(last_datetime))
334
+ if ktype == 'DAY' and last_krecord['transCount'] != 0 and abs(float(last_krecord['transCount']) - bar["vol"]) > 10:
328
335
  hku_error(
329
336
  f"fetch data from tdx error! {bar_datetime} {ktype} {market}{code} last_krecord count: {last_krecord['transCount']}, bar: {bar['vol']}")
330
- return 0
337
+ return (0, False, Datetime(last_datetime))
331
338
  continue
332
339
 
333
340
  if today_datetime >= bar_datetime > last_datetime \
@@ -374,7 +381,16 @@ def import_one_stock_data(connect, api, h5file, market, ktype, stock_record, sta
374
381
  table.remove()
375
382
 
376
383
  # table.close()
377
- return add_record_count
384
+ return (add_record_count, True, Datetime(last_datetime))
385
+
386
+
387
+ @hku_catch(ret=None)
388
+ def get_hdf5_importer(market, ktype):
389
+ filename = os.path.expanduser('~') + '/.hikyuu/hikyuu.ini'
390
+ config = ConfigParser()
391
+ config.read(filename, encoding='utf-8')
392
+ importer = KDataToHdf5Importer()
393
+ return importer if importer.set_config(config.get("hikyuu", "datadir"), [market], [ktype]) else None
378
394
 
379
395
 
380
396
  def import_data(connect, market, ktype, quotations, api, dest_dir, startDate=199012190000, progress=ProgressBar):
@@ -397,6 +413,9 @@ def import_data(connect, market, ktype, quotations, api, dest_dir, startDate=199
397
413
  if not stock_list:
398
414
  return 0
399
415
 
416
+ failed_limit = 20
417
+ failed_count = 0
418
+ failed_list = []
400
419
  total = len(stock_list)
401
420
  for i, stock in enumerate(stock_list):
402
421
  if stock[3] == 0 or len(stock[2]) != 6:
@@ -404,7 +423,12 @@ def import_data(connect, market, ktype, quotations, api, dest_dir, startDate=199
404
423
  progress(i, total)
405
424
  continue
406
425
 
407
- this_count = import_one_stock_data(connect, api, h5file, market, ktype, stock, startDate)
426
+ this_count, success, lastdate = import_one_stock_data(connect, api, h5file, market, ktype, stock, startDate)
427
+ if not success:
428
+ failed_count += 1
429
+ failed_list.append((market, stock[2], lastdate))
430
+ if failed_count >= failed_limit:
431
+ break
408
432
  add_record_count += this_count
409
433
  if this_count > 0:
410
434
  if ktype == 'DAY':
@@ -414,8 +438,31 @@ def import_data(connect, market, ktype, quotations, api, dest_dir, startDate=199
414
438
  if progress:
415
439
  progress(i, total)
416
440
 
441
+ if total > 0 and progress:
442
+ progress(total, total)
443
+
417
444
  connect.commit()
418
445
  h5file.close()
446
+
447
+ if 0 < failed_count < failed_limit and is_valid_license():
448
+ # 删除最后记录
449
+ ktype_dict = {
450
+ 'DAY': 'DAY',
451
+ '1MIN': 'MIN',
452
+ '5MIN': 'MIN5'
453
+ }
454
+ nktype = ktype_dict[ktype]
455
+ h5_importer = get_hdf5_importer(market, nktype)
456
+ if h5_importer is not None:
457
+ for r in failed_list:
458
+ hku_warn("清理 {}{} {}: {}", r[0], r[1], nktype, r[2].start_of_day())
459
+ h5_importer.remove(r[0], r[1], nktype, r[2].start_of_day())
460
+ hku_warn(f"已清理 {market} {failed_count} 个失败股票的最后记录,建议重新导入")
461
+
462
+ if failed_count >= failed_limit:
463
+ hku_error(f"{market} {ktype} 连续失败20个股票,已停止导入, 建议重新导入")
464
+ return add_record_count
465
+
419
466
  return add_record_count
420
467
 
421
468
 
@@ -475,12 +522,13 @@ def import_on_stock_trans(connect, api, h5file, market, stock_record, max_days):
475
522
  second += 3
476
523
  if second > 59:
477
524
  continue
478
- row['datetime'] = cur_date * 1000000 + minute * 100 + second
479
- row['price'] = int(record['price'] * 1000)
480
- row['vol'] = record['vol']
481
- row['buyorsell'] = record['buyorsell']
482
- row.append()
483
- add_record_count += 1
525
+ if record['price'] > 0.0 and record['vol'] >= 0.0:
526
+ row['datetime'] = cur_date * 1000000 + minute * 100 + second
527
+ row['price'] = int(record['price'] * 1000)
528
+ row['vol'] = record['vol']
529
+ row['buyorsell'] = record['buyorsell']
530
+ row.append()
531
+ add_record_count += 1
484
532
  except Exception as e:
485
533
  hku_error("Failed trans to record! {}", e)
486
534
 
@@ -574,12 +622,13 @@ def import_on_stock_time(connect, api, h5file, market, stock_record, max_days):
574
622
  elif time == 1360:
575
623
  time = 1400
576
624
  try:
577
- row['datetime'] = this_date + time
578
- row['price'] = int(record['price'] * 1000)
579
- row['vol'] = record['vol']
580
- row.append()
625
+ if record['price'] > 0.0 and record['vol'] >= 0.0:
626
+ row['datetime'] = this_date + time
627
+ row['price'] = int(record['price'] * 1000)
628
+ row['vol'] = record['vol']
629
+ row.append()
630
+ add_record_count += 1
581
631
  time += 1
582
- add_record_count += 1
583
632
  except Exception as e:
584
633
  hku_error("Failed trans record {}! {}".format(record, e))
585
634
 
@@ -620,7 +669,7 @@ if __name__ == '__main__':
620
669
  import time
621
670
  starttime = time.time()
622
671
 
623
- dest_dir = "d:\\stock"
672
+ dest_dir = "/Users/fasiondog/stock"
624
673
  tdx_server = '180.101.48.170'
625
674
  tdx_port = 7709
626
675
  quotations = ['stock', 'fund']
@@ -23,15 +23,17 @@
23
23
  # SOFTWARE.
24
24
 
25
25
  import sys
26
+ import os
26
27
  import math
27
28
  import datetime
28
29
  from pytdx.hq import TDXParams
30
+ from configparser import ConfigParser
29
31
 
30
32
  from hikyuu.util.mylog import hku_error, hku_debug
31
33
 
32
34
  import mysql.connector
33
35
 
34
- from hikyuu import Datetime
36
+ from hikyuu import Datetime, is_valid_license, KDataToMySQLImporter
35
37
  from .common import *
36
38
  from .common_pytdx import to_pytdx_market, pytdx_get_day_trans
37
39
  from .common_mysql import (
@@ -318,10 +320,10 @@ def import_one_stock_data(
318
320
  today.year * 10000 + today.month * 100 + today.day
319
321
  ) * 10000 + 1500
320
322
  else:
321
- return 0
323
+ return (0, True, Datetime(last_datetime))
322
324
 
323
325
  if today_datetime <= last_datetime:
324
- return 0
326
+ return (0, True, Datetime(last_datetime))
325
327
 
326
328
  get_bars = (
327
329
  api.get_index_bars if stktype == STOCKTYPE.INDEX else api.get_security_bars
@@ -348,31 +350,35 @@ def import_one_stock_data(
348
350
  hku_error("Failed translate datetime: {}, from {}! {}".format(bar, api.ip, e))
349
351
  continue
350
352
 
353
+ 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:
354
+ hku_warn(f"Ignore invalid bar: {bar_datetime}, missing fields!")
355
+ continue
356
+
351
357
  if last_krecord is not None and bar_datetime == last_datetime:
352
358
  if abs(last_krecord[1] - bar["open"]) / last_krecord[1] > 0.01:
353
359
  hku_error(
354
360
  f"fetch data from tdx error! {bar_datetime} {ktype} {market}{code} last_krecord open: {last_krecord[1]}, bar: {bar['open']}")
355
- return 0
361
+ return (0, False, Datetime(last_datetime))
356
362
  if abs(last_krecord[2] - bar["high"]) / last_krecord[2] > 0.01:
357
363
  hku_error(
358
364
  f"fetch data from tdx error! {bar_datetime} {ktype} {market}{code} last_krecord high: {last_krecord[2]}, bar: {bar['high']}")
359
- return 0
365
+ return (0, False, Datetime(last_datetime))
360
366
  if abs(last_krecord[3] - bar["low"]) / last_krecord[3] > 0.01:
361
367
  hku_error(
362
368
  f"fetch data from tdx error! {bar_datetime} {ktype} {market}{code} last_krecord low: {last_krecord[3]}, bar: {bar['low']}")
363
- return 0
369
+ return (0, False, Datetime(last_datetime))
364
370
  if abs(last_krecord[4] - bar["close"]) / last_krecord[4] > 0.01:
365
371
  hku_error(
366
372
  f"fetch data from tdx error! {bar_datetime} {ktype} {market}{code} last_krecord close: {last_krecord[4]}, bar: {bar['close']}")
367
- return 0
368
- if ktype == 'DAY' and last_krecord[5] != 0.0 and abs(last_krecord[5] - bar["amount"]*0.001) / last_krecord[5] > 0.1:
373
+ return (0, False, Datetime(last_datetime))
374
+ if ktype == 'DAY' and last_krecord[5] != 0.0 and abs(last_krecord[5] - bar["amount"]*0.001) > 10:
369
375
  hku_error(
370
376
  f"fetch data from tdx error! {bar_datetime} {ktype} {market}{code} last_krecord amount: {last_krecord[5]}, bar: {bar['amount']*0.001}")
371
- return 0
372
- if ktype == 'DAY' and last_krecord[5] != 0.0 and abs(last_krecord[6] - bar["vol"]) / last_krecord[6] > 0.1:
377
+ return (0, False, Datetime(last_datetime))
378
+ if ktype == 'DAY' and last_krecord[6] != 0.0 and abs(last_krecord[6] - bar["vol"]) > 10:
373
379
  hku_error(
374
380
  f"fetch data from tdx error! {bar_datetime} {ktype} {market}{code} last_krecord count: {last_krecord[6]}, bar: {bar['vol']}")
375
- return 0
381
+ return (0, False, Datetime(last_datetime))
376
382
  continue
377
383
 
378
384
  if (
@@ -436,7 +442,17 @@ def import_one_stock_data(
436
442
  connect.commit()
437
443
  cur.close()
438
444
 
439
- return len(buf)
445
+ return (len(buf), True, Datetime(last_datetime))
446
+
447
+
448
+ @hku_catch(ret=None)
449
+ def get_mysql_importer():
450
+ filename = os.path.expanduser('~') + '/.hikyuu/hikyuu.ini'
451
+ config = ConfigParser()
452
+ config.read(filename, encoding='utf-8')
453
+ importer = KDataToMySQLImporter()
454
+ return importer if importer.set_config(config.get("kdata", "host"), config.getint("kdata", "port", fallback=3306),
455
+ config.get("kdata", "usr"), config.get("kdata", "pwd")) else None
440
456
 
441
457
 
442
458
  @hku_catch(trace=True, re_raise=True)
@@ -466,6 +482,9 @@ def import_data(
466
482
 
467
483
  stock_list = get_stock_list(connect, market, quotations)
468
484
 
485
+ failed_limit = 20
486
+ failed_count = 0
487
+ failed_list = []
469
488
  total = len(stock_list)
470
489
  for i, stock in enumerate(stock_list):
471
490
  if stock[3] == 0 or len(stock[2]) != 6:
@@ -473,9 +492,14 @@ def import_data(
473
492
  progress(i, total)
474
493
  continue
475
494
 
476
- this_count = import_one_stock_data(
495
+ this_count, success, lastdate = import_one_stock_data(
477
496
  connect, api, market, ktype, stock, startDate
478
497
  )
498
+ if not success:
499
+ failed_count += 1
500
+ failed_list.append((market, stock[2], lastdate))
501
+ if failed_count >= failed_limit:
502
+ break
479
503
  add_record_count += this_count
480
504
  if this_count > 0:
481
505
  if ktype == "DAY":
@@ -487,6 +511,28 @@ def import_data(
487
511
  progress(i, total)
488
512
 
489
513
  connect.commit()
514
+
515
+ if total > 0 and progress:
516
+ progress(total, total)
517
+
518
+ if 0 < failed_count < failed_limit and is_valid_license():
519
+ # 删除最后记录
520
+ ktype_dict = {
521
+ 'DAY': 'DAY',
522
+ '1MIN': 'MIN',
523
+ '5MIN': 'MIN5'
524
+ }
525
+ nktype = ktype_dict[ktype]
526
+ h5_importer = get_mysql_importer(market, nktype)
527
+ if h5_importer is not None:
528
+ for r in failed_list:
529
+ hku_warn("remove {}{} {}: {}", r[0], r[1], nktype, r[2].start_of_day())
530
+ h5_importer.remove(r[0], r[1], nktype, r[2].start_of_day())
531
+ hku_warn(f"已清理 {market} {failed_count} 个失败股票的最后记录,建议重新导入")
532
+
533
+ if failed_count >= failed_limit:
534
+ hku_error(f"{market} {ktype} 连续失败20个股票,已停止导入, 建议重新导入")
535
+ return add_record_count
490
536
  return add_record_count
491
537
 
492
538
 
@@ -584,14 +630,15 @@ def import_on_stock_trans(connect, api, market, stock_record, max_days):
584
630
  if second > 59:
585
631
  continue
586
632
 
587
- trans_buf.append(
588
- (
589
- cur_date * 1000000 + minute * 100 + second,
590
- record["price"],
591
- record["vol"],
592
- record["buyorsell"],
633
+ if record['price'] > 0.0 and record['vol'] >= 0.0:
634
+ trans_buf.append(
635
+ (
636
+ cur_date * 1000000 + minute * 100 + second,
637
+ record["price"],
638
+ record["vol"],
639
+ record["buyorsell"],
640
+ )
593
641
  )
594
- )
595
642
  except Exception as e:
596
643
  hku_error("Failed trans to record! {}", e)
597
644
 
@@ -717,7 +764,8 @@ def import_on_stock_time(connect, api, market, stock_record, max_days):
717
764
  elif time == 1360:
718
765
  time = 1400
719
766
  try:
720
- time_buf.append((this_date + time, record['price'], record['vol']))
767
+ if record['price'] > 0.0 and record['vol'] >= 0.0:
768
+ time_buf.append((this_date + time, record['price'], record['vol']))
721
769
  time += 1
722
770
  except Exception as e:
723
771
  hku_error("Failed trans record {}! {}".format(record, e))
@@ -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:
@@ -55,6 +55,8 @@ def pytdx_import_weight_to_clickhouse(pytdx_api, connect, market):
55
55
  db_last_date, last_total_count, last_free_count = (0, 0, 0)
56
56
 
57
57
  xdxr_list = pytdx_api.get_xdxr_info(pytdx_market, code)
58
+ if xdxr_list is None:
59
+ continue
58
60
  update_last_db_weight = False
59
61
  new_last_db_weight = last_db_weight
60
62
  records = {}
@@ -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
 
@@ -67,6 +67,8 @@ def pytdx_import_weight_to_mysql(pytdx_api, connect, market):
67
67
  cur.close()
68
68
 
69
69
  xdxr_list = pytdx_api.get_xdxr_info(pytdx_market, code)
70
+ if xdxr_list is None:
71
+ continue
70
72
  update_last_db_weight = False
71
73
  new_last_db_weight = last_db_weight
72
74
  records = {}
@@ -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
 
@@ -64,6 +64,8 @@ def pytdx_import_weight_to_sqlite(pytdx_api, connect, market):
64
64
  cur.close()
65
65
 
66
66
  xdxr_list = pytdx_api.get_xdxr_info(pytdx_market, code)
67
+ if xdxr_list is None:
68
+ continue
67
69
  update_last_db_weight = False
68
70
  new_last_db_weight = last_db_weight
69
71
  records = {}
@@ -0,0 +1,4 @@
1
+ BEGIN TRANSACTION;
2
+ update `stocktypeinfo` set `minTradeNumber`=100 where `type`=5 and `description`='ETF';
3
+ UPDATE `version` set `version` = 29;
4
+ COMMIT;
@@ -189,7 +189,7 @@ def tdx_import_day_data_from_file(connect, filename, ktype, market, stock_record
189
189
  with open(filename, 'rb') as src_file:
190
190
  data = src_file.read(32)
191
191
  while data:
192
- record = struct.unpack('iiiiifii', data)
192
+ record = struct.unpack('IIIIIfII', data)
193
193
  if lastdatetime and record[0] <= lastdatetime:
194
194
  data = src_file.read(32)
195
195
  continue
@@ -291,7 +291,7 @@ def tdx_import_min_data_from_file(connect, filename, ktype, market, stock_record
291
291
 
292
292
  data = src_file.read(32)
293
293
  while data:
294
- record = struct.unpack('HHfffffii', data)
294
+ record = struct.unpack('HHfffffII', data)
295
295
  if record[3] >= record[2] >= record[4] > 0\
296
296
  and record[3] >= record[5] >= record[4] > 0\
297
297
  and record[5] >= 0 \
hikyuu/data/tdx_to_h5.py CHANGED
@@ -124,14 +124,14 @@ def tdx_import_stock_name_from_file(connect, filename, market, quotations=None):
124
124
  length = len(codepre[0])
125
125
  if code[:length] == codepre[0]:
126
126
  count += 1
127
- #print(market, code, newStockDict[code], codepre)
127
+ # print(market, code, newStockDict[code], codepre)
128
128
  sql = "insert into Stock(marketid, code, name, type, valid, startDate, endDate) \
129
129
  values (%s, '%s', '%s', %s, %s, %s, %s)" \
130
130
  % (marketid, code, newStockDict[code], codepre[1], 1, today, 99999999)
131
131
  cur.execute(sql)
132
132
  break
133
133
 
134
- #print('%s新增股票数:%i' % (market.upper(), count))
134
+ # print('%s新增股票数:%i' % (market.upper(), count))
135
135
  connect.commit()
136
136
  cur.close()
137
137
  return count
@@ -163,7 +163,7 @@ def tdx_import_day_data_from_file(connect, filename, h5file, market, stock_recor
163
163
  with open(filename, 'rb') as src_file:
164
164
  data = src_file.read(32)
165
165
  while data:
166
- record = struct.unpack('iiiiifii', data)
166
+ record = struct.unpack('IIIIIfII', data)
167
167
  if lastdatetime and record[0] <= lastdatetime:
168
168
  data = src_file.read(32)
169
169
  continue
@@ -191,8 +191,8 @@ def tdx_import_day_data_from_file(connect, filename, h5file, market, stock_recor
191
191
  if add_record_count > 0:
192
192
  table.flush()
193
193
 
194
- #更新基础信息数据库中股票对应的起止日期及其有效标志
195
- #if valid == 0:
194
+ # 更新基础信息数据库中股票对应的起止日期及其有效标志
195
+ # if valid == 0:
196
196
  cur = connect.cursor()
197
197
  cur.execute(
198
198
  "update stock set valid=1, startdate=%i, enddate=%i where stockid=%i" %
@@ -201,13 +201,13 @@ def tdx_import_day_data_from_file(connect, filename, h5file, market, stock_recor
201
201
  connect.commit()
202
202
  cur.close()
203
203
 
204
- #记录最新更新日期
204
+ # 记录最新更新日期
205
205
  if (code == '000001' and marketid == MARKETID.SH) \
206
- or (code == '399001' and marketid == MARKETID.SZ) :
206
+ or (code == '399001' and marketid == MARKETID.SZ):
207
207
  update_last_date(connect, marketid, table[-1]['datetime'] / 10000)
208
208
 
209
209
  elif table.nrows == 0:
210
- #print(market, stock_record)
210
+ # print(market, stock_record)
211
211
  table.remove()
212
212
 
213
213
  return add_record_count
@@ -290,7 +290,7 @@ def tdx_import_min_data_from_file(connect, filename, h5file, market, stock_recor
290
290
 
291
291
  data = src_file.read(32)
292
292
  while data:
293
- record = struct.unpack('HHfffffii', data)
293
+ record = struct.unpack('HHfffffII', data)
294
294
  if 0 not in record[2:6]:
295
295
  if record[3] >= record[2] >= record[4] \
296
296
  and record[3] >= record[5] >= record[4]:
@@ -314,7 +314,7 @@ def tdx_import_min_data_from_file(connect, filename, h5file, market, stock_recor
314
314
  if add_record_count > 0:
315
315
  table.flush()
316
316
  elif table.nrows == 0:
317
- #print(market, stock_record)
317
+ # print(market, stock_record)
318
318
  table.remove()
319
319
 
320
320
  return add_record_count
@@ -386,7 +386,7 @@ if __name__ == '__main__':
386
386
 
387
387
  src_dir = "D:\\TdxW_HuaTai"
388
388
  dest_dir = "c:\\stock"
389
- quotations = ['stock', 'fund'] #通达信盘后数据没有债券
389
+ quotations = ['stock', 'fund'] # 通达信盘后数据没有债券
390
390
 
391
391
  connect = sqlite3.connect(dest_dir + "\\stock.db")
392
392
  create_database(connect)
@@ -171,7 +171,7 @@ def tdx_import_day_data_from_file(connect, filename, ktype, market, stock_record
171
171
  with open(filename, 'rb') as src_file:
172
172
  data = src_file.read(32)
173
173
  while data:
174
- record = struct.unpack('iiiiifii', data)
174
+ record = struct.unpack('IIIIIfII', data)
175
175
  if lastdatetime and record[0] <= lastdatetime:
176
176
  data = src_file.read(32)
177
177
  continue
@@ -297,7 +297,7 @@ def tdx_import_min_data_from_file(connect, filename, ktype, market, stock_record
297
297
 
298
298
  data = src_file.read(32)
299
299
  while data:
300
- record = struct.unpack('HHfffffii', data)
300
+ record = struct.unpack('HHfffffII', data)
301
301
  if record[3] >= record[2] >= record[4] > 0\
302
302
  and record[3] >= record[5] >= record[4] > 0\
303
303
  and record[5] >= 0 \
@@ -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
hikyuu/draw/__init__.pyi CHANGED
@@ -9,8 +9,8 @@ from hikyuu.draw.drawplot import gcf
9
9
  from hikyuu.draw.drawplot import get_current_draw_engine
10
10
  from hikyuu.draw.drawplot.matplotlib_draw import DRAWBAND
11
11
  from hikyuu.draw.drawplot.matplotlib_draw import DRAWICON
12
- from hikyuu.draw.drawplot.matplotlib_draw import DRAWIMG as DRAWBMP
13
12
  from hikyuu.draw.drawplot.matplotlib_draw import DRAWIMG
13
+ from hikyuu.draw.drawplot.matplotlib_draw import DRAWIMG as DRAWBMP
14
14
  from hikyuu.draw.drawplot.matplotlib_draw import DRAWLINE
15
15
  from hikyuu.draw.drawplot.matplotlib_draw import DRAWNUMBER
16
16
  from hikyuu.draw.drawplot.matplotlib_draw import DRAWNUMBER_FIX
@@ -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