Exemplo n.º 1
0
def test_context_load_strategy_error() -> None:
    settings = Setting()
    settings.STRATEGY = MagicMock()  # type:ignore

    context = Context(settings)
    with pytest.raises(SettingError):
        context.load_strategy()
Exemplo n.º 2
0
def test_context_custom_setting() -> None:
    with patch("monkq.exchange.bitmex.exchange.BitmexDataloader"):
        settings = Setting()
        settings.STRATEGY = TestStrategy  # type:ignore
        settings.TRADE_COUNTER = TestTradeCounter  # type:ignore
        settings.STATISTIC = TestStatistic  # type:ignore
        settings.ACCOUNTS[0]['ACCOUNT_MODEL'] = TestAccount  # type:ignore
        settings.EXCHANGES['bitmex']['ENGINE'] = TestExchange  # type:ignore

        context = Context(settings)
        context.setup_context()

        assert isinstance(context.strategy, TestStrategy)
        assert isinstance(context.trade_counter, TestTradeCounter)
        assert isinstance(context.stat, TestStatistic)
        assert isinstance(context.accounts, dict)
        assert isinstance(context.exchanges, dict)