Record Class TradeAnalytics.Result

java.lang.Object
java.lang.Record
com.quantfinlib.backtest.TradeAnalytics.Result
Record Components:
count - number of trades
winRate - fraction of strictly-positive trades
expectancy - average P&L per trade
avgWin - mean P&L of winning trades (0 if none)
avgLoss - mean magnitude of losing trades (0 if none)
payoffRatio - avgWin / avgLoss (+inf if no losers)
maxWinStreak - longest run of consecutive winners
maxLossStreak - longest run of consecutive losers
kellyFraction - W - (1-W)/R, clamped to [0, 1]
avgBarsHeldWinners - mean holding period of winners
avgBarsHeldLosers - mean holding period of losers
Enclosing class:
TradeAnalytics

public static record TradeAnalytics.Result(int count, double winRate, double expectancy, double avgWin, double avgLoss, double payoffRatio, int maxWinStreak, int maxLossStreak, double kellyFraction, double avgBarsHeldWinners, double avgBarsHeldLosers) extends Record
  • Constructor Details

    • Result

      public Result(int count, double winRate, double expectancy, double avgWin, double avgLoss, double payoffRatio, int maxWinStreak, int maxLossStreak, double kellyFraction, double avgBarsHeldWinners, double avgBarsHeldLosers)
      Creates an instance of a Result record class.
      Parameters:
      count - the value for the count record component
      winRate - the value for the winRate record component
      expectancy - the value for the expectancy record component
      avgWin - the value for the avgWin record component
      avgLoss - the value for the avgLoss record component
      payoffRatio - the value for the payoffRatio record component
      maxWinStreak - the value for the maxWinStreak record component
      maxLossStreak - the value for the maxLossStreak record component
      kellyFraction - the value for the kellyFraction record component
      avgBarsHeldWinners - the value for the avgBarsHeldWinners record component
      avgBarsHeldLosers - the value for the avgBarsHeldLosers record component
  • Method Details

    • toString

      public final String toString()
      Returns a string representation of this record class. The representation contains the name of the class, followed by the name and value of each of the record components.
      Specified by:
      toString in class Record
      Returns:
      a string representation of this object
    • hashCode

      public final int hashCode()
      Returns a hash code value for this object. The value is derived from the hash code of each of the record components.
      Specified by:
      hashCode in class Record
      Returns:
      a hash code value for this object
    • equals

      public final boolean equals(Object o)
      Indicates whether some other object is "equal to" this one. The objects are equal if the other object is of the same class and if all the record components are equal. All components in this record class are compared with the compare method from their corresponding wrapper classes.
      Specified by:
      equals in class Record
      Parameters:
      o - the object with which to compare
      Returns:
      true if this object is the same as the o argument; false otherwise.
    • count

      public int count()
      Returns the value of the count record component.
      Returns:
      the value of the count record component
    • winRate

      public double winRate()
      Returns the value of the winRate record component.
      Returns:
      the value of the winRate record component
    • expectancy

      public double expectancy()
      Returns the value of the expectancy record component.
      Returns:
      the value of the expectancy record component
    • avgWin

      public double avgWin()
      Returns the value of the avgWin record component.
      Returns:
      the value of the avgWin record component
    • avgLoss

      public double avgLoss()
      Returns the value of the avgLoss record component.
      Returns:
      the value of the avgLoss record component
    • payoffRatio

      public double payoffRatio()
      Returns the value of the payoffRatio record component.
      Returns:
      the value of the payoffRatio record component
    • maxWinStreak

      public int maxWinStreak()
      Returns the value of the maxWinStreak record component.
      Returns:
      the value of the maxWinStreak record component
    • maxLossStreak

      public int maxLossStreak()
      Returns the value of the maxLossStreak record component.
      Returns:
      the value of the maxLossStreak record component
    • kellyFraction

      public double kellyFraction()
      Returns the value of the kellyFraction record component.
      Returns:
      the value of the kellyFraction record component
    • avgBarsHeldWinners

      public double avgBarsHeldWinners()
      Returns the value of the avgBarsHeldWinners record component.
      Returns:
      the value of the avgBarsHeldWinners record component
    • avgBarsHeldLosers

      public double avgBarsHeldLosers()
      Returns the value of the avgBarsHeldLosers record component.
      Returns:
      the value of the avgBarsHeldLosers record component