Struct tokio_binance::AccountClient[][src]

pub struct AccountClient { /* fields omitted */ }

Client for dealing with orders

Implementations

impl AccountClient[src]

pub fn connect<A, S, U>(api_key: A, secret_key: S, url: U) -> Result<Self> where
    A: Into<String>,
    S: Into<String>,
    U: Into<String>, 
[src]

Creates new client instance.

Example

use tokio_binance::{AccountClient, BINANCE_US_URL};
 
#[tokio::main]
async fn main() -> Result<(), Box<dyn std::error::Error>> {
    let client = AccountClient::connect("<api-key>", "<secret-key>", BINANCE_US_URL)?;
    Ok(())
}

pub fn place_limit_order<'a>(
    &self,
    symbol: &'a str,
    side: Side,
    price: f64,
    quantity: f64,
    execute: bool
) -> ParamBuilder<'a, '_, LimitOrderParams>
[src]

Place a new limit order.

Example

use tokio_binance::{Side::Sell, TimeInForce::Fok, OrderRespType::Full};
use serde_json::Value;
 
let response = client
    // false will send as test, true will send as a real order.
    .place_limit_order("BNBUSDT", Sell, 20.00, 5.00, false)
    // optional: lifetime of order; default is Gtc.
    .with_time_in_force(Fok)
    // optional: unique id; auto generated by default.
    .with_new_client_order_id("<uuid>")
    // optional: splits quantity; sets time in force to Gtc.
    .with_iceberg_qty(1.00)
    // optional: output verbosity; default is Ack.
    .with_new_order_resp_type(Full)
    // optional: converts Limit to Stop-Limit; triggers when price hits below 21.00.
    .with_stop_loss_limit(21.00)
    // optional: converts Limit to Stop-Limit; triggers when price hits above 21.00.
    .with_take_profit_limit(21.00)
    // optional: processing time for request; default is 5000, can't be above 60000.
    .with_recv_window(8000)
    // optional: converts Limit to Limit-Maker; consumes builder and returns a different one.
    .into_limit_maker_order()
    //
    .json::<Value>()
    .await?;

pub fn place_market_order<'a>(
    &self,
    symbol: &'a str,
    side: Side,
    quantity: f64,
    execute: bool
) -> ParamBuilder<'a, '_, MarketOrderParams>
[src]

Place a new market order.

Example

use tokio_binance::{Side::Sell, TimeInForce::Fok, OrderRespType::Full};
use serde_json::Value;
 
let response = client
    // false will send as test, true will send as a real order.
    .place_market_order("BNBUSDT", Sell, 5.00, false)
    // optional: unique id; auto generated by default.
    .with_new_client_order_id("<uuid>")
    // optional: output verbosity; default is Ack.
    .with_new_order_resp_type(Full)
    // optional: converts Market to Stop-Loss; triggers when price hits below 21.00.
    .with_stop_loss(21.00)
    // optional: converts Market to Stop-Loss; triggers when price hits above 21.00.
    .with_take_profit(21.00)
    // optional: processing time for request; default is 5000, can't be above 60000.
    .with_recv_window(8000)
    //
    .json::<Value>()
    .await?;

pub fn get_order<'a>(
    &self,
    symbol: &'a str,
    id: ID<'a>
) -> ParamBuilder<'a, '_, OrderStatusParams>
[src]

Get order.

Example

use tokio_binance::ID;
use serde_json::Value;
 
let response = client
    .get_order("BNBUSDT", ID::ClientOId("<uuid>"))
    // optional: processing time for request; default is 5000, can't be above 60000.
    .with_recv_window(8000)
    //
    .json::<Value>()
    .await?;

pub fn cancel_order<'a>(
    &self,
    symbol: &'a str,
    id: ID<'a>
) -> ParamBuilder<'a, '_, CancelOrderParams>
[src]

Cancel order.

Example

use tokio_binance::ID;
use serde_json::Value;
 
