Beispiel #1
0
def test_rvi(date, index):
    """Проверка, что первые данные обрезаны."""
    df = indexes.rvi(pd.Timestamp("2020-10-16"))

    assert isinstance(df, pd.Series)
    assert df.index.is_monotonic_increasing and df.name == col.CLOSE

    assert df.index[0] >= bootstrap.START_DATE
    assert df.index[-1] == pd.Timestamp("2020-10-16")

    assert df.loc[date] == pytest.approx(index)
Beispiel #2
0
 def __init__(self, ticker: str, params: DataParams):
     super().__init__(ticker, params)
     rvi = indexes.rvi(params.end)
     price = params.price(ticker)
     rvi = rvi.reindex(
         price.index,
         method="ffill",
         axis=0,
     )
     self.rvi = torch.tensor(rvi.values, dtype=torch.float, device=DEVICE)
     self.history_days = params.history_days
Beispiel #3
0
def test_index():
    """Совпадение данных произвольного индекса и специальной функции."""
    pd.testing.assert_series_equal(
        indexes.index("RVI", pd.Timestamp("2021-09-02")),
        indexes.rvi(pd.Timestamp("2021-09-02")),
    )