Common

class BusMessage

Bases: object

Represents a bus message including a topic and serialized payload.

Control messages (such as CLOSE) that carry no typed payload use an empty [BusPayloadType::Custom].

encoding
payload
payload_type
topic
class Cache

Bases: object

Wrapper providing shared access to [Cache] from Python.

This wrapper holds an Rc<RefCell<Cache>> allowing actors to share the same cache instance. All methods delegate to the underlying cache.

account(account_id)
account_for_venue(venue)
account_id(venue)
add(key, value)
bar(bar_type, index=0)
bar_count(bar_type)
bar_types(aggregation_source, instrument_id=None, price_type=None)
bars(bar_type)
book_update_count(instrument_id)
client_id(client_order_id)
client_order_id(venue_order_id)
client_order_ids(venue=None, instrument_id=None, strategy_id=None, account_id=None)
client_order_ids_closed(venue=None, instrument_id=None, strategy_id=None, account_id=None)
client_order_ids_emulated(venue=None, instrument_id=None, strategy_id=None, account_id=None)
client_order_ids_inflight(venue=None, instrument_id=None, strategy_id=None, account_id=None)
client_order_ids_open(venue=None, instrument_id=None, strategy_id=None, account_id=None)
dispose()
exec_algorithm_ids()
exec_spawn_total_filled_qty(exec_spawn_id, active_only)
exec_spawn_total_leaves_qty(exec_spawn_id, active_only)
exec_spawn_total_quantity(exec_spawn_id, active_only)
funding_rate(instrument_id)
funding_rate_count(instrument_id)
funding_rates(instrument_id)
get(key)
get_mark_xrate(from_currency, to_currency)
get_xrate(venue, from_currency, to_currency, price_type)
has_bars(bar_type)
has_funding_rates(instrument_id)
has_index_prices(instrument_id)
has_instrument_statuses(instrument_id)
has_mark_prices(instrument_id)
has_order_book(instrument_id)
has_quote_ticks(instrument_id)
has_trade_ticks(instrument_id)
index_price(instrument_id)
index_price_count(instrument_id)
index_prices(instrument_id)
instrument(instrument_id)
instrument_ids(venue=None)
instrument_status(instrument_id)
instrument_status_count(instrument_id)
instrument_statuses(instrument_id)
instruments(venue=None)
is_order_closed(client_order_id)
is_order_emulated(client_order_id)
is_order_inflight(client_order_id)
is_order_open(client_order_id)
is_order_pending_cancel_local(client_order_id)
is_position_closed(position_id)
is_position_open(position_id)
mark_price(instrument_id)
mark_price_count(instrument_id)
mark_prices(instrument_id)
order(client_order_id)
order_book(instrument_id)
order_exists(client_order_id)
order_list(order_list_id)
order_list_exists(order_list_id)
order_lists(venue=None, instrument_id=None, strategy_id=None, account_id=None)
orders(venue=None, instrument_id=None, strategy_id=None, account_id=None, side=None)
orders_closed(venue=None, instrument_id=None, strategy_id=None, account_id=None, side=None)
orders_closed_count(venue=None, instrument_id=None, strategy_id=None, account_id=None, side=None)
orders_emulated(venue=None, instrument_id=None, strategy_id=None, account_id=None, side=None)
orders_emulated_count(venue=None, instrument_id=None, strategy_id=None, account_id=None, side=None)
orders_for_exec_algorithm(exec_algorithm_id, venue=None, instrument_id=None, strategy_id=None, account_id=None, side=None)
orders_for_exec_spawn(exec_spawn_id)
orders_for_position(position_id)
orders_inflight(venue=None, instrument_id=None, strategy_id=None, account_id=None, side=None)
orders_inflight_count(venue=None, instrument_id=None, strategy_id=None, account_id=None, side=None)
orders_open(venue=None, instrument_id=None, strategy_id=None, account_id=None, side=None)
orders_open_count(venue=None, instrument_id=None, strategy_id=None, account_id=None, side=None)
orders_total_count(venue=None, instrument_id=None, strategy_id=None, account_id=None, side=None)
own_order_book(instrument_id)
pool(instrument_id)
pool_profiler(instrument_id)
position(position_id)
position_closed_ids(venue=None, instrument_id=None, strategy_id=None, account_id=None)
position_exists(position_id)
position_for_order(client_order_id)
position_id(client_order_id)
position_ids(venue=None, instrument_id=None, strategy_id=None, account_id=None)
position_open_ids(venue=None, instrument_id=None, strategy_id=None, account_id=None)
position_snapshot_bytes(position_id)
position_snapshots(position_id=None, account_id=None)
positions(venue=None, instrument_id=None, strategy_id=None, account_id=None, side=None)
positions_closed(venue=None, instrument_id=None, strategy_id=None, account_id=None, side=None)
positions_closed_count(venue=None, instrument_id=None, strategy_id=None, account_id=None, side=None)
positions_open(venue=None, instrument_id=None, strategy_id=None, account_id=None, side=None)
positions_open_count(venue=None, instrument_id=None, strategy_id=None, account_id=None, side=None)
positions_total_count(venue=None, instrument_id=None, strategy_id=None, account_id=None, side=None)
price(instrument_id, price_type)
purge_account_events(ts_now, lookback_secs=0)
purge_closed_orders(ts_now, buffer_secs=0)
purge_closed_positions(ts_now, buffer_secs=0)
purge_instrument(instrument_id)
purge_order(client_order_id)
purge_position(position_id)
quote(instrument_id, index=0)
quote_count(instrument_id)
quotes(instrument_id)
reset()
snapshot_position(position)
strategy_id_for_order(client_order_id)
strategy_id_for_position(position_id)
strategy_ids()
synthetic(instrument_id)
synthetic_ids()
trade(instrument_id, index=0)
trade_count(instrument_id)
trades(instrument_id)
venue_order_id(client_order_id)
class CacheConfig

Bases: object

Configuration for Cache instances.

bar_capacity
buffer_interval_ms
bulk_read_batch_size
drop_instruments_on_reset
encoding
flush_on_start
persist_account_events
save_market_data
tick_capacity
timestamps_as_iso8601
use_instance_id
use_trader_prefix
class Clock

Bases: object

Unified PyO3 interface over both [TestClock] and [LiveClock].

A PyClock instance owns a boxed trait object implementing [Clock]. It delegates method calls to this inner clock, allowing a single Python class to transparently wrap either implementation and eliminating the large amount of duplicated glue code previously required.

It intentionally does not expose a __new__ constructor to Python - clocks should be created from Rust and handed over to Python as needed.

cancel_callbacks()
cancel_default_handler()
cancel_timer(name)
cancel_timers()
static new_test()
next_time_ns(name)
register_default_handler(callback)
set_time(to_time_ns)
set_time_alert(name, alert_time, callback=None, allow_past=None)
set_time_alert_ns(name, alert_time_ns, callback=None, allow_past=None)
set_timer(name, interval, start_time=None, stop_time=None, callback=None, allow_past=None, fire_immediately=None)
set_timer_ns(name, interval_ns, start_time_ns=None, stop_time_ns=None, callback=None, allow_past=None, fire_immediately=None)
timer_count()

Returns the count of active timers in the clock.

timer_names()

Returns the names of active timers in the clock.

timestamp()

Returns the current UNIX timestamp in seconds.

timestamp_ms()

Returns the current UNIX timestamp in milliseconds (ms).

timestamp_ns()

Returns the current UNIX timestamp in nanoseconds (ns).

timestamp_us()

Returns the current UNIX timestamp in microseconds (μs).

utc_now()

Returns the current UTC timestamp.

class ComponentState

Bases: object

The state of a component within the system.

DEGRADED = ComponentState.DEGRADED
DEGRADING = ComponentState.DEGRADING
DISPOSED = ComponentState.DISPOSED
DISPOSING = ComponentState.DISPOSING
FAULTED = ComponentState.FAULTED
FAULTING = ComponentState.FAULTING
PRE_INITIALIZED = ComponentState.PRE_INITIALIZED
READY = ComponentState.READY
RESETTING = ComponentState.RESETTING
RESUMING = ComponentState.RESUMING
RUNNING = ComponentState.RUNNING
STARTING = ComponentState.STARTING
STOPPED = ComponentState.STOPPED
STOPPING = ComponentState.STOPPING
class ComponentTrigger

