Oracle3
Oracle3: 예측시장 거래 엔진·MCP 서버
아직 감지된 업데이트가 없습니다. GitHub 릴리스가 나오면 여기에 보입니다.
개인 계정의 공개 저장소 소유자는 GitHub로 로그인해 운영자를 확인하고 소개를 직접 관리할 수 있습니다. 관리자 승인은 필요하지 않습니다.
로그인한 뒤 확인 파일을 만들어 이 저장소의 기본 브랜치에 30분 안에 커밋해 주세요. 다른 브랜치나 포크의 파일은 인정하지 않습니다. 파일을 올린 뒤 아래에서 확인하면 관리자 승인 없이 관리할 수 있습니다. 자격을 유지하려면 파일을 남겨 두세요.
로그인이 필요하면 로그인 화면으로 이동합니다. 로그인 후 이곳으로 돌아와 원하는 확인 버튼을 다시 눌러 주세요.
프로젝트 폴더에서 /nomorevibe verify를 실행하면 소유권을 확인하고 소개를 직접 관리할 수 있습니다.
1분 만에 확인하기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.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.