完善HikyuuTDX及移除spot_server测试代码

This commit is contained in:
fasiondog 2021-02-04 21:29:54 +08:00
parent 1239d83f5d
commit 235b907ad2
6 changed files with 18 additions and 15 deletions

View File

@ -716,8 +716,6 @@ class MyMainWindow(QMainWindow, Ui_MainWindow):
@pyqtSlot()
def on_start_import_pushButton_clicked(self):
if not self._is_sched_import_running:
self.sched_import_pushButton.setEnabled(False)
config = self.getCurrentConfig()
dest_dir = config.get('hdf5', '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_thread.terminate()
self.sched_import_thread.wait()
self.logger.info("已停止定时采集")
self.logger.info("已停止定时导入")
self.sched_import_thread = None
self.sched_import_pushButton.setEnabled(True)
self.start_import_pushButton.setEnabled(True)

View File

@ -114,10 +114,12 @@ class ImportWeightToSqliteTask:
api = TdxHq_API()
api.connect(hosts[0][2], hosts[0][3])
self.logger.info('')
self.queue.put([self.msg_name, '...', 0, 0, 0])
total_count = pytdx_import_weight(api, connect, "SH")
total_count += pytdx_import_weight(api, connect, "SZ")
self.queue.put([self.msg_name, '!', 0, 0, total_count])
self.logger.info('')
#self.queue.put([self.msg_name, '下载通达信财务信息(上证)...', 0, 0, 0])
#x = pytdx_import_finance(connect, api, "SH")

View File

@ -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"
"<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=\" 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=\" 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.collect_source_comboBox.setItemText(0, _translate("MainWindow", "sina"))
self.collect_source_comboBox.setItemText(1, _translate("MainWindow", "qq"))

View File

@ -1199,9 +1199,9 @@ p, li { white-space: pre-wrap; }
&lt;/style&gt;&lt;/head&gt;&lt;body style=&quot; font-family:'SimSun'; font-size:9pt; font-weight:400; font-style:normal;&quot;&gt;
&lt;p style=&quot; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;&quot;&gt;注:&lt;/p&gt;
&lt;p style=&quot;-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;&quot;&gt;&lt;br /&gt;&lt;/p&gt;
&lt;p style=&quot; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;&quot;&gt;&lt;span style=&quot; font-size:10pt; font-weight:600; color:#ff0000;&quot;&gt;1、行情采集服务仅对预加载数据有效&lt;/span&gt;在行情采集服务运行期间hikyuu运行时将自动连接采集服务获取行情数据并更新预加载的内容数据。&lt;/p&gt;
&lt;p style=&quot; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;&quot;&gt;&lt;span style=&quot; font-size:10pt; font-weight:600; color:#ff0000;&quot;&gt;1、行情采集服务仅对预加载数据有效&lt;/span&gt;在行情采集服务运行期间hikyuu.interactive运行时将自动连接采集服务获取行情数据,并更新预加载的内容数据。&lt;/p&gt;
&lt;p style=&quot;-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;&quot;&gt;&lt;br /&gt;&lt;/p&gt;
&lt;p style=&quot; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;&quot;&gt;2、如使用芝麻代理&lt;a href=&quot;http://h.zhimaruanjian.com/&quot;&gt;&lt;span style=&quot; text-decoration: underline; color:#0000ff;&quot;&gt;http://h.zhimaruanjian.com/&lt;/span&gt;&lt;/a&gt;请自行申请并确保ip为其白名单&lt;/p&gt;&lt;/body&gt;&lt;/html&gt;</string>
&lt;p style=&quot; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;&quot;&gt;2、如使用芝麻代理&lt;a href=&quot;http://h.zhimaruanjian.com/&quot;&gt;&lt;span style=&quot; text-decoration: underline; color:#0000ff;&quot;&gt;http://h.zhimaruanjian.com/&lt;/span&gt;&lt;/a&gt;),请自行申请(需付费)并确保ip为其白名单&lt;/p&gt;&lt;/body&gt;&lt;/html&gt;</string>
</property>
</widget>
<widget class="QWidget" name="layoutWidget">

View File

@ -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.util.mylog import class_logger
class UsePytdxImportToH5Thread(QThread):
message = pyqtSignal(list)
@ -94,9 +95,11 @@ class UsePytdxImportToH5Thread(QThread):
if self.config.getboolean('ktype', 'time', fallback=False):
task_count += 2
self.logger.info('')
self.send_message(['INFO', ''])
self.hosts = search_best_tdx()
if not self.hosts:
self.logger.warn('')
self.send_message(['INFO', ''])
return
@ -227,8 +230,10 @@ class UsePytdxImportToH5Thread(QThread):
self.init_task()
self._run()
except Exception as e:
self.logger.error(str(e))
self.send_message(['THREAD', 'FAILURE', str(e)])
else:
self.logger.info('')
self.send_message(['THREAD', 'FINISHED'])
def _run(self):
@ -248,6 +253,7 @@ class UsePytdxImportToH5Thread(QThread):
time_progress = {'SH': 0, 'SZ': 0}
#正在导入代码表
self.logger.info('')
self.send_message(['INFO', ''])
if self.config.getboolean('hdf5', 'enable', fallback=True):
@ -318,4 +324,5 @@ class UsePytdxImportToH5Thread(QThread):
else:
self.logger.error("Unknow task: {}".format(taskname))
class_logger(UsePytdxImportToH5Thread)

View File

@ -225,10 +225,6 @@ def collect(use_proxy, source, seconds, phase1, phase2, ignore_weekend):
phase1_time = [today + x for x in phase1_delta]
phase2_time = [today + x for x in phase2_delta]
start_time = Datetime.now()
if not (
phase1_time[0] <= start_time <= phase1_time[1]
or phase2_time[0] <= start_time <= phase2_time[1]
):
delta = next_delta(start_time, seconds, phase1_delta, phase2_delta, ignore_weekend)
next_time = start_time + delta
hku_info("启动采集时间:{}".format(next_time))