When the Fed publishes a statement, when a tariff lands, when a tanker is hit in the Strait of Hormuz, markets move in seconds. Squawk Box watches the sources that matter, explains what a headline means for which assets and why, and can optionally hand it to a risk-gated executor, all on your own machine. Paper trading is the default and nothing leaves your computer unless you configure it to.
Research software, not financial advice. News trading is hard and a language model can be wrong. Nothing here is a promise of profit. See Safety.
| π Fundamental signal cards | Each tradeable headline becomes a card: affected assets (indices, yields, USD, gold, oil, BTC, tickers) with a direction each, a one-line thesis, time horizon, source reliability, confirmations, and what would invalidate the call. Retractions and contradictions mark earlier cards invalid. The macro playbook is a plain TOML file you can read and edit. |
| β±οΈ Speed layer | Trusted headlines are broadcast the instant they are classified, before the LLM finishes. Official sources are burst-polled around scheduled releases using the built-in economic calendar. Per-source latency stats show who reports first. No speed is promised; measure it on your own connection. |
| π Surprise engine | CPI, NFP, claims, GDP and similar releases are compared with forecast without waiting for a model: CPI y/y 3.4% vs 3.1% exp (prev 3.2%): HOT +0.3pp -> hawkish. It stays silent when direction, units or forecast are uncertain. |
| π Honest track record | Every card leg is priced at signal time and +1/+5/+15/+60 minutes later, with sample sizes, confidence intervals and an "insufficient data" flag. Unpriced assets are excluded, never guessed. |
| π Subscriber API | Hashed API keys with plans and entitlements, polling, Server-Sent Events with replay, and HMAC-signed webhooks with per-subscriber filters, ready for a paid feed. |
| ποΈ Watchlists and filings | Watch tickers and themes; SEC 8-K item codes are classified and tied to tickers. A daily pre-market briefing summarises cards, the day's calendar and yesterday's track record. |
| π‘ 40 verified sources | Fed, ECB, BoE, BoJ, BLS, Census, EIA, White House, SEC (press and 8-K), CNBC, WSJ, FT, MarketWatch, BBC, investingLive, FinancialJuice, crypto desks, plus targeted Google News queries. Optional Telegram channels. |
| 𧬠Cross-source dedup | The same story from five outlets becomes one headline with a confirmation count, not five trades. Reversals ("raises" vs "cuts", "agrees" vs "rejects") are deliberately kept apart. |
| π― Impact-scored filtering | Regex matrix with 13 categories, a noise gate for clickbait, negation-aware sentiment and a 0-100 impact score. |
| π§ Pluggable LLM | Local Ollama (DeepSeek R1 by default) or any OpenAI-compatible endpoint. Strict output validation: bad confidence values or unknown instruments become NO_TRADE. |
| π Graceful degradation | If the model is down, a deterministic rules-based signal keeps the dashboard informative. Its confidence is capped below the trading threshold, so it never trades by default. |
| π‘οΈ Real risk management | Position-size tiers, per-instrument cooldowns, conflict suppression, trailing stops, max duration, max open positions, and a daily loss breaker (USD or %) that survives restarts. |
| π Alerts | Discord, Slack and Telegram-bot webhooks with rate limiting and retries. |
| π§ͺ Backtester | Replay historical headlines through the same risk rules with next-bar fills, fees, slippage and the conservative stop-first rule. Outputs metrics and an HTML report. |
| π₯οΈ Live dashboard | Headlines, signals, positions, equity curve, market mood, source health and optional text-to-speech squawk. |
| π Secure by default | Binds to localhost, optional API key, CSRF header and Origin checks, WebSocket origin check. |
| π¦ Ships ready | Docker, docker-compose, Makefile, squawkbox doctor setup check, 700+ offline tests, CI. |
Trading view: signals, positions, equity curve and market mood
News feed: every headline tagged by source, category and confirmations
40 feeds + Telegram ββΆ ingestion ββΆ dedup ββΆ filters ββΆ LLM (or rules fallback)
β
dashboard / WebSocket βββ alerts βββ signal manager (risk gates)
β
paper β Binance executor
Details and a full diagram are in docs/ARCHITECTURE.md. Signal cards for discretionary traders, the track record and the key-authenticated API (polling, SSE, signed webhooks) are described there and in docs/SUBSCRIBER_API.md.
Requirements: Python 3.11+ and, for the default model, Ollama.
git clone https://github.com/Kiankk/squawk-box.git
cd squawk-box
pip install -r requirements.txt
ollama pull deepseek-r1:14b # skip if you use an OpenAI-compatible provider
cp .env.example .env # then edit; every setting is optional to start
python -m squawkbox doctor # checks config, database, model and feeds, and tells you how to fix problems
python -m squawkbox run # dashboard at http://127.0.0.1:8000cp .env.example .env
make docker-up # app only
make docker-up WITH_OLLAMA=1 # app + bundled OllamaWhen the dashboard is reached through a published Docker port, set SQUAWK_API_KEY in .env. The trading buttons ask for it once.
LLM_PROVIDER=openai_compatible
LLM_BASE_URL=https://your-endpoint/v1
LLM_API_KEY=...
LLM_MODEL=...Try it on the bundled synthetic sample (made-up data that shows the harness works, not how the strategy performs):
make backtest-demoBacktest your own history by exporting what the live system recorded:
python -m backtest.export --help
python -m backtest --headlines my_headlines.jsonl --prices-source ccxt --exchange binance --timeframe 1mSignals fill at the next bar open after the headline, never on the bar it arrived in. If a stop and target are both hit in one bar, the stop wins. Read docs/BACKTESTING.md for the file formats and the known limits, such as drawdown measured on closed trades only.
Everything is controlled by environment variables (see .env.example) and trading_config.py. The full reference is docs/CONFIGURATION.md. The common ones:
| Variable | Default | Meaning |
|---|---|---|
EXECUTOR |
paper |
paper or binance |
LLM_PROVIDER |
ollama |
ollama or openai_compatible |
MAX_DAILY_LOSS_USD / MAX_DAILY_LOSS_PCT |
500 / 5 |
Daily circuit breaker; the tighter limit applies |
SQUAWK_API_KEY |
empty | Protects trading controls |
SQUAWK_DISABLED_SOURCES |
empty | Turn individual feeds off |
DISCORD_WEBHOOK_URL, SLACK_WEBHOOK_URL, TELEGRAM_BOT_TOKEN |
empty | Alert channels |
Sources live in sources.py with a reliability weight and poll interval. Official sources such as the Fed and BLS carry the highest weights.
| Endpoint | Purpose |
|---|---|
GET /api/health |
Uptime, ingesters, model reachability, database, executor mode |
GET /api/sources |
Per-source health: last success, last error, items seen, failures |
GET /api/calendar |
Upcoming high-impact economic releases, calendar fetch status and the burst-polling schedule (?hours=&impact=¤cies=) |
GET /api/releases |
Recent DATA_RELEASE signals from the surprise engine (actual vs forecast, polarity, impact map) |
GET /api/latency |
Detection and pipeline latency: median/p90 detect lag and first-to-report rate per source (?window_min=) |
GET /api/headlines, /api/stats, /api/prices |
Recent headlines, counters, live prices |
GET /api/trading/status, /positions, /trades, /signals, /performance |
Trading state |
POST /api/trading/toggle, /close-all, /close/{id} |
Controls. Require X-API-Key when a key is set, otherwise localhost only plus an X-Requested-With: squawkbox header. toggle takes {"enabled": true|false} |
WS /ws |
Live stream for the dashboard |
- Paper by default.
EXECUTOR=binanceruns on the Binance testnet unless you also setBINANCE_LIVE_CONFIRMto the exact confirmation phrase from.env.example. Without API keys it falls back to paper. - Unverified state never trades. The Binance executor refuses new entries until it has checked your balance and existing positions. Exits are always allowed.
- Exchange-side protection. Stops and targets are placed on the exchange and exits are reduce-only.
- The exchange code is tested against fake exchanges only. Run it on the testnet for a good while before you consider real money.
- The model is not trusted. Confidence is validated, unknown instruments are rejected, and fallback signals cannot trade at default settings.
- The default server binds to
127.0.0.1. Put it behind TLS and setSQUAWK_API_KEYbefore exposing it anywhere: with the key set, the card feed, briefing, track record and/wsneed it too. To serve subscribers publicly, expose only/api/v1through a reverse proxy (seedocs/SUBSCRIBER_API.md).
pip install -r requirements-dev.txt
make check # ruff + pytest, same as CIThe suite runs fully offline. Contributions are welcome: if the filters miss a headline type, open an issue with the source and timestamp.
- X/Twitter ingestion
- Multi-model voting (ensemble of local models)
- Per-bar mark-to-market drawdown in the backtester
- More instruments on the live executor (currently crypto perpetuals)
- Browser extension for one-click headline injection
See CHANGELOG.md for what has shipped.
β Star the repo to follow along.

