Record Class BacktestConfig
java.lang.Object
java.lang.Record
com.quantfinlib.backtest.BacktestConfig
- Record Components:
fillPolicy- when a signal decided at a bar's close fills (defaultFillPolicy.NEXT_OPEN)
public record BacktestConfig(double initialCapital, double commissionRate, double slippageRate, double stopLossPct, double takeProfitPct, int periodsPerYear, FillPolicy fillPolicy)
extends Record
Backtest execution parameters. Rates are fractions (0.001 = 10 bps).
slippageRate is applied to the fill price against the trader
(buys fill higher, sells lower) and stands for half-spread plus
implementation shortfall; commissionRate is charged on notional.
stopLossPct/takeProfitPct of 0 disable the respective
check; a strategy's own stop/take-profit settings override zeros here.-
Constructor Summary
ConstructorsConstructorDescriptionBacktestConfig(double initialCapital, double commissionRate, double slippageRate, double stopLossPct, double takeProfitPct, int periodsPerYear) Next-open fills.BacktestConfig(double initialCapital, double commissionRate, double slippageRate, double stopLossPct, double takeProfitPct, int periodsPerYear, FillPolicy fillPolicy) Creates an instance of aBacktestConfigrecord class. -
Method Summary
Modifier and TypeMethodDescriptiondoubleReturns the value of thecommissionRaterecord component.static BacktestConfigdefaults()Daily-bar defaults matchingTradeCostModel.institutional(1, 2, 1, …)without impact: 1 bp commission, 3 bp slippage (2 bp half-spread plus 1 bp shortfall), next-open fills, 100,000 capital.final booleanIndicates whether some other object is "equal to" this one.Returns the value of thefillPolicyrecord component.static BacktestConfigNo commission, no slippage, next-open fills: for unit tests and attribution of costs.final inthashCode()Returns a hash code value for this object.doubleReturns the value of theinitialCapitalrecord component.intReturns the value of theperiodsPerYearrecord component.doubleReturns the value of theslippageRaterecord component.doubleReturns the value of thestopLossPctrecord component.doubleReturns the value of thetakeProfitPctrecord component.final StringtoString()Returns a string representation of this record class.withCommission(double rate) withFillPolicy(FillPolicy policy) withInitialCapital(double capital) withSlippage(double rate) withStopLoss(double pct) withTakeProfit(double pct)
-
Constructor Details
-
BacktestConfig
public BacktestConfig(double initialCapital, double commissionRate, double slippageRate, double stopLossPct, double takeProfitPct, int periodsPerYear, FillPolicy fillPolicy) Creates an instance of aBacktestConfigrecord class.- Parameters:
initialCapital- the value for theinitialCapitalrecord componentcommissionRate- the value for thecommissionRaterecord componentslippageRate- the value for theslippageRaterecord componentstopLossPct- the value for thestopLossPctrecord componenttakeProfitPct- the value for thetakeProfitPctrecord componentperiodsPerYear- the value for theperiodsPerYearrecord componentfillPolicy- the value for thefillPolicyrecord component
-
BacktestConfig
public BacktestConfig(double initialCapital, double commissionRate, double slippageRate, double stopLossPct, double takeProfitPct, int periodsPerYear) Next-open fills.
-
-
Method Details
-
defaults
Daily-bar defaults matchingTradeCostModel.institutional(1, 2, 1, …)without impact: 1 bp commission, 3 bp slippage (2 bp half-spread plus 1 bp shortfall), next-open fills, 100,000 capital. -
frictionless
No commission, no slippage, next-open fills: for unit tests and attribution of costs. -
withInitialCapital
-
withCommission
-
withSlippage
-
withStopLoss
-
withTakeProfit
-
withFillPolicy
-
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. -
initialCapital
public double initialCapital()Returns the value of theinitialCapitalrecord component.- Returns:
- the value of the
initialCapitalrecord component
-
commissionRate
public double commissionRate()Returns the value of thecommissionRaterecord component.- Returns:
- the value of the
commissionRaterecord component
-
slippageRate
public double slippageRate()Returns the value of theslippageRaterecord component.- Returns:
- the value of the
slippageRaterecord component
-
stopLossPct
public double stopLossPct()Returns the value of thestopLossPctrecord component.- Returns:
- the value of the
stopLossPctrecord component
-
takeProfitPct
public double takeProfitPct()Returns the value of thetakeProfitPctrecord component.- Returns:
- the value of the
takeProfitPctrecord 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
-