xapi-binance 0.0.1

Binance API client
Documentation
use crate::data::enums::{
    contract_status::BnContractStatus, contract_type::BnContractType, order_type::BnOrderType,
    ratelimit::BnRateLimit, symbol_filter::BnSymbolFilter, symbol_status::BnSymbolStatus,
};
use chrono::{DateTime, Utc};
use rust_decimal::Decimal;
use serde::Deserialize;
use serde_with::{TimestampMilliSeconds, formats::Flexible};
use xapi_shared::data::{crypto_asset::CryptoAsset, crypto_symbol::CryptoSymbol};

#[derive(Deserialize, Debug, Clone)]
#[serde(rename_all = "camelCase")]
pub struct BnSpotExchangeInformation {
    pub rate_limits: Vec<BnRateLimit>,
    pub symbols: Vec<BnSpotExchangeSymbol>,
}

#[derive(Deserialize, Debug, Clone)]
#[serde(rename_all = "camelCase")]
pub struct BnSpotExchangeSymbol {
    pub symbol: CryptoSymbol,
    pub status: BnSymbolStatus,
    pub base_asset: CryptoAsset,
    pub base_asset_precision: u8,
    pub quote_asset: CryptoAsset,
    /// will be removed in future api versions (v4+)
    pub quote_precision: Option<u8>,
    pub quote_asset_precision: u8,
    pub base_commission_precision: u8,
    pub quote_commission_precision: u8,
    pub order_types: Vec<BnOrderType>,
    pub iceberg_allowed: bool,
    pub oco_allowed: bool,
    pub oto_allowed: bool,
    pub quote_order_qty_market_allowed: bool,
    pub allow_trailing_stop: bool,
    pub cancel_replace_allowed: bool,
    pub amend_allowed: bool,
    pub is_spot_trading_allowed: bool,
    pub is_margin_trading_allowed: bool,
    pub filters: Vec<BnSymbolFilter>,
}

#[derive(Deserialize, Debug, Clone)]
#[serde(rename_all = "camelCase")]
pub struct BnUsdmExchangeInformation {
    pub assets: Vec<BnUsdmExchangeAsset>,
    pub symbols: Vec<BnUsdmExchangeSymbol>,
    pub timezone: String,
}

#[derive(Deserialize, Debug, Clone)]
#[serde(rename_all = "camelCase")]
pub struct BnUsdmExchangeAsset {
    pub asset: CryptoAsset,
    /// whether the asset can be used as margin in Multi-Assets mode
    pub margin_available: bool,
    /// auto-exchange threshold in Multi-Assets margin mode
    pub auto_asset_exchange: Decimal,
}

#[serde_with::serde_as]
#[derive(Deserialize, Debug, Clone)]
#[serde(rename_all = "camelCase")]
pub struct BnUsdmExchangeSymbol {
    pub symbol: CryptoSymbol,
    pub pair: String,
    pub contract_type: BnContractType,
    #[serde_as(as = "TimestampMilliSeconds<String, Flexible>")]
    pub delivery_date: DateTime<Utc>,
    #[serde_as(as = "TimestampMilliSeconds<String, Flexible>")]
    pub onboard_date: DateTime<Utc>,
    pub status: BnContractStatus,
    pub base_asset: CryptoAsset,
    pub quote_asset: CryptoAsset,
    pub margin_asset: CryptoAsset,
    pub underlying_type: String,
    pub underlying_sub_type: Vec<String>,
    pub filters: Vec<BnSymbolFilter>,
    pub liquidation_fee: Decimal,
    pub market_take_bound: Decimal,
}