core.instruments¶
Tick size, tick value and contract specifications — the numbers that convert a price move into dollars.
instruments
¶
Instrument specifications: tick economics, venue, session class, cap weight.
The runtime source of truth for tick size/value is the SDK ContractModel;
the built-in SPECS table is the offline reference (and consistency check)
for the products commonly traded on Topstep. point_value is always derived
as tick_value / tick_size and the triple is asserted consistent on load.
Position caps count micro-units: a mini counts 10, a micro counts 1 (Topstep's 10:1 ratio), so cap math is pure integer arithmetic.
SPECS
module-attribute
¶
SPECS: dict[str, InstrumentSpec] = {sym: _spec(sym, venue, sess, tick, value, micro=micro, expect_point=point) for sym, venue, sess, tick, value, micro, point in _TABLE}
Venue
¶
Bases: StrEnum
Exchange within CME Group (matters for calendars and fees).
SessionClass
¶
Bases: StrEnum
Asset-class RTH template (ET). Globex hours are shared by all.
InstrumentSpec
¶
Bases: Struct
Frozen per-product economics and session metadata.
cap_units is the product's weight toward Topstep's position cap in
micro-units (mini=10, micro=1).
symbol_of_contract_id
¶
Extract the product symbol from a gateway contract id.
"CON.F.US.MNQ.U26" -> "MNQ"; a bare symbol passes through unchanged.
Source code in src/topstep_backtest/core/instruments.py
spec_for_symbol
¶
spec_for_symbol(symbol: str) -> InstrumentSpec
spec_for_contract
¶
spec_for_contract(contract: ContractModel) -> InstrumentSpec
Build a spec from a live SDK ContractModel, validated against the table.
The contract's tick_size/tick_value are authoritative; if the symbol
is in SPECS the values must agree (a mismatch means the reference table
is stale and must be corrected — a silent override would corrupt P&L).