Struct binance::market::Market [−][src]
pub struct Market { pub client: Client, pub recv_window: u64, }
Fields
client: Client
recv_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);
pub async fn get_average_price<S>(&self, symbol: S) -> Result<AveragePrice> where
S: Into<String>,
pub async fn get_average_price<S>(&self, symbol: S) -> Result<AveragePrice> where
S: Into<String>,
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);
pub async fn get_24h_price_stats<S>(&self, symbol: S) -> Result<PriceStats> where
S: Into<String>,
pub async fn get_24h_price_stats<S>(&self, symbol: S) -> Result<PriceStats> where
S: Into<String>,
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);
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
Auto Trait Implementations
impl !RefUnwindSafe for Market
impl !UnwindSafe for Market
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