diff --git a/nautilus_trader/adapters/sandbox/execution.py b/nautilus_trader/adapters/sandbox/execution.py index c145d08eacb5..18d112a52329 100644 --- a/nautilus_trader/adapters/sandbox/execution.py +++ b/nautilus_trader/adapters/sandbox/execution.py @@ -86,6 +86,7 @@ def __init__( balance: int, oms_type: OmsType = OmsType.NETTING, account_type: AccountType = AccountType.MARGIN, + default_leverage: Decimal = Decimal(10), ) -> None: self._currency = Currency.from_str(currency) money = Money(value=balance, currency=self._currency) @@ -112,7 +113,7 @@ def __init__( account_type=self._account_type, base_currency=self._currency, starting_balances=[self.balance.free], - default_leverage=Decimal(10), + default_leverage=default_leverage, leverages={}, instruments=self.INSTRUMENTS, modules=[], @@ -132,6 +133,7 @@ def __init__( clock=self.test_clock, ) self.exchange.register_client(self._client) + self.exchange.initialize_account() def connect(self) -> None: """ diff --git a/tests/integration_tests/adapters/sandbox/conftest.py b/tests/integration_tests/adapters/sandbox/conftest.py index b171d2958438..7eacad869e03 100644 --- a/tests/integration_tests/adapters/sandbox/conftest.py +++ b/tests/integration_tests/adapters/sandbox/conftest.py @@ -13,9 +13,12 @@ # limitations under the License. # ------------------------------------------------------------------------------------------------- +from decimal import Decimal + import pytest from nautilus_trader.adapters.sandbox.execution import SandboxExecutionClient +from nautilus_trader.model.enums import AccountType from nautilus_trader.model.events import AccountState from nautilus_trader.model.identifiers import AccountId from nautilus_trader.model.identifiers import Venue @@ -48,6 +51,8 @@ def exec_client( venue=venue.value, currency="USD", balance=100_000, + account_type=AccountType.CASH, + default_leverage=Decimal(1), )