Skip to content

About

πŸ“‘ Real-time financial news trading engine β€” LLM-powered (DeepSeek R1 via Ollama) headline analysis with automated futures/crypto execution. Telegram + RSS + SEC ingestion, FastAPI dashboard, paper + live Binance modes.

Topics

Resources

Stars

1 star

Watchers

0 watching

Forks

Latest commit

Β 

History

88 Commits

Folders and files

NameName
Last commit message
Last commit date
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 

Repository files navigation

⚑ Squawk Box

Fundamental news signals, fast: 40 live sources in, structured signal cards out. Built for traders who trade the news, not the chart.

CI Python Mode

Trading View

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.


✨ What you get

πŸƒ 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.

πŸ–ΌοΈ Screenshots

Trading view: signals, positions, equity curve and market mood

Trading View

News feed: every headline tagged by source, category and confirmations

News Feed


πŸ—οΈ How it works

 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.


πŸš€ Quick start

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:8000

Docker

cp .env.example .env
make docker-up                   # app only
make docker-up WITH_OLLAMA=1     # app + bundled Ollama

When the dashboard is reached through a published Docker port, set SQUAWK_API_KEY in .env. The trading buttons ask for it once.

No GPU? Use a hosted model

LLM_PROVIDER=openai_compatible
LLM_BASE_URL=https://your-endpoint/v1
LLM_API_KEY=...
LLM_MODEL=...

πŸ§ͺ Backtesting

Try it on the bundled synthetic sample (made-up data that shows the harness works, not how the strategy performs):

make backtest-demo

Backtest 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 1m

Signals 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.


βš™οΈ Configuration

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.


πŸ”Œ API

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=&currencies=)
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

πŸ›‘οΈ Safety first

  • Paper by default. EXECUTOR=binance runs on the Binance testnet unless you also set BINANCE_LIVE_CONFIRM to 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 set SQUAWK_API_KEY before exposing it anywhere: with the key set, the card feed, briefing, track record and /ws need it too. To serve subscribers publicly, expose only /api/v1 through a reverse proxy (see docs/SUBSCRIBER_API.md).

🧰 Development

pip install -r requirements-dev.txt
make check          # ruff + pytest, same as CI

The suite runs fully offline. Contributions are welcome: if the filters miss a headline type, open an issue with the source and timestamp.


πŸ—ΊοΈ Roadmap

  • 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.

About

πŸ“‘ Real-time financial news trading engine β€” LLM-powered (DeepSeek R1 via Ollama) headline analysis with automated futures/crypto execution. Telegram + RSS + SEC ingestion, FastAPI dashboard, paper + live Binance modes.

Topics

Resources

Stars

1 star

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages