# Trade Calendar

Trading calendar for the Shanghai (SSE) and Shenzhen (SZSE) exchanges, flagging whether each calendar date is a trading day and providing the preceding trading day (pretrade_date). It supports backtest date alignment, rolling-window construction, gap-filling for missing sessions, and holiday detection. Results are returned per exchange; the two calendars almost always agree but should be queried by the relevant exchange. The calendar is updated as official holiday schedules are published, so confirm coverage of the target year before cross-year backtests.

`GET /v2/reference/trade-calendar`

## Parameters

| Name | Type | Required | Description |
| --- | --- | --- | --- |
| `exchange` | string | No | Exchange: SSE / SZSE (default SSE) |
| `is_open` | int | No | Is trading day: 1 open / 0 closed |
| `start_date` | string | No | Start date (YYYYMMDD) |
| `end_date` | string | No | End date (YYYYMMDD) |

## Response Fields

| Field | Type | Description |
| --- | --- | --- |
| `exchange` | string | Exchange code (SSE / SZSE) |
| `cal_date` | string | Calendar date |
| `is_open` | int | 1=trading day, 0=closed |
| `pretrade_date` | string | Previous trading date |

## API Example

cURL

```
curl -H "X-API-Key: YOUR_KEY" \
  "https://asharehub.com/v2/reference/trade-calendar?exchange=SSE"
```

Python SDK

```
from asharehub import AShareHub

client = AShareHub(api_key="YOUR_KEY")
df = client.trade_calendar(exchange="SSE")
print(df.head())
```

## Sample Data

returns a pandas.DataFrame

| exchange | cal_date | is_open | pretrade_date |
| --- | --- | --- | --- |
| SSE | 20261231 | 1 | 20261230 |
| SSE | 20261230 | 1 | 20261229 |
| SSE | 20261229 | 1 | 20261228 |
