Instruments¶
Naming Convention¶
There are two types of assets: SPOT and SWAP. SWAP is divided into PERP and FUTURE, and both PERP and FUTURE have LINEAR and INVERSE categories.
SPOT:
BTCUSDT.BINANCE- SWAP
- PERP
LINEAR:
BTCUSDT-PERP.BYBITINVERSE:
BTCUSD-PERP.BYBIT
- FUTURE
LINEAR:
BTCUSDT-241227.BYBITINVERSE:
BTCUSD-241227.BINANCE
Note
SWAP can be either FUTURE or PERP, depending on whether the character after - is PERP or a number. Eg: BTCUSD-241227.BINANCE is FUTURE while BTCUSDT-PERP.BYBIT is PERP. The difference between LINEAR and INVERSE is the determination of the asset. LINEAR is determined by quote asset, while INVERSE is the price of the base asset.
Bybit TradFi (MT5)¶
Bybit TradFi instruments also use the NexusTrader symbol.EXCHANGE format,
but the symbol prefix is derived from the MT5 broker symbol. Leading # or
. prefixes are stripped, and internal dots are replaced with underscores
before appending .BYBIT_TRADFI.
MT5 Symbol |
NexusTrader Symbol |
|---|---|
|
|
|
|
|
|
Use the NexusTrader symbol everywhere in strategy code, including subscriptions, order placement, and cache lookups:
self.subscribe_bookl1("XAUUSD_s.BYBIT_TRADFI")
position = self.cache.get_position("XAUUSD_s.BYBIT_TRADFI")
The raw MT5 symbol, such as XAUUSD.s, is only used internally by the MT5
connector.
Usage¶
from nexustrader.schema import InstrumentId
## create an instrument id
instrument_id = InstrumentId.from_str("BTCUSDT-PERP.BYBIT")
## is_spot
instrument_id.is_spot() # False
## is_swap
instrument_id.is_linear() # True
## is_future
instrument_id.is_inverse() # False