malkhut: fee+slippage execution threshold
This commit is contained in:
@@ -120,30 +120,50 @@ def build_our_actions(
|
||||
post_only=intent.prefer_maker, reduce_only=intent.reduce_only,
|
||||
))
|
||||
|
||||
# Aggressive crossing — urgency-driven maker/taker decision
|
||||
# Below threshold: passive only (maker). Above: aggressive (taker).
|
||||
# The system learns the cheapest/fastest path as a function of urgency.
|
||||
# Aggressive crossing — urgency + fee+slippage threshold driven maker/taker decision
|
||||
# The system learns: if (fee + slippage) < threshold → execute (pay the friction)
|
||||
# Threshold is movable (CMA-ES optimizable), tested at 2-3 bps per leg.
|
||||
estimated_fee_bps = state.venue.taker_fee_bps # what taker would pay
|
||||
estimated_slippage_bps = 0.5 # rough estimate; calibrated model refines in CWM
|
||||
estimated_friction = estimated_fee_bps + estimated_slippage_bps
|
||||
|
||||
if intent.urgency > params.urgency_taker_threshold:
|
||||
# High urgency: MARKET for immediate fill
|
||||
for frac in (0.05, 0.10, 0.25):
|
||||
actions.append(FulfilmentAction(
|
||||
kind=ActionKind.CROSS_SPREAD, side=side,
|
||||
order_type=OrderType.MARKET, price_ticks_from_best=0,
|
||||
qty_fraction=frac, ttl_ms=params.aggressive_ttl_ms,
|
||||
reduce_only=intent.reduce_only,
|
||||
metadata={"urgency": intent.urgency, "mode": "taker_market"},
|
||||
))
|
||||
# High urgency: full taker if friction is acceptable
|
||||
if estimated_friction <= params.execution_friction_threshold_bps or intent.urgency > 0.9:
|
||||
for frac in (0.05, 0.10, 0.25):
|
||||
actions.append(FulfilmentAction(
|
||||
kind=ActionKind.CROSS_SPREAD, side=side,
|
||||
order_type=OrderType.MARKET, price_ticks_from_best=0,
|
||||
qty_fraction=frac, ttl_ms=params.aggressive_ttl_ms,
|
||||
reduce_only=intent.reduce_only,
|
||||
metadata={"urgency": intent.urgency, "mode": "taker_market",
|
||||
"friction_bps": estimated_friction},
|
||||
))
|
||||
else:
|
||||
# Friction too high even at high urgency → IOC partial
|
||||
for frac in (0.03, 0.06):
|
||||
actions.append(FulfilmentAction(
|
||||
kind=ActionKind.CROSS_SPREAD, side=side,
|
||||
order_type=OrderType.LIMIT, price_ticks_from_best=0,
|
||||
qty_fraction=frac, ttl_ms=params.aggressive_ttl_ms,
|
||||
time_in_force="IOC",
|
||||
reduce_only=intent.reduce_only,
|
||||
metadata={"urgency": intent.urgency, "mode": "taker_ioc",
|
||||
"friction_bps": estimated_friction},
|
||||
))
|
||||
elif intent.urgency > params.urgency_taker_threshold * 0.5:
|
||||
# Medium urgency: LIMIT + IOC (partial fill OK)
|
||||
for frac in (0.03, 0.06):
|
||||
actions.append(FulfilmentAction(
|
||||
kind=ActionKind.CROSS_SPREAD, side=side,
|
||||
order_type=OrderType.LIMIT, price_ticks_from_best=0,
|
||||
qty_fraction=frac, ttl_ms=params.aggressive_ttl_ms,
|
||||
time_in_force="IOC",
|
||||
reduce_only=intent.reduce_only,
|
||||
metadata={"urgency": intent.urgency, "mode": "taker_ioc"},
|
||||
))
|
||||
# Medium urgency: IOC partial if friction is low
|
||||
if estimated_friction <= params.execution_friction_threshold_bps * 1.5:
|
||||
for frac in (0.03, 0.06):
|
||||
actions.append(FulfilmentAction(
|
||||
kind=ActionKind.CROSS_SPREAD, side=side,
|
||||
order_type=OrderType.LIMIT, price_ticks_from_best=0,
|
||||
qty_fraction=frac, ttl_ms=params.aggressive_ttl_ms,
|
||||
time_in_force="IOC",
|
||||
reduce_only=intent.reduce_only,
|
||||
metadata={"urgency": intent.urgency, "mode": "taker_ioc",
|
||||
"friction_bps": estimated_friction},
|
||||
))
|
||||
# Low urgency: passive only (maker) — no taker actions added
|
||||
|
||||
# Path-risk exits
|
||||
|
||||
Reference in New Issue
Block a user