Record Class DatedFutureInstrument

java.lang.Object
java.lang.Record
com.wualabs.qtsurfer.engine.core.instrument.DatedFutureInstrument
Record Components:
base - base currency, e.g. "BTC"
quote - quote currency, e.g. "USDT"
settle - settlement currency — an asset code, never a compound token
expiry - delivery date, rendered into the symbol as yyMMdd
All Implemented Interfaces:
Instrument

public record DatedFutureInstrument(@NonNull String base, @NonNull String quote, @NonNull String settle, @NonNull LocalDate expiry) extends Record implements Instrument
A delivery contract that expires on a fixed date: BTC/USDT:USDT-240628.

This is the variant the rest of the model exists for. Two contracts on the same pair with different expiries trade at different prices on the same underlying, so they are different instruments — unequal, and distinct as map keys. Nothing else in the hierarchy can express that.

Prefer Instrument.of(String, String, String, java.time.LocalDate) over this constructor. Neither accepts a null or blank component: without an expiry this is a perpetual, and the caller has to say which one it means.

  • Constructor Details

    • DatedFutureInstrument

      public DatedFutureInstrument(@NonNull @NonNull String base, @NonNull @NonNull String quote, @NonNull @NonNull String settle, @NonNull @NonNull LocalDate expiry)
      Creates an instance of a DatedFutureInstrument record class.
      Parameters:
      base - the value for the base record component
      quote - the value for the quote record component
      settle - the value for the settle record component
      expiry - the value for the expiry record component
  • Method Details

    • isDerivative

      public boolean isDerivative()
      Description copied from interface: Instrument
      true for any contract settled in a currency — perpetual or dated.
      Specified by:
      isDerivative in interface Instrument
    • isDated

      public boolean isDated()
      Description copied from interface: Instrument
      true only for a delivery contract with a fixed expiry.
      Specified by:
      isDated in interface Instrument
    • symbol

      public String symbol()
      Description copied from interface: Instrument
      CCXT-style canonical string. Inverse of Instrument.parse(String).
      Specified by:
      symbol in interface Instrument
    • toString

      public 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 Objects::equals(Object,Object).
      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.
    • base

      @NonNull public @NonNull String base()
      Returns the value of the base record component.
      Specified by:
      base in interface Instrument
      Returns:
      the value of the base record component
    • quote

      @NonNull public @NonNull String quote()
      Returns the value of the quote record component.
      Specified by:
      quote in interface Instrument
      Returns:
      the value of the quote record component
    • settle

      @NonNull public @NonNull String settle()
      Returns the value of the settle record component.
      Returns:
      the value of the settle record component
    • expiry

      @NonNull public @NonNull LocalDate expiry()
      Returns the value of the expiry record component.
      Returns:
      the value of the expiry record component