Skip to content

Commit

Permalink
Add CFD and Commodity support for Interactive Brokers
Browse files Browse the repository at this point in the history
Signed-off-by: DracheShiki <[email protected]>
  • Loading branch information
D authored and DracheShiki committed Apr 23, 2024
1 parent a128ba4 commit 536f839
Show file tree
Hide file tree
Showing 4 changed files with 16 additions and 10 deletions.
11 changes: 10 additions & 1 deletion nautilus_trader/adapters/interactive_brokers/common.py
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,16 @@ class IBContract(NautilusConfig, frozen=True, repr_omit_defaults=True):
"""

secType: Literal[
"CASH", "STK", "OPT", "FUT", "FOP", "CONTFUT", "CRYPTO", "CFD", "CMDTY", ""
"CASH",
"STK",
"OPT",
"FUT",
"FOP",
"CONTFUT",
"CRYPTO",
"CFD",
"CMDTY",
"",
] = ""
conId: int = 0
exchange: str = ""
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -78,9 +78,6 @@
]
VENUES_CFD = [
"IBCFD", # self named, in fact mapping to "SMART" when parsing
"IBUSCFD", # US
"IBCFD", # EU
"IBAPCFD", # Asia-Pacific
]
VENUES_CMDTY = ["IBCMDTY"] # self named, in fact mapping to "SMART" when parsing

Expand Down
8 changes: 4 additions & 4 deletions nautilus_trader/model/instruments/cfd.pyx
Original file line number Diff line number Diff line change
Expand Up @@ -19,10 +19,10 @@ from libc.stdint cimport uint64_t

from nautilus_trader.core.correctness cimport Condition
from nautilus_trader.core.rust.model cimport AssetClass
from nautilus_trader.model.functions cimport asset_class_from_str
from nautilus_trader.model.functions cimport asset_class_to_str
from nautilus_trader.core.rust.model cimport CurrencyType
from nautilus_trader.core.rust.model cimport InstrumentClass
from nautilus_trader.model.functions cimport asset_class_from_str
from nautilus_trader.model.functions cimport asset_class_to_str
from nautilus_trader.model.identifiers cimport InstrumentId
from nautilus_trader.model.identifiers cimport Symbol
from nautilus_trader.model.instruments.base cimport Instrument
Expand Down Expand Up @@ -148,7 +148,7 @@ cdef class Cfd(Instrument):
str tick_scheme_name = None,
dict info = None,
):

super().__init__(
instrument_id=instrument_id,
raw_symbol=raw_symbol,
Expand Down Expand Up @@ -198,7 +198,7 @@ cdef class Cfd(Instrument):
size_precision=values["size_precision"],
price_increment=Price.from_str_c(values["price_increment"]),
size_increment=Quantity.from_str_c(values["size_increment"]),
base_currency=Currency.from_str_c(values["base_currency"]) if base_c is not None else None,
base_currency=Currency.from_str_c(values["base_currency"]) if base_c is not None else None,
lot_size=Quantity.from_str_c(lot_s) if lot_s is not None else None,
max_quantity=Quantity.from_str_c(max_q) if max_q is not None else None,
min_quantity=Quantity.from_str_c(min_q) if min_q is not None else None,
Expand Down
4 changes: 2 additions & 2 deletions nautilus_trader/model/instruments/commodity.pyx
Original file line number Diff line number Diff line change
Expand Up @@ -19,10 +19,10 @@ from libc.stdint cimport uint64_t

from nautilus_trader.core.correctness cimport Condition
from nautilus_trader.core.rust.model cimport AssetClass
from nautilus_trader.model.functions cimport asset_class_from_str
from nautilus_trader.model.functions cimport asset_class_to_str
from nautilus_trader.core.rust.model cimport CurrencyType
from nautilus_trader.core.rust.model cimport InstrumentClass
from nautilus_trader.model.functions cimport asset_class_from_str
from nautilus_trader.model.functions cimport asset_class_to_str
from nautilus_trader.model.identifiers cimport InstrumentId
from nautilus_trader.model.identifiers cimport Symbol
from nautilus_trader.model.instruments.base cimport Instrument
Expand Down

0 comments on commit 536f839

Please sign in to comment.