4 changed files with 70 additions and 6 deletions
@ -0,0 +1,38 @@ |
|||
import pytest |
|||
from datetime import datetime |
|||
from pandas import DataFrame, Series # type: ignore |
|||
|
|||
from auto_trading.strat.prop import Prop |
|||
from auto_trading.indicators.dumb import Dumb |
|||
from auto_trading.interfaces import PTFState |
|||
from auto_trading.orders import Long, Short |
|||
|
|||
|
|||
date = datetime.strptime("2015-03-31", "%Y-%m-%d") |
|||
|
|||
|
|||
@pytest.mark.parametrize( |
|||
"max_delta, data, indicators_results, state, results", |
|||
[ |
|||
( |
|||
10, |
|||
DataFrame({"close": {(date, "GOOG"): 10, (date, "GOOGL"): 10}}), |
|||
Series({"GOOG": 1, "GOOGL": -1}), |
|||
PTFState(50, {"GOOG": 0, "GOOGL": 0}), |
|||
[Long("GOOG", price=10, amount=5)], |
|||
), |
|||
( |
|||
10, |
|||
DataFrame({"close": {(date, "GOOG"): 10, (date, "GOOGL"): 10}}), |
|||
Series({"GOOG": 1, "GOOGL": -1}), |
|||
PTFState(5, {"GOOG": 0, "GOOGL": 0}), |
|||
[], |
|||
), |
|||
], |
|||
) |
|||
def test_prop(max_delta, data, indicators_results, state, results): |
|||
strat = Prop(max_delta=max_delta, indicators={"ind": Dumb(indicators_results)}) |
|||
res = strat.run(data, state) |
|||
assert len(res) == len(results) |
|||
for result in results: |
|||
assert result in res |
Loading…
Reference in new issue