Record Class Backtester.State

java.lang.Object
java.lang.Record
com.quantfinlib.backtest.Backtester.State
Record Components:
cash - cash held
quantity - shares held (0 = flat)
entryPrice - fill price of the open position (stops key off it)
entryCost - cash committed at entry
entryIndex - absolute bar index of the entry
entryTime - timestamp of the entry bar
pending - signal decided on the last bar and not yet filled
Enclosing class:
Backtester

public static record Backtester.State(double cash, double quantity, double entryPrice, double entryCost, int entryIndex, long entryTime, Signal pending) extends Record
Book state carried between segments.
  • Constructor Summary

    Constructors
    Constructor
    Description
    State(double cash, double quantity, double entryPrice, double entryCost, int entryIndex, long entryTime, Signal pending)
    Creates an instance of a State record class.
  • Method Summary

    Modifier and Type
    Method
    Description
    double
    Returns the value of the cash record component.
    double
    Returns the value of the entryCost record component.
    int
    Returns the value of the entryIndex record component.
    double
    Returns the value of the entryPrice record component.
    long
    Returns the value of the entryTime record component.
    final boolean
    Indicates whether some other object is "equal to" this one.
    flat(double capital)
    Flat book with capital in cash.
    final int
    Returns a hash code value for this object.
    Returns the value of the pending record component.
    double
    Returns the value of the quantity record component.
    final String
    Returns a string representation of this record class.

    Methods inherited from class Object

    clone, finalize, getClass, notify, notifyAll, wait, wait, wait
  • Constructor Details

    • State

      public State(double cash, double quantity, double entryPrice, double entryCost, int entryIndex, long entryTime, Signal pending)
      Creates an instance of a State record class.
      Parameters:
      cash - the value for the cash record component
      quantity - the value for the quantity record component
      entryPrice - the value for the entryPrice record component
      entryCost - the value for the entryCost record component
      entryIndex - the value for the entryIndex record component
      entryTime - the value for the entryTime record component
      pending - the value for the pending record component
  • Method Details

    • flat

      public static Backtester.State flat(double capital)
      Flat book with capital in cash.
    • 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.
    • cash

      public double cash()
      Returns the value of the cash record component.
      Returns:
      the value of the cash record component
    • quantity

      public double quantity()
      Returns the value of the quantity record component.
      Returns:
      the value of the quantity record component
    • entryPrice

      public double entryPrice()
      Returns the value of the entryPrice record component.
      Returns:
      the value of the entryPrice record component
    • entryCost

      public double entryCost()
      Returns the value of the entryCost record component.
      Returns:
      the value of the entryCost record component
    • entryIndex

      public int entryIndex()
      Returns the value of the entryIndex record component.
      Returns:
      the value of the entryIndex record component
    • entryTime

      public long entryTime()
      Returns the value of the entryTime record component.
      Returns:
      the value of the entryTime record component
    • pending

      public Signal pending()
      Returns the value of the pending record component.
      Returns:
      the value of the pending record component