期货 · 商品 · 指数 · 贵金属

期货行情 API

外盘期货与国内商品期货,一个接口实时接入

高频期货行情接口,支持通过 WebSocket 订阅国内外期货实时行情,可回溯最长 3 年的 1 分钟 K 线。同时提供主力连续合约与单月合约。

  • 支持现货、期货、CFD 报价
  • 提供最佳 1 档盘口
  • 7 天免费试用
期货与商品覆盖

全球关键合约标的,一个接口接入

覆盖全球主要市场及多元资产类别,从股指期货到大宗商品合约,通过统一接口获取字段一致的行情数据,并支持 WebSocket 实时推送。

类别类型品种数量示例
股指期货Futures64ES · NQ · YM · RTY · HSI · NKD · FDAX
能源期货Futures12CL · BZ · NG · HO · TTF
全球指数CFDINDEX35US500 · NAS100 · GER40 · JPN225 · HSII
贵金属期货Futures18GC · SI · HG · PA · ALI
农产品期货Futures29ZC · ZS · ZW · LE · HE
利率期货Futures26ZT · ZF · TN · ZB · SR3
外汇期货Futures406E · 6J · 6B · 6A · CNH
现货与 CFD 贵金属SpotCFD17XAUUSD · XAGUSD · XPTUSD · XCUUSD
加密货币期货Futures25BTC · ETH · SOL · XRP
商品指数Futures3AW · GD · ECF
国内商品期货Futures41AU · CU · RB · RU · TA · CF
现货与 CFD 能源SpotCFD4WTI · USOIL · UKOIL · NGAS

数据统计截至 2026 年 10 月。品种会持续增加,实际数量以接口返回为准。

API 在线调试

热门期货合约,在线体验实时数据

点击任意品种,立即测试实时数据。

XAUUSD
Gold / USD
-USD
-
在线调试
XAGUSD
Silver / USD
-USD
-
在线调试
XCUUSD
Copper / USD
-USD
-
在线调试
NGAS
Natural Gas
-USD
-
在线调试
合约类型

连续合约与单月合约

用一条不中断的价格序列回测,也可以深入到具体到期月份,不用手动拼接各个月份的合约。

连续合约

每个品种一个代码,始终指向当前合约。适合长周期回测、图表和交易信号,不会在换月时出现断点。

单月合约

指定具体到期月份,比如 12 月原油,用于跨期价差、换月分析和与到期日相关的策略。

获取免费 API Key
行情数据接口

期货实时与历史数据

通过 WebSocket 实时订阅成交、K 线和盘口,或通过 REST 查询快照和期货历史数据。期货、现货、CFD 用同一套请求方式。

Infoway Real-time Futures API
POSThttps://data.infoway.io/common/v2/batch_kline
import requests

api_url = "https://data.infoway.io/common/v2/batch_kline"

headers = {
    "User-Agent": "Mozilla/5.0",
    "Accept": "application/json",
    "Content-Type": "application/json",
    "apiKey": "yourApikey",
}

payload = {
    "klineType": 1,
    "klineNum": 10,
    "codes": "CL,GC,NG"
}

response = requests.post(api_url, headers=headers, json=payload)
print(f"HTTP code: {response.status_code}")
print(f"message: {response.text}")
为什么选择 Infoway

稳定可靠的期货行情API接口

实时与历史数据

实时与历史行情,同一个接口搞定。

WebSocket 高频推送

成交、K 线、盘口通过一条连接实时推送,无需轮询。

期货、现货、CFD

三种类型清楚标注,同一套数据格式。

连续 + 单月合约

连续合约用于回测,单月合约应对到期月策略。

最高1档盘口

所有期货只提供最佳 1 档买卖盘。

7天免费试用

注册账号自动获得试用API Key,无需绑定信用卡。

获取免费 API Key

用 Infoway API 构建你的产品

为你的金融产品、交易策略、研究和工作流提供数据。

量化交易

跨换月回测

直接用连续合约的 1 分钟数据跑策略,做跨期价差时再切换到单月合约。

import time

import pandas as pd
import requests

URL = "https://data.infoway.io/common/v2/batch_kline"  # futures, spot and CFD
HEADERS = {"apiKey": "YOUR_API_KEY"}


