hikyuu 2.6.5__py3-none-win_amd64.whl → 2.6.7__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 +16 -0
- hikyuu/__init__.pyi +484 -474
- hikyuu/analysis/__init__.pyi +466 -445
- hikyuu/analysis/analysis.pyi +467 -446
- hikyuu/core.pyi +468 -447
- 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 +1070 -878
- hikyuu/cpp/core311.pyd +0 -0
- hikyuu/cpp/core311.pyi +1070 -878
- hikyuu/cpp/core312.pyd +0 -0
- hikyuu/cpp/core312.pyi +1070 -878
- hikyuu/cpp/core313.pyd +0 -0
- hikyuu/cpp/core313.pyi +1070 -876
- hikyuu/cpp/core39.pyd +0 -0
- hikyuu/cpp/core39.pyi +1070 -878
- hikyuu/cpp/hikyuu.dll +0 -0
- hikyuu/cpp/hikyuu.lib +0 -0
- hikyuu/cpp/i18n/__init__.py +0 -0
- hikyuu/cpp/i18n/zh_CN/__init__.py +0 -0
- hikyuu/cpp/i18n/zh_CN/hikyuu.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_clickhouse.py +465 -0
- hikyuu/data/em_block_to_clickhouse.py +120 -0
- hikyuu/data/hku_config_template.py +58 -3
- hikyuu/data/pytdx_finance_to_clickhouse.py +107 -0
- hikyuu/data/pytdx_to_clickhouse.py +841 -0
- hikyuu/data/pytdx_to_mysql.py +4 -4
- hikyuu/data/pytdx_weight_to_clickhouse.py +191 -0
- hikyuu/data/tdx_to_clickhouse.py +448 -0
- hikyuu/data/tdx_to_h5.py +1 -1
- hikyuu/data/zh_bond10_to_clickhouse.py +49 -0
- hikyuu/draw/__init__.pyi +1 -1
- hikyuu/draw/drawplot/bokeh_draw.pyi +479 -471
- hikyuu/draw/drawplot/echarts_draw.py +9 -8
- hikyuu/draw/drawplot/echarts_draw.pyi +479 -471
- hikyuu/draw/drawplot/matplotlib_draw.py +3 -3
- hikyuu/draw/drawplot/matplotlib_draw.pyi +479 -471
- hikyuu/draw/elder.pyi +6 -6
- hikyuu/draw/kaufman.py +1 -1
- hikyuu/draw/kaufman.pyi +10 -10
- hikyuu/draw/volume.pyi +5 -5
- hikyuu/examples/notebook/000-Index.ipynb +1 -1
- hikyuu/examples/notebook/001-overview.ipynb +78 -63
- hikyuu/examples/notebook/002-HowToGetStock.ipynb +259 -40
- hikyuu/examples/notebook/003-HowToGetKDataAndDraw.ipynb +49 -41
- hikyuu/examples/notebook/004-IndicatorOverview.ipynb +29 -29
- hikyuu/examples/notebook/005-Drawplot.ipynb +66 -37
- hikyuu/examples/notebook/006-TradeManager.ipynb +808 -61
- hikyuu/examples/notebook/007-SystemDetails.ipynb +23 -23
- hikyuu/examples/notebook/009-RealData.ipynb +3 -3
- hikyuu/examples/notebook/010-Portfolio.ipynb +761 -122
- hikyuu/extend.py +15 -100
- hikyuu/extend.pyi +478 -493
- hikyuu/fetcher/stock/zh_stock_a_pytdx.py +9 -20
- 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 +134 -7
- hikyuu/gui/data/ImportBlockInfoTask.py +11 -0
- hikyuu/gui/data/ImportHistoryFinanceTask.py +15 -1
- hikyuu/gui/data/ImportPytdxTimeToH5Task.py +11 -1
- hikyuu/gui/data/ImportPytdxToH5Task.py +13 -1
- hikyuu/gui/data/ImportPytdxTransToH5Task.py +11 -1
- hikyuu/gui/data/ImportTdxToH5Task.py +13 -1
- hikyuu/gui/data/ImportWeightToSqliteTask.py +14 -1
- hikyuu/gui/data/ImportZhBond10Task.py +11 -0
- hikyuu/gui/data/MainWindow.py +210 -135
- hikyuu/gui/data/UsePytdxImportToH5Thread.py +45 -26
- hikyuu/gui/data/UseTdxImportToH5Thread.py +19 -1
- 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 +2 -0
- hikyuu/include/hikyuu/KQuery.h +22 -28
- hikyuu/include/hikyuu/MarketInfo.h +1 -1
- hikyuu/include/hikyuu/Stock.h +15 -3
- hikyuu/include/hikyuu/StockManager.h +12 -3
- hikyuu/include/hikyuu/StockTypeInfo.h +6 -0
- hikyuu/include/hikyuu/TransRecord.h +2 -8
- hikyuu/include/hikyuu/data_driver/kdata/mysql/KRecordTable.h +1 -0
- hikyuu/include/hikyuu/doc.h +4 -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/Indicator.h +37 -0
- hikyuu/include/hikyuu/lang.h +27 -0
- hikyuu/include/hikyuu/plugin/KDataToHdf5Importer.h +9 -1
- hikyuu/include/hikyuu/plugin/dataserver.h +26 -1
- hikyuu/include/hikyuu/plugin/device.h +2 -1
- hikyuu/include/hikyuu/plugin/hkuextra.h +56 -0
- 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 +1 -1
- hikyuu/include/hikyuu/plugin/interface/HkuExtraPluginInterface.h +38 -0
- hikyuu/include/hikyuu/plugin/interface/ImportKDataToHdf5PluginInterface.h +13 -1
- hikyuu/include/hikyuu/plugin/interface/plugins.h +4 -0
- hikyuu/include/hikyuu/python/pybind_utils.h +9 -0
- hikyuu/include/hikyuu/strategy/Strategy.h +0 -9
- hikyuu/include/hikyuu/trade_manage/TradeRecord.h +1 -1
- hikyuu/include/hikyuu/utilities/config.h +0 -2
- hikyuu/include/hikyuu/utilities/os.h +9 -0
- hikyuu/include/hikyuu/utilities/plugin/PluginLoader.h +2 -1
- hikyuu/include/hikyuu/version.h +4 -4
- hikyuu/include/hikyuu/view/MarketView.h +59 -0
- hikyuu/indicator/__init__.py +0 -1
- hikyuu/indicator/indicator.py +14 -53
- 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/hkuextra.dll +0 -0
- hikyuu/plugin/import2hdf5.dll +0 -0
- hikyuu/plugin/tmreport.dll +0 -0
- hikyuu/test/test_init.py +59 -0
- hikyuu/test/test_real_tdx_import.py +336 -0
- hikyuu/test/test_tdx_import.py +315 -0
- hikyuu/test/test_tdx_real_data_import.py +281 -0
- hikyuu/trade_manage/__init__.pyi +479 -471
- hikyuu/trade_manage/trade.py +4 -65
- hikyuu/trade_manage/trade.pyi +479 -483
- hikyuu/trade_sys/__init__.py +11 -0
- hikyuu/util/__init__.py +1 -0
- hikyuu/util/__init__.pyi +4 -4
- hikyuu/util/check.py +8 -0
- hikyuu/util/check.pyi +5 -1
- hikyuu/util/singleton.pyi +1 -1
- {hikyuu-2.6.5.dist-info → hikyuu-2.6.7.dist-info}/METADATA +7 -5
- {hikyuu-2.6.5.dist-info → hikyuu-2.6.7.dist-info}/RECORD +142 -124
- {hikyuu-2.6.5.dist-info → hikyuu-2.6.7.dist-info}/top_level.txt +4 -3
- hikyuu/include/hikyuu/global/agent/hikyuu/flat/__init__.py +0 -1
- hikyuu/include/hikyuu/utilities/mo/__init__.py +0 -1
- hikyuu/include/hikyuu/utilities/mo/mo.h +0 -48
- hikyuu/indicator/talib_wrap.py +0 -1273
- /hikyuu/include/hikyuu/utilities/{mo/moFileReader.h → moFileReader.h} +0 -0
- /hikyuu/include/hikyuu/{global/agent/hikyuu → view}/__init__.py +0 -0
- {hikyuu-2.6.5.dist-info → hikyuu-2.6.7.dist-info}/LICENSE +0 -0
- {hikyuu-2.6.5.dist-info → hikyuu-2.6.7.dist-info}/WHEEL +0 -0
- {hikyuu-2.6.5.dist-info → hikyuu-2.6.7.dist-info}/entry_points.txt +0 -0
hikyuu/gui/HikyuuTDX.py
CHANGED
|
@@ -22,6 +22,8 @@ import mysql.connector
|
|
|
22
22
|
from mysql.connector import errorcode
|
|
23
23
|
from mysql.connector.locales.eng import client_error # 此句仅为pyinstaller打包时能够自动引入
|
|
24
24
|
|
|
25
|
+
import clickhouse_connect
|
|
26
|
+
|
|
25
27
|
from hikyuu.gui.data.MainWindow import *
|
|
26
28
|
from hikyuu.gui.data.EscapetimeThread import EscapetimeThread
|
|
27
29
|
from hikyuu.gui.data.UseTdxImportToH5Thread import UseTdxImportToH5Thread
|
|
@@ -187,6 +189,49 @@ class MyMainWindow(QMainWindow, Ui_MainWindow):
|
|
|
187
189
|
hour2_max=current_config.getint('preload', 'hour2_max', fallback=4096),
|
|
188
190
|
)
|
|
189
191
|
)
|
|
192
|
+
elif current_config.getboolean('clickhouse', 'enable', fallback=True):
|
|
193
|
+
data_dir = current_config['clickhouse']['tmpdir']
|
|
194
|
+
if not os.path.lexists(data_dir + '/tmp'):
|
|
195
|
+
try:
|
|
196
|
+
os.mkdir(data_dir + '/tmp')
|
|
197
|
+
except:
|
|
198
|
+
pass
|
|
199
|
+
with open(filename, 'w', encoding="utf-8") as f:
|
|
200
|
+
f.write(
|
|
201
|
+
hku_config_template.clickhouse_template.format(
|
|
202
|
+
dir=data_dir,
|
|
203
|
+
quotation_server=current_config.get(
|
|
204
|
+
'collect', 'quotation_server', fallback='ipc:///tmp/hikyuu_real.ipc'),
|
|
205
|
+
host=current_config['clickhouse']['host'],
|
|
206
|
+
port=current_config['clickhouse']['port'],
|
|
207
|
+
usr=current_config['clickhouse']['usr'],
|
|
208
|
+
pwd=current_config['clickhouse']['pwd'],
|
|
209
|
+
day=current_config.getboolean('preload', 'day', fallback=True),
|
|
210
|
+
week=current_config.getboolean('preload', 'week', fallback=False),
|
|
211
|
+
month=current_config.getboolean('preload', 'month', fallback=False),
|
|
212
|
+
quarter=current_config.getboolean('preload', 'quarter', fallback=False),
|
|
213
|
+
halfyear=current_config.getboolean('preload', 'halfyear', fallback=False),
|
|
214
|
+
year=current_config.getboolean('preload', 'year', fallback=False),
|
|
215
|
+
min1=current_config.getboolean('preload', 'min', fallback=False),
|
|
216
|
+
min5=current_config.getboolean('preload', 'min5', fallback=False),
|
|
217
|
+
min15=current_config.getboolean('preload', 'min15', fallback=False),
|
|
218
|
+
min30=current_config.getboolean('preload', 'min30', fallback=False),
|
|
219
|
+
min60=current_config.getboolean('preload', 'min60', fallback=False),
|
|
220
|
+
hour2=current_config.getboolean('preload', 'hour2', fallback=False),
|
|
221
|
+
day_max=current_config.getint('preload', 'day_max', fallback=100000),
|
|
222
|
+
week_max=current_config.getint('preload', 'week_max', fallback=100000),
|
|
223
|
+
month_max=current_config.getint('preload', 'month_max', fallback=100000),
|
|
224
|
+
quarter_max=current_config.getint('preload', 'quarter_max', fallback=100000),
|
|
225
|
+
halfyear_max=current_config.getint('preload', 'halfyear_max', fallback=100000),
|
|
226
|
+
year_max=current_config.getint('preload', 'year_max', fallback=100000),
|
|
227
|
+
min1_max=current_config.getint('preload', 'min_max', fallback=4096),
|
|
228
|
+
min5_max=current_config.getint('preload', 'min5_max', fallback=4096),
|
|
229
|
+
min15_max=current_config.getint('preload', 'min15_max', fallback=4096),
|
|
230
|
+
min30_max=current_config.getint('preload', 'min30_max', fallback=4096),
|
|
231
|
+
min60_max=current_config.getint('preload', 'min60_max', fallback=4096),
|
|
232
|
+
hour2_max=current_config.getint('preload', 'hour2_max', fallback=4096),
|
|
233
|
+
)
|
|
234
|
+
)
|
|
190
235
|
|
|
191
236
|
try:
|
|
192
237
|
if not data_dir and not os.path.lexists(data_dir):
|
|
@@ -282,14 +327,15 @@ class MyMainWindow(QMainWindow, Ui_MainWindow):
|
|
|
282
327
|
sys.stderr = self._stream
|
|
283
328
|
self.log_textEdit.document().setMaximumBlockCount(1000)
|
|
284
329
|
|
|
330
|
+
self.tabWidget.setCurrentIndex(0)
|
|
331
|
+
|
|
285
332
|
current_dir = os.path.dirname(__file__)
|
|
286
333
|
icon = QIcon(f"{current_dir}/images/hikyuu_small.png")
|
|
287
334
|
star_img = QPixmap(f"{current_dir}/images/star.png")
|
|
288
335
|
self.label_44.setPixmap(star_img)
|
|
289
336
|
self.label_46.setOpenExternalLinks(True)
|
|
290
337
|
self.label_license.setText(view_license())
|
|
291
|
-
|
|
292
|
-
self.fetch_trial_pushButton.setEnabled(False)
|
|
338
|
+
self.fetch_trial_pushButton.setEnabled(not is_valid_license())
|
|
293
339
|
|
|
294
340
|
self.setWindowIcon(icon)
|
|
295
341
|
QApplication.instance().setWindowIcon(icon)
|
|
@@ -383,6 +429,30 @@ class MyMainWindow(QMainWindow, Ui_MainWindow):
|
|
|
383
429
|
self.mysql_pwd_lineEdit.setEnabled(mysql_enable)
|
|
384
430
|
self.mysql_test_pushButton.setEnabled(mysql_enable)
|
|
385
431
|
|
|
432
|
+
# 初始化clickhouse设置
|
|
433
|
+
clickhouse_enable = import_config.getboolean('clickhouse', 'enable', fallback=False)
|
|
434
|
+
if (not is_valid_license()) or hdf5_enable or mysql_enable:
|
|
435
|
+
clickhouse_enable = False
|
|
436
|
+
self.enable_clickhouse_radioButton.setChecked(clickhouse_enable)
|
|
437
|
+
self.clickhouse_tmpdir_lineEdit.setText(import_config.get('clickhouse', 'tmpdir', fallback='d:/stock'))
|
|
438
|
+
self.clickhouse_tmpdir_pushButton.setEnabled(clickhouse_enable)
|
|
439
|
+
clickhouse_ip = import_config.get('clickhouse', 'host', fallback='127.0.0.1')
|
|
440
|
+
self.clickhouse_ip_lineEdit.setText(clickhouse_ip)
|
|
441
|
+
self.clickhouse_ip_lineEdit.setEnabled(clickhouse_enable)
|
|
442
|
+
clickhouse_port = import_config.get('clickhouse', 'port', fallback='9000')
|
|
443
|
+
self.clickhouse_port_lineEdit.setText(clickhouse_port)
|
|
444
|
+
self.clickhouse_port_lineEdit.setEnabled(clickhouse_enable)
|
|
445
|
+
clickhouse_http_port = import_config.get('clickhouse', 'http_port', fallback='8123')
|
|
446
|
+
self.clickhouse_http_port_lineEdit.setText(clickhouse_http_port)
|
|
447
|
+
self.clickhouse_http_port_lineEdit.setEnabled(clickhouse_enable)
|
|
448
|
+
clickhouse_usr = import_config.get('clickhouse', 'usr', fallback='default')
|
|
449
|
+
self.clickhouse_usr_lineEdit.setText(clickhouse_usr)
|
|
450
|
+
self.clickhouse_usr_lineEdit.setEnabled(clickhouse_enable)
|
|
451
|
+
clickhouse_pwd = import_config.get('clickhouse', 'pwd', fallback='test')
|
|
452
|
+
self.clickhouse_pwd_lineEdit.setText(clickhouse_pwd)
|
|
453
|
+
self.clickhouse_pwd_lineEdit.setEnabled(clickhouse_enable)
|
|
454
|
+
self.clickhouse_test_pushButton.setEnabled(clickhouse_enable)
|
|
455
|
+
|
|
386
456
|
self.sched_import_timeEdit.setTime(
|
|
387
457
|
datetime.time.fromisoformat(import_config.get('schec', 'time', fallback='18:00'))
|
|
388
458
|
)
|
|
@@ -484,6 +554,15 @@ class MyMainWindow(QMainWindow, Ui_MainWindow):
|
|
|
484
554
|
'usr': self.mysql_usr_lineEdit.text(),
|
|
485
555
|
'pwd': self.mysql_pwd_lineEdit.text()
|
|
486
556
|
}
|
|
557
|
+
import_config['clickhouse'] = {
|
|
558
|
+
'enable': is_valid_license() and self.enable_clickhouse_radioButton.isChecked(),
|
|
559
|
+
'tmpdir': self.clickhouse_tmpdir_lineEdit.text(),
|
|
560
|
+
'host': self.clickhouse_ip_lineEdit.text(),
|
|
561
|
+
'http_port': self.clickhouse_http_port_lineEdit.text(),
|
|
562
|
+
'port': self.clickhouse_port_lineEdit.text(),
|
|
563
|
+
'usr': self.clickhouse_usr_lineEdit.text(),
|
|
564
|
+
'pwd': self.clickhouse_pwd_lineEdit.text()
|
|
565
|
+
}
|
|
487
566
|
import_config['sched'] = {
|
|
488
567
|
'time': self.sched_import_timeEdit.time().toString(),
|
|
489
568
|
}
|
|
@@ -545,8 +624,7 @@ class MyMainWindow(QMainWindow, Ui_MainWindow):
|
|
|
545
624
|
info = fetch_trial_license(email)
|
|
546
625
|
QMessageBox.about(self, "获取试用许可", info)
|
|
547
626
|
self.label_license.setText(view_license())
|
|
548
|
-
|
|
549
|
-
self.fetch_trial_pushButton.setEnabled(False)
|
|
627
|
+
self.fetch_trial_pushButton.setEnabled(not is_valid_license())
|
|
550
628
|
|
|
551
629
|
@pyqtSlot()
|
|
552
630
|
def on_pytdx_radioButton_clicked(self):
|
|
@@ -621,15 +699,24 @@ class MyMainWindow(QMainWindow, Ui_MainWindow):
|
|
|
621
699
|
def on_enable_hdf55_radioButton_clicked(self):
|
|
622
700
|
if self.enable_hdf55_radioButton.isChecked():
|
|
623
701
|
self.enable_mysql_radioButton.setChecked(False)
|
|
624
|
-
|
|
702
|
+
self.enable_clickhouse_radioButton.setChecked(False)
|
|
703
|
+
self.on_enable_database_toggled(hdf5=True, mysql=False, clickhouse=False)
|
|
625
704
|
|
|
626
705
|
@pyqtSlot()
|
|
627
706
|
def on_enable_mysql_radioButton_clicked(self):
|
|
628
707
|
if self.enable_mysql_radioButton.isChecked():
|
|
629
708
|
self.enable_hdf55_radioButton.setChecked(False)
|
|
630
|
-
|
|
709
|
+
self.enable_clickhouse_radioButton.setChecked(False)
|
|
710
|
+
self.on_enable_database_toggled(hdf5=False, mysql=True, clickhouse=False)
|
|
631
711
|
|
|
632
|
-
|
|
712
|
+
@pyqtSlot()
|
|
713
|
+
def on_enable_clickhouse_radioButton_clicked(self):
|
|
714
|
+
if self.enable_clickhouse_radioButton.isChecked():
|
|
715
|
+
self.enable_hdf55_radioButton.setChecked(False)
|
|
716
|
+
self.enable_mysql_radioButton.setChecked(False)
|
|
717
|
+
self.on_enable_database_toggled(hdf5=False, mysql=False, clickhouse=True)
|
|
718
|
+
|
|
719
|
+
def on_enable_database_toggled(self, hdf5, mysql, clickhouse):
|
|
633
720
|
self.hdf5_dir_lineEdit.setEnabled(hdf5)
|
|
634
721
|
self.mysql_ip_lineEdit.setEnabled(mysql)
|
|
635
722
|
self.mysql_port_lineEdit.setEnabled(mysql)
|
|
@@ -637,6 +724,13 @@ class MyMainWindow(QMainWindow, Ui_MainWindow):
|
|
|
637
724
|
self.mysql_pwd_lineEdit.setEnabled(mysql)
|
|
638
725
|
self.mysql_test_pushButton.setEnabled(mysql)
|
|
639
726
|
self.mysql_tmpdir_pushButton.setEnabled(mysql)
|
|
727
|
+
self.clickhouse_ip_lineEdit.setEnabled(clickhouse)
|
|
728
|
+
self.clickhouse_http_port_lineEdit.setEnabled(clickhouse)
|
|
729
|
+
self.clickhouse_port_lineEdit.setEnabled(clickhouse)
|
|
730
|
+
self.clickhouse_usr_lineEdit.setEnabled(clickhouse)
|
|
731
|
+
self.clickhouse_pwd_lineEdit.setEnabled(clickhouse)
|
|
732
|
+
self.clickhouse_test_pushButton.setEnabled(clickhouse)
|
|
733
|
+
self.clickhouse_tmpdir_pushButton.setEnabled(clickhouse)
|
|
640
734
|
|
|
641
735
|
@pyqtSlot()
|
|
642
736
|
def on_mysql_tmpdir_pushButton_clicked(self):
|
|
@@ -648,6 +742,20 @@ class MyMainWindow(QMainWindow, Ui_MainWindow):
|
|
|
648
742
|
dirname = dlg.selectedFiles()
|
|
649
743
|
self.mysql_tmpdir_lineEdit.setText(dirname[0])
|
|
650
744
|
|
|
745
|
+
@pyqtSlot()
|
|
746
|
+
def on_clickhouse_tmpdir_pushButton_clicked(self):
|
|
747
|
+
if not is_valid_license():
|
|
748
|
+
QMessageBox.critical(self, "clickhouse引擎", "需要捐赠授权才能使用clickhouse引擎")
|
|
749
|
+
return
|
|
750
|
+
|
|
751
|
+
dlg = QFileDialog()
|
|
752
|
+
dlg.setFileMode(QFileDialog.Directory)
|
|
753
|
+
config = self.getCurrentConfig()
|
|
754
|
+
dlg.setDirectory(config['clickhouse']['tmpdir'])
|
|
755
|
+
if dlg.exec_():
|
|
756
|
+
dirname = dlg.selectedFiles()
|
|
757
|
+
self.clickhouse_tmpdir_lineEdit.setText(dirname[0])
|
|
758
|
+
|
|
651
759
|
@pyqtSlot()
|
|
652
760
|
def on_mysql_test_pushButton_clicked(self):
|
|
653
761
|
"""测试数据库连接"""
|
|
@@ -672,6 +780,25 @@ class MyMainWindow(QMainWindow, Ui_MainWindow):
|
|
|
672
780
|
|
|
673
781
|
QMessageBox.about(self, "测试数据库连接", " 连接成功!")
|
|
674
782
|
|
|
783
|
+
@pyqtSlot()
|
|
784
|
+
def on_clickhouse_test_pushButton_clicked(self):
|
|
785
|
+
"""测试数据库连接"""
|
|
786
|
+
db_config = {
|
|
787
|
+
'username': self.clickhouse_usr_lineEdit.text(),
|
|
788
|
+
'password': self.clickhouse_pwd_lineEdit.text(),
|
|
789
|
+
'host': self.clickhouse_ip_lineEdit.text(),
|
|
790
|
+
'port': self.clickhouse_http_port_lineEdit.text()
|
|
791
|
+
}
|
|
792
|
+
|
|
793
|
+
try:
|
|
794
|
+
cnx = clickhouse_connect.get_client(**db_config)
|
|
795
|
+
cnx.close()
|
|
796
|
+
except Exception as err:
|
|
797
|
+
QMessageBox.critical(self, "测试数据库连接失败", str(err))
|
|
798
|
+
return
|
|
799
|
+
|
|
800
|
+
QMessageBox.about(self, "测试数据库连接", " 连接成功!")
|
|
801
|
+
|
|
675
802
|
def reset_progress_bar(self):
|
|
676
803
|
self.hdf5_weight_label.setText('')
|
|
677
804
|
self.hdf5_day_progressBar.setValue(0)
|
|
@@ -9,6 +9,7 @@ import mysql.connector
|
|
|
9
9
|
from hikyuu.data.common import MARKET, get_stk_code_name_list
|
|
10
10
|
from hikyuu.data.em_block_to_mysql import em_import_block_to_mysql
|
|
11
11
|
from hikyuu.data.em_block_to_sqlite import em_import_block_to_sqlite
|
|
12
|
+
from hikyuu.data.em_block_to_clickhouse import em_import_block_to_clickhouse
|
|
12
13
|
from hikyuu.util import *
|
|
13
14
|
|
|
14
15
|
|
|
@@ -38,6 +39,16 @@ class ImportBlockInfoTask:
|
|
|
38
39
|
}
|
|
39
40
|
connect = mysql.connector.connect(**db_config)
|
|
40
41
|
import_block = em_import_block_to_mysql
|
|
42
|
+
elif self.config.getboolean('clickhouse', 'enable', fallback=True):
|
|
43
|
+
db_config = {
|
|
44
|
+
'username': self.config['clickhouse']['usr'],
|
|
45
|
+
'password': self.config['clickhouse']['pwd'],
|
|
46
|
+
'host': self.config['clickhouse']['host'],
|
|
47
|
+
'port': self.config['clickhouse']['http_port']
|
|
48
|
+
}
|
|
49
|
+
import clickhouse_connect
|
|
50
|
+
connect = clickhouse_connect.get_client(**db_config)
|
|
51
|
+
import_block = em_import_block_to_clickhouse
|
|
41
52
|
|
|
42
53
|
count = 0
|
|
43
54
|
try:
|
|
@@ -27,9 +27,11 @@ import shutil
|
|
|
27
27
|
import hashlib
|
|
28
28
|
import sqlite3
|
|
29
29
|
import mysql.connector
|
|
30
|
+
import clickhouse_connect
|
|
30
31
|
from pytdx.hq import TdxHq_API
|
|
31
32
|
from hikyuu.data.pytdx_finance_to_mysql import history_finance_import_mysql
|
|
32
33
|
from hikyuu.data.pytdx_finance_to_sqlite import history_finance_import_sqlite
|
|
34
|
+
from hikyuu.data.pytdx_finance_to_clickhouse import history_finance_import_clickhouse
|
|
33
35
|
from hikyuu.util import *
|
|
34
36
|
|
|
35
37
|
|
|
@@ -77,6 +79,16 @@ class ImportHistoryFinanceTask:
|
|
|
77
79
|
self.db_connect = mysql.connector.connect(**db_config)
|
|
78
80
|
self.history_finance_import = history_finance_import_mysql
|
|
79
81
|
self.engine = 'mysql'
|
|
82
|
+
elif self.config.getboolean('clickhouse', 'enable', fallback=True):
|
|
83
|
+
db_config = {
|
|
84
|
+
'username': self.config['clickhouse']['usr'],
|
|
85
|
+
'password': self.config['clickhouse']['pwd'],
|
|
86
|
+
'host': self.config['clickhouse']['host'],
|
|
87
|
+
'port': self.config['clickhouse']['http_port']
|
|
88
|
+
}
|
|
89
|
+
self.db_connect = clickhouse_connect.get_client(**db_config)
|
|
90
|
+
self.history_finance_import = history_finance_import_clickhouse
|
|
91
|
+
self.engine = 'clickhouse'
|
|
80
92
|
|
|
81
93
|
def import_to_db(self, filename):
|
|
82
94
|
try:
|
|
@@ -129,6 +141,8 @@ class ImportHistoryFinanceTask:
|
|
|
129
141
|
self.queue.put([self.task_name, None, None, int(100 * count / self.total_count), self.total_count])
|
|
130
142
|
except Exception as e:
|
|
131
143
|
hku_error(str(e))
|
|
144
|
+
if self.engine == 'clickhouse':
|
|
145
|
+
hku_run_ignore_exception(self.db_connect.command, "OPTIMIZE TABLE hku_base.historyfinance FINAL")
|
|
132
146
|
self.db_connect.close()
|
|
133
147
|
self.api.disconnect()
|
|
134
148
|
|
|
@@ -142,6 +156,6 @@ if __name__ == "__main__":
|
|
|
142
156
|
this_dir = os.path.expanduser('~') + '/.hikyuu'
|
|
143
157
|
import_config = ConfigParser()
|
|
144
158
|
import_config.read(this_dir + '/importdata-gui.ini', encoding='utf-8')
|
|
145
|
-
task = ImportHistoryFinanceTask(None, None,
|
|
159
|
+
task = ImportHistoryFinanceTask(None, None, import_config, "/Users/fasiondog/stock")
|
|
146
160
|
task()
|
|
147
161
|
print("over!")
|
|
@@ -25,9 +25,11 @@
|
|
|
25
25
|
import logging
|
|
26
26
|
import sqlite3
|
|
27
27
|
import mysql.connector
|
|
28
|
+
import clickhouse_connect
|
|
28
29
|
from pytdx.hq import TdxHq_API
|
|
29
30
|
from hikyuu.data.pytdx_to_h5 import import_time as h5_import_time
|
|
30
31
|
from hikyuu.data.pytdx_to_mysql import import_time as mysql_import_time
|
|
32
|
+
from hikyuu.data.pytdx_to_clickhouse import import_time as clickhouse_import_time
|
|
31
33
|
from hikyuu.util import *
|
|
32
34
|
|
|
33
35
|
|
|
@@ -73,6 +75,15 @@ class ImportPytdxTimeToH5:
|
|
|
73
75
|
}
|
|
74
76
|
connect = mysql.connector.connect(**db_config)
|
|
75
77
|
import_time = mysql_import_time
|
|
78
|
+
elif self.config.getboolean('clickhouse', 'enable', fallback=True):
|
|
79
|
+
db_config = {
|
|
80
|
+
'username': self.config['clickhouse']['usr'],
|
|
81
|
+
'password': self.config['clickhouse']['pwd'],
|
|
82
|
+
'host': self.config['clickhouse']['host'],
|
|
83
|
+
'port': self.config['clickhouse']['http_port']
|
|
84
|
+
}
|
|
85
|
+
connect = clickhouse_connect.get_client(**db_config)
|
|
86
|
+
import_time = clickhouse_import_time
|
|
76
87
|
|
|
77
88
|
count = 0
|
|
78
89
|
try:
|
|
@@ -89,7 +100,6 @@ class ImportPytdxTimeToH5:
|
|
|
89
100
|
self.logger.error(e)
|
|
90
101
|
finally:
|
|
91
102
|
api.close()
|
|
92
|
-
connect.commit()
|
|
93
103
|
connect.close()
|
|
94
104
|
|
|
95
105
|
self.queue.put([self.task_name, self.market, 'TIME', None, count])
|
|
@@ -28,6 +28,7 @@ import mysql.connector
|
|
|
28
28
|
from pytdx.hq import TdxHq_API
|
|
29
29
|
from hikyuu.data.pytdx_to_h5 import import_data as h5_import_data
|
|
30
30
|
from hikyuu.data.pytdx_to_mysql import import_data as mysql_import_data
|
|
31
|
+
from hikyuu.data.pytdx_to_clickhouse import import_data as clickhouse_import_data
|
|
31
32
|
from hikyuu.util import *
|
|
32
33
|
|
|
33
34
|
|
|
@@ -76,6 +77,18 @@ class ImportPytdxToH5:
|
|
|
76
77
|
connect = mysql.connector.connect(**db_config)
|
|
77
78
|
import_data = mysql_import_data
|
|
78
79
|
self.logger.debug('use mysql import kdata')
|
|
80
|
+
elif self.config.getboolean('clickhouse', 'enable', fallback=True):
|
|
81
|
+
db_config = {
|
|
82
|
+
'username': self.config['clickhouse']['usr'],
|
|
83
|
+
'password': self.config['clickhouse']['pwd'],
|
|
84
|
+
'host': self.config['clickhouse']['host'],
|
|
85
|
+
'port': int(self.config['clickhouse']['http_port']),
|
|
86
|
+
'send_receive_timeout': 60,
|
|
87
|
+
}
|
|
88
|
+
import clickhouse_connect
|
|
89
|
+
connect = clickhouse_connect.get_client(**db_config)
|
|
90
|
+
import_data = clickhouse_import_data
|
|
91
|
+
self.logger.debug('use clickhouse import kdata')
|
|
79
92
|
|
|
80
93
|
count = 0
|
|
81
94
|
try:
|
|
@@ -93,7 +106,6 @@ class ImportPytdxToH5:
|
|
|
93
106
|
# self.queue.put([self.task_name, self.market, self.ktype, str(e), count])
|
|
94
107
|
finally:
|
|
95
108
|
api.close()
|
|
96
|
-
connect.commit()
|
|
97
109
|
connect.close()
|
|
98
110
|
|
|
99
111
|
self.queue.put([self.task_name, self.market, self.ktype, None, count])
|
|
@@ -28,6 +28,7 @@ import mysql.connector
|
|
|
28
28
|
from pytdx.hq import TdxHq_API
|
|
29
29
|
from hikyuu.data.pytdx_to_h5 import import_trans as h5_import_trans
|
|
30
30
|
from hikyuu.data.pytdx_to_mysql import import_trans as mysql_import_trans
|
|
31
|
+
from hikyuu.data.pytdx_to_clickhouse import import_trans as clickhouse_import_trans
|
|
31
32
|
from hikyuu.util import *
|
|
32
33
|
|
|
33
34
|
|
|
@@ -73,6 +74,16 @@ class ImportPytdxTransToH5:
|
|
|
73
74
|
}
|
|
74
75
|
connect = mysql.connector.connect(**db_config)
|
|
75
76
|
import_trans = mysql_import_trans
|
|
77
|
+
elif self.config.getboolean('clickhouse', 'enable', fallback=True):
|
|
78
|
+
db_config = {
|
|
79
|
+
'username': self.config['clickhouse']['usr'],
|
|
80
|
+
'password': self.config['clickhouse']['pwd'],
|
|
81
|
+
'host': self.config['clickhouse']['host'],
|
|
82
|
+
'port': self.config['clickhouse']['http_port']
|
|
83
|
+
}
|
|
84
|
+
import clickhouse_connect
|
|
85
|
+
connect = clickhouse_connect.get_client(**db_config)
|
|
86
|
+
import_trans = clickhouse_import_trans
|
|
76
87
|
|
|
77
88
|
count = 0
|
|
78
89
|
try:
|
|
@@ -89,7 +100,6 @@ class ImportPytdxTransToH5:
|
|
|
89
100
|
self.logger.error(e)
|
|
90
101
|
finally:
|
|
91
102
|
api.close()
|
|
92
|
-
connect.commit()
|
|
93
103
|
connect.close()
|
|
94
104
|
|
|
95
105
|
self.queue.put([self.task_name, self.market, 'TRANS', None, count])
|
|
@@ -30,6 +30,7 @@ from hikyuu.util.check import hku_catch
|
|
|
30
30
|
from hikyuu.util.mylog import class_logger
|
|
31
31
|
from hikyuu.data.tdx_to_h5 import tdx_import_data as h5_import_data
|
|
32
32
|
from hikyuu.data.tdx_to_mysql import tdx_import_data as mysql_import_data
|
|
33
|
+
from hikyuu.data.tdx_to_clickhouse import tdx_import_data as clickhouse_import_data
|
|
33
34
|
from hikyuu.util import capture_multiprocess_all_logger, get_default_logger
|
|
34
35
|
|
|
35
36
|
|
|
@@ -91,7 +92,7 @@ class ImportTdxToH5Task:
|
|
|
91
92
|
import_data = h5_import_data
|
|
92
93
|
self.logger.debug('use hdf5 import kdata')
|
|
93
94
|
use_hdf = True
|
|
94
|
-
|
|
95
|
+
elif self.config.getboolean('mysql', 'enable', fallback=True):
|
|
95
96
|
db_config = {
|
|
96
97
|
'user': self.config['mysql']['usr'],
|
|
97
98
|
'password': self.config['mysql']['pwd'],
|
|
@@ -101,6 +102,17 @@ class ImportTdxToH5Task:
|
|
|
101
102
|
connect = mysql.connector.connect(**db_config)
|
|
102
103
|
import_data = mysql_import_data
|
|
103
104
|
self.logger.debug('use mysql import kdata')
|
|
105
|
+
elif self.config.getboolean('clickhouse', 'enable', fallback=True):
|
|
106
|
+
db_config = {
|
|
107
|
+
'username': self.config['clickhouse']['usr'],
|
|
108
|
+
'password': self.config['clickhouse']['pwd'],
|
|
109
|
+
'host': self.config['clickhouse']['host'],
|
|
110
|
+
'port': self.config['clickhouse']['http_port']
|
|
111
|
+
}
|
|
112
|
+
import clickhouse_connect
|
|
113
|
+
connect = clickhouse_connect.get_client(**db_config)
|
|
114
|
+
import_data = clickhouse_import_data
|
|
115
|
+
self.logger.debug('use clickhouse import kdata')
|
|
104
116
|
|
|
105
117
|
count = 0
|
|
106
118
|
try:
|
|
@@ -28,6 +28,7 @@ import hashlib
|
|
|
28
28
|
import sqlite3
|
|
29
29
|
import urllib.request
|
|
30
30
|
import mysql.connector
|
|
31
|
+
import clickhouse_connect
|
|
31
32
|
|
|
32
33
|
from pytdx.hq import TdxHq_API
|
|
33
34
|
from hikyuu.data.common import MARKET, g_market_list
|
|
@@ -37,6 +38,8 @@ from hikyuu.data.pytdx_weight_to_sqlite import pytdx_import_weight_to_sqlite
|
|
|
37
38
|
from hikyuu.data.pytdx_weight_to_mysql import pytdx_import_weight_to_mysql
|
|
38
39
|
from hikyuu.data.pytdx_finance_to_sqlite import pytdx_import_finance_to_sqlite
|
|
39
40
|
from hikyuu.data.pytdx_finance_to_mysql import pytdx_import_finance_to_mysql
|
|
41
|
+
from hikyuu.data.pytdx_finance_to_clickhouse import pytdx_import_finance_to_clickhouse
|
|
42
|
+
from hikyuu.data.pytdx_weight_to_clickhouse import pytdx_import_weight_to_clickhouse
|
|
40
43
|
from hikyuu.util import capture_multiprocess_all_logger, get_default_logger
|
|
41
44
|
from hikyuu.util.check import hku_catch, hku_check
|
|
42
45
|
|
|
@@ -78,6 +81,17 @@ class ImportWeightToSqliteTask:
|
|
|
78
81
|
pytdx_import_weight = pytdx_import_weight_to_mysql
|
|
79
82
|
pytdx_import_finance = pytdx_import_finance_to_mysql
|
|
80
83
|
self.logger.debug('use mysql import weight')
|
|
84
|
+
elif self.config.getboolean('clickhouse', 'enable', fallback=True):
|
|
85
|
+
db_config = {
|
|
86
|
+
'username': self.config['clickhouse']['usr'],
|
|
87
|
+
'password': self.config['clickhouse']['pwd'],
|
|
88
|
+
'host': self.config['clickhouse']['host'],
|
|
89
|
+
'port': self.config['clickhouse']['http_port']
|
|
90
|
+
}
|
|
91
|
+
connect = clickhouse_connect.get_client(**db_config)
|
|
92
|
+
pytdx_import_weight = pytdx_import_weight_to_clickhouse
|
|
93
|
+
pytdx_import_finance = pytdx_import_finance_to_clickhouse
|
|
94
|
+
self.logger.debug('use clickhouse import weight')
|
|
81
95
|
|
|
82
96
|
except Exception as e:
|
|
83
97
|
# self.queue.put([self.msg_name, str(e), -1, 0, total_count])
|
|
@@ -108,7 +122,6 @@ class ImportWeightToSqliteTask:
|
|
|
108
122
|
self.queue.put([self.msg_name, 'INFO', str(e), 0, 0])
|
|
109
123
|
finally:
|
|
110
124
|
api.close()
|
|
111
|
-
connect.commit()
|
|
112
125
|
connect.close()
|
|
113
126
|
|
|
114
127
|
self.queue.put([self.msg_name, '', 0, None, total_count])
|
|
@@ -6,8 +6,10 @@
|
|
|
6
6
|
|
|
7
7
|
import sqlite3
|
|
8
8
|
import mysql.connector
|
|
9
|
+
import clickhouse_connect
|
|
9
10
|
from hikyuu.data.zh_bond10_to_mysql import import_zh_bond10_to_mysql
|
|
10
11
|
from hikyuu.data.zh_bond10_to_sqlite import import_zh_bond10_to_sqlite
|
|
12
|
+
from hikyuu.data.zh_bond10_to_clickhouse import import_zh_bond10_to_clickhouse
|
|
11
13
|
from hikyuu.util import *
|
|
12
14
|
|
|
13
15
|
|
|
@@ -36,6 +38,15 @@ class ImportZhBond10Task:
|
|
|
36
38
|
}
|
|
37
39
|
connect = mysql.connector.connect(**db_config)
|
|
38
40
|
import_zh_bond10 = import_zh_bond10_to_mysql
|
|
41
|
+
elif self.config.getboolean('clickhouse', 'enable', fallback=True):
|
|
42
|
+
db_config = {
|
|
43
|
+
'username': self.config['clickhouse']['usr'],
|
|
44
|
+
'password': self.config['clickhouse']['pwd'],
|
|
45
|
+
'host': self.config['clickhouse']['host'],
|
|
46
|
+
'port': self.config['clickhouse']['http_port']
|
|
47
|
+
}
|
|
48
|
+
connect = clickhouse_connect.get_client(**db_config)
|
|
49
|
+
import_zh_bond10 = import_zh_bond10_to_clickhouse
|
|
39
50
|
|
|
40
51
|
try:
|
|
41
52
|
import_zh_bond10(connect)
|