Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Apteryx-T/PokieTicker

Repository files navigation

PokieTicker β€” Understand the "Why" Behind Every Price Move

πŸ”— Live Demo: mitrui.com/PokieTicker | Buy Me A Coffee

Since I wanted to understand the stories behind candlestick charts, I vibe coded this app.

As a stock market beginner, the news was too fragmented and I was wasting a lot of time, never understanding why prices went up or down. I built PokieTicker to develop event-driven thinking β€” to understand the "why" behind every price move.

Watch Demo

Click to watch the full demo video

What It Does

  • News on the chart β€” Dots on the candlestick chart represent news for each date. Click any dot to see the news impacting that company at the time.
  • Filter by impact type β€” Market, earnings, product, policy, competition, or management. Click a category to see related bullish or bearish news.
  • Find similar events β€” Discover historical days with similar news patterns and see what happened to the stock afterward.
  • AI explains price moves β€” Select a date range and ask AI why the stock dropped or rallied. It tells you what events caused it.
  • Predict trends β€” Based on the past 30 days of news events, the model predicts how these events might affect future price direction.

screenshot

How the Prediction Works

PokieTicker includes an XGBoost-based prediction system that combines news sentiment with technical indicators:

Features (31 total):

  • News features β€” article count, sentiment score, positive/negative ratio, 3/5/10-day rolling averages, sentiment momentum
  • Technical features β€” price returns (1/3/5/10-day), volatility, volume ratio, RSI-14, moving average crossover

How it works:

  1. News articles are scored for sentiment by Claude Haiku (batch API) β€” each article gets a sentiment label, key discussion summary, and bullish/bearish reasons
  2. These are combined with OHLC price data into daily feature vectors
  3. XGBoost classifiers predict up/down direction at T+1, T+3, and T+5 horizons
  4. The system also finds historically similar periods (cosine similarity on feature vectors) and shows what happened next

Why news-driven prediction can work:

  • Stock prices are driven by information. Major news events (earnings, policy changes, product launches) create predictable short-term momentum
  • Sentiment clustering matters β€” when multiple negative articles cluster on the same day, the downward pressure tends to persist for 1-3 days
  • Historical pattern matching works because markets react similarly to similar events (e.g., tariff announcements, FDA approvals, earnings beats)

This is an experimental tool for learning, not financial advice. Markets are complex and no model captures everything.

Architecture

Frontend (React + Vite + D3.js) Backend (FastAPI + SQLite)
+---------------------------------+ +----------------------------+
| CandlestickChart (D3.js) | | /api/stocks/{sym}/ohlc |
| +- news dots on each date |----->| /api/news/{sym}?date= |
| +- crosshair + click to lock | | /api/news/{sym}/categories|
| | | |
| NewsPanel (right sidebar) |<-----| SQLite: pokieticker.db |
| +- sentiment sorted | | +- ohlc (51K+ rows) |
| +- up/down reasons | | +- news_raw (61K+) |
| +- T+1/T+5 returns | | +- layer1_results (97K+) |
| | | |
| PredictionPanel |<-----| /api/predict/{sym}/forecast|
| +- 7-day & 30-day forecasts | | +- XGBoost models |
| +- similar historical periods | | +- cosine similarity |
+---------------------------------+ +----------------------------+

Data Pipeline

Polygon API --> Layer 0 (rule filter) --> Layer 1 (Haiku Batch API) --> Layer 2 (Sonnet, on-demand)
 OHLC + News reject spam/listicles sentiment + up/down reasons deep analysis on click
 ~17% rejected 50 articles per batch call cached in DB

Quick Start

The repo includes a pre-built database (pokieticker.db) with historical data, so you can run it immediately β€” no API keys needed.

git clone https://github.com/owengetinfo-design/PokieTicker.git
cd PokieTicker
# Unpack the pre-built database and models
gunzip -k pokieticker.db.gz
tar xzf models.tar.gz -C backend/ml/
# Backend (Python 3.10+)
python -m venv venv
source venv/bin/activate # Windows: venv\Scripts\activate
pip install -r requirements.txt
# Frontend (Node.js 18+)
cd frontend && npm install && cd ..

