> For the complete documentation index, see [llms.txt](https://docs.alpha-lenz.com/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.alpha-lenz.com/ko/api-reference/public-api/stock.md).

# Stock API

OHLCV (시가, 고가, 저가, 종가, 거래량)를 포함한 주가 데이터에 액세스합니다.

**필요 스코프:** `read:stock` 또는 `read:all`

## 주가 조회

종목의 OHLCV 주가 데이터를 조회합니다.

```
GET /api/public/v1/stock/prices/{symbol}
```

### Path Parameters

| 파라미터     | 타입     | 설명                  |
| -------- | ------ | ------------------- |
| `symbol` | string | 주식 심볼 (예: "005930") |

### Query Parameters

| 파라미터       | 타입      | 설명                                             |
| ---------- | ------- | ---------------------------------------------- |
| `interval` | string  | 시간 간격: "1day", "1week", "1month" (기본값: "1day") |
| `limit`    | integer | 데이터 포인트 수 (1-500, 기본값: 100)                    |

### 요청 예시

```bash
curl -X GET "https://api.alpha-lenz.com/api/public/v1/stock/prices/005930?interval=1day&limit=30" \
     -H "X-API-Key: ak_your_key"
```

### 응답

```json
{
  "symbol": "005930",
  "company_name": "Samsung Electronics",
  "interval": "1day",
  "data": [
    {
      "datetime": "2024-01-15T00:00:00",
      "open": 71500.0,
      "high": 72000.0,
      "low": 71000.0,
      "close": 71800.0,
      "volume": 15000000
    },
    {
      "datetime": "2024-01-16T00:00:00",
      "open": 71800.0,
      "high": 72500.0,
      "low": 71500.0,
      "close": 72200.0,
      "volume": 12500000
    }
  ],
  "count": 30
}
```

***

## 주가 히스토리 조회

날짜 필터링 및 페이지네이션과 함께 과거 주가 데이터를 조회합니다.

```
GET /api/public/v1/stock/prices/{symbol}/history
```

### Path Parameters

| 파라미터     | 타입     | 설명    |
| -------- | ------ | ----- |
| `symbol` | string | 주식 심볼 |

### Query Parameters

| 파라미터         | 타입      | 설명                               |
| ------------ | ------- | -------------------------------- |
| `interval`   | string  | 시간 간격: "1day", "1week", "1month" |
| `start_date` | string  | 시작 날짜 필터 (YYYY-MM-DD)            |
| `end_date`   | string  | 종료 날짜 필터 (YYYY-MM-DD)            |
| `limit`      | integer | 페이지당 결과 수 (1-1000, 기본값: 100)     |
| `offset`     | integer | 페이지네이션 오프셋 (기본값: 0)              |

### 요청 예시

```bash
curl -X GET "https://api.alpha-lenz.com/api/public/v1/stock/prices/005930/history?start_date=2024-01-01&end_date=2024-01-31&limit=100" \
     -H "X-API-Key: ak_your_key"
```

### 응답

```json
{
  "symbol": "005930",
  "company_name": "Samsung Electronics",
  "interval": "1day",
  "data": [
    {
      "datetime": "2024-01-02T00:00:00",
      "open": 70000.0,
      "high": 71000.0,
      "low": 69500.0,
      "close": 70500.0,
      "volume": 18000000
    }
  ],
  "count": 22,
  "has_more": false
}
```

### OHLCV 필드

| 필드         | 타입      | 설명            |
| ---------- | ------- | ------------- |
| `datetime` | string  | ISO 8601 날짜시간 |
| `open`     | float   | 시가            |
| `high`     | float   | 고가            |
| `low`      | float   | 저가            |
| `close`    | float   | 종가            |
| `volume`   | integer | 거래량           |

### 페이지네이션

`offset`과 `limit`을 사용하여 페이지네이션을 구현합니다. `has_more`를 확인하여 추가 결과가 있는지 확인하세요:

```bash
# 첫 페이지
GET /stock/prices/005930/history?limit=100&offset=0

# 두 번째 페이지
GET /stock/prices/005930/history?limit=100&offset=100
```
