Skip to content
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
17 changes: 16 additions & 1 deletion src/general.rs
Original file line number Diff line number Diff line change
@@ -1,10 +1,11 @@
use error_chain::bail;

use crate::util::build_request;
use crate::model::{Empty, ExchangeInformation, ServerTime, Symbol};
use crate::client::Client;
use crate::errors::Result;
use crate::api::API;
use crate::api::Spot;
use std::collections::BTreeMap;

#[derive(Clone)]
pub struct General {
Expand All @@ -29,6 +30,20 @@ impl General {
self.client.get(API::Spot(Spot::ExchangeInfo), None)
}



// Obtain exchange information with permissions
// - Current exchange trading rules and symbol information
pub fn exchange_info_permission<S>(&self, permission : S) -> Result<ExchangeInformation>
where
S: Into<String>,
{
let mut parameters: BTreeMap<String, String> = BTreeMap::new();
parameters.insert("permissions".into(), permission.into());
let request = build_request(parameters);
self.client.get(API::Spot(Spot::ExchangeInfo), Some(request))
}

// Get Symbol information
pub fn get_symbol_info<S>(&self, symbol: S) -> Result<Symbol>
where
Expand Down
6 changes: 6 additions & 0 deletions src/model.rs
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,11 @@ pub enum Filters {
max_price: String,
tick_size: String,
},
#[serde(rename = "POSITION_RISK_CONTROL")]
#[serde(rename_all = "camelCase")]
PositionRiskControl {
},

#[serde(rename = "PERCENT_PRICE")]
#[serde(rename_all = "camelCase")]
PercentPrice {
Expand Down Expand Up @@ -137,6 +142,7 @@ pub struct AccountInformation {
pub can_withdraw: bool,
pub can_deposit: bool,
pub balances: Vec<Balance>,
pub permissions: Vec<String>,
}

#[derive(Debug, Serialize, Deserialize, Clone)]
Expand Down