From e7bc50b6cab410dbb38b03b58aabd41787a48f61 Mon Sep 17 00:00:00 2001 From: fasiondog Date: Tue, 13 Nov 2018 23:32:44 +0800 Subject: [PATCH] data tool(continue) --- hikyuu_python/tools/maintain/MainWindow.py | 9 ++------- hikyuu_python/tools/maintain/MainWindow.ui | 14 ++------------ hikyuu_python/tools/maintain/hku_config.py | 6 ++---- hikyuu_python/tools/maintain/pytdx_to_h5.py | 12 +++++++++--- hikyuu_python/tools/maintain/sqlite3_common.py | 2 +- 5 files changed, 16 insertions(+), 27 deletions(-) diff --git a/hikyuu_python/tools/maintain/MainWindow.py b/hikyuu_python/tools/maintain/MainWindow.py index dc7e6d18..4992824c 100644 --- a/hikyuu_python/tools/maintain/MainWindow.py +++ b/hikyuu_python/tools/maintain/MainWindow.py @@ -205,7 +205,7 @@ class Ui_MainWindow(object): self.groupBox_7.setGeometry(QtCore.QRect(10, 20, 511, 91)) self.groupBox_7.setObjectName("groupBox_7") self.layoutWidget5 = QtWidgets.QWidget(self.groupBox_7) - self.layoutWidget5.setGeometry(QtCore.QRect(20, 30, 208, 18)) + self.layoutWidget5.setGeometry(QtCore.QRect(20, 30, 141, 18)) self.layoutWidget5.setObjectName("layoutWidget5") self.horizontalLayout_3 = QtWidgets.QHBoxLayout(self.layoutWidget5) self.horizontalLayout_3.setContentsMargins(0, 0, 0, 0) @@ -216,10 +216,6 @@ class Ui_MainWindow(object): self.import_fund_checkBox = QtWidgets.QCheckBox(self.layoutWidget5) self.import_fund_checkBox.setObjectName("import_fund_checkBox") self.horizontalLayout_3.addWidget(self.import_fund_checkBox) - self.import_bond_checkBox = QtWidgets.QCheckBox(self.layoutWidget5) - self.import_bond_checkBox.setEnabled(False) - self.import_bond_checkBox.setObjectName("import_bond_checkBox") - self.horizontalLayout_3.addWidget(self.import_bond_checkBox) self.import_future_checkBox = QtWidgets.QCheckBox(self.layoutWidget5) self.import_future_checkBox.setEnabled(False) self.import_future_checkBox.setObjectName("import_future_checkBox") @@ -248,7 +244,7 @@ class Ui_MainWindow(object): self.import_min_time_checkBox.setObjectName("import_min_time_checkBox") self.horizontalLayout_2.addWidget(self.import_min_time_checkBox) self.import_weight_checkBox = QtWidgets.QCheckBox(self.groupBox_7) - self.import_weight_checkBox.setGeometry(QtCore.QRect(250, 30, 151, 16)) + self.import_weight_checkBox.setGeometry(QtCore.QRect(200, 30, 151, 16)) self.import_weight_checkBox.setObjectName("import_weight_checkBox") self.import_status_label = QtWidgets.QLabel(self.tab) self.import_status_label.setGeometry(QtCore.QRect(650, 30, 361, 21)) @@ -307,7 +303,6 @@ class Ui_MainWindow(object): self.groupBox_7.setTitle(_translate("MainWindow", "导入设置")) self.import_stock_checkBox.setText(_translate("MainWindow", "股票")) self.import_fund_checkBox.setText(_translate("MainWindow", "基金")) - self.import_bond_checkBox.setText(_translate("MainWindow", "债券")) self.import_future_checkBox.setText(_translate("MainWindow", "期货")) self.import_day_checkBox.setText(_translate("MainWindow", "日线")) self.import_min_checkBox.setText(_translate("MainWindow", "1分钟线")) diff --git a/hikyuu_python/tools/maintain/MainWindow.ui b/hikyuu_python/tools/maintain/MainWindow.ui index a00b6484..566e3dde 100644 --- a/hikyuu_python/tools/maintain/MainWindow.ui +++ b/hikyuu_python/tools/maintain/MainWindow.ui @@ -490,7 +490,7 @@ p, li { white-space: pre-wrap; } 20 30 - 208 + 141 18 @@ -509,16 +509,6 @@ p, li { white-space: pre-wrap; } - - - - false - - - 债券 - - - @@ -587,7 +577,7 @@ p, li { white-space: pre-wrap; } - 250 + 200 30 151 16 diff --git a/hikyuu_python/tools/maintain/hku_config.py b/hikyuu_python/tools/maintain/hku_config.py index 83dc6dd8..f5a66492 100644 --- a/hikyuu_python/tools/maintain/hku_config.py +++ b/hikyuu_python/tools/maintain/hku_config.py @@ -45,7 +45,7 @@ class MyMainWindow(QMainWindow, Ui_MainWindow): self.reset_progress_bar() #读取保存的配置文件信息,如果不存在,则使用默认配置 - this_dir = os.getcwd() + this_dir = os.path.dirname(__file__) import_config = ConfigParser() if os.path.exists(this_dir + '/importdata.ini'): import_config.read(this_dir + '/importdata.ini') @@ -53,7 +53,6 @@ class MyMainWindow(QMainWindow, Ui_MainWindow): #初始化导入行情数据类型配置 self.import_stock_checkBox.setChecked(import_config.getboolean('quotation', 'stock', fallback=True)) self.import_fund_checkBox.setChecked(import_config.getboolean('quotation', 'fund', fallback=True)) - self.import_bond_checkBox.setChecked(import_config.getboolean('quotation', 'bond', fallback=False)) self.import_future_checkBox.setChecked(import_config.getboolean('quotation', 'future', fallback=False)) #初始化导入K线类型配置 @@ -111,7 +110,6 @@ class MyMainWindow(QMainWindow, Ui_MainWindow): import_config = ConfigParser() import_config['quotation'] = {'stock': self.import_stock_checkBox.isChecked(), 'fund': self.import_fund_checkBox.isChecked(), - 'bond': self.import_bond_checkBox.isChecked(), 'future': self.import_future_checkBox.isChecked()} import_config['ktype'] = {'day': self.import_day_checkBox.isChecked(), 'min': self.import_min_checkBox.isChecked(), @@ -134,7 +132,7 @@ class MyMainWindow(QMainWindow, Ui_MainWindow): return import_config def saveConfig(self): - filename = os.getcwd() + '/importdata.ini' + filename = os.path.dirname(__file__) + '/importdata.ini' with open(filename, 'w') as f: self.getCurrentConfig().write(f) diff --git a/hikyuu_python/tools/maintain/pytdx_to_h5.py b/hikyuu_python/tools/maintain/pytdx_to_h5.py index 2ab96b89..dfc2330e 100644 --- a/hikyuu_python/tools/maintain/pytdx_to_h5.py +++ b/hikyuu_python/tools/maintain/pytdx_to_h5.py @@ -309,19 +309,25 @@ if __name__ == '__main__': api.connect(tdx_server, tdx_port) print("导入股票代码表") - import_stock_name(connect, api, 'SH', quotations) - import_stock_name(connect, api, 'SZ', quotations) + #import_stock_name(connect, api, 'SH', quotations) + #import_stock_name(connect, api, 'SZ', quotations) add_count = 0 print("\n导入上证日线数据") - add_count = import_data(connect, 'SH', 'DAY', ['bond'], api, dest_dir, progress=ProgressBar) + #add_count = import_data(connect, 'SH', 'DAY', ['bond'], api, dest_dir, progress=ProgressBar) print("\n导入数量:", add_count) print("\n导入深证日线数据") #add_count = import_data(connect, 'SZ', 'DAY', ['stock'], api, dest_dir, progress=ProgressBar) print("\n导入数量:", add_count) + for i in range(10): + x = api.get_history_transaction_data(TDXParams.MARKET_SZ, '000001', (9-i)*2000, 2000, 20181112) + #x = api.get_transaction_data(TDXParams.MARKET_SZ, '000001', (9-i)*800, 800) + if x is not None and len(x) > 0: + print(i, len(x), x[0], x[-1]) + api.disconnect() diff --git a/hikyuu_python/tools/maintain/sqlite3_common.py b/hikyuu_python/tools/maintain/sqlite3_common.py index 26058cb2..c8483714 100644 --- a/hikyuu_python/tools/maintain/sqlite3_common.py +++ b/hikyuu_python/tools/maintain/sqlite3_common.py @@ -32,7 +32,7 @@ def create_database(connect): """创建SQLITE3数据库表""" try: cur = connect.cursor() - filename = os.getcwd() + '/sqlite_createdb.sql' + filename = os.path.dirname(__file__) + '/sqlite_createdb.sql' with open(filename, 'r', encoding='utf8') as sqlfile: cur.executescript(sqlfile.read()) connect.commit()