Bases: object

A trigger condition for a component within the system.

DEGRADE = ComponentTrigger.DEGRADE
DEGRADE_COMPLETED = ComponentTrigger.DEGRADE_COMPLETED
DISPOSE = ComponentTrigger.DISPOSE
DISPOSE_COMPLETED = ComponentTrigger.DISPOSE_COMPLETED
FAULT = ComponentTrigger.FAULT
FAULT_COMPLETED = ComponentTrigger.FAULT_COMPLETED
INITIALIZE = ComponentTrigger.INITIALIZE
RESET = ComponentTrigger.RESET
RESET_COMPLETED = ComponentTrigger.RESET_COMPLETED
RESUME = ComponentTrigger.RESUME
RESUME_COMPLETED = ComponentTrigger.RESUME_COMPLETED
START = ComponentTrigger.START
START_COMPLETED = ComponentTrigger.START_COMPLETED
STOP = ComponentTrigger.STOP
STOP_COMPLETED = ComponentTrigger.STOP_COMPLETED
class CustomData

Bases: object

Represents a custom data.

data_type
ts_event
ts_init
value
class DataActor

Bases: object

Python-facing wrapper for DataActor.

This wrapper holds shared ownership of PyDataActorInner via Rc<UnsafeCell<>>. Both Python (through this wrapper) and the global registries share the same underlying actor instance, ensuring mutations are visible from both sides.

actor_id
add_synthetic(synthetic)
cache
clock
config
degrade()
dispose()
fault()
indicators_initialized()
is_degraded()
is_disposed()
is_faulted()
is_ready()
is_running()
is_stopped()
load(state)
log
on_bar(bar)
on_block(block)
on_book(book)
on_book_deltas(deltas)
on_book_depth(depth)
on_data(data)
on_degrade()
on_dispose()
on_fault()
on_funding_rate(funding_rate)
on_historical_bars(bars)
on_historical_book_deltas(deltas)
on_historical_book_depth(depths)
on_historical_data(data)
on_historical_funding_rates(funding_rates)
on_historical_index_prices(index_prices)
on_historical_mark_prices(mark_prices)
on_historical_quotes(quotes)
on_historical_trades(trades)
on_index_price(index_price)
on_instrument(instrument)
on_instrument_close(close)
on_instrument_status(status)
on_load(state)
on_mark_price(mark_price)
on_option_chain(slice)
on_option_greeks(greeks)
on_pool(pool)
on_pool_fee_collect(update)
on_pool_flash(flash)
on_pool_liquidity_update(update)
on_pool_swap(swap)
on_queue_state(event)
on_quote(quote)
on_reset()
on_resume()
on_save()
on_signal(signal)
on_socket_state(event)
on_start()
on_stop()
on_time_event(event)
on_trade(trade)
publish_data(data_type, data)
publish_signal(name, value, ts_event=0)
reconnect_socket(client_id, endpoint)

Requests reconnect of one socket endpoint owned by client_id.

