tradingstrategy-ai / trade-executor

A Python framework for managing positions and trades in DeFi
https://tradingstrategy.ai
Other
107 stars 29 forks source link

stats not updating on last cycle #907

Closed AlexTheLion123 closed 6 months ago

AlexTheLion123 commented 6 months ago

Background

Example 1

see test_synthetic_data_backtest_stop_loss

https://github.com/tradingstrategy-ai/trade-executor/blob/2988f1d8f0085186666c388dd6f0f4783db07e49/tests/backtest/test_backtest_position_trigger.py#L459-L460

The number of trades here should be 62 since all the positions are closed (add assert len([p for p in state.portfolio.get_all_positions() if p.is_closed()] == 31 to confirm)

Example 2

Same concept

https://github.com/tradingstrategy-ai/trade-executor/blob/2988f1d8f0085186666c388dd6f0f4783db07e49/tests/backtest/test_backtest_position_trigger.py#L643-L644

This also happens for the number of stop losses and take profits if it happens on the last cycle

Acceptance criteria