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:
@@ -0,0 +1,60 @@
|
||||
---
|
||||
description: "Cash-and-carry (index) arbitrage exploits price inefficiencies between an index spot price and its futures price, trading the basis when futures are mispriced relative to their theoretical fair value."
|
||||
tags: [indexes, arbitrage, futures, basis, cash-and-carry]
|
||||
---
|
||||
|
||||
# Cash-and-Carry Arbitrage
|
||||
|
||||
**Section**: 6.2 | **Asset Class**: Indexes | **Type**: Arbitrage
|
||||
|
||||
## Overview
|
||||
Cash-and-carry arbitrage (also called "index arbitrage") exploits discrepancies between the spot value of an index and the price of index futures. Theoretically, the futures price must equal the spot price compounded at the risk-free rate minus the present value of dividends. When the actual futures price deviates from this fair value beyond transaction costs, an arbitrage trade exists.
|
||||
|
||||
## Construction / Mechanics
|
||||
|
||||
**Theoretical (fair) futures price**:
|
||||
```
|
||||
F*(t,T) = [S(t) - D(t,T)] · exp(r(T-t)) (421)
|
||||
```
|
||||
|
||||
where:
|
||||
- F*(t,T): theoretical futures price with delivery T at time t
|
||||
- S(t): current spot value of the index
|
||||
- D(t,T): present value (as of t) of dividends paid by index constituents between t and T
|
||||
- r: risk-free rate (assumed constant)
|
||||
|
||||
**Basis** (normalized deviation from fair value):
|
||||
```
|
||||
B(t,T) = [F(t,T) - F*(t,T)] / S(t) (422)
|
||||
```
|
||||
|
||||
where F(t,T) is the actual futures price.
|
||||
|
||||
**Trading rule**:
|
||||
- If B(t,T) > 0 (futures rich relative to spot): **sell futures + buy cash** (index basket)
|
||||
- If B(t,T) < 0 (futures cheap relative to spot): **buy futures + sell cash** (index basket)
|
||||
- Only trade when |B(t,T)| exceeds pertinent transaction costs
|
||||
- Close the position when the basis converges to zero (futures price converges to fair value at delivery)
|
||||
|
||||
## Payoff / Return Profile
|
||||
- Earns the basis B(t,T) as a riskless profit (if perfectly hedged) when the position is held to delivery.
|
||||
- The basis converges to zero at expiry: futures price → spot price at delivery.
|
||||
- Return per dollar of notional ≈ |B(t,T)| minus transaction costs.
|
||||
|
||||
## Key Parameters / Signals
|
||||
- B(t,T): the basis — primary signal; trade when |B| > transaction cost threshold
|
||||
- S(t): index spot level
|
||||
- D(t,T): expected dividends over the futures lifetime
|
||||
- r: risk-free rate
|
||||
- Transaction cost threshold: determines minimum |B| required to trade profitably
|
||||
|
||||
## Variations
|
||||
- **Incomplete basket**: use a subset of index constituents to reduce transaction costs; introduces tracking error.
|
||||
- **ETF arbitrage**: similar logic applied to ETF mispricing (see Section 6.4).
|
||||
|
||||
## Notes
|
||||
- Arbitrage opportunities are short-lived and require extremely fast execution; this is a domain of high-frequency trading.
|
||||
- Selling the cash index (short-selling constituent stocks) is operationally complex: hard-to-borrow stocks, short-sale restrictions, etc.
|
||||
- Dollar-neutral long cash / short futures book helps manage execution but requires continuous monitoring.
|
||||
- Slippage from large orders moving the market can be prohibitive.
|
||||
- Incomplete baskets (omitting illiquid or low-cap stocks) reduce transaction costs but introduce residual tracking risk.
|
||||
@@ -0,0 +1,79 @@
|
||||
---
|
||||
description: "Dispersion trading goes long single-stock option straddles on index constituents and short the index option straddle, exploiting the empirical tendency for index implied volatility to exceed the theoretical volatility implied by constituent volatilities and correlations."
|
||||
tags: [indexes, volatility, dispersion, options, straddle, correlation]
|
||||
---
|
||||
|
||||
# Dispersion Trading in Equity Indexes
|
||||
|
||||
**Section**: 6.3 | **Asset Class**: Indexes | **Type**: Volatility / Arbitrage
|
||||
|
||||
## Overview
|
||||
Dispersion trading exploits the empirical observation that the implied volatility of index options is typically higher than the theoretical index volatility implied by constituent implied volatilities and their correlations. The strategy goes long single-stock volatility (via straddles on each constituent) and short index volatility (via a short index straddle), profiting when realized correlations are lower than the correlation implied by index options pricing.
|
||||
|
||||
## Construction / Mechanics
|
||||
|
||||
**Theoretical index variance** from constituent volatilities and correlation matrix:
|
||||
```
|
||||
σ_I² = Σ_{i,j=1}^N w_i·w_j·σ_i·σ_j·ρ_ij (423)
|
||||
```
|
||||
|
||||
where:
|
||||
- w_i: index weights (assumed market-cap weighted)
|
||||
- σ_i: implied volatility of stock i (from single-stock options)
|
||||
- ρ_ij: sample (historical) correlation matrix (ρ_ii = 1)
|
||||
|
||||
Empirically, the implied index volatility ̃σ_I > σ_I, i.e., index options are priced at a premium to theoretical constituent volatility.
|
||||
|
||||
**Position construction** (near-ATM straddles, ~1 month to expiry):
|
||||
- For each stock i in the index: **long n_i straddles** on stock i (near-ATM)
|
||||
- **Short 1 index straddle** (near-ATM, index level P_I)
|
||||
|
||||
**Sizing** n_i (for market-cap-weighted index):
|
||||
```
|
||||
n_i = S_i · P_I / Σ_{k=1}^N S_k·P_k (424)
|
||||
```
|
||||
|
||||
where S_i is shares outstanding for stock i. With this sizing, P_I = Σ_i n_i·P_i, so the index straddle payoff matches the sum of individual straddle payoffs as closely as possible.
|
||||
|
||||
All positions held until expiry (~1 month).
|
||||
|
||||
## Payoff / Return Profile
|
||||
- Profits when constituent volatilities are high relative to index volatility (low realized correlation).
|
||||
- Loses when correlation spikes (e.g., broad market selloff where all stocks fall together), causing the index to move as much as the constituents.
|
||||
- The strategy can also be viewed as short the average pairwise correlation ρ_ij.
|
||||
|
||||
## Key Parameters / Signals
|
||||
- ̃σ_I: implied index volatility (from index options)
|
||||
- σ_I: theoretical index volatility from Eq. (423) using constituent implied vols + historical correlations
|
||||
- Spread ̃σ_I - σ_I: the basis to be monetized
|
||||
- Realized vs. implied correlation: the key P&L driver
|
||||
|
||||
## Variations
|
||||
|
||||
### 6.3.1 Dispersion Trading — Subset Portfolio
|
||||
For large indexes (e.g., S&P 500), some constituent stocks may lack liquid single-stock options (typically smaller-cap stocks). These must be excluded from the bought portfolio. Additional reasons to use a subset:
|
||||
- Reducing the number of single-stock positions lowers transaction costs.
|
||||
- The sample correlation matrix ρ_ij is singular for typical lookback periods (e.g., 1 year of daily returns with N=500 stocks), making Eq. (423) unreliable.
|
||||
|
||||
**Stabilized correlation matrix** using a statistical risk model (PCA-based):
|
||||
```
|
||||
ψ_ij = ξ_i²·δ_ij + Σ_{A=1}^K λ^(A)·V_i^(A)·V_j^(A) (425)
|
||||
ξ_i² = 1 - Σ_{A=1}^K λ^(A)·[V_i^(A)]² (426)
|
||||
```
|
||||
|
||||
where K < r (r = rank of ρ_ij) principal components explain systematic risk; ξ_i is the idiosyncratic (specific) risk of stock i. K is chosen via eRank.
|
||||
|
||||
Using ψ_ij instead of ρ_ij, the theoretical variance becomes:
|
||||
```
|
||||
σ_I² = Σ_{i,j=1}^N w_i·w_j·σ_i·σ_j·ψ_ij
|
||||
= Σ_i w_i²σ_i²ξ_i² + Σ_{A=1}^K λ^(A)·[Σ_i λ^(A)·V_i^(A)·w_i·σ_i]² (427)
|
||||
```
|
||||
|
||||
The subset long portfolio contains only the N_* stocks with the lowest w_i²σ_i²ξ_i² values (e.g., N_* = 100 for S&P 500), which are the stocks contributing least specific risk to the index.
|
||||
|
||||
## Notes
|
||||
- This strategy sits at the boundary of index and volatility strategies; it can also be viewed as correlation trading.
|
||||
- The strategy loses badly during market crises when correlations spike toward 1 (e.g., 2008), as the index moves almost as much as the individual stocks.
|
||||
- The pairwise correlations ρ_ij are unstable out-of-sample; using a PCA-based risk model (subset variation) mitigates this.
|
||||
- ATM options may not be available for all stocks; OTM options close to ATM can substitute.
|
||||
- The strategy is typically implemented with options expiring in about 1 month, and all positions held to expiration.
|
||||
35
gateway/knowledge/trading/strategies/indexes/generalities.md
Normal file
35
gateway/knowledge/trading/strategies/indexes/generalities.md
Normal file
@@ -0,0 +1,35 @@
|
||||
---
|
||||
description: "Background on index investing: an index is a diversified portfolio of assets with defined weights, and investment vehicles such as futures and ETFs allow efficient, single-trade exposure to broad indexes."
|
||||
tags: [indexes, background, etf, futures, index-arbitrage]
|
||||
---
|
||||
|
||||
# Index Generalities
|
||||
|
||||
**Section**: 6.1 | **Asset Class**: Indexes | **Type**: Background / Reference
|
||||
|
||||
## Overview
|
||||
An index is a diversified portfolio of assets combined according to specified weights. The underlying assets are typically stocks (e.g., DJIA, S&P 500, Russell 3000). Index weights are determined by price (DJIA) or market capitalization (S&P 500, Russell 3000). Investment vehicles such as index futures and index-based ETFs allow a trader to gain broad market exposure through a single trade.
|
||||
|
||||
## Construction / Mechanics
|
||||
|
||||
**Index types by weighting scheme**:
|
||||
- **Price-weighted**: DJIA — each stock's weight proportional to its price; a high-priced stock has disproportionate influence.
|
||||
- **Market-cap-weighted**: S&P 500, Russell 3000 — each stock's weight proportional to its market capitalization (shares × price); larger companies dominate.
|
||||
- **Equal-weighted**: each constituent receives the same weight; requires frequent rebalancing.
|
||||
|
||||
**Investment vehicles**:
|
||||
- **Index futures**: standardized contracts to buy/sell the index at a future date; require no upfront payment of the full notional (margin only); settled in cash.
|
||||
- **Index ETFs**: exchange-traded funds that hold (or replicate) the index constituents; trade intraday like stocks; e.g., SPY (S&P 500), IVV (iShares S&P 500).
|
||||
- Both instruments allow leveraged or hedged exposure to the index.
|
||||
|
||||
## Key Concepts
|
||||
- **Spot price S(t)**: current value of the index based on constituent prices.
|
||||
- **Futures price F(t,T)**: price of the futures contract with delivery at T; theoretically F*(t,T) = [S(t) - D(t,T)] · exp(r(T-t)) where D(t,T) is the present value of dividends and r is the risk-free rate.
|
||||
- **Basis B(t,T)**: normalized difference between futures price and theoretical fair value; basis trading exploits deviations of B from zero.
|
||||
- **Tracking error**: difference between an ETF's NAV return and the index return; minimizing tracking error is a key ETF management objective.
|
||||
|
||||
## Notes
|
||||
- Index futures and ETFs are highly liquid, making index strategies generally easier to implement than single-stock strategies.
|
||||
- Market-cap-weighted indexes concentrate exposure in the largest stocks; this can create significant single-name risk.
|
||||
- ETF arbitrage (Section 6.4) exploits intraday mispricings between different ETFs tracking the same index.
|
||||
- Dispersion trading (Section 6.3) exploits the difference between index implied volatility and constituent implied volatilities.
|
||||
@@ -0,0 +1,49 @@
|
||||
---
|
||||
description: "Intraday ETF arbitrage exploits short-term mispricings between two ETFs tracking the same underlying index by buying the cheaper ETF and shorting the more expensive one when their bid-ask prices diverge beyond a threshold."
|
||||
tags: [indexes, arbitrage, etf, intraday, high-frequency]
|
||||
---
|
||||
|
||||
# Intraday Arbitrage Between Index ETFs
|
||||
|
||||
**Section**: 6.4 | **Asset Class**: Indexes | **Type**: Arbitrage / High-Frequency
|
||||
|
||||
## Overview
|
||||
When two ETFs track the same underlying index, their prices should be nearly identical. Short-lived intraday mispricings arise due to order flow imbalances, liquidity differences, or market microstructure effects. The strategy exploits these mispricings by simultaneously buying the cheaper ETF and shorting the more expensive one, closing the position when prices converge.
|
||||
|
||||
## Construction / Mechanics
|
||||
|
||||
Let ETF1 and ETF2 track the same index. Let P_1^Bid, P_1^Ask be the bid and ask prices for ETF1, and P_2^Bid, P_2^Ask for ETF2. Let κ be a predefined price threshold (κ close to 1, e.g., κ = 1.002).
|
||||
|
||||
**Trading rule**:
|
||||
```
|
||||
Rule = { Buy ETF2, short ETF1 if P_1^Bid ≥ P_2^Ask × κ
|
||||
{ Liquidate position if P_2^Bid ≥ P_1^Ask
|
||||
{ Buy ETF1, short ETF2 if P_2^Bid ≥ P_1^Ask × κ
|
||||
{ Liquidate position if P_1^Bid ≥ P_2^Ask (428)
|
||||
```
|
||||
|
||||
- **Enter**: when one ETF's bid exceeds the other's ask by at least factor κ (i.e., the spread exceeds transaction costs by a sufficient margin).
|
||||
- **Exit**: when the spread collapses (the two bid-ask ranges overlap), meaning convergence has occurred.
|
||||
- Orders are placed as marketable **"fill or kill"** limit orders to ensure immediate execution.
|
||||
|
||||
## Payoff / Return Profile
|
||||
- Earns the price differential (P_1^Bid - P_2^Ask or P_2^Bid - P_1^Ask) when the ETFs revert to parity.
|
||||
- Profit per trade ≈ (P_i^Bid/P_j^Ask - 1) - transaction costs, which is small (basis points level) but high frequency.
|
||||
- Cumulative return from many small, fast trades.
|
||||
|
||||
## Key Parameters / Signals
|
||||
- κ: minimum price threshold to trigger trade (e.g., 1.002 = 0.2% premium)
|
||||
- P_i^Bid, P_i^Ask: real-time bid and ask prices for each ETF
|
||||
- Entry condition: P_1^Bid ≥ P_2^Ask × κ (or vice versa)
|
||||
- Exit condition: bid-ask ranges overlap (spread collapses to zero)
|
||||
|
||||
## Variations
|
||||
- Apply the same logic to an ETF and its underlying index futures (similar to cash-and-carry arbitrage, Section 6.2).
|
||||
- Multi-ETF: trade mispricings across three or more ETFs on related (but not identical) indexes.
|
||||
|
||||
## Notes
|
||||
- Arbitrage opportunities are ephemeral and require a fast order execution system; slippage will eat away profits at slow execution speeds.
|
||||
- "Fill or kill" limit orders are critical: partial fills create unhedged residual risk.
|
||||
- The threshold κ must exceed the effective transaction cost (bid-ask spread + commissions + market impact) to ensure profitability.
|
||||
- E.g., for S&P 500 ETFs: SPY (SPDR Trust) and IVV (iShares) are the main candidates.
|
||||
- This strategy is firmly in the domain of high-frequency / algorithmic trading.
|
||||
@@ -0,0 +1,58 @@
|
||||
---
|
||||
description: "Index volatility targeting maintains a constant portfolio volatility level by dynamically rebalancing between a risky index and a risk-free asset, scaling the index allocation inversely with current volatility."
|
||||
tags: [indexes, volatility-targeting, risk-management, rebalancing, allocation]
|
||||
---
|
||||
|
||||
# Index Volatility Targeting with Risk-Free Asset
|
||||
|
||||
**Section**: 6.5 | **Asset Class**: Indexes | **Type**: Risk Management / Volatility Targeting
|
||||
|
||||
## Overview
|
||||
A volatility targeting strategy maintains a constant target volatility σ_* for a portfolio by periodically rebalancing between a risky asset (an index) and a riskless asset (e.g., U.S. Treasury bills). The allocation to the risky asset is scaled inversely with the current (estimated) volatility of the index, so the portfolio's realized volatility stays close to σ_*.
|
||||
|
||||
## Construction / Mechanics
|
||||
|
||||
**Risky asset weight** (allocation to the index):
|
||||
```
|
||||
w = σ_* / σ
|
||||
```
|
||||
|
||||
where:
|
||||
- σ_*: target volatility (constant, set by the investor)
|
||||
- σ: current estimated volatility of the index (e.g., realized or implied)
|
||||
|
||||
**Risk-free asset weight**: 1 - w
|
||||
|
||||
If a maximum leverage constraint L is imposed: w is capped at L.
|
||||
|
||||
**Rebalancing to avoid overtrading**: instead of rebalancing on a fixed schedule (weekly, monthly), rebalance only when the allocation has drifted significantly:
|
||||
```
|
||||
Rebalance only if |Δw| / w > κ
|
||||
```
|
||||
where Δw is the change in w since the last rebalance and κ is a preset threshold (e.g., 5–10%). This reduces transaction costs while maintaining approximately constant volatility.
|
||||
|
||||
**Net portfolio**: a fraction w in the index + a fraction (1-w) in T-bills.
|
||||
|
||||
## Payoff / Return Profile
|
||||
- Targets a constant realized volatility close to σ_*.
|
||||
- When market volatility rises, the index allocation is reduced, limiting drawdowns.
|
||||
- When market volatility is low, the index allocation increases (potentially with leverage), improving returns.
|
||||
- The strategy does not make a directional bet on the market; it is a risk management overlay.
|
||||
|
||||
## Key Parameters / Signals
|
||||
- σ_*: volatility target (investor-specified, e.g., 10% annualized)
|
||||
- σ: current volatility estimate (realized vol from recent returns, or implied vol from options)
|
||||
- w = σ_*/σ: dynamic allocation weight
|
||||
- κ: rebalancing threshold (avoids unnecessary turnover)
|
||||
- Maximum leverage L: caps w if set
|
||||
|
||||
## Variations
|
||||
- Apply to other asset classes (bonds, commodities) using the same framework.
|
||||
- Combine volatility targeting with a trend-following signal: only hold the index when its trend is positive, otherwise hold the risk-free asset.
|
||||
- Use implied volatility (e.g., VIX) as σ for a forward-looking allocation rather than backward-looking realized vol.
|
||||
|
||||
## Notes
|
||||
- Volatility targeting implicitly creates momentum-like behavior: reduces risk when volatility spikes (which often accompanies market selloffs) and adds risk when volatility is low (often in trending markets).
|
||||
- The strategy does not protect against sudden gap moves (e.g., flash crashes) where volatility spikes before rebalancing can occur.
|
||||
- Transaction costs from rebalancing must be weighed against the volatility-stabilization benefit; the threshold κ controls this trade-off.
|
||||
- The choice of σ (historical lookback window vs. implied vol) significantly affects performance and responsiveness.
|
||||
Reference in New Issue
Block a user