register_indicator_for_bars(bar_type, indicator)
register_indicator_for_quote_ticks(instrument_id, indicator)
register_indicator_for_trade_ticks(instrument_id, indicator)
registered_indicators
request_bars(bar_type, start=None, end=None, limit=None, client_id=None, params=None)
request_book_deltas(instrument_id, start=None, end=None, limit=None, client_id=None, params=None)
request_book_depth(instrument_id, start=None, end=None, limit=None, depth=None, client_id=None, params=None)
request_book_snapshot(instrument_id, depth=None, client_id=None, params=None)
request_data(data_type, client_id, start=None, end=None, limit=None, params=None)
request_funding_rates(instrument_id, start=None, end=None, limit=None, client_id=None, params=None)
request_instrument(instrument_id, start=None, end=None, client_id=None, params=None)
request_instruments(venue=None, start=None, end=None, client_id=None, params=None)
request_quotes(instrument_id, start=None, end=None, limit=None, client_id=None, params=None)
request_trades(instrument_id, start=None, end=None, limit=None, client_id=None, params=None)
reset()
resume()
save()
shutdown_system(reason=None)
start()
state()
stop()
subscribe_bars(bar_type, client_id=None, params=None)
subscribe_blocks(chain, client_id=None, params=None)
subscribe_book_at_interval(instrument_id, book_type, interval_ms, depth=None, client_id=None, params=None)
subscribe_book_deltas(instrument_id, book_type, depth=None, client_id=None, managed=False, params=None)
subscribe_book_depth10(instrument_id, book_type, client_id=None, managed=False, params=None)
subscribe_data(data_type, client_id=None, params=None)
subscribe_funding_rates(instrument_id, client_id=None, params=None)
subscribe_index_prices(instrument_id, client_id=None, params=None)
subscribe_instrument(instrument_id, client_id=None, params=None)
subscribe_instrument_close(instrument_id, client_id=None, params=None)
subscribe_instrument_status(instrument_id, client_id=None, params=None)
subscribe_instruments(venue, client_id=None, params=None)
subscribe_mark_prices(instrument_id, client_id=None, params=None)
subscribe_option_chain(series_id, strike_range, snapshot_interval_ms=None, client_id=None, params=None)
subscribe_option_greeks(instrument_id, client_id=None, params=None)
subscribe_pool(instrument_id, client_id=None, params=None)
subscribe_pool_fee_collects(instrument_id, client_id=None, params=None)
subscribe_pool_flash_events(instrument_id, client_id=None, params=None)
subscribe_pool_liquidity_updates(instrument_id, client_id=None, params=None)
subscribe_pool_swaps(instrument_id, client_id=None, params=None)
subscribe_queue_state(priority=None)
subscribe_quotes(instrument_id, client_id=None, params=None)
subscribe_signal(name='', priority=None)
subscribe_socket_state(priority=None)
subscribe_trades(instrument_id, client_id=None, params=None)
trader_id
unsubscribe_bars(bar_type, client_id=None, params=None)
unsubscribe_blocks(chain, client_id=None, params=None)
unsubscribe_book_at_interval(instrument_id, interval_ms, client_id=None, params=None)
unsubscribe_book_deltas(instrument_id, client_id=None, params=None)
unsubscribe_book_depth10(instrument_id, client_id=None, params=None)
unsubscribe_data(data_type, client_id=None, params=None)
unsubscribe_funding_rates(instrument_id, client_id=None, params=None)
unsubscribe_index_prices(instrument_id, client_id=None, params=None)
unsubscribe_instrument(instrument_id, client_id=None, params=None)
unsubscribe_instrument_close(instrument_id, client_id=None, params=None)
unsubscribe_instrument_status(instrument_id, client_id=None, params=None)
unsubscribe_instruments(venue, client_id=None, params=None)
unsubscribe_mark_prices(instrument_id, client_id=None, params=None)
unsubscribe_option_chain(series_id, client_id=None)
unsubscribe_option_greeks(instrument_id, client_id=None, params=None)
unsubscribe_pool(instrument_id, client_id=None, params=None)
unsubscribe_pool_fee_collects(instrument_id, client_id=None, params=None)
unsubscribe_pool_flash_events(instrument_id, client_id=None, params=None)
unsubscribe_pool_liquidity_updates(instrument_id, client_id=None, params=None)
unsubscribe_pool_swaps(instrument_id, client_id=None, params=None)
unsubscribe_queue_state()
unsubscribe_quotes(instrument_id, client_id=None, params=None)
unsubscribe_signal(name='')
unsubscribe_socket_state()
unsubscribe_trades(instrument_id, client_id=None, params=None)
update_synthetic(synthetic)
class DataActorConfig

Bases: object

Common configuration for [DataActor] based components.

actor_id
log_commands
log_events
class Environment

Bases: object

Represents the environment context for a Nautilus system.

BACKTEST = Environment.BACKTEST
LIVE = Environment.LIVE
SANDBOX = Environment.SANDBOX
classmethod from_str(data)
name
value
classmethod variants()
class FifoCache

Bases: object

add(key)
capacity
clear()
remove(key)
class FileWriterConfig

Bases: object

directory
file_format
file_name
file_rotate
class GreeksCalculator

Bases: object

