Closed 3rock618 closed 5 years ago
I've found the problem. The order object in handleOrders comes back where order['account'] = ''
. However tws.getPositions(None)
is not the same as tws.getPositions('')
, hence the error.
Since I'd rather not mess with the whole order object pipeline (it's a bit hairy), I can monkeypatch getPositions
with if account == '': account = None
import ezibpy
# MONKEY PATCH
def getPositions(self, account=None):
if len(self._positions) == 0:
return {}
if account == '':
account = None
account = self._get_default_account_if_none(account)
if account is None:
if len(self._positions) > 1:
raise ValueError("Must specify account number as multiple accounts exists.")
return self._positions[list(self._positions.keys())[0]]
if account in self._positions:
return self._positions[account]
raise ValueError("Account %s not found in account list" % account)
ezibpy.ezIBpy.getPositions = getPositions
Hi,
Thanks for pointing that out!
I've updated the library to use a more fool-proof_get_active_account()
(foremarly _get_default_account_if_none()
) to handle this. I've also made sure that handleOrders
uses None
as the default account value instead of ""
. This should do the trick :)
Please update to 1.12.69 to get the changes and let me know if the problem is solved.
Thanks, Ran
Problem still persists in .68, when I debug getPositions it tells me that account = ''
Thanks!
When calling getPositions()
- are you not getting the positions, or are you just not getting the account code?
Also - do you call getPositions()
with or without specifying the account?
?
Working from the github version, this is solved now. 👍🏼🙏🏼 Thanks Ran for all your great work!
1.12.67 was working fine, error with 1.12.68:
When I place an a basic market order I get the following error:
Using TWS I can see that the order completes successfully. Also when I type tws.getPositions() I get my positions back as normal.