Skip to content

Commit

Permalink
fix(rust): Added parsing for TRADE_LITE message; but, no actual fun…
Browse files Browse the repository at this point in the history
…ctionality has been implemented. (#172)
  • Loading branch information
nkaz001 committed Jan 14, 2025
1 parent 0e3f799 commit cc1fc2f
Show file tree
Hide file tree
Showing 2 changed files with 43 additions and 0 deletions.
36 changes: 36 additions & 0 deletions connector/src/binancefutures/msg/stream.rs
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,8 @@ pub enum EventStream {
Trade(Trade),
#[serde(rename = "ORDER_TRADE_UPDATE")]
OrderTradeUpdate(OrderTradeUpdate),
#[serde(rename = "TRADE_LITE")]
TradeLite(TradeLite),
#[serde(rename = "ACCOUNT_UPDATE")]
AccountUpdate(AccountUpdate),
#[serde(rename = "listenKeyExpired")]
Expand Down Expand Up @@ -77,6 +79,40 @@ pub struct Trade {
pub is_the_buyer_the_market_maker: bool,
}

#[derive(Deserialize, Debug)]
pub struct TradeLite {
#[serde(rename = "E")]
pub event_time: i64,
#[serde(rename = "T")]
pub transaction_time: i64,
#[serde(rename = "s")]
#[serde(deserialize_with = "to_lowercase")]
pub symbol: String,
#[serde(rename = "q")]
#[serde(deserialize_with = "from_str_to_f64")]
pub qty: f64,
#[serde(rename = "p")]
#[serde(deserialize_with = "from_str_to_f64")]
pub price: f64,
#[serde(rename = "m")]
pub is_this_trade_the_market_maker: bool,
#[serde(rename = "c")]
pub client_order_id: String,
#[serde(rename = "S")]
#[serde(deserialize_with = "from_str_to_side")]
pub side: Side,
#[serde(rename = "L")]
#[serde(deserialize_with = "from_str_to_f64")]
pub last_filled_price: f64,
#[serde(rename = "l")]
#[serde(deserialize_with = "from_str_to_f64")]
pub last_filled_qty: f64,
#[serde(rename = "t")]
pub trade_id: i64,
#[serde(rename = "i")]
pub order_id: i64,
}

#[derive(Deserialize, Debug)]
pub struct AccountUpdate {
#[serde(rename = "E")]
Expand Down
7 changes: 7 additions & 0 deletions connector/src/binancefutures/user_data_stream.rs
Original file line number Diff line number Diff line change
Expand Up @@ -98,6 +98,13 @@ impl UserDataStream {
}
}
}
EventStream::TradeLite(_data) => {
// Since this message does not include the order status, additional logic is
// required to fully utilize it. To reduce latency— which first needs to be
// measured—a new logic must be implemented to reconstruct the order status and open
// position by using the last filled quantity and reconciling it with data from the
// ORDER_TRADE_UPDATE message.
}
}
Ok(())
}
Expand Down

0 comments on commit cc1fc2f

Please sign in to comment.