cache_futures_spread(call_instrument_id, put_instrument_id, futures_instrument_id)
get_cached_futures_spread_price(underlying_instrument_id)
instrument_greeks(instrument_id, flat_interest_rate=0.0425, flat_dividend_yield=None, spot_shock=0.0, vol_shock=0.0, time_to_expiry_shock=0.0, use_cached_greeks=False, update_vol=False, cache_greeks=False, ts_event=0, position=None, percent_greeks=False, index_instrument_id=None, beta_weights=None, vega_time_weight_base=None, vol_index_instrument_id=None, vol_beta_weights=None)
modify_greeks(delta_input, gamma_input, underlying_instrument_id, underlying_price, unshocked_underlying_price, percent_greeks, index_instrument_id=None, beta_weights=None, vega_input=0.0, vol=0.0, expiry_in_days=0, vega_time_weight_base=None, unshocked_vol=0.0, vol_index_instrument_id=None, vol_beta_weights=None, index_price=None, vol_index_price=None)
portfolio_greeks(underlyings=None, venue=None, instrument_id=None, strategy_id=None, side=None, flat_interest_rate=0.0425, flat_dividend_yield=None, spot_shock=0.0, vol_shock=0.0, time_to_expiry_shock=0.0, use_cached_greeks=False, update_vol=False, cache_greeks=False, percent_greeks=False, index_instrument_id=None, beta_weights=None, greeks_filter=None, vega_time_weight_base=None, vol_index_instrument_id=None, vol_beta_weights=None)
class ImportableActorConfig

Bases: object

Configuration for creating actors from importable paths.

actor_path
config
config_path
class LogColor

Bases: object

The log color for log messages.

BLUE = LogColor.BLUE
CYAN = LogColor.CYAN
GREEN = LogColor.GREEN
MAGENTA = LogColor.MAGENTA
NORMAL = LogColor.NORMAL
RED = LogColor.RED
YELLOW = LogColor.YELLOW
classmethod from_str(data)
name
value
classmethod variants()
class LogFormat

Bases: object

An ANSI log line format specifier. This is used for formatting log messages with ANSI escape codes.

BOLD = LogFormat.BOLD
ENDC = LogFormat.ENDC
HEADER = LogFormat.HEADER
UNDERLINE = LogFormat.UNDERLINE
class LogGuard

Bases: object

A guard that manages the lifecycle of the logging subsystem.

LogGuard tracks active users of the process-global logging subsystem. Dropping the last guard synchronously flushes and syncs pending file logs, but leaves the logging thread running so a later initialization can acquire a valid guard. Only [crate::logging::logging_shutdown] permanently terminates the logging thread.

# Reference Counting

The logging system maintains a global atomic counter of active LogGuard instances. This ensures that: - The logging thread remains active for the process lifetime, including while no guards exist. - Pending log messages are flushed when intermediate guards are dropped. - Pending file logs are synchronously flushed and synced when the last guard is dropped.

# Shutdown Behavior

Call [crate::logging::logging_shutdown] for terminal shutdown. After shutdown, no new guards can be acquired and the logger cannot be re-initialized.

Python on Windows: Non-deterministic GC order during interpreter shutdown can occasionally prevent proper thread join, resulting in truncated logs.

# Limits

The system supports a maximum of 255 concurrent LogGuard instances.

class LogLevel

Bases: object

The log level for log messages.

DEBUG = LogLevel.DEBUG
ERROR = LogLevel.ERROR
INFO = LogLevel.INFO
OFF = LogLevel.OFF
TRACE = LogLevel.TRACE
WARNING = LogLevel.WARNING
classmethod from_str(data)
name
value
classmethod variants()
class Logger

Bases: object

A thin wrapper around the global Rust logger which exposes ergonomic logging helpers for Python code.

It mirrors the familiar Python logging interface while forwarding all records through the Nautilus logging infrastructure so that log levels and formatting remain consistent across Rust and Python.

debug(message, color=None)

Emit a DEBUG level record.

error(message, color=None)

Emit an ERROR level record.

exception(message='', color=None)

Emit an ERROR level record with the active Python exception info.

flush()

Flush buffered log records.

info(message, color=None)

Emit an INFO level record.

name

The component identifier carried by this logger.

trace(message, color=None)

Emit a TRACE level record.

