수정본
This commit is contained in:
42
docs/backend_guide.md
Normal file
42
docs/backend_guide.md
Normal file
@@ -0,0 +1,42 @@
|
||||
# Backend
|
||||
|
||||
## Batch daily analysis (DB cache)
|
||||
|
||||
Precompute technical indicators each morning and cache results for fast recommendations.
|
||||
|
||||
### Run once (today)
|
||||
|
||||
```zsh
|
||||
cd /Users/commylife/myproject/java/workspace/auto-stock/backend
|
||||
python3 batch_daily_analysis.py --test # quick: ~10 stocks
|
||||
# or full run
|
||||
python3 batch_daily_analysis.py
|
||||
```
|
||||
|
||||
### Schedule (cron on macOS)
|
||||
|
||||
```zsh
|
||||
crontab -e
|
||||
# weekdays 08:30 run (adjust path)
|
||||
30 8 * * 1-5 cd /Users/commylife/myproject/java/workspace/auto-stock/backend && /usr/bin/python3 batch_daily_analysis.py >> ../logs/batch.log 2>&1
|
||||
```
|
||||
|
||||
### Use DB cache in API
|
||||
|
||||
- Endpoint: `/api/v1/recommendations/rule-based`
|
||||
- Default: uses DB cache; if cache empty, it automatically falls back to realtime analysis.
|
||||
- Force realtime:
|
||||
|
||||
```text
|
||||
/api/v1/recommendations/rule-based?realtime=true
|
||||
```
|
||||
|
||||
### Monitoring
|
||||
|
||||
- API safety stats: `/api/v1/monitoring/api-stats`
|
||||
- Health: `/api/v1/monitoring/health`
|
||||
|
||||
### Troubleshooting
|
||||
|
||||
- No recommendations: ensure `stock_analysis` has rows for today (run batch).
|
||||
- Slow responses: rely on DB cache or reduce realtime stock count via query params.
|
||||
Reference in New Issue
Block a user