Stock Data API Guide股票数据 API 指南

Choose a Free Historical Stock Data API
for Reliable Backtests
选择适合可靠回测的
免费历史股票数据 API

Compare historical depth, OHLCV coverage, adjustments, rate limits, formats, and licensing before you build.

接入前,应比较历史数据覆盖年限、OHLCV 覆盖范围、复权规则、请求上限、数据格式与使用许可。

Hand-drawn workflow from archived stock prices through API retrieval and validation to research and backtesting

Quick answer: what a free historical stock data API provides快速解答:免费历史股票数据 API 能提供哪些数据

A historical stock data API retrieves past market observations by symbol and date range. A useful free tier should return consistent OHLCV bars, document the earliest available date, explain corporate-action adjustments, and disclose request and usage limits.

历史股票数据 API 可按证券代码和日期范围返回过往行情。实用的免费套餐应提供口径一致的 OHLCV K 线数据,注明最早可查询日期,说明如何针对公司行动进行复权,并明确请求上限与使用限制。

Best for

Backtests, screeners, research notebooks, portfolio reports, and dashboards that do not require live ticks.

History depth matters

A long date range is only useful when delisted symbols, corporate actions, calendars, and identifiers are handled consistently.

Free has limits

Expect caps on requests, years of history, exchanges, symbols, bulk downloads, or commercial use.

适用场景

适合回测、选股工具、研究笔记、投资组合报告,以及不需要实时逐笔成交数据的仪表盘。

历史覆盖年限并非越长越好

只有采用一致的方式处理退市证券、公司行动、交易日历和证券标识符,时间跨度更长的数据才真正有价值。

免费不等于无限制

免费套餐通常会限制请求额度、可查询的历史年限、覆盖的交易所和证券数量,并可能限制批量下载或商业用途。

Treat “historical stock data” as a research package, not only a price series. For one security it should connect raw and adjusted OHLCV to corporate actions, listing identity, currency, and exchange calendar. For a multi-security backtest it must also preserve the point-in-time universe and inactive listings. Use the narrower historical stock price guide when only price-field semantics matter; use a market-wide dataset workflow when the main problem is reconstructing the full cross-section.

“历史股票数据”应被视为一套研究数据包,而不只是价格序列。对于单只证券,它应把原始与复权 OHLCV 同公司行为、上市身份、币种和交易所日历关联起来;对于多证券回测,还必须保留历史时点股票池和已失效上市记录。如果只关心价格字段口径,可以采用更窄的历史股票价格指南;如果核心问题是还原全市场横截面,则需要全市场数据工作流。

What a historical stock data response should include历史股票数据接口应返回哪些字段

Field字段What it tells you含义What to verify需要核对
OHLCOpen, high, low, and close for each interval.每个周期的开盘价、最高价、最低价和收盘价。Interval, exchange calendar, and timezone.时间粒度、交易日历与时区。
Volume成交量Shares traded during the session.该交易时段内成交的股票数量。Units, venue aggregation, and corrections.计量单位、不同交易场所的汇总口径及数据更正规则。
Adjusted close复权收盘价A series normalized for splits and sometimes dividends.按拆股因素调整,并可能计入分红影响的收盘价序列。Adjustment method and revision timing.复权计算方法及历史数据的修订时间。
Symbol metadata证券标识信息Ticker, exchange, currency, and asset identity.证券代码、交易所、计价币种和资产身份标识。Delisted tickers and symbol changes.退市证券的代码及证券代码变更记录。
Corporate actions公司行为Splits, cash and stock dividends, spin-offs, rights, mergers, and successor mappings.拆股、现金与股票分红、分拆、配股、并购和后续证券映射。Ex-date, effective date, factor, amount, currency, and revision.除权除息日、生效日、因子、金额、币种和修订。
Security master证券主数据Stable security, listing, company, share-class, and identifier history.稳定的证券、上市地、公司、股份类别和标识历史。Ticker text is not used as permanent identity.不能把股票代码文本当作永久身份。
Calendar and status日历与状态Trading sessions, holidays, early closes, halts, listing and delisting dates.交易时段、节假日、提前收盘、停牌、上市与退市日期。No-trade sessions are separated from missing data.无交易时段与数据缺失能够区分。
Provenance数据来源Provider, endpoint, source time, retrieval time, request, and dataset version.服务商、接口、来源时间、获取时间、请求和数据集版本。Every changed historical row can be explained.每条发生变化的历史记录都能解释。

