An automated multi-page Streamlit platform and CFTC Legacy Futures scraper for tracking weekly institutional non-commercial positioning, side-by-side asset orderflow divergence, and historical order-injection rankings across 21 Forex, Crypto, Equity Index, Metals, and Energy futures contracts.
Overview โข Pages & Features โข Methodology โข 21 Tracked Assets โข Architecture โข Structure โข Setup โข License
Cot-Reports automates the ingestion and quantitative analysis of weekly Commodity Futures Trading Commission (CFTC) Commitments of Traders (deacot) legacy futures reports. By isolating Non-Commercial (speculative / institutional) long and short futures contracts, the platform enables macro and FX traders to monitor weekly institutional orderflow, spot diverging currency pair positioning, and rank the strongest contract inflows relative to each market's historical distribution.
When launched, the Streamlit home page (0_๐_Accueil.py) automatically checks the freshness of local CSV datasets (csv_folder/forex/eur.csv). If datasets are missing or older than 7 days, it invokes main_scraper.py to fetch annual deacot{year}.zip archives directly from cftc.gov, parses all 21 configured contract codes, and updates csv_folder/ on disk.
UI Language Note: While this documentation is written in English, the Streamlit page titles, sidebar links, and explanatory labels in
0_๐_Accueil.py,pages/1_โ๏ธ_Comparateur d'actifs.py, andpages/2_๐ธ_Meilleures_metriques.pyare presented in French.
| Page File | UI Title (French) | Core Analytical Functionality |
|---|---|---|
0_๐_Accueil.py |
Commitments of traders - Datas | Auto-freshness check (check_for_updates() triggers download_and_process_cot_data([2025, 2026]) if data is absent or |
pages/1_โ๏ธ_Comparateur d'actifs.py |
Comparateur d'actifs financiers | Side-by-side weekly institutional positioning comparison for any two of the 21 contracts (default: EUR vs. USD) over a user-selected lookback slider. Renders a seaborn diverging gradient on Net position, zero-aligned positive/negative bars on Change long and Change short, and CSV export buttons. |
pages/2_๐ธ_Meilleures_metriques.py |
Plus grosses injections d'ordres des derniers rapports COT | Ranks all 21 assets by the historical significance of their latest weekly orderflow injection, split into Long Injection Rankings (Classement positions long) and Short Injection Rankings (Classement positions short) formatted via millify. |
main_scraper.py |
(CLI / Module Scraper) | Downloads annual CFTC deacot{year}.zip bundles, extracts Non-Commercial Long/Short levels and weekly changes, computes Net position, deduplicates dates (DD/MM/YY newest-first), and writes standardized CSVs into csv_folder/<category>/. |
For each weekly report date
Each exported CSV stores Date, Long, Short, Change long, Change short, Net position, url_report, and type.
For every historical report row of an asset, ranking() decomposes weekly contract changes into directional buying flow (
- All historical positive flows (
$\Delta_{\text{flow}, t} \ge 0$ ) are sorted descending; all negative flows ($\Delta_{\text{flow}, t} < 0$ ) are sorted ascending (most negative first). - The latest week's flow (
$\Delta_{\text{flow}, 0}$ ) receives an intra-asset historical rank (Rank 1= largest positive or negative weekly orderflow injection in the dataset). - All 21 assets are then sorted across markets by their
Rankto surface which futures contracts experienced unusually extreme institutional capital flows in the latest CFTC release.
ALL_ASSET in main_scraper.py tracks 21 contracts across 5 asset categories (csv_folder/):
Category (csv_folder/) |
Asset | CSV File | CFTC Market Code | Report Group |
|---|---|---|---|---|
Forex (forex/) |
Euro (EUR) |
eur.csv |
099741 |
deacmesf |
Forex (forex/) |
Japanese Yen (JPY) |
jpy.csv |
097741 |
deacmesf |
Forex (forex/) |
Australian Dollar (AUD) |
aud.csv |
232741 |
deacmesf |
Forex (forex/) |
New Zealand Dollar (NZD) |
nzd.csv |
112741 |
deacmesf |
Forex (forex/) |
Canadian Dollar (CAD) |
cad.csv |
090741 |
deacmesf |
Forex (forex/) |
British Pound (GBP) |
gbp.csv |
096742 |
deacmesf |
Forex (forex/) |
Swiss Franc (CHF) |
chf.csv |
092741 |
deacmesf |
Forex (forex/) |
Mexican Peso (MXN) |
mxn.csv |
095741 |
deacmesf |
Forex (forex/) |
Brazilian Real (BRL) |
brl.csv |
102741 |
deacmesf |
Forex (forex/) |
South African Rand (ZAR) |
zar.csv |
122741 |
deacmesf |
Forex (forex/) |
US Dollar Index (USD) |
usd.csv |
098662 |
deanybtsf |
Crypto (crypto/) |
Bitcoin (BTC) |
btc.csv |
133741 |
deacmesf |
Crypto (crypto/) |
Ethereum (ETH) |
eth.csv |
146021 |
deacmesf |
Index (index/) |
NASDAQ-100 (NASDAQ-100) |
nasdaq-100.csv |
209742 |
deacmesf |
Index (index/) |
S&P 500 (S&P 500) |
s&p 500.csv |
13874A |
deacmesf |
Index (index/) |
Dow Jones (DOW JONES) |
dow jones.csv |
124603 |
deacbtsf |
Metals (metals/) |
Silver (SILVER) |
silver.csv |
084691 |
deacmxsf |
Metals (metals/) |
Copper (COPPER) |
copper.csv |
085692 |
deacmxsf |
Metals (metals/) |
Gold (GOLD) |
gold.csv |
088691 |
deacmxsf |
Other (other/) |
Crude Oil (OIL) |
oil.csv |
067651 |
deanymesf |
Other (other/) |
Natural Gas (GAS) |
gas.csv |
023651 |
deanymesf |
flowchart TD
CFTC["CFTC Historical Archives\n(cftc.gov/files/dea/history/deacot{year}.zip)"] --> Scraper["main_scraper.py\ndownload_and_process_cot_data()"]
Scraper --> Store["csv_folder/\ncrypto/, forex/, index/, metals/, other/ (21 CSVs)"]
Home["0_๐_Accueil.py\ncheck_for_updates() (7+ days check)"] -->|"Triggers refresh if stale/missing"| Scraper
Store --> Home
Store --> Comp["pages/1_โ๏ธ_Comparateur d'actifs.py\nSide-by-Side Styler Tables & CSV Export"]
Store --> Metrics["pages/2_๐ธ_Meilleures_metriques.py\nranking() Long & Short Flow Leaderboards"]
Cot-Reports/
โโโ .streamlit/
โ โโโ config.toml # Streamlit dark theme (#0E1117 background)
โโโ csv_folder/
โ โโโ crypto/ # btc.csv, eth.csv
โ โโโ forex/ # aud.csv, brl.csv, cad.csv, chf.csv, eur.csv, gbp.csv, jpy.csv, mxn.csv, nzd.csv, usd.csv, zar.csv
โ โโโ index/ # dow jones.csv, nasdaq-100.csv, s&p 500.csv
โ โโโ metals/ # copper.csv, gold.csv, silver.csv
โ โโโ other/ # gas.csv, oil.csv
โโโ deacot2025_extracted/
โ โโโ annual.txt # Extracted CFTC 2025 annual report dataset
โโโ pages/
โ โโโ 1_โ๏ธ_Comparateur d'actifs.py # Dual-asset COT comparison & diverging heatmap tables
โ โโโ 2_๐ธ_Meilleures_metriques.py # Historical order-injection ranking dashboard
โโโ .gitattributes
โโโ .gitignore
โโโ 0_๐_Accueil.py # Main Streamlit entrypoint & auto-update controller
โโโ LICENSE # MIT License
โโโ README.md # Project documentation
โโโ deacot2025.zip # Local 2025 CFTC annual archive
โโโ ideas.txt # French feature backlog & research notes
โโโ main_scraper.py # CFTC ZIP downloader & per-asset CSV generator
โโโ requirements.txt # Dependencies (streamlit, pandas, seaborn, requests, millify)
- Python:
3.9+ - Internet access when refreshing weekly reports from
cftc.gov(bundledcsv_folder/allows immediate offline exploration)
git clone https://github.com/khalid-naami/Cot-Reports.git
cd Cot-ReportsWindows (PowerShell):
python -m venv .venv
.\.venv\Scripts\Activate.ps1
pip install -r requirements.txtmacOS / Linux:
python3 -m venv .venv
source .venv/bin/activate
pip install -r requirements.txtpython main_scraper.pystreamlit run 0_๐_Accueil.pyNavigate between Accueil, Comparateur d'actifs, and Meilleures metriques in the Streamlit sidebar.
- Regulatory Market Data: U.S. Commodity Futures Trading Commission (cftc.gov) Legacy Futures-Only annual archives (
deacot2025.zip/deacot2026.zip).
Disclaimer: Commitments of Traders data reflects lagged Tuesday institutional/non-commercial futures positioning released weekly by the CFTC. This dashboard is strictly for macroeconomic and quantitative market research and does not constitute trading or financial advice.
Released under the MIT License. See LICENSE for full terms.