Record Class AlphaBacktester.Config

java.lang.Object
java.lang.Record
com.quantfinlib.alpha.AlphaBacktester.Config
Record Components:
startIndex - first decision bar (covers factor warm-up and, when capital > 0, more than impactWindow bars)
rebalanceEveryBars - bars between decisions
commissionBps - commission per side on traded notional
halfSpreadBps - half the quoted spread, paid per trade
slippageBps - fixed implementation shortfall per trade
capital - book size in currency at the start; impact and participation need real size (0 disables both)
impactWindow - trailing bars for ADV/vol estimation
periodsPerYear - bars per year for annualised metrics and financing
fillPolicy - when a decision fills (default NEXT_OPEN)
borrowBpsPerYear - annual borrow fee on short notional
cashRatePerYear - annual rate earned on positive cash (fraction, 0.03 = 3%)
marginRatePerYear - annual rate paid on negative cash
maxParticipation - max fraction of ADV traded per name per bar (0 = no cap)
Enclosing class:
AlphaBacktester

public static record AlphaBacktester.Config(int startIndex, int rebalanceEveryBars, double commissionBps, double halfSpreadBps, double slippageBps, double capital, int impactWindow, int periodsPerYear, FillPolicy fillPolicy, double borrowBpsPerYear, double cashRatePerYear, double marginRatePerYear, double maxParticipation) extends Record
Backtest settings: decision schedule, costs and capital.
  • Constructor Details

    • Config

      public Config(int startIndex, int rebalanceEveryBars, double commissionBps, double halfSpreadBps, double slippageBps, double capital, int impactWindow, int periodsPerYear, FillPolicy fillPolicy, double borrowBpsPerYear, double cashRatePerYear, double marginRatePerYear, double maxParticipation)
      Creates an instance of a Config record class.
      Parameters:
      startIndex - the value for the startIndex record component
      rebalanceEveryBars - the value for the rebalanceEveryBars record component
      commissionBps - the value for the commissionBps record component
      halfSpreadBps - the value for the halfSpreadBps record component
      slippageBps - the value for the slippageBps record component
      capital - the value for the capital record component
      impactWindow - the value for the impactWindow record component
      periodsPerYear - the value for the periodsPerYear record component
      fillPolicy - the value for the fillPolicy record component
      borrowBpsPerYear - the value for the borrowBpsPerYear record component
      cashRatePerYear - the value for the cashRatePerYear record component
      marginRatePerYear - the value for the marginRatePerYear record component
      maxParticipation - the value for the maxParticipation record component
    • Config

      public Config(int startIndex, int rebalanceEveryBars, double commissionBps, double halfSpreadBps, double slippageBps, double capital, int impactWindow, int periodsPerYear)
      No financing, no participation cap, next-open fills.
  • Method Details

    • defaults

      public static AlphaBacktester.Config defaults(int startIndex)
      Daily-bar defaults: monthly (21-bar) rebalance, 1 bp commission, 2 bp half-spread, 1 bp slippage, $100m book, 20-bar impact window, next-open fills, no financing, no participation cap.
    • withFillPolicy

      public AlphaBacktester.Config withFillPolicy(FillPolicy policy)
    • withFinancing

      public AlphaBacktester.Config withFinancing(double borrowBps, double cashRate, double marginRate)
      Annual borrow fee (bps of short notional), cash rate and margin rate.
    • withMaxParticipation

      public AlphaBacktester.Config withMaxParticipation(double fractionOfAdv)
    • withRebalanceEvery

      public AlphaBacktester.Config withRebalanceEvery(int bars)
    • frictionless

      public AlphaBacktester.Config frictionless()
      The same config with every cost, financing rate and the cap set to zero.
    • 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. Reference components are compared with Objects::equals(Object,Object); primitive components 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.
    • startIndex

      public int startIndex()
      Returns the value of the startIndex record component.
      Returns:
      the value of the startIndex record component
    • rebalanceEveryBars

      public int rebalanceEveryBars()
      Returns the value of the rebalanceEveryBars record component.
      Returns:
      the value of the rebalanceEveryBars record component
    • commissionBps

      public double commissionBps()
      Returns the value of the commissionBps record component.
      Returns:
      the value of the commissionBps record component
    • halfSpreadBps

      public double halfSpreadBps()
      Returns the value of the halfSpreadBps record component.
      Returns:
      the value of the halfSpreadBps record component
    • slippageBps

      public double slippageBps()
      Returns the value of the slippageBps record component.
      Returns:
      the value of the slippageBps record component
    • capital

      public double capital()
      Returns the value of the capital record component.
      Returns:
      the value of the capital record component
    • impactWindow

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

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

      public FillPolicy fillPolicy()
      Returns the value of the fillPolicy record component.
      Returns:
      the value of the fillPolicy record component
    • borrowBpsPerYear

      public double borrowBpsPerYear()
      Returns the value of the borrowBpsPerYear record component.
      Returns:
      the value of the borrowBpsPerYear record component
    • cashRatePerYear

      public double cashRatePerYear()
      Returns the value of the cashRatePerYear record component.
      Returns:
      the value of the cashRatePerYear record component
    • marginRatePerYear

      public double marginRatePerYear()
      Returns the value of the marginRatePerYear record component.
      Returns:
      the value of the marginRatePerYear record component
    • maxParticipation

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