kernc / kernc/backtesting.py

Finalize Trades

Open
#1,342 1 comment 1 reaction 0 assignees View on GitHub
bug enhancement
Dominant language
Python
Stars
9k
Forks
1.5k
PR merge metrics
No merged PRs in 30d

Description

### Enhancement description

I have a bit of an issue with how if one sets `finalize_trades=False` the BT algo does not do/open the last trade, even if the signals are there for it to BUY/SELL, it does not implement it because `False` does not allow it to close the trade, hence it skips it altogether.

I think a change should be made here. If you set `finalize_trades=False` it should do the trade with `_trade` history showing the `EntryPrice`, with `ExitPrice` of course being blank (since it has not trade signal to close).

It would be a great improvement I think, in helping algo traders a lot.

### Code sample

```python

```

### Additional info, images

_No response_

Contributor guide

Open the contributing guide

Research direction

Start by tracing how the finalize_trades setting affects the final signal and how _trade history records EntryPrice and ExitPrice. Confirm the intended behavior for an unclosed final trade, then add or update coverage so finalize_trades=False preserves the entry while leaving the exit blank.

Written by the indexing model from the issue text.

Assessment

Tech stack
python
Domain
backend, fintech-quant
Issue type
Feature
Difficulty
4/5
Estimated time
3-5 days
Activity status
Quiet
Clarity
Mostly clear
Newbie friendliness
48/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.