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:

MethodEndpointDescription
market_daily()/v2/market/dailyDaily OHLCV prices
fundamentals()/v2/market/fundamentalsPE, PB, turnover, market cap
adj_factor()/v2/market/adj-factorPrice adjustment factor
technical_factors()/v2/market/technical-factorsMACD, KDJ, RSI, BOLL, CCI
technical_factors_pro()/v2/market/technical-factors-pro200+ technical indicators
margin()/v2/market/marginMargin trading detail
block_trade()/v2/market/block-tradeBlock trade with buyer/seller
top_list()/v2/market/top-listDragon & Tiger list
top_inst()/v2/market/top-instDragon & Tiger institutional seats
shareholders()/v2/market/shareholdersShareholder count
holder_trade()/v2/market/holder-tradeMajor shareholder trades
concepts()/v2/market/conceptsConcept sector indices
concept_members()/v2/market/concept-membersConcept constituents
limit_list()/v2/market/limit-listLimit up/down stocks
moneyflow_hsgt()/v2/flows/moneyflow-hsgtStock Connect capital flows
moneyflow()/v2/flows/moneyflowPer-stock money flow
northbound_holdings()/v2/flows/northbound-holdingsForeign investor holdings
southbound_holdings()/v2/flows/southbound-holdingsMainland-held HK stocks
chip_distribution()/v2/chips/distributionCost distribution & winner rates
fx_daily()/v2/fx/dailyFX rates (default USD/CNH)
index_daily()/v2/indices/dailyIndex OHLCV data
index_weight()/v2/indices/index-weightIndex constituent weights
financial_indicators()/v2/financials/indicators50+ quarterly financial metrics
income()/v2/financials/incomeIncome statement
balance_sheet()/v2/financials/balance-sheetBalance sheet
cash_flow()/v2/financials/cash-flowCash flow statement
forecast()/v2/financials/forecastEarnings forecast
express()/v2/financials/expressEarnings express
audit()/v2/financials/auditAudit opinions
main_business()/v2/financials/main-businessMain business composition
disclosure_date()/v2/financials/disclosure-dateDisclosure schedule
analyst_reports()/v2/financials/analyst-reportsAnalyst reports & forecasts
dividend()/v2/shareholders/dividendDividend distribution
stock_list()/v2/reference/stocksA-share stock list
industry_list()/v2/reference/industriesShenwan industry classification
trade_calendar()/v2/reference/trade-calendarSSE/SZSE trading calendar