| | |
| | | # '10932:产品状态资源访问授权不足', 'orderSysID': '110010190000809', 'accountId': |
| | | # '38800001334901'}} |
| | | if resultJSON['code'] == 0: |
| | | resultJSON = resultJSON['data'] |
| | | statusCode = resultJSON['orderStatus'] |
| | | if statusCode == huaxin_util.TORA_TSTP_OST_Rejected: |
| | | # 交易所拒绝 |
| | | raise Exception(resultJSON['statusMsg']) |
| | | else: |
| | | trade_huaxin.order_success(resultJSON['securityId'], resultJSON['accountId'], |
| | | resultJSON['orderSysID']) |
| | | return_str = json.dumps({"code": 0}) |
| | | try: |
| | | resultJSON = resultJSON['data'] |
| | | statusCode = resultJSON['orderStatus'] |
| | | |
| | | if statusCode == huaxin_util.TORA_TSTP_OST_Rejected: |
| | | # 交易所拒绝 |
| | | raise Exception(resultJSON['statusMsg']) |
| | | else: |
| | | trade_huaxin.order_success(resultJSON['securityId'], |
| | | resultJSON['accountId'], |
| | | resultJSON['orderSysID']) |
| | | return_str = json.dumps({"code": 0}) |
| | | finally: |
| | | # 更新委托列表 |
| | | trade_data_request_queue.put_nowait({"type": "delegate_list"}) |
| | | # 更新资金 |
| | | trade_data_request_queue.put_nowait({"type": "money"}) |
| | | else: |
| | | raise Exception(resultJSON['msg']) |
| | | |
| | |
| | | raise Exception("签名错误") |
| | | codes_data = data_json["data"] |
| | | code = codes_data["code"] |
| | | orderSysID = codes_data["orderSysID"] |
| | | if code and orderSysID: |
| | | orderSysID = codes_data.get("orderSysID") |
| | | accountId = codes_data.get("accountId") |
| | | if code and orderSysID and accountId: |
| | | result = trade_api.cancel_order(trade_api.TRADE_DIRECTION_BUY, code, orderSysID, True) |
| | | print("---撤单结果----") |
| | | print(result) |
| | | if result["code"] == 0: |
| | | if result["data"]["cancel"] == 1: |
| | | # 撤单成功 |
| | | trade_huaxin.cancel_order_success(code, accountId, orderSysID) |
| | | return_str = json.dumps({"code": 0}) |
| | | else: |
| | | # 撤单失败 |
| | | raise Exception(result["data"]["errorMsg"]) |
| | | else: |
| | | raise Exception(result["msg"]) |
| | | |
| | | elif code: |
| | | state = trade_manager.get_trade_state(code) |
| | | if state == trade_manager.TRADE_STATE_BUY_PLACE_ORDER or state == trade_manager.TRADE_STATE_BUY_DELEGATED or state == trade_manager.TRADE_STATE_BUY_CANCEL_ING: |