mirror of
https://gitee.com/fasiondog/hikyuu.git
synced 2024-12-04 04:48:17 +08:00
完善HikyuuTDX及移除spot_server测试代码
This commit is contained in:
parent
1239d83f5d
commit
235b907ad2
@ -716,8 +716,6 @@ class MyMainWindow(QMainWindow, Ui_MainWindow):
|
|||||||
|
|
||||||
@pyqtSlot()
|
@pyqtSlot()
|
||||||
def on_start_import_pushButton_clicked(self):
|
def on_start_import_pushButton_clicked(self):
|
||||||
if not self._is_sched_import_running:
|
|
||||||
self.sched_import_pushButton.setEnabled(False)
|
|
||||||
config = self.getCurrentConfig()
|
config = self.getCurrentConfig()
|
||||||
dest_dir = config.get('hdf5', 'dir')
|
dest_dir = config.get('hdf5', 'dir')
|
||||||
if not os.path.exists(dest_dir) or not os.path.isdir(dest_dir):
|
if not os.path.exists(dest_dir) or not os.path.isdir(dest_dir):
|
||||||
@ -758,7 +756,7 @@ class MyMainWindow(QMainWindow, Ui_MainWindow):
|
|||||||
self.sched_import_pushButton.setText("启动定时导入")
|
self.sched_import_pushButton.setText("启动定时导入")
|
||||||
self.sched_import_thread.terminate()
|
self.sched_import_thread.terminate()
|
||||||
self.sched_import_thread.wait()
|
self.sched_import_thread.wait()
|
||||||
self.logger.info("已停止定时采集")
|
self.logger.info("已停止定时导入")
|
||||||
self.sched_import_thread = None
|
self.sched_import_thread = None
|
||||||
self.sched_import_pushButton.setEnabled(True)
|
self.sched_import_pushButton.setEnabled(True)
|
||||||
self.start_import_pushButton.setEnabled(True)
|
self.start_import_pushButton.setEnabled(True)
|
||||||
|
@ -114,10 +114,12 @@ class ImportWeightToSqliteTask:
|
|||||||
api = TdxHq_API()
|
api = TdxHq_API()
|
||||||
api.connect(hosts[0][2], hosts[0][3])
|
api.connect(hosts[0][2], hosts[0][3])
|
||||||
|
|
||||||
|
self.logger.info('正在导入权息数据')
|
||||||
self.queue.put([self.msg_name, '正在导入权息数据...', 0, 0, 0])
|
self.queue.put([self.msg_name, '正在导入权息数据...', 0, 0, 0])
|
||||||
total_count = pytdx_import_weight(api, connect, "SH")
|
total_count = pytdx_import_weight(api, connect, "SH")
|
||||||
total_count += pytdx_import_weight(api, connect, "SZ")
|
total_count += pytdx_import_weight(api, connect, "SZ")
|
||||||
self.queue.put([self.msg_name, '导入权息数据完毕!', 0, 0, total_count])
|
self.queue.put([self.msg_name, '导入权息数据完毕!', 0, 0, total_count])
|
||||||
|
self.logger.info('导入权息数据完毕')
|
||||||
|
|
||||||
#self.queue.put([self.msg_name, '下载通达信财务信息(上证)...', 0, 0, 0])
|
#self.queue.put([self.msg_name, '下载通达信财务信息(上证)...', 0, 0, 0])
|
||||||
#x = pytdx_import_finance(connect, api, "SH")
|
#x = pytdx_import_finance(connect, api, "SH")
|
||||||
|
@ -675,9 +675,9 @@ class Ui_MainWindow(object):
|
|||||||
"</style></head><body style=\" font-family:\'SimSun\'; font-size:9pt; font-weight:400; font-style:normal;\">\n"
|
"</style></head><body style=\" font-family:\'SimSun\'; font-size:9pt; font-weight:400; font-style:normal;\">\n"
|
||||||
"<p style=\" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;\">注:</p>\n"
|
"<p style=\" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;\">注:</p>\n"
|
||||||
"<p style=\"-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;\"><br /></p>\n"
|
"<p style=\"-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;\"><br /></p>\n"
|
||||||
"<p style=\" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;\"><span style=\" font-size:10pt; font-weight:600; color:#ff0000;\">1、行情采集服务仅对预加载数据有效</span>,在行情采集服务运行期间,hikyuu运行时将自动连接采集服务获取行情数据,并更新预加载的内容数据。</p>\n"
|
"<p style=\" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;\"><span style=\" font-size:10pt; font-weight:600; color:#ff0000;\">1、行情采集服务仅对预加载数据有效</span>,在行情采集服务运行期间,hikyuu.interactive运行时将自动连接采集服务获取行情数据,并更新预加载的内容数据。</p>\n"
|
||||||
"<p style=\"-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;\"><br /></p>\n"
|
"<p style=\"-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;\"><br /></p>\n"
|
||||||
"<p style=\" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;\">2、如使用芝麻代理(<a href=\"http://h.zhimaruanjian.com/\"><span style=\" text-decoration: underline; color:#0000ff;\">http://h.zhimaruanjian.com/</span></a>),请自行申请,并确保ip为其白名单</p></body></html>"))
|
"<p style=\" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;\">2、如使用芝麻代理(<a href=\"http://h.zhimaruanjian.com/\"><span style=\" text-decoration: underline; color:#0000ff;\">http://h.zhimaruanjian.com/</span></a>),请自行申请(需付费),并确保ip为其白名单。</p></body></html>"))
|
||||||
self.label_39.setText(_translate("MainWindow", "行情数据源:"))
|
self.label_39.setText(_translate("MainWindow", "行情数据源:"))
|
||||||
self.collect_source_comboBox.setItemText(0, _translate("MainWindow", "sina"))
|
self.collect_source_comboBox.setItemText(0, _translate("MainWindow", "sina"))
|
||||||
self.collect_source_comboBox.setItemText(1, _translate("MainWindow", "qq"))
|
self.collect_source_comboBox.setItemText(1, _translate("MainWindow", "qq"))
|
||||||
|
@ -1199,9 +1199,9 @@ p, li { white-space: pre-wrap; }
|
|||||||
</style></head><body style=" font-family:'SimSun'; font-size:9pt; font-weight:400; font-style:normal;">
|
</style></head><body style=" font-family:'SimSun'; font-size:9pt; font-weight:400; font-style:normal;">
|
||||||
<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;">注:</p>
|
<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;">注:</p>
|
||||||
<p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><br /></p>
|
<p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><br /></p>
|
||||||
<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-size:10pt; font-weight:600; color:#ff0000;">1、行情采集服务仅对预加载数据有效</span>,在行情采集服务运行期间,hikyuu运行时将自动连接采集服务获取行情数据,并更新预加载的内容数据。</p>
|
<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-size:10pt; font-weight:600; color:#ff0000;">1、行情采集服务仅对预加载数据有效</span>,在行情采集服务运行期间,hikyuu.interactive运行时将自动连接采集服务获取行情数据,并更新预加载的内容数据。</p>
|
||||||
<p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><br /></p>
|
<p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><br /></p>
|
||||||
<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;">2、如使用芝麻代理(<a href="http://h.zhimaruanjian.com/"><span style=" text-decoration: underline; color:#0000ff;">http://h.zhimaruanjian.com/</span></a>),请自行申请,并确保ip为其白名单</p></body></html></string>
|
<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;">2、如使用芝麻代理(<a href="http://h.zhimaruanjian.com/"><span style=" text-decoration: underline; color:#0000ff;">http://h.zhimaruanjian.com/</span></a>),请自行申请(需付费),并确保ip为其白名单。</p></body></html></string>
|
||||||
</property>
|
</property>
|
||||||
</widget>
|
</widget>
|
||||||
<widget class="QWidget" name="layoutWidget">
|
<widget class="QWidget" name="layoutWidget">
|
||||||
|
@ -42,6 +42,7 @@ from hikyuu.data.common_mysql import create_database as mysql_create_database
|
|||||||
from hikyuu.data.pytdx_to_mysql import import_stock_name as mysql_import_stock_name
|
from hikyuu.data.pytdx_to_mysql import import_stock_name as mysql_import_stock_name
|
||||||
from hikyuu.util.mylog import class_logger
|
from hikyuu.util.mylog import class_logger
|
||||||
|
|
||||||
|
|
||||||
class UsePytdxImportToH5Thread(QThread):
|
class UsePytdxImportToH5Thread(QThread):
|
||||||
message = pyqtSignal(list)
|
message = pyqtSignal(list)
|
||||||
|
|
||||||
@ -94,9 +95,11 @@ class UsePytdxImportToH5Thread(QThread):
|
|||||||
if self.config.getboolean('ktype', 'time', fallback=False):
|
if self.config.getboolean('ktype', 'time', fallback=False):
|
||||||
task_count += 2
|
task_count += 2
|
||||||
|
|
||||||
|
self.logger.info('搜索通达信服务器')
|
||||||
self.send_message(['INFO', '搜索通达信服务器'])
|
self.send_message(['INFO', '搜索通达信服务器'])
|
||||||
self.hosts = search_best_tdx()
|
self.hosts = search_best_tdx()
|
||||||
if not self.hosts:
|
if not self.hosts:
|
||||||
|
self.logger.warn('无法连接通达信行情服务器!请检查网络设置!')
|
||||||
self.send_message(['INFO', '无法连接通达信行情服务器!请检查网络设置!'])
|
self.send_message(['INFO', '无法连接通达信行情服务器!请检查网络设置!'])
|
||||||
return
|
return
|
||||||
|
|
||||||
@ -227,8 +230,10 @@ class UsePytdxImportToH5Thread(QThread):
|
|||||||
self.init_task()
|
self.init_task()
|
||||||
self._run()
|
self._run()
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
|
self.logger.error(str(e))
|
||||||
self.send_message(['THREAD', 'FAILURE', str(e)])
|
self.send_message(['THREAD', 'FAILURE', str(e)])
|
||||||
else:
|
else:
|
||||||
|
self.logger.info('导入完毕')
|
||||||
self.send_message(['THREAD', 'FINISHED'])
|
self.send_message(['THREAD', 'FINISHED'])
|
||||||
|
|
||||||
def _run(self):
|
def _run(self):
|
||||||
@ -248,6 +253,7 @@ class UsePytdxImportToH5Thread(QThread):
|
|||||||
time_progress = {'SH': 0, 'SZ': 0}
|
time_progress = {'SH': 0, 'SZ': 0}
|
||||||
|
|
||||||
#正在导入代码表
|
#正在导入代码表
|
||||||
|
self.logger.info('导入股票代码表')
|
||||||
self.send_message(['INFO', '导入股票代码表'])
|
self.send_message(['INFO', '导入股票代码表'])
|
||||||
|
|
||||||
if self.config.getboolean('hdf5', 'enable', fallback=True):
|
if self.config.getboolean('hdf5', 'enable', fallback=True):
|
||||||
@ -318,4 +324,5 @@ class UsePytdxImportToH5Thread(QThread):
|
|||||||
else:
|
else:
|
||||||
self.logger.error("Unknow task: {}".format(taskname))
|
self.logger.error("Unknow task: {}".format(taskname))
|
||||||
|
|
||||||
|
|
||||||
class_logger(UsePytdxImportToH5Thread)
|
class_logger(UsePytdxImportToH5Thread)
|
@ -225,14 +225,10 @@ def collect(use_proxy, source, seconds, phase1, phase2, ignore_weekend):
|
|||||||
phase1_time = [today + x for x in phase1_delta]
|
phase1_time = [today + x for x in phase1_delta]
|
||||||
phase2_time = [today + x for x in phase2_delta]
|
phase2_time = [today + x for x in phase2_delta]
|
||||||
start_time = Datetime.now()
|
start_time = Datetime.now()
|
||||||
if not (
|
delta = next_delta(start_time, seconds, phase1_delta, phase2_delta, ignore_weekend)
|
||||||
phase1_time[0] <= start_time <= phase1_time[1]
|
next_time = start_time + delta
|
||||||
or phase2_time[0] <= start_time <= phase2_time[1]
|
hku_info("启动采集时间:{}".format(next_time))
|
||||||
):
|
time.sleep(delta.total_seconds())
|
||||||
delta = next_delta(start_time, seconds, phase1_delta, phase2_delta, ignore_weekend)
|
|
||||||
next_time = start_time + delta
|
|
||||||
hku_info("启动采集时间:{}".format(next_time))
|
|
||||||
time.sleep(delta.total_seconds())
|
|
||||||
while True:
|
while True:
|
||||||
try:
|
try:
|
||||||
start_time = Datetime.now()
|
start_time = Datetime.now()
|
||||||
|
Loading…
Reference in New Issue
Block a user