随机设置一个session_id值,并传入极简客户端用户目录和账号ID、类型,连接客户端:
@api.route('/login', methods=['GET'])
async def login(request):
'''
账号登录
'''
session_id = int(request.args.get("session_id", random.randint(20000, 60000)))
qmt_dir = request.args.get("qmt_dir", 'C:\\gszq\\qmt\\userdata_mini')
account_id = request.args.get("account_id", '')
account_type = request.args.get("account_type", 'STOCK') # 账号类型,可选STOCK、CREDIT
connect_result = trader.set_trader(qmt_dir, session_id)
trader.set_account(account_id, account_type=account_type)
print("交易连接成功!") if connect_result == 0 else print("交易连接失败!")
return response.json({"status": connect_result})