修复粉尘桥拦开仓,并继续消除模拟盘嵌套握锁导致的 database is locked。
Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
@@ -273,6 +273,8 @@ class SimBroker:
|
||||
side = (direction or "").lower().strip()
|
||||
if side not in ("long", "short"):
|
||||
raise ValueError("direction 须为 long 或 short")
|
||||
# 行情先拉,再开库,避免握锁等网络
|
||||
bid, ask = _ticker_bid_ask(exchange, symbol)
|
||||
conn = self.get_db()
|
||||
try:
|
||||
row = conn.execute(
|
||||
@@ -289,7 +291,6 @@ class SimBroker:
|
||||
if close_c <= 0:
|
||||
raise ValueError("平仓张数无效")
|
||||
fr = sim_fee_rate(fee_rate)
|
||||
bid, ask = _ticker_bid_ask(exchange, symbol)
|
||||
qty = close_c * ct_sz
|
||||
pr = perp_fill(side=side, action="close", bid=bid, ask=ask, qty=qty, fee_rate=fr)
|
||||
if side == "long":
|
||||
@@ -492,6 +493,10 @@ class SimBroker:
|
||||
n = int(sheets)
|
||||
if n < 1:
|
||||
return {"ok": False, "msg": "张数至少为 1"}
|
||||
# 行情先拉,再开库,避免握锁等网络/嵌套写钱包
|
||||
bid, ask, _ = _option_bid_ask(exchange_options, inst_id)
|
||||
if price is not None and float(price) > 0:
|
||||
bid = max(float(bid), float(price)) if float(price) > 0 else float(bid)
|
||||
conn = self.get_db()
|
||||
try:
|
||||
row = conn.execute(
|
||||
@@ -506,9 +511,6 @@ class SimBroker:
|
||||
if close_n <= 0:
|
||||
return {"ok": False, "msg": "平仓张数无效"}
|
||||
fr = sim_fee_rate(fee_rate)
|
||||
bid, ask, _ = _option_bid_ask(exchange_options, inst_id)
|
||||
if price is not None and float(price) > 0:
|
||||
bid = max(float(bid), float(price)) if float(price) > 0 else float(bid)
|
||||
qty = close_n * ct_mult
|
||||
pr = option_fill(action="close", bid=bid, ask=ask, qty=qty, fee_rate=fr)
|
||||
credit = pr.notional - pr.fee
|
||||
|
||||
Reference in New Issue
Block a user