コード例 #1
0
    def test_closed(self):
        fr = FrameFactory()

        next_frame = FrameFactory()
        fr.next_frame = next_frame

        assert fr.closed is True
コード例 #2
0
    def test_update_last_tick(self):
        tick = TickFactory()
        fr = FrameFactory()

        fr.on_new_tick(tick)

        assert fr.last_tick == tick
コード例 #3
0
    def test_update_high_tick(self):
        fr = FrameFactory()
        fr.high_tick = TickFactory(bid=99, ask=101)

        new_high = TickFactory(bid=100, ask=102)
        fr.on_new_tick(new_high)

        assert fr.high_tick == new_high
コード例 #4
0
    def test_update_low_tick(self):
        fr = FrameFactory()
        fr.low_tick = TickFactory(bid=99, ask=101)

        new_low = TickFactory(bid=98, ask=100)
        fr.on_new_tick(new_low)

        assert fr.low_tick == new_low
コード例 #5
0
    def test_indicators_on_new_tick_called__indicator_none(
            self, mocker, market_open):
        epic_mock = mocker.Mock()
        epic_mock.market_open = market_open
        parent_framset = FrameSetFactory()
        indicator_mock = mocker.Mock()
        indicator_mock.ref = "my_indicator_ref"
        parent_framset.epic = epic_mock
        parent_framset.add_indicator(indicator_mock)
        fr = FrameFactory(parent_frameset=parent_framset)
        fr.indicators = {"my_indicator_ref": None}

        tick = TickFactory()
        fr.on_new_tick(tick)

        assert indicator_mock.build_value_from_frame.call_args_list == [
            call(fr, market_open),  # call on Frame Init
            call(fr, market_open),
        ]
コード例 #6
0
ファイル: test_rsi_value.py プロジェクト: cimourdain/estrade
    def test_base_indicator_value_call(self, mocker):
        init_mock = mocker.patch.object(
            BaseIndicatorValue, "__init__", wraps=BaseIndicatorValue.__init__
        )

        frame_mock = FrameFactory()
        rsi = RSIFactory()
        rsi.rsi_periods = 5
        rsiv = RSIValue(frame=frame_mock, indicator=rsi)

        assert init_mock.call_args_list == [call(rsiv, frame=frame_mock, indicator=rsi)]
コード例 #7
0
    def test_indicators_not_empty(self, mocker):
        epic_mock = mocker.Mock()
        epic_mock.market_open = True
        parent_framset = FrameSetFactory()
        indicator_mock = mocker.Mock()
        indicator_mock.ref = "my_indicator_ref"
        indicator_mock.build_value_from_frame.return_value = "indicator_value"
        parent_framset.epic = epic_mock
        parent_framset.add_indicator(indicator_mock)
        fr = FrameFactory(parent_frameset=parent_framset)

        assert fr.indicators == {"my_indicator_ref": "indicator_value"}
コード例 #8
0
ファイル: test_frame_set.py プロジェクト: cimourdain/estrade
    def test_create_new_frame_call__gap(self, mocker):
        fs = FrameSetFactory(unit=Unit.SECOND, unit_quantity=10)
        create_new_frame_mock = mocker.patch.object(fs,
                                                    "create_new_frame",
                                                    wraps=fs.create_new_frame)
        current_last_tick = TickFactory()
        current_frame = FrameFactory(
            first_tick=current_last_tick,
            period_start=arrow.get("2020-01-01 12:34:10"),
            period_end=arrow.get("2020-01-01 12:34:20"),
        )
        fs.frames = [current_frame]

        new_tick = TickFactory(datetime=arrow.get("2020-01-01 12:34:56"))
        fs.on_new_tick(new_tick)

        assert create_new_frame_mock.call_args_list == [
            call(
                current_last_tick,
                arrow.get("2020-01-01 12:34:20"),
                arrow.get("2020-01-01 12:34:30"),
            ),
            call(
                current_last_tick,
                arrow.get("2020-01-01 12:34:30"),
                arrow.get("2020-01-01 12:34:40"),
            ),
            call(
                current_last_tick,
                arrow.get("2020-01-01 12:34:40"),
                arrow.get("2020-01-01 12:34:50"),
            ),
            call(
                new_tick,
                arrow.get("2020-01-01 12:34:50"),
                arrow.get("2020-01-01 12:35:00"),
            ),
        ]
コード例 #9
0
    def test_period_start(self):
        period_start = arrow.utcnow()

        fr = FrameFactory(period_start=period_start)

        assert fr.period_start == period_start
コード例 #10
0
    def test_indicators__no_indicators(self):
        fr = FrameFactory()

        assert fr.indicators == {}
コード例 #11
0
    def test_low_tick__default(self):
        tick = TickFactory()

        fr = FrameFactory(first_tick=tick)

        assert fr.low_tick == tick
コード例 #12
0
    def test_nb_ticks__default(self):
        fr = FrameFactory()

        assert fr.nb_ticks == 1
コード例 #13
0
    def test_previous_frame__manual(self):
        previous_frame = FrameFactory()

        fr = FrameFactory(previous_frame=previous_frame)

        assert fr.previous_frame == previous_frame
コード例 #14
0
    def test_previous_frame__default(self):
        fr = FrameFactory()

        assert fr.previous_frame is None
コード例 #15
0
    def test_period_end__manual(self):
        period_end = arrow.utcnow()

        fr = FrameFactory(period_end=period_end)

        assert fr.period_end == period_end
コード例 #16
0
    def test_period_end__default(self):
        fr = FrameFactory()

        assert fr.period_end is None
コード例 #17
0
    def test_resistance3(self):
        bpt = BasePivotType(indicator="test", frame=FrameFactory())

        with pytest.raises(NotImplementedError):
            bpt.resistance3
コード例 #18
0
    def test_not_closed(self):
        fr = FrameFactory()

        assert fr.closed is False
コード例 #19
0
    def test_frame(self):
        fr = FrameFactory()
        biv = BaseIndicatorValueFactory(frame=fr)

        assert biv.frame == fr
コード例 #20
0
    def test_first_tick(self):
        tick = TickFactory()

        fr = FrameFactory(first_tick=tick)

        assert fr.first_tick == tick
コード例 #21
0
    def test_nb_ticks_update(self):
        fr = FrameFactory()

        fr.on_new_tick(TickFactory())

        assert fr.nb_ticks == 2
コード例 #22
0
ファイル: test_frame_set.py プロジェクト: cimourdain/estrade
    def test_exists(self):
        fs = FrameSetFactory()
        last_frame = FrameFactory()
        fs.frames = ["first", last_frame]

        assert fs.current == last_frame
コード例 #23
0
    def test_get_not_existing(self):
        fr = FrameFactory()

        assert fr["undefined"] is None
コード例 #24
0
    def test_existing(self):
        fr = FrameFactory()

        fr.indicators["test_indicator"] = "test"

        assert fr["test_indicator"] == "test"
コード例 #25
0
    def test_support2(self):
        bpt = BasePivotType(indicator="test", frame=FrameFactory())

        with pytest.raises(NotImplementedError):
            bpt.support2