docs: fix markdown lint COT spec (blanks, table padding, code lang)
ci / ruff lint (push) Failing after 38s
ci / mypy mcp_common (push) Failing after 36s
ci / pytest (push) Failing after 34s
ci / validate compose + Caddyfile (push) Failing after 32s
ci / build & push to registry (push) Has been skipped

This commit is contained in:
AdrianoDev
2026-04-28 23:51:01 +02:00
parent b218ac3a2c
commit ad3f542c0f
@@ -37,25 +37,26 @@ Approccio adottato:
obsoleto, troppo aggregato, perde la granularità sui 4 ruoli
istituzionali.
Motivazione: i due report coprono i 13 simboli watchlist con la
massima granularità senza overlap.
Motivazione: i due report coprono i 13 simboli watchlist con la massima
granularità senza overlap.
## 3. Sorgenti dati
API CFTC pubblica (no API key richiesta), endpoint Socrata:
`https://publicreporting.cftc.gov/resource/<dataset>.json`.
| Report | Dataset ID | Frequenza | Contenuto |
|--------|-----------|-----------|-----------|
| TFF F&O combined | `gpe5-46if` | settimanale (ven 15:30 ET) | Dealer/Intermediary, Asset Manager, Leveraged Funds, Other Reportables |
| Disaggregated F&O combined | `72hh-3qpy` | settimanale (ven 15:30 ET) | Producer/Merchant, Swap Dealer, Managed Money, Other Reportables |
| Report | Dataset ID | Frequenza | Contenuto |
| -------------------------- | ----------- | --------------------------- | -------------------------------------------------------------------- |
| TFF F&O combined | `gpe5-46if` | settimanale (ven 15:30 ET) | Dealer/Intermediary, Asset Manager, Leveraged Funds, Other Reportables |
| Disaggregated F&O combined | `72hh-3qpy` | settimanale (ven 15:30 ET) | Producer/Merchant, Swap Dealer, Managed Money, Other Reportables |
Dati osservati al **martedì** della settimana, pubblicati il
**venerdì** seguente alle 15:30 ET.
Dati osservati al **martedì** della settimana, pubblicati il **venerdì**
seguente alle 15:30 ET.
## 4. Watchlist simboli
### TFF
- `ES` (E-mini S&P 500)
- `NQ` (E-mini Nasdaq-100)
- `RTY` (E-mini Russell 2000)
@@ -66,6 +67,7 @@ Dati osservati al **martedì** della settimana, pubblicati il
- `DX` (US Dollar Index)
### Disaggregated
- `CL` (Crude Oil WTI)
- `GC` (Gold)
- `SI` (Silver)
@@ -74,18 +76,20 @@ Dati osservati al **martedì** della settimana, pubblicati il
- `ZC` (Corn)
- `ZS` (Soybeans)
Mapping `ticker → cftc_contract_market_code` mantenuto in costante
nel modulo (es. ES → `13874A`, CL → `067651`). I codici sono pubblici
CFTC e non cambiano.
Mapping `ticker → cftc_contract_market_code` mantenuto in costante nel
modulo (es. ES → `13874A`, CL → `067651`). I codici sono pubblici CFTC e
non cambiano.
## 5. Tool MCP esposti
Tre tool, tutti `reads` (core + observer):
### 5.1 `get_cot_tff(symbol, lookback_weeks=52)`
Ritorna serie temporale TFF per un simbolo equity/financial.
Output:
```json
{
"symbol": "ES",
@@ -98,24 +102,26 @@ Output:
"lev_funds_long": 100000, "lev_funds_short": 350000, "lev_funds_net": -250000,
"other_long": 50000, "other_short": 50000, "other_net": 0,
"open_interest": 2500000
},
...
}
],
"data_timestamp": "2026-04-27T20:00:00Z"
}
```
### 5.2 `get_cot_disaggregated(symbol, lookback_weeks=52)`
Stessa shape, campi diversi: `producer_*`, `swap_*`, `managed_money_*`,
`other_*`.
### 5.3 `get_cot_extreme_positioning(lookback_weeks=156)`
Scanner che restituisce, per ogni simbolo della watchlist, il
percentile storico (1y o 3y) dell'ultimo *net position* per il ruolo
chiave (Leveraged Funds per TFF, Managed Money per Disaggregated).
Flagga estremi a percentili ≤ 5 o ≥ 95.
Scanner che restituisce, per ogni simbolo della watchlist, il percentile
storico (1y o 3y) dell'ultimo *net position* per il ruolo chiave
(Leveraged Funds per TFF, Managed Money per Disaggregated). Flagga
estremi a percentili ≤ 5 o ≥ 95.
Output:
```json
{
"lookback_weeks": 156,
@@ -127,8 +133,7 @@ Output:
"percentile": 3.2,
"signal": "extreme_short",
"report_date": "2026-04-22"
},
...
}
],
"data_timestamp": "2026-04-27T20:00:00Z"
}
@@ -138,7 +143,7 @@ Output:
## 6. Architettura
```
```text
mcp-macro/
src/mcp_macro/
fetchers.py # esistente — aggiunge fetch_cot_tff, fetch_cot_disaggregated, fetch_cot_extreme_positioning
@@ -175,18 +180,21 @@ testata indipendentemente dal layer HTTP. I fetcher async usano
## 9. Test plan
Pure-logic (no HTTP):
- `compute_percentile(value, history)` con casi noti.
- `classify_extreme(percentile, threshold=5)` → boundary cases.
- `parse_tff_row()` e `parse_disaggregated_row()` su payload Socrata
mock (campi reali documentati).
Integration (httpx_mock):
- `fetch_cot_tff("ES", lookback_weeks=52)` con risposta CFTC mock →
verifica shape output + ordering rows ASC per data.
- `fetch_cot_extreme_positioning()` con dati che includono casi
extreme + casi neutral → verifica filtering e signal.
- `fetch_cot_extreme_positioning()` con dati che includono casi extreme
+ casi neutral → verifica filtering e signal.
ACL test (TestClient):
- `POST /tools/get_cot_tff` con core/observer/no-auth → 200/200/401.
- `POST /tools/get_cot_extreme_positioning` idem.