def test_manager_change_params(monkeypatch):
    fake_params = copy.deepcopy(model.DividendsModel.PARAMS)
    fake_params['data']['lags'] += 1
    monkeypatch.setattr(model.DividendsModel, 'PARAMS', fake_params)
    positions = tuple(['PRTK', 'MVID', 'CHMF', 'MTSS', 'PMSBP'])
    date = pd.Timestamp('2018-09-06')
    data = manager.DividendsMLDataManager(positions, date)
    assert data.value.params['data']['lags'] == fake_params['data']['lags']
    assert data.value.params == model.DividendsModel(positions, date).params
Ejemplo n.º 2
0
def test_tickers_real_after_tax_mean():
    positions = dict(GMKN=146, MSTT=1823, NLMK=507, TTLK=234, PRTK=0)
    date = '2018-09-04'
    portfolio = metrics.Portfolio(date, 0, positions)
    dividends_metrics = metrics.dividends_metrics_ml.MLDividendsMetrics(
        portfolio)
    dividends_model = model.DividendsModel(tuple(sorted(positions)),
                                           pd.Timestamp(date))
    assert dividends_metrics._tickers_real_after_tax_mean.equals(
        dividends_model.prediction_mean)
def make_data():
    saved_params = model.DividendsModel.PARAMS
    saved_searches = hyper.MAX_SEARCHES
    saved_space = hyper.make_model_space
    model.DividendsModel.PARAMS = PARAMS
    hyper.MAX_SEARCHES = 2
    hyper.make_model_space = fake_make_model_space
    yield model.DividendsModel(('CHMF', 'MSTT', 'PMSBP', 'SNGSP', 'NLMK'),
                               pd.Timestamp('2018-09-05'))
    model.DividendsModel.PARAMS = saved_params
    hyper.MAX_SEARCHES = saved_searches
    hyper.make_model_space = saved_space
Ejemplo n.º 4
0
def test_tickers_real_after_tax_std():
    positions = dict(GMKN=146, MSTT=1823, NLMK=507, TTLK=234, PRTK=0)
    date = '2018-09-04'
    portfolio = metrics.Portfolio(date, 0, positions)
    dividends_metrics = metrics.dividends_metrics_ml.MLDividendsMetrics(
        portfolio)
    dividends_model = model.DividendsModel(tuple(sorted(positions)),
                                           pd.Timestamp(date))
    assert isinstance(dividends_metrics._tickers_real_after_tax_std, pd.Series)
    assert dividends_metrics._tickers_real_after_tax_std.index.equals(
        pd.Index(sorted(positions)))
    assert np.allclose(dividends_metrics._tickers_real_after_tax_std.values,
                       dividends_model.std)
def test_manager_first_time():
    positions = tuple(['MSTT', 'MVID', 'CHMF', 'MTSS', 'PMSBP'])
    date = pd.Timestamp('2018-09-06')
    data = manager.DividendsMLDataManager(positions, date)
    assert data.value.params == model.DividendsModel(positions, date).params