Record Class BacktestConfig

java.lang.Object
java.lang.Record
com.quantfinlib.backtest.BacktestConfig

public record BacktestConfig(double initialCapital, double commissionRate, double slippageRate, double stopLossPct, double takeProfitPct, int periodsPerYear) extends Record
Backtest execution parameters. Rates are fractions (0.001 = 10 bps). stopLossPct/takeProfitPct of 0 disable the respective check; a strategy's own stop/take-profit settings override zeros here.
  • Constructor Details

    • BacktestConfig

      public BacktestConfig(double initialCapital, double commissionRate, double slippageRate, double stopLossPct, double takeProfitPct, int periodsPerYear)
      Creates an instance of a BacktestConfig record class.
      Parameters:
      initialCapital - the value for the initialCapital record component
      commissionRate - the value for the commissionRate record component
      slippageRate - the value for the slippageRate record component
      stopLossPct - the value for the stopLossPct record component
      takeProfitPct - the value for the takeProfitPct record component
      periodsPerYear - the value for the periodsPerYear record component
  • Method Details

    • defaults

      public static BacktestConfig defaults()
    • withInitialCapital

      public BacktestConfig withInitialCapital(double capital)
    • withCommission

      public BacktestConfig withCommission(double rate)
    • withStopLoss

      public BacktestConfig withStopLoss(double pct)
    • withTakeProfit

      public BacktestConfig withTakeProfit(double pct)
    • 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.
    • initialCapital

      public double initialCapital()
      Returns the value of the initialCapital record component.
      Returns:
      the value of the initialCapital record component
    • commissionRate

      public double commissionRate()
      Returns the value of the commissionRate record component.
      Returns:
      the value of the commissionRate record component
    • slippageRate

      public double slippageRate()
      Returns the value of the slippageRate record component.
      Returns:
      the value of the slippageRate record component
    • stopLossPct

      public double stopLossPct()
      Returns the value of the stopLossPct record component.
      Returns:
      the value of the stopLossPct record component
    • takeProfitPct

      public double takeProfitPct()
      Returns the value of the takeProfitPct record component.
      Returns:
      the value of the takeProfitPct record component
    • periodsPerYear

      public int periodsPerYear()
      Returns the value of the periodsPerYear record component.
      Returns:
      the value of the periodsPerYear record component