Add OKX trading-account USDC auto-swap and lock exit target while in position.
Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
@@ -362,6 +362,15 @@ class BinanceLiveExecutor(Matcher):
|
||||
)
|
||||
self.db._conn.commit()
|
||||
|
||||
try:
|
||||
from ..strategy.exits import lock_trade_exit_target
|
||||
|
||||
lock_trade_exit_target(
|
||||
self.db, group_id=group_id, initial_premium=initial_premium
|
||||
)
|
||||
except Exception:
|
||||
logger.exception("lock exit target failed group=%s", group_id)
|
||||
|
||||
return OpenResult(
|
||||
ok=True,
|
||||
group_id=group_id,
|
||||
@@ -480,6 +489,14 @@ class BinanceLiveExecutor(Matcher):
|
||||
),
|
||||
)
|
||||
self.db._conn.commit()
|
||||
try:
|
||||
from ..strategy.exits import lock_trade_exit_target
|
||||
|
||||
lock_trade_exit_target(
|
||||
self.db, group_id=group_id, initial_premium=initial_premium
|
||||
)
|
||||
except Exception:
|
||||
logger.exception("lock exit target failed half_open group=%s", group_id)
|
||||
|
||||
def repair_half_open(self) -> CloseResult:
|
||||
"""卖出 half_open 残留期权,清本地状态。"""
|
||||
@@ -557,7 +574,8 @@ class BinanceLiveExecutor(Matcher):
|
||||
"""UPDATE positions SET
|
||||
group_id=NULL, perp_side=NULL, perp_qty_eth=0, perp_entry_px=NULL,
|
||||
option_inst_id=NULL, option_side=NULL, option_qty_eth=0, option_qty_contracts=0,
|
||||
option_entry_px=NULL, entry_index_px=NULL, initial_premium=0, status='flat'
|
||||
option_entry_px=NULL, entry_index_px=NULL, initial_premium=0,
|
||||
exit_target_usdt=NULL, status='flat'
|
||||
WHERE id=1"""
|
||||
)
|
||||
self.db._conn.commit()
|
||||
@@ -668,6 +686,14 @@ class BinanceLiveExecutor(Matcher):
|
||||
),
|
||||
)
|
||||
self.db._conn.commit()
|
||||
try:
|
||||
from ..strategy.exits import lock_trade_exit_target
|
||||
|
||||
lock_trade_exit_target(
|
||||
self.db, group_id=group_id, initial_premium=initial_premium
|
||||
)
|
||||
except Exception:
|
||||
logger.exception("lock exit target failed recover group=%s", group_id)
|
||||
return CloseResult(
|
||||
ok=True,
|
||||
detail="recover_opening: 已提升为 open",
|
||||
@@ -1053,7 +1079,8 @@ class BinanceLiveExecutor(Matcher):
|
||||
"""UPDATE positions SET
|
||||
group_id=NULL, perp_side=NULL, perp_qty_eth=0, perp_entry_px=NULL,
|
||||
option_inst_id=NULL, option_side=NULL, option_qty_eth=0, option_qty_contracts=0,
|
||||
option_entry_px=NULL, entry_index_px=NULL, initial_premium=0, status='flat'
|
||||
option_entry_px=NULL, entry_index_px=NULL, initial_premium=0,
|
||||
exit_target_usdt=NULL, status='flat'
|
||||
WHERE id=1"""
|
||||
)
|
||||
self.db._conn.commit()
|
||||
@@ -1270,7 +1297,8 @@ class BinanceLiveExecutor(Matcher):
|
||||
"""UPDATE positions SET
|
||||
group_id=NULL, perp_side=NULL, perp_qty_eth=0, perp_entry_px=NULL,
|
||||
option_inst_id=NULL, option_side=NULL, option_qty_eth=0, option_qty_contracts=0,
|
||||
option_entry_px=NULL, entry_index_px=NULL, initial_premium=0, status='flat'
|
||||
option_entry_px=NULL, entry_index_px=NULL, initial_premium=0,
|
||||
exit_target_usdt=NULL, status='flat'
|
||||
WHERE id=1"""
|
||||
)
|
||||
self.db._conn.commit()
|
||||
|
||||
@@ -380,6 +380,15 @@ class OkxLiveExecutor(Matcher):
|
||||
)
|
||||
self.db._conn.commit()
|
||||
|
||||
try:
|
||||
from ..strategy.exits import lock_trade_exit_target
|
||||
|
||||
lock_trade_exit_target(
|
||||
self.db, group_id=group_id, initial_premium=initial_premium
|
||||
)
|
||||
except Exception:
|
||||
logger.exception("lock exit target failed group=%s", group_id)
|
||||
|
||||
return OpenResult(
|
||||
ok=True,
|
||||
group_id=group_id,
|
||||
@@ -498,6 +507,14 @@ class OkxLiveExecutor(Matcher):
|
||||
),
|
||||
)
|
||||
self.db._conn.commit()
|
||||
try:
|
||||
from ..strategy.exits import lock_trade_exit_target
|
||||
|
||||
lock_trade_exit_target(
|
||||
self.db, group_id=group_id, initial_premium=initial_premium
|
||||
)
|
||||
except Exception:
|
||||
logger.exception("lock exit target failed half_open group=%s", group_id)
|
||||
|
||||
def repair_half_open(self) -> CloseResult:
|
||||
"""卖出 half_open 残留期权,清本地状态。"""
|
||||
@@ -576,7 +593,8 @@ class OkxLiveExecutor(Matcher):
|
||||
"""UPDATE positions SET
|
||||
group_id=NULL, perp_side=NULL, perp_qty_eth=0, perp_entry_px=NULL,
|
||||
option_inst_id=NULL, option_side=NULL, option_qty_eth=0, option_qty_contracts=0,
|
||||
option_entry_px=NULL, entry_index_px=NULL, initial_premium=0, status='flat'
|
||||
option_entry_px=NULL, entry_index_px=NULL, initial_premium=0,
|
||||
exit_target_usdt=NULL, status='flat'
|
||||
WHERE id=1"""
|
||||
)
|
||||
self.db._conn.commit()
|
||||
@@ -696,6 +714,14 @@ class OkxLiveExecutor(Matcher):
|
||||
),
|
||||
)
|
||||
self.db._conn.commit()
|
||||
try:
|
||||
from ..strategy.exits import lock_trade_exit_target
|
||||
|
||||
lock_trade_exit_target(
|
||||
self.db, group_id=group_id, initial_premium=initial_premium
|
||||
)
|
||||
except Exception:
|
||||
logger.exception("lock exit target failed recover group=%s", group_id)
|
||||
return CloseResult(
|
||||
ok=True,
|
||||
detail="recover_opening: 已提升为 open",
|
||||
@@ -1091,7 +1117,8 @@ class OkxLiveExecutor(Matcher):
|
||||
"""UPDATE positions SET
|
||||
group_id=NULL, perp_side=NULL, perp_qty_eth=0, perp_entry_px=NULL,
|
||||
option_inst_id=NULL, option_side=NULL, option_qty_eth=0, option_qty_contracts=0,
|
||||
option_entry_px=NULL, entry_index_px=NULL, initial_premium=0, status='flat'
|
||||
option_entry_px=NULL, entry_index_px=NULL, initial_premium=0,
|
||||
exit_target_usdt=NULL, status='flat'
|
||||
WHERE id=1"""
|
||||
)
|
||||
self.db._conn.commit()
|
||||
@@ -1293,7 +1320,8 @@ class OkxLiveExecutor(Matcher):
|
||||
"""UPDATE positions SET
|
||||
group_id=NULL, perp_side=NULL, perp_qty_eth=0, perp_entry_px=NULL,
|
||||
option_inst_id=NULL, option_side=NULL, option_qty_eth=0, option_qty_contracts=0,
|
||||
option_entry_px=NULL, entry_index_px=NULL, initial_premium=0, status='flat'
|
||||
option_entry_px=NULL, entry_index_px=NULL, initial_premium=0,
|
||||
exit_target_usdt=NULL, status='flat'
|
||||
WHERE id=1"""
|
||||
)
|
||||
self.db._conn.commit()
|
||||
|
||||
Reference in New Issue
Block a user