| | |
| | | # volume:交易量 |
| | | # price:价格(如果是卖时不传价格就按照5挡价卖) |
| | | # blocking是否阻塞进程 |
| | | def order(direction, code, volume, price, price_type=2, blocking=False, sinfo=None, request_id=None,local_order_id = None): |
| | | def order(direction, code, volume, price, price_type=2, blocking=False, sinfo=None, request_id=None, |
| | | local_order_id=None): |
| | | timestamp = round(time.time() * 1000) |
| | | if not sinfo: |
| | | sinfo = f"b_{code}_{timestamp}" |
| | |
| | | |
| | | |
| | | # 获取成交列表 |
| | | def get_deal_list(blocking=True): |
| | | def get_deal_list(blocking=True, timeout=TIMEOUT): |
| | | request_id = __request(ClientSocketManager.CLIENT_TYPE_DEAL_LIST, |
| | | {"type": ClientSocketManager.CLIENT_TYPE_DEAL_LIST}, blocking=blocking, |
| | | is_pipe=is_pipe_channel_normal()) |
| | | return __read_response(request_id, blocking) |
| | | return __read_response(request_id, blocking, timeout=timeout) |
| | | |
| | | |
| | | # 获取持仓列表 |
| | |
| | | trade_manager.AccountAvailableMoneyManager().set_available_money(0, usefulMoney) |
| | | # 设置可用资金 |
| | | elif type_ == "deal_list": |
| | | dataJSON = huaxin_trade_api.get_deal_list() |
| | | dataJSON = huaxin_trade_api.get_deal_list(timeout=10) |
| | | print("成交响应:", dataJSON) |
| | | if dataJSON["code"] == 0: |
| | | datas = dataJSON["data"] |