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, batch)class method- Instances must have
ts_event,ts_init, andencode_record_batch_py(items).
To write the type to a catalog and query it back, the class must also supply the Arrow
schema its batches use, through a _schema class attribute or an arrow_schema_py()
class method. That schema must contain ts_init. Any ts_event or ts_init fields must use
timestamp("ns", tz="UTC"). The @customdataclass decorator generates both the schema
and the Arrow methods. Without a usable schema the class still registers for JSON use, and
write_custom_data raises rather than writing a file that cannot be queried.
§Arguments
data_class- The custom data class (e.g.MarketTickPythonormodule.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
from nautilus_trader.model import register_custom_data_class
@customdataclass()
class MarketTickPython:
symbol: str = ""
price: float = 0.0
volume: int = 0
register_custom_data_class(MarketTickPython)