Skip to content

Commit

Permalink
Consistently use TraderId
Browse files Browse the repository at this point in the history
  • Loading branch information
cjdsellers committed Jan 24, 2024
1 parent bc34886 commit f0b8ad9
Show file tree
Hide file tree
Showing 15 changed files with 30 additions and 15 deletions.
3 changes: 2 additions & 1 deletion docs/tutorials/backtest_low_level.md
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ from nautilus_trader.model.currencies import ETH
from nautilus_trader.model.currencies import USDT
from nautilus_trader.model.enums import AccountType
from nautilus_trader.model.enums import OmsType
from nautilus_trader.model.identifiers import TraderId
from nautilus_trader.model.identifiers import Venue
from nautilus_trader.model.objects import Money
from nautilus_trader.persistence.wranglers import TradeTickDataWrangler
Expand Down Expand Up @@ -72,7 +73,7 @@ to show the general configuration pattern:

```python
# Configure backtest engine
config = BacktestEngineConfig(trader_id="BACKTESTER-001")
config = BacktestEngineConfig(trader_id=TraderId("BACKTESTER-001"))

# Build the backtest engine
engine = BacktestEngine(config=config)
Expand Down
3 changes: 2 additions & 1 deletion examples/backtest/betfair_backtest_orderbook_imbalance.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,14 +30,15 @@
from nautilus_trader.model.enums import BookType
from nautilus_trader.model.enums import OmsType
from nautilus_trader.model.identifiers import ClientId
from nautilus_trader.model.identifiers import TraderId
from nautilus_trader.model.objects import Money
from tests.integration_tests.adapters.betfair.test_kit import BetfairDataProvider
from tests.integration_tests.adapters.betfair.test_kit import betting_instrument


if __name__ == "__main__":
# Configure backtest engine
config = BacktestEngineConfig(trader_id="BACKTESTER-001")
config = BacktestEngineConfig(trader_id=TraderId("BACKTESTER-001"))

# Build the backtest engine
engine = BacktestEngine(config=config)
Expand Down
3 changes: 2 additions & 1 deletion examples/backtest/crypto_ema_cross_ethusdt_trailing_stop.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@
from nautilus_trader.model.data import BarType
from nautilus_trader.model.enums import AccountType
from nautilus_trader.model.enums import OmsType
from nautilus_trader.model.identifiers import TraderId
from nautilus_trader.model.identifiers import Venue
from nautilus_trader.model.objects import Money
from nautilus_trader.persistence.wranglers import TradeTickDataWrangler
Expand All @@ -37,7 +38,7 @@

if __name__ == "__main__":
# Configure backtest engine
config = BacktestEngineConfig(trader_id="BACKTESTER-001")
config = BacktestEngineConfig(trader_id=TraderId("BACKTESTER-001"))

# Build the backtest engine
engine = BacktestEngine(config=config)
Expand Down
3 changes: 2 additions & 1 deletion examples/backtest/crypto_ema_cross_with_binance_provider.py
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@
from nautilus_trader.model.enums import OmsType
from nautilus_trader.model.identifiers import InstrumentId
from nautilus_trader.model.identifiers import Symbol
from nautilus_trader.model.identifiers import TraderId
from nautilus_trader.model.identifiers import Venue
from nautilus_trader.model.objects import Money
from nautilus_trader.persistence.wranglers import QuoteTickDataWrangler
Expand Down Expand Up @@ -66,7 +67,7 @@ async def create_provider():
if __name__ == "__main__":
# Configure backtest engine
config = BacktestEngineConfig(
trader_id="BACKTESTER-001",
trader_id=TraderId("BACKTESTER-001"),
logging=LoggingConfig(log_level="INFO"),
)

Expand Down
3 changes: 2 additions & 1 deletion examples/backtest/crypto_orderbook_imbalance.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@
from nautilus_trader.model.enums import BookType
from nautilus_trader.model.enums import OmsType
from nautilus_trader.model.enums import book_type_to_str
from nautilus_trader.model.identifiers import TraderId
from nautilus_trader.model.identifiers import Venue
from nautilus_trader.model.objects import Money
from nautilus_trader.persistence.loaders import BinanceOrderBookDeltaDataLoader
Expand All @@ -40,7 +41,7 @@
if __name__ == "__main__":
# Configure backtest engine
config = BacktestEngineConfig(
trader_id="BACKTESTER-001",
trader_id=TraderId("BACKTESTER-001"),
# logging=LoggingConfig(log_level="DEBUG"),
)

Expand Down
3 changes: 2 additions & 1 deletion examples/backtest/fx_ema_cross_audusd_bars_from_ticks.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@
from nautilus_trader.model.data import BarType
from nautilus_trader.model.enums import AccountType
from nautilus_trader.model.enums import OmsType
from nautilus_trader.model.identifiers import TraderId
from nautilus_trader.model.identifiers import Venue
from nautilus_trader.model.objects import Money
from nautilus_trader.persistence.wranglers import QuoteTickDataWrangler
Expand All @@ -39,7 +40,7 @@
if __name__ == "__main__":
# Configure backtest engine
config = BacktestEngineConfig(
trader_id="BACKTESTER-001",
trader_id=TraderId("BACKTESTER-001"),
)

# Build the backtest engine
Expand Down
3 changes: 2 additions & 1 deletion examples/backtest/fx_ema_cross_audusd_ticks.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@
from nautilus_trader.model.data import BarType
from nautilus_trader.model.enums import AccountType
from nautilus_trader.model.enums import OmsType
from nautilus_trader.model.identifiers import TraderId
from nautilus_trader.model.identifiers import Venue
from nautilus_trader.model.objects import Money
from nautilus_trader.persistence.wranglers import QuoteTickDataWrangler
Expand All @@ -40,7 +41,7 @@
if __name__ == "__main__":
# Configure backtest engine
config = BacktestEngineConfig(
trader_id="BACKTESTER-001",
trader_id=TraderId("BACKTESTER-001"),
)

# Build the backtest engine
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@
from nautilus_trader.model.data import BarType
from nautilus_trader.model.enums import AccountType
from nautilus_trader.model.enums import OmsType
from nautilus_trader.model.identifiers import TraderId
from nautilus_trader.model.identifiers import Venue
from nautilus_trader.model.objects import Money
from nautilus_trader.persistence.wranglers import BarDataWrangler
Expand All @@ -42,7 +43,7 @@
if __name__ == "__main__":
# Configure backtest engine
config = BacktestEngineConfig(
trader_id="BACKTESTER-001",
trader_id=TraderId("BACKTESTER-001"),
logging=LoggingConfig(log_level="INFO"),
risk_engine=RiskEngineConfig(
bypass=True, # Example of bypassing pre-trade risk checks for backtests
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@
from nautilus_trader.model.data import BarType
from nautilus_trader.model.enums import AccountType
from nautilus_trader.model.enums import OmsType
from nautilus_trader.model.identifiers import TraderId
from nautilus_trader.model.identifiers import Venue
from nautilus_trader.model.objects import Money
from nautilus_trader.persistence.wranglers import QuoteTickDataWrangler
Expand All @@ -42,7 +43,7 @@
if __name__ == "__main__":
# Configure backtest engine
config = BacktestEngineConfig(
trader_id="BACKTESTER-001",
trader_id=TraderId("BACKTESTER-001"),
logging=LoggingConfig(log_level="INFO"),
risk_engine=RiskEngineConfig(
bypass=True, # Example of bypassing pre-trade risk checks for backtests
Expand Down
3 changes: 2 additions & 1 deletion examples/backtest/fx_market_maker_gbpusd_bars.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@
from nautilus_trader.model.data import BarType
from nautilus_trader.model.enums import AccountType
from nautilus_trader.model.enums import OmsType
from nautilus_trader.model.identifiers import TraderId
from nautilus_trader.model.identifiers import Venue
from nautilus_trader.model.objects import Money
from nautilus_trader.persistence.wranglers import QuoteTickDataWrangler
Expand All @@ -41,7 +42,7 @@
if __name__ == "__main__":
# Configure backtest engine
config = BacktestEngineConfig(
trader_id="BACKTESTER-001",
trader_id=TraderId("BACKTESTER-001"),
)

# Build the backtest engine
Expand Down
3 changes: 2 additions & 1 deletion examples/backtest/fx_talib_gbpusd_bars_internal.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@
from nautilus_trader.model.data import BarType
from nautilus_trader.model.enums import AccountType
from nautilus_trader.model.enums import OmsType
from nautilus_trader.model.identifiers import TraderId
from nautilus_trader.model.identifiers import Venue
from nautilus_trader.model.objects import Money
from nautilus_trader.persistence.wranglers import QuoteTickDataWrangler
Expand All @@ -39,7 +40,7 @@
if __name__ == "__main__":
# Configure backtest engine
config = BacktestEngineConfig(
trader_id="BACKTESTER-001",
trader_id=TraderId("BACKTESTER-001"),
logging=LoggingConfig(log_level="INFO"),
risk_engine=RiskEngineConfig(
bypass=True, # Example of bypassing pre-trade risk checks for backtests
Expand Down
3 changes: 2 additions & 1 deletion tests/mem_leak_tests/memray_backtest.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@
from nautilus_trader.model.data import BarType
from nautilus_trader.model.enums import AccountType
from nautilus_trader.model.enums import OmsType
from nautilus_trader.model.identifiers import TraderId
from nautilus_trader.model.identifiers import Venue
from nautilus_trader.model.objects import Money
from nautilus_trader.persistence.wranglers import TradeTickDataWrangler
Expand All @@ -43,7 +44,7 @@

# Configure backtest engine
config = BacktestEngineConfig(
trader_id="BACKTESTER-001",
trader_id=TraderId("BACKTESTER-001"),
logging=LoggingConfig(bypass_logging=True),
)

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@
from nautilus_trader.model.data import BarType
from nautilus_trader.model.enums import AccountType
from nautilus_trader.model.enums import OmsType
from nautilus_trader.model.identifiers import TraderId
from nautilus_trader.model.identifiers import Venue
from nautilus_trader.model.objects import Money
from nautilus_trader.persistence.wranglers import QuoteTickDataWrangler
Expand All @@ -41,7 +42,7 @@
def run(*args, **kwargs):
# Configure backtest engine
config = BacktestEngineConfig(
trader_id="BACKTESTER-001",
trader_id=TraderId("BACKTESTER-001"),
logging=LoggingConfig(log_level="INFO", bypass_logging=True),
risk_engine=RiskEngineConfig(
bypass=True, # Example of bypassing pre-trade risk checks for backtests
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@
from nautilus_trader.model.data import BarType
from nautilus_trader.model.enums import AccountType
from nautilus_trader.model.enums import OmsType
from nautilus_trader.model.identifiers import TraderId
from nautilus_trader.model.identifiers import Venue
from nautilus_trader.model.objects import Money
from nautilus_trader.persistence.wranglers import TradeTickDataWrangler
Expand All @@ -38,7 +39,7 @@
def run(*args, **kwargs):
# Configure backtest engine
config = BacktestEngineConfig(
trader_id="BACKTESTER-001",
trader_id=TraderId("BACKTESTER-001"),
logging=LoggingConfig(log_level="INFO", bypass_logging=True),
)

Expand Down
3 changes: 2 additions & 1 deletion tests/mem_leak_tests/tracemalloc_market_maker_gbpusd_bars.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@
from nautilus_trader.model.data import BarType
from nautilus_trader.model.enums import AccountType
from nautilus_trader.model.enums import OmsType
from nautilus_trader.model.identifiers import TraderId
from nautilus_trader.model.identifiers import Venue
from nautilus_trader.model.objects import Money
from nautilus_trader.persistence.wranglers import QuoteTickDataWrangler
Expand All @@ -41,7 +42,7 @@
def run():
# Configure backtest engine
config = BacktestEngineConfig(
trader_id="BACKTESTER-001",
trader_id=TraderId("BACKTESTER-001"),
logging=LoggingConfig(log_level="INFO", bypass_logging=True),
)

Expand Down

0 comments on commit f0b8ad9

Please sign in to comment.