Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

启动证券客户端问题修复 #59

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 8 additions & 2 deletions easyquant/main_engine.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,9 @@
import time
from collections import OrderedDict
from threading import Thread, Lock
import json
import argparse
from collections import namedtuple

import easytrader
from logbook import Logger, StreamHandler
Expand All @@ -25,7 +28,6 @@

ACCOUNT_OBJECT_FILE = 'account.session'


class MainEngine:
"""主引擎,负责行情 / 事件驱动引擎 / 交易"""

Expand All @@ -38,10 +40,14 @@ def __init__(self, broker=None, need_data=None, quotation_engines=None,

# 登录账户
if (broker is not None) and (need_data is not None):
broker += "_client"
self.user = easytrader.use(broker)
need_data_file = pathlib.Path(need_data)
if need_data_file.exists():
self.user.prepare(need_data)
with open(need_data_file) as json_data:
need_data = json.load(json_data)
self.user.login(**need_data)
#self.user.prepare(need_data)
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

注释掉的代码可以直接移除,不需要保留

else:
log_handler.warn("券商账号信息文件 %s 不存在, easytrader 将不可用" % need_data)
else:
Expand Down
7 changes: 4 additions & 3 deletions ht.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
{
"userName":"用户名",
"servicePwd":"通讯密码",
"trdpwd":"加密后的密码"
"user":"用户名",
"comm_password":"通讯密码",
"password":"交易密码",
"exe_path":"运行路径"
}
8 changes: 6 additions & 2 deletions test.py
Original file line number Diff line number Diff line change
Expand Up @@ -42,10 +42,14 @@ def fetch_quotation(self):

quotation_engine = DefaultQuotationEngine if quotation_choose == '1' else LFEngine

push_interval = int(input('请输入行情推送间隔(s)\n:'))
quotation_engine.PushInterval = push_interval
push_interval = input('请输入行情推送间隔(s)\n:')
if push_interval == '':
push_interval = 1
quotation_engine.PushInterval = int(push_interval)

log_type_choose = input('请输入 log 记录方式: 1: 显示在屏幕 2: 记录到指定文件\n: ')
if log_type_choose == "":
log_type_choose = '1'
log_type = 'stdout' if log_type_choose == '1' else 'file'

log_filepath = input('请输入 log 文件记录路径\n: ') if log_type == 'file' else ''
Expand Down