From 6a94f67e8226d23475d6a865fa80df046b02c9d8 Mon Sep 17 00:00:00 2001 From: yanweidong Date: Fri, 4 Sep 2026 21:04:34 +0800 Subject: [PATCH] fix bug --- api/qmt_rest_new.py | 9 +++++++++ py-client/sdk/trade.py | 17 +++++++++++++++-- py-client/strategy/ipo/boot.py | 1 + 3 files changed, 25 insertions(+), 2 deletions(-) diff --git a/api/qmt_rest_new.py b/api/qmt_rest_new.py index 2180e2c..d5152d3 100644 --- a/api/qmt_rest_new.py +++ b/api/qmt_rest_new.py @@ -274,6 +274,14 @@ class CancelByIdHandler(BaseHandler): "order_id": order_id, }) +# get_ipo_data() - Get today's new stock and bond offerings +class IpoDataHandler(BaseHandler): + def post(self): + data = json.loads(self.request.body) + typ = data.get('type', 'STOCK') + ret = safe_call(get_ipo_data, typ) + self.write_json(ret) + # sys: Python version information class PythonVersionHandler(BaseHandler): def get(self): @@ -368,6 +376,7 @@ def make_app(): (r"/api/portfolio/deal", DealHandler), (r"/api/data/full_tick", FullTickHandler), + (r"/api/trade/ipo_data", IpoDataHandler), (r"/api/trade/cancel_by_id", CancelByIdHandler), (r"/api/trade/passorder", PassorderHandler), diff --git a/py-client/sdk/trade.py b/py-client/sdk/trade.py index 9e3c3dd..658a048 100644 --- a/py-client/sdk/trade.py +++ b/py-client/sdk/trade.py @@ -15,15 +15,20 @@ class TradeMixin: def passorder( self, op_type: int, - stock_code: str, - volume: int, + stock_code: str = "", + volume: int = 0, order_type: int = ORDER_TYPE_VOLUME, pr_type: int = PR_TYPE_LATEST, price: float = -1, quick_trade: int = QUICK_TRADE_NOW, strategy_name: str = "", order_id: str = "", + stock: str = "", ) -> dict[str, Any]: + # ``stock`` is retained for compatibility with the original IPO client. + stock_code = str(stock_code or stock).strip() + if not stock_code: + raise ValueError("stock_code cannot be empty") return self._post_json( "/api/trade/passorder", { @@ -39,6 +44,14 @@ class TradeMixin: }, ) + def ipo_data(self, ipo_type: str = "STOCK") -> list[dict[str, Any]]: + """Return today's IPO candidates from the QMT REST service.""" + response = self._post_json( + "/api/trade/ipo_data", + {"type": str(ipo_type).strip().upper()}, + ) or [] + return response if isinstance(response, list) else [] + def passorder_latest(self, side: int, stock_code: str, volume: int) -> dict[str, Any]: return self.passorder(side, stock_code, volume) diff --git a/py-client/strategy/ipo/boot.py b/py-client/strategy/ipo/boot.py index 7709367..e3cccb5 100644 --- a/py-client/strategy/ipo/boot.py +++ b/py-client/strategy/ipo/boot.py @@ -51,6 +51,7 @@ def AutoBuyIpo() -> int: price=ipo_price, strategy_name="新股申购", ) + logging.info("[IPO] %s 申购,发行价:%s 可申购额度:%s", stock) except Exception: logging.info("[IPO] %s 申购失败,不写入锁文件", stock) else: