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] Criteria depending on ReturnCriterion includes the base #1076

Open
nimo23 opened this issue Jul 26, 2023 · 2 comments
Open

[BUG] Criteria depending on ReturnCriterion includes the base #1076

nimo23 opened this issue Jul 26, 2023 · 2 comments
Labels
bug Issue describing or discussing an bug in this library

Comments

@nimo23
Copy link
Contributor

nimo23 commented Jul 26, 2023

Describe the bug
I don't know exactly if this is a bug, but we should discuss it to make sure that it's correct.

The following critera:

  • ReturnOverMaxDrawdownCriterion
  • AverageReturnPerBarCriterion
  • LinearTransactionCostCriterion

use the ReturnCriterion which includes the base for their calculations. Is this correct? Or should we exclude the base by doing:

(1) AverageReturnPerBarCriterion:

public class AverageReturnPerBarCriterion extends AbstractAnalysisCriterion {

   private final ReturnCriterion grossReturn = new ReturnCriterion(false);
..

(2) ReturnOverMaxDrawdownCriterion:

public class ReturnOverMaxDrawdownCriterion extends AbstractAnalysisCriterion {

   private final AnalysisCriterion grossReturnCriterion = new ReturnCriterion(false);
..

(3) LinearTransactionCostCriterion:

public class LinearTransactionCostCriterion extends AbstractAnalysisCriterion {

public LinearTransactionCostCriterion(double initialAmount, double a, double b) {
        this.initialAmount = initialAmount;
        this.a = a;
        this.b = b;
        grossReturn = new ReturnCriterion(false);
}
..
}

What do you think?

For (1) AverageReturnPerBarCriterion:

The general formula for ReturnOverMaxDrawdownCriterion:

Return over Max. Drawdown = Total Return / Max. Drawdown

or:

Return over Max. Drawdown = (Total Return - Max. Drawdown) / Max. Drawdown

with the general formula for TotalReturn:

Total Return = (Final Investment Value - Initial Investment Value) / Initial Investment Value

If we have a MaxDrawdownCriterion = 1 (= total loss) and ReturnCriterion = 1 (because we include the base), then we have ReturnOverMaxDrawdownCriterion = 1. I don't know if this makes sense at all. I think, the "Total Return in percentage" should not include the base value of 100% Am I right? If so, then we should exclude the base from the calculation of ReturnOverMaxDrawdownCriterion.

@nimo23 nimo23 added the bug Issue describing or discussing an bug in this library label Jul 26, 2023
@nimo23 nimo23 changed the title [BUG] ReturnOverMaxDrawdownCriterion and AverageReturnPerBarCriterion [BUG] Criteria depending on ReturnCriterion includes the base Jul 26, 2023
@nimo23
Copy link
Contributor Author

nimo23 commented Jul 30, 2023

Ok, I think there are misunderstandings due to a lack of information:

We need to add the base to avoid minus signs canceling out when dividing. I guess (but I am not 100% sure), it is not wrong to include the base,

@team172011 can you confirm that it's actually correct?

@nimo23 nimo23 closed this as completed Jul 30, 2023
@nimo23 nimo23 reopened this Jul 30, 2023
@phong-phuong
Copy link
Contributor

I agree. For most metrics where return is used, it is the excess return (without the base) that is of interest.
Otherwise, for a strategy that does absolutely nothing, 100% return per bar looks amazing, but in fact doesn't generate any yield.

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

2 participants