예제 #1
0
def test_context_load_statistic_error() -> None:
    settings = Setting()
    settings.STATISTIC = MagicMock  # type:ignore

    context = Context(settings)
    with pytest.raises(SettingError):
        context.load_statistic()
예제 #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)