def fetch_continuous(symbol, pages=10):
    """1-minute candles for a continuous contract, 500 per request.
    The series already rolls from month to month, so there is nothing to stitch."""
    rows, ts = [], None
    for _ in range(pages):
        body = {"klineType": 1, "klineNum": 500, "codes": symbol}
        if ts:
            body["timestamp"] = ts
        resp = requests.post(URL, headers=HEADERS, json=body, timeout=10).json()
        if resp.get("ret") != 200 or not resp.get("data"):
            break  # e.g. the request reaches past your plan's history
        batch = resp["data"][0]["respList"]  # newest first
        if not batch:
            break
        rows += batch
        ts = int(batch[-1]["t"]) - 60  # continue before the oldest candle
        time.sleep(1)  # stay within your plan's rate limit
    df = pd.DataFrame(rows).drop_duplicates("t")
    df["t"] = pd.to_datetime(df["t"].astype(int), unit="s")
    return df.set_index("t").sort_index()[["o", "h", "l", "c", "v"]].astype(float)


bars = fetch_continuous("CL")  # WTI crude oil, continuous contract
bars_15m = bars.resample("15min").agg(
    {"o": "first", "h": "max", "l": "min", "c": "last", "v": "sum"}
).dropna()  # skips the daily break and weekends

# Breakout: long above the 20-bar high, short below the 20-bar low
upper = bars_15m["h"].rolling(20).max().shift(1)
lower = bars_15m["l"].rolling(20).min().shift(1)
signal = pd.Series(float("nan"), index=bars_15m.index)
signal[bars_15m["c"] > upper] = 1
signal[bars_15m["c"] < lower] = -1
position = signal.ffill().fillna(0).shift(1).fillna(0)
returns = bars_15m["c"].pct_change().fillna(0)

print(f"{len(bars):,} one-minute bars, {bars.index[0]:%Y-%m-%d} to {bars.index[-1]:%Y-%m-%d}")
print(f"Buy & hold: {(1 + returns).prod() - 1:.2%}")
print(f"Breakout:   {(1 + position * returns).prod() - 1:.2%}")
CFD 平台

一条数据流,接入多类型、多市场期货合约

用一条 WebSocket 连接,驱动股指、商品和贵金属的报价板、图表和下单界面。

import asyncio
import json
import uuid

import websockets

WS_URL = "wss://data.infoway.io/ws?business=common&apikey=YOUR_API_KEY"

# Futures, spot and CFD symbols share one connection and one message format
BOARD = {
    "GC": "Futures",       # gold futures, continuous (USD/oz)
    "XAUUSD": "Spot",      # spot gold (USD/oz)
    "HG": "Futures",       # copper futures, continuous (USD/lb)
    "XCUUSD": "CFD",       # copper CFD (USD/lb)
    "XCUUSD_S": "Spot",    # spot copper (USD/t)
}
last = {}


def frame(code, data=None):
    msg = {"code": code, "trace": uuid.uuid4().hex}
    if data is not None:
        msg["data"] = data
    return json.dumps(msg)


async def heartbeat(ws):
    while True:
        await asyncio.sleep(30)
        await ws.send(frame(10010))


def on_trade(symbol, price):
    last[symbol] = price
    line = f"{symbol:<9} {BOARD[symbol]:<8} {price:>12,.4f}"
    if "GC" in last and "XAUUSD" in last:
        line += f"   gold futures vs spot: {last['GC'] - last['XAUUSD']:+.2f}"
    print(line)


async def quote_board():
    while True:
        try:
            async with websockets.connect(WS_URL) as ws:
                await ws.send(frame(10000, {"codes": ",".join(BOARD)}))
                hb = asyncio.create_task(heartbeat(ws))
                try:
                    async for raw in ws:
                        msg = json.loads(raw)
                        if msg.get("code") == 10002:  # trade push
                            data = msg["data"]
                            on_trade(data["s"], float(data["p"]))
                finally:
                    hb.cancel()
        except (websockets.ConnectionClosed, OSError):
            await asyncio.sleep(5)  # back off before reconnecting


asyncio.run(quote_board())
AI 与大模型智能体

为你的 AI 提供高质量行情数据

通过 API 或 MCP 服务,为大模型和交易智能体提供结构化的实时价格、基本面数据和新闻。

立即开始

选择适合你的接入方式

Infoway 官方 SDK

用对开发者友好的 SDK,在代码里直接获取 Infoway 行情数据,轻松完成集成。

Google Sheets 插件

把行情数据直接导入 Google Sheets,不写代码也能分析、跟踪和处理金融数据。

立即安装

常见问题

如需帮助,请随时联系客服。

免费开始使用市场数据

免费试用 Infoway 市场数据 API,马上获取接口访问权限。只需使用邮箱注册,即可获得您的 API Key。

获取免费APIKey 无需信用卡