Skip to content

Commit

Permalink
added backtest unit test
Browse files Browse the repository at this point in the history
  • Loading branch information
AxelGard committed Apr 2, 2024
1 parent 91ad2a4 commit e15543c
Showing 1 changed file with 14 additions and 0 deletions.
14 changes: 14 additions & 0 deletions tests/test_strategy.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,3 +22,17 @@ def test_storing_strategy():
assert CHECK == new_strat.test_name

os.system(f"rm {FILE}")


def test_backtest():
feature_data = util.stock_data
strat = cira.strategy.Randomness(seed=2**14)
prices = feature_data["close"].to_frame()
prices["close"] = [10, 100, 10_000, 100, 10]

resutlt = cira.strategy.back_test(strat, feature_data, prices, 10_000)

res = resutlt[strat.name].values.tolist()
res = [int(r) for r in res]

assert res == [9999, 10089, 20029, 20029]

0 comments on commit e15543c

Please sign in to comment.