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