Category: Analytics / Screening
Dynamically discovers active futures contracts for an underlying, builds the term structure, computes annualised roll yield, and classifies contango/backwardation.
- User provides a futures code stem (e.g.,
HK.HHIfor Hang Seng Index Futures). - Dynamically discovers active contracts by iterating month codes.
- Optionally enriches with expiry dates via
get_instrument_info. - Renders an ASCII term structure chart showing prices across expiries.
- Computes roll yield for each consecutive month pair:
roll_yield = (far_price - near_price) / near_price × (365 / days_to_expiry_diff) - Classifies the curve: CONTANGO, BACKWARDATION, HUMPED, or IRREGULAR.
python3 main.py HK.HHI # Hang Seng Index Futures
python3 main.py HK.MHI # MHI Futures- Dynamic futures contract discovery via API (no hardcoded code lists)
get_market_snapshotandget_instrument_infofor contract metadata- Annualised roll yield computation
- ASCII term structure visualization
- Pure stdlib — no external plotting libraries
| Regime | Meaning |
|---|---|
| CONTANGO | Far month trades at premium (normal market) |
| BACKWARDATION | Far month trades at discount (supply tight) |
| HUMPED | Maximum or minimum in the middle of the curve |
| IRREGULAR | No clear shape |