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.
- hikyuu/__init__.py +55 -23
- hikyuu/__init__.pyi +626 -595
- hikyuu/analysis/__init__.pyi +589 -563
- hikyuu/analysis/analysis.pyi +590 -564
- hikyuu/core.py +2 -0
- hikyuu/core.pyi +591 -565
- hikyuu/cpp/__init__.pyi +2 -2
- hikyuu/cpp/core310.pyi +587 -130
- hikyuu/cpp/core310.so +0 -0
- hikyuu/cpp/core311.pyi +587 -130
- hikyuu/cpp/core311.so +0 -0
- hikyuu/cpp/core312.pyi +587 -130
- hikyuu/cpp/core312.so +0 -0
- hikyuu/cpp/core313.pyi +587 -130
- hikyuu/cpp/core313.so +0 -0
- hikyuu/cpp/i18n/zh_CN/hikyuu.mo +0 -0
- hikyuu/cpp/i18n/zh_CN/hikyuu_plugin.mo +0 -0
- hikyuu/cpp/libboost_atomic.so +0 -0
- hikyuu/cpp/libboost_atomic.so.1.90.0 +0 -0
- hikyuu/cpp/libboost_charconv.so +0 -0
- hikyuu/cpp/libboost_charconv.so.1.90.0 +0 -0
- hikyuu/cpp/libboost_chrono.so +0 -0
- hikyuu/cpp/libboost_chrono.so.1.90.0 +0 -0
- hikyuu/cpp/libboost_container.so +0 -0
- hikyuu/cpp/libboost_container.so.1.90.0 +0 -0
- hikyuu/cpp/libboost_date_time.so +0 -0
- hikyuu/cpp/libboost_date_time.so.1.90.0 +0 -0
- hikyuu/cpp/libboost_locale.so +0 -0
- hikyuu/cpp/libboost_locale.so.1.90.0 +0 -0
- hikyuu/cpp/libboost_random.so +0 -0
- hikyuu/cpp/libboost_random.so.1.90.0 +0 -0
- hikyuu/cpp/libboost_serialization.so +0 -0
- hikyuu/cpp/libboost_serialization.so.1.90.0 +0 -0
- hikyuu/cpp/libboost_thread.so +0 -0
- hikyuu/cpp/libboost_thread.so.1.90.0 +0 -0
- hikyuu/cpp/libboost_wserialization.so +0 -0
- hikyuu/cpp/libboost_wserialization.so.1.90.0 +0 -0
- hikyuu/cpp/libhikyuu.so +0 -0
- hikyuu/cpp/libhku_hdf5.so +0 -0
- hikyuu/cpp/libhku_hdf5.so.200 +0 -0
- hikyuu/cpp/libhku_hdf5.so.200.2.0 +0 -0
- hikyuu/cpp/libhku_hdf5_cpp.so +0 -0
- hikyuu/cpp/libhku_hdf5_cpp.so.200 +0 -0
- hikyuu/cpp/libhku_hdf5_cpp.so.200.2.0 +0 -0
- hikyuu/cpp/libhku_hdf5_hl.so +0 -0
- hikyuu/cpp/libhku_hdf5_hl.so.200 +0 -0
- hikyuu/cpp/libhku_hdf5_hl.so.200.1.0 +0 -0
- hikyuu/cpp/libhku_hdf5_hl_cpp.so +0 -0
- hikyuu/cpp/libhku_hdf5_hl_cpp.so.200 +0 -0
- hikyuu/cpp/libhku_hdf5_hl_cpp.so.200.1.0 +0 -0
- hikyuu/cpp/libhku_hdf5_tools.so +0 -0
- hikyuu/cpp/libhku_hdf5_tools.so.200 +0 -0
- hikyuu/cpp/libhku_hdf5_tools.so.200.1.1 +0 -0
- hikyuu/cpp/libsqlite3.so +0 -0
- hikyuu/data/clickhouse_upgrade/0001.sql +2 -0
- hikyuu/data/clickhouse_upgrade/createdb.sql +105 -105
- hikyuu/data/common.py +3 -3
- hikyuu/data/common_clickhouse.py +1 -3
- hikyuu/data/download_block.py +351 -0
- hikyuu/data/em_block_to_clickhouse.py +26 -74
- hikyuu/data/em_block_to_mysql.py +25 -75
- hikyuu/data/em_block_to_sqlite.py +26 -78
- hikyuu/data/hku_config_template.py +33 -6
- hikyuu/data/mysql_upgrade/0029.sql +2 -0
- hikyuu/data/pytdx_to_clickhouse.py +96 -38
- hikyuu/data/pytdx_to_h5.py +78 -29
- hikyuu/data/pytdx_to_mysql.py +69 -21
- hikyuu/data/pytdx_weight_to_clickhouse.py +3 -1
- hikyuu/data/pytdx_weight_to_mysql.py +3 -1
- hikyuu/data/pytdx_weight_to_sqlite.py +3 -1
- hikyuu/data/sqlite_upgrade/0029.sql +4 -0
- hikyuu/data/tdx_to_clickhouse.py +2 -2
- hikyuu/data/tdx_to_h5.py +11 -11
- hikyuu/data/tdx_to_mysql.py +2 -2
- hikyuu/data/zh_bond10_to_clickhouse.py +1 -1
- hikyuu/draw/__init__.pyi +1 -1
- hikyuu/draw/drawplot/__init__.pyi +8 -8
- hikyuu/draw/drawplot/bokeh_draw.pyi +610 -583
- hikyuu/draw/drawplot/common.pyi +1 -1
- hikyuu/draw/drawplot/echarts_draw.pyi +612 -585
- hikyuu/draw/drawplot/matplotlib_draw.py +12 -76
- hikyuu/draw/drawplot/matplotlib_draw.pyi +623 -596
- hikyuu/draw/elder.pyi +11 -11
- hikyuu/draw/kaufman.pyi +18 -18
- hikyuu/draw/volume.pyi +10 -10
- hikyuu/examples/notebook/Demo/Demo1.ipynb +48 -33
- hikyuu/extend.py +0 -7
- hikyuu/extend.pyi +599 -573
- hikyuu/fetcher/stock/zh_block_em.py +12 -40
- hikyuu/gui/HikyuuTDX.py +140 -33
- hikyuu/gui/data/CollectSpotThread.py +1 -1
- hikyuu/gui/data/EscapetimeThread.py +8 -14
- hikyuu/gui/data/ImportBlockInfoTask.py +3 -10
- hikyuu/gui/data/MainWindow.py +1300 -761
- hikyuu/gui/data/SchedImportThread.py +2 -2
- hikyuu/gui/data/UsePytdxImportToH5Thread.py +3 -3
- hikyuu/gui/data/UseQmtImportToH5Thread.py +2 -2
- hikyuu/gui/data/UseTdxImportToH5Thread.py +3 -3
- hikyuu/gui/data/tool.py +32 -25
- hikyuu/gui/dataserver.py +5 -3
- hikyuu/gui/images/liandongxiaopu.png +0 -0
- hikyuu/gui/importdata.py +4 -0
- hikyuu/hub.pyi +6 -6
- hikyuu/include/hikyuu/DataType.h +4 -16
- hikyuu/include/hikyuu/KData.h +6 -3
- hikyuu/include/hikyuu/KDataPrivatedBufferImp.h +1 -1
- hikyuu/include/hikyuu/KDataSharedBufferImp.h +1 -1
- hikyuu/include/hikyuu/KQuery.h +2 -2
- hikyuu/include/hikyuu/Stock.h +4 -1
- hikyuu/include/hikyuu/StockManager.h +29 -4
- hikyuu/include/hikyuu/StrategyContext.h +4 -4
- hikyuu/include/hikyuu/data_driver/BaseInfoDriver.h +9 -0
- hikyuu/include/hikyuu/data_driver/BlockInfoDriver.h +6 -0
- hikyuu/include/hikyuu/data_driver/KDataDriver.h +24 -1
- hikyuu/include/hikyuu/data_driver/base_info/mysql/MySQLBaseInfoDriver.h +1 -1
- hikyuu/include/hikyuu/data_driver/base_info/sqlite/SQLiteBaseInfoDriver.h +1 -1
- hikyuu/include/hikyuu/data_driver/block_info/mysql/MySQLBlockInfoDriver.h +2 -1
- hikyuu/include/hikyuu/data_driver/block_info/qianlong/QLBlockInfoDriver.h +2 -1
- hikyuu/include/hikyuu/data_driver/block_info/sqlite/SQLiteBlockInfoDriver.h +2 -1
- hikyuu/include/hikyuu/data_driver/kdata/DoNothingKDataDriver.h +1 -1
- hikyuu/include/hikyuu/data_driver/kdata/cvs/KDataTempCsvDriver.h +1 -1
- hikyuu/include/hikyuu/data_driver/kdata/hdf5/H5KDataDriver.h +1 -1
- hikyuu/include/hikyuu/data_driver/kdata/mysql/MySQLKDataDriver.h +6 -2
- hikyuu/include/hikyuu/data_driver/kdata/sqlite/SQLiteKDataDriver.h +2 -2
- hikyuu/include/hikyuu/data_driver/kdata/tdx/TdxKDataDriver.h +1 -1
- hikyuu/include/hikyuu/global/sysinfo.h +24 -5
- hikyuu/include/hikyuu/hikyuu.h +1 -1
- hikyuu/include/hikyuu/indicator/IndicatorImp.h +1 -1
- hikyuu/include/hikyuu/indicator/build_in.h +1 -0
- hikyuu/include/hikyuu/indicator/crt/CYCLE.h +4 -4
- hikyuu/include/hikyuu/indicator/crt/HSL.h +2 -2
- hikyuu/include/hikyuu/indicator/crt/QUANTILE_TRUNC.h +30 -0
- hikyuu/include/hikyuu/indicator/crt/TURNOVER.h +1 -0
- hikyuu/include/hikyuu/indicator/crt/ZSCORE.h +2 -2
- hikyuu/include/hikyuu/indicator/imp/IQuantileTrunc.h +25 -0
- hikyuu/include/hikyuu/lang.h +15 -2
- hikyuu/include/hikyuu/misc.h +38 -0
- hikyuu/include/hikyuu/plugin/KDataToClickHouseImporter.h +40 -0
- hikyuu/include/hikyuu/plugin/KDataToMySQLImporter.h +40 -0
- hikyuu/include/hikyuu/plugin/checkdata.h +20 -0
- hikyuu/include/hikyuu/plugin/dataserver.h +2 -1
- hikyuu/include/hikyuu/plugin/device.h +10 -0
- hikyuu/include/hikyuu/plugin/extind.h +40 -0
- hikyuu/include/hikyuu/plugin/hkuextra.h +1 -17
- hikyuu/include/hikyuu/plugin/interface/CheckDataPluginInterface.h +25 -0
- hikyuu/include/hikyuu/plugin/interface/DataServerPluginInterface.h +2 -2
- hikyuu/include/hikyuu/plugin/interface/DevicePluginInterface.h +2 -0
- hikyuu/include/hikyuu/plugin/interface/ExtendIndicatorsPluginInterface.h +12 -0
- hikyuu/include/hikyuu/plugin/interface/HkuExtraPluginInterface.h +1 -13
- hikyuu/include/hikyuu/plugin/interface/ImportKDataToClickHousePluginInterface.h +44 -0
- hikyuu/include/hikyuu/plugin/interface/ImportKDataToMySQLPluginInterface.h +42 -0
- hikyuu/include/hikyuu/plugin/interface/plugins.h +9 -1
- hikyuu/include/hikyuu/python/convert_any.h +9 -6
- hikyuu/include/hikyuu/python/pybind_utils.h +4 -11
- hikyuu/include/hikyuu/strategy/RunSystemInStrategy.h +3 -0
- hikyuu/include/hikyuu/strategy/Strategy.h +1 -1
- hikyuu/include/hikyuu/trade_manage/Performance.h +4 -4
- hikyuu/include/hikyuu/trade_manage/TradeManagerBase.h +10 -2
- hikyuu/include/hikyuu/trade_manage/TradeRecord.h +2 -1
- hikyuu/include/hikyuu/trade_sys/allocatefunds/AllocateFundsBase.h +0 -1
- hikyuu/include/hikyuu/trade_sys/allocatefunds/build_in.h +1 -0
- hikyuu/include/hikyuu/trade_sys/allocatefunds/crt/AF_FixedAmount.h +26 -0
- hikyuu/include/hikyuu/trade_sys/allocatefunds/imp/FixAmountFunds.h +18 -0
- hikyuu/include/hikyuu/trade_sys/condition/ConditionBase.h +0 -1
- hikyuu/include/hikyuu/trade_sys/environment/EnvironmentBase.h +0 -1
- hikyuu/include/hikyuu/trade_sys/moneymanager/MoneyManagerBase.h +0 -1
- hikyuu/include/hikyuu/trade_sys/moneymanager/imp/FixedCapitalFundsMM.h +0 -4
- hikyuu/include/hikyuu/trade_sys/multifactor/MultiFactorBase.h +36 -4
- hikyuu/include/hikyuu/trade_sys/multifactor/NormalizeBase.h +124 -0
- hikyuu/include/hikyuu/trade_sys/multifactor/ScoresFilterBase.h +124 -0
- hikyuu/include/hikyuu/trade_sys/multifactor/build_in.h +3 -0
- hikyuu/include/hikyuu/trade_sys/multifactor/buildin_norm.h +36 -0
- hikyuu/include/hikyuu/trade_sys/multifactor/buildin_scfilter.h +51 -0
- hikyuu/include/hikyuu/trade_sys/multifactor/filter/GroupSCFilter.h +24 -0
- hikyuu/include/hikyuu/trade_sys/multifactor/filter/IgnoreLessOrEqualValueSCFilter.h +24 -0
- hikyuu/include/hikyuu/trade_sys/multifactor/filter/IgnoreNanSCFilter.h +24 -0
- hikyuu/include/hikyuu/trade_sys/multifactor/filter/MinAmountPercentSCFilter.h +25 -0
- hikyuu/include/hikyuu/trade_sys/multifactor/filter/PriceSCFilter.h +24 -0
- hikyuu/include/hikyuu/trade_sys/multifactor/filter/TopNSCFilter.h +24 -0
- hikyuu/include/hikyuu/trade_sys/multifactor/imp/EqualWeightMultiFactor.h +1 -1
- hikyuu/include/hikyuu/trade_sys/multifactor/imp/ICIRMultiFactor.h +1 -1
- hikyuu/include/hikyuu/trade_sys/multifactor/imp/ICMultiFactor.h +1 -1
- hikyuu/include/hikyuu/trade_sys/multifactor/imp/WeightMultiFactor.h +1 -1
- hikyuu/include/hikyuu/trade_sys/multifactor/normalize/NormMinMax.h +23 -0
- hikyuu/include/hikyuu/trade_sys/multifactor/normalize/NormQuantile.h +28 -0
- hikyuu/include/hikyuu/trade_sys/multifactor/normalize/NormQuantileUniform.h +28 -0
- hikyuu/include/hikyuu/trade_sys/multifactor/normalize/NormZScore.h +25 -0
- hikyuu/include/hikyuu/trade_sys/multifactor/normalize/__init__.py +1 -0
- hikyuu/include/hikyuu/trade_sys/multifactor/normalize/quantile_trunc.h +16 -0
- hikyuu/include/hikyuu/trade_sys/portfolio/Portfolio.h +20 -13
- hikyuu/include/hikyuu/trade_sys/portfolio/imp/SimplePortfolio.h +7 -0
- hikyuu/include/hikyuu/trade_sys/portfolio/imp/WithoutAFPortfolio.h +7 -0
- hikyuu/include/hikyuu/trade_sys/profitgoal/ProfitGoalBase.h +9 -11
- hikyuu/include/hikyuu/trade_sys/selector/SelectorBase.h +49 -1
- hikyuu/include/hikyuu/trade_sys/selector/build_in.h +1 -0
- hikyuu/include/hikyuu/trade_sys/selector/crt/SE_MultiFactor2.h +40 -0
- hikyuu/include/hikyuu/trade_sys/selector/imp/MultiFactorSelector.h +0 -3
- hikyuu/include/hikyuu/trade_sys/selector/imp/MultiFactorSelector2.h +49 -0
- hikyuu/include/hikyuu/trade_sys/selector/imp/logic/OperatorSelector.h +1 -1
- hikyuu/include/hikyuu/trade_sys/selector/imp/logic/OperatorValueSelector.h +1 -1
- hikyuu/include/hikyuu/trade_sys/signal/SignalBase.h +0 -1
- hikyuu/include/hikyuu/trade_sys/signal/imp/BandSignal2.h +0 -4
- hikyuu/include/hikyuu/trade_sys/signal/imp/logic/AddValueSignal.h +2 -2
- hikyuu/include/hikyuu/trade_sys/signal/imp/logic/DivValueSignal.h +2 -2
- hikyuu/include/hikyuu/trade_sys/signal/imp/logic/MulValueSignal.h +2 -2
- hikyuu/include/hikyuu/trade_sys/signal/imp/logic/OperatorSignal.h +1 -1
- hikyuu/include/hikyuu/trade_sys/signal/imp/logic/OperatorValueSignal.h +4 -4
- hikyuu/include/hikyuu/trade_sys/signal/imp/logic/SubValueSignal.h +2 -2
- hikyuu/include/hikyuu/trade_sys/slippage/SlippageBase.h +0 -1
- hikyuu/include/hikyuu/trade_sys/slippage/build_in.h +5 -1
- hikyuu/include/hikyuu/trade_sys/slippage/crt/SP_LogNormal.h +22 -0
- hikyuu/include/hikyuu/trade_sys/slippage/crt/SP_Normal.h +22 -0
- hikyuu/include/hikyuu/trade_sys/slippage/crt/SP_TruncNormal.h +25 -0
- hikyuu/include/hikyuu/trade_sys/slippage/crt/SP_Uniform.h +23 -0
- hikyuu/include/hikyuu/trade_sys/slippage/imp/LogNormalSlippage.h +28 -0
- hikyuu/include/hikyuu/trade_sys/slippage/imp/NormalSlippage.h +28 -0
- hikyuu/include/hikyuu/trade_sys/slippage/imp/TruncNormalSlippage.h +28 -0
- hikyuu/include/hikyuu/trade_sys/slippage/imp/UniformSlippage.h +24 -0
- hikyuu/include/hikyuu/trade_sys/stoploss/StoplossBase.h +0 -1
- hikyuu/include/hikyuu/trade_sys/system/System.h +15 -3
- hikyuu/include/hikyuu/utilities/Log.h +6 -7
- hikyuu/include/hikyuu/utilities/Parameter.h +17 -0
- hikyuu/include/hikyuu/utilities/SpendTimer.h +17 -7
- hikyuu/include/hikyuu/utilities/arithmetic.h +55 -0
- hikyuu/include/hikyuu/utilities/config.h +28 -0
- hikyuu/include/hikyuu/utilities/db_connect/mysql/MySQLConnect.h +1 -1
- hikyuu/include/hikyuu/utilities/db_connect/mysql/MySQLStatement.h +1 -1
- hikyuu/include/hikyuu/utilities/db_connect/sqlite/SQLiteConnect.h +1 -1
- hikyuu/include/hikyuu/utilities/db_connect/sqlite/SQLiteStatement.h +1 -1
- hikyuu/include/hikyuu/utilities/plugin/PluginBase.h +17 -2
- hikyuu/include/hikyuu/utilities/plugin/PluginLoader.h +4 -1
- hikyuu/include/hikyuu/utilities/plugin/PluginManager.h +41 -22
- hikyuu/include/hikyuu/utilities/thread/GlobalStealThreadPool.h +1 -2
- hikyuu/include/hikyuu/utilities/thread/GlobalThreadPool.h +1 -1
- hikyuu/include/hikyuu/utilities/thread/MQStealThreadPool.h +286 -0
- hikyuu/include/hikyuu/utilities/thread/MQThreadPool.h +1 -0
- hikyuu/include/hikyuu/utilities/thread/StealThreadPool.h +297 -0
- hikyuu/include/hikyuu/utilities/thread/ThreadPool.h +1 -0
- hikyuu/include/hikyuu/utilities/thread/WorkStealQueue.h +9 -8
- hikyuu/include/hikyuu/utilities/thread/algorithm.h +64 -14
- hikyuu/include/hikyuu/version.h +5 -5
- hikyuu/plugin/libbacktest.so +0 -0
- hikyuu/plugin/libcheckdata.so +0 -0
- hikyuu/plugin/libclickhousedriver.so +0 -0
- hikyuu/plugin/libdataserver.so +0 -0
- hikyuu/{cpp/core39.so → plugin/libdataserver_parquet.so} +0 -0
- hikyuu/plugin/libdevice.so +0 -0
- hikyuu/plugin/libextind.so +0 -0
- hikyuu/plugin/libhkuextra.so +0 -0
- hikyuu/plugin/libimport2ch.so +0 -0
- hikyuu/plugin/libimport2hdf5.so +0 -0
- hikyuu/plugin/libimport2mysql.so +0 -0
- hikyuu/plugin/libtmreport.so +0 -0
- hikyuu/trade_manage/__init__.pyi +607 -582
- hikyuu/trade_manage/broker.pyi +3 -3
- hikyuu/trade_manage/broker_easytrader.pyi +1 -1
- hikyuu/trade_manage/trade.py +0 -2
- hikyuu/trade_manage/trade.pyi +607 -582
- hikyuu/trade_sys/trade_sys.py +54 -5
- hikyuu/util/__init__.pyi +2 -2
- hikyuu/util/singleton.pyi +1 -1
- {hikyuu-2.6.8.3.dist-info → hikyuu-2.7.3.dist-info}/METADATA +42 -32
- {hikyuu-2.6.8.3.dist-info → hikyuu-2.7.3.dist-info}/RECORD +267 -212
- {hikyuu-2.6.8.3.dist-info → hikyuu-2.7.3.dist-info}/top_level.txt +2 -2
- hikyuu/cpp/core39.pyi +0 -14190
- hikyuu/data/pytdx_to_taos.py +0 -736
- hikyuu/data_driver/__init__.py +0 -49
- hikyuu/data_driver/jqdata_data_driver.py +0 -277
- hikyuu/data_driver/pytdx_data_driver.py +0 -292
- hikyuu/fetcher/stock/zh_stock_a_huatai.py +0 -51
- hikyuu/fetcher/stock/zh_stock_a_pytdx.py +0 -129
- hikyuu/gui/data/CollectToMemThread.py +0 -123
- hikyuu/gui/data/CollectToMySQLThread.py +0 -178
- hikyuu/gui/start_huatai_insight.py +0 -510
- hikyuu/include/hikyuu/views/arrow_common.h +0 -38
- hikyuu/include/hikyuu/views/arrow_views.h +0 -117
- hikyuu/tools/update_block_info.py +0 -168
- /hikyuu/include/hikyuu/{views → trade_sys/multifactor/filter}/__init__.py +0 -0
- {hikyuu-2.6.8.3.dist-info → hikyuu-2.7.3.dist-info}/WHEEL +0 -0
- {hikyuu-2.6.8.3.dist-info → hikyuu-2.7.3.dist-info}/entry_points.txt +0 -0
|
@@ -4,97 +4,51 @@
|
|
|
4
4
|
# Create on: 20240102
|
|
5
5
|
# Author: fasiondog
|
|
6
6
|
|
|
7
|
-
|
|
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
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
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
|
-
|
|
80
|
-
|
|
81
|
-
|
|
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
|
|
89
|
-
for name in
|
|
90
|
-
for code in
|
|
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
|
-
|
|
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()
|
|
@@ -26,7 +26,9 @@ hdf5_template = """
|
|
|
26
26
|
[hikyuu]
|
|
27
27
|
tmpdir = {dir}/tmp
|
|
28
28
|
datadir = {dir}
|
|
29
|
+
reload_time = {reload_time}
|
|
29
30
|
quotation_server = {quotation_server}
|
|
31
|
+
lazy_preload = {lazy_preload}
|
|
30
32
|
|
|
31
33
|
[block]
|
|
32
34
|
type = sqlite3
|
|
@@ -52,6 +54,8 @@ min15 = {min15}
|
|
|
52
54
|
min30 = {min30}
|
|
53
55
|
min60 = {min60}
|
|
54
56
|
hour2= {hour2}
|
|
57
|
+
timeline = {timeline}
|
|
58
|
+
trans = {trans}
|
|
55
59
|
day_max = {day_max}
|
|
56
60
|
week_max = {week_max}
|
|
57
61
|
month_max = {month_max}
|
|
@@ -64,6 +68,8 @@ min15_max = {min15_max}
|
|
|
64
68
|
min30_max = {min30_max}
|
|
65
69
|
min60_max = {min60_max}
|
|
66
70
|
hour2_max = {hour2_max}
|
|
71
|
+
timeline_max = {timeline_max}
|
|
72
|
+
trans_max = {trans_max}
|
|
67
73
|
|
|
68
74
|
[baseinfo]
|
|
69
75
|
type = sqlite3
|
|
@@ -94,7 +100,9 @@ mysql_template = """
|
|
|
94
100
|
[hikyuu]
|
|
95
101
|
tmpdir = {dir}
|
|
96
102
|
datadir = {dir}
|
|
103
|
+
reload_time = {reload_time}
|
|
97
104
|
quotation_server = {quotation_server}
|
|
105
|
+
lazy_preload = {lazy_preload}
|
|
98
106
|
|
|
99
107
|
[block]
|
|
100
108
|
type = mysql
|
|
@@ -116,6 +124,8 @@ min15 = {min15}
|
|
|
116
124
|
min30 = {min30}
|
|
117
125
|
min60 = {min60}
|
|
118
126
|
hour2 = {hour2}
|
|
127
|
+
timeline = {timeline}
|
|
128
|
+
trans = {trans}
|
|
119
129
|
day_max = {day_max}
|
|
120
130
|
week_max = {week_max}
|
|
121
131
|
month_max = {month_max}
|
|
@@ -128,6 +138,8 @@ min15_max = {min15_max}
|
|
|
128
138
|
min30_max = {min30_max}
|
|
129
139
|
min60_max = {min60_max}
|
|
130
140
|
hour2_max = {hour2_max}
|
|
141
|
+
timeline_max = {timeline_max}
|
|
142
|
+
trans_max = {trans_max}
|
|
131
143
|
|
|
132
144
|
[baseinfo]
|
|
133
145
|
type = mysql
|
|
@@ -149,7 +161,9 @@ clickhouse_template = """
|
|
|
149
161
|
[hikyuu]
|
|
150
162
|
tmpdir = {dir}
|
|
151
163
|
datadir = {dir}
|
|
164
|
+
reload_time = {reload_time}
|
|
152
165
|
quotation_server = {quotation_server}
|
|
166
|
+
lazy_preload = {lazy_preload}
|
|
153
167
|
|
|
154
168
|
[block]
|
|
155
169
|
type = clickhouse
|
|
@@ -171,6 +185,8 @@ min15 = {min15}
|
|
|
171
185
|
min30 = {min30}
|
|
172
186
|
min60 = {min60}
|
|
173
187
|
hour2 = {hour2}
|
|
188
|
+
timeline = {timeline}
|
|
189
|
+
trans = {trans}
|
|
174
190
|
day_max = {day_max}
|
|
175
191
|
week_max = {week_max}
|
|
176
192
|
month_max = {month_max}
|
|
@@ -183,6 +199,8 @@ min15_max = {min15_max}
|
|
|
183
199
|
min30_max = {min30_max}
|
|
184
200
|
min60_max = {min60_max}
|
|
185
201
|
hour2_max = {hour2_max}
|
|
202
|
+
timeline_max = {timeline_max}
|
|
203
|
+
trans_max = {trans_max}
|
|
186
204
|
|
|
187
205
|
[baseinfo]
|
|
188
206
|
type = clickhouse
|
|
@@ -210,8 +228,8 @@ future = False
|
|
|
210
228
|
day = True
|
|
211
229
|
min = True
|
|
212
230
|
min5 = True
|
|
213
|
-
trans =
|
|
214
|
-
time =
|
|
231
|
+
trans = False
|
|
232
|
+
time = False
|
|
215
233
|
day_start_date = 1990-12-19
|
|
216
234
|
min_start_date = 2023-09-19
|
|
217
235
|
min5_start_date = 2023-09-19
|
|
@@ -251,7 +269,7 @@ enable = False
|
|
|
251
269
|
enable = False
|
|
252
270
|
;tmpdir = D:/stock
|
|
253
271
|
;host = 127.0.0.1
|
|
254
|
-
|
|
272
|
+
;http_port = 8123
|
|
255
273
|
;port = 9000
|
|
256
274
|
;usr = root
|
|
257
275
|
;pwd =
|
|
@@ -269,6 +287,9 @@ phase1_end = 11:35:00
|
|
|
269
287
|
phase2_start = 12:00:00
|
|
270
288
|
phase2_end = 15:05:00
|
|
271
289
|
|
|
290
|
+
[lazy_preload]
|
|
291
|
+
enable = False
|
|
292
|
+
|
|
272
293
|
[preload]
|
|
273
294
|
day = True
|
|
274
295
|
week = True
|
|
@@ -282,6 +303,8 @@ min15 = False
|
|
|
282
303
|
min30 = False
|
|
283
304
|
min60 = False
|
|
284
305
|
hour2 = False
|
|
306
|
+
timeline = False
|
|
307
|
+
trans = False
|
|
285
308
|
day_max = 100000
|
|
286
309
|
week_max = 100000
|
|
287
310
|
month_max = 100000
|
|
@@ -294,6 +317,8 @@ min15_max = 5120
|
|
|
294
317
|
min30_max = 5120
|
|
295
318
|
min60_max = 5120
|
|
296
319
|
hour2_max = 5120
|
|
320
|
+
timeline_max = 5120
|
|
321
|
+
trans_max = 5120
|
|
297
322
|
"""
|
|
298
323
|
|
|
299
324
|
|
|
@@ -304,14 +329,16 @@ def generate_default_config():
|
|
|
304
329
|
from hikyuu.data.hku_config_template import hdf5_template
|
|
305
330
|
user_dir = os.path.expanduser('~')
|
|
306
331
|
data_dir = "c:\\stock" if sys.platform == 'win32' else f"{user_dir}/stock"
|
|
307
|
-
hdf5_config = hdf5_template.format(dir=data_dir, quotation_server='ipc:///tmp/hikyuu_real.ipc',
|
|
332
|
+
hdf5_config = hdf5_template.format(dir=data_dir, reload_time="00:00", quotation_server='ipc:///tmp/hikyuu_real.ipc',
|
|
308
333
|
day=True, week=False,
|
|
309
334
|
month=False, quarter=False, halfyear=False, year=False,
|
|
310
335
|
min1=False, min5=False, min15=False, min30=False,
|
|
311
|
-
min60=False, hour2=False,
|
|
336
|
+
min60=False, hour2=False, timeline=False, trans=False,
|
|
337
|
+
day_max=100000, week_max=100000,
|
|
312
338
|
month_max=100000, quarter_max=100000, halfyear_max=100000,
|
|
313
339
|
year_max=100000, min1_max=5120, min5_max=5120, min15_max=5120,
|
|
314
|
-
min30_max=5120, min60_max=5120, hour2_max=5120
|
|
340
|
+
min30_max=5120, min60_max=5120, hour2_max=5120,
|
|
341
|
+
timeline_max=5120, trans_max=5120)
|
|
315
342
|
config_dir = f"{user_dir}/.hikyuu"
|
|
316
343
|
if not os.path.lexists(config_dir):
|
|
317
344
|
os.makedirs(config_dir)
|
|
@@ -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
|
from pytdx.hq import TDXParams
|
|
30
|
+
from configparser import ConfigParser
|
|
29
31
|
|
|
30
32
|
from hikyuu.util import hku_error, hku_debug, hku_run_ignore_exception
|
|
31
33
|
|
|
32
|
-
from hikyuu import Datetime
|
|
34
|
+
from hikyuu import Datetime, roundEx, is_valid_license, KDataToClickHouseImporter
|
|
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_clickhouse import (
|
|
@@ -134,6 +136,9 @@ def import_stock_name(connect, api, market, quotations=None):
|
|
|
134
136
|
if code not in deSet:
|
|
135
137
|
newStockDict[code] = stock["name"]
|
|
136
138
|
|
|
139
|
+
# 号码前缀
|
|
140
|
+
codepre_list = get_codepre_list(connect, market, quotations)
|
|
141
|
+
|
|
137
142
|
stktype_list = get_stktype_list(quotations)
|
|
138
143
|
stktype_list = list(stktype_list)
|
|
139
144
|
stktype_list.remove(STOCKTYPE.INDEX) # 移除指数类型
|
|
@@ -149,23 +154,29 @@ def import_stock_name(connect, api, market, quotations=None):
|
|
|
149
154
|
|
|
150
155
|
oldname, oldtype, oldvalid, oldstartDate, oldendDate = oldstock[2], oldstock[3], oldstock[4], oldstock[5], oldstock[6]
|
|
151
156
|
|
|
157
|
+
# 检测是否类型发生变化
|
|
158
|
+
newtype = oldtype
|
|
159
|
+
for codepre in codepre_list:
|
|
160
|
+
length = len(codepre[0])
|
|
161
|
+
if oldcode[:length] == codepre[0]:
|
|
162
|
+
if oldtype != codepre[1]:
|
|
163
|
+
newtype = codepre[1]
|
|
164
|
+
break
|
|
165
|
+
|
|
152
166
|
# 新的代码表中无此股票,则置为无效
|
|
153
|
-
# if (oldvalid == 1) and (oldcode not in newStockDict):
|
|
154
167
|
if (oldvalid == 1) and ((oldcode not in newStockDict) or oldcode in deSet):
|
|
155
168
|
sql = f"delete from hku_base.stock where market='{market}' and code='{oldcode}'"
|
|
156
169
|
connect.command(sql)
|
|
157
|
-
insert_records.append((market, oldcode, oldname,
|
|
170
|
+
insert_records.append((market, oldcode, oldname, newtype, 0, oldstartDate, oldendDate))
|
|
158
171
|
|
|
159
172
|
# 股票名称发生变化,更新股票名称;如果原无效,则置为有效
|
|
160
173
|
if oldcode in newStockDict:
|
|
161
|
-
if oldname != newStockDict[oldcode] or oldvalid == 0:
|
|
174
|
+
if oldname != newStockDict[oldcode] or oldvalid == 0 or oldtype != newtype:
|
|
162
175
|
sql = f"delete from hku_base.stock where market='{market}' and code='{oldcode}'"
|
|
163
176
|
connect.command(sql)
|
|
164
|
-
insert_records.append((market, oldcode, newStockDict[oldcode],
|
|
177
|
+
insert_records.append((market, oldcode, newStockDict[oldcode], newtype, 1, oldstartDate, 99999999))
|
|
165
178
|
|
|
166
179
|
# 处理新出现的股票
|
|
167
|
-
codepre_list = get_codepre_list(connect, market, quotations)
|
|
168
|
-
|
|
169
180
|
today = datetime.date.today()
|
|
170
181
|
today = today.year * 10000 + today.month * 100 + today.day
|
|
171
182
|
count = 0
|
|
@@ -274,10 +285,10 @@ def import_one_stock_data(
|
|
|
274
285
|
today.year * 10000 + today.month * 100 + today.day
|
|
275
286
|
) * 10000 + 1500
|
|
276
287
|
else:
|
|
277
|
-
return 0
|
|
288
|
+
return (0, True, Datetime(last_datetime))
|
|
278
289
|
|
|
279
290
|
if today_datetime <= last_datetime:
|
|
280
|
-
return 0
|
|
291
|
+
return (0, True, Datetime(last_datetime))
|
|
281
292
|
|
|
282
293
|
get_bars = (
|
|
283
294
|
api.get_index_bars if stktype == STOCKTYPE.INDEX else api.get_security_bars
|
|
@@ -304,31 +315,35 @@ def import_one_stock_data(
|
|
|
304
315
|
hku_error("Failed translate datetime: {}, from {}! {}".format(bar, api.ip, e))
|
|
305
316
|
continue
|
|
306
317
|
|
|
318
|
+
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:
|
|
319
|
+
hku_warn(f"Ignore invalid bar: {bar_datetime}, missing fields!")
|
|
320
|
+
continue
|
|
321
|
+
|
|
307
322
|
if last_krecord is not None and bar_datetime == last_datetime:
|
|
308
323
|
if abs(last_krecord[1] - bar["open"]) / last_krecord[1] > 0.01:
|
|
309
324
|
hku_error(
|
|
310
325
|
f"fetch data from tdx error! {bar_datetime} {ktype} {market}{code} last_krecord open: {last_krecord[1]}, bar: {bar['open']}")
|
|
311
|
-
return 0
|
|
326
|
+
return (0, False, Datetime(last_datetime))
|
|
312
327
|
if abs(last_krecord[2] - bar["high"]) / last_krecord[2] > 0.01:
|
|
313
328
|
hku_error(
|
|
314
329
|
f"fetch data from tdx error! {bar_datetime} {ktype} {market}{code} last_krecord high: {last_krecord[2]}, bar: {bar['high']}")
|
|
315
|
-
return 0
|
|
316
|
-
if abs(last_krecord[3] - bar["low"]) / last_krecord[3] > 0.01:
|
|
330
|
+
return (0, False, Datetime(last_datetime))
|
|
331
|
+
if abs(last_krecord[3] - bar["low"]) / last_krecord[3] > 0.01 and abs(last_krecord[3] - bar["low"]) > 0.01:
|
|
317
332
|
hku_error(
|
|
318
333
|
f"fetch data from tdx error! {bar_datetime} {ktype} {market}{code} last_krecord low: {last_krecord[3]}, bar: {bar['low']}")
|
|
319
|
-
return 0
|
|
334
|
+
return (0, False, Datetime(last_datetime))
|
|
320
335
|
if abs(last_krecord[4] - bar["close"]) / last_krecord[4] > 0.01:
|
|
321
336
|
hku_error(
|
|
322
337
|
f"fetch data from tdx error! {bar_datetime} {ktype} {market}{code} last_krecord close: {last_krecord[4]}, bar: {bar['close']}")
|
|
323
|
-
return 0
|
|
324
|
-
if ktype == 'DAY' and last_krecord[5] != 0.0 and abs(last_krecord[5] - bar["amount"]
|
|
338
|
+
return (0, False, Datetime(last_datetime))
|
|
339
|
+
if ktype == 'DAY' and last_krecord[5] != 0.0 and abs(last_krecord[5] - bar["amount"]) > 10000:
|
|
325
340
|
hku_error(
|
|
326
|
-
f"fetch data from tdx error! {bar_datetime} {ktype} {market}{code} last_krecord amount: {last_krecord[5]}, bar: {bar['amount']
|
|
327
|
-
return 0
|
|
328
|
-
if ktype == 'DAY' and last_krecord[
|
|
341
|
+
f"fetch data from tdx error! {bar_datetime} {ktype} {market}{code} last_krecord amount: {last_krecord[5]}, bar: {bar['amount']}")
|
|
342
|
+
return (0, False, Datetime(last_datetime))
|
|
343
|
+
if ktype == 'DAY' and last_krecord[6] != 0.0 and last_krecord[6] != 0.0 and abs(last_krecord[6] - bar["vol"]) > 10000:
|
|
329
344
|
hku_error(
|
|
330
345
|
f"fetch data from tdx error! {bar_datetime} {ktype} {market}{code} last_krecord count: {last_krecord[6]}, bar: {bar['vol']}")
|
|
331
|
-
return 0
|
|
346
|
+
return (0, False, Datetime(last_datetime))
|
|
332
347
|
continue
|
|
333
348
|
|
|
334
349
|
if (
|
|
@@ -343,12 +358,12 @@ def import_one_stock_data(
|
|
|
343
358
|
(
|
|
344
359
|
table[1], table[2],
|
|
345
360
|
Datetime(bar_datetime).timestamp_utc()//1000000,
|
|
346
|
-
bar["open"],
|
|
347
|
-
bar["high"],
|
|
348
|
-
bar["low"],
|
|
349
|
-
bar["close"],
|
|
350
|
-
bar["amount"]
|
|
351
|
-
bar["vol"]
|
|
361
|
+
int(roundEx(bar["open"], 3)*1000),
|
|
362
|
+
int(roundEx(bar["high"], 3)*1000),
|
|
363
|
+
int(roundEx(bar["low"], 3)*1000),
|
|
364
|
+
int(roundEx(bar["close"], 3)*1000),
|
|
365
|
+
int(roundEx(bar["amount"], 0)),
|
|
366
|
+
int(roundEx(bar["vol"], 3)*1000)
|
|
352
367
|
# bar['vol'] if stktype == 2 else round(bar['vol'] * 0.01)
|
|
353
368
|
)
|
|
354
369
|
)
|
|
@@ -361,7 +376,7 @@ def import_one_stock_data(
|
|
|
361
376
|
data=buf)
|
|
362
377
|
connect.insert(context=ic, settings={"prefer_warmed_unmerged_parts_seconds": 86400})
|
|
363
378
|
|
|
364
|
-
return len(buf)
|
|
379
|
+
return (len(buf), True, Datetime(last_datetime))
|
|
365
380
|
|
|
366
381
|
|
|
367
382
|
def update_stock_info(connect, market):
|
|
@@ -405,7 +420,7 @@ def clear_extern_data(connect, market, data_type):
|
|
|
405
420
|
index_list = ('min15', 'min30', 'min60', 'hour2')
|
|
406
421
|
lastdate = connect.command(
|
|
407
422
|
f"select toInt32(max(date)) from hku_data.min5_k where market='SH' and code='000001'")
|
|
408
|
-
lastdate = Datetime.from_timestamp_utc(lastdate*1000000).start_of_day()
|
|
423
|
+
lastdate = Datetime.from_timestamp_utc(int(lastdate*1000000)).start_of_day()
|
|
409
424
|
last_timestamp = Datetime(lastdate).timestamp_utc()//1000000
|
|
410
425
|
for index_type in index_list:
|
|
411
426
|
sql = f"delete from hku_data.{index_type}_k where market='{market}' and date>={last_timestamp}"
|
|
@@ -416,6 +431,16 @@ def clear_extern_data(connect, market, data_type):
|
|
|
416
431
|
hku_info(f"清理 {market} {data_type} 线扩展数据完毕")
|
|
417
432
|
|
|
418
433
|
|
|
434
|
+
@hku_catch(ret=None)
|
|
435
|
+
def get_clickhouse_importer():
|
|
436
|
+
filename = os.path.expanduser('~') + '/.hikyuu/hikyuu.ini'
|
|
437
|
+
config = ConfigParser()
|
|
438
|
+
config.read(filename, encoding='utf-8')
|
|
439
|
+
importer = KDataToClickHouseImporter()
|
|
440
|
+
return importer if importer.set_config(config.get("kdata", "host"), config.getint("kdata", "port", fallback=9000),
|
|
441
|
+
config.get("kdata", "usr"), config.get("kdata", "pwd")) else None
|
|
442
|
+
|
|
443
|
+
|
|
419
444
|
@hku_catch(trace=True, re_raise=True)
|
|
420
445
|
def import_data(
|
|
421
446
|
connect,
|
|
@@ -456,6 +481,9 @@ def import_data(
|
|
|
456
481
|
for index_type in index_list:
|
|
457
482
|
update_data[index_type] = []
|
|
458
483
|
|
|
484
|
+
failed_limit = 20
|
|
485
|
+
failed_count = 0
|
|
486
|
+
failed_list = []
|
|
459
487
|
total = len(stock_list)
|
|
460
488
|
# market, code, valid, type
|
|
461
489
|
for i, stock in enumerate(stock_list):
|
|
@@ -464,9 +492,15 @@ def import_data(
|
|
|
464
492
|
progress(i, total)
|
|
465
493
|
continue
|
|
466
494
|
|
|
467
|
-
this_count = import_one_stock_data(
|
|
495
|
+
this_count, success, lastdate = import_one_stock_data(
|
|
468
496
|
connect, api, market, ktype, stock, startDate
|
|
469
497
|
)
|
|
498
|
+
if not success:
|
|
499
|
+
failed_count += 1
|
|
500
|
+
failed_list.append((market, stock[1], lastdate))
|
|
501
|
+
if failed_count >= failed_limit:
|
|
502
|
+
# hku_error(f"{market} {ktype} 连续失败20个股票,已停止导入, 建议重新导入")
|
|
503
|
+
break
|
|
470
504
|
add_record_count += this_count
|
|
471
505
|
if ktype in ("DAY", "5MIN"):
|
|
472
506
|
if ktype == "DAY":
|
|
@@ -486,6 +520,9 @@ def import_data(
|
|
|
486
520
|
if progress:
|
|
487
521
|
progress(i, total)
|
|
488
522
|
|
|
523
|
+
if total > 0 and progress:
|
|
524
|
+
progress(total, total)
|
|
525
|
+
|
|
489
526
|
if ktype in ("DAY", "5MIN"):
|
|
490
527
|
for index_type in index_list:
|
|
491
528
|
if len(update_data[index_type]) > 0:
|
|
@@ -497,6 +534,25 @@ def import_data(
|
|
|
497
534
|
update_data[index_type].clear()
|
|
498
535
|
update_data.clear()
|
|
499
536
|
|
|
537
|
+
if 0 < failed_count < failed_limit and is_valid_license():
|
|
538
|
+
# 删除最后记录
|
|
539
|
+
ktype_dict = {
|
|
540
|
+
'DAY': 'DAY',
|
|
541
|
+
'1MIN': 'MIN',
|
|
542
|
+
'5MIN': 'MIN5'
|
|
543
|
+
}
|
|
544
|
+
nktype = ktype_dict[ktype]
|
|
545
|
+
ch_importer = get_clickhouse_importer()
|
|
546
|
+
if ch_importer is not None:
|
|
547
|
+
for r in failed_list:
|
|
548
|
+
hku_warn(f"清理 {r[0]} {r[1]} {nktype} {r[2].start_of_day()}")
|
|
549
|
+
ch_importer.remove(r[0], r[1], nktype, r[2].start_of_day())
|
|
550
|
+
hku_warn(f"已清理 {market} {failed_count} 个失败股票的最后记录,建议重新导入")
|
|
551
|
+
|
|
552
|
+
if failed_count >= failed_limit:
|
|
553
|
+
hku_error(f"{market} {ktype} 连续失败20个股票,已停止导入, 建议重新导入")
|
|
554
|
+
return add_record_count
|
|
555
|
+
|
|
500
556
|
cur_year = Datetime.today().year
|
|
501
557
|
if ktype == "DAY":
|
|
502
558
|
update_stock_info(connect, market)
|
|
@@ -588,15 +644,16 @@ def import_on_stock_trans(connect, api, market, stock_record, max_days):
|
|
|
588
644
|
if second > 59:
|
|
589
645
|
continue
|
|
590
646
|
|
|
591
|
-
|
|
592
|
-
(
|
|
593
|
-
|
|
594
|
-
|
|
595
|
-
|
|
596
|
-
|
|
597
|
-
|
|
647
|
+
if record['price'] > 0.0 and record['vol'] >= 0.0:
|
|
648
|
+
trans_buf.append(
|
|
649
|
+
(
|
|
650
|
+
market, code,
|
|
651
|
+
Datetime(cur_date * 1000000 + minute * 100 + second).timestamp_utc()//1000000,
|
|
652
|
+
int(roundEx(record["price"], 3) * 1000.0),
|
|
653
|
+
int(record["vol"]),
|
|
654
|
+
record["buyorsell"],
|
|
655
|
+
)
|
|
598
656
|
)
|
|
599
|
-
)
|
|
600
657
|
except Exception as e:
|
|
601
658
|
hku_error("Failed trans to record! {}", e)
|
|
602
659
|
|
|
@@ -697,8 +754,9 @@ def import_on_stock_time(connect, api, market, stock_record, max_days):
|
|
|
697
754
|
elif time == 1360:
|
|
698
755
|
time = 1400
|
|
699
756
|
try:
|
|
700
|
-
|
|
701
|
-
|
|
757
|
+
if record['price'] > 0.0 and record['vol'] >= 0.0:
|
|
758
|
+
time_buf.append((market, code, Datetime(this_date + time).timestamp_utc() //
|
|
759
|
+
ticks, int(roundEx(record['price'], 3) * 1000.0), int(record['vol'])))
|
|
702
760
|
time += 1
|
|
703
761
|
except Exception as e:
|
|
704
762
|
hku_error("Failed trans record {}! {}".format(record, e))
|