diff --git a/tests/test_strategy.py b/tests/test_strategy.py index 32c04b4..7cc6607 100644 --- a/tests/test_strategy.py +++ b/tests/test_strategy.py @@ -2,6 +2,7 @@ from . import util import os import numpy as np +import pandas as pd def test_iterate(): @@ -59,4 +60,36 @@ def test_backtest_fees(): resutlt = cira.strategy.back_test(strat, feature_data, prices, 100, use_fees=True) res = resutlt[strat.name].values.astype(int).tolist() - assert res == [99, 98, 97, 96, 95] \ No newline at end of file + assert res == [99, 98, 97, 96, 95] + + +def test_backtest_multi_asset_uniform_prices(): + feature_data = util.stock_data + strat = cira.strategy.DollarCostAveraging(amount=1) + + prices = pd.DataFrame() + prices["ast_1"] = [10, 10, 5, 20, 10] + prices["ast_2"] = [10, 10, 5, 20, 10] + prices["ast_3"] = [10, 10, 5, 20, 10] + prices["ast_4"] = [10, 10, 5, 20, 10] + + resutlt = cira.strategy.back_test(strat, feature_data, prices, 40, use_fees=False) + + res = resutlt[strat.name].values.astype(int).tolist() + assert res == [40, 40, 20, 80, 40] + + +def test_backtest_multi_asset(): + feature_data = util.stock_data + strat = cira.strategy.DollarCostAveraging(amount=1) + + prices = pd.DataFrame() + prices["ast_1"] = [10, 10, 1, 0, 0] + prices["ast_2"] = [10, 11, 5, 0, 0] + prices["ast_3"] = [10, 10, 1, 0, 0] + prices["ast_4"] = [10, 14, 7, 99, 0] + + resutlt = cira.strategy.back_test(strat, feature_data, prices, 40, use_fees=False) + + res = resutlt[strat.name].values.astype(int).tolist() + assert res == [40, 45, 14, 99, 0] \ No newline at end of file