[英]Interactive Brokers: Unable to fetch Forex Historical data
I am trying IB very the first time.我是第一次尝试 IB。 I am trying to fetch historical data of $EUR but I am getting an error:我正在尝试获取 $EUR 的历史数据,但出现错误:
Error 162, reqId 3: Historical Market Data Service error message:No historical market data for EUR/CASH@FXSUBPIP Last 1800, contract: Contract(secType='CASH', symbol='EUR', exchange='IDEALPRO', currency='USD')错误 162,reqId 3:历史市场数据服务错误消息:没有 EUR/CASH 的历史市场数据@FXSUBPIP Last 1800,合约:Contract(secType='CASH', symbol='EUR', exchange='IDEALPRO', currency= '美元')
Below is my code:下面是我的代码:
import datetime
from ib_insync import *
if __name__ == '__main__':
ib = IB()
r = ib.connect('127.0.0.1', port=7497, clientId=1)
contract = Contract()
contract.symbol = "EUR"
contract.secType = "CASH"
contract.currency = "USD"
contract.exchange = "IDEALPRO"
data = ib.reqHistoricalData(
contract=contract,
endDateTime='',
durationStr='100 D',
barSizeSetting='30 mins',
useRTH=True,
whatToShow='ADJUSTED_LAST'
)
https://interactivebrokers.github.io/tws-api/historical_bars.html#available_products_hd https://interactivebrokers.github.io/tws-api/historical_bars.html#available_products_hd
You can see that whatToShow='ADJUSTED_LAST'
needs to be something available for forex like MIDPOINT
.您可以看到whatToShow='ADJUSTED_LAST'
需要像MIDPOINT
这样的外汇可用的东西。 Obviously there are no dividends to adjust for.显然没有股息可以调整。
Also, there is no real forex exchange and comprehensive data, all you get is what is happening at IB.此外,没有真正的外汇交易和综合数据,您得到的只是 IB 的情况。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.