diff --git a/API_DOCUMENTATION.md b/API_DOCUMENTATION.md index 0244aa4..136169b 100644 --- a/API_DOCUMENTATION.md +++ b/API_DOCUMENTATION.md @@ -8,6 +8,16 @@ Stock Oracle provides comprehensive financial, price, news, and social media dat ## πŸš€ Quick Start +### Running the API + +```bash +# Start all services (first time) +docker-compose up -d + +# Restart API after code changes +just run dev +``` + ### Base URL ``` http://localhost:18001/api/v1 @@ -335,6 +345,50 @@ Download and ingest FINRA short volume file(s) for a specific date or date range ### Stock Market Data πŸ†• +#### `GET /stocks/index/{index_name}` +S&P 500 λ˜λŠ” Nasdaq 100 ꡬ성 μ’…λͺ©μ„ Wikipediaμ—μ„œ μ‘°νšŒν•©λ‹ˆλ‹€. + +**Path Parameters:** +- `index_name`: `sp500` λ˜λŠ” `nasdaq100` + +**Query Parameters:** +- `force_refresh`: `true`/`false` (default: `false`) β€” μΊμ‹œ λ¬΄μ‹œν•˜κ³  재쑰회 + +**Caching:** +- TTL: 24μ‹œκ°„ (`Cache-Control: public, max-age=86400`) +- `X-Cache: HIT` / `MISS`, `ETag` 헀더 포함 + +**Response:** +```json +{ + "success": true, + "index": "sp500", + "count": 503, + "constituents": [ + { + "symbol": "AAPL", + "name": "Apple Inc.", + "sector": "Information Technology", + "industry": "Technology Hardware, Storage & Peripherals" + } + ] +} +``` + +**Examples:** +``` +GET /stocks/index/sp500 β†’ S&P 500 ꡬ성 μ’…λͺ© (~503개) +GET /stocks/index/nasdaq100 β†’ Nasdaq 100 ꡬ성 μ’…λͺ© (~101개) +GET /stocks/index/sp500?force_refresh=true β†’ μΊμ‹œ λ¬΄μ‹œν•˜κ³  재쑰회 +GET /stocks/index/foo β†’ 400 Bad Request +``` + +**Error Codes:** +- `400`: μ§€μ›ν•˜μ§€ μ•ŠλŠ” `index_name` +- `504`: Wikipedia 응닡 30초 초과 + +--- + #### `GET /stocks/most-active` Most actively traded stocks from Yahoo Finance. diff --git a/README.md b/README.md index fcffe50..d3e6c09 100644 --- a/README.md +++ b/README.md @@ -16,6 +16,7 @@ Stock Oracle is a comprehensive investment analysis API that leverages SEC EDGAR ### Market Data Intelligence (NEW! πŸ†•) - **Most Active Stocks**: Real-time ~170 most actively traded stocks (sub-5s response) - **52-Week Gainers**: 1,350+ top gaining stocks with intelligent rate limiting (5-90s) +- **Index Constituents**: S&P 500 / Nasdaq 100 ꡬ성 μ’…λͺ© 쑰회 β€” Wikipedia νŒŒμ‹±, 24μ‹œκ°„ μΊμ‹œ - **FRED Economic Data**: Federal Reserve economic indicators with smart caching (1000/day limit) - **Advanced Web Scraping**: curl_cffi + Chrome impersonation bypasses rate limits - **Smart Pagination**: Configurable page limits (1-10 pages) for performance tuning @@ -94,10 +95,15 @@ pip install -r requirements-api.txt cp .env.example .env # Edit .env with your settings -# Run the API -python -m uvicorn app.main:app --host 0.0.0.0 --port 18000 --reload +# Start all services (first time) +docker-compose up -d + +# Restart API after code changes (code is volume-mounted, no rebuild needed) +just run dev ``` +> **Note**: Always use `just run dev` to restart the API. The `app/` directory is volume-mounted into the container, so code changes take effect on restart without rebuilding the image. + ## ⚑ Quick Examples ### Get Market Overview @@ -733,6 +739,7 @@ curl "http://localhost:18001/api/v1/news/NVDA/social-only?days_back=3&max_social - `GET /api/v1/stocks/trending` - **Trending stocks combining most active + 52-week gainers** (πŸš€ Recommended) - `GET /api/v1/stocks/most-active` - Most actively traded stocks (optional limit parameter) - `GET /api/v1/stocks/52-week-gainers` - 52-week top gaining stocks with intelligent rate limiting +- `GET /api/v1/stocks/index/{index_name}` - S&P 500 / Nasdaq 100 constituents from Wikipedia (24h cache) #### Alpaca Market Data (NEW! πŸ†•) - `GET /api/v1/alpaca/status` - Alpaca connection status and API key validation diff --git a/justfile b/justfile new file mode 100644 index 0000000..b0c3e3a --- /dev/null +++ b/justfile @@ -0,0 +1,6 @@ +# Stock Oracle dev commands + +# Restart API container (code is volume-mounted, so this picks up changes immediately) +run dev: + docker restart stock_oracle_api + docker logs -f stock_oracle_api