def test_toomanyasset(): """ Test if fetch_usstocks raises ValueError when n_asset is too many. """ with pytest.raises(ValueError): fetch_usstocks(n_assets=1000)
def main(): universe = fetch_usstocks(n_assets=10) strategy = SimpleTrendFollower() strategy.run(universe) plot(strategy)
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()) # ---
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)