Skip to main content

Crate nautilus_persistence_macros

Crate nautilus_persistence_macros 

Source
Expand description

Procedural macros for Nautilus. Provides #[custom_data] for defining custom data types with generated boilerplate (constructor, HasTsInit, CustomDataTrait, optional Arrow, derives).

Attribute Macrosยง

custom_data
Expands a struct into a custom data type with generated impls: #[derive(Debug, Clone, Serialize, Deserialize, PartialEq)], constructor, HasTsInit, CustomDataTrait, ArrowSchemaProvider, EncodeToRecordBatch, DecodeDataFromRecordBatch unless no_arrow is set, CatalogPathPrefix, From/TryFrom for Data. Call nautilus_serialization::ensure_custom_data_registered::<T>() once per Arrow-enabled type, or nautilus_model::data::ensure_custom_data_json_registered::<T>() for no_arrow types. For Python, also call nautilus_model::data::register_rust_extractor::<T>() once per type. Requires fields to include ts_event and ts_init (e.g. nautilus_core::UnixNanos). Supported field types include InstrumentId, AccountId, Currency, BarType, Params, UnixNanos, f64, f32, bool, String, u64, i64, u32, i32, Vec<f64>, and Vec<u8>. Use #[custom_data_field(serde)] on a field to store any Serde serializable field as a Serde JSON-backed Arrow Utf8 column. Python access uses typed dict conversion when both K and V of HashMap<K, V> or IndexMap<K, V> are in the typed-element whitelist: InstrumentId, AccountId, Currency, BarType, Price, Quantity, Money, String, f64, f32, bool, u64, i64, u32, i32 (see is_typed_json_map_segment in custom.rs). All other Serde-backed fields use the generic JSON bridge and accept/return JSON-compatible Python values.