Interface Instrument
- All Known Implementing Classes:
DatedFutureInstrument, PerpetualInstrument, SpotInstrument
Three market kinds, one per implementation:
SpotInstrument—BTC/USDTPerpetualInstrument—BTC/USDT:USDT(USDT-margined),BTC/USD:BTC(coin-margined)DatedFutureInstrument—BTC/USDT:USDT-240628, a delivery contract with a fixed expiry
The distinction matters for identity, not just display: two delivery contracts on the same pair with different expiries trade at different prices, so they must be unequal and usable as distinct map keys. A single record with an optional expiry field would also permit a spot instrument carrying one; this hierarchy makes that unrepresentable.
Construct through of(String, String) rather than the record constructors. Each overload names exactly
one variant and accepts no absent component: no null, no blank string. A call site holding
an optional settlement currency must therefore decide for itself what it means — the factory will
not quietly turn a missing component into a simpler market kind, because that is how a derivative
ends up recorded as spot.
symbol() is a persisted and transported format, not a display convenience: it is the
QuestDB ins column, part of the NATS subject grammar, and the identity used by the cache
and the signal stores. parse(String) is its exact inverse. Note that settle() is
deliberately absent from this interface — it exists only on the variants that have one, so code
composing a wire format out of an instrument's parts cannot silently omit the expiry.
Engine-owned, with no XChange dependency. XChange's own instrument types are confined to the
exchange-adapter / order-execution boundary, where XChangeConvert
(qtsurfer-engine-exchange) bridges the two.
-
Method Summary
Modifier and TypeMethodDescriptionbase()Base currency, e.g.default booleanisDated()trueonly for a delivery contract with a fixed expiry.default booleantruefor any contract settled in a currency — perpetual or dated.static SpotInstrumentA spot instrument.static PerpetualInstrumentA perpetual contract.static DatedFutureInstrumentA dated delivery contract.static InstrumentParses a CCXT symbol back into the variant it denotes.quote()Quote currency, e.g.symbol()CCXT-style canonical string.
-
Method Details
-
base
String base()Base currency, e.g."BTC". -
quote
String quote()Quote currency, e.g."USDT". -
symbol
String symbol()CCXT-style canonical string. Inverse ofparse(String). -
isDerivative
default boolean isDerivative()truefor any contract settled in a currency — perpetual or dated. -
isDated
default boolean isDated()trueonly for a delivery contract with a fixed expiry. -
of
A spot instrument.- Throws:
NullPointerException- if any argument isnullIllegalArgumentException- if any currency code is blank
-
of
A perpetual contract.- Throws:
NullPointerException- if any argument isnullIllegalArgumentException- if any currency code is blank
-
of
A dated delivery contract.- Throws:
NullPointerException- if any argument isnullIllegalArgumentException- if any currency code is blank
-
parse
Parses a CCXT symbol back into the variant it denotes.The dated form is recognised only when the tail after the settlement currency is a hyphen followed by exactly six digits forming a valid date. Anything else stays part of the settlement currency, so every symbol written by an earlier release parses to what it parsed to before.
-