Skip to content

Commit d2f519f

Browse files
authored
IB adapter update v1030 (#2420)
1 parent 966caab commit d2f519f

File tree

9 files changed

+44
-18
lines changed

9 files changed

+44
-18
lines changed

nautilus_trader/adapters/interactive_brokers/client/client.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -24,9 +24,9 @@
2424
from ibapi import comm
2525
from ibapi.client import EClient
2626
from ibapi.commission_report import CommissionReport
27-
from ibapi.common import MAX_MSG_LEN
28-
from ibapi.common import NO_VALID_ID
2927
from ibapi.common import BarData
28+
from ibapi.const import MAX_MSG_LEN
29+
from ibapi.const import NO_VALID_ID
3030
from ibapi.errors import BAD_LENGTH
3131
from ibapi.execution import Execution
3232
from ibapi.utils import current_fn_name

nautilus_trader/adapters/interactive_brokers/client/connection.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -19,8 +19,8 @@
1919
from ibapi import comm
2020
from ibapi import decoder
2121
from ibapi.client import EClient
22-
from ibapi.common import NO_VALID_ID
2322
from ibapi.connection import Connection
23+
from ibapi.const import NO_VALID_ID
2424
from ibapi.errors import CONNECT_FAIL
2525
from ibapi.server_versions import MAX_CLIENT_VER
2626
from ibapi.server_versions import MIN_CLIENT_VER
@@ -133,8 +133,8 @@ async def _send_version_info(self) -> None:
133133
"""
134134
v100prefix = "API\0"
135135
v100version = f"v{MIN_CLIENT_VER}..{MAX_CLIENT_VER}"
136-
if self._eclient.connectionOptions:
137-
v100version += f" {self._eclient.connectionOptions}"
136+
if self._eclient.connectOptions:
137+
v100version += f" {self._eclient.connectOptions}"
138138
msg = comm.make_msg(v100version)
139139
msg2 = str.encode(v100prefix, "ascii") + msg
140140
await asyncio.to_thread(functools.partial(self._eclient.conn.sendMsg, msg2))

nautilus_trader/adapters/interactive_brokers/client/market_data.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -72,7 +72,7 @@ async def set_market_data_type(self, market_data_type: MarketDataTypeEnum) -> No
7272
The market data type to be set
7373
7474
"""
75-
self._log.info(f"Setting Market DataType to {MarketDataTypeEnum.to_str(market_data_type)}")
75+
self._log.info(f"Setting Market DataType to {MarketDataTypeEnum.toStr(market_data_type)}")
7676
self._eclient.reqMarketDataType(market_data_type)
7777

7878
async def _subscribe(
@@ -715,9 +715,9 @@ async def process_market_data_type(self, *, req_id: int, market_data_type: int)
715715
to frozen and back and from delayed to delayed-frozen and back.
716716
"""
717717
if market_data_type == MarketDataTypeEnum.REALTIME:
718-
self._log.debug(f"Market DataType is {MarketDataTypeEnum.to_str(market_data_type)}")
718+
self._log.debug(f"Market DataType is {MarketDataTypeEnum.toStr(market_data_type)}")
719719
else:
720-
self._log.warning(f"Market DataType is {MarketDataTypeEnum.to_str(market_data_type)}")
720+
self._log.warning(f"Market DataType is {MarketDataTypeEnum.toStr(market_data_type)}")
721721

722722
async def process_tick_by_tick_bid_ask(
723723
self,

nautilus_trader/adapters/interactive_brokers/client/wrapper.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -570,7 +570,6 @@ def receiveFA(self, faData: FaDataType, cxml: str) -> None:
570570
One of the following:
571571
- Groups: Offer traders a way to create a group of accounts and apply a single allocation method
572572
to all accounts in the group.
573-
- Profiles: Let you allocate shares on an account-by-account basis using a predefined calculation value.
574573
- Account Aliases: Let you easily identify the accounts by meaningful names rather than account numbers.
575574
cxml : str
576575
The XML-formatted configuration.

nautilus_trader/adapters/interactive_brokers/common.py

Lines changed: 28 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,9 @@
1616
from decimal import Decimal
1717
from typing import Final, Literal
1818

19-
from ibapi.common import UNSET_DECIMAL
19+
from ibapi.const import UNSET_DECIMAL
20+
from ibapi.contract import FundAssetType
21+
from ibapi.contract import FundDistributionPolicyIndicator
2022
from ibapi.tag_value import TagValue
2123

2224
from nautilus_trader.config import NautilusConfig
@@ -101,6 +103,8 @@ class IBContract(NautilusConfig, frozen=True, repr_omit_defaults=True):
101103
Filters the options_chain and futures_chain which are expiring before number of days specified.
102104
lastTradeDateOrContractMonth: str (%Y%m%d or %Y%m) (default: '')
103105
Filters the options_chain and futures_chain specific for this expiry date
106+
lastTradeDate: str (default: '')
107+
The contract last trading day.
104108
105109
"""
106110

@@ -127,6 +131,7 @@ class IBContract(NautilusConfig, frozen=True, repr_omit_defaults=True):
127131

128132
# options and futures
129133
lastTradeDateOrContractMonth: str = ""
134+
lastTradeDate: str = ""
130135
multiplier: str = ""
131136

132137
# options
@@ -240,3 +245,25 @@ class IBContractDetails(NautilusConfig, frozen=True, repr_omit_defaults=True):
240245
nextOptionType: str = ""
241246
nextOptionPartial: bool = False
242247
notes: str = ""
248+
249+
# FUND values
250+
fundName: str = ""
251+
fundFamily: str = ""
252+
fundType: str = ""
253+
fundFrontLoad: str = ""
254+
fundBackLoad: str = ""
255+
fundBackLoadTimeInterval: str = ""
256+
fundManagementFee: str = ""
257+
fundClosed: bool = False
258+
fundClosedForNewInvestors: bool = False
259+
fundClosedForNewMoney: bool = False
260+
fundNotifyAmount: str = ""
261+
fundMinimumInitialPurchase: str = ""
262+
fundSubsequentMinimumPurchase: str = ""
263+
fundBlueSkyStates: str = ""
264+
fundBlueSkyTerritories: str = ""
265+
fundDistributionPolicyIndicator: FundDistributionPolicyIndicator = (
266+
FundDistributionPolicyIndicator.NoneItem
267+
)
268+
fundAssetType: FundAssetType = FundAssetType.NoneItem
269+
ineligibilityReasonList: list = None

nautilus_trader/adapters/interactive_brokers/execution.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,8 +19,8 @@
1919
from typing import Any
2020

2121
from ibapi.commission_report import CommissionReport
22-
from ibapi.common import UNSET_DECIMAL
23-
from ibapi.common import UNSET_DOUBLE
22+
from ibapi.const import UNSET_DECIMAL
23+
from ibapi.const import UNSET_DOUBLE
2424
from ibapi.execution import Execution
2525
from ibapi.order import Order as IBOrder
2626
from ibapi.order_state import OrderState as IBOrderState

pyproject.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -73,7 +73,7 @@ betfair = [
7373
]
7474
ib = [
7575
"defusedxml>=0.7.1,<1.0.0",
76-
"nautilus-ibapi==10.19.4",
76+
"nautilus-ibapi==10.30.1",
7777
]
7878
docker = [
7979
"docker>=7.1.0,<8.0.0",

tests/integration_tests/adapters/interactive_brokers/client/test_client_connection.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
from unittest.mock import MagicMock
44

55
import pytest
6-
from ibapi.common import NO_VALID_ID
6+
from ibapi.const import NO_VALID_ID
77
from ibapi.errors import CONNECT_FAIL
88

99

uv.lock

Lines changed: 4 additions & 4 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)