Example #1
0
def test_multiple_nested_quotes_update():
    duration = 1
    quotes = Quotes(duration)
    jaw = quotes.close
    teeth = quotes.close
    ave = (jaw * 13 + teeth * 8) / 21

    mock_quotes = Quote.mock_ohlcv_points(list(np.arange(1, 25)), t_step=1)
    for q in mock_quotes:
        quotes.append(q)
        assert jaw.is_updating is False
        assert teeth.is_updating is False
        assert ave.is_updating is False
        _ = ave.domain

    assert ave.domain == Interval.closed(0, 23)
    assert ave(0) == 1
Example #2
0
def test_offset_close_update_from_empty():
    quotes = Quotes(1)
    ps = quotes.close.offset(10)
    assert ps.domain.is_empty

    mock_quotes = Quote.mock_ohlcv_points([(1, 2.2, 0.9, 2), (2, 3.1, 1.9, 3)],
                                          t_step=1)

    for q in mock_quotes:
        quotes.append(q)
        _ = ps.domain

    assert ps.domain == Interval.closed(10, 11)
    assert ps(9) is None
    assert ps(10) == 2
    assert ps(11) == 3
    assert ps(12) is None