簡體   English   中英

如何在 TDAmeritrade API 中獲取 EUR/USD 等外匯價格歷史?

[英]How to get the price history of forex in TDAmeritrade API such as EUR/USD?

我使用 API 文檔中記錄的 TD Ameritrade API。

獲取價格歷史記錄的 URL 包含要獲取的資產的符號。

在此處輸入圖像描述

文檔說:

將 URL 中的{symbol}替換為實際符號

它適用於 GOOG、AAPL 或 FB 等股票代碼。

例如,對於 AAPL,url 將是: https://api.tdameritrade.com/vi/marketdata/AAPL/pricehistory

But with symbols that contain a backslash like the EUR/USD spot, it does not work because the backslash is considered as an additional path to the URL So I get URL not found withhttps://api.tdameritrade.com/vi/marketdata /歐元/美元/價格歷史

EUR/CADEUR/GBP和其他外匯現貨相同。 如何獲取外匯現貨?

在貨幣之間使用點而不是斜線。 所以這將起作用:https://api.tdameritrade.com/v1/marketdata/EUR.USD/pricehistory

是的,文檔對此很垃圾,甚至符號查找也將斜杠作為符號的一部分返回,例如。 GBP/USD 作為有效交易品種:

{
  "GBP/USD": {
    "symbol": "GBP/USD",
    "description": "GBPound/US Dollar Spot",
    "exchange": "GFT",
    "assetType": "FOREX"
  }
}

對於其他經紀人(X Trade Brokers),您可以在NodeJS https://github.com/peterszombati/xapi-node#get-eurusd-m1-price-history中請求 EURUSD 價格歷史

使用此模塊的請求價格歷史記錄很簡單,就像這段代碼一樣

x.onReady(() => {
    x.getPriceHistory({
        symbol:'EURUSD',
        period: PERIOD_FIELD.PERIOD_M1
    }).then(({candles, digits}) => {
        console.log(candles.length);
        console.log(candles[0]);
        console.log('digits = ' + digits);
    })
});

pricehistory端點僅提供股票期權指數價格 我收到了來自 TD Ameritrades 產品經理之一的 email 確認:

你好托比亞,

感謝您提供 email,對於延遲回復我深表歉意。

外匯數據只能通過獲取報價端點獲得 以下是同時請求多個外匯交易品種以獲取即時報價的示例:https://api.tdameritrade.com/v1/marketdata/quotes?apikey=YING4&symbol=EUR%2FUSD%2CUSD%2FJPY

獲取價格歷史目前僅適用於股票、期權和指數 期貨和外匯工具將無法通過該端點獲得。

親切的問候,

Michael Ying 產品經理,Trader TD Ameritrade 600 W Chicago Ave, Chicago, IL 60654

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM