ワンクリックで
nt-model
Use when working with domain model types, instruments, identifiers, value types, enums, or currencies in NautilusTrader.
Codex または Claude でインストール この Prompt をコピーして Codex、Claude、または他のアシスタントに貼り付けると、Skill ページを確認してインストールできます。
メニュー
Use when working with domain model types, instruments, identifiers, value types, enums, or currencies in NautilusTrader.
Codex または Claude でインストール この Prompt をコピーして Codex、Claude、または他のアシスタントに貼り付けると、Skill ページを確認してインストールできます。
SOC 職業分類に基づく
Use when working with strategy logic, order execution, risk management, position/portfolio tracking, or exec algorithms in NautilusTrader.
Use when working with backtesting engine, fill models, matching engine, simulated exchange, or backtest configuration in NautilusTrader.
Use when working with market data pipelines, data storage, ParquetDataCatalog, serialization, or cache operations in NautilusTrader.
Use when working with live trading nodes, system boot, NautilusKernel, engine configuration, component lifecycle, or deployment in NautilusTrader.
Use when working with exchange or data provider adapters, HTTP/WebSocket clients, instrument providers, or venue integration in NautilusTrader.
Use when learning NautilusTrader from scratch or deepening understanding. Provides a structured curriculum from installation to building custom NT components in Python and Rust.
| name | nt-model |
| description | Use when working with domain model types, instruments, identifiers, value types, enums, or currencies in NautilusTrader. |
NautilusTrader domain model — instruments, identifiers, value types, enums, and currencies.
Python modules: model/identifiers, model/instruments/ (14 types), model/types/, model/objects, model/enums, model/tick_scheme/
Rust crates: nautilus_model (identifiers, instruments, types, enums)
Price, Quantity, Money, Currency typesSyntheticInstrument or custom tick schemesnt-signals (@customdataclass)nt-tradingnt-datant-adaptersfrom nautilus_trader.model.identifiers import InstrumentId, Venue, Symbol, TraderId, StrategyId
instrument_id = InstrumentId.from_str("ETHUSDT-PERP.BINANCE")
venue = Venue("BINANCE")
symbol = Symbol("ETHUSDT-PERP")
# Identifier components
instrument_id.venue # Venue("BINANCE")
instrument_id.symbol # Symbol("ETHUSDT-PERP")
from nautilus_trader.model.objects import Price, Quantity, Money, Currency
# Price with precision
price = Price.from_str("1850.50")
price = Price(1850.50, precision=2)
# Quantity with precision
qty = Quantity.from_str("1.5")
qty = Quantity(1.5, precision=1)
# Money
balance = Money(10_000, Currency.from_str("USD"))
balance = Money.from_str("10000 USD")
# Arithmetic
total = price * qty # Returns float
from nautilus_trader.model.instruments import CurrencyPair, Equity, CryptoPerpetual, FuturesContract
# Instruments are typically loaded from adapters or created for backtests
# Access via cache:
instrument = self.cache.instrument(instrument_id)
# Key properties:
instrument.id # InstrumentId
instrument.venue # Venue
instrument.base_currency # Currency (for pairs)
instrument.quote_currency # Currency
instrument.price_precision # int
instrument.size_precision # int
instrument.lot_size # Quantity
instrument.min_quantity # Quantity
instrument.max_quantity # Quantity
instrument.min_price # Price
instrument.max_price # Price
# Create quantity/price with correct precision:
qty = instrument.make_qty(1.5)
price = instrument.make_price(1850.50)
14 instrument types:
CurrencyPair — FX pairs (EUR/USD)Equity — stocksFuturesContract — dated futuresOptionContract — dated optionsCryptoPerpetual — perpetual swapsCryptoFuture — crypto dated futuresCryptoOption — crypto optionsCommodity — commoditiesIndex — indicesCFD — contracts for differenceBettingInstrument — betting marketsBinaryOption — binary optionsSyntheticInstrument — user-defined syntheticInstrument — base classfrom nautilus_trader.model.enums import (
OrderSide, # BUY, SELL
OrderType, # MARKET, LIMIT, STOP_MARKET, STOP_LIMIT, etc.
TimeInForce, # GTC, IOC, FOK, GTD, DAY
PositionSide, # LONG, SHORT, FLAT
OmsType, # HEDGING, NETTING
AccountType, # CASH, MARGIN
OrderStatus, # INITIALIZED, SUBMITTED, ACCEPTED, FILLED, CANCELED, etc.
BarAggregation, # TICK, SECOND, MINUTE, HOUR, DAY, etc.
PriceType, # BID, ASK, MID, LAST
BookType, # L1_MBP, L2_MBP, L3_MBO
)
from nautilus_trader.model.currencies import BTC, ETH, USD, USDT
# Or dynamically:
currency = Currency.from_str("USD")
from nautilus_trader.model.instruments import SyntheticInstrument
# Define a synthetic instrument from a formula combining other instruments
synthetic = SyntheticInstrument(
symbol=Symbol("SPREAD-1"),
price_precision=2,
components=[instrument_id_1, instrument_id_2],
formula="(component_0 - component_1)",
)
from nautilus_trader.model.tick_scheme import TickScheme
# Define custom tick schemes for instruments with non-uniform tick sizes
use nautilus_model::identifiers::{InstrumentId, Venue, Symbol};
use nautilus_model::instruments::CryptoPerpetual;
use nautilus_model::types::{Price, Quantity, Money};
use nautilus_model::enums::{OrderSide, OrderType};
All 14 instrument types are defined in Rust (crates/model/src/instruments/) and exposed to Python via PyO3. New instruments follow the same pattern:
use pyo3::prelude::*;
use nautilus_model::identifiers::InstrumentId;
use nautilus_model::types::{Price, Quantity, Currency};
#[pyclass]
pub struct MyInstrument {
id: InstrumentId,
price_precision: u8,
size_precision: u8,
// Custom fields
}
#[pymethods]
impl MyInstrument {
#[new]
fn new(id: InstrumentId, price_precision: u8, size_precision: u8) -> Self { ... }
#[getter]
fn id(&self) -> InstrumentId { self.id }
fn make_price(&self, value: f64) -> Price {
Price::new(value, self.price_precision)
}
fn make_qty(&self, value: f64) -> Quantity {
Quantity::new(value, self.size_precision)
}
}
Identifiers are lightweight string wrappers with Copy semantics:
use pyo3::prelude::*;
use nautilus_model::identifier::Ustr; // Interned string type
#[pyclass]
#[derive(Clone, Copy, Debug, Hash, PartialEq, Eq)]
pub struct MyIdentifier {
value: Ustr, // Interned for O(1) equality checks
}
#[pymethods]
impl MyIdentifier {
#[new]
fn new(value: &str) -> Self {
Self { value: Ustr::from(value) }
}
fn __repr__(&self) -> String { format!("MyIdentifier('{}')", self.value) }
fn __hash__(&self) -> u64 { ... }
}
Value types (Price, Quantity, Money) use fixed-point representation internally:
i64 backing with precision 0-9i128 backing (enable high-precision feature flag)Price::new(value, precision) or Price::from_raw(raw_value, precision)from_raw to preserve exact precision when passing between Rust and Python#[pyclass] and #[pymethods] for Python-visible typescrates/pyo3/src/lib.rsHash, PartialEq, Eq, CopyCopy semantics, implement Display for __repr__abort_on_panic(|| { ... })Ustr (interned strings) for identifiers — O(1) equality and hashingInstrumentId: "{symbol}.{venue}" (e.g., "ETHUSDT-PERP.BINANCE")Venue: uppercase alphanumeric (e.g., "BINANCE", "SIM")Symbol: venue-specific format (e.g., "ETHUSDT-PERP", "EUR/USD")TraderId: "{name}-{tag}" (e.g., "TRADER-001")StrategyId: "{name}-{tag}" (e.g., "EMACross-001")InstrumentProviderTestInstrumentProvider or loaded from cataloginstrument.make_qty() and instrument.make_price() for correct precisionPrice and Quantity carry precision metadatainstrument.make_qty(value) / instrument.make_price(value) helpersValue types convert automatically between Rust and Python via PyO3:
Price ↔ Python Price (transparent)Quantity ↔ Python Quantity (transparent)from_str() / to_string()references/concepts/ — instruments, value types, overviewreferences/api/model/ — identifiers, instruments, orders, position, events, objects, data, book, tick_scheme, index