Worked split-adjustment example. A stock closes at $200 before a 2-for-1 split and at $102 on the first post-split session. Comparing raw closes produces a false return of (102 ÷ 200) − 1 = −49%. Adjusting the pre-split close to $100 produces the economically meaningful price return of (102 ÷ 100) − 1 = +2%. Historical share volume normally requires the inverse adjustment so pre-split price and volume remain comparable. Cash dividends need a separate total-return method; never assume that an adjusted_close field includes dividends merely because it includes splits. Store the provider’s action record, factor, effective date, and adjustment version with the derived series.

拆股复权计算示例。 某股票在 1 拆 2 前收于 200 美元,拆股后首个交易日收于 102 美元。直接比较原始收盘价会得到 (102 ÷ 200) − 1 = −49% 的虚假跌幅;把拆股前收盘价复权为 100 美元后,才得到 (102 ÷ 100) − 1 = +2% 的真实价格收益。历史成交股数通常需要按相反方向调整,才能让拆股前后的价格与成交量保持可比。现金分红则需要单独的总回报计算方法;不能因为 adjusted_close 包含拆股复权,就默认它也计入现金分红。应把供应商的公司行动记录、复权因子、生效日期和复权版本与派生序列一起保存。

How to evaluate a free historical stock data API如何评估免费历史股票数据 API

Demand point-in-time symbol history

Backtests need securities that later delisted, renamed, merged, changed exchanges, or changed tickers. A current-symbol endpoint alone produces a survivor-only universe.

Separate price history from security master history

Join bars to a stable security ID with effective-dated ticker, exchange, currency, share class, and listing status instead of treating the ticker as permanent identity.

Version corporate-action adjustments

Store splits, cash and stock dividends, spin-offs, rights issues, and merger treatment. Preserve both as-traded prices and the exact adjustment factors used by each research run.

Test long-window extraction economics

Estimate symbols, intervals, years, pagination, bulk exports, inactive-security access, and repair passes. One free call for AAPL does not prove a complete research universe is feasible.

Measure dataset completeness

For sampled dates and venues, compare expected listings with returned observations; report missing, stale, duplicate, zero-volume, currency-mismatched, and unadjusted records rather than only API success.

Audit delisting and merger outcomes

Verify final trading values, cash or stock consideration, successor securities, suspended periods, and the date coverage ends. Omitting these outcomes can materially inflate backtests.

Read data rights for the complete workflow

Confirm storage, caching, bulk extraction, model training, internal sharing, client display, derived results, and redistribution. Free API access may allow some but not all stages.

要求时点一致的代码历史

回测需要后来退市、更名、合并、转板或更换代码的证券。只提供当前代码的端点会生成仅含幸存者的资产范围。

区分价格历史与证券主数据历史

用稳定证券 ID 关联日线,并按生效日期保存代码、交易所、币种、股份类别和上市状态,不能把 ticker 当成永久身份。

为公司行动复权设置版本

保存拆股、现金与股票分红、分拆、配股和并购处理,同时保留实际成交价及每次研究使用的精确复权因子。

测试长区间提取成本

估算证券数、周期、年限、分页、批量导出、失效证券访问和修复轮次。免费获取一次 AAPL 并不能证明完整研究范围可行。

测量数据集完整性

选取多个日期和交易场所,比较预期上市证券与实际观测,并报告缺失、陈旧、重复、零成交量、币种不一致和未复权记录,不能只统计 API 是否成功。

审计退市与并购结果

核对最后交易价格、现金或换股对价、后续证券、停牌期间和覆盖终止日期。遗漏这些结果会显著高估回测表现。

核对完整工作流的数据权利

确认数据能否存储、缓存、批量提取、用于模型训练、内部共享、向客户展示、生成衍生结果或再分发。免费 API 访问可能只允许其中部分环节。