warning(message, color=None)

Emit a WARNING level record.

class LoggerConfig

Bases: object

Configuration for the Nautilus logger.

buffered_stdout
bypass_logging
clear_log_file
component_levels
file_config
fileout_level
fileout_sync_on_flush
static from_spec(spec)

Parses a configuration from a spec string.

# Format

Semicolon-separated key-value pairs or bare flags: `text stdout=Info;fileout=Debug;RiskEngine=Error;my_crate::module=Debug;is_colored `

# Errors

Returns an error if the spec string contains invalid syntax or log levels.

is_colored
log_components_only
print_config
stdout_level
class MessageBus

Bases: object

Python message bus backed by the Rust thread-local [MessageBus].

Publish, subscribe, and request/response calls from Python route through the single Rust bus. Python custom events travel through the Any-based dispatch path via [PyMessage] wrappers.

add_listener(listener)

Adds a listener to the message bus.

add_streaming_type(cls)

Registers a type for external-to-internal message streaming.

deregister(endpoint, handler=None)

Deregisters the handler from the given endpoint address.

dispose()

Disposes of the message bus, clearing all state.

endpoints()

Returns all registered endpoint addresses.

has_backing

Returns whether the message bus has an external backing.

has_subscribers(pattern=None)

Returns whether there are subscribers for the given topic pattern.

instance_id

Returns the instance ID associated with the message bus.

is_pending_request(request_id)

Returns whether the given request ID is pending a response.

is_streaming_type(cls)

Returns whether the given type is registered for streaming.

is_subscribed(topic, handler)

Returns whether the given topic and handler is subscribed.

name

Returns the name of the message bus.

pub_count

Returns the count of messages published.

publish(topic, msg, external_pub=True)

Publishes a message for the given topic.

register(endpoint, handler)

Registers a handler at the given endpoint address.

req_count

Returns the count of requests made.

request(endpoint, request)

Sends a request to the given endpoint with correlation tracking.

res_count

Returns the count of responses handled.

response(response)

Handles a response by invoking the correlated callback.

send(endpoint, msg)

Sends a message to the given endpoint address.

sent_count

Returns the count of messages sent via point-to-point.

streaming_types()

Returns all types registered for streaming.

subscribe(topic, handler, priority=0)

Subscribes to the given topic with the given handler.

subscriptions(pattern=None)

Returns subscriptions matching the given topic pattern.

topics()

Returns all topics with active subscribers.

trader_id

Returns the trader ID associated with the message bus.

unsubscribe(topic, handler)

Unsubscribes the given handler from the given topic.

class MessageBusConfig

Bases: object

Configuration for MessageBus instances.

autotrim_maxlen
autotrim_mins
buffer_interval_ms
encoding
encoding_builtin
encoding_market_data
external_streams
heartbeat_interval_secs
stream_per_topic
streams_prefix
timestamps_as_iso8601
types_filter
use_instance_id
use_trader_id
use_trader_prefix
class MessageBusListener

Bases: object

close()

Closes the listener.

is_active()
is_closed()

Returns whether the listener is closed.

publish(topic, payload)

Publishes a message with the given topic and payload.

stream(callback)

Streams messages arriving on the receiver channel.

class OrderFactory

Bases: object

Wrapper providing shared access to [OrderFactory] from Python.

