Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[BUG] VersusEnterAndHoldCriterion should use 'amount' to match comparsion #1132

Open
2 tasks done
Cashmeiser opened this issue Feb 18, 2024 · 0 comments
Open
2 tasks done
Labels
bug Issue describing or discussing an bug in this library

Comments

@Cashmeiser
Copy link

I have checked existing issues and wiki

Describe the bug
When running a Backtest with BarSeriesManager a amount is provided and used as the quantity of each trade.
When running a VersusEnterAndHoldCriterion it always uses 1 as the amount (or quantity) for the buy and sell trade.
If comparing with a non-percentage criterion it will be a non-useful comparison.

Lets see an example:
Run a backtest with BarSeriesManager with amount 10 (quantity).
Then run a new VersusEnterAndHoldCriterion(new ProfitLossCriterion()).calculate(barSeries, tradingRecord)
and it will produce a value 10 times greater than it actually is, due to not creating the "enter and hold" with same amount (quantity).

To Reproduce
Steps to reproduce the behavior:

  1. Run a backtest with BarSeriesManager and use amount=10 and assign result to variable tradingRecordTen
  2. Run a new backtest with BarSeriesManager and use amount=1 and assign result to variable tradingRecordOne
  3. Run new VersusEnterAndHoldCriterion(new ProfitLossCriterion()).calculate(barSeries, tradingRecordTen) and compare result when you run new VersusEnterAndHoldCriterion(new ProfitLossCriterion()).calculate(barSeries, tradingRecordOne).
  4. Be amazed that the higher quantity used, the better you are than Buy and Hold

Expected behavior
Expect that VersusEnterAndHoldCriterion comparison should give same result no matter what amount is used per trade, since I expect enter and hold always uses same amount as its compared to.

@Cashmeiser Cashmeiser added the bug Issue describing or discussing an bug in this library label Feb 18, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Issue describing or discussing an bug in this library
Projects
None yet
Development

No branches or pull requests

1 participant