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,79 @@
---
description: "Futures mean-reversion strategy that buys recent underperformers and sells recent outperformers relative to an equally-weighted futures market index, with an extension using volume and open interest filters."
tags: [futures, mean-reversion, contrarian, market-index, dollar-neutral]
---
# Contrarian Trading (Mean-Reversion)
**Section**: 10.3 | **Asset Class**: Futures | **Type**: Mean-Reversion / Contrarian
## Overview
Analogous to the equity mean-reversion strategy (Section 3.9), this futures strategy bets that recent losers will rebound and recent winners will give back gains. Returns of individual futures are measured relative to an equally-weighted market index, and capital is allocated inversely to the deviation from that index. The result is a dollar-neutral, automatically constructed contrarian portfolio rebalanced weekly.
## Construction / Mechanics
Within a universe of N futures labeled i = 1,...,N, define the "market index" return as the equally-weighted average:
```
R_m = (1/N) Σ R_i (469)
```
where R_i are individual futures returns, typically measured over the last one week.
The capital allocation weights are:
```
w_i = -γ [R_i - R_m] (470)
```
where γ > 0 is fixed via the dollar-neutral normalization condition:
```
Σ |w_i| = 1 (471)
```
- Futures below the market index (R_i < R_m): positive weight (long)
- Futures above the market index (R_i > R_m): negative weight (short)
- The portfolio is automatically dollar-neutral (Σ w_i = 0)
- The strategy buys losers and sells winners relative to the market index
**Volatility adjustment**: To mitigate overinvestment in volatile futures, suppress w_i by 1/σ_i or 1/σ_i², where σ_i are the historical volatilities.
## Return Profile
Profits when futures returns mean-revert toward the market index over a one-week horizon. Returns are driven by short-term overreaction and subsequent correction. The strategy is market-neutral at the index level.
## Key Parameters / Signals
| Parameter | Description |
|-----------|-------------|
| R_i | Individual futures return over the last week |
| R_m | Equally-weighted market index return (Eq. 469) |
| w_i = -γ[R_i - R_m] | Allocation weight; negative for winners, positive for losers |
| γ | Scaling parameter fixed by Eq. (471) |
| σ_i | Historical volatility; used to suppress w_i optionally |
| Rebalancing | Weekly |
## Variations
### 10.3.1 Contrarian Trading — Market Activity
Volume and open interest filters can improve the basic mean-reversion signal. Define:
```
v_i = ln(V_i / V_i') (472)
u_i = ln(U_i / U_i') (473)
```
where V_i is total volume for futures i over the last week, V_i' is total volume over the prior week, and U_i, U_i' are the analogous open interest quantities.
**Construction:**
1. Take the upper half of futures by volume factor v_i (higher recent volume relative to prior week).
2. Within that subset, take the lower half by open interest factor u_i.
3. Apply the contrarian weights from Eq. (470) to this filtered subset.
**Rationale:**
- Larger volume changes indicate greater overreaction (a stronger snap-back is expected).
- A decrease in open interest (low u_i) signals hedger withdrawal and suggests a deeper market for the mean-reversion to work.
## Notes
- The simple weighting scheme (Eq. 470) can overinvest in highly volatile futures; volatility scaling (1/σ_i or 1/σ_i²) is recommended in practice.
- Weekly rebalancing incurs transaction costs; the net alpha must exceed round-trip costs across all positions.
- Contrarian strategies can suffer sustained losses during trending regimes; combining with a trend-following overlay (Section 10.4) may reduce drawdowns.
- The market-index return R_m links this strategy to the broader futures universe; changing the universe composition changes the benchmark and alters all weights.