bracket(instrument_id, order_side, quantity, quote_quantity=False, emulation_trigger=None, trigger_instrument_id=None, contingency_type=Ellipsis, entry_order_type=Ellipsis, entry_price=None, entry_trigger_price=None, expire_time=None, time_in_force=Ellipsis, entry_post_only=False, entry_exec_algorithm_id=None, entry_exec_algorithm_params=None, entry_tags=None, entry_client_order_id=None, tp_order_type=Ellipsis, tp_price=None, tp_trigger_price=None, tp_trigger_type=Ellipsis, tp_activation_price=None, tp_trailing_offset=None, tp_trailing_offset_type=Ellipsis, tp_limit_offset=None, tp_time_in_force=Ellipsis, tp_post_only=True, tp_exec_algorithm_id=None, tp_exec_algorithm_params=None, tp_tags=None, tp_client_order_id=None, sl_order_type=Ellipsis, sl_trigger_price=None, sl_trigger_type=Ellipsis, sl_activation_price=None, sl_trailing_offset=None, sl_trailing_offset_type=Ellipsis, sl_time_in_force=Ellipsis, sl_exec_algorithm_id=None, sl_exec_algorithm_params=None, sl_tags=None, sl_client_order_id=None)
generate_client_order_id()
generate_order_list_id()
get_client_order_id_count()
get_order_list_id_count()
limit(instrument_id, order_side, quantity, price, time_in_force=None, expire_time=None, post_only=None, reduce_only=None, quote_quantity=None, display_qty=None, emulation_trigger=None, trigger_instrument_id=None, exec_algorithm_id=None, exec_algorithm_params=None, tags=None, client_order_id=None)
limit_if_touched(instrument_id, order_side, quantity, price, trigger_price, trigger_type=None, time_in_force=None, expire_time=None, post_only=None, reduce_only=None, quote_quantity=None, display_qty=None, emulation_trigger=None, trigger_instrument_id=None, exec_algorithm_id=None, exec_algorithm_params=None, tags=None, client_order_id=None)
market(instrument_id, order_side, quantity, time_in_force=None, reduce_only=None, quote_quantity=None, exec_algorithm_id=None, exec_algorithm_params=None, tags=None, client_order_id=None)
market_if_touched(instrument_id, order_side, quantity, trigger_price, trigger_type=None, time_in_force=None, expire_time=None, reduce_only=None, quote_quantity=None, emulation_trigger=None, trigger_instrument_id=None, exec_algorithm_id=None, exec_algorithm_params=None, tags=None, client_order_id=None)
market_to_limit(instrument_id, order_side, quantity, time_in_force=None, expire_time=None, reduce_only=None, quote_quantity=None, display_qty=None, exec_algorithm_id=None, exec_algorithm_params=None, tags=None, client_order_id=None)
reset()
stop_limit(instrument_id, order_side, quantity, price, trigger_price, trigger_type=None, time_in_force=None, expire_time=None, post_only=None, reduce_only=None, quote_quantity=None, display_qty=None, emulation_trigger=None, trigger_instrument_id=None, exec_algorithm_id=None, exec_algorithm_params=None, tags=None, client_order_id=None)
stop_market(instrument_id, order_side, quantity, trigger_price, trigger_type=None, time_in_force=None, expire_time=None, reduce_only=None, quote_quantity=None, display_qty=None, emulation_trigger=None, trigger_instrument_id=None, exec_algorithm_id=None, exec_algorithm_params=None, tags=None, client_order_id=None)
strategy_id
trader_id
trailing_stop_limit(instrument_id, order_side, quantity, price, limit_offset, trailing_offset, trailing_offset_type=None, activation_price=None, trigger_price=None, trigger_type=None, time_in_force=None, expire_time=None, post_only=None, reduce_only=None, quote_quantity=None, display_qty=None, emulation_trigger=None, trigger_instrument_id=None, exec_algorithm_id=None, exec_algorithm_params=None, tags=None, client_order_id=None)
trailing_stop_market(instrument_id, order_side, quantity, trailing_offset, trailing_offset_type=None, activation_price=None, trigger_price=None, trigger_type=None, time_in_force=None, expire_time=None, reduce_only=None, quote_quantity=None, display_qty=None, emulation_trigger=None, trigger_instrument_id=None, exec_algorithm_id=None, exec_algorithm_params=None, tags=None, client_order_id=None)
class QueueCondition

Bases: object

Represents a runner queue pressure condition.

BACKLOGGED = QueueCondition.BACKLOGGED
SLOW = QueueCondition.SLOW
class QueueState

Bases: object

Represents the state of a runner queue pressure condition.

CLEARED = QueueState.CLEARED
TRIGGERED = QueueState.TRIGGERED
class QueueStateChanged

Bases: object

Represents an event where a runner queue pressure condition has changed.

channel
condition
event_id
mean_dispatch_ns
queue_depth
state
trader_id
ts_event
ts_init
class ReconnectSocket

Bases: object

Command requesting reconnect of one socket endpoint owned by one client.

client_id
endpoint
trader_id
ts_init
class SerializationEncoding

