Struct binance::account::Account [−][src]
pub struct Account { pub client: Client, pub recv_window: u64, }
Expand description
Account API access, full example provided in examples/binance_endpoints.rs
Fields
client: Client
recv_window: u64
Implementations
General account information
Examples
use binance::{api::*, account::*, config::*}; let account: Account = Binance::new_with_env(&Config::testnet()); let account = tokio_test::block_on(account.get_account()); assert!(account.is_ok(), "{:?}", account);
Account balance for a single asset
Examples
use binance::{api::*, account::*, config::*}; let account: Account = Binance::new_with_env(&Config::testnet()); let balance = tokio_test::block_on(account.get_balance("BTC")); assert!(balance.is_ok(), "{:?}", balance);
All currently open orders for a single symbol
Examples
use binance::{api::*, account::*, config::*}; let account: Account = Binance::new_with_env(&Config::testnet()); let orders = tokio_test::block_on(account.get_open_orders("BTCUSDT")); assert!(orders.is_ok(), "{:?}", orders);
All orders for the account
Examples
use binance::{api::*, account::*, config::*}; let account: Account = Binance::new_with_env(&Config::testnet()); let query = OrdersQuery { symbol: "BTCUSDT".to_string(), order_id: None, start_time: None, end_time: None, limit: None, recv_window: None, }; let orders = tokio_test::block_on(account.get_all_orders(query)); assert!(orders.is_ok(), "{:?}", orders);
All currently open orders for the account
Examples
use binance::{api::*, account::*, config::*}; let account: Account = Binance::new_with_env(&Config::testnet()); let orders = tokio_test::block_on(account.get_all_open_orders()); assert!(orders.is_ok(), "{:?}", orders);
Check an order’s status
Examples
use binance::{api::*, account::*, config::*}; let account: Account = Binance::new_with_env(&Config::testnet()); let query = OrderStatusRequest { symbol: "BTCUSDT".to_string(), order_id: Some(1), orig_client_order_id: Some("my_id".to_string()), recv_window: None }; let order = tokio_test::block_on(account.order_status(query)); assert!(order.is_ok(), "{:?}", order);
Place a test status order
This order is sandboxed: it is validated, but not sent to the matching engine.
Examples
use binance::{api::*, account::*, config::*}; let account: Account = Binance::new_with_env(&Config::testnet()); let query = OrderStatusRequest { symbol: "BTCUSDT".to_string(), order_id: Some(1), orig_client_order_id: Some("my_id".to_string()), recv_window: None }; let resp = tokio_test::block_on(account.test_order_status(query)); assert!(resp.is_ok(), "{:?}", resp);
Place an order Returns the Transaction if Ok This methods validates the order request before sending, making sure it complies with Binance rules
Examples
use binance::{api::*, account::*, config::*, rest_model::*}; let account: Account = Binance::new_with_env(&Config::testnet()); let limit_buy = OrderRequest { symbol: "BTCUSDT".to_string(), quantity: Some(10.0), price: Some(0.014000), order_type: OrderType::Limit, side: OrderSide::Buy, time_in_force: Some(TimeInForce::FOK), ..OrderRequest::default() }; let transaction = tokio_test::block_on(account.place_order(limit_buy)); assert!(transaction.is_ok(), "{:?}", transaction);
Place a test order
Despite being a test, this order is still validated before calls This order is sandboxed: it is validated, but not sent to the matching engine.
Examples
use binance::{api::*, account::*, config::*, rest_model::*}; let account: Account = Binance::new_with_env(&Config::testnet()); let limit_buy = OrderRequest { symbol: "BTCUSDT".to_string(), quantity: Some(10.0), price: Some(0.014000), order_type: OrderType::Limit, side: OrderSide::Buy, time_in_force: Some(TimeInForce::FOK), ..OrderRequest::default() }; let resp = tokio_test::block_on(account.place_test_order(limit_buy)); assert!(resp.is_ok(), "{:?}", resp);
Place a cancellation order
Examples
use binance::{api::*, account::*, config::*}; let account: Account = Binance::new_with_env(&Config::testnet()); let query = OrderCancellation { symbol: "BTCUSDT".to_string(), order_id: Some(1), orig_client_order_id: Some("my_id".to_string()), new_client_order_id: None, recv_window: None }; let canceled = tokio_test::block_on(account.cancel_order(query)); assert!(canceled.is_ok(), "{:?}", canceled);
Place a test cancel order
This order is sandboxed: it is validated, but not sent to the matching engine.
Examples
use binance::{api::*, account::*, config::*}; let account: Account = Binance::new_with_env(&Config::testnet()); let query = OrderCancellation { symbol: "BTCUSDT".to_string(), order_id: Some(1), orig_client_order_id: Some("my_id".to_string()), new_client_order_id: None, recv_window: None }; let response = tokio_test::block_on(account.test_cancel_order(query)); assert!(response.is_ok(), "{:?}", response);
pub async fn trade_history<S>(&self, symbol: S) -> Result<Vec<TradeHistory>> where
S: Into<String>,
pub async fn trade_history<S>(&self, symbol: S) -> Result<Vec<TradeHistory>> where
S: Into<String>,
Trade history
Examples
use binance::{api::*, account::*, config::*}; let account: Account = Binance::new_with_env(&Config::testnet()); let trade_history = tokio_test::block_on(account.trade_history("BTCUSDT")); assert!(trade_history.is_ok(), "{:?}", trade_history);
Trait Implementations
Auto Trait Implementations
impl !RefUnwindSafe for Account
impl !UnwindSafe for Account
Blanket Implementations
Mutably borrows from an owned value. Read more
Instruments this type with the provided Span
, returning an
Instrumented
wrapper. Read more
type Output = T
type Output = T
Should always be Self