台股/美股即時報價 LINE 機器人 - 雙模式備援架構(yfinance + 爬蟲)
- Real-time Stock Quotes - Taiwan & US stocks
- Dual-mode Fallback - yfinance + web scraper
- Watchlist - Save your favorite stocks
- Price Alerts - Get notified when price hits target
- Market Index - Taiwan weighted index
You: 2330
Bot:
📊 台積電 (2330)
━━━━━━━━━━━━
開盤:NT$1,770.00
收盤:NT$1,780.00
漲跌:🔺 +10.00 (+0.56%)
成交量:53,450 張
━━━━━━━━━━━━
⏰ 2026-01-27 14:30:00
You: AAPL
Bot:
📊 Apple Inc. (AAPL)
━━━━━━━━━━━━
開盤:$250.00
現價:$255.41
漲跌:🔺 +5.41 (+2.16%)
━━━━━━━━━━━━
⏰ 2026-01-27 22:30:00
git clone https://github.com/Yakitori197/Stock_LineBot_Public.git
cd Stock_LineBot_Publicpython -m venv venv
# Windows
venv\Scripts\activate
# Mac/Linux
source venv/bin/activatepip install -r requirements.txtcp .env.example .env
# Edit .env and add your LINE Bot credentialspython src/app.py- Go to LINE Developers Console
- Create a new Messaging API channel
- Get your Channel Secret and Channel Access Token
- Set up Webhook URL:
https://your-domain.com/callback
| Command | Description |
|---|---|
2330 |
Query Taiwan stock |
AAPL |
Query US stock |
/help |
Show help message |
/market |
Show market index |
/add 2330 |
Add to watchlist |
/del 2330 |
Remove from watchlist |
/list |
Show watchlist |
/alert 2330 > 1000 |
Set price alert |
/alerts |
Show all alerts |
Stock_LineBot/
├── src/
│ ├── app.py # LINE Bot main app
│ ├── stock_service.py # Dual-mode stock service
│ └── scheduler.py # Price alert scheduler
├── config/
│ └── settings.py # Configuration
├── .env.example # Environment variables template
├── requirements.txt # Python dependencies
├── Start.bat # Windows startup script
├── Stop.bat # Windows stop script
├── Dockerfile
├── docker-compose.yml
└── README.md
┌─────────────────────────────────────────┐
│ StockDataService │
│ │
│ ┌─────────────┐ ┌─────────────┐ │
│ │ yfinance │───▶│ Scraper │ │
│ │ (Primary) │fail│ (Fallback) │ │
│ └─────────────┘ └─────────────┘ │
└─────────────────────────────────────────┘
- Primary: yfinance - Fast and reliable
- Fallback: Web scraper - Works when yfinance fails
docker-compose up -dMIT License - feel free to use this project for personal or commercial purposes.
YoLab 工作室
- GitHub: @Yakitori197
- LINE: @442fjdqq
有任何問題或合作需求,歡迎透過 LINE 聯繫我們!