Bases: object

The serialization encoding.

CAPNP = SerializationEncoding.CAPNP
JSON = SerializationEncoding.JSON
MSG_PACK = SerializationEncoding.MSG_PACK
SBE = SerializationEncoding.SBE
class Signal

Bases: object

Represents a generic signal.

name
ts_event
ts_init
value
class SocketState

Bases: object

Represents the availability state of a socket transport.

CONNECTED = SocketState.CONNECTED
DISCONNECTED = SocketState.DISCONNECTED
class SocketStateChanged

Bases: object

Represents an event where a socket transport state has changed.

client_id
endpoint
event_id
state
trader_id
ts_event
ts_init
venue
class SystemChannel

Bases: object

A monitored message channel feeding the runner event loop.

Each variant identifies an engine-facing channel tracked by the queue monitor.

DATA_COMMANDS = SystemChannel.DATA_COMMANDS
DATA_EVENTS = SystemChannel.DATA_EVENTS
EXEC_COMMANDS = SystemChannel.EXEC_COMMANDS
EXEC_EVENTS = SystemChannel.EXEC_EVENTS
TIME_EVENTS = SystemChannel.TIME_EVENTS
class TimeEvent

Bases: object

Represents a time event occurring at the event timestamp.

A TimeEvent carries metadata such as the event’s name, a unique event ID, and timestamps indicating when the event was scheduled to occur and when it was initialized.

event_id
name
ts_event
ts_init
get_exchange_rate(from_currency, to_currency, price_type, quotes_bid, quotes_ask)

Calculates the exchange rate between two currencies using provided bid and ask quotes.

This function builds a graph of direct conversion rates from the quotes and uses a DFS to accumulate the conversion rate along a valid conversion path. While a full Floyd-Warshall algorithm could compute all-pairs conversion rates, the DFS approach here provides a quick solution for a single conversion query.

# Errors

For conversions between distinct currencies (an identical from_currency and to_currency returns a rate of one without inspecting the quotes), returns an error if: - quotes_bid or quotes_ask is empty. - quotes_bid and quotes_ask lengths are not equal. - price_type is equal to Last or Mark (cannot calculate from quotes). - The bid or ask side of a pair is missing.

init_logging(trader_id, instance_id, level_stdout, level_file=None, component_levels=None, directory=None, file_name=None, file_format=None, file_rotate=None, is_colored=None, is_bypassed=None, print_config=None, log_components_only=None, fileout_sync_on_flush=None, buffered_stdout=None)

Initialize logging.

Logging should be used for Python and sync Rust logic which is most of the components in the [nautilus_trader](https://pypi.org/project/nautilus_trader) package. Logging can be configured to filter components and write up to a specific level only by passing a configuration using the NAUTILUS_LOG environment variable.

Should only be called once during an applications run, ideally at the beginning of the run.

# Errors

Returns an error if the logging subsystem fails to initialize.

init_tracing()

Initializes a tracing subscriber for external Rust crate logging.

This sets up a standard tracing subscriber that outputs to stdout with the format controlled by RUST_LOG environment variable. The output format uses nanosecond timestamps to align with Nautilus logging.

# Environment Variables

  • RUST_LOG: Controls which modules emit tracing events and at what level. - Example: RUST_LOG=hyper=debug,tokio=warn. - Default: warn (if not set).

# Errors

Returns an error if the tracing subscriber has already been initialized.

log_header(trader_id, machine_id, instance_id, component)

Logs the standard Nautilus system header.

log_sysinfo(component)

Logs system information.

logger_flush()
logger_log(level, color, component, message)

Create a new log event.

logging_clock_set_realtime_mode()

Sets the global logging clock to real-time mode.

logging_clock_set_static_mode()

Sets the global logging clock to static mode.

logging_clock_set_static_time(time_ns)

Sets the global logging clock static time with the given UNIX timestamp (nanoseconds).

logging_sync_to_disk()

Flushes and syncs file logs to disk.

This is a no-op when logging is not initialized or file logging is disabled.

# Errors

Returns an error if the sync request cannot be delivered or acknowledged.

tracing_is_initialized()

Returns whether the tracing subscriber has been initialized.