A reliable historical data ingestion workflow可靠的历史行情数据接入流程

  1. Freeze a point-in-time security universe that includes active and inactive listings, then map every historical ticker to a stable security ID.
  2. Backfill deterministic date partitions and store raw bars, security-master snapshot, corporate actions, and provider version together.
  3. Validate exchange calendars, currencies, share classes, duplicate listings, delisting returns, and unexplained gaps before calculating factors.
  4. Save an immutable research snapshot so later vendor repairs or adjustment changes cannot silently alter a published backtest.
  5. Partition raw downloads by provider, endpoint, security ID, interval, and date; fingerprint every request and retain headers, cursors, status, and retrieval time.
  6. Build normalized bars and adjustment layers without overwriting the as-traded source values; keep null and correction semantics explicit.
  7. Run point-in-time joins using valid-from and valid-to intervals for ticker, exchange, currency, share class, classification, and listing status.
  8. Publish a data-quality manifest with row counts, expected sessions, missing bars, corporate-action coverage, excluded securities, and unresolved errors for each run.
  1. 冻结包含在市与退市证券的时点资产范围,再把每个历史 ticker 映射到稳定证券 ID。
  2. 按确定性日期分区回填,并把原始行情、证券主数据快照、公司行动和供应商版本一起保存。
  3. 计算因子前检查交易所日历、币种、股份类别、重复上市、退市收益和无解释缺口。
  4. 保存不可变研究快照,避免供应商后续修复或复权变化悄然改变已发布回测。
  5. 按服务商、接口、证券 ID、周期和日期划分原始下载,为每次请求生成指纹,并保留响应头、游标、状态和获取时间。
  6. 生成标准化 K 线和复权层时,不能覆盖实际成交口径的原始值;空值和更正语义必须明确保留。
  7. 使用有效起止日期关联股票代码、交易所、币种、股份类别、分类和上市状态,确保所有关联符合历史时点。
  8. 每次运行都发布数据质量清单,列明记录数、预期交易时段、缺失 K 线、公司行为覆盖、被排除证券和未解决错误。

Use QVeris to discover stock data capabilities使用 QVeris 查找股票数据能力

QVeris helps agents discover and inspect callable financial-data capabilities without hardcoding a single provider first. Compare a tool’s input schema, coverage, and output shape, then call the capability that fits your workflow.

QVeris 可帮助智能体查找并检查可调用的金融数据接口,无需先在代码中绑定某一家服务商。比较各工具的输入参数、数据覆盖范围和返回结构后,即可调用最适合当前工作流的接口。

QVeris can simplify discovery and routing across historical price, security-reference, and corporate-action capabilities. The application still owns point-in-time universes, stable identity, adjustment policy, ingestion recovery, quality manifests, research snapshots, licensing, and the decision to combine multiple sources.

QVeris 能够简化历史价格、证券参考数据和公司行为能力的查找与路由,但历史时点股票池、稳定身份、复权政策、接入恢复、质量清单、研究快照、许可,以及是否组合多个来源的决策,仍由应用方负责。

FAQ常见问题

Is historical stock data free?

Some providers offer free tiers, but history depth, exchanges, request caps, and permitted use vary.

Does historical data include adjusted prices?

Not always. Some APIs return raw and adjusted series; others require a separate endpoint or paid plan.

Can I use free historical data for backtesting?

Usually for personal research, provided you handle survivorship bias, corporate actions, calendar gaps, and revisions.

历史股票数据可以免费获取吗?

部分服务商提供免费套餐,但可查询的历史年限、覆盖的交易所、请求上限和允许的用途各不相同。

历史数据包含复权价格吗?

不一定。有些 API 会同时返回未复权与复权价格序列,另一些则需要调用单独的接口或订阅付费套餐。

免费历史数据可以用于回测吗?

通常可用于个人研究,但需要妥善处理幸存者偏差、公司行动、交易日历缺口和历史数据修订。

Historical stock data or historical stock prices?

Prices are one component. A research-ready stock dataset also includes stable identifiers, listing status, calendars, currency, corporate actions, adjustments, and provenance.

How should delisting returns be handled?

Use the final available trade and documented cash, merger, bankruptcy, or successor outcome under a consistent policy. Do not drop the security on its last normal trading day without recording the terminal event.

Should vendor corrections change an old backtest?

Not silently. Retain immutable original and corrected dataset versions, rerun under a controlled process, and report whether results changed because of data or model code.

Can multiple free APIs be combined?

Yes, but identifiers, calendars, currencies, adjustments, units, timestamps, licenses, and source priority must be reconciled. Preserve provenance at field or row level.

历史股票数据与历史股票价格有什么区别?

价格只是其中一部分。可用于研究的股票数据集还需要稳定标识、上市状态、交易日历、币种、公司行为、复权和来源记录。

退市收益应该怎样处理?

应依据统一政策,使用最后可得成交和有文档的现金、并购、破产或后续证券结果。不能在最后一个正常交易日直接删除证券而不记录终止事件。

服务商更正数据后,旧回测应该自动改变吗?

不能静默改变。应保留不可变的原始与更正版本,通过受控流程重新运行,并说明结果变化来自数据还是模型代码。

可以组合多个免费 API 吗?

可以,但必须统一标识、日历、币种、复权、单位、时间戳、许可和来源优先级,并在字段或记录层保留数据来源。

Authoritative references权威参考资料