let response = client
    .cancel_order("BNBUSDT", ID::ClientOId("<uuid>"))
    // optional: unique id; auto generated by default.
    .with_new_client_order_id("<uuid>")
    // optional: processing time for request; default is 5000, can't be above 60000.
    .with_recv_window(8000)
    //
    .json::<Value>()
    .await?;

pub fn get_open_orders(&self) -> ParamBuilder<'_, '_, OpenOrderParams>[src]

Get open orders.

Example

use serde_json::Value;
 
let response = client
    .get_open_orders()
    // optional: filter by symbol; gets all symbols by default.
    .with_symbol("BNBUSDT")
    // optional: processing time for request; default is 5000, can't be above 60000.
    .with_recv_window(8000)
    //
    .json::<Value>()
    .await?;

pub fn get_all_orders<'a>(
    &self,
    symbol: &'a str
) -> ParamBuilder<'a, '_, AllOrdersParams>
[src]

Get all orders.

Example

use chrono::{Utc, Duration};
use serde_json::Value;
 
let end = Utc::now();
let start = end - Duration::hours(23);
 
let response = client
    .get_all_orders("BNBUSDT")
    // optional: filter by orders greater than or equal to the provided id.
    // If supplied, neither startTime or endTime can be provided
    .with_order_id(1230494)
    // optional: get orders from; pass 24 hours of orders is the default.
    .with_start_time(start)
    // optional: get orders until; default is now.
    .with_end_time(end)
    // optional: limit the amount of orders; default 500; max 1000.
    .with_limit(100)
    // optional: processing time for request; default is 5000, can't be above 60000.
    .with_recv_window(8000)
    //
    .json::<Value>()
    .await?;

pub fn place_oco_order<'a>(
    &self,
    symbol: &'a str,
    side: Side,
    price: f64,
    stop_price: f64,
    quantity: f64
) -> ParamBuilder<'a, '_, OcoParams>
[src]

Place a new oco order.

Price Restrictions:

  • SELL: Limit Price > Last Price > Stop Price
  • BUY: Limit Price < Last Price < Stop Price

Example

use tokio_binance::{Side::Sell, TimeInForce::Gtc, OrderRespType::Full};
use serde_json::Value;
 
let response = client
    // Limit to sell at 30.00 and Stop-Loss at 20.00; One cancels the other.
    .place_oco_order("BNBUSDT", Sell, 30.00, 20.00, 5.00)
    // optional: A unique Id for the entire orderList; auto generated by default.
    .with_list_client_order_id("<uuid>")
    // optional: A unique Id for the limit order; auto generated by default.
    .with_limit_client_order_id("<uuid>")
    // optional: splits quantity for the limit order leg;
    .with_limit_iceberg_qty(1.00)
    // optional: A unique Id for the stop loss/stop loss limit leg; auto generated by default.
    .with_stop_client_order_id("<uuid>")
    // optional: Converts Stop-Loss to Stop-Limit; triggers bellow 20.00.
    .with_stop_limit_price(19.00, Gtc)
    // optional: splits quantity for the stop order leg;
    .with_stop_iceberg_qty(1.00)
    // optional: output verbosity; default is Ack.
    .with_new_order_resp_type(Full)
    // optional: processing time for request; default is 5000, can't be above 60000.
    .with_recv_window(8000)
    //
    .json::<Value>()
    .await?;

pub fn cancel_oco_order<'a>(
    &self,
    symbol: &'a str,
    id: ID<'a>
) -> ParamBuilder<'a, '_, CancelOcoParams>
[src]

Cancel oco order.

Example

use tokio_binance::ID;
use serde_json::Value;
 
let response = client
    .cancel_oco_order("BNBUSDT", ID::ClientOId("<uuid>"))
    // optional: unique id; auto generated by default.
    .with_new_client_order_id("<uuid>")
    // optional: processing time for request; default is 5000, can't be above 60000.
    .with_recv_window(8000)
    //
    .json::<Value>()
    .await?;

pub fn get_oco_order<'a>(
    &self,
    id: ID<'a>
) -> ParamBuilder<'a, '_, OcoStatusParams>
[src]

Get oco order.

Example

use tokio_binance::ID;
use serde_json::Value;
 
