|
| 1 | +spec "MarketMakingStrategy" v1.0 { |
| 2 | + description: "Advanced market making strategy with AI-powered spread optimization and inventory management for systematic liquidity provision and bid-ask capture." |
| 3 | + |
| 4 | + inputs: |
| 5 | + strategy_id: string |
| 6 | + trading_pair: string { default: "BTC/USD" } |
| 7 | + base_spread_bps: int { default: 10 } |
| 8 | + order_size: float { default: 1000.0 } |
| 9 | + max_inventory: float { default: 10.0 } |
| 10 | + |
| 11 | + account_balance: float { default: 100000.0 } |
| 12 | + inventory_target: float { default: 0.0 } |
| 13 | + spread_multiplier: float { default: 1.0 } |
| 14 | + min_spread_bps: int { default: 5 } |
| 15 | + max_spread_bps: int { default: 50 } |
| 16 | + |
| 17 | + dynamic_spread_enabled: bool { default: true } |
| 18 | + inventory_skew_enabled: bool { default: true } |
| 19 | + volatility_adjustment: bool { default: true } |
| 20 | + order_refresh_enabled: bool { default: true } |
| 21 | + |
| 22 | + ai_models: string |
| 23 | + market_data_feed: string |
| 24 | + execution_venue: string |
| 25 | + |
| 26 | + order_refresh_interval: int { default: 5 } |
| 27 | + inventory_rebalance_threshold: float { default: 0.8 } |
| 28 | + adverse_selection_protection: bool { default: true } |
| 29 | + |
| 30 | + risk_management_enabled: bool { default: true } |
| 31 | + max_position_size: float { default: 0.1 } |
| 32 | + stop_loss_enabled: bool { default: true } |
| 33 | + profit_target_enabled: bool { default: false } |
| 34 | + |
| 35 | + computed: |
| 36 | + current_inventory: -> calculate_inventory() |
| 37 | + optimal_spread: -> calculate_optimal_spread() |
| 38 | + market_volatility: -> measure_volatility() |
| 39 | + |
| 40 | + events: |
| 41 | + on_create(strategy): initialize_market_making |
| 42 | + on_fill(order): manage_inventory |
| 43 | + on_timer(order_refresh_interval): refresh_quotes |
| 44 | + on_change(market_volatility): adjust_spread |
| 45 | + on_error(inventory_limit): rebalance_inventory |
| 46 | + |
| 47 | + actions: |
| 48 | + initialize_market_making { |
| 49 | + description: "Initialize market making strategy" |
| 50 | + mcp_call: "trading/market_making/initialize" |
| 51 | + parameters: { |
| 52 | + strategy_id: strategy_id, |
| 53 | + trading_pair: trading_pair, |
| 54 | + base_spread_bps: base_spread_bps, |
| 55 | + order_size: order_size, |
| 56 | + account_balance: account_balance |
| 57 | + } |
| 58 | + } |
| 59 | + |
| 60 | + manage_inventory { |
| 61 | + description: "Manage inventory after order fills" |
| 62 | + mcp_call: "trading/market_making/manage_inventory" |
| 63 | + parameters: { |
| 64 | + current_inventory: current_inventory, |
| 65 | + inventory_target: inventory_target, |
| 66 | + max_inventory: max_inventory, |
| 67 | + inventory_skew_enabled: inventory_skew_enabled |
| 68 | + } |
| 69 | + } |
| 70 | + |
| 71 | + refresh_quotes { |
| 72 | + description: "Refresh bid and ask quotes" |
| 73 | + mcp_call: "trading/market_making/refresh_quotes" |
| 74 | + parameters: { |
| 75 | + trading_pair: trading_pair, |
| 76 | + optimal_spread: optimal_spread, |
| 77 | + order_size: order_size, |
| 78 | + current_inventory: current_inventory |
| 79 | + } |
| 80 | + } |
| 81 | + |
| 82 | + adjust_spread { |
| 83 | + description: "Dynamically adjust spread based on market conditions" |
| 84 | + mcp_call: "trading/market_making/adjust_spread" |
| 85 | + parameters: { |
| 86 | + market_volatility: market_volatility, |
| 87 | + volatility_adjustment: volatility_adjustment, |
| 88 | + min_spread_bps: min_spread_bps, |
| 89 | + max_spread_bps: max_spread_bps |
| 90 | + } |
| 91 | + } |
| 92 | + |
| 93 | + rebalance_inventory { |
| 94 | + description: "Rebalance inventory when limits are breached" |
| 95 | + mcp_call: "trading/market_making/rebalance" |
| 96 | + parameters: { |
| 97 | + strategy_id: strategy_id, |
| 98 | + current_inventory: current_inventory, |
| 99 | + inventory_rebalance_threshold: inventory_rebalance_threshold |
| 100 | + } |
| 101 | + } |
| 102 | +} |
0 commit comments