This commit is contained in:
2026-09-04 21:04:34 +08:00
parent eb0bbcdddc
commit 6a94f67e82
3 changed files with 25 additions and 2 deletions

View File

@@ -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),

View File

@@ -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)

View File

@@ -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: