Skip to content

Commit 172f2ec

Browse files
authored
Fix ERROR:ibapi.wrapper:ERROR 25 200 No security definition has been found for the request (#36)
* Fix contract details error when subscribing to a portfolio. Resolves #33.
1 parent 483bdbc commit 172f2ec

File tree

1 file changed

+8
-0
lines changed

1 file changed

+8
-0
lines changed

src/deephaven_ib/_tws/tws_client.py

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -688,6 +688,14 @@ def accountSummary(self, reqId: int, account: str, tag: str, value: str, currenc
688688

689689
def positionMulti(self, reqId: int, account: str, modelCode: str, contract: Contract, pos: float, avgCost: float):
690690
EWrapper.positionMulti(self, reqId, account, modelCode, contract, pos, avgCost)
691+
692+
# The returned contract seems to be inconsistent with IB's API to request contract details.
693+
# This hack is to work around the problem.
694+
# See https://github.com/deephaven-examples/deephaven-ib/issues/33
695+
696+
if contract.secType == "STK":
697+
contract.exchange = "SMART"
698+
691699
self._table_writers["accounts_positions"].write_row(
692700
[reqId, account, modelCode, *logger_contract.vals(contract), pos, avgCost])
693701

0 commit comments

Comments
 (0)