Metadata-Version: 2.4
Name: seeddata-quant
Version: 1.1.0
Summary: SeedData Python client SDK
Author-email: SeedData <2236158935@qq.com>
License-Expression: LicenseRef-Proprietary
Classifier: Development Status :: 3 - Alpha
Classifier: Intended Audience :: Financial and Insurance Industry
Classifier: Intended Audience :: Developers
Classifier: Programming Language :: Python :: 3
Classifier: Programming Language :: Python :: 3 :: Only
Classifier: Programming Language :: Python :: 3.10
Classifier: Programming Language :: Python :: 3.11
Classifier: Programming Language :: Python :: 3.12
Classifier: Programming Language :: Python :: 3.13
Classifier: Topic :: Office/Business :: Financial
Requires-Python: >=3.10
Description-Content-Type: text/markdown
Requires-Dist: httpx>=0.27.0
Requires-Dist: pandas<3.0,>=2.2.0
Requires-Dist: tradecal<2027,>=2026.10.0
Requires-Dist: pyarrow>=23.0.0
Requires-Dist: sqlglot>=25.20.0

# SeedData Python SDK

SeedData is a Python client SDK for accessing SeedData market data services.

This package only contains the client SDK. The server-side gateway and worker components are not included in this PyPI distribution.

## Installation

```bash
pip install seeddata-quant
```

## Quick Start

```python
import seeddata as sd

sd.set_token("YOUR_TOKEN")

result = sd.query("SELECT * FROM trade_date LIMIT 5")
print(result.df)
```

## Common APIs

```python
import seeddata as sd

sd.set_token("YOUR_TOKEN")

df = sd.get_klines(
    instruments=["000001.SZ"],
    fields=["close"],
    start_time="2024-01-01",
    end_time="2024-01-31",
    period="1d",
    adjust="none",
    market_type="cn_stock",
)

realtime_1min = sd.query(
    "SELECT * FROM cn_stock_1min_realtime_data "
    "LATEST ON trade_time PARTITION BY ts_code LIMIT 20"
).df
```

## Trading Calendars

Trading calendars are provided by the independent `tradecal` dependency, installed
with `seeddata-quant`. Queries run locally without network calls.

```python
import tradecal as cal

calendar = cal.get_calendar("XNYS")
calendar.valid_days("2026-06-01", "2026-06-30")
calendar.schedule("2026-11-27", session="extended")
```

See the [tradecal package documentation](https://pypi.org/project/tradecal/)
for supported MICs, APIs, data sources, and strict coverage boundaries.

## Token

Non-local SeedData gateways require a token:

```python
sd.set_token("YOUR_TOKEN")
```

You can also set the token through an environment variable:

```bash
export SEEDDATA_TOKEN="YOUR_TOKEN"
```

A gateway running on your local machine may allow anonymous local access. In
that case the SDK can send requests without `sd.set_token(...)`; the server
decides whether anonymous requests are allowed.

## Base URL

By default, the SDK targets the local gateway of a standard SeedData private
deployment:

- history: `http://127.0.0.1:28637`
- realtime: `http://127.0.0.1:28637`

A single gateway serves both history and realtime endpoints, so with the
SeedData database package installed on the same machine, the SDK works out of
the box. If your gateway runs on another host, point the SDK at it:

```python
sd.set_base_url(
    history="http://192.168.1.10:28637",
    realtime="http://192.168.1.10:28637",
)
```

You can set only one side if needed:

```python
sd.set_base_url(history="http://192.168.1.10:28637")
sd.set_base_url(realtime="http://192.168.1.10:28637")
```

Missing arguments keep their current values. Trailing slashes are removed, and
empty values raise an error. This function only configures request URLs and does
not check network connectivity.

## Server compatibility

This SDK requires a SeedData server of version 0.1.10 or newer. The query API
returns results as an Apache Arrow stream; the staged large-result download mode
of SDK 1.0.4 is no longer supported. Floating-point query results are returned
exactly as stored, without implicit rounding (server 0.1.10 behavior).

## License

This package is proprietary software. Installation and use require authorization from SeedData.
