nautechsystems / nautilus_trader

A high-performance algorithmic trading platform and event-driven backtester
https://nautilustrader.io
GNU Lesser General Public License v3.0
1.71k stars 402 forks source link

Deserialize bool to u8 in Rust order events #1641

Closed filipmacek closed 1 month ago

filipmacek commented 1 month ago

Pull Request

Because of the Rust migration, some of these Rust structs have bool fields set as u8 to be compatible with C representation of boolean with FFI. This can also happen pretty often in Cython <-> Rust conversion that is being done in Postgres adapter. This poses some problems in deserialization from dicts or strings to these native Rust types. One way to handle this discrepancy is to create a custom deserializer that will convert bools to u8 We also have to take into account that we can receive bool and normal integer