| | |
| | | return |
| | | if sinfo in self.__buy_sinfo_set: |
| | | raise Exception(f'下单请求已经提交:{sinfo}') |
| | | async_log_util.info(logger_local_huaxin_trade_debug, |
| | | f"进入买入方法:code-{code} sinfo-{sinfo}") |
| | | self.__buy_sinfo_set.add(sinfo) |
| | | self.req_id += 1 |
| | | # 请求报单 |
| | |
| | | try: |
| | | req_rid_dict[sinfo] = (client_id, request_id, sk, local_order_id) |
| | | self.__tradeSimpleApi.buy(code, volume, price, sinfo) |
| | | |
| | | except Exception as e: |
| | | send_response(json.dumps({"code": 1, "msg": str(e)}), TYPE_ORDER, client_id, |
| | | request_id) |
| | | |
| | | async_log_util.info(logger_local_huaxin_trade_debug, |
| | | f"买入结束:code-{code} sinfo-{sinfo}") |
| | | elif direction == 2: |
| | | try: |
| | | price_type = data["price_type"] |
| | |
| | | raise Exception("没有找到系统订单号") |
| | | req_rid_dict[sinfo] = (client_id, request_id, sk) |
| | | self.__tradeSimpleApi.cancel_buy(code, orderSysID, sinfo) |
| | | async_log_util.info(logger_local_huaxin_trade_debug, |
| | | f"撤单结束:code-{code} order_sys_id-{orderSysID} sinfo-{sinfo}") |
| | | except Exception as e: |
| | | send_response(json.dumps({"code": 1, "msg": str(e)}), TYPE_CANCEL_ORDER, client_id, |
| | | request_id) |