def QueryExchangeSort(exchange: str, count: int, sortFiled: str): frequence = None start_time_stamp = int(time.time() * 1000) # http = MarketHttpClient() # market_token = http.get_market_token( # http.get_login_token(phone=login_phone, pwd=login_pwd, device_id=login_device_id)) market_token = None loop = Common().getNewLoop() api = SubscribeApi(union_ws_url, loop) loop.run_until_complete(future=api.client.ws_connect()) loop.run_until_complete( future=api.LoginReq(token=market_token, start_time_stamp=start_time_stamp, frequence=frequence)) # asyncio.run_coroutine_threadsafe(api.hearbeat_job(), new_loop) rsp_sort_list = asyncio.get_event_loop().run_until_complete( future=api.QueryExchangeSortMsgReqApi( isSubTrade=None, exchange=exchange, sortFiled=sortFiled, count=count, start_time_stamp=start_time_stamp, recv_num=1)) app_sort = rsp_sort_list[0] api.client.disconnect() return app_sort
def StartChartData(exchange: str, code: str): # exchange = exchange # code = code frequence = None start_time_stamp = int(time.time() * 1000) # http = MarketHttpClient() # market_token = http.get_market_token( # http.get_login_token(phone=login_phone, pwd=login_pwd, device_id=login_device_id)) market_token = None loop = Common().getNewLoop() api = SubscribeApi(union_ws_url, loop) loop.run_until_complete(future=api.client.ws_connect()) loop.run_until_complete( future=api.LoginReq(token=market_token, start_time_stamp=start_time_stamp, frequence=frequence)) asyncio.run_coroutine_threadsafe(api.hearbeat_job(), loop) app_rsp_list = loop.run_until_complete(future=api.StartChartDataReqApi( exchange, code, start_time_stamp, recv_num=1)) app_rsp = app_rsp_list[0] api.client.disconnect() # return app_rsp return """ <html> <head> <title>查询合约</title> </head> <body> <pre id="out_pre"></pre> </body> <script type="text/javascript"> var result = JSON.stringify({text}, null, 2);//将字符串转换成json对象 document.getElementById('out_pre').innerText= result ; </script> </html> """.format(text=app_rsp)