예제 #1
0
def test_update_data_bad_date():
    port = portfolio.Portfolio(date=DATE_OLD, cash=CASH, positions=POSITIONS)
    with pytest.raises(POptimizerError) as error:
        pdf.update_data(
            "test",
            port.date,
            port.value[PORTFOLIO],
            dict(WLMike=1000, Igor=-2000),
            1234,
        )
    assert str(error.value) == "В этом месяце данные уже вносились в отчет"
예제 #2
0
def test_update_data():
    port = portfolio.Portfolio(date=DATE_NEW, cash=CASH, positions=POSITIONS)
    pdf.update_data("test", port.date, port.value[PORTFOLIO],
                    dict(WLMike=1000, Igor=-2000), 1234)
    df = pdf.read_data("test")
    assert df.shape == (241, 6)
    assert df.index[-1] == pd.Timestamp("2018-05-07")
    assert df.loc["2018-05-07", "WLMike"] == pytest.approx(1000)
    assert df.loc["2018-05-07", "Igor"] == pytest.approx(-2000)
    assert df.loc["2018-05-07",
                  "Value_WLMike"] == pytest.approx(384_396.431_074_62)
    assert df.loc["2018-05-07",
                  "Value_Igor"] == pytest.approx(8126.568_925_380_33)
    assert df.loc["2018-05-07", "Value"] == pytest.approx(392_523)
    assert df.loc["2018-05-07", "Dividends"] == pytest.approx(1234)
예제 #3
0
def test_update_data_bad_investor_name():
    port = portfolio.Portfolio(date=DATE_NEW, cash=CASH, positions=POSITIONS)
    with pytest.raises(POptimizerError) as error:
        pdf.update_data("test", port.date, port.value[PORTFOLIO],
                        dict(WLMike1=1000), 1234)
    assert str(error.value) == "Неверное имя инвестора - WLMike1"