Then start both services (in two terminal windows):

# Terminal 1: Backend
source venv/bin/activate
uvicorn backend.api.main:app --reload
# Terminal 2: Frontend
cd frontend && npm run dev

Open http://localhost:7777/PokieTicker/ and you're done.

Just want to see the demo? Visit mitrui.com/PokieTicker β€” no setup needed.

Updating data (optional)

If you want to fetch the latest stock data and run AI analysis, you'll need API keys:

cp .env.example .env
# Edit .env and fill in your keys:
Key Where to get it Cost
POLYGON_API_KEY polygon.io Free tier
ANTHROPIC_API_KEY console.anthropic.com Pay-as-you-go
# Fetch new OHLC + news
python -m backend.bulk_fetch
# Run AI analysis
python -m backend.batch_submit --top 50
python -m backend.batch_collect <batch_id>

Project Structure

.env # API keys (gitignored)
pokieticker.db # SQLite database (gitignored)
requirements.txt # Python dependencies
backend/
 config.py # pydantic-settings, loads .env
 database.py # 9-table SQLite schema
 bulk_fetch.py # Bulk download OHLC + news for many tickers
 batch_submit.py # Submit Layer 1 to Anthropic Batch API
 batch_collect.py # Collect Batch API results
 weekly_update.py # Incremental weekly data update
 polygon/
 client.py # Polygon API with retry/backoff
 pipeline/
 layer0.py # Rule-based filter (free)
 layer1.py # Claude Haiku batch analysis
 layer2.py # Sonnet on-demand deep analysis
 alignment.py # News -> trading day + forward returns
 similarity.py # Similar news pattern matching
 ml/
 features.py # 31-feature engineering (news + technical)
 model.py # XGBoost training (per-ticker + unified)
 inference.py # Forecast generation + similar period analysis
 backtest.py # Backtesting framework
 lstm_model.py # Experimental LSTM model
 api/
 main.py # FastAPI app + CORS
 routers/
 stocks.py # GET /api/stocks, /search, /{sym}/ohlc
 news.py # GET /api/news/{sym}, /{sym}/timeline
 analysis.py # POST /api/analysis/deep, /story
 pipeline.py # POST /api/pipeline/fetch, /process
 predict.py # GET /api/predict/{sym}/forecast
frontend/
 src/
 App.tsx # Main layout (chart + panels)
 components/
 CandlestickChart.tsx # D3.js chart with news dots
 NewsPanel.tsx # Sentiment-sorted news cards
 NewsCategoryPanel.tsx # Filter by impact category
 PredictionPanel.tsx # AI forecast + similar periods
 RangeQueryPopup.tsx # "Why did it drop?" range analysis
 SimilarDaysPanel.tsx # Historical pattern matches
 StockSelector.tsx # Ticker search + tabs

Weekly Update

# Fetch new OHLC + news since last update
python -m backend.weekly_update
# Run AI analysis on new articles
python -m backend.batch_submit --top 50
python -m backend.batch_collect <batch_id>

Cost Summary

Item Cost
Polygon data (free tier) 0ドル
Layer 1 Batch API (per 1000 articles) ~0ドル.35
Layer 2 on-demand (per article) ~0ドル.003
Weekly incremental update ~1ドル-2

Tech Stack

  • Frontend: React, TypeScript, Vite, D3.js
  • Backend: FastAPI, SQLite (WAL mode), Pydantic
  • AI: Claude Haiku 4.5 (batch sentiment), Claude Sonnet (deep analysis)
  • ML: XGBoost (prediction), cosine similarity (pattern matching)
  • Data: Polygon.io REST API

License

MIT β€” see LICENSE for details.

About

No description, website, or topics provided.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

Contributors

Languages

  • Python 55.7%
  • TypeScript 30.7%
  • CSS 13.3%
  • Other 0.3%

AltStyle γ«γ‚ˆγ£γ¦ε€‰ζ›γ•γ‚ŒγŸγƒšγƒΌγ‚Έ (->γ‚ͺγƒͺγ‚ΈγƒŠγƒ«) /