hikyuu 2.6.3__py3-none-win_amd64.whl → 2.6.6__py3-none-win_amd64.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- hikyuu/__init__.py +6 -0
- hikyuu/__init__.pyi +548 -546
- hikyuu/analysis/__init__.pyi +519 -514
- hikyuu/analysis/analysis.pyi +520 -515
- hikyuu/core.pyi +521 -516
- hikyuu/cpp/__init__.pyi +2 -2
- hikyuu/cpp/boost_date_time-mt.dll +0 -0
- hikyuu/cpp/boost_serialization-mt.dll +0 -0
- hikyuu/cpp/boost_wserialization-mt.dll +0 -0
- hikyuu/cpp/core310.pyd +0 -0
- hikyuu/cpp/core310.pyi +167 -36
- hikyuu/cpp/core311.pyd +0 -0
- hikyuu/cpp/core311.pyi +167 -36
- hikyuu/cpp/core312.pyd +0 -0
- hikyuu/cpp/core312.pyi +167 -36
- hikyuu/cpp/core313.pyd +0 -0
- hikyuu/cpp/core313.pyi +167 -36
- hikyuu/cpp/core39.pyd +0 -0
- hikyuu/cpp/core39.pyi +167 -36
- hikyuu/cpp/hikyuu.dll +0 -0
- hikyuu/cpp/hikyuu.lib +0 -0
- hikyuu/cpp/i18n/__init__.py +0 -0
- hikyuu/cpp/i18n/zh_CN.mo +0 -0
- hikyuu/cpp/sqlite3.dll +0 -0
- hikyuu/data/clickhouse_upgrade/__init__.py +1 -0
- hikyuu/data/clickhouse_upgrade/createdb.sql +1085 -0
- hikyuu/data/common.py +1 -1
- hikyuu/data/common_clickhouse.py +512 -0
- hikyuu/data/common_mysql.py +19 -0
- hikyuu/data/common_pytdx.py +2 -0
- hikyuu/data/common_sqlite3.py +1 -0
- hikyuu/data/em_block_to_clickhouse.py +120 -0
- hikyuu/data/hku_config_template.py +70 -1
- hikyuu/data/mysql_upgrade/0028.sql +95 -0
- hikyuu/data/pytdx_finance_to_clickhouse.py +107 -0
- hikyuu/data/pytdx_to_clickhouse.py +841 -0
- hikyuu/data/pytdx_to_h5.py +53 -13
- hikyuu/data/pytdx_to_mysql.py +42 -9
- hikyuu/data/pytdx_to_taos.py +736 -0
- hikyuu/data/pytdx_weight_to_clickhouse.py +191 -0
- hikyuu/data/sqlite_upgrade/0028.sql +97 -0
- hikyuu/data/tdx_to_clickhouse.py +448 -0
- hikyuu/data/zh_bond10_to_clickhouse.py +49 -0
- hikyuu/draw/__init__.pyi +1 -1
- hikyuu/draw/drawplot/__init__.pyi +8 -8
- hikyuu/draw/drawplot/bokeh_draw.pyi +538 -536
- hikyuu/draw/drawplot/common.pyi +1 -1
- hikyuu/draw/drawplot/echarts_draw.pyi +540 -538
- hikyuu/draw/drawplot/matplotlib_draw.py +7 -7
- hikyuu/draw/drawplot/matplotlib_draw.pyi +550 -548
- hikyuu/draw/elder.pyi +11 -11
- hikyuu/draw/kaufman.pyi +18 -18
- hikyuu/draw/volume.pyi +10 -10
- hikyuu/examples/notebook/001-overview.ipynb +65 -100
- hikyuu/examples/notebook/004-IndicatorOverview.ipynb +34 -32
- hikyuu/examples/notebook/007-SystemDetails.ipynb +64 -50
- hikyuu/examples/notebook/010-Portfolio.ipynb +120 -124
- hikyuu/extend.py +1 -1
- hikyuu/extend.pyi +527 -527
- hikyuu/fetcher/stock/zh_block_em.py +349 -5
- hikyuu/fetcher/stock/zh_stock_a_pytdx.py +11 -21
- hikyuu/fetcher/stock/zh_stock_a_qmt.py +4 -5
- hikyuu/fetcher/stock/zh_stock_a_sina_qq.py +16 -60
- hikyuu/flat/Spot.py +96 -200
- hikyuu/gui/HikyuuTDX.py +175 -23
- hikyuu/gui/data/ImportBlockInfoTask.py +12 -1
- hikyuu/gui/data/ImportHistoryFinanceTask.py +62 -44
- hikyuu/gui/data/ImportPytdxTimeToH5Task.py +14 -2
- hikyuu/gui/data/ImportPytdxToH5Task.py +17 -3
- hikyuu/gui/data/ImportPytdxTransToH5Task.py +14 -2
- hikyuu/gui/data/ImportTdxToH5Task.py +13 -1
- hikyuu/gui/data/ImportWeightToSqliteTask.py +16 -2
- hikyuu/gui/data/ImportZhBond10Task.py +12 -1
- hikyuu/gui/data/MainWindow.py +191 -110
- hikyuu/gui/data/UsePytdxImportToH5Thread.py +52 -29
- hikyuu/gui/data/UseQmtImportToH5Thread.py +1 -0
- hikyuu/gui/data/UseTdxImportToH5Thread.py +21 -2
- hikyuu/gui/dataserver.py +12 -4
- hikyuu/gui/spot_server.py +30 -40
- hikyuu/gui/start_qmt.py +20 -3
- hikyuu/hub.pyi +6 -6
- hikyuu/include/hikyuu/DataType.h +11 -0
- hikyuu/include/hikyuu/MarketInfo.h +6 -0
- hikyuu/include/hikyuu/StockManager.h +8 -0
- hikyuu/include/hikyuu/data_driver/BaseInfoDriver.h +35 -0
- hikyuu/include/hikyuu/data_driver/kdata/mysql/KRecordTable.h +1 -0
- hikyuu/include/hikyuu/global/GlobalSpotAgent.h +1 -1
- hikyuu/include/hikyuu/global/SpotRecord.h +15 -31
- hikyuu/include/hikyuu/global/agent/spot_generated.h +48 -232
- hikyuu/include/hikyuu/global/schedule/scheduler.h +1 -1
- hikyuu/include/hikyuu/indicator/build_in.h +1 -0
- hikyuu/include/hikyuu/indicator/crt/BARSLASTCOUNT.h +33 -0
- hikyuu/include/hikyuu/indicator/imp/IBarsLastCount.h +27 -0
- hikyuu/include/hikyuu/plugin/KDataToHdf5Importer.h +3 -0
- hikyuu/include/hikyuu/plugin/backtest.h +2 -2
- hikyuu/include/hikyuu/plugin/dataserver.h +26 -1
- hikyuu/include/hikyuu/plugin/device.h +8 -4
- hikyuu/include/hikyuu/plugin/interface/BackTestPluginInterface.h +1 -1
- hikyuu/include/hikyuu/plugin/interface/DataDriverPluginInterface.h +27 -0
- hikyuu/include/hikyuu/plugin/interface/DataServerPluginInterface.h +2 -1
- hikyuu/include/hikyuu/plugin/interface/DevicePluginInterface.h +2 -1
- hikyuu/include/hikyuu/plugin/interface/ImportKDataToHdf5PluginInterface.h +3 -0
- hikyuu/include/hikyuu/plugin/interface/TMReportPluginInterface.h +80 -0
- hikyuu/include/hikyuu/plugin/interface/plugins.h +4 -0
- hikyuu/include/hikyuu/strategy/Strategy.h +0 -9
- hikyuu/include/hikyuu/trade_manage/Performance.h +17 -9
- hikyuu/include/hikyuu/trade_manage/PositionExtInfo.h +92 -0
- hikyuu/include/hikyuu/trade_manage/PositionRecord.h +7 -1
- hikyuu/include/hikyuu/trade_manage/TradeManagerBase.h +60 -1
- hikyuu/include/hikyuu/trade_sys/selector/crt/SE_Optimal.h +8 -0
- hikyuu/include/hikyuu/trade_sys/selector/imp/optimal/OptimalEvaluateSelector.h +28 -0
- hikyuu/include/hikyuu/trade_sys/selector/imp/optimal/OptimalSelectorBase.h +1 -0
- hikyuu/include/hikyuu/utilities/DllLoader.h +226 -0
- hikyuu/include/hikyuu/utilities/config.h +1 -1
- hikyuu/include/hikyuu/utilities/datetime/Datetime.h +20 -0
- hikyuu/include/hikyuu/utilities/datetime/TimeDelta.h +6 -0
- hikyuu/include/hikyuu/utilities/mo/mo.h +30 -14
- hikyuu/include/hikyuu/utilities/os.h +6 -0
- hikyuu/include/hikyuu/utilities/plugin/PluginLoader.h +10 -10
- hikyuu/include/hikyuu/utilities/thread/MQThreadPool.h +13 -7
- hikyuu/include/hikyuu/utilities/thread/ThreadPool.h +13 -6
- hikyuu/include/hikyuu/version.h +4 -4
- hikyuu/plugin/backtest.dll +0 -0
- hikyuu/plugin/clickhousedriver.dll +0 -0
- hikyuu/plugin/dataserver.dll +0 -0
- hikyuu/plugin/device.dll +0 -0
- hikyuu/plugin/extind.dll +0 -0
- hikyuu/plugin/import2hdf5.dll +0 -0
- hikyuu/plugin/tmreport.dll +0 -0
- hikyuu/trade_manage/__init__.pyi +537 -535
- hikyuu/trade_manage/broker.pyi +3 -3
- hikyuu/trade_manage/broker_easytrader.pyi +1 -1
- hikyuu/trade_manage/trade.pyi +537 -535
- hikyuu/util/__init__.py +1 -0
- hikyuu/util/__init__.pyi +4 -3
- hikyuu/util/check.py +8 -0
- hikyuu/util/check.pyi +5 -1
- hikyuu/util/singleton.pyi +1 -1
- {hikyuu-2.6.3.dist-info → hikyuu-2.6.6.dist-info}/METADATA +4 -3
- {hikyuu-2.6.3.dist-info → hikyuu-2.6.6.dist-info}/RECORD +144 -123
- {hikyuu-2.6.3.dist-info → hikyuu-2.6.6.dist-info}/top_level.txt +2 -2
- hikyuu/include/hikyuu/global/agent/hikyuu/__init__.py +0 -1
- hikyuu/include/hikyuu/global/agent/hikyuu/flat/__init__.py +0 -1
- {hikyuu-2.6.3.dist-info → hikyuu-2.6.6.dist-info}/LICENSE +0 -0
- {hikyuu-2.6.3.dist-info → hikyuu-2.6.6.dist-info}/WHEEL +0 -0
- {hikyuu-2.6.3.dist-info → hikyuu-2.6.6.dist-info}/entry_points.txt +0 -0
hikyuu/data/pytdx_to_h5.py
CHANGED
|
@@ -29,7 +29,7 @@ import sqlite3
|
|
|
29
29
|
from pytdx.hq import TDXParams
|
|
30
30
|
|
|
31
31
|
from hikyuu.util.mylog import get_default_logger, hku_error, hku_debug
|
|
32
|
-
|
|
32
|
+
from hikyuu import Datetime
|
|
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_sqlite3 import (
|
|
@@ -191,7 +191,10 @@ def guess_day_n_step(last_datetime):
|
|
|
191
191
|
if n < 1:
|
|
192
192
|
last_m = last_date // 100 - last_y * 100
|
|
193
193
|
last_d = last_date - (last_y * 10000 + last_m * 100)
|
|
194
|
-
step = (today - datetime.date(last_y, last_m, last_d)).days
|
|
194
|
+
step = (today - datetime.date(last_y, last_m, last_d)).days + 1
|
|
195
|
+
if step > 800:
|
|
196
|
+
n = 1
|
|
197
|
+
step = 800
|
|
195
198
|
|
|
196
199
|
return (n, step)
|
|
197
200
|
|
|
@@ -204,10 +207,10 @@ def guess_1min_n_step(last_datetime):
|
|
|
204
207
|
last_m = last_date // 100 - last_y * 100
|
|
205
208
|
last_d = last_date - (last_y * 10000 + last_m * 100)
|
|
206
209
|
|
|
207
|
-
n = int((today - datetime.date(last_y, last_m, last_d)).days * 240 // 800)
|
|
210
|
+
n = int(((today - datetime.date(last_y, last_m, last_d)).days * 240 + 1) // 800)
|
|
208
211
|
step = 800
|
|
209
212
|
if n < 1:
|
|
210
|
-
step = (today - datetime.date(last_y, last_m, last_d)).days * 240
|
|
213
|
+
step = (today - datetime.date(last_y, last_m, last_d)).days * 240 + 1
|
|
211
214
|
elif n > 99:
|
|
212
215
|
n = 99
|
|
213
216
|
|
|
@@ -222,10 +225,10 @@ def guess_5min_n_step(last_datetime):
|
|
|
222
225
|
last_m = last_date // 100 - last_y * 100
|
|
223
226
|
last_d = last_date - (last_y * 10000 + last_m * 100)
|
|
224
227
|
|
|
225
|
-
n = int((today - datetime.date(last_y, last_m, last_d)).days * 48 // 800)
|
|
228
|
+
n = int(((today - datetime.date(last_y, last_m, last_d)).days * 48 + 1) // 800)
|
|
226
229
|
step = 800
|
|
227
230
|
if n < 1:
|
|
228
|
-
step = (today - datetime.date(last_y, last_m, last_d)).days * 48
|
|
231
|
+
step = (today - datetime.date(last_y, last_m, last_d)).days * 48 + 1
|
|
229
232
|
elif n > 99:
|
|
230
233
|
n = 99
|
|
231
234
|
|
|
@@ -270,6 +273,12 @@ def import_one_stock_data(connect, api, h5file, market, ktype, stock_record, sta
|
|
|
270
273
|
|
|
271
274
|
get_bars = api.get_index_bars if stktype == STOCKTYPE.INDEX else api.get_security_bars
|
|
272
275
|
|
|
276
|
+
need_check = False
|
|
277
|
+
last_krecord = None
|
|
278
|
+
if table.nrows > 0:
|
|
279
|
+
need_check = True
|
|
280
|
+
last_krecord = table[-1]
|
|
281
|
+
|
|
273
282
|
add_record_count = 0
|
|
274
283
|
|
|
275
284
|
row = table.row
|
|
@@ -277,7 +286,7 @@ def import_one_stock_data(connect, api, h5file, market, ktype, stock_record, sta
|
|
|
277
286
|
bar_list = get_bars(pytdx_kline_type, pytdx_market, code, n * 800, step)
|
|
278
287
|
n -= 1
|
|
279
288
|
if bar_list is None:
|
|
280
|
-
|
|
289
|
+
print(code, "invalid!!")
|
|
281
290
|
continue
|
|
282
291
|
|
|
283
292
|
for bar in bar_list:
|
|
@@ -293,6 +302,34 @@ def import_one_stock_data(connect, api, h5file, market, ktype, stock_record, sta
|
|
|
293
302
|
hku_error("Failed translate datetime: {}, from {}! {}".format(bar, api.ip, e))
|
|
294
303
|
continue
|
|
295
304
|
|
|
305
|
+
if need_check and bar_datetime == last_datetime:
|
|
306
|
+
# print(f'{bar_datetime} {ktype} {market}{code}')
|
|
307
|
+
if abs(last_krecord['openPrice']*0.001 - bar["open"]) / (last_krecord['openPrice']*0.001) > 0.02:
|
|
308
|
+
hku_error(
|
|
309
|
+
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
|
|
311
|
+
if abs(last_krecord['highPrice']*0.001 - bar["high"]) / (last_krecord['highPrice']*0.001) > 0.02:
|
|
312
|
+
hku_error(
|
|
313
|
+
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
|
|
315
|
+
if abs(last_krecord['lowPrice']*0.001 - bar["low"]) / (last_krecord['lowPrice']*0.001) > 0.02:
|
|
316
|
+
hku_error(
|
|
317
|
+
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
|
|
319
|
+
if abs(last_krecord['closePrice']*0.001 - bar["close"]) / (last_krecord['closePrice']*0.001) > 0.02:
|
|
320
|
+
hku_error(
|
|
321
|
+
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:
|
|
324
|
+
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:
|
|
328
|
+
hku_error(
|
|
329
|
+
f"fetch data from tdx error! {bar_datetime} {ktype} {market}{code} last_krecord count: {last_krecord['transCount']}, bar: {bar['vol']}")
|
|
330
|
+
return 0
|
|
331
|
+
continue
|
|
332
|
+
|
|
296
333
|
if today_datetime >= bar_datetime > last_datetime \
|
|
297
334
|
and bar['high'] >= bar['open'] >= bar['low'] > 0 \
|
|
298
335
|
and bar['high'] >= bar['close'] >= bar['low'] > 0 \
|
|
@@ -584,7 +621,7 @@ if __name__ == '__main__':
|
|
|
584
621
|
starttime = time.time()
|
|
585
622
|
|
|
586
623
|
dest_dir = "d:\\stock"
|
|
587
|
-
tdx_server = '
|
|
624
|
+
tdx_server = '180.101.48.170'
|
|
588
625
|
tdx_port = 7709
|
|
589
626
|
quotations = ['stock', 'fund']
|
|
590
627
|
|
|
@@ -601,10 +638,11 @@ if __name__ == '__main__':
|
|
|
601
638
|
add_count = import_index_name(connect)
|
|
602
639
|
print("指数个数:", add_count)
|
|
603
640
|
"""
|
|
604
|
-
print("导入股票代码表")
|
|
605
|
-
add_count = import_stock_name(connect, api, 'SH', quotations)
|
|
606
|
-
# add_count += import_stock_name(connect, api, 'SZ', quotations)
|
|
607
|
-
print("新增股票数:", add_count)
|
|
641
|
+
# print("导入股票代码表")
|
|
642
|
+
# add_count = import_stock_name(connect, api, 'SH', quotations)
|
|
643
|
+
# # add_count += import_stock_name(connect, api, 'SZ', quotations)
|
|
644
|
+
# print("新增股票数:", add_count)
|
|
645
|
+
|
|
608
646
|
"""
|
|
609
647
|
print("\n导入上证日线数据")
|
|
610
648
|
add_count = import_data(connect, 'SH', 'DAY', quotations, api, dest_dir, progress=ProgressBar)
|
|
@@ -613,11 +651,13 @@ if __name__ == '__main__':
|
|
|
613
651
|
print("\n导入深证日线数据")
|
|
614
652
|
add_count = import_data(connect, 'SZ', 'DAY', quotations, api, dest_dir, progress=ProgressBar)
|
|
615
653
|
print("\n导入数量:", add_count)
|
|
654
|
+
"""
|
|
616
655
|
|
|
617
656
|
print("\n导入上证5分钟线数据")
|
|
618
|
-
add_count = import_data(connect, 'SH', '
|
|
657
|
+
add_count = import_data(connect, 'SH', 'DAY', quotations, api, dest_dir, progress=ProgressBar)
|
|
619
658
|
print("\n导入数量:", add_count)
|
|
620
659
|
|
|
660
|
+
"""
|
|
621
661
|
print("\n导入深证5分钟线数据")
|
|
622
662
|
add_count = import_data(connect, 'SZ', '5MIN', quotations, api, dest_dir, progress=ProgressBar)
|
|
623
663
|
print("\n导入数量:", add_count)
|
hikyuu/data/pytdx_to_mysql.py
CHANGED
|
@@ -31,6 +31,7 @@ from hikyuu.util.mylog import hku_error, hku_debug
|
|
|
31
31
|
|
|
32
32
|
import mysql.connector
|
|
33
33
|
|
|
34
|
+
from hikyuu import Datetime
|
|
34
35
|
from .common import *
|
|
35
36
|
from .common_pytdx import to_pytdx_market, pytdx_get_day_trans
|
|
36
37
|
from .common_mysql import (
|
|
@@ -40,6 +41,7 @@ from .common_mysql import (
|
|
|
40
41
|
get_stock_list,
|
|
41
42
|
get_table,
|
|
42
43
|
get_lastdatetime,
|
|
44
|
+
get_last_krecord,
|
|
43
45
|
update_extern_data,
|
|
44
46
|
)
|
|
45
47
|
from .weight_to_mysql import qianlong_import_weight
|
|
@@ -238,8 +240,10 @@ def guess_day_n_step(last_datetime):
|
|
|
238
240
|
if n < 1:
|
|
239
241
|
last_m = last_date // 100 - last_y * 100
|
|
240
242
|
last_d = last_date - (last_y * 10000 + last_m * 100)
|
|
241
|
-
step = (today - datetime.date(last_y, last_m, last_d)).days
|
|
242
|
-
|
|
243
|
+
step = (today - datetime.date(last_y, last_m, last_d)).days + 1
|
|
244
|
+
if step > 800:
|
|
245
|
+
n = 1
|
|
246
|
+
step = 800
|
|
243
247
|
return (n, step)
|
|
244
248
|
|
|
245
249
|
|
|
@@ -251,10 +255,10 @@ def guess_1min_n_step(last_datetime):
|
|
|
251
255
|
last_m = last_date // 100 - last_y * 100
|
|
252
256
|
last_d = last_date - (last_y * 10000 + last_m * 100)
|
|
253
257
|
|
|
254
|
-
n = int((today - datetime.date(last_y, last_m, last_d)).days * 240 // 800)
|
|
258
|
+
n = int(((today - datetime.date(last_y, last_m, last_d)).days * 240 + 1) // 800)
|
|
255
259
|
step = 800
|
|
256
260
|
if n < 1:
|
|
257
|
-
step = (today - datetime.date(last_y, last_m, last_d)).days * 240
|
|
261
|
+
step = (today - datetime.date(last_y, last_m, last_d)).days * 240 + 1
|
|
258
262
|
elif n > 99:
|
|
259
263
|
n = 99
|
|
260
264
|
|
|
@@ -269,10 +273,10 @@ def guess_5min_n_step(last_datetime):
|
|
|
269
273
|
last_m = last_date // 100 - last_y * 100
|
|
270
274
|
last_d = last_date - (last_y * 10000 + last_m * 100)
|
|
271
275
|
|
|
272
|
-
n = int((today - datetime.date(last_y, last_m, last_d)).days * 48 // 800)
|
|
276
|
+
n = int(((today - datetime.date(last_y, last_m, last_d)).days * 48 + 1) // 800)
|
|
273
277
|
step = 800
|
|
274
278
|
if n < 1:
|
|
275
|
-
step = (today - datetime.date(last_y, last_m, last_d)).days * 48
|
|
279
|
+
step = (today - datetime.date(last_y, last_m, last_d)).days * 48 + 1
|
|
276
280
|
elif n > 99:
|
|
277
281
|
n = 99
|
|
278
282
|
|
|
@@ -288,9 +292,11 @@ def import_one_stock_data(
|
|
|
288
292
|
stockid, marketid, code, valid, stktype = stock_record[:5]
|
|
289
293
|
hku_debug("{}{}".format(market, code))
|
|
290
294
|
table = get_table(connect, market, code, ktype)
|
|
291
|
-
|
|
292
|
-
if
|
|
293
|
-
|
|
295
|
+
last_krecord = get_last_krecord(connect, table)
|
|
296
|
+
last_datetime = startDate if last_krecord is None else last_krecord[0]
|
|
297
|
+
# last_datetime = get_lastdatetime(connect, table)
|
|
298
|
+
# if last_datetime is None:
|
|
299
|
+
# last_datetime = startDate
|
|
294
300
|
|
|
295
301
|
today = datetime.date.today()
|
|
296
302
|
if ktype == "DAY":
|
|
@@ -342,6 +348,33 @@ def import_one_stock_data(
|
|
|
342
348
|
hku_error("Failed translate datetime: {}, from {}! {}".format(bar, api.ip, e))
|
|
343
349
|
continue
|
|
344
350
|
|
|
351
|
+
if last_krecord is not None and bar_datetime == last_datetime:
|
|
352
|
+
if abs(last_krecord[1] - bar["open"]) / last_krecord[1] > 0.01:
|
|
353
|
+
hku_error(
|
|
354
|
+
f"fetch data from tdx error! {bar_datetime} {ktype} {market}{code} last_krecord open: {last_krecord[1]}, bar: {bar['open']}")
|
|
355
|
+
return 0
|
|
356
|
+
if abs(last_krecord[2] - bar["high"]) / last_krecord[2] > 0.01:
|
|
357
|
+
hku_error(
|
|
358
|
+
f"fetch data from tdx error! {bar_datetime} {ktype} {market}{code} last_krecord high: {last_krecord[2]}, bar: {bar['high']}")
|
|
359
|
+
return 0
|
|
360
|
+
if abs(last_krecord[3] - bar["low"]) / last_krecord[3] > 0.01:
|
|
361
|
+
hku_error(
|
|
362
|
+
f"fetch data from tdx error! {bar_datetime} {ktype} {market}{code} last_krecord low: {last_krecord[3]}, bar: {bar['low']}")
|
|
363
|
+
return 0
|
|
364
|
+
if abs(last_krecord[4] - bar["close"]) / last_krecord[4] > 0.01:
|
|
365
|
+
hku_error(
|
|
366
|
+
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:
|
|
369
|
+
hku_error(
|
|
370
|
+
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:
|
|
373
|
+
hku_error(
|
|
374
|
+
f"fetch data from tdx error! {bar_datetime} {ktype} {market}{code} last_krecord count: {last_krecord[6]}, bar: {bar['vol']}")
|
|
375
|
+
return 0
|
|
376
|
+
continue
|
|
377
|
+
|
|
345
378
|
if (
|
|
346
379
|
today_datetime >= bar_datetime > last_datetime
|
|
347
380
|
and bar["high"] >= bar["open"] >= bar["low"] > 0
|