期貨 · 商品 · 指數 · 貴金屬

期貨行情 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 無需信用卡