Choose a Free Forex Historical Data API
for Rates and OHLC选择适合汇率与回测的
免费外汇历史数据 API
Compare free historical FX APIs by data type, coverage, interval, limits, and output—then retrieve and validate the right series.
按数据类型、历史范围、时间粒度、免费限制与返回格式比较接口,
再获取并校验适合分析或回测的外汇序列。
Free forex historical data API: quick answer免费外汇历史数据 API:快速结论
Daily reference rates and intraday OHLC candles solve different jobs. Confirm the required pair, interval, history, and timezone first.
A free plan may limit calls, symbols, history, redistribution, or commercial use. Verify current provider terms before building.
Check timestamps, missing bars, weekends, bid/ask versus midpoint, duplicates, and candle definitions before analysis.
QVeris can help an agent discover and inspect available FX data capabilities; provider availability and cost signals must be checked at call time.
每日参考汇率与分钟级 OHLC K线用途不同。先确定货币对、粒度、历史范围与时区。
免费层可能限制调用数、货币对、历史区间、再分发或商业用途,接入前必须核对当前条款。
检查时间戳、缺失 K线、周末、买卖价或中间价、重复记录与 K线定义。
QVeris 可帮助 Agent 发现并检查外汇数据能力;具体供应商可用性与成本信号应在调用时确认。
What a forex historical data API can return外汇历史数据接口可以返回什么
Historical reference rates and tradable market candles solve different tasks. A useful forex historical-data response identifies the base and quote currencies, timestamp, source or price basis, and requested interval instead of returning an unexplained number.
历史参考汇率与可用于交易分析的市场 K 线解决的是不同任务。可靠的外汇历史数据响应应明确基础货币、报价货币、时间戳、数据来源或价格口径,以及请求粒度,而不是只返回一个无法解释的数值。
Daily or periodic reference rates suit accounting, reporting, conversion, and long-range analysis. They are not necessarily executable trading prices.
Open, high, low, and close values support charting and backtesting. Confirm whether candles use bid, ask, midpoint, or a provider-specific composite.
Higher-frequency strategies may need bid/ask quotes or ticks. These datasets are larger and are less commonly included in a permanent free tier.
JSON is convenient for applications; CSV or NDJSON is often easier for long date ranges, pandas, and reproducible research.
每日或定期参考汇率适合财务、报表、换算与长期分析,但不一定是可成交价格。
开高低收可用于图表和回测。需确认 K线使用买价、卖价、中间价,还是供应商组合价格。
高频策略可能需要买卖报价或 Tick。此类数据量更大,永久免费层通常更少见。
JSON 便于应用调用;长区间、pandas 和可复现实验通常更适合 CSV 或 NDJSON。
Reference rates, candles, and ticks are not interchangeable参考汇率、K线与 Tick 不能互相替代
A central-bank reference series may publish one rate per working day and can be ideal for accounting or macro analysis. A broker candle aggregates quotes over a fixed interval and may use bid, ask, midpoint, or another convention. Tick data records individual quote changes. Choosing the wrong class can make a chart look plausible while making a backtest invalid.
央行参考序列可能每个工作日只发布一次,适合会计换算或宏观分析;经纪商 K线把固定区间内的报价聚合为开高低收,并可能采用买价、卖价或中间价;Tick 数据则记录逐次报价变化。数据类型选错时,图表可能看似合理,但回测结论并不成立。
Historical availability is not always point-in-time availability现在能查到的历史,不一定是当时可获得的历史
Reference series can be revised, corrected, or backfilled, while vendor candles may be rebuilt after late ticks or feed repairs. For research that claims point-in-time realism, keep retrieval time, raw-file checksum, revision status, and the first date the observation was available. A clean download today may contain information that was not present on the original trading date.
参考汇率序列可能被修订、纠错或补录,供应商 K线也可能在迟到 Tick 或行情修复后重新生成。若研究要求真实还原当时信息,应保存抓取时间、原始文件校验值、修订状态和观测值首次可用日期。今天下载到的完整历史,可能包含原交易日尚不存在的信息。
A price history alone does not make a tradable backtest只有价格历史并不能形成可交易回测
A midpoint candle omits spread, liquidity, slippage, financing, rollover, and execution delay. Model those costs separately and align them with the strategy's session and holding period. If the provider does not expose historical bid/ask or spread, state that limitation instead of treating midpoint returns as executable performance.
中间价 K线没有包含点差、流动性、滑点、融资成本、隔夜展期和执行延迟。应根据策略交易时段与持有周期单独建模这些成本。若供应商不提供历史买卖价或点差,就应明确披露限制,而不是把中间价收益当成可成交表现。
Fields to require in a historical forex response历史外汇响应中应具备的字段
- Explicit base and quote currencies, plus unambiguous pair orientation.
- ISO-8601 timestamps with a documented timezone and interval boundary.
- A price basis such as reference, bid, ask, midpoint, or composite.
- For candles: open, high, low, close, and—only when meaningful—volume.
- Pagination or continuation metadata for date ranges larger than one response.
- 明确的基础货币、报价货币与货币对方向。
- ISO-8601 时间戳、已说明的时区与区间边界。
- 参考价、买价、卖价、中间价或组合价等价格口径。
- K线应包含开、高、低、收;只有在有意义时才使用成交量。
- 跨多个响应获取长日期区间时所需的分页或游标信息。
Invert a candle without corrupting its high and low反转货币对时不能破坏最高价与最低价
Suppose a EUR/USD candle has open 1.1000, high 1.1200, low 1.0800, and close 1.1100. The inverse USD/EUR candle does not keep the original high and low positions. Its open is 1 ÷ 1.1000 = 0.9091, its high is 1 ÷ 1.0800 = 0.9259, its low is 1 ÷ 1.1200 = 0.8929, and its close is 1 ÷ 1.1100 = 0.9009.
假设一根 EUR/USD K 线的开盘价为 1.1000、最高价 1.1200、最低价 1.0800、收盘价 1.1100。反转成 USD/EUR 时,最高价和最低价不能保留原字段位置。新开盘价是 1 ÷ 1.1000 = 0.9091,新最高价来自原最低价,即 1 ÷ 1.0800 = 0.9259;新最低价来自原最高价,即 1 ÷ 1.1200 = 0.8929;新收盘价为 1 ÷ 1.1100 = 0.9009。
Validation rule: after inversion, require low ≤ open/close ≤ high, preserve the original pair and transformation, and avoid inverting rounded display values when higher-precision source values exist. A provider-native inverse pair may still differ because it can use a separate quote stream, spread, or liquidity source.
验证规则:反转后仍应满足 最低价 ≤ 开盘价/收盘价 ≤ 最高价,并保存原货币对与转换方法;存在更高精度源数据时,不要对已舍入的展示值取倒数。供应商原生提供的反向货币对仍可能不同,因为它可能采用另一条报价流、点差或流动性来源。
How to compare a free forex historical data API如何比较免费外汇历史数据 API
| Check检查项 | Questions to ask需要确认 | Why it matters影响 | Red flag风险信号 |
|---|---|---|---|
| Coverage覆盖范围 | Which pairs, dates, and sessions are available?支持哪些货币对、日期与交易时段? | Determines whether the dataset fits the research period.决定数据能否覆盖研究区间。 | No source or history boundary.不说明来源或历史边界。 |
| Granularity时间粒度 | Daily rates, hourly candles, minutes, or ticks?日汇率、小时、分钟 K线还是 Tick? | Controls charting and backtest resolution.决定制图与回测分辨率。 | “Real time” without an interval definition.只说“实时”但不定义粒度。 |
| Free limits免费限制 | Calls, rows, symbols, retention, and license?调用、行数、品种、留存与许可限制? | Prevents a prototype from failing at scale.避免原型放大后不可用。 | No published quota or terms.不公开额度或使用条款。 |
| Data quality数据质量 | Timezone, gaps, revisions, bid/ask, and timestamps?时区、缺口、修订、买卖价与时间戳? | Avoids false backtest signals.避免产生虚假回测信号。 | Undocumented candle construction.不说明 K线构造方式。 |
Free tier, open endpoint, and free trial mean different things免费层、开放端点与免费试用含义不同
An open endpoint may work without registration but still require attribution and enforce fair-use limits. A free tier normally needs an API key and resets a quota daily or monthly. A trial may expire or expose premium history temporarily. Record the plan name, quota, historical depth, allowed use, attribution rule, and review date instead of storing a single “free: true” flag.
开放端点可能无需注册,但仍要求署名并执行合理使用限制;免费层通常需要 API Key,并按日或按月重置额度;试用则可能到期,或只暂时开放高级历史数据。不要只记录一个“是否免费”,应同时记录套餐名称、额度、历史深度、许可用途、署名要求和核验日期。
A practical shortlist decision实用的候选接口筛选方法
Keep a provider only if it satisfies the non-negotiable pair, date range, interval, price basis, and license. Then compare authentication effort, pagination, quota, response format, documentation quality, and failure behavior. This prevents a generous request allowance from masking an unusable dataset.
只有同时满足必需货币对、日期范围、粒度、价格口径与许可的接口才进入候选名单;之后再比较鉴权成本、分页、额度、格式、文档质量和失败行为。这样可以避免“调用次数很多”掩盖“数据本身不适用”的问题。
How to get forex historical data with an API in Python如何用 Python API 获取外汇历史数据
Write down EUR/USD versus USD/EUR, UTC handling, start and end dates, and whether you need daily reference rates or OHLC candles.
Confirm authentication, pagination, rate limits, date format, response fields, error codes, and whether the API supports JSON, CSV, or both.
Use a timeout, check the HTTP status, parse timestamps as timezone-aware values, sort by time, and map provider fields to a stable internal schema.
Reject duplicates, impossible high/low values, inverted pairs, unexpected gaps, and records outside the requested interval. Cache immutable history within the license terms.
明确 EUR/USD 与 USD/EUR、UTC 处理、起止日期,以及需要日参考汇率还是 OHLC K线。
确认鉴权、分页、限频、日期格式、返回字段、错误码,以及是否支持 JSON 或 CSV。
设置超时、检查 HTTP 状态、按带时区时间戳解析、排序,并把供应商字段映射到稳定内部结构。
排除重复、异常高低价、反向货币对、意外缺口和区间外记录;在许可范围内缓存不可变历史数据。
Provider-neutral Python request pattern与供应商无关的 Python 请求模式
requests.get(url, params={"base":"EUR","quote":"USD","from":"2024-01-01","to":"2024-12-31"}, timeout=20)
requests.get(url, params={"base":"EUR","quote":"USD","from":"2024-01-01","to":"2024-12-31"}, timeout=20)
Treat this as a request shape, not a universal endpoint: every provider names parameters differently. After raise_for_status(), verify that the content type is expected, the response pair matches the request, timestamps are parseable, and the returned range is complete. Follow pagination until no continuation token remains.
这只是请求结构,不是通用端点;不同供应商的参数名并不相同。调用 raise_for_status() 后,还要检查 Content-Type、返回货币对、时间戳可解析性和日期覆盖,并持续处理分页,直到不再返回游标。
Backtest quality checks before using the file将数据用于回测前的质量检查
- Convert all timestamps to one timezone without silently dropping daylight-saving transitions.
- Confirm
low ≤ open/close ≤ highfor every candle and reject duplicates. - Explain weekend and holiday gaps separately from unexpected missing intervals.
- Do not invent volume when an OTC forex source does not provide meaningful centralized volume.
- Keep the raw response alongside normalized data so transformations remain auditable.
- 把时间戳统一到同一时区,不要静默丢失夏令时切换记录。
- 验证每根 K线满足“最低价 ≤ 开盘价/收盘价 ≤ 最高价”,并排除重复记录。
- 区分周末、节假日缺口与本应存在却缺失的时间区间。
- 场外外汇源没有有意义的集中成交量时,不要虚构 volume。
- 在标准化数据之外保留原始响应,使每一步转换都可审计。
Keep the trading-day label separate from UTC把交易日标签与 UTC 时间分开保存
A provider that defines its daily FX boundary at 17:00 in America/New_York reaches 22:00 UTC during standard time and 21:00 UTC during daylight-saving time. Do not hard-code one UTC offset or derive the provider's trading date from the UTC calendar date alone. Preserve the original timestamp, IANA timezone, local trading-date label, interval start and end, and the rule used for holidays and shortened sessions.
如果供应商以 America/New_York 时区的 17:00 作为外汇日线边界,冬令时对应 22:00 UTC,夏令时则对应 21:00 UTC。不能写死一个 UTC 偏移,也不能只根据 UTC 自然日推断供应商的交易日。应保存原始时间戳、IANA 时区、当地交易日标签、区间起止时间,以及节假日和缩短交易时段的处理规则。
Execution approximation: if the historical quote is 1.0998 bid and 1.1002 ask, the midpoint is 1.1000 but the quoted spread is 0.0004, or four pips for EUR/USD. A simulated purchase enters at the ask and a sale exits at the bid before slippage and fees. When only midpoint candles exist, label the backtest as a spread-free research approximation and run an explicit spread sensitivity test rather than reporting midpoint returns as executable performance.
执行近似:如果历史报价为买价 1.0998、卖价 1.1002,中间价是 1.1000,但报价点差为 0.0004,即 EUR/USD 的 4 个点。模拟买入应使用卖价,卖出应使用买价,随后还要考虑滑点与费用。只有中间价 K 线时,应把回测标为“不含点差的研究近似”,并单独进行点差敏感性测试,不能把中间价收益写成可成交表现。
How QVeris helps find forex historical data APIsQVeris 如何帮助查找外汇历史数据 API
QVeris is a capability routing layer, not the underlying source of every FX quote. An agent can search for a historical forex capability, inspect its parameters and current cost signals, then call the selected tool through the documented QVeris flow.
QVeris 是能力路由层,并非每一条外汇报价的原始数据源。Agent 可搜索历史外汇能力,检查参数与当前成本信号,再通过 QVeris 文档流程调用所选工具。
- Discover candidate capabilities with a natural-language description of the pair, date range, and interval.
- Inspect the returned schema, provider information, reliability signals, and cost metadata before execution.
- Call only after confirming that the selected capability matches the dataset and license your workflow needs.
- 用货币对、日期范围与时间粒度的自然语言描述发现候选能力。
- 执行前检查返回 Schema、供应商信息、可靠性信号和成本元数据。
- 确认能力匹配所需数据集与许可后再调用,不把“可发现”误写成“永久免费”。
Free forex historical data API FAQ免费外汇历史数据 API 常见问题
Free API plans, open central-bank reference-rate datasets, and downloadable market archives are common starting points. Match the source to daily rates, OHLC candles, or tick data.
Yes, but “free” may mean an open endpoint, a capped free tier, or a trial. Check authentication, quotas, history, license, and attribution requirements.
Yes. Use an HTTP client, validate the status and schema, parse timezone-aware timestamps, normalize pair orientation, and then load the records into pandas.
Some providers include daily or limited intraday candles; others supply reference rates only. Never infer OHLC support from the phrase “exchange rate API.”
Only when the data resolution, price basis, history, quality, and license match the test. Validate gaps and avoid treating reference rates as executable prices.
可从免费 API 层、央行公开参考汇率或可下载行情档案入手;先区分日汇率、OHLC K线和 Tick 数据。
部分供应商提供日线或有限的日内 K线,另一些只提供参考汇率;不能仅凭“汇率 API”就推断其支持 OHLC。
通过 HTTP 客户端请求,检查状态和 Schema,解析带时区时间戳,统一货币对方向,再载入 pandas。
只有在粒度、价格口径、历史范围、质量和许可都符合时才适用,并需先检查缺口和重复记录。
不一定。免费可能是免 Key 开放端点、需注册的限额免费层或试用,必须以当前文档为准。
