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 thanimpactWindowbars)rebalanceEveryBars- bars between decisionscommissionBps- commission per side on traded notionalhalfSpreadBps- half the quoted spread, paid per tradeslippageBps- fixed implementation shortfall per tradecapital- book size in currency at the start; impact and participation need real size (0 disables both)impactWindow- trailing bars for ADV/vol estimationperiodsPerYear- bars per year for annualised metrics and financingfillPolicy- when a decision fills (defaultNEXT_OPEN)borrowBpsPerYear- annual borrow fee on short notionalcashRatePerYear- annual rate earned on positive cash (fraction, 0.03 = 3%)marginRatePerYear- annual rate paid on negative cashmaxParticipation- 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 Summary
ConstructorsConstructorDescriptionConfig(int startIndex, int rebalanceEveryBars, double commissionBps, double halfSpreadBps, double slippageBps, double capital, int impactWindow, int periodsPerYear) No financing, no participation cap, next-open fills.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 aConfigrecord class. -
Method Summary
Modifier and TypeMethodDescriptiondoubleReturns the value of theborrowBpsPerYearrecord component.doublecapital()Returns the value of thecapitalrecord component.doubleReturns the value of thecashRatePerYearrecord component.doubleReturns the value of thecommissionBpsrecord component.static AlphaBacktester.Configdefaults(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.final booleanIndicates whether some other object is "equal to" this one.Returns the value of thefillPolicyrecord component.The same config with every cost, financing rate and the cap set to zero.doubleReturns the value of thehalfSpreadBpsrecord component.final inthashCode()Returns a hash code value for this object.intReturns the value of theimpactWindowrecord component.doubleReturns the value of themarginRatePerYearrecord component.doubleReturns the value of themaxParticipationrecord component.intReturns the value of theperiodsPerYearrecord component.intReturns the value of therebalanceEveryBarsrecord component.doubleReturns the value of theslippageBpsrecord component.intReturns the value of thestartIndexrecord component.final StringtoString()Returns a string representation of this record class.withFillPolicy(FillPolicy policy) withFinancing(double borrowBps, double cashRate, double marginRate) Annual borrow fee (bps of short notional), cash rate and margin rate.withMaxParticipation(double fractionOfAdv) withRebalanceEvery(int bars)
-
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 aConfigrecord class.- Parameters:
startIndex- the value for thestartIndexrecord componentrebalanceEveryBars- the value for therebalanceEveryBarsrecord componentcommissionBps- the value for thecommissionBpsrecord componenthalfSpreadBps- the value for thehalfSpreadBpsrecord componentslippageBps- the value for theslippageBpsrecord componentcapital- the value for thecapitalrecord componentimpactWindow- the value for theimpactWindowrecord componentperiodsPerYear- the value for theperiodsPerYearrecord componentfillPolicy- the value for thefillPolicyrecord componentborrowBpsPerYear- the value for theborrowBpsPerYearrecord componentcashRatePerYear- the value for thecashRatePerYearrecord componentmarginRatePerYear- the value for themarginRatePerYearrecord componentmaxParticipation- the value for themaxParticipationrecord 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
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
-
withFinancing
Annual borrow fee (bps of short notional), cash rate and margin rate. -
withMaxParticipation
-
withRebalanceEvery
-
frictionless
The same config with every cost, financing rate and the cap set to zero. -
toString
-
hashCode
-
equals
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 withObjects::equals(Object,Object); primitive components are compared with thecomparemethod from their corresponding wrapper classes. -
startIndex
public int startIndex()Returns the value of thestartIndexrecord component.- Returns:
- the value of the
startIndexrecord component
-
rebalanceEveryBars
public int rebalanceEveryBars()Returns the value of therebalanceEveryBarsrecord component.- Returns:
- the value of the
rebalanceEveryBarsrecord component
-
commissionBps
public double commissionBps()Returns the value of thecommissionBpsrecord component.- Returns:
- the value of the
commissionBpsrecord component
-
halfSpreadBps
public double halfSpreadBps()Returns the value of thehalfSpreadBpsrecord component.- Returns:
- the value of the
halfSpreadBpsrecord component
-
slippageBps
public double slippageBps()Returns the value of theslippageBpsrecord component.- Returns:
- the value of the
slippageBpsrecord component
-
capital
-
impactWindow
public int impactWindow()Returns the value of theimpactWindowrecord component.- Returns:
- the value of the
impactWindowrecord component
-
periodsPerYear
public int periodsPerYear()Returns the value of theperiodsPerYearrecord component.- Returns:
- the value of the
periodsPerYearrecord component
-
fillPolicy
Returns the value of thefillPolicyrecord component.- Returns:
- the value of the
fillPolicyrecord component
-
borrowBpsPerYear
public double borrowBpsPerYear()Returns the value of theborrowBpsPerYearrecord component.- Returns:
- the value of the
borrowBpsPerYearrecord component
-
cashRatePerYear
public double cashRatePerYear()Returns the value of thecashRatePerYearrecord component.- Returns:
- the value of the
cashRatePerYearrecord component
-
marginRatePerYear
public double marginRatePerYear()Returns the value of themarginRatePerYearrecord component.- Returns:
- the value of the
marginRatePerYearrecord component
-
maxParticipation
public double maxParticipation()Returns the value of themaxParticipationrecord component.- Returns:
- the value of the
maxParticipationrecord component
-