Skip to main content

register_custom_data_class

Function register_custom_data_class 

Source
pub fn register_custom_data_class(data_class: &Bound<'_, PyAny>) -> PyResult<()>
Expand description

Registers a custom data type (class) with the catalog registry.

Use this when you prefer to pass the class instead of a sample instance. The class must have:

  • type_name_static() class method or __name__ (used as type name in storage)
  • decode_record_batch_py(metadata, ipc_bytes) class method
  • Instances must have ts_event, ts_init and encode_record_batch_py(items).

§Arguments

  • data_class - The custom data class (e.g. MarketTickPython or module.MarketTickData)

§Errors

Returns a PyErr if the class lacks required methods or the type is already registered.

§Example

from nautilus_trader.model.custom import customdataclass_pyo3
from nautilus_trader.model import register_custom_data_class

@customdataclass_pyo3()
class MarketTickPython:
    symbol: str = ""
    price: float = 0.0
    volume: int = 0

register_custom_data_class(MarketTickPython)