| version | 1 |
| name | anyfinancial-realtime-api-data-cn |
| description | CN Stocks provider for direct/recent China market data under AnyFinancial. Uses POST /api/data/cn-stocks/<operation> with sandbox bearer auth. |
CN Stocks Real-time/API Data
Use the CN Stocks provider for direct China market data. Every operation is a
POST request to the Rebyte relay:
POST /api/data/cn-stocks/<operation>
Authentication
Resolve auth from the sandbox, then send it as a bearer token:
AUTH_TOKEN=$(/home/user/.local/bin/rebyte-auth)
API_URL=$(python3 -c "import json; print(json.load(open('/home/user/.rebyte.ai/auth.json'))['sandbox']['relay_url'])")
curl -fsS -X POST "$API_URL/api/data/cn-stocks/universe" \
-H "Authorization: Bearer $AUTH_TOKEN" \
-H "Content-Type: application/json" \
-d '{}'
If AUTH_TOKEN or API_URL is unavailable, stop and report that sandbox auth is
missing. Do not invent credentials.
Operations
| Operation | Endpoint | Use for |
|---|
bars | /api/data/cn-stocks/bars | Daily or higher-level OHLCV price bars. |
adj_factor | /api/data/cn-stocks/adj_factor | Price adjustment factors for splits/dividends/rebases. |
bars_1min | /api/data/cn-stocks/bars_1min | 1-minute intraday OHLCV bars. |
valuation | /api/data/cn-stocks/valuation | Valuation metrics such as market value or ratios. |
financials | /api/data/cn-stocks/financials | Financial statement and reported fundamentals data. |
universe | /api/data/cn-stocks/universe | Available CN stock universe and identifiers. |
news | /api/data/cn-stocks/news | CN market or ticker news. |
Local Commands
Use the bundled CLI to call any CN operation:
python3 ../scripts/anyfinancial_api_data.py cn universe --payload '{}'
python3 ../scripts/anyfinancial_api_data.py cn bars --payload '{"ts_code":"000001.SZ","start_date":"2024-01-02","end_date":"2024-01-02"}'
python3 ../scripts/anyfinancial_api_data.py cn bars_1min --payload '{"ts_code":"000001.SZ","start_date":"2024-01-02 09:30:00","end_date":"2024-01-02 09:31:00"}'
python3 ../scripts/anyfinancial_api_data.py cn valuation --payload '{"ts_code":"000001.SZ","start_date":"2024-01-02","end_date":"2024-01-02"}'
python3 ../scripts/anyfinancial_api_data.py cn financials --payload '{"ts_code":"000001.SZ","statement":"income","start_date":"20240101","end_date":"20241231"}'
python3 ../scripts/anyfinancial_api_data.py cn news --payload '{"start_date":"2024-01-02 00:00:00","end_date":"2024-01-02 23:59:59"}'
Run these from realtime-api-data/cn/. From the repository root, use
python3 realtime-api-data/scripts/anyfinancial_api_data.py ....
Request Shape
Send JSON. Keep payloads narrow and operation-specific. Common fields are:
| Field | Meaning |
|---|
ts_code | CN instrument code when the operation is single-security. |
symbol | Alternate symbol input if the provider operation accepts it. |
start_date / end_date | Date range. Prefer YYYY-MM-DD. |
statement | Required by financials: income, balancesheet, cashflow, or fina_indicator. |
limit | Maximum records for exploration. |
offset | Page offset when paginating. |
fields | Optional list of fields to project if supported. |
Examples:
curl -fsS -X POST "$API_URL/api/data/cn-stocks/bars" \
-H "Authorization: Bearer $AUTH_TOKEN" \
-H "Content-Type: application/json" \
-d '{"ts_code":"000001.SZ","start_date":"2024-01-01","end_date":"2024-01-31","limit":100}'
curl -fsS -X POST "$API_URL/api/data/cn-stocks/bars_1min" \
-H "Authorization: Bearer $AUTH_TOKEN" \
-H "Content-Type: application/json" \
-d '{"ts_code":"000001.SZ","start_date":"2024-01-02 09:30:00","end_date":"2024-01-02 09:31:00"}'
curl -fsS -X POST "$API_URL/api/data/cn-stocks/news" \
-H "Authorization: Bearer $AUTH_TOKEN" \
-H "Content-Type: application/json" \
-d '{"start_date":"2024-01-02 00:00:00","end_date":"2024-01-02 23:59:59"}'
curl -fsS -X POST "$API_URL/api/data/cn-stocks/financials" \
-H "Authorization: Bearer $AUTH_TOKEN" \
-H "Content-Type: application/json" \
-d '{"ts_code":"000001.SZ","statement":"income","start_date":"20240101","end_date":"20241231"}'
Response Format
Successful responses are JSON. Handle all compatible row containers because
provider responses may vary by operation:
{
"success": true,
"data": [],
"rowCount": 0,
"meta": {}
}
Rows may appear in data, rows, result, or results. If the body itself is
an array, treat it as the row list. Preserve metadata when reporting coverage,
pagination, or provider timing.
Error Format
Errors are JSON when the provider can return a structured response:
{
"success": false,
"error": {
"code": "bad_request",
"message": "Invalid request",
"details": {}
}
}
Some errors may use a string error, message, or detail. Report the HTTP
status and the provider message exactly. Do not retry the same failing payload.
Usage Rules
- Start with
universe when the user gives an ambiguous CN company name or code.
- Use
bars for daily/history-style price checks and bars_1min only for
bounded intraday windows. bars_1min requires start_date and end_date as
YYYY-MM-DD HH:MM:SS.
- Pair
bars with adj_factor when the user asks for adjusted prices, returns,
or comparable historical performance.
- Use
valuation for market ratios/market value and financials for reported
fundamentals. financials requires a statement value; do not infer one
statement from another unless explicitly calculated and labeled.
- Use
news for CN provider news lookups. news requires start_date and
end_date as YYYY-MM-DD HH:MM:SS. Include publication timestamps and source
fields when returned.
- Some CN endpoints may ignore
limit; use narrow date/time windows first and
paginate intentionally for larger pulls.
- Do not use this provider for US data. Use
../us/SKILL.md.
- Do not use direct provider pulls as a substitute for the event-driven
backtesting workflow. Use
../../backtesting/SKILL.md for simulations.