let response = client
    .get_oco_order(ID::ClientOId("<uuid>"))
    // optional: processing time for request; default is 5000, can't be above 60000.
    .with_recv_window(8000)
    //
    .json::<Value>()
    .await?;

pub fn get_all_oco_orders(&self) -> ParamBuilder<'_, '_, AllOcoParams>[src]

Get all oco orders.

Example

use chrono::{Utc, Duration};
use serde_json::Value;
 
let end = Utc::now();
let start = end - Duration::hours(23);
 
let response = client
    .get_all_oco_orders()
    // optional: filter by orders greater than or equal to the provided id.
    // If supplied, neither startTime or endTime can be provided
    .with_from_id(1230494)
    // optional: get orders from; pass 24 hours of orders is the default.
    .with_start_time(start)
    // optional: get orders until; default is now.
    .with_end_time(end)
    // optional: limit the amount of orders; default 500; max 1000.
    .with_limit(100)
    // optional: processing time for request; default is 5000, can't be above 60000.
    .with_recv_window(8000)
    //
    .json::<Value>()
    .await?;

pub fn get_open_oco_orders(&self) -> ParamBuilder<'_, '_, OpenOcoParams>[src]

Get open oco orders.

Example

use serde_json::Value;
 
let response = client
    .get_open_oco_orders()
    // optional: processing time for request; default is 5000, can't be above 60000.
    .with_recv_window(8000)
    //
    .json::<Value>()
    .await?;

pub fn get_account(&self) -> ParamBuilder<'_, '_, AccountParams>[src]

Get current account information.

Example

use serde_json::Value;
 
let response = client
    .get_account()
    // optional: processing time for request; default is 5000, can't be above 60000.
    .with_recv_window(8000)
    //
    .json::<Value>()
    .await?;

pub fn get_account_trades<'a>(
    &self,
    symbol: &'a str
) -> ParamBuilder<'a, '_, AccountTradesParams>
[src]

Get trades for a specific account and symbol.

Example

use chrono::{Utc, Duration};
use serde_json::Value;
 
let end = Utc::now();
let start = end - Duration::hours(23);
 
let response = client
    .get_account_trades("BNBUSDT")
    // optional: filter by orders greater than or equal to the provided id.
    // If supplied, neither startTime or endTime can be provided
    .with_from_id(1230494)
    // optional: get orders from; pass 24 hours of orders is the default.
    .with_start_time(start)
    // optional: get orders until; default is now.
    .with_end_time(end)
    // optional: limit the amount of orders; default 500; max 1000.
    .with_limit(100)
    // optional: processing time for request; default is 5000, can't be above 60000.
    .with_recv_window(8000)
    //
    .json::<Value>()
    .await?;

pub fn to_withdraw_client(&self) -> WithdrawalClient[src]

Helper method for getting a withdraw client instance.

pub fn to_market_data_client(&self) -> MarketDataClient[src]

Helper method for getting a market client instance.

pub fn to_general_client(&self) -> GeneralClient[src]

Helper method for getting a general client instance.

Trait Implementations

impl Clone for AccountClient[src]

Auto Trait Implementations

Blanket Implementations

impl<T> Any for T where
    T: 'static + ?Sized
[src]

impl<T> Borrow<T> for T where
    T: ?Sized
[src]

impl<T> BorrowMut<T> for T where
    T: ?Sized
[src]

impl<T> From<T> for T[src]

impl<T> Instrument for T[src]

impl<T> Instrument for T[src]

impl<T, U> Into<U> for T where
    U: From<T>, 
[src]

impl<T> Same<T> for T

type Output = T

Should always be Self

impl<T> ToOwned for T where
    T: Clone
[src]

type Owned = T

The resulting type after obtaining ownership.

impl<T, U> TryFrom<U> for T where
    U: Into<T>, 
[src]

type Error = Infallible

The type returned in the event of a conversion error.

impl<T, U> TryInto<U> for T where
    U: TryFrom<T>, 
[src]

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.

impl<V, T> VZip<V> for T where
    V: MultiLane<T>,