Пример #1
0
def test_toomanyasset():
    """
    Test if fetch_usstocks raises ValueError
    when n_asset is too many.
    """
    with pytest.raises(ValueError):
        fetch_usstocks(n_assets=1000)
Пример #2
0
def main():
    universe = fetch_usstocks(n_assets=10)

    strategy = SimpleTrendFollower()
    strategy.run(universe)

    plot(strategy)
Пример #3
0
    import pandas as pd

    import epymetheus as ep
    from epymetheus.benchmarks import dumb_strategy

    # ---

    my_strategy = ep.create_strategy(dumb_strategy,
                                     profit_take=20.0,
                                     stop_loss=-10.0)

    # ---

    from epymetheus.datasets import fetch_usstocks

    universe = fetch_usstocks()
    print(">>> universe.head()")
    print_as_comment(universe.head())

    print(">>> my_strategy.run(universe)")
    my_strategy.run(universe)

    # ---

    df_history = my_strategy.history()
    df_history.head()
    print(">>> df_history.head()")
    print_as_comment(df_history.head())

    # ---
Пример #4
0
def test_usstocks():
    try:
        universe = fetch_usstocks(n_assets=2)
        assert not np.isnan(universe.prices.values).any(axis=None)
    except RemoteDataError as e:
        print("Skip", e)