Skip to content
This repository has been archived by the owner on Jan 12, 2024. It is now read-only.

KeyError looking up contract on forex order #27

Closed
jkleint opened this issue Nov 14, 2016 · 4 comments
Closed

KeyError looking up contract on forex order #27

jkleint opened this issue Nov 14, 2016 · 4 comments

Comments

@jkleint
Copy link
Contributor

jkleint commented Nov 14, 2016

I'm trying to put in an order for ("EUR", "CASH", "IDEALPRO", "USD").

Traceback (most recent call last):
  File "strategy.py", line 84, in set_position
    self.instrument.order('BUY' if qty > 0 else 'SELL', abs(qty))
  File "/progs/qtpy/python/src/qtpylib/qtpylib/instrument.py", line 180, in order
    self.parent.order(direction.upper(), self, quantity, **kwargs)
  File "/progs/qtpy/python/src/qtpylib/qtpylib/algo.py", line 470, in order
    self._create_order(**kwargs)
  File "/progs/qtpy/python/src/qtpylib/qtpylib/broker.py", line 589, in _create_order
    contract = self.get_contract(symbol)
  File "/progs/qtpy/python/src/qtpylib/qtpylib/broker.py", line 794, in get_contract
    return self.ibConn.contracts[self.ibConn.tickerId(symbol)]
KeyError: 2

If I print the relevant variables in Broker.get_contract():

symbol ('EUR', 'CASH', 'IDEALPRO', 'USD')

self.ibConn.contracts
1 {'m_expiry': '', 'm_currency': 'USD', 'm_strike': 0.0, 'm_includeExpired': False, 'm_secType': 'CASH', 'm_exchange': 'IDEALPRO', 'm_conId': 0, 'm_right': '', 'm_symbol': 'EUR'}

self.ibConn.tickerIds
0 SYMBOL
1 EURUSD_CASH

Looks like tickerId() is not matching, then creates a new ID?

@ranaroussi
Copy link
Owner

Looking into it now

@ranaroussi
Copy link
Owner

ranaroussi commented Nov 14, 2016

Works fine here... Are you running the latest ezIBpy 1.12.32?

BTW - I've created a chatroom on Gitter for exchanging ideas / features for QTPyLib and ezIBpy. I'd love it if you'd join via https://gitter.im/qtpylib

@jkleint
Copy link
Contributor Author

jkleint commented Nov 15, 2016

Latest version, no luck. I can't actually get any orders to work, so it might be a bigger issue. I'll file a separate ticket.

@ranaroussi
Copy link
Owner

Closing this then

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants