Automated Commitment of Traders (COT) analysis system that detects hedge fund positioning divergences and extreme levels, delivering weekly email reports via n8n.
Based on: Swing Trading Strategy Framework - Verified Traders Roundtable
cot_monitor.py- Main Python script for COT analysisrequirements.txt- Python dependenciesconfig.json- Configuration file (assets, webhook URL)n8n_cot_workflow.json- Ready-to-import n8n workflowREADME.md- This file
Monitors 7 Assets:
- NQ (Nasdaq 100)
- SPX (S&P 500)
- BTC (Bitcoin)
- ETH (Ethereum)
- EUR (Euro FX)
- USD (US Dollar Index)
- GOLD (Gold)
Detects 4 Signal Types:
- Bullish Divergence - Price new low, hedge funds higher low
- Bearish Divergence - Price new high, hedge funds lower high
- Extreme Bullish - Hedge funds at 3-year max bearish (contrarian buy)
- Extreme Bearish - Hedge funds at 3-year max bullish (contrarian sell)
Delivers:
- Beautiful HTML email every Sunday
- Summary of active signals
- Full positioning data for all assets
- Playbook guidance for each signal
pip install -r requirements.txt- Open your n8n cloud instance
- Click Workflows β Import from File
- Upload
n8n_cot_workflow.json - Open the "Send Email" node
- Configure with your Gmail account (OAuth2)
- Update the recipient email address
- Click "Webhook" node to see your webhook URL
- Copy the webhook URL (looks like:
https://your-n8n.app/webhook/cot-report) - Save & Activate the workflow
Edit config.json and update:
{
"n8n_webhook_url": "https://your-n8n.app/webhook/cot-report",
...
}python3 cot_monitor.pyExpected output:
======================================================================
COT SMART MONEY MONITOR
======================================================================
Run time: 2025-11-11 11:30:00
β Loaded configuration from config.json
π Analyzing Nasdaq 100 (NQ)...
Fetching NASDAQ-100 MINI...
β Retrieved 156 weeks of data
Status: NEUTRAL
HF Net: 15,234
[... continues for all assets ...]
======================================================================
SUMMARY
======================================================================
Assets analyzed: 7
Active signals: 2
π¨ ACTIVE SIGNALS:
β’ Nasdaq 100 (NQ): π₯ BULLISH DIVERGENCE
β’ Gold (GOLD): β οΈ EXTREME BULLISH
πΎ Report saved: cot_report_20251111.json
π€ Sending to webhook: https://your-n8n.app/webhook/cot-report
β Webhook delivered successfully
β Analysis complete!
======================================================================
Check your email! You should receive the formatted COT report.
- β 100% free tier with cron jobs
- β Runs every Sunday automatically
- β No server management
- β Built-in monitoring
-
Create Render Account
- Go to https://render.com
- Sign up (free)
-
Create New Cron Job
- Dashboard β "New +" β "Cron Job"
- Name:
cot-monitor - Runtime: Python 3
- Build Command:
pip install -r requirements.txt - Command:
python cot_monitor.py - Schedule:
0 17 * * 5(Every Friday 5pm EST - when COT data drops)
-
Connect Your Repository
Option A: Upload via GitHub
- Create a private GitHub repo
- Push all files (
cot_monitor.py,requirements.txt,config.json) - Connect repo to Render
Option B: Upload Directly
- Zip all files
- Upload to Render dashboard
-
Set Environment Variables (Optional)
- In Render dashboard, go to Environment
- Add:
N8N_WEBHOOK_URL= your webhook URL - Update
cot_monitor.pyto read from env var instead of config.json
-
Deploy
- Click "Create Cron Job"
- Wait for first build (~1-2 minutes)
- View logs to confirm success
Your Sunday email will look like this:
π COT Smart Money Report
Week ending November 10, 2025
π¨ ACTIVE SIGNALS
β’ Nasdaq 100 (NQ): π₯ BULLISH DIVERGENCE (Net: 15,234)
β’ Gold (GOLD): β οΈ EXTREME BULLISH (Net: -45,678)
π All Assets Summary
Code | Asset | HF Net | Status | Guidance
------|--------------------|-----------|--------------------|-------------------
NQ | Nasdaq 100 | +15,234 | π₯ BULLISH DIV | Wait for retracement
SPX | S&P 500 | +45,123 | NEUTRAL | Monitor
BTC | Bitcoin | -8,456 | NEUTRAL | Monitor
ETH | Ethereum | -2,345 | NEUTRAL | Monitor
EUR | Euro FX | +12,678 | NEUTRAL | Monitor
USD | US Dollar Index | -5,432 | NEUTRAL | Monitor
GOLD | Gold | -45,678 | β οΈ EXTREME BULL | Contrarian long zone
π Playbook Reminder
β’ Bullish Divergence: Price makes new low, but hedge funds make higher low
β’ Bearish Divergence: Price makes new high, but hedge funds make lower high
β’ Extreme Positioning: Hedge funds at 3-year max = contrarian opportunity
β’ Next Step: Use technical analysis to time entry on retracements
Edit config.json:
"assets": {
"YOUR_CODE": {
"name": "Display Name",
"contract_name": "EXACT CFTC CONTRACT NAME",
"cftc_code": "CFTC_CODE"
}
}Find CFTC contract names: https://publicreporting.cftc.gov/
Render Cron Syntax:
0 17 * * 5= Every Friday 5pm EST0 9 * * 0= Every Sunday 9am0 */6 * * *= Every 6 hours
When does COT data update?
- Released every Friday at 3:30pm EST
- Set cron for 5pm EST to ensure data is available
Edit config.json:
"lookback": {
"divergence_weeks": 52, // 1 year
"extreme_weeks": 156 // 3 years
}Modify n8n workflow:
- Add Telegram node after "Format Email"
- Add Discord webhook node
- Add Slack notification node
- All nodes receive same data
Cause: CFTC contract name doesn't match API Fix: Verify contract names at https://publicreporting.cftc.gov/resource/gpe5-46if.json
Example query:
https://publicreporting.cftc.gov/resource/gpe5-46if.json?$select=contract_market_name&$group=contract_market_name
Cause: Incorrect webhook URL or n8n workflow not activated Fix:
- Check n8n workflow is Activated (toggle in top-right)
- Copy webhook URL directly from n8n webhook node
- Test webhook with curl:
curl -X POST https://your-n8n.app/webhook/cot-report \ -H "Content-Type: application/json" \ -d '{"test": "data"}'
Fix:
- In n8n, re-authenticate Gmail node
- Use OAuth2 (not SMTP)
- Grant all required permissions
Cause: CFTC API slow or down Fix: The script has 30-second timeouts. If CFTC is down, wait and retry later.
Primary: CFTC Socrata API
- Endpoint: https://publicreporting.cftc.gov/resource/gpe5-46if.json
- Report: Traders in Financial Futures (TFF)
- Update Schedule: Every Friday 3:30pm EST
- Rate Limit: None (public API)
- Cost: 100% Free
Alternative: CFTC Legacy Reports
- If Socrata API unavailable, script can be modified to parse legacy text files
- Less reliable but backup option
- config.json contains webhook URL - Don't commit to public repos
- Add to .gitignore:
config.json cot_report_*.json - Render Environment Variables - Use for production webhook URL
- n8n Webhook - No authentication by default. Add basic auth if needed.
Phase 2: Price Integration
- Fetch actual price data to improve divergence detection
- Currently uses HF positioning trends as proxy
Phase 3: Backtesting
- Historical signal performance
- Win rate analysis
- Optimal entry timing
Phase 4: Altcoin Indicator (Arkham MCP)
- On-chain whale wallet tracking
- Smart money accumulation for SOL, AVAX, HYPE
- Same divergence logic, blockchain data
- CFTC COT Reports: https://www.cftc.gov/MarketReports/CommitmentsofTraders/index.htm
- Playbook Source: Titans of Tomorrow Podcast - Verified Traders Roundtable
- n8n Docs: https://docs.n8n.io
- Render Docs: https://render.com/docs
- Python installed (3.8+)
- Dependencies installed (
pip install -r requirements.txt) - n8n workflow imported and activated
- Gmail connected in n8n
- Webhook URL copied to config.json
- Test run successful (
python3 cot_monitor.py) - Email received
- Deployed to Render (optional)
- First automated run verified
Issues?
- Check logs:
cot_report_YYYYMMDD.json - Verify n8n workflow is active
- Test webhook manually with curl
- Confirm CFTC API is accessible
Need Help?
- Review troubleshooting section above
- Check CFTC API status
- Verify contract names match exactly
Built with:
- Python 3
- CFTC Socrata API
- n8n workflow automation
- Render.com hosting
Last Updated: November 11, 2025