Python SDK for querying ETF data from value300.cn
Project description
value300
Python SDK for querying ETF data from value300.cn.
Install
pip install value300
# With pandas support:
pip install value300[pandas]
Quick Start
from value300 import Value300
client = Value300()
# 1. Single ETF history (by date range)
data = client.get_history("510300", start_date="2026-01-01", end_date="2026-06-30")
# 2. Single ETF history (by days back from today)
data = client.get_history("510300", days=180)
# 3. All ETFs snapshot for a specific date
snapshot = client.get_snapshot("2026-07-08")
# 4. All ETFs snapshot for latest trading day
snapshot = client.get_snapshot()
# As pandas DataFrame
df = client.get_history("510300", days=180, as_dataframe=True)
df_snapshot = client.get_snapshot(as_dataframe=True)
Caching
- Snapshot cache: 500 entries (LRU, keyed by date)
- History cache: 2000 records per ETF code (LRU, keyed by trade_date)
# Check cache stats
print(client.cache_stats())
# Clear caches
client.clear_cache()
client.clear_history_cache("510300") # specific code only
Rate Limiting
Server-side rate limit: 1000 requests/day per IP.
Exceeding returns RateLimitError with daily_limit, used, and retry_after attributes.
from value300 import RateLimitError
try:
data = client.get_history("510300", days=365)
except RateLimitError as e:
print(f"Limit: {e.daily_limit}/day, used: {e.used}, retry in {e.retry_after}s")
API Reference
Value300(base_url, timeout, max_retries, snapshot_cache_size, history_cache_size)
| Parameter | Default | Description |
|---|---|---|
base_url |
https://value300.cn |
API base URL |
timeout |
30 |
Request timeout (seconds) |
max_retries |
3 |
Max retry attempts |
snapshot_cache_size |
500 |
Max cached snapshot entries |
history_cache_size |
2000 |
Max cached records per ETF code |
Methods
| Method | Returns | Description |
|---|---|---|
get_history(code, start_date, end_date, days, fields, as_dataframe) |
list[dict] or DataFrame |
Single ETF historical data |
get_snapshot(date, as_dataframe) |
list[dict] or DataFrame |
All ETFs snapshot for a date |
clear_cache() |
None |
Clear all caches |
clear_history_cache(code) |
None |
Clear history cache |
clear_snapshot_cache() |
None |
Clear snapshot cache |
cache_stats() |
dict |
Cache statistics |
Record Fields
| Field | Type | Description |
|---|---|---|
code |
str |
ETF code |
name |
str |
ETF name |
trade_date |
str |
Trading date (YYYY-MM-DD) |
open |
float |
Open price |
close |
float |
Close price |
high |
float |
High price |
low |
float |
Low price |
pct_chg |
float |
Price change percentage |
volume |
int |
Trading volume |
amount |
float |
Trading amount |
License
MIT
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
value300-0.1.0.tar.gz
(8.0 kB
view details)
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file value300-0.1.0.tar.gz.
File metadata
- Download URL: value300-0.1.0.tar.gz
- Upload date:
- Size: 8.0 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.11.5
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
756cb6bb13ff9f73d00e22e97655f337c3d1824280ba360f2d0bb529084090df
|
|
| MD5 |
d0a8e1d23d659a72e8ec8fb9ca854bc2
|
|
| BLAKE2b-256 |
32acd41ad8420bc71dc1f7ec82589626ab1beb1a58eb5bde00ffcfd27db7fd83
|
File details
Details for the file value300-0.1.0-py3-none-any.whl.
File metadata
- Download URL: value300-0.1.0-py3-none-any.whl
- Upload date:
- Size: 7.9 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.11.5
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
4c4ca233f3d2f8e56d03b511b19ed045efaa61c09afe84fee28548dda8b4057f
|
|
| MD5 |
fa9178fcdfe9b8ad491ccc7591d58183
|
|
| BLAKE2b-256 |
d19fdc5029b7c98e80f8432a3ee599772f55c814ba820884870050f4fe321818
|