malkhut: all exchange order types in DSL + action_menu
ActionType → OrderType mapping (common-sensical): QUOTE/REQUOTE/CHASE: LIMIT (passive, post_only) CROSS_SPREAD (high urgency): MARKET (immediate fill) CROSS_SPREAD (medium urgency): LIMIT + IOC (partial fill) STOP_LOSS: STOP_MARKET (trigger → market exit) TAKE_PROFIT: TRIGGER_MARKET (trigger → market exit) TRAILING_STOP: TRAILING_STOP (trailing stop exit) EXIT/FLAT_ALL: STOP_MARKET EMERGENCY_EXIT: MARKET (immediate) All order types exercised: LIMIT, MARKET, STOP_MARKET, TRIGGER_MARKET, TRAILING_STOP
This commit is contained in:
@@ -5,6 +5,14 @@ Menu size target:
|
||||
our actions: 8-24
|
||||
each counterparty role: 3-12
|
||||
depth: 2-4
|
||||
|
||||
Order type mapping (common-sensical):
|
||||
QUOTE/REQUOTE/CHASE: LIMIT (passive, post_only)
|
||||
CROSS_SPREAD (low urgency): LIMIT + IOC (taker, partial fill OK)
|
||||
CROSS_SPREAD (high urgency): MARKET (immediate fill)
|
||||
STOP_LOSS: STOP_MARKET (trigger → market exit)
|
||||
TAKE_PROFIT: TRIGGER_MARKET (trigger → market exit)
|
||||
TRAILING_STOP: TRAILING_STOP (trailing stop exit)
|
||||
"""
|
||||
from __future__ import annotations
|
||||
|
||||
@@ -116,18 +124,17 @@ def build_our_actions(
|
||||
# Below threshold: passive only (maker). Above: aggressive (taker).
|
||||
# The system learns the cheapest/fastest path as a function of urgency.
|
||||
if intent.urgency > params.urgency_taker_threshold:
|
||||
# High urgency: aggressive taker fills
|
||||
# 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.LIMIT, price_ticks_from_best=0,
|
||||
order_type=OrderType.MARKET, 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"},
|
||||
metadata={"urgency": intent.urgency, "mode": "taker_market"},
|
||||
))
|
||||
elif intent.urgency > params.urgency_taker_threshold * 0.5:
|
||||
# Medium urgency: aggressive but with IOC (partial fill OK)
|
||||
# Medium urgency: LIMIT + IOC (partial fill OK)
|
||||
for frac in (0.03, 0.06):
|
||||
actions.append(FulfilmentAction(
|
||||
kind=ActionKind.CROSS_SPREAD, side=side,
|
||||
@@ -135,17 +142,18 @@ def build_our_actions(
|
||||
qty_fraction=frac, ttl_ms=params.aggressive_ttl_ms,
|
||||
time_in_force="IOC",
|
||||
reduce_only=intent.reduce_only,
|
||||
metadata={"urgency": intent.urgency, "mode": "taker_partial"},
|
||||
metadata={"urgency": intent.urgency, "mode": "taker_ioc"},
|
||||
))
|
||||
# Low urgency: passive only (maker) — no taker actions added
|
||||
|
||||
# Path-risk exits
|
||||
if _path_risk_says_exit(state, params):
|
||||
# STOP_MARKET for stop-loss exits (trigger → market)
|
||||
actions.append(FulfilmentAction(
|
||||
kind=ActionKind.FULL_EXIT, side=_exit_side_for_position(state),
|
||||
order_type=OrderType.MARKET, price_ticks_from_best=0,
|
||||
order_type=OrderType.STOP_MARKET, price_ticks_from_best=0,
|
||||
qty_fraction=1.0, ttl_ms=0, reduce_only=True,
|
||||
metadata={"reason": "path_risk_exit"},
|
||||
metadata={"reason": "path_risk_exit", "exit_type": "stop_market"},
|
||||
))
|
||||
|
||||
# Chase actions (cancel → wait → retry with configurable wait_to_retry_ms)
|
||||
@@ -160,7 +168,8 @@ def build_our_actions(
|
||||
ttl_ms=chase_ttl,
|
||||
post_only=True,
|
||||
metadata={"chase": True, "chase_offset": offset,
|
||||
"chase_max_retries": params.chase_max_retries},
|
||||
"chase_max_retries": params.chase_max_retries,
|
||||
"order_type_combo": "LIMIT+post_only+chase"},
|
||||
))
|
||||
|
||||
return tuple(actions)
|
||||
|
||||
Reference in New Issue
Block a user