SDK Usage Examples
Initialize the client:
from asharehub import AShareHub
client = AShareHub(api_key="ash_your_key_here")
Fetch daily prices:
df = client.market_daily(symbol="000001.SZ", start_date="20240101", end_date="20240331")
print(df.head())
Fetch northbound capital flows:
flows = client.moneyflow_hsgt(start_date="20240101", end_date="20240131")
print(flows[["trade_date", "north_money"]].head())
Fetch financial indicators:
fina = client.financial_indicators(symbol="000001.SZ")
print(fina[["end_date", "roe", "grossprofit_margin", "eps"]].head())
All available methods:
| Method | Endpoint | Description |
|---|---|---|
| market_daily() | /v2/market/daily | Daily OHLCV prices |
| fundamentals() | /v2/market/fundamentals | PE, PB, turnover, market cap |
| adj_factor() | /v2/market/adj-factor | Price adjustment factor |
| technical_factors() | /v2/market/technical-factors | MACD, KDJ, RSI, BOLL, CCI |
| technical_factors_pro() | /v2/market/technical-factors-pro | 200+ technical indicators |
| margin() | /v2/market/margin | Margin trading detail |
| block_trade() | /v2/market/block-trade | Block trade with buyer/seller |
| top_list() | /v2/market/top-list | Dragon & Tiger list |
| top_inst() | /v2/market/top-inst | Dragon & Tiger institutional seats |
| shareholders() | /v2/market/shareholders | Shareholder count |
| holder_trade() | /v2/market/holder-trade | Major shareholder trades |
| concepts() | /v2/market/concepts | Concept sector indices |
| concept_members() | /v2/market/concept-members | Concept constituents |
| limit_list() | /v2/market/limit-list | Limit up/down stocks |
| moneyflow_hsgt() | /v2/flows/moneyflow-hsgt | Stock Connect capital flows |
| moneyflow() | /v2/flows/moneyflow | Per-stock money flow |
| northbound_holdings() | /v2/flows/northbound-holdings | Foreign investor holdings |
| southbound_holdings() | /v2/flows/southbound-holdings | Mainland-held HK stocks |
| chip_distribution() | /v2/chips/distribution | Cost distribution & winner rates |
| fx_daily() | /v2/fx/daily | FX rates (default USD/CNH) |
| index_daily() | /v2/indices/daily | Index OHLCV data |
| index_weight() | /v2/indices/index-weight | Index constituent weights |
| financial_indicators() | /v2/financials/indicators | 50+ quarterly financial metrics |
| income() | /v2/financials/income | Income statement |
| balance_sheet() | /v2/financials/balance-sheet | Balance sheet |
| cash_flow() | /v2/financials/cash-flow | Cash flow statement |
| forecast() | /v2/financials/forecast | Earnings forecast |
| express() | /v2/financials/express | Earnings express |
| audit() | /v2/financials/audit | Audit opinions |
| main_business() | /v2/financials/main-business | Main business composition |
| disclosure_date() | /v2/financials/disclosure-date | Disclosure schedule |
| analyst_reports() | /v2/financials/analyst-reports | Analyst reports & forecasts |
| dividend() | /v2/shareholders/dividend | Dividend distribution |
| stock_list() | /v2/reference/stocks | A-share stock list |
| industry_list() | /v2/reference/industries | Shenwan industry classification |
| trade_calendar() | /v2/reference/trade-calendar | SSE/SZSE trading calendar |
Esc