Oracle3
Open-source trading engine and MCP server for prediction markets. Fee-aware no-arbitrage trading across related contracts, live on Kalshi, Polymarket and Solana or on paper.
StockSense — 台股、美股與 ETF 的技術指標自動判讀、走勢預測與新聞情緒分析平台。
Translation pending
FinancePython · JavaScriptGitHub @yakiniku35OnlineOwner unconfirmed
Have you tried it? One tap is enough. No sign-in needed.
No updates detected yet. GitHub releases will appear here.
Owners of public repositories under a personal GitHub account can sign in to verify ownership and manage the introduction themselves. No administrator approval is needed.
Sign in, generate a verification file, and commit it to this repository’s default branch within 30 minutes. Files on other branches or forks do not count. Then check the file below to manage the project without administrator approval. Keep the file to retain your access.
If needed, you will go to sign-in. After signing in, return here and press your chosen verification button again.
Run /nomorevibe verify in your project folder to verify ownership and manage the introduction yourself.
Verify in one minuteAsk about other verification options
Loading the full README. The saved excerpt is shown below.
A stock trend prediction project for Taiwan and U.S. markets. The goal is to combine historical market data, financial indicators, and news or social sentiment signals to support price trend analysis and visualization.
Project status: Phase 1 (multi-source crawler), Phase 2 (sentiment baseline + time-bucket features), and Phase 3 (RNN/LSTM training, deployment, rollback, and A/B monitoring) are implemented.Read the full README ↗A stock trend prediction project for Taiwan and U.S. markets. The goal is to combine historical market data, financial indicators, and news or social sentiment signals to support price trend analysis and visualization.
Project status: Phase 1 (multi-source crawler), Phase 2 (sentiment baseline + time-bucket features), and Phase 3 (RNN/LSTM training, deployment, rollback, and A/B monitoring) are implemented.
Clone the repository:
git clone https://github.com/yakiniku35/stock_predict.git
cd stock_predict
Create and activate a virtual environment:
python -m venv .venv
source .venv/bin/activate
Install dependencies:
pip install -r requirements.txt
Start the web app and API with ./start.sh (see Web App (v2)). The data pipeline,
sentiment training, inference, rollback, and monitoring scripts below are runnable on their own too.
Run the scraper and export normalized news records to JSONL:
python -m crawler.news_scraper \
--config crawler/news_sources.json \
--output data/raw/news_latest.jsonl \
--ticker 2330 \
--content-extract-mode auto \
--max-articles 200
Common flags:
--append: append records instead of overwriting output.--max-articles: cap record count for one run.--ticker: set default stock ticker for each record.--query: dynamic query for sources with {query} / {query_encoded} placeholders.--per-source-max-items: cap records per source for throughput/source balance.--content-extract-mode: source | auto | html | r.jina.ai | markdown.new.
auto tries r.jina.ai and markdown.new to get cleaner article body, then falls back to HTML selector parsing.--disable-content-extract-fallback: disable HTML fallback after remote extraction failure.--content-extract-timeout: override timeout (seconds) for remote extraction.--summary-output: write run-level crawler summary JSON.Output schema (one JSON object per line):
id, source, headline, content, urlpublished_at (UTC ISO timestamp)fetched_at (UTC ISO timestamp)language, tickersentiment_score, sentiment_label (filled in Phase 2)Run everything with one command:
./start.sh # http://127.0.0.1:5000
python tests/test_stocksense.py # 124 offline tests, no network needed
Highlights:
0050, 00878, 006208 -> .TW, 6488 -> .TWO), plus US tickers and ETFs (SPY, QQQ, NVDA). Chinese names work too (台積電, 高股息).localStorage; charts re-theme with the UI.輸入中文(例如「台積電」「長榮航」「高股息」)也能找到標的:
backend/symbol_catalog.py bundles ~125 popular symbols with Chinese and English names.backend/tw_directory.py pulls the full TWSE/TPEx listing (~3,000 stocks and ETFs) from the
exchange ISIN page.backend/us_directory.py pulls the full U.S. listing (~11,000 stocks and ETFs, with an ETF flag)
from the NASDAQ Trader symbol files, so English company names such as "Palantir" resolve too.data/runtime/ for 7 days and degrade to the bundled catalog offline.python scripts/update_symbol_directory.py./api/stock_insight also returns corporate_actions:
dividends.yearly: dividend total and payment count per year (drives the bar chart).dividends.records: every ex-dividend date and amount.dividends.ttm_total / ttm_yield_pct / average_3y: trailing 12-month dividend and yield.dividends.frequency: monthly / quarterly / semi-annual / annual, detected from payment counts.dividends.consecutive_years: consecutive years with a dividend.splits.records: split and reverse-split history with readable labels.rights.records (Taiwan only): stock-dividend (ex-rights) history — date, type, bonus shares per
1,000 held, and the ex-rights reference price. Bonus shares only, never an NT$ amount: converting
a ratio into "NT$X of stock dividend" assumes a NT$10 par value, which TWSE does not require.fund_profile (ETF only): top 10 holdings and sector weightings, or holdings_reference when
Yahoo has no holdings data.Taiwan stock dividends. yfinance's dividends only covers cash dividends; Taiwanese bonus
shares show up in splits instead (100 bonus shares per 1,000 held becomes ratio 1.1). So a Taiwan ratio in
1 < ratio <= 1.5 is read as a stock dividend rather than a split — it moves to the ex-rights tab
and is removed from the split tab, so the same event never appears twice. On top of that,
backend/tw_exrights.py reads the TWSE ex-rights/ex-dividend calculation table (TWT49U) for the
authoritative type and reference prices. That fetch happens on a background thread and is cached
for 12 hours (30 minutes on failure), so the API never blocks on TWSE; if it is unreachable the
ratio-derived numbers are used on their own.
ETF holdings. get_fund_profile() accepts funds_data as either a property or a
get_funds_data() method, matches column names loosely (Holding Percent / holdingPercent /
Weight), and decides whether weights are fractions or percentages from their sum rather than
per-row. When Yahoo has nothing — which is the norm for Taiwanese ETFs — it returns
holdings_reference so the UI can point at the issuer's own daily disclosure instead of showing an
empty panel.
risk_metrics (in /api/stock_insight): total and annualized return, annualized volatility, max drawdown
with its peak/trough dates, Sharpe, Sortino, monthly win rate, plus beta and correlation against the local
benchmark (^TWII for Taiwan, ^GSPC for the U.S.).dca (in /api/stock_insight): monthly dollar-cost-averaging simulation with dividend reinvestment,
computed for a unit contribution so the UI can rescale instantly; includes a lump-sum comparison.GET /api/compare?tickers=0050,006208,00878&period=1y: up to four symbols rebased to 100 with their
risk/return metrics side by side.The front end also has a watchlist (stored in the browser), shareable URLs
(?ticker=&period=&interval=&horizon=) and CSV export of prices and indicators.
| Endpoint | Purpose |
|---|---|
GET /api/health | Service and feature flags |
GET /api/symbol_search?q=00878 | Offline symbol autocomplete (stocks + ETFs) |
GET /api/stock_insight?ticker=0050&period=1y&interval=1d&forecast_horizon=7 | Prices, indicators, forecast, auto reading, news |
GET /api/search?ticker=2330 | News sentiment only |
/api/stock_insight returns:
symbol: resolved yfinance symbol, market, instrument kind (stock / etf / index).company_overview: stock fundamentals, or ETF fields (expense ratio, total assets, NAV, trailing returns).technical_indicators: SMA(5/20/60/120/240), EMA, BB, MACD, KD, RSI, BIAS, AD, ATR, OBV.price_change_detail: intraday / 1D / 1W / 1M / 3M changes.forecast: holt_damped, theta, ridge_ar, knn_analog, drift, ema_momentum plus a weighted ensemble with an 80% confidence band. Every model reports its walk-forward MAPE, directional accuracy and weight.market_read: verdict score, stance, per-indicator reading and a Traditional Chinese summary paragraph.Forecast horizons: 5, 7, 14, 30 days.
/Users/peterchiu/stock_predict/.venv/bin/python models/run_sentiment_batch.py \
--input data/raw/news_latest.jsonl \
--output data/normalized/news_with_sentiment.jsonl \
--summary-output data/normalized/news_with_sentiment_summary.json \
--model-type lexicon \
--workers 4
Sentiment score scale:
100: super positive0: neutral-100: super negativeDefault lexicon thresholds are 20 (positive) and -20 (negative).
/Users/peterchiu/stock_predict/.venv/bin/python models/build_daily_features.py \
--input data/normalized/news_with_sentiment.jsonl \
--output data/features/sentiment_features_hour.csv \
--timeframe hour \
--timezone Asia/Taipei
Supported --timeframe values:
dayhour30min15min/Users/peterchiu/stock_predict/.venv/bin/python models/train_rnn_sentiment.py \
--input data/normalized/news_with_sentiment.jsonl \
--output-dir models/rnn_artifacts \
--summary-output models/rnn_artifacts/train_summary.json \
--label-source auto \
--epochs 8 \
--batch-size 64 \
--max-len 256 \
--vocab-size 20000
/Users/peterchiu/stock_predict/.venv/bin/python models/retrain_rnn_and_promote.py \
--input data/normalized/news_with_sentiment.jsonl \
--registry-dir models/rnn_registry \
--eval-input data/normalized/news_with_sentiment.jsonl \
--eval-label-source field \
--rollback-metric macro_f1 \
--rollback-min-improvement 0.002 \
--label-source field \
--epochs 8 \
--batch-size 64 \
--summary-output models/rnn_registry/last_retrain_summary.json
Rollback behavior:
--disable-rollback to bypass checks.--force-promote to promote regardless of metric comparison.--event-log to append rollback/promotion events and --notify-hook-url + --notify-on rollback for webhook alerts./Users/peterchiu/stock_predict/.venv/bin/python models/predict_rnn_sentiment.py \
--input data/raw/news_latest.jsonl \
--output data/normalized/news_with_sentiment_rnn.jsonl \
--summary-output data/normalized/news_with_sentiment_rnn_summary.json \
--model-dir models/rnn_registry \
--batch-size 128
/Users/peterchiu/stock_predict/.venv/bin/python models/run_sentiment_batch.py \
--input data/raw/news_latest.jsonl \
--output data/normalized/news_with_sentiment.jsonl \
--summary-output data/normalized/news_with_sentiment_summary.json \
--model-type rnn \
--rnn-model-dir models/rnn_registry \
--rnn-batch-size 128
/Users/peterchiu/stock_predict/.venv/bin/python models/run_sentiment_batch.py \
--input data/raw/news_latest.jsonl \
--output data/normalized/news_with_sentiment_ab.jsonl \
--summary-output data/monitoring/ab_runs/summary_latest.json \
--ab-enabled \
--ab-rnn-ratio 0.35 \
--ab-key-field id \
--ab-salt stock_predict_ab_v1 \
--rnn-model-dir models/rnn_registry \
--rnn-batch-size 128 \
--workers 4 \
--ab-report-output data/monitoring/ab_runs/report_latest.json
/Users/peterchiu/stock_predict/.venv/bin/python models/generate_ab_monitoring_report.py \
--input-glob "data/monitoring/ab_runs/report_*.json" \
--eval-summary models/rnn_registry/last_retrain_summary.json \
--output data/monitoring/ab_report_daily.json \
--markdown-output data/monitoring/ab_report_daily.md \
--ratio-config models/rnn_registry/traffic_policy.json \
--write-ratio-config
Outputs:
ab_report_daily.json: aggregated stats + daily metrics + 7/30 day trend datasets.ab_report_daily.md: human-readable report with Mermaid trend charts.traffic_policy.json: adaptive rnn_ratio policy consumed by AB inference.Adaptive traffic policy notes:
rnn_ratio is computed from both quality (accuracy from evaluation summary) and speed (7-day throughput).--weight-accuracy and --weight-throughput to tune priorities.--max-ratio-step to cap per-run ratio changes and avoid oscillation.See docs/cron_templates.md for scheduling templates:
stock_predict/
├── api/
│ └── index.py # Flask app: all HTTP routes (also used by Vercel)
├── backend/
│ ├── app.py # Local dev entry point (reuses api/index.py)
│ ├── fetcher.py # yfinance access, ETF/OTC resolution, TTL cache
│ ├── symbols.py # Symbol resolution and offline search
│ ├── tw_directory.py # Full TWSE/TPEx listing (Chinese name lookup)
│ ├── us_directory.py # Full U.S. listing (English name lookup)
│ ├── directory_cache.py # Shared snapshot / cache / fetch plumbing
│ ├── tw_exrights.py # TWSE ex-rights/ex-dividend table (Taiwan stock dividends)
│ ├── analytics.py # Risk metrics, DCA simulation, comparison series
│ ├── symbol_catalog.py # Offline catalog of popular TW/US stocks and ETFs
│ ├── indicators.py # Technical indicator series + latest snapshot
│ ├── forecast.py # Six forecasting models + walk-forward backtest
│ ├── signals.py # Auto indicator reading -> Traditional Chinese text
│ └── news.py # Google News RSS + RNN/lexicon sentiment
├── public/
│ ├── index.html # Single-page UI
│ ├── styles.css # Design system (dark / light tokens)
│ └── app.js # State, charts, theme switching
├── models/ # Sentiment training / inference scripts + artifacts
├── crawler/ # Multi-source news crawler
├── tests/
│ └── test_stocksense.py # 124 offline tests (synthetic data, no network)
├── data/ # Local datasets and pipeline output
├── scripts/
│ └── update_symbol_directory.py # Refresh the offline name snapshots
├── start.sh / stop.sh # Start and stop the local service
└── vercel.json # Deployment config
Please review the terms of service and usage limits of each data provider before collecting or redistributing data.
Thanks to all contributors.
.env files.models/rnn_registry/active_model.json) for safe online weight upgrades.This project is for research and educational purposes only. It does not provide financial advice, investment recommendations, or guaranteed prediction results.