@@ -62,7 +62,10 @@ pub struct OKXCandlestick(
6262) ;
6363
6464use crate :: common:: {
65- enums:: { OKXExecType , OKXInstrumentType , OKXMarginMode , OKXPositionSide , OKXSide } ,
65+ enums:: {
66+ OKXAlgoOrderType , OKXExecType , OKXInstrumentType , OKXMarginMode , OKXOrderStatus ,
67+ OKXOrderType , OKXPositionSide , OKXSide , OKXTradeMode , OKXTriggerType ,
68+ } ,
6669 parse:: deserialize_string_to_u64,
6770} ;
6871
@@ -372,13 +375,12 @@ pub struct OKXPlaceOrderResponse {
372375 pub side : Option < OKXSide > ,
373376 /// Order type (optional).
374377 #[ serde( default ) ]
375- pub ord_type : Option < String > ,
378+ pub ord_type : Option < OKXOrderType > ,
376379 /// Order size (optional).
377380 #[ serde( default ) ]
378381 pub sz : Option < String > ,
379382 /// Order state (optional).
380- #[ serde( default ) ]
381- pub state : Option < String > ,
383+ pub state : Option < OKXOrderStatus > ,
382384 /// Price (optional).
383385 #[ serde( default ) ]
384386 pub px : Option < String > ,
@@ -446,7 +448,7 @@ pub struct OKXOrderHistory {
446448 /// Instrument ID.
447449 pub inst_id : Ustr ,
448450 /// Order type.
449- pub ord_type : String ,
451+ pub ord_type : OKXOrderType ,
450452 /// Order size.
451453 pub sz : String ,
452454 /// Price (optional).
@@ -456,13 +458,13 @@ pub struct OKXOrderHistory {
456458 /// Position side.
457459 pub pos_side : OKXPositionSide ,
458460 /// Trade mode.
459- pub td_mode : String ,
461+ pub td_mode : OKXTradeMode ,
460462 /// Reduce-only flag.
461463 pub reduce_only : String ,
462464 /// Target currency (optional).
463465 pub tgt_ccy : String ,
464466 /// Order state.
465- pub state : String ,
467+ pub state : OKXOrderStatus ,
466468 /// Average price (optional).
467469 pub avg_px : String ,
468470 /// Execution fee.
@@ -617,12 +619,12 @@ pub struct OKXPlaceAlgoOrderRequest {
617619 pub inst_id : String ,
618620 /// Trade mode (isolated, cross, cash).
619621 #[ serde( rename = "tdMode" ) ]
620- pub td_mode : String ,
622+ pub td_mode : OKXTradeMode ,
621623 /// Order side (buy, sell).
622- pub side : String ,
624+ pub side : OKXSide ,
623625 /// Algo order type (trigger).
624626 #[ serde( rename = "ordType" ) ]
625- pub ord_type : String ,
627+ pub ord_type : OKXAlgoOrderType ,
626628 /// Order size.
627629 pub sz : String ,
628630 /// Client-supplied algo order ID.
@@ -636,13 +638,13 @@ pub struct OKXPlaceAlgoOrderRequest {
636638 pub order_px : Option < String > ,
637639 /// Trigger type (last, mark, index).
638640 #[ serde( rename = "triggerPxType" , skip_serializing_if = "Option::is_none" ) ]
639- pub trigger_px_type : Option < String > ,
641+ pub trigger_px_type : Option < OKXTriggerType > ,
640642 /// Target currency (base_ccy or quote_ccy).
641643 #[ serde( rename = "tgtCcy" , skip_serializing_if = "Option::is_none" ) ]
642644 pub tgt_ccy : Option < String > ,
643645 /// Position side (net, long, short).
644646 #[ serde( rename = "posSide" , skip_serializing_if = "Option::is_none" ) ]
645- pub pos_side : Option < String > ,
647+ pub pos_side : Option < OKXPositionSide > ,
646648 /// Whether to close position.
647649 #[ serde( rename = "closePosition" , skip_serializing_if = "Option::is_none" ) ]
648650 pub close_position : Option < bool > ,
@@ -717,14 +719,14 @@ mod tests {
717719 fn test_algo_order_request_serialization ( ) {
718720 let request = OKXPlaceAlgoOrderRequest {
719721 inst_id : "ETH-USDT-SWAP" . to_string ( ) ,
720- td_mode : "isolated" . to_string ( ) ,
721- side : "buy" . to_string ( ) ,
722- ord_type : "trigger" . to_string ( ) ,
722+ td_mode : OKXTradeMode :: Isolated ,
723+ side : OKXSide :: Buy ,
724+ ord_type : OKXAlgoOrderType :: Trigger ,
723725 sz : "0.01" . to_string ( ) ,
724726 algo_cl_ord_id : Some ( "test123" . to_string ( ) ) ,
725727 trigger_px : Some ( "3000" . to_string ( ) ) ,
726728 order_px : Some ( "-1" . to_string ( ) ) ,
727- trigger_px_type : Some ( "last" . to_string ( ) ) ,
729+ trigger_px_type : Some ( OKXTriggerType :: Last ) ,
728730 tgt_ccy : None ,
729731 pos_side : None ,
730732 close_position : None ,
@@ -753,16 +755,16 @@ mod tests {
753755 fn test_algo_order_request_array_serialization ( ) {
754756 let request = OKXPlaceAlgoOrderRequest {
755757 inst_id : "BTC-USDT" . to_string ( ) ,
756- td_mode : "cross" . to_string ( ) ,
757- side : "sell" . to_string ( ) ,
758- ord_type : "trigger" . to_string ( ) ,
758+ td_mode : OKXTradeMode :: Cross ,
759+ side : OKXSide :: Sell ,
760+ ord_type : OKXAlgoOrderType :: Trigger ,
759761 sz : "0.1" . to_string ( ) ,
760762 algo_cl_ord_id : None ,
761763 trigger_px : Some ( "50000" . to_string ( ) ) ,
762764 order_px : Some ( "49900" . to_string ( ) ) ,
763- trigger_px_type : Some ( "mark" . to_string ( ) ) ,
765+ trigger_px_type : Some ( OKXTriggerType :: Mark ) ,
764766 tgt_ccy : Some ( "base_ccy" . to_string ( ) ) ,
765- pos_side : Some ( "net" . to_string ( ) ) ,
767+ pos_side : Some ( OKXPositionSide :: Net ) ,
766768 close_position : None ,
767769 tag : None ,
768770 reduce_only : Some ( true ) ,
0 commit comments