Skip to content

Commit

Permalink
完善HikyuuTDX及移除spot_server测试代码
Browse files Browse the repository at this point in the history
  • Loading branch information
fasiondog committed Feb 4, 2021
1 parent 1239d83 commit 235b907
Show file tree
Hide file tree
Showing 6 changed files with 18 additions and 15 deletions.
4 changes: 1 addition & 3 deletions hikyuu/gui/HikyuuTDX.py
Original file line number Diff line number Diff line change
Expand Up @@ -716,8 +716,6 @@ def on_message_from_thread(self, msg):
@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):
Expand Down Expand Up @@ -758,7 +756,7 @@ def on_sched_import_pushButton_clicked(self):
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)
Expand Down
2 changes: 2 additions & 0 deletions hikyuu/gui/data/ImportWeightToSqliteTask.py
Original file line number Diff line number Diff line change
Expand Up @@ -114,10 +114,12 @@ def __call__(self):
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")
Expand Down
4 changes: 2 additions & 2 deletions hikyuu/gui/data/MainWindow.py
Original file line number Diff line number Diff line change
Expand Up @@ -675,9 +675,9 @@ def retranslateUi(self, MainWindow):
"</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"))
Expand Down
4 changes: 2 additions & 2 deletions hikyuu/gui/data/MainWindow.ui
Original file line number Diff line number Diff line change
Expand Up @@ -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">
Expand Down
7 changes: 7 additions & 0 deletions hikyuu/gui/data/UsePytdxImportToH5Thread.py
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@
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)

Expand Down Expand Up @@ -94,9 +95,11 @@ def init_task(self):
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

Expand Down Expand Up @@ -227,8 +230,10 @@ def run(self):
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):
Expand All @@ -248,6 +253,7 @@ def _run(self):
time_progress = {'SH': 0, 'SZ': 0}

#正在导入代码表
self.logger.info('导入股票代码表')
self.send_message(['INFO', '导入股票代码表'])

if self.config.getboolean('hdf5', 'enable', fallback=True):
Expand Down Expand Up @@ -318,4 +324,5 @@ def _run(self):
else:
self.logger.error("Unknow task: {}".format(taskname))


class_logger(UsePytdxImportToH5Thread)
12 changes: 4 additions & 8 deletions hikyuu/gui/spot_server.py
Original file line number Diff line number Diff line change
Expand Up @@ -225,14 +225,10 @@ def batch_func(records):
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))
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:
try:
start_time = Datetime.now()
Expand Down

0 comments on commit 235b907

Please sign in to comment.