Ejemplo n.º 1
0
    def test_from_dict_returns_expected_tick(self):
        # Arrange
        ticker = Ticker(
            ETHUSDT_BINANCE.id,
            0,
            0,
        )

        # Act
        result = Ticker.from_dict(Ticker.to_dict(ticker))

        # Assert
        assert ticker == result
Ejemplo n.º 2
0
    def test_to_dict_returns_expected_dict(self):
        # Arrange
        ticker = Ticker(
            ETHUSDT_BINANCE.id,
            0,
            0,
        )

        # Act
        result = Ticker.to_dict(ticker)

        # Assert
        assert result == {
            "type": "Ticker",
            "instrument_id": "ETHUSDT.BINANCE",
            "ts_event": 0,
            "ts_init": 0,
        }
Ejemplo n.º 3
0
    def test_ticker_hash_str_and_repr(self):
        # Arrange
        ticker = Ticker(
            ETHUSDT_BINANCE.id,
            0,
            0,
        )

        # Act, Assert
        assert isinstance(hash(ticker), int)
        assert str(
            ticker
        ) == "Ticker(instrument_id=ETHUSDT.BINANCE, ts_event=0)"  # noqa
        assert repr(
            ticker
        ) == "Ticker(instrument_id=ETHUSDT.BINANCE, ts_event=0)"  # noqa
Ejemplo n.º 4
0
 def test_fully_qualified_name(self):
     # Arrange, Act, Assert
     assert Ticker.fully_qualified_name(
     ) == "nautilus_trader.model.data.ticker.Ticker"
Ejemplo n.º 5
0
 def ticker(instrument_id=None) -> Ticker:
     return Ticker(
         instrument_id=instrument_id or TestIdStubs.audusd_id(),
         ts_event=0,
         ts_init=0,
     )