From 3348b5600f42ee2547982b4daefbb009b39e7a6e Mon Sep 17 00:00:00 2001 From: Chris Sellers Date: Wed, 10 Apr 2024 18:54:50 +1000 Subject: [PATCH] Rename CommissionModel to FeeModel --- nautilus_trader/adapters/sandbox/execution.py | 4 ++-- nautilus_trader/backtest/engine.pyx | 17 ++++++++++------- nautilus_trader/backtest/exchange.pxd | 6 +++--- nautilus_trader/backtest/exchange.pyx | 13 +++++++------ nautilus_trader/backtest/matching_engine.pxd | 4 ++-- nautilus_trader/backtest/matching_engine.pyx | 13 ++++++------- nautilus_trader/backtest/models.pxd | 15 +++++---------- nautilus_trader/backtest/models.pyx | 19 +++++++++++-------- .../backtest/test_commission_model.py | 14 +++++++------- .../backtest/test_exchange_bitmex.py | 4 ++-- ...est_exchange_bracket_if_touched_entries.py | 4 ++-- .../unit_tests/backtest/test_exchange_cash.py | 4 ++-- .../backtest/test_exchange_contingencies.py | 4 ++-- .../backtest/test_exchange_l2_mbp.py | 4 ++-- .../backtest/test_exchange_margin.py | 8 ++++---- .../backtest/test_exchange_stop_limits.py | 4 ++-- .../backtest/test_exchange_trailing_stops.py | 4 ++-- .../backtest/test_matching_engine.py | 4 ++-- tests/unit_tests/execution/test_algorithm.py | 4 ++-- .../execution/test_emulator_list.py | 4 ++-- tests/unit_tests/trading/test_strategy.py | 4 ++-- tests/unit_tests/trading/test_trader.py | 4 ++-- 22 files changed, 81 insertions(+), 80 deletions(-) diff --git a/nautilus_trader/adapters/sandbox/execution.py b/nautilus_trader/adapters/sandbox/execution.py index 1440a5d24bcc..c145d08eacb5 100644 --- a/nautilus_trader/adapters/sandbox/execution.py +++ b/nautilus_trader/adapters/sandbox/execution.py @@ -22,8 +22,8 @@ from nautilus_trader.backtest.exchange import SimulatedExchange from nautilus_trader.backtest.execution_client import BacktestExecClient from nautilus_trader.backtest.models import FillModel -from nautilus_trader.backtest.models import InstrumentSpecificPercentCommissionModel from nautilus_trader.backtest.models import LatencyModel +from nautilus_trader.backtest.models import MakerTakerFeeModel from nautilus_trader.cache.cache import Cache from nautilus_trader.common.component import LiveClock from nautilus_trader.common.component import MessageBus @@ -120,7 +120,7 @@ def __init__( msgbus=self._msgbus, cache=cache, fill_model=FillModel(), - commission_model=InstrumentSpecificPercentCommissionModel(), + fee_model=MakerTakerFeeModel(), latency_model=LatencyModel(0), clock=self.test_clock, frozen_account=True, # <-- Freezing account diff --git a/nautilus_trader/backtest/engine.pyx b/nautilus_trader/backtest/engine.pyx index 6d99e38061ba..e8ab3bd31e2a 100644 --- a/nautilus_trader/backtest/engine.pyx +++ b/nautilus_trader/backtest/engine.pyx @@ -41,10 +41,10 @@ from nautilus_trader.backtest.data_client cimport BacktestDataClient from nautilus_trader.backtest.data_client cimport BacktestMarketDataClient from nautilus_trader.backtest.exchange cimport SimulatedExchange from nautilus_trader.backtest.execution_client cimport BacktestExecClient -from nautilus_trader.backtest.models cimport CommissionModel +from nautilus_trader.backtest.models cimport FeeModel from nautilus_trader.backtest.models cimport FillModel -from nautilus_trader.backtest.models cimport InstrumentSpecificPercentCommissionModel from nautilus_trader.backtest.models cimport LatencyModel +from nautilus_trader.backtest.models cimport MakerTakerFeeModel from nautilus_trader.backtest.modules cimport SimulationModule from nautilus_trader.cache.base cimport CacheFacade from nautilus_trader.common.actor cimport Actor @@ -368,7 +368,7 @@ cdef class BacktestEngine: leverages: dict[InstrumentId, Decimal] | None = None, modules: list[SimulationModule] | None = None, fill_model: FillModel | None = None, - commission_model: CommissionModel = InstrumentSpecificPercentCommissionModel(), + fee_model: FeeModel | None = None, latency_model: LatencyModel | None = None, book_type: BookType = BookType.L1_MBP, routing: bool = False, @@ -405,8 +405,8 @@ cdef class BacktestEngine: The simulation modules to load into the exchange. fill_model : FillModel, optional The fill model for the exchange. - commission_model : CommissionModel, optional - The commission model for the exchange. + fee_model : FeeModel, optional + The fee model for the venue. latency_model : LatencyModel, optional The latency model for the exchange. book_type : BookType, default ``BookType.L1_MBP`` @@ -441,11 +441,14 @@ cdef class BacktestEngine: modules = [] if fill_model is None: fill_model = FillModel() + if fee_model is None: + fee_model = MakerTakerFeeModel() Condition.not_none(venue, "venue") Condition.not_in(venue, self._venues, "venue", "_venues") Condition.not_empty(starting_balances, "starting_balances") Condition.list_type(modules, SimulationModule, "modules") - Condition.type_or_none(fill_model, FillModel, "fill_model") + Condition.type(fill_model, FillModel, "fill_model") + Condition.type(fee_model, FeeModel, "fee_model") if default_leverage is None: if account_type == AccountType.MARGIN: @@ -468,7 +471,7 @@ cdef class BacktestEngine: msgbus=self.kernel.msgbus, cache=self.kernel.cache, fill_model=fill_model, - commission_model=commission_model, + fee_model=fee_model, latency_model=latency_model, book_type=book_type, clock=self.kernel.clock, diff --git a/nautilus_trader/backtest/exchange.pxd b/nautilus_trader/backtest/exchange.pxd index cee06a09514a..e9049dc3c0cb 100644 --- a/nautilus_trader/backtest/exchange.pxd +++ b/nautilus_trader/backtest/exchange.pxd @@ -18,7 +18,7 @@ from libc.stdint cimport uint64_t from nautilus_trader.accounting.accounts.base cimport Account from nautilus_trader.backtest.execution_client cimport BacktestExecClient from nautilus_trader.backtest.matching_engine cimport OrderMatchingEngine -from nautilus_trader.backtest.models cimport CommissionModel +from nautilus_trader.backtest.models cimport FeeModel from nautilus_trader.backtest.models cimport FillModel from nautilus_trader.backtest.models cimport LatencyModel from nautilus_trader.cache.cache cimport Cache @@ -79,8 +79,8 @@ cdef class SimulatedExchange: """The latency model for the exchange.\n\n:returns: `LatencyModel`""" cdef readonly FillModel fill_model """The fill model for the exchange.\n\n:returns: `FillModel`""" - cdef readonly CommissionModel commission_model - """The commission model for the exchange.\n\n:returns: `CommissionModel`""" + cdef readonly FeeModel fee_model + """The fee model for the exchange.\n\n:returns: `FeeModel`""" cdef readonly bint bar_execution """If bars should be processed by the matching engine(s) (and move the market).\n\n:returns: `bool`""" cdef readonly bint reject_stop_orders diff --git a/nautilus_trader/backtest/exchange.pyx b/nautilus_trader/backtest/exchange.pyx index 525d7f5aae21..9d9c4dfbec92 100644 --- a/nautilus_trader/backtest/exchange.pyx +++ b/nautilus_trader/backtest/exchange.pyx @@ -24,9 +24,10 @@ from libc.stdint cimport uint64_t from nautilus_trader.accounting.accounts.base cimport Account from nautilus_trader.backtest.execution_client cimport BacktestExecClient from nautilus_trader.backtest.matching_engine cimport OrderMatchingEngine -from nautilus_trader.backtest.models cimport CommissionModel +from nautilus_trader.backtest.models cimport FeeModel from nautilus_trader.backtest.models cimport FillModel from nautilus_trader.backtest.models cimport LatencyModel +from nautilus_trader.backtest.models cimport MakerTakerFeeModel from nautilus_trader.backtest.modules cimport SimulationModule from nautilus_trader.cache.base cimport CacheFacade from nautilus_trader.common.component cimport Logger @@ -89,8 +90,8 @@ cdef class SimulatedExchange: The read-only cache for the exchange. fill_model : FillModel The fill model for the exchange. - commission_model : CommissionModel - The commission model for the matching engine. + fee_model : FeeModel + The fee model for the exchange. latency_model : LatencyModel, optional The latency model for the exchange. clock : TestClock @@ -147,7 +148,7 @@ cdef class SimulatedExchange: CacheFacade cache not None, TestClock clock not None, FillModel fill_model not None, - CommissionModel commission_model not None, + FeeModel fee_model not None, LatencyModel latency_model = None, BookType book_type = BookType.L1_MBP, bint frozen_account = False, @@ -197,7 +198,7 @@ cdef class SimulatedExchange: self.use_random_ids = use_random_ids self.use_reduce_only = use_reduce_only self.fill_model = fill_model - self.commission_model = commission_model + self.fee_model = fee_model self.latency_model = latency_model # Load modules @@ -333,7 +334,7 @@ cdef class SimulatedExchange: instrument=instrument, raw_id=len(self.instruments), fill_model=self.fill_model, - commission_model=self.commission_model, + fee_model=self.fee_model, book_type=self.book_type, oms_type=self.oms_type, account_type=self.account_type, diff --git a/nautilus_trader/backtest/matching_engine.pxd b/nautilus_trader/backtest/matching_engine.pxd index 470e77bb85cd..ba279db45133 100644 --- a/nautilus_trader/backtest/matching_engine.pxd +++ b/nautilus_trader/backtest/matching_engine.pxd @@ -17,7 +17,7 @@ from libc.stdint cimport int64_t from libc.stdint cimport uint32_t from libc.stdint cimport uint64_t -from nautilus_trader.backtest.models cimport CommissionModel +from nautilus_trader.backtest.models cimport FeeModel from nautilus_trader.backtest.models cimport FillModel from nautilus_trader.cache.base cimport CacheFacade from nautilus_trader.common.component cimport Clock @@ -77,7 +77,7 @@ cdef class OrderMatchingEngine: cdef OrderBook _opening_auction_book cdef OrderBook _closing_auction_book cdef FillModel _fill_model - cdef CommissionModel _commission_model + cdef FeeModel _fee_model # cdef object _auction_match_algo cdef bint _bar_execution cdef bint _reject_stop_orders diff --git a/nautilus_trader/backtest/matching_engine.pyx b/nautilus_trader/backtest/matching_engine.pyx index 3fff47bb3900..10a95fa66371 100644 --- a/nautilus_trader/backtest/matching_engine.pyx +++ b/nautilus_trader/backtest/matching_engine.pyx @@ -21,7 +21,7 @@ import uuid from cpython.datetime cimport timedelta from libc.stdint cimport uint64_t -from nautilus_trader.backtest.models cimport CommissionModel +from nautilus_trader.backtest.models cimport FeeModel from nautilus_trader.backtest.models cimport FillModel from nautilus_trader.cache.base cimport CacheFacade from nautilus_trader.common.component cimport LogColor @@ -111,8 +111,8 @@ cdef class OrderMatchingEngine: The raw integer ID for the instrument. fill_model : FillModel The fill model for the matching engine. - commission_model : CommissionModel - The commission model for the matching engine. + fee_model : FeeModel + The fee model for the matching engine. book_type : BookType The order book type for the engine. oms_type : OmsType @@ -153,7 +153,7 @@ cdef class OrderMatchingEngine: Instrument instrument not None, uint32_t raw_id, FillModel fill_model not None, - CommissionModel commission_model not None, + FeeModel fee_model not None, BookType book_type, OmsType oms_type, AccountType account_type, @@ -191,7 +191,7 @@ cdef class OrderMatchingEngine: self._use_reduce_only = use_reduce_only # self._auction_match_algo = auction_match_algo self._fill_model = fill_model - self._commission_model = commission_model + self._fee_model = fee_model self._book = OrderBook( instrument_id=instrument.id, book_type=book_type, @@ -1770,8 +1770,7 @@ cdef class OrderMatchingEngine: order.liquidity_side = liquidity_side # Calculate commission - cdef Money commission - commission = self._commission_model.get_commission( + cdef Money commission = self._fee_model.get_commission( order=order, fill_qty=last_qty, fill_px=last_px, diff --git a/nautilus_trader/backtest/models.pxd b/nautilus_trader/backtest/models.pxd index 931c03122c37..bba724164ce3 100644 --- a/nautilus_trader/backtest/models.pxd +++ b/nautilus_trader/backtest/models.pxd @@ -48,17 +48,12 @@ cdef class LatencyModel: """The latency (nanoseconds) for order cancel messages to reach the exchange.\n\n:returns: `int`""" -cdef class CommissionModel: +cdef class FeeModel: cpdef Money get_commission(self, Order order, Quantity fill_qty, Price fill_px, Instrument instrument) -cdef class InstrumentSpecificPercentCommissionModel(CommissionModel): - """ - Provide a commission model for trades based on a percentage of the notional value - of the trade. +cdef class MakerTakerFeeModel(FeeModel): + pass - """ - -cdef class FixedCommissionModel(CommissionModel): - cdef Money commission - """The constant commission.""" +cdef class FixedCommissionModel(FeeModel): + cdef Money _commission diff --git a/nautilus_trader/backtest/models.pyx b/nautilus_trader/backtest/models.pyx index d81bb0ed1cf3..5f90398a1bd9 100644 --- a/nautilus_trader/backtest/models.pyx +++ b/nautilus_trader/backtest/models.pyx @@ -163,10 +163,11 @@ cdef class LatencyModel: self.cancel_latency_nanos = base_latency_nanos + cancel_latency_nanos -cdef class CommissionModel: +cdef class FeeModel: """ - Provide an abstract commission model for trades. + Provides an abstract fee model for trades. """ + cpdef Money get_commission( self, Order order, @@ -196,10 +197,10 @@ cdef class CommissionModel: raise NotImplementedError("Method 'get_commission' must be implemented in a subclass.") -cdef class InstrumentSpecificPercentCommissionModel(CommissionModel): +cdef class MakerTakerFeeModel(FeeModel): """ - Provide a commission model for trades based on a percentage of the notional value - of the trade. + Provide a fee model for trades based on a maker/taker fee schedule + and notional value of the trade. """ @@ -235,7 +236,7 @@ cdef class InstrumentSpecificPercentCommissionModel(CommissionModel): return commission -cdef class FixedCommissionModel(CommissionModel): +cdef class FixedCommissionModel(FeeModel): """ Provides a fixed commission model for trades. @@ -253,7 +254,9 @@ cdef class FixedCommissionModel(CommissionModel): def __init__(self, Money commission): Condition.type(commission, Money, "commission") - self.commission = commission + Condition.positive(commission, "commission") + + self._commission = commission cpdef Money get_commission( self, @@ -262,4 +265,4 @@ cdef class FixedCommissionModel(CommissionModel): Price fill_px, Instrument instrument, ): - return self.commission + return self._commission diff --git a/tests/unit_tests/backtest/test_commission_model.py b/tests/unit_tests/backtest/test_commission_model.py index d55c99a71a0f..ea84c6d86b14 100644 --- a/tests/unit_tests/backtest/test_commission_model.py +++ b/tests/unit_tests/backtest/test_commission_model.py @@ -17,7 +17,7 @@ # fmt: off from nautilus_trader.backtest.models import FixedCommissionModel -from nautilus_trader.backtest.models import InstrumentSpecificPercentCommissionModel +from nautilus_trader.backtest.models import MakerTakerFeeModel from nautilus_trader.model.currencies import USD from nautilus_trader.model.enums import OrderSide from nautilus_trader.model.instruments.base import Instrument @@ -55,10 +55,10 @@ def sell_order(instrument: Instrument) -> Order: def test_fixed_commission(buy_order, instrument): # Arrange expected = Money(1, USD) - commission_model = FixedCommissionModel(expected) + fee_model = FixedCommissionModel(expected) # Act - commission = commission_model.get_commission( + commission = fee_model.get_commission( buy_order, buy_order.quantity, Price.from_str("1.1234"), @@ -71,11 +71,11 @@ def test_fixed_commission(buy_order, instrument): def test_instrument_percent_commission_maker(instrument, buy_order): # Arrange - commission_model = InstrumentSpecificPercentCommissionModel() + fee_model = MakerTakerFeeModel() expected = buy_order.quantity * buy_order.price * instrument.maker_fee # Act - commission = commission_model.get_commission( + commission = fee_model.get_commission( buy_order, buy_order.quantity, buy_order.price, @@ -89,11 +89,11 @@ def test_instrument_percent_commission_maker(instrument, buy_order): def test_instrument_percent_commission_taker(instrument, sell_order): # Arrange - commission_model = InstrumentSpecificPercentCommissionModel() + fee_model = MakerTakerFeeModel() expected = sell_order.quantity * sell_order.price * instrument.taker_fee # Act - commission = commission_model.get_commission( + commission = fee_model.get_commission( sell_order, sell_order.quantity, sell_order.price, diff --git a/tests/unit_tests/backtest/test_exchange_bitmex.py b/tests/unit_tests/backtest/test_exchange_bitmex.py index 07422fdefbdf..71fc9f5ae9bc 100644 --- a/tests/unit_tests/backtest/test_exchange_bitmex.py +++ b/tests/unit_tests/backtest/test_exchange_bitmex.py @@ -18,8 +18,8 @@ from nautilus_trader.backtest.exchange import SimulatedExchange from nautilus_trader.backtest.execution_client import BacktestExecClient from nautilus_trader.backtest.models import FillModel -from nautilus_trader.backtest.models import InstrumentSpecificPercentCommissionModel from nautilus_trader.backtest.models import LatencyModel +from nautilus_trader.backtest.models import MakerTakerFeeModel from nautilus_trader.common.component import MessageBus from nautilus_trader.common.component import TestClock from nautilus_trader.data.engine import DataEngine @@ -104,7 +104,7 @@ def setup(self): instruments=[XBTUSD_BITMEX], modules=[], fill_model=FillModel(), - commission_model=InstrumentSpecificPercentCommissionModel(), + fee_model=MakerTakerFeeModel(), clock=self.clock, latency_model=LatencyModel(0), ) diff --git a/tests/unit_tests/backtest/test_exchange_bracket_if_touched_entries.py b/tests/unit_tests/backtest/test_exchange_bracket_if_touched_entries.py index 00393ddee621..d138e74983af 100644 --- a/tests/unit_tests/backtest/test_exchange_bracket_if_touched_entries.py +++ b/tests/unit_tests/backtest/test_exchange_bracket_if_touched_entries.py @@ -20,8 +20,8 @@ from nautilus_trader.backtest.exchange import SimulatedExchange from nautilus_trader.backtest.execution_client import BacktestExecClient from nautilus_trader.backtest.models import FillModel -from nautilus_trader.backtest.models import InstrumentSpecificPercentCommissionModel from nautilus_trader.backtest.models import LatencyModel +from nautilus_trader.backtest.models import MakerTakerFeeModel from nautilus_trader.common.component import MessageBus from nautilus_trader.common.component import TestClock from nautilus_trader.data.engine import DataEngine @@ -108,7 +108,7 @@ def setup(self): instruments=[ETHUSDT_PERP_BINANCE], modules=[], fill_model=FillModel(), - commission_model=InstrumentSpecificPercentCommissionModel(), + fee_model=MakerTakerFeeModel(), portfolio=self.portfolio, msgbus=self.msgbus, cache=self.cache, diff --git a/tests/unit_tests/backtest/test_exchange_cash.py b/tests/unit_tests/backtest/test_exchange_cash.py index 9eafd90e4793..c1174f82d0fb 100644 --- a/tests/unit_tests/backtest/test_exchange_cash.py +++ b/tests/unit_tests/backtest/test_exchange_cash.py @@ -20,8 +20,8 @@ from nautilus_trader.backtest.exchange import SimulatedExchange from nautilus_trader.backtest.execution_client import BacktestExecClient from nautilus_trader.backtest.models import FillModel -from nautilus_trader.backtest.models import InstrumentSpecificPercentCommissionModel from nautilus_trader.backtest.models import LatencyModel +from nautilus_trader.backtest.models import MakerTakerFeeModel from nautilus_trader.common.component import MessageBus from nautilus_trader.common.component import TestClock from nautilus_trader.config import ExecEngineConfig @@ -100,7 +100,7 @@ def setup(self) -> None: instruments=[_AAPL_XNAS], modules=[], fill_model=FillModel(), - commission_model=InstrumentSpecificPercentCommissionModel(), + fee_model=MakerTakerFeeModel(), portfolio=self.portfolio, msgbus=self.msgbus, cache=self.cache, diff --git a/tests/unit_tests/backtest/test_exchange_contingencies.py b/tests/unit_tests/backtest/test_exchange_contingencies.py index 7dfc3f8e23e4..de2ecb3ff483 100644 --- a/tests/unit_tests/backtest/test_exchange_contingencies.py +++ b/tests/unit_tests/backtest/test_exchange_contingencies.py @@ -18,8 +18,8 @@ from nautilus_trader.backtest.exchange import SimulatedExchange from nautilus_trader.backtest.execution_client import BacktestExecClient from nautilus_trader.backtest.models import FillModel -from nautilus_trader.backtest.models import InstrumentSpecificPercentCommissionModel from nautilus_trader.backtest.models import LatencyModel +from nautilus_trader.backtest.models import MakerTakerFeeModel from nautilus_trader.common.component import MessageBus from nautilus_trader.common.component import TestClock from nautilus_trader.data.engine import DataEngine @@ -97,7 +97,7 @@ def setup(self): instruments=[ETHUSDT_PERP_BINANCE], modules=[], fill_model=FillModel(), - commission_model=InstrumentSpecificPercentCommissionModel(), + fee_model=MakerTakerFeeModel(), portfolio=self.portfolio, msgbus=self.msgbus, cache=self.cache, diff --git a/tests/unit_tests/backtest/test_exchange_l2_mbp.py b/tests/unit_tests/backtest/test_exchange_l2_mbp.py index f85b90a359b9..cc663db39c36 100644 --- a/tests/unit_tests/backtest/test_exchange_l2_mbp.py +++ b/tests/unit_tests/backtest/test_exchange_l2_mbp.py @@ -20,8 +20,8 @@ from nautilus_trader.backtest.exchange import SimulatedExchange from nautilus_trader.backtest.execution_client import BacktestExecClient from nautilus_trader.backtest.models import FillModel -from nautilus_trader.backtest.models import InstrumentSpecificPercentCommissionModel from nautilus_trader.backtest.models import LatencyModel +from nautilus_trader.backtest.models import MakerTakerFeeModel from nautilus_trader.common.component import MessageBus from nautilus_trader.common.component import TestClock from nautilus_trader.data.engine import DataEngine @@ -103,7 +103,7 @@ def setup(self): instruments=[_USDJPY_SIM], modules=[], fill_model=FillModel(), - commission_model=InstrumentSpecificPercentCommissionModel(), + fee_model=MakerTakerFeeModel(), portfolio=self.portfolio, msgbus=self.msgbus, cache=self.cache, diff --git a/tests/unit_tests/backtest/test_exchange_margin.py b/tests/unit_tests/backtest/test_exchange_margin.py index 4fc8e5c07b26..304753e8adcc 100644 --- a/tests/unit_tests/backtest/test_exchange_margin.py +++ b/tests/unit_tests/backtest/test_exchange_margin.py @@ -21,8 +21,8 @@ from nautilus_trader.backtest.exchange import SimulatedExchange from nautilus_trader.backtest.execution_client import BacktestExecClient from nautilus_trader.backtest.models import FillModel -from nautilus_trader.backtest.models import InstrumentSpecificPercentCommissionModel from nautilus_trader.backtest.models import LatencyModel +from nautilus_trader.backtest.models import MakerTakerFeeModel from nautilus_trader.backtest.modules import SimulationModule from nautilus_trader.common.component import MessageBus from nautilus_trader.common.component import TestClock @@ -129,7 +129,7 @@ def setup(self) -> None: instruments=[_USDJPY_SIM], modules=[], fill_model=FillModel(), - commission_model=InstrumentSpecificPercentCommissionModel(), + fee_model=MakerTakerFeeModel(), portfolio=self.portfolio, msgbus=self.msgbus, cache=self.cache, @@ -2731,7 +2731,7 @@ def test_adjust_account_when_account_frozen_does_not_change_balance(self) -> Non instruments=[_USDJPY_SIM], modules=[], fill_model=FillModel(), - commission_model=InstrumentSpecificPercentCommissionModel(), + fee_model=MakerTakerFeeModel(), portfolio=self.portfolio, msgbus=self.msgbus, cache=self.cache, @@ -3030,7 +3030,7 @@ def reset(self): instruments=[_USDJPY_SIM], modules=[self.module], fill_model=FillModel(), - commission_model=InstrumentSpecificPercentCommissionModel(), + fee_model=MakerTakerFeeModel(), portfolio=self.portfolio, msgbus=self.msgbus, cache=self.cache, diff --git a/tests/unit_tests/backtest/test_exchange_stop_limits.py b/tests/unit_tests/backtest/test_exchange_stop_limits.py index ca1c1302be32..843b65ba6754 100644 --- a/tests/unit_tests/backtest/test_exchange_stop_limits.py +++ b/tests/unit_tests/backtest/test_exchange_stop_limits.py @@ -18,8 +18,8 @@ from nautilus_trader.backtest.exchange import SimulatedExchange from nautilus_trader.backtest.execution_client import BacktestExecClient from nautilus_trader.backtest.models import FillModel -from nautilus_trader.backtest.models import InstrumentSpecificPercentCommissionModel from nautilus_trader.backtest.models import LatencyModel +from nautilus_trader.backtest.models import MakerTakerFeeModel from nautilus_trader.common.component import MessageBus from nautilus_trader.common.component import TestClock from nautilus_trader.config import ExecEngineConfig @@ -101,7 +101,7 @@ def setup(self): instruments=[USDJPY_SIM], modules=[], fill_model=FillModel(), - commission_model=InstrumentSpecificPercentCommissionModel(), + fee_model=MakerTakerFeeModel(), portfolio=self.portfolio, msgbus=self.msgbus, cache=self.cache, diff --git a/tests/unit_tests/backtest/test_exchange_trailing_stops.py b/tests/unit_tests/backtest/test_exchange_trailing_stops.py index 999d6b823639..b3d4b904562a 100644 --- a/tests/unit_tests/backtest/test_exchange_trailing_stops.py +++ b/tests/unit_tests/backtest/test_exchange_trailing_stops.py @@ -20,8 +20,8 @@ from nautilus_trader.backtest.exchange import SimulatedExchange from nautilus_trader.backtest.execution_client import BacktestExecClient from nautilus_trader.backtest.models import FillModel -from nautilus_trader.backtest.models import InstrumentSpecificPercentCommissionModel from nautilus_trader.backtest.models import LatencyModel +from nautilus_trader.backtest.models import MakerTakerFeeModel from nautilus_trader.common.component import MessageBus from nautilus_trader.common.component import TestClock from nautilus_trader.config import ExecEngineConfig @@ -110,7 +110,7 @@ def setup(self) -> None: instruments=[USDJPY_SIM], modules=[], fill_model=FillModel(), - commission_model=InstrumentSpecificPercentCommissionModel(), + fee_model=MakerTakerFeeModel(), portfolio=self.portfolio, msgbus=self.msgbus, cache=self.cache, diff --git a/tests/unit_tests/backtest/test_matching_engine.py b/tests/unit_tests/backtest/test_matching_engine.py index 0d23be8694d5..bd849e0c9ba9 100644 --- a/tests/unit_tests/backtest/test_matching_engine.py +++ b/tests/unit_tests/backtest/test_matching_engine.py @@ -19,7 +19,7 @@ from nautilus_trader.backtest.matching_engine import OrderMatchingEngine from nautilus_trader.backtest.models import FillModel -from nautilus_trader.backtest.models import InstrumentSpecificPercentCommissionModel +from nautilus_trader.backtest.models import MakerTakerFeeModel from nautilus_trader.common.component import MessageBus from nautilus_trader.common.component import TestClock from nautilus_trader.model.enums import AccountType @@ -60,7 +60,7 @@ def setup(self): instrument=self.instrument, raw_id=0, fill_model=FillModel(), - commission_model=InstrumentSpecificPercentCommissionModel(), + fee_model=MakerTakerFeeModel(), book_type=BookType.L1_MBP, oms_type=OmsType.NETTING, account_type=AccountType.MARGIN, diff --git a/tests/unit_tests/execution/test_algorithm.py b/tests/unit_tests/execution/test_algorithm.py index 2676fa589a64..5f2468fe1a7c 100644 --- a/tests/unit_tests/execution/test_algorithm.py +++ b/tests/unit_tests/execution/test_algorithm.py @@ -21,7 +21,7 @@ from nautilus_trader.backtest.exchange import SimulatedExchange from nautilus_trader.backtest.execution_client import BacktestExecClient from nautilus_trader.backtest.models import FillModel -from nautilus_trader.backtest.models import InstrumentSpecificPercentCommissionModel +from nautilus_trader.backtest.models import MakerTakerFeeModel from nautilus_trader.cache.cache import Cache from nautilus_trader.common.component import MessageBus from nautilus_trader.common.component import TestClock @@ -133,7 +133,7 @@ def setup(self) -> None: instruments=[ETHUSDT_PERP_BINANCE], modules=[], fill_model=FillModel(), - commission_model=InstrumentSpecificPercentCommissionModel(), + fee_model=MakerTakerFeeModel(), portfolio=self.portfolio, msgbus=self.msgbus, cache=self.cache, diff --git a/tests/unit_tests/execution/test_emulator_list.py b/tests/unit_tests/execution/test_emulator_list.py index c6a006138af1..526263984716 100644 --- a/tests/unit_tests/execution/test_emulator_list.py +++ b/tests/unit_tests/execution/test_emulator_list.py @@ -21,7 +21,7 @@ from nautilus_trader.backtest.exchange import SimulatedExchange from nautilus_trader.backtest.execution_client import BacktestExecClient from nautilus_trader.backtest.models import FillModel -from nautilus_trader.backtest.models import InstrumentSpecificPercentCommissionModel +from nautilus_trader.backtest.models import MakerTakerFeeModel from nautilus_trader.cache.cache import Cache from nautilus_trader.common.component import MessageBus from nautilus_trader.common.component import TestClock @@ -131,7 +131,7 @@ def setup(self) -> None: instruments=[ETHUSDT_PERP_BINANCE], modules=[], fill_model=FillModel(), - commission_model=InstrumentSpecificPercentCommissionModel(), + fee_model=MakerTakerFeeModel(), portfolio=self.portfolio, msgbus=self.msgbus, cache=self.cache, diff --git a/tests/unit_tests/trading/test_strategy.py b/tests/unit_tests/trading/test_strategy.py index c705f8725712..252e7b7648ca 100644 --- a/tests/unit_tests/trading/test_strategy.py +++ b/tests/unit_tests/trading/test_strategy.py @@ -25,8 +25,8 @@ from nautilus_trader.backtest.exchange import SimulatedExchange from nautilus_trader.backtest.execution_client import BacktestExecClient from nautilus_trader.backtest.models import FillModel -from nautilus_trader.backtest.models import InstrumentSpecificPercentCommissionModel from nautilus_trader.backtest.models import LatencyModel +from nautilus_trader.backtest.models import MakerTakerFeeModel from nautilus_trader.common.component import MessageBus from nautilus_trader.common.component import TestClock from nautilus_trader.common.enums import ComponentState @@ -126,7 +126,7 @@ def setup(self) -> None: instruments=[_USDJPY_SIM], modules=[], fill_model=FillModel(), - commission_model=InstrumentSpecificPercentCommissionModel(), + fee_model=MakerTakerFeeModel(), clock=self.clock, latency_model=LatencyModel(0), support_contingent_orders=False, diff --git a/tests/unit_tests/trading/test_trader.py b/tests/unit_tests/trading/test_trader.py index 9be506e9de88..919a1948d4ee 100644 --- a/tests/unit_tests/trading/test_trader.py +++ b/tests/unit_tests/trading/test_trader.py @@ -22,7 +22,7 @@ from nautilus_trader.backtest.exchange import SimulatedExchange from nautilus_trader.backtest.execution_client import BacktestExecClient from nautilus_trader.backtest.models import FillModel -from nautilus_trader.backtest.models import InstrumentSpecificPercentCommissionModel +from nautilus_trader.backtest.models import MakerTakerFeeModel from nautilus_trader.common.actor import Actor from nautilus_trader.common.component import MessageBus from nautilus_trader.common.component import TestClock @@ -104,7 +104,7 @@ def setup(self) -> None: instruments=[USDJPY_SIM], modules=[], fill_model=FillModel(), - commission_model=InstrumentSpecificPercentCommissionModel(), + fee_model=MakerTakerFeeModel(), clock=self.clock, )