| | |
| | | if not current_price: |
| | | raise Exception("尚未获取到现价") |
| | | price = round(tool.get_buy_max_price(current_price), 3) |
| | | result = huaxin_trade_api.order(1, code, volume, price, blocking=True) |
| | | result = huaxin_trade_api.order(1, code, volume, price, blocking=True, order_ref=order_ref) |
| | | if result: |
| | | if result["code"] == 0: |
| | | sinfo = result["data"]["sinfo"] |
| | | # 需要立即卖的数据 |
| | | cb_data_util.need_sell_sinfos.add(sinfo) |
| | | # 记录当前的sinfo |
| | | async_log_util.info(logger_trade, f"API买结果: {result}") |
| | | async_log_util.info(logger_trade, f"API可转债买结果: {result}") |
| | | self.send_response(result, client_id, request_id) |
| | | except Exception as e: |
| | | if str(e).find("超时") >= 0: |
| | | self.send_response({"code": 0, "data": {"orderRef": order_ref}}, client_id, request_id) |
| | | else: |
| | | raise e |
| | | elif ctype == "sell_cb_for_commission": |
| | | # 用可转债填交易费漏洞 |
| | | code = data["code"] |
| | | volume = data["volume"] |
| | | current_price = None |
| | | results = history_k_data_util.HistoryKDatasUtils.get_gp_current_info([code]) |
| | | if results: |
| | | current_price = results[0]["price"] |
| | | order_ref = huaxin_util.create_order_ref() |
| | | try: |
| | | if not current_price: |
| | | raise Exception("尚未获取到现价") |
| | | price = round(tool.get_buy_min_price(current_price) + 0.001, 3) |
| | | result = huaxin_trade_api.order(2, code, volume, price, order_ref=order_ref, blocking=True) |
| | | async_log_util.info(logger_trade, f"API可转债卖结果: {result}") |
| | | self.send_response(result, client_id, request_id) |
| | | except Exception as e: |
| | | if str(e).find("超时") >= 0: |