API Reference · Namespace Map
v2 refactors v1's flat sdk.getXxx() into domain-organized namespaces. Every data-fetching capability lives under sdk.<namespace>.<method>(); pure-computation capabilities (indicators, signals, symbol parsing) are exported via subpaths, imported on demand and tree-shaking friendly.
ts
import { StockSDK } from 'stock-sdk'
const sdk = new StockSDK()
const quotes = await sdk.quotes.cn(['600519', '000001']) // namespaced call
const kline = await sdk.kline.cn('600519', { period: 'daily' })
const k = await sdk.options.etf.dailyKline('10004336') // nested namespaceA
stringsymbol is a first-class input:'sh600519'/'600519'/'00700'/'AAPL'all work, resolved leniently bynormalizeSymbol. When you need object hints, usenormalizeSymbolfromstock-sdk/symbolsfirst. See Symbols & Codes.
Quotes & Batch
| Namespace | Purpose | Docs |
|---|---|---|
sdk.quotes | Real-time quotes: A-share full/simple, HK, US, fund, fund flow (simple), large orders, intraday timeline | quotes |
sdk.codes | Code lists per market: CN / US / HK / fund | codes |
sdk.batch | Whole-market batch quotes: CN / HK / US / by-codes / raw | batch |
K-line & Boards
| Namespace | Purpose | Docs |
|---|---|---|
sdk.kline | A/HK/US history K-line, minute K-line, K-line with indicators | kline |
sdk.board.industry · sdk.board.concept | Industry / concept boards: list, spot, constituents, kline, minute | board |
Derivatives
| Namespace | Purpose | Docs |
|---|---|---|
sdk.options | Options: index (index) / ETF (etf) / commodity (commodity) / CFFEX (cffex) + options LHB (lhb) | options |
sdk.futures | Futures: domestic/global K-line, inventory symbols and inventory data | futures |
Capital Flow
| Namespace | Purpose | Docs |
|---|---|---|
sdk.fundFlow | Fund flow (deep): individual / market / rank / sector rank / sector history | fundFlow |
sdk.northbound | Stock Connect / northbound: minute / summary / holding rank / history / individual | northbound |
sdk.marketEvent | Market events: limit-up pool / stock changes / board changes | marketEvent |
sdk.dragonTiger | Dragon-Tiger list: detail / stock stats / institution / branch rank / seat detail | dragonTiger |
sdk.blockTrade | Block trades: market stat / detail / daily stat | blockTrade |
sdk.margin | Margin trading: account info / target list | margin |
Funds & Utilities
| Namespace | Purpose | Docs |
|---|---|---|
sdk.fund | Mutual fund extensions: dividend list / NAV history / estimate / rank history | fund |
sdk.calendar | Trading calendar: is-trading-day / next / prev / market status | calendar |
sdk.reference | Reference data: dividend detail / A-share trading calendar | reference |
sdk.search(keyword) | Stock search (top-level shortcut) | search |
Pure computation · subpath exports
Indicators, signals and symbol parsing are pure functions, zero network, with no dependency on a StockSDK instance. Import them from their own subpaths:
ts
import { calcMACD, addIndicators } from 'stock-sdk/indicators'
import { calcSignals } from 'stock-sdk/signals'
import { normalizeSymbol } from 'stock-sdk/symbols'| Module | Import path | Purpose | Docs |
|---|---|---|---|
| Indicators | stock-sdk/indicators | 14 indicators: calcMA / calcMACD / calcBOLL / calcKDJ / calcRSI / calcWR / calcBIAS / calcCCI / calcATR / calcOBV / calcROC / calcDMI / calcSAR / calcKC + addIndicators | indicators |
| Signals | stock-sdk/signals | calcSignals: golden / death cross, overbought / oversold, etc. | signals |
| Symbols | stock-sdk/symbols | normalizeSymbol, SymbolRef type: lenient symbol parsing | Symbols & Codes |
Conventions
- Method table → call example → return notes is the shared layout of every API page.
- Return values follow the v2 unified data contract: base fields
symbol/market/assetType/exchange/currency/timestamp/tz/source; therawfield is removed;timestampisnumber | null(nullwhen unparseable); percentages are percentage numbers (e.g.5.2). Amount / price / volume have unified target units, but in the current beta runtime values still follow each provider's raw convention. See Migrate from v1. - The v2 SDK is still being implemented: namespaces and method names are stable, but exact parameters / return fields are subject to the final implementation.