For code/output blocks: Use ``` (aka backtick or grave accent) in a single line before and after the block. See: http://commonmark.org/help/
Can't trade commodity (XAUUSD) on IB paper account
-
Some test codes:
cerebro = bt.Cerebro() cerebro.addstrategy(A_Strategy) ibstore = bt.stores.IBStore( host = '192.168.0.120', port = 7497, _debug = True, ) cerebro.broker = ibstore.getbroker() data = ibstore.getdata( dataname = 'XAUUSD', sectype = 'CMDTY', ) cerebro.adddata(data)
Which
- doesn't invoke
next()
's of A_Strategy at all, only its__init__()
. - doesn't print out the OHLC information.
But for example
'EUR.USD-CASH-IDEALPRO'
works well, invokes the strategy properly, and prints out OHLC information from IB. - doesn't invoke
-
@yangnw said in Can't trade commodity (XAUUSD) on IB paper account:
sectype = 'CMDTY',
CMDTY
is not a supported security type. The platform doesn't know what to do with it. The known types are listed in the documentation: Docs - Data Feeds Reference under IBData. -
Thanks. Is it possible to implement its support? Its request signature is exactly the same as STK, the only difference probably lies in how to parse the received messages, etc. in
tickPrice()
andtickSize()
. It would be greatly appreciated. -
This will be looked into.
-
Quick fix, though in no way tested:
- in
stores/ibstore.py
, lines 725, 751 and 836, add 'CMDTY', etc.if contract.m_secType in ['CASH', 'CFD', 'CMDTY']: ..
- when defining the data feed, use full kwargs, etc.
data = ibstore.getdata( dataname = 'XAUUSD', sectype = 'CMDTY', exchange = "SMART", currency = "USD", )
- in