Skip to content

Commit

Permalink
Fix sandbox account initialization (#1613)
Browse files Browse the repository at this point in the history
  • Loading branch information
davidsblom authored Apr 27, 2024
1 parent 6fe3ae3 commit 2e23d21
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 1 deletion.
4 changes: 3 additions & 1 deletion nautilus_trader/adapters/sandbox/execution.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand All @@ -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=[],
Expand All @@ -132,6 +133,7 @@ def __init__(
clock=self.test_clock,
)
self.exchange.register_client(self._client)
self.exchange.initialize_account()

def connect(self) -> None:
"""
Expand Down
5 changes: 5 additions & 0 deletions tests/integration_tests/adapters/sandbox/conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -48,6 +51,8 @@ def exec_client(
venue=venue.value,
currency="USD",
balance=100_000,
account_type=AccountType.CASH,
default_leverage=Decimal(1),
)


Expand Down

0 comments on commit 2e23d21

Please sign in to comment.