Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix sandbox account initialization #1613

Merged
merged 3 commits into from
Apr 27, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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