nautechsystems / nautilus_trader

A high-performance algorithmic trading platform and event-driven backtester

Home Page:https://nautilustrader.io

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

tutorial not working

quant2008 opened this issue · comments

Hello, developers, I run this tutorial,
and it gives error "Argument 'instrument_id' has incorrect type (expected nautilus_trader.model.identifiers.InstrumentId, got str)"

Then I delete str in the following sentence (instrument_id=str(ETHUSDT_BINANCE.id):
strategy_config = EMACrossTWAPConfig(
instrument_id=str(ETHUSDT_BINANCE.id),
bar_type="ETHUSDT.BINANCE-250-TICK-LAST-INTERNAL",
trade_size=Decimal("0.10"),
fast_ema_period=10,
slow_ema_period=20,
twap_horizon_secs=10.0,
twap_interval_secs=2.5,
)
I run again, this time it gives error TypeError: Argument 'bar_type' has incorrect type (expected nautilus_trader.model.data.BarType, got str).
How to solve it?
I run on windows 10 and python 10.

Hi @quant2008

Apologies, the docs are lagging behind a change to configs. What you want is something like this:

# Configure your strategy
strategy_config = EMACrossTWAPConfig(
    instrument_id=ETHUSDT_BINANCE.id,
    bar_type=BarType.from_str("ETHUSDT.BINANCE-250-TICK-LAST-INTERNAL"),
    trade_size=Decimal("0.10"),
    fast_ema_period=10,
    slow_ema_period=20,
    twap_horizon_secs=10.0,
    twap_interval_secs=2.5,
)

Closing this as now fixed across all tutorials on develop branch.