Пример #1
0
def test_transformers():
    """Verify transformers work."""
    pos_from_price = PositionsFromPricePrediction()
    df = simulated_market_data_4_years_gen()
    df["forecast_price_change"] = df["close"] * 0.000_1
    df_with_positions = pos_from_price.fit_transform(df)
    predictions_from_positions = PricePredictionFromPositions()
    df0 = predictions_from_positions.fit_transform(df_with_positions)
    df0 = df0.round()
    df = df_with_positions.round()
    assert list(df["forecast_price_change"]) == list(df0["forecast_price_change"])
Пример #2
0
def test_readme_example_three():
    """Get price prediction and positions from a signal transformer"""
    pipeline = make_pipeline(scikit_signal_factory(normalised_close),
                             PricePredictionFromSignalRegression(),
                             PositionsFromPricePrediction())

    pipeline.fit_transform(simulated_market_data_4_years_gen())
Пример #3
0
def test_readme_example_four():
    """Get price prediction and positions from an external signal transformer"""
    adapted_aroon = ta_adaptor(AroonIndicator, "aroon_down", window=1)
    pipeline = make_pipeline(
        scikit_signal_factory(adapted_aroon), PricePredictionFromSignalRegression(), PositionsFromPricePrediction()
    )
    pipeline.fit_transform(simulated_market_data_4_years_gen())
Пример #4
0
def test_pipeline_signal_to_position():
    """Checks we can use a signal in conjunction with a rule to calculate a position."""
    signal_to_positions = make_pipeline(
        scikit_signal_factory(normalised_close, ),
        PricePredictionFromSignalRegression(), PositionsFromPricePrediction())
    df = signal_to_positions.fit_transform(simulated_market_data_4_years_gen())
    assert isinstance(df, pd.DataFrame)