dbn icon indicating copy to clipboard operation
dbn copied to clipboard

serde StatusAction, StatusReason and TradingEvent

Open victorstewart opened this issue 5 months ago • 3 comments

can you add Serialize and Deserialize for StatusAction, StatusReason and TradingEvent? i have to write some indirections to achieve this right now.

victorstewart avatar Jul 24 '25 12:07 victorstewart

what are you trying to achieve with (de)serializing those enums? Are you serializing to a format other than CSV or JSON?

threecgreen avatar Jul 29 '25 17:07 threecgreen

i create this instruments multi map in Rust to store every asset my code touches and status updates and tick updates. i serialize/deserialize it to/from disk because it's not massive and would be a nuisance to unfurl everything into a database schema.

so instead of creating copycats of these and other enums dbn defines, i just include them directly.

i already ended up using a solution like this...

#[derive(Serialize, Deserialize)]
#[serde(remote = "dbn::StatusAction")]
#[repr(u16)]                    
pub enum StatusActionDef
{
   None                     = 0,
   PreOpen                  = 1,
   PreCross                 = 2,
   Quoting                  = 3,
   Cross                    = 4,
   Rotation                 = 5,
   NewPriceIndication       = 6,
   Trading                  = 7,
   Halt                     = 8,
   Pause                    = 9,
   Suspend                  = 10,
   PreClose                 = 11,
   Close                    = 12,
   PostClose                = 13,
   SsrChange                = 14,
   NotAvailableForTrading   = 15
}

#[serde(with = "StatusActionDef")]
   pub action:        dbn::StatusAction,

but would be nice to not hardcore / reproduce them.

victorstewart avatar Jul 29 '25 17:07 victorstewart

and you don't want to write to disk as DBN?

Currently only enums with string conversion have Serialize and Deserialize implemented, though it would be straightforward to add string conversion for the enums you listed.

threecgreen avatar Jul 29 '25 18:07 threecgreen