Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update futures trade model #244

Open
wants to merge 4 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
30 changes: 22 additions & 8 deletions src/futures/model.rs
Original file line number Diff line number Diff line change
Expand Up @@ -110,17 +110,29 @@ pub enum Trades {
#[derive(Debug, Serialize, Deserialize, Clone)]
#[serde(rename_all = "camelCase")]
pub struct Trade {
pub id: u64,
pub is_buyer_maker: bool,
#[serde(with = "string_or_float")]
pub price: f64,
#[serde(with = "string_or_float")]
pub qty: f64,
#[serde(with = "string_or_float")]
pub quote_qty: f64,
#[serde(rename = "T")]
pub time: u64,

#[serde(rename = "s")]
pub symbol: String,

#[serde(rename = "t")]
pub transaction_id: i64,

#[serde(rename = "p", with = "string_or_float")]
pub price: f64,

#[serde(rename = "q", with = "string_or_float")]
pub quantity: f64,

#[serde(rename = "X")]
pub order_type: String,

#[serde(rename = "m")]
pub is_buyer_maker: bool,
}


#[derive(Debug, Serialize, Deserialize, Clone)]
#[serde(untagged)]
pub enum AggTrades {
Expand Down Expand Up @@ -612,6 +624,8 @@ pub struct OrderTradeEvent {
pub order: OrderUpdate,
}



#[derive(Debug, Serialize, Deserialize, Clone)]
#[serde(rename_all = "camelCase")]
pub struct Income {
Expand Down
8 changes: 5 additions & 3 deletions src/futures/websockets.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ use crate::config::Config;
use crate::model::{
AccountUpdateEvent, AggrTradesEvent, BookTickerEvent, ContinuousKlineEvent, DayTickerEvent,
DepthOrderBookEvent, IndexKlineEvent, IndexPriceEvent, KlineEvent, LiquidationEvent,
MarkPriceEvent, MiniTickerEvent, OrderBook, TradeEvent, UserDataStreamExpiredEvent,
MarkPriceEvent, MiniTickerEvent, OrderBook, UserDataStreamExpiredEvent,
};
use crate::futures::model;
use error_chain::bail;
Expand All @@ -16,6 +16,8 @@ use tungstenite::protocol::WebSocket;
use tungstenite::stream::MaybeTlsStream;
use tungstenite::handshake::client::Response;

use super::model::Trade;

#[allow(clippy::all)]
enum FuturesWebsocketAPI {
Default,
Expand Down Expand Up @@ -55,7 +57,7 @@ pub enum FuturesWebsocketEvent {
AccountUpdate(AccountUpdateEvent),
OrderTrade(model::OrderTradeEvent),
AggrTrades(AggrTradesEvent),
Trade(TradeEvent),
Trade(Trade),
OrderBook(OrderBook),
DayTicker(DayTickerEvent),
MiniTicker(MiniTickerEvent),
Expand Down Expand Up @@ -92,7 +94,7 @@ enum FuturesEvents {
IndexPriceEvent(IndexPriceEvent),
MarkPriceEvent(MarkPriceEvent),
VecMarkPriceEvent(Vec<MarkPriceEvent>),
TradeEvent(TradeEvent),
TradeEvent(Trade),
KlineEvent(KlineEvent),
ContinuousKlineEvent(ContinuousKlineEvent),
IndexKlineEvent(IndexKlineEvent),
Expand Down
Loading