我正在尝试从雅虎财经获取历史数据,但它仅为当前日期提供了如何在特定日期获得基础货币数据。
http://query.yahooapis.com/v1/public/yql?q=select+*+from+yahoo.finance.xchange+where+pair+in%28%22PKRUSD%22%2C%22PKRGBP%22%2C%22PKRKWD%22%2C%22PKRSAR%22%29&format=json&env=store://datatables.org/alltableswithkeys
答案 0 :(得分:1)
似乎无法获得您选择的两种货币的历史汇率,但是,您可以获得从USD
到世界上任何货币的历史汇率。你是这样得到的:
SELECT * FROM yahoo.finance.historicaldata WHERE symbol = "CCC=X" AND startDate = "YYYY-MM-DD" AND endDate = "YYY-MM-DD"
您可以选择YYYY-MM-DD格式的货币(CCC)和日期。例如,这将为您提供2014-10-01至2014-10-03期间从美元到瑞典克朗的汇率:
SELECT * FROM yahoo.finance.historicaldata WHERE symbol = "SEK=X" AND startDate = "2014-10-02" AND endDate = "2014-10-03"
此查询将产生以下响应:
{
query: {
count: 3,
created: "2016-09-10T12:53:42Z",
lang: "sv-SE",
results: {
quote: [
{
Symbol: "SEK%3dX",
Date: "2014-10-03",
Open: "7.182",
High: "7.29607",
Low: "7.182",
Close: "7.1817",
Volume: "000",
Adj_Close: "7.1817"
},
{
Symbol: "SEK%3dX",
Date: "2014-10-02",
Open: "7.2151",
High: "7.2174",
Low: "7.1723",
Close: "7.217",
Volume: "000",
Adj_Close: "7.217"
}
]
}
}
}
您可以随时为两种货币进行两次这样的划分,并将它们分开以获得两者之间的汇率。例如:
USD/SEK: 8.5
USD/EUR: 0.85
SEK/EUR = 8.5/0.85 = 10.
希望这个答案能够提供帮助。