Expand model tag support: add GLM-5.1, simplify Anthropic IDs, scan tags anywhere in message

- Flink update_bars debouncing
- update_bars subscription idempotency bugfix
- Price decimal correction bugfix of previous commit
- Add GLM-5.1 model tag alongside renamed GLM-5
- Use short Anthropic model IDs (sonnet/haiku/opus) instead of full version strings
- Allow @tags anywhere in message content, not just at start
- Return hasOtherContent flag instead of trimmed rest string
- Only trigger greeting stream when tag has no other content
- Update workspace knowledge base references to platform/workspace and platform/shapes
- Hierarchical knowledge base catalog
- 151 Trading Strategies knowledge base articles
- Shapes knowledge base article
- MutateShapes tool instead of workspace patch
This commit is contained in:
2026-04-28 15:05:15 -04:00
parent d41fcd0499
commit 47471b7700
184 changed files with 9044 additions and 170 deletions

View File

@@ -0,0 +1,54 @@
---
description: "Captures the bid-ask spread by posting passive limit orders at the bid and ask, using short-horizon directional signals to stay on the correct side and avoid adverse selection from informed order flow."
tags: [stocks, market-making, high-frequency, bid-ask-spread]
---
# Market-Making
**Section**: 3.19 | **Asset Class**: Stocks | **Type**: Market-Making / High-Frequency Trading
## Overview
Market-making captures the bid-ask spread by simultaneously quoting to buy at the bid and sell at the ask. The strategy profits when order flow is uninformed ("dumb"); it loses money when order flow is "smart" (informed/toxic) due to adverse selection. Practical implementations use short-horizon directional signals to stay on the correct side of the market, often augmented by longer-horizon signals to handle adverse selection on individual fills.
## Construction / Signal
**Simplified rule**:
```
Rule = { Buy at the bid
{ Sell at the ask (359)
```
**Practical refinement — short-horizon signal**: Maintain a signal indicating the likely near-term price direction. Place limit orders such that:
- If signal indicates price increase: buy at the bid (stay long side)
- If signal indicates price decrease: sell at the ask (stay short side)
**Combined short- and long-horizon signal approach**:
- Short-horizon signal: indicates near-term direction; used to route passive vs. aggressive orders.
- Long-horizon signal: provides directional conviction; can justify accepting adverse selection on individual trades if the trade is based on positive expected return from the longer signal.
- If both signals agree: consider aggressive (marketable) order instead of passive limit order to ensure fill.
## Entry / Exit Rules
- **Entry**: Post limit orders at bid (to buy) or ask (to sell), sized to the desired position.
- **Exit**: The opposite-side limit order fills (completing the round-trip), or a signal change triggers cancellation and replacement of orders.
- **Position limits**: Must be defined; the strategy should not accumulate large directional inventory.
- **Queue priority**: Must be #1 (or near front) in the limit order queue at each price level to ensure fills; this is what makes speed/infrastructure critical.
## Key Parameters
- **Bid-ask spread**: The primary source of profit per round-trip
- **Signal horizon (short)**: Milliseconds to seconds; used for order placement direction
- **Signal horizon (long)**: Minutes to hours; used to tolerate adverse selection
- **Cents-per-share target**: Realized P&L in cents per total share traded (including both establishing and liquidating trades)
- **Inventory limit**: Maximum tolerated directional position before reducing quotes
- **Speed/latency**: Infrastructure speed is critical for queue position in high-frequency market-making
## Variations
- **Pure passive**: Only post limit orders; profit entirely from spread capture; maximally exposed to adverse selection
- **Mixed passive + aggressive**: Use longer-horizon signal to occasionally place aggressive (market) orders when signal strength justifies paying the spread
- **Multi-level quoting**: Quote at multiple price levels across the order book
## Notes
- In a market with mostly uninformed ("dumb") order flow, pure market-making is highly profitable; in a market dominated by informed ("smart") flow, adverse selection erodes all profits.
- Adverse selection: smart order flow tends to arrive when the market is moving against the market-maker's position (e.g., buys come when the price is declining through the bid).
- The "cents-per-share" metric (realized P&L in cents / total shares traded, counting both establishing and liquidating trades) is the standard performance measure.
- High-frequency trading (HFT) infrastructure is key: speed determines queue priority for limit orders, which determines fill probability.
- Long-horizon signal typically has lower Sharpe ratio but higher cents-per-share than the short-horizon signal.
- This strategy is primarily relevant for professional trading operations with direct market access and co-location infrastructure.