Struct binance::market::Market[][src]

pub struct Market {
    pub client: Client,
    pub recv_window: u64,
}

Fields

client: Clientrecv_window: u64

Implementations

Order book (Default 100; max 5000)

Examples
use binance::{api::*, market::*, config::*};
let market: Market = Binance::new_with_env(&Config::default());
let orderbook = tokio_test::block_on(market.get_depth("BTCUSDT".to_string()));
assert!(orderbook.is_ok(), "{:?}", orderbook);

Order book with a custom depth limit Supported limits are: 5, 10, 20, 50, 100, 500, 1000, 5000

Examples
use binance::{api::*, market::*, config::*};
let market: Market = Binance::new_with_env(&Config::default());
let orderbook = tokio_test::block_on(market.get_custom_depth("BTCUSDT".to_string(), 50));
assert!(orderbook.is_ok(), "{:?}", orderbook);
let bids_len = orderbook.unwrap().bids.len();
assert_eq!(bids_len, 50);

Latest price for ALL symbols.

Examples
use binance::{api::*, market::*, config::*};
let market: Market = Binance::new_with_env(&Config::default());
let prices = tokio_test::block_on(market.get_all_prices());
assert!(prices.is_ok(), "{:?}", prices);

Latest price for ONE symbol.

Examples
use binance::{api::*, market::*, config::*};
let market: Market = Binance::new_with_env(&Config::default());
let price = tokio_test::block_on(market.get_price("BTCUSDT"));
assert!(price.is_ok(), "{:?}", price);

Average price for ONE symbol.

Examples
use binance::{api::*, market::*, config::*};
let market: Market = Binance::new_with_env(&Config::default());
let avg_price = tokio_test::block_on(market.get_average_price("BTCUSDT"));
assert!(avg_price.is_ok(), "{:?}", avg_price);

Symbols order book ticker -> Best price/qty on the order book for ALL symbols.

Examples
use binance::{api::*, market::*, config::*};
let market: Market = Binance::new_with_env(&Config::default());
let tickers = tokio_test::block_on(market.get_all_book_tickers());
assert!(tickers.is_ok(), "{:?}", tickers);

-> Best price/qty on the order book for ONE symbol

Examples
use binance::{api::*, market::*, config::*};
let market: Market = Binance::new_with_env(&Config::default());
let tickers = tokio_test::block_on(market.get_book_ticker("BTCUSDT"));
assert!(tickers.is_ok(), "{:?}", tickers);

24hr ticker price change statistics

Examples
use binance::{api::*, market::*, config::*};
let market: Market = Binance::new_with_env(&Config::default());
let price_stats = tokio_test::block_on(market.get_24h_price_stats("BTCUSDT"));
assert!(price_stats.is_ok(), "{:?}", price_stats);

Get aggregated historical trades. If you provide start_time, you also need to provide end_time. If from_id, start_time and end_time are omitted, the most recent trades are fetched.

Examples
use binance::{api::*, market::*, config::*};
let market: Market = Binance::new_with_env(&Config::default());
let agg_trades = tokio_test::block_on(market.get_agg_trades("BNBETH", None, None, None, Some(10)));
assert!(agg_trades.is_ok(), "{:?}", agg_trades);

Returns up to ‘limit’ klines for given symbol and interval (“1m”, “5m”, …) https://github.com/binance-exchange/binance-official-api-docs/blob/master/rest-api.md#klinecandlestick-data

Examples
use binance::{api::*, market::*, config::*};
let market: Market = Binance::new_with_env(&Config::default());
let klines = tokio_test::block_on(market.get_klines("BTCUSDT", "1m", None, None, None));
assert!(klines.is_ok(), "{:?}", klines);

Trait Implementations

Create a binance API using environment variables for credentials BINANCE_API_KEY= BINANCE_API_SECRET_KEY= Read more

Returns a copy of the value. Read more

Performs copy-assignment from source. Read more

Auto Trait Implementations

Blanket Implementations

Gets the TypeId of self. Read more

Immutably borrows from an owned value. Read more

Mutably borrows from an owned value. Read more

Performs the conversion.

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more

Instruments this type with the current Span, returning an Instrumented wrapper. Read more

Performs the conversion.

Should always be Self

The resulting type after obtaining ownership.

Creates owned data from borrowed data, usually by cloning. Read more

🔬 This is a nightly-only experimental API. (toowned_clone_into)

Uses borrowed data to replace owned data, usually by cloning. Read more

The type returned in the event of a conversion error.

Performs the conversion.

The type returned in the event of a conversion error.

Performs the conversion.

Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more