Initial commit

This commit is contained in:
2025-11-14 11:05:31 +09:00
commit b147498c31
124 changed files with 17983 additions and 0 deletions

42
backend/README.md Normal file
View 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.