// PLEASE DO NOT EDIT THIS FILE, IT IS GENERATED AND WILL BE OVERWRITTEN:
// https://github.com/ccxt/ccxt/blob/master/CONTRIBUTING.md#how-to-contribute-code
#![allow(unused, non_snake_case, clippy::all)]
use crate::Value;
use crate::get_value;
use crate::runtime::*;
// Base methods are now trait methods (review #1: static dispatch). Bring the
// traits into scope so `self.market(...)`, `self.safe_market(...)`,
// `self.load_markets(...)`, … on this Core resolve to the base defaults.
use crate::exchange_generated::ExchangeBase;
use crate::exchange::ExchangeRuntime;
pub struct BinanceCore {
pub exchange: crate::exchange::Exchange,
}
impl BinanceCore {
pub fn new(config: Option<crate::Value>) -> Self {
let mut s = Self { exchange: crate::exchange::Exchange::new(config) };
s.init();
s
}
pub fn init(&mut self) {
let described = BinanceCore::describe(self);
self.initialize_properties(described);
<Self as crate::exchange_generated::ExchangeBase>::after_construct(self);
}
/// Compatibility no-op. The old pointer-based dispatch needed a post-move
/// `bind()`; static trait dispatch (review #1) needs no binding, so this
/// just exists so callers that still call it keep compiling.
#[inline]
pub fn bind(&mut self) {}
}
impl crate::exchange::DerivedExchange for BinanceCore {
fn nonce(&self, ) -> crate::Value {
// Forward to the inherent method on BinanceCore.
BinanceCore::nonce(self, )
}
fn parse_ticker(&self, ticker: crate::Value, market: crate::Value) -> crate::Value {
// Forward to the inherent method on BinanceCore.
BinanceCore::parse_ticker(self, ticker, &[market.clone()])
}
fn parse_trade(&self, trade: crate::Value, market: crate::Value) -> crate::Value {
// Forward to the inherent method on BinanceCore.
BinanceCore::parse_trade(self, trade, &[market.clone()])
}
fn parse_order(&self, order: crate::Value, market: crate::Value) -> crate::Value {
// Forward to the inherent method on BinanceCore.
BinanceCore::parse_order(self, order, &[market.clone()])
}
fn parse_market(&self, market: crate::Value) -> crate::Value {
// Forward to the inherent method on BinanceCore.
BinanceCore::parse_market(self, market)
}
fn parse_ohlcv(&self, ohlcv: crate::Value, market: crate::Value) -> crate::Value {
// Forward to the inherent method on BinanceCore.
BinanceCore::parse_ohlcv(self, ohlcv, &[market.clone()])
}
fn parse_funding_rate(&self, rate: crate::Value, market: crate::Value) -> crate::Value {
// Forward to the inherent method on BinanceCore.
BinanceCore::parse_funding_rate(self, rate, &[market.clone()])
}
fn parse_deposit_address(&self, depositAddress: crate::Value, currency: crate::Value) -> crate::Value {
// Forward to the inherent method on BinanceCore.
BinanceCore::parse_deposit_address(self, depositAddress, &[currency.clone()])
}
fn parse_last_price(&self, entry: crate::Value, market: crate::Value) -> crate::Value {
// Forward to the inherent method on BinanceCore.
BinanceCore::parse_last_price(self, entry, &[market.clone()])
}
fn parse_ledger_entry(&self, entry: crate::Value, currency: crate::Value) -> crate::Value {
// Forward to the inherent method on BinanceCore.
BinanceCore::parse_ledger_entry(self, entry, &[currency.clone()])
}
fn parse_transfer(&self, transfer: crate::Value, currency: crate::Value) -> crate::Value {
// Forward to the inherent method on BinanceCore.
BinanceCore::parse_transfer(self, transfer, &[currency.clone()])
}
fn parse_currency(&self, currency: crate::Value) -> crate::Value {
// Forward to the inherent method on BinanceCore.
BinanceCore::parse_currency(self, currency)
}
fn parse_open_interest(&self, interest: crate::Value, market: crate::Value) -> crate::Value {
// Forward to the inherent method on BinanceCore.
BinanceCore::parse_open_interest(self, interest, &[market.clone()])
}
fn parse_liquidation(&self, liquidation: crate::Value, market: crate::Value) -> crate::Value {
// Forward to the inherent method on BinanceCore.
BinanceCore::parse_liquidation(self, liquidation, &[market.clone()])
}
fn parse_funding_rate_history(&self, entry: crate::Value, market: crate::Value) -> crate::Value {
// Forward to the inherent method on BinanceCore.
BinanceCore::parse_funding_rate_history(self, entry, &[market.clone()])
}
fn parse_margin_modification(&self, data: crate::Value, market: crate::Value) -> crate::Value {
// Forward to the inherent method on BinanceCore.
BinanceCore::parse_margin_modification(self, data, &[market.clone()])
}
fn parse_transaction(&self, transaction: crate::Value, currency: crate::Value) -> crate::Value {
// Forward to the inherent method on BinanceCore.
BinanceCore::parse_transaction(self, transaction, &[currency.clone()])
}
fn parse_borrow_interest(&self, info: crate::Value, market: crate::Value) -> crate::Value {
// Forward to the inherent method on BinanceCore.
BinanceCore::parse_borrow_interest(self, info, &[market.clone()])
}
fn parse_adl_rank(&self, info: crate::Value, market: crate::Value) -> crate::Value {
// Forward to the inherent method on BinanceCore.
BinanceCore::parse_adl_rank(self, info, &[market.clone()])
}
fn parse_income(&self, info: crate::Value, market: crate::Value) -> crate::Value {
// Forward to the inherent method on BinanceCore.
BinanceCore::parse_income(self, info, &[market.clone()])
}
fn parse_greeks(&self, greeks: crate::Value, market: crate::Value) -> crate::Value {
// Forward to the inherent method on BinanceCore.
BinanceCore::parse_greeks(self, greeks, &[market.clone()])
}
fn parse_margin_mode(&self, margin_mode: crate::Value, market: crate::Value) -> crate::Value {
// Forward to the inherent method on BinanceCore.
BinanceCore::parse_margin_mode(self, margin_mode, &[market.clone()])
}
fn parse_conversion(&self, conversion: crate::Value, from_currency: crate::Value, to_currency: crate::Value) -> crate::Value {
// Forward to the inherent method on BinanceCore.
BinanceCore::parse_conversion(self, conversion, &[from_currency.clone(), to_currency.clone()])
}
fn parse_borrow_rate(&self, info: crate::Value, currency: crate::Value) -> crate::Value {
// Forward to the inherent method on BinanceCore.
BinanceCore::parse_borrow_rate(self, info, &[currency.clone()])
}
fn parse_leverage(&self, leverage: crate::Value, market: crate::Value) -> crate::Value {
// Forward to the inherent method on BinanceCore.
BinanceCore::parse_leverage(self, leverage, &[market.clone()])
}
fn parse_market_leverage_tiers(&self, info: crate::Value, market: crate::Value) -> crate::Value {
// Forward to the inherent method on BinanceCore.
BinanceCore::parse_market_leverage_tiers(self, info, &[market.clone()])
}
fn parse_deposit_withdraw_fee(&self, fee: crate::Value, currency: crate::Value) -> crate::Value {
// Forward to the inherent method on BinanceCore.
BinanceCore::parse_deposit_withdraw_fee(self, fee, &[currency.clone()])
}
fn create_expired_option_market(&self, symbol: crate::Value) -> crate::Value {
// Forward to the inherent method on BinanceCore.
BinanceCore::create_expired_option_market(self, symbol)
}
fn sign(&self, path: crate::Value, api: crate::Value, method: crate::Value, params: crate::Value, headers: crate::Value, body: crate::Value) -> crate::Value {
// Forward to the inherent method on BinanceCore.
BinanceCore::sign(self, path, &[api.clone(), method.clone(), params.clone(), headers.clone(), body.clone()])
}
fn handle_errors(&self, code: crate::Value, reason: crate::Value, url: crate::Value, method: crate::Value, headers: crate::Value, body: crate::Value, response: crate::Value, request_headers: crate::Value, request_body: crate::Value) -> crate::Value {
// Forward to the inherent method on BinanceCore.
BinanceCore::handle_errors(self, code, reason, url, method, headers, body, response, request_headers, request_body)
}
}
impl crate::exchange_generated::ExchangeBase for BinanceCore {
fn call_dynamic<'a>(&'a mut self, method: &'a str, args: Vec<crate::Value>)
-> std::pin::Pin<Box<dyn std::future::Future<Output = crate::Value> + Send + 'a>>
{
Box::pin(async move {
match method {
"add_margin" => self.add_margin(args.get(0).cloned().unwrap_or(crate::Value::Null), args.get(1).cloned().unwrap_or(crate::Value::Null), &args.get(2..).unwrap_or(&[]).to_vec()[..]).await,
"borrow_cross_margin" => self.borrow_cross_margin(args.get(0).cloned().unwrap_or(crate::Value::Null), args.get(1).cloned().unwrap_or(crate::Value::Null), &args.get(2..).unwrap_or(&[]).to_vec()[..]).await,
"borrow_isolated_margin" => self.borrow_isolated_margin(args.get(0).cloned().unwrap_or(crate::Value::Null), args.get(1).cloned().unwrap_or(crate::Value::Null), args.get(2).cloned().unwrap_or(crate::Value::Null), &args.get(3..).unwrap_or(&[]).to_vec()[..]).await,
"calculate_rate_limiter_cost" => self.calculate_rate_limiter_cost(args.get(0).cloned().unwrap_or(crate::Value::Null), args.get(1).cloned().unwrap_or(crate::Value::Null), args.get(2).cloned().unwrap_or(crate::Value::Null), args.get(3).cloned().unwrap_or(crate::Value::Null), &args.get(4..).unwrap_or(&[]).to_vec()[..]),
"cancel_all_orders" => self.cancel_all_orders(&args.get(0..).unwrap_or(&[]).to_vec()[..]).await,
"cancel_order" => self.cancel_order(args.get(0).cloned().unwrap_or(crate::Value::Null), &args.get(1..).unwrap_or(&[]).to_vec()[..]).await,
"cancel_orders" => self.cancel_orders(args.get(0).cloned().unwrap_or(crate::Value::Null), &args.get(1..).unwrap_or(&[]).to_vec()[..]).await,
"create_convert_trade" => self.create_convert_trade(args.get(0).cloned().unwrap_or(crate::Value::Null), args.get(1).cloned().unwrap_or(crate::Value::Null), args.get(2).cloned().unwrap_or(crate::Value::Null), &args.get(3..).unwrap_or(&[]).to_vec()[..]).await,
"create_expired_option_market" => self.create_expired_option_market(args.get(0).cloned().unwrap_or(crate::Value::Null)),
"create_gift_code" => self.create_gift_code(args.get(0).cloned().unwrap_or(crate::Value::Null), args.get(1).cloned().unwrap_or(crate::Value::Null), &args.get(2..).unwrap_or(&[]).to_vec()[..]).await,
"create_market_buy_order_with_cost" => self.create_market_buy_order_with_cost(args.get(0).cloned().unwrap_or(crate::Value::Null), args.get(1).cloned().unwrap_or(crate::Value::Null), &args.get(2..).unwrap_or(&[]).to_vec()[..]).await,
"create_market_order_with_cost" => self.create_market_order_with_cost(args.get(0).cloned().unwrap_or(crate::Value::Null), args.get(1).cloned().unwrap_or(crate::Value::Null), args.get(2).cloned().unwrap_or(crate::Value::Null), &args.get(3..).unwrap_or(&[]).to_vec()[..]).await,
"create_market_sell_order_with_cost" => self.create_market_sell_order_with_cost(args.get(0).cloned().unwrap_or(crate::Value::Null), args.get(1).cloned().unwrap_or(crate::Value::Null), &args.get(2..).unwrap_or(&[]).to_vec()[..]).await,
"create_order" => self.create_order(args.get(0).cloned().unwrap_or(crate::Value::Null), args.get(1).cloned().unwrap_or(crate::Value::Null), args.get(2).cloned().unwrap_or(crate::Value::Null), args.get(3).cloned().unwrap_or(crate::Value::Null), &args.get(4..).unwrap_or(&[]).to_vec()[..]).await,
"create_order_request" => self.create_order_request(args.get(0).cloned().unwrap_or(crate::Value::Null), args.get(1).cloned().unwrap_or(crate::Value::Null), args.get(2).cloned().unwrap_or(crate::Value::Null), args.get(3).cloned().unwrap_or(crate::Value::Null), &args.get(4..).unwrap_or(&[]).to_vec()[..]),
"create_orders" => self.create_orders(args.get(0).cloned().unwrap_or(crate::Value::Null), &args.get(1..).unwrap_or(&[]).to_vec()[..]).await,
"edit_contract_order" => self.edit_contract_order(args.get(0).cloned().unwrap_or(crate::Value::Null), args.get(1).cloned().unwrap_or(crate::Value::Null), args.get(2).cloned().unwrap_or(crate::Value::Null), args.get(3).cloned().unwrap_or(crate::Value::Null), args.get(4).cloned().unwrap_or(crate::Value::Null), &args.get(5..).unwrap_or(&[]).to_vec()[..]).await,
"edit_contract_order_request" => self.edit_contract_order_request(args.get(0).cloned().unwrap_or(crate::Value::Null), args.get(1).cloned().unwrap_or(crate::Value::Null), args.get(2).cloned().unwrap_or(crate::Value::Null), args.get(3).cloned().unwrap_or(crate::Value::Null), args.get(4).cloned().unwrap_or(crate::Value::Null), &args.get(5..).unwrap_or(&[]).to_vec()[..]),
"edit_order" => self.edit_order(args.get(0).cloned().unwrap_or(crate::Value::Null), args.get(1).cloned().unwrap_or(crate::Value::Null), args.get(2).cloned().unwrap_or(crate::Value::Null), args.get(3).cloned().unwrap_or(crate::Value::Null), &args.get(4..).unwrap_or(&[]).to_vec()[..]).await,
"edit_orders" => self.edit_orders(args.get(0).cloned().unwrap_or(crate::Value::Null), &args.get(1..).unwrap_or(&[]).to_vec()[..]).await,
"edit_spot_order" => self.edit_spot_order(args.get(0).cloned().unwrap_or(crate::Value::Null), args.get(1).cloned().unwrap_or(crate::Value::Null), args.get(2).cloned().unwrap_or(crate::Value::Null), args.get(3).cloned().unwrap_or(crate::Value::Null), args.get(4).cloned().unwrap_or(crate::Value::Null), &args.get(5..).unwrap_or(&[]).to_vec()[..]).await,
"edit_spot_order_request" => self.edit_spot_order_request(args.get(0).cloned().unwrap_or(crate::Value::Null), args.get(1).cloned().unwrap_or(crate::Value::Null), args.get(2).cloned().unwrap_or(crate::Value::Null), args.get(3).cloned().unwrap_or(crate::Value::Null), args.get(4).cloned().unwrap_or(crate::Value::Null), &args.get(5..).unwrap_or(&[]).to_vec()[..]),
"fetch_account_positions" => self.fetch_account_positions(&args.get(0..).unwrap_or(&[]).to_vec()[..]).await,
"fetch_adl_rank" => self.fetch_adl_rank(args.get(0).cloned().unwrap_or(crate::Value::Null), &args.get(1..).unwrap_or(&[]).to_vec()[..]).await,
"fetch_all_greeks" => self.fetch_all_greeks(&args.get(0..).unwrap_or(&[]).to_vec()[..]).await,
"fetch_balance" => self.fetch_balance(&args.get(0..).unwrap_or(&[]).to_vec()[..]).await,
"fetch_bids_asks" => self.fetch_bids_asks(&args.get(0..).unwrap_or(&[]).to_vec()[..]).await,
"fetch_borrow_interest" => self.fetch_borrow_interest(&args.get(0..).unwrap_or(&[]).to_vec()[..]).await,
"fetch_borrow_rate_history" => self.fetch_borrow_rate_history(args.get(0).cloned().unwrap_or(crate::Value::Null), &args.get(1..).unwrap_or(&[]).to_vec()[..]).await,
"fetch_canceled_and_closed_orders" => self.fetch_canceled_and_closed_orders(&args.get(0..).unwrap_or(&[]).to_vec()[..]).await,
"fetch_canceled_orders" => self.fetch_canceled_orders(&args.get(0..).unwrap_or(&[]).to_vec()[..]).await,
"fetch_closed_orders" => self.fetch_closed_orders(&args.get(0..).unwrap_or(&[]).to_vec()[..]).await,
"fetch_convert_currencies" => self.fetch_convert_currencies(&args.get(0..).unwrap_or(&[]).to_vec()[..]).await,
"fetch_convert_quote" => self.fetch_convert_quote(args.get(0).cloned().unwrap_or(crate::Value::Null), args.get(1).cloned().unwrap_or(crate::Value::Null), &args.get(2..).unwrap_or(&[]).to_vec()[..]).await,
"fetch_convert_trade" => self.fetch_convert_trade(args.get(0).cloned().unwrap_or(crate::Value::Null), &args.get(1..).unwrap_or(&[]).to_vec()[..]).await,
"fetch_convert_trade_history" => self.fetch_convert_trade_history(&args.get(0..).unwrap_or(&[]).to_vec()[..]).await,
"fetch_cross_borrow_rate" => self.fetch_cross_borrow_rate(args.get(0).cloned().unwrap_or(crate::Value::Null), &args.get(1..).unwrap_or(&[]).to_vec()[..]).await,
"fetch_currencies" => self.fetch_currencies(&args.get(0..).unwrap_or(&[]).to_vec()[..]).await,
"fetch_deposit_address" => self.fetch_deposit_address(args.get(0).cloned().unwrap_or(crate::Value::Null), &args.get(1..).unwrap_or(&[]).to_vec()[..]).await,
"fetch_deposit_withdraw_fees" => self.fetch_deposit_withdraw_fees(&args.get(0..).unwrap_or(&[]).to_vec()[..]).await,
"fetch_deposits" => self.fetch_deposits(&args.get(0..).unwrap_or(&[]).to_vec()[..]).await,
"fetch_funding_history" => self.fetch_funding_history(&args.get(0..).unwrap_or(&[]).to_vec()[..]).await,
"fetch_funding_intervals" => self.fetch_funding_intervals(&args.get(0..).unwrap_or(&[]).to_vec()[..]).await,
"fetch_funding_rate" => self.fetch_funding_rate(args.get(0).cloned().unwrap_or(crate::Value::Null), &args.get(1..).unwrap_or(&[]).to_vec()[..]).await,
"fetch_funding_rate_history" => self.fetch_funding_rate_history(&args.get(0..).unwrap_or(&[]).to_vec()[..]).await,
"fetch_funding_rates" => self.fetch_funding_rates(&args.get(0..).unwrap_or(&[]).to_vec()[..]).await,
"fetch_greeks" => self.fetch_greeks(args.get(0).cloned().unwrap_or(crate::Value::Null), &args.get(1..).unwrap_or(&[]).to_vec()[..]).await,
"fetch_isolated_borrow_rate" => self.fetch_isolated_borrow_rate(args.get(0).cloned().unwrap_or(crate::Value::Null), &args.get(1..).unwrap_or(&[]).to_vec()[..]).await,
"fetch_isolated_borrow_rates" => self.fetch_isolated_borrow_rates(&args.get(0..).unwrap_or(&[]).to_vec()[..]).await,
"fetch_last_prices" => self.fetch_last_prices(&args.get(0..).unwrap_or(&[]).to_vec()[..]).await,
"fetch_ledger" => self.fetch_ledger(&args.get(0..).unwrap_or(&[]).to_vec()[..]).await,
"fetch_ledger_entry" => self.fetch_ledger_entry(args.get(0).cloned().unwrap_or(crate::Value::Null), &args.get(1..).unwrap_or(&[]).to_vec()[..]).await,
"fetch_leverage_tiers" => self.fetch_leverage_tiers(&args.get(0..).unwrap_or(&[]).to_vec()[..]).await,
"fetch_leverages" => self.fetch_leverages(&args.get(0..).unwrap_or(&[]).to_vec()[..]).await,
"fetch_long_short_ratio_history" => self.fetch_long_short_ratio_history(&args.get(0..).unwrap_or(&[]).to_vec()[..]).await,
"fetch_margin_adjustment_history" => self.fetch_margin_adjustment_history(&args.get(0..).unwrap_or(&[]).to_vec()[..]).await,
"fetch_margin_mode" => self.fetch_margin_mode(args.get(0).cloned().unwrap_or(crate::Value::Null), &args.get(1..).unwrap_or(&[]).to_vec()[..]).await,
"fetch_margin_modes" => self.fetch_margin_modes(&args.get(0..).unwrap_or(&[]).to_vec()[..]).await,
"fetch_mark_price" => self.fetch_mark_price(args.get(0).cloned().unwrap_or(crate::Value::Null), &args.get(1..).unwrap_or(&[]).to_vec()[..]).await,
"fetch_mark_prices" => self.fetch_mark_prices(&args.get(0..).unwrap_or(&[]).to_vec()[..]).await,
"fetch_markets" => self.fetch_markets(&args.get(0..).unwrap_or(&[]).to_vec()[..]).await,
"fetch_my_dust_trades" => self.fetch_my_dust_trades(&args.get(0..).unwrap_or(&[]).to_vec()[..]).await,
"fetch_my_liquidations" => self.fetch_my_liquidations(&args.get(0..).unwrap_or(&[]).to_vec()[..]).await,
"fetch_my_settlement_history" => self.fetch_my_settlement_history(&args.get(0..).unwrap_or(&[]).to_vec()[..]).await,
"fetch_my_trades" => self.fetch_my_trades(&args.get(0..).unwrap_or(&[]).to_vec()[..]).await,
"fetch_ohlcv" => self.fetch_ohlcv(args.get(0).cloned().unwrap_or(crate::Value::Null), &args.get(1..).unwrap_or(&[]).to_vec()[..]).await,
"fetch_open_interest" => self.fetch_open_interest(args.get(0).cloned().unwrap_or(crate::Value::Null), &args.get(1..).unwrap_or(&[]).to_vec()[..]).await,
"fetch_open_interest_history" => self.fetch_open_interest_history(args.get(0).cloned().unwrap_or(crate::Value::Null), &args.get(1..).unwrap_or(&[]).to_vec()[..]).await,
"fetch_open_order" => self.fetch_open_order(args.get(0).cloned().unwrap_or(crate::Value::Null), &args.get(1..).unwrap_or(&[]).to_vec()[..]).await,
"fetch_open_orders" => self.fetch_open_orders(&args.get(0..).unwrap_or(&[]).to_vec()[..]).await,
"fetch_option" => self.fetch_option(args.get(0).cloned().unwrap_or(crate::Value::Null), &args.get(1..).unwrap_or(&[]).to_vec()[..]).await,
"fetch_option_positions" => self.fetch_option_positions(&args.get(0..).unwrap_or(&[]).to_vec()[..]).await,
"fetch_order" => self.fetch_order(args.get(0).cloned().unwrap_or(crate::Value::Null), &args.get(1..).unwrap_or(&[]).to_vec()[..]).await,
"fetch_order_book" => self.fetch_order_book(args.get(0).cloned().unwrap_or(crate::Value::Null), &args.get(1..).unwrap_or(&[]).to_vec()[..]).await,
"fetch_order_trades" => self.fetch_order_trades(args.get(0).cloned().unwrap_or(crate::Value::Null), &args.get(1..).unwrap_or(&[]).to_vec()[..]).await,
"fetch_orders" => self.fetch_orders(&args.get(0..).unwrap_or(&[]).to_vec()[..]).await,
"fetch_position" => self.fetch_position(args.get(0).cloned().unwrap_or(crate::Value::Null), &args.get(1..).unwrap_or(&[]).to_vec()[..]).await,
"fetch_position_mode" => self.fetch_position_mode(&args.get(0..).unwrap_or(&[]).to_vec()[..]).await,
"fetch_positions" => self.fetch_positions(&args.get(0..).unwrap_or(&[]).to_vec()[..]).await,
"fetch_positions_adl_rank" => self.fetch_positions_adl_rank(&args.get(0..).unwrap_or(&[]).to_vec()[..]).await,
"fetch_positions_risk" => self.fetch_positions_risk(&args.get(0..).unwrap_or(&[]).to_vec()[..]).await,
"fetch_settlement_history" => self.fetch_settlement_history(&args.get(0..).unwrap_or(&[]).to_vec()[..]).await,
"fetch_status" => self.fetch_status(&args.get(0..).unwrap_or(&[]).to_vec()[..]).await,
"fetch_ticker" => self.fetch_ticker(args.get(0).cloned().unwrap_or(crate::Value::Null), &args.get(1..).unwrap_or(&[]).to_vec()[..]).await,
"fetch_tickers" => self.fetch_tickers(&args.get(0..).unwrap_or(&[]).to_vec()[..]).await,
"fetch_time" => self.fetch_time(&args.get(0..).unwrap_or(&[]).to_vec()[..]).await,
"fetch_trades" => self.fetch_trades(args.get(0).cloned().unwrap_or(crate::Value::Null), &args.get(1..).unwrap_or(&[]).to_vec()[..]).await,
"fetch_trading_fee" => self.fetch_trading_fee(args.get(0).cloned().unwrap_or(crate::Value::Null), &args.get(1..).unwrap_or(&[]).to_vec()[..]).await,
"fetch_trading_fees" => self.fetch_trading_fees(&args.get(0..).unwrap_or(&[]).to_vec()[..]).await,
"fetch_trading_limits" => self.fetch_trading_limits(&args.get(0..).unwrap_or(&[]).to_vec()[..]).await,
"fetch_transaction_fees" => self.fetch_transaction_fees(&args.get(0..).unwrap_or(&[]).to_vec()[..]).await,
"fetch_transfers" => self.fetch_transfers(&args.get(0..).unwrap_or(&[]).to_vec()[..]).await,
"fetch_withdrawals" => self.fetch_withdrawals(&args.get(0..).unwrap_or(&[]).to_vec()[..]).await,
"futures_transfer" => self.futures_transfer(args.get(0).cloned().unwrap_or(crate::Value::Null), args.get(1).cloned().unwrap_or(crate::Value::Null), args.get(2).cloned().unwrap_or(crate::Value::Null), &args.get(3..).unwrap_or(&[]).to_vec()[..]).await,
"get_base_domain_from_url" => self.get_base_domain_from_url(args.get(0).cloned().unwrap_or(crate::Value::Null)),
"get_exceptions_by_url" => self.get_exceptions_by_url(args.get(0).cloned().unwrap_or(crate::Value::Null), args.get(1).cloned().unwrap_or(crate::Value::Null)),
"get_network_code_by_network_url" => self.get_network_code_by_network_url(args.get(0).cloned().unwrap_or(crate::Value::Null), &args.get(1..).unwrap_or(&[]).to_vec()[..]),
"handle_errors" => self.handle_errors(args.get(0).cloned().unwrap_or(crate::Value::Null), args.get(1).cloned().unwrap_or(crate::Value::Null), args.get(2).cloned().unwrap_or(crate::Value::Null), args.get(3).cloned().unwrap_or(crate::Value::Null), args.get(4).cloned().unwrap_or(crate::Value::Null), args.get(5).cloned().unwrap_or(crate::Value::Null), args.get(6).cloned().unwrap_or(crate::Value::Null), args.get(7).cloned().unwrap_or(crate::Value::Null), args.get(8).cloned().unwrap_or(crate::Value::Null)),
"is_inverse" => self.is_inverse(args.get(0).cloned().unwrap_or(crate::Value::Null), &args.get(1..).unwrap_or(&[]).to_vec()[..]),
"is_linear" => self.is_linear(args.get(0).cloned().unwrap_or(crate::Value::Null), &args.get(1..).unwrap_or(&[]).to_vec()[..]),
"load_leverage_brackets" => self.load_leverage_brackets(&args.get(0..).unwrap_or(&[]).to_vec()[..]).await,
"market" => self.market(args.get(0).cloned().unwrap_or(crate::Value::Null)),
"mint_tokenized_asset" => self.mint_tokenized_asset(args.get(0).cloned().unwrap_or(crate::Value::Null), args.get(1).cloned().unwrap_or(crate::Value::Null), &args.get(2..).unwrap_or(&[]).to_vec()[..]).await,
"modify_margin_helper" => self.modify_margin_helper(args.get(0).cloned().unwrap_or(crate::Value::Null), args.get(1).cloned().unwrap_or(crate::Value::Null), args.get(2).cloned().unwrap_or(crate::Value::Null), &args.get(3..).unwrap_or(&[]).to_vec()[..]).await,
"nonce" => self.nonce(),
"parse_account_position" => self.parse_account_position(args.get(0).cloned().unwrap_or(crate::Value::Null), &args.get(1..).unwrap_or(&[]).to_vec()[..]),
"parse_account_positions" => self.parse_account_positions(args.get(0).cloned().unwrap_or(crate::Value::Null), &args.get(1..).unwrap_or(&[]).to_vec()[..]),
"parse_adl_rank" => self.parse_adl_rank(args.get(0).cloned().unwrap_or(crate::Value::Null), &args.get(1..).unwrap_or(&[]).to_vec()[..]),
"parse_balance_custom" => self.parse_balance_custom(args.get(0).cloned().unwrap_or(crate::Value::Null), &args.get(1..).unwrap_or(&[]).to_vec()[..]),
"parse_balance_helper" => self.parse_balance_helper(args.get(0).cloned().unwrap_or(crate::Value::Null)),
"parse_borrow_interest" => self.parse_borrow_interest(args.get(0).cloned().unwrap_or(crate::Value::Null), &args.get(1..).unwrap_or(&[]).to_vec()[..]),
"parse_borrow_rate" => self.parse_borrow_rate(args.get(0).cloned().unwrap_or(crate::Value::Null), &args.get(1..).unwrap_or(&[]).to_vec()[..]),
"parse_conversion" => self.parse_conversion(args.get(0).cloned().unwrap_or(crate::Value::Null), &args.get(1..).unwrap_or(&[]).to_vec()[..]),
"parse_currencies_custom" => self.parse_currencies_custom(args.get(0).cloned().unwrap_or(crate::Value::Null), args.get(1).cloned().unwrap_or(crate::Value::Null)),
"parse_currency" => self.parse_currency(args.get(0).cloned().unwrap_or(crate::Value::Null)),
"parse_deposit_address" => self.parse_deposit_address(args.get(0).cloned().unwrap_or(crate::Value::Null), &args.get(1..).unwrap_or(&[]).to_vec()[..]),
"parse_deposit_withdraw_fee" => self.parse_deposit_withdraw_fee(args.get(0).cloned().unwrap_or(crate::Value::Null), &args.get(1..).unwrap_or(&[]).to_vec()[..]),
"parse_dust_trade" => self.parse_dust_trade(args.get(0).cloned().unwrap_or(crate::Value::Null), &args.get(1..).unwrap_or(&[]).to_vec()[..]),
"parse_funding_rate" => self.parse_funding_rate(args.get(0).cloned().unwrap_or(crate::Value::Null), &args.get(1..).unwrap_or(&[]).to_vec()[..]),
"parse_funding_rate_history" => self.parse_funding_rate_history(args.get(0).cloned().unwrap_or(crate::Value::Null), &args.get(1..).unwrap_or(&[]).to_vec()[..]),
"parse_greeks" => self.parse_greeks(args.get(0).cloned().unwrap_or(crate::Value::Null), &args.get(1..).unwrap_or(&[]).to_vec()[..]),
"parse_income" => self.parse_income(args.get(0).cloned().unwrap_or(crate::Value::Null), &args.get(1..).unwrap_or(&[]).to_vec()[..]),
"parse_isolated_borrow_rate" => self.parse_isolated_borrow_rate(args.get(0).cloned().unwrap_or(crate::Value::Null), &args.get(1..).unwrap_or(&[]).to_vec()[..]),
"parse_last_price" => self.parse_last_price(args.get(0).cloned().unwrap_or(crate::Value::Null), &args.get(1..).unwrap_or(&[]).to_vec()[..]),
"parse_ledger_entry" => self.parse_ledger_entry(args.get(0).cloned().unwrap_or(crate::Value::Null), &args.get(1..).unwrap_or(&[]).to_vec()[..]),
"parse_ledger_entry_type" => self.parse_ledger_entry_type(args.get(0).cloned().unwrap_or(crate::Value::Null)),
"parse_leverage" => self.parse_leverage(args.get(0).cloned().unwrap_or(crate::Value::Null), &args.get(1..).unwrap_or(&[]).to_vec()[..]),
"parse_liquidation" => self.parse_liquidation(args.get(0).cloned().unwrap_or(crate::Value::Null), &args.get(1..).unwrap_or(&[]).to_vec()[..]),
"parse_long_short_ratio" => self.parse_long_short_ratio(args.get(0).cloned().unwrap_or(crate::Value::Null), &args.get(1..).unwrap_or(&[]).to_vec()[..]),
"parse_margin_loan" => self.parse_margin_loan(args.get(0).cloned().unwrap_or(crate::Value::Null), &args.get(1..).unwrap_or(&[]).to_vec()[..]),
"parse_margin_mode" => self.parse_margin_mode(args.get(0).cloned().unwrap_or(crate::Value::Null), &args.get(1..).unwrap_or(&[]).to_vec()[..]),
"parse_margin_modification" => self.parse_margin_modification(args.get(0).cloned().unwrap_or(crate::Value::Null), &args.get(1..).unwrap_or(&[]).to_vec()[..]),
"parse_market" => self.parse_market(args.get(0).cloned().unwrap_or(crate::Value::Null)),
"parse_market_leverage_tiers" => self.parse_market_leverage_tiers(args.get(0).cloned().unwrap_or(crate::Value::Null), &args.get(1..).unwrap_or(&[]).to_vec()[..]),
"parse_ohlcv" => self.parse_ohlcv(args.get(0).cloned().unwrap_or(crate::Value::Null), &args.get(1..).unwrap_or(&[]).to_vec()[..]),
"parse_open_interest" => self.parse_open_interest(args.get(0).cloned().unwrap_or(crate::Value::Null), &args.get(1..).unwrap_or(&[]).to_vec()[..]),
"parse_option" => self.parse_option(args.get(0).cloned().unwrap_or(crate::Value::Null), &args.get(1..).unwrap_or(&[]).to_vec()[..]),
"parse_option_position" => self.parse_option_position(args.get(0).cloned().unwrap_or(crate::Value::Null), &args.get(1..).unwrap_or(&[]).to_vec()[..]),
"parse_order" => self.parse_order(args.get(0).cloned().unwrap_or(crate::Value::Null), &args.get(1..).unwrap_or(&[]).to_vec()[..]),
"parse_order_status" => self.parse_order_status(args.get(0).cloned().unwrap_or(crate::Value::Null)),
"parse_order_type_by_market" => self.parse_order_type_by_market(args.get(0).cloned().unwrap_or(crate::Value::Null), args.get(1).cloned().unwrap_or(crate::Value::Null)),
"parse_position_risk" => self.parse_position_risk(args.get(0).cloned().unwrap_or(crate::Value::Null), &args.get(1..).unwrap_or(&[]).to_vec()[..]),
"parse_settlement" => self.parse_settlement(args.get(0).cloned().unwrap_or(crate::Value::Null), args.get(1).cloned().unwrap_or(crate::Value::Null)),
"parse_settlements" => self.parse_settlements(args.get(0).cloned().unwrap_or(crate::Value::Null), args.get(1).cloned().unwrap_or(crate::Value::Null)),
"parse_ticker" => self.parse_ticker(args.get(0).cloned().unwrap_or(crate::Value::Null), &args.get(1..).unwrap_or(&[]).to_vec()[..]),
"parse_tickers_for_rolling" => self.parse_tickers_for_rolling(args.get(0).cloned().unwrap_or(crate::Value::Null), args.get(1).cloned().unwrap_or(crate::Value::Null)),
"parse_trade" => self.parse_trade(args.get(0).cloned().unwrap_or(crate::Value::Null), &args.get(1..).unwrap_or(&[]).to_vec()[..]),
"parse_trading_fee" => self.parse_trading_fee(args.get(0).cloned().unwrap_or(crate::Value::Null), &args.get(1..).unwrap_or(&[]).to_vec()[..]),
"parse_transaction" => self.parse_transaction(args.get(0).cloned().unwrap_or(crate::Value::Null), &args.get(1..).unwrap_or(&[]).to_vec()[..]),
"parse_transaction_status_by_type" => self.parse_transaction_status_by_type(args.get(0).cloned().unwrap_or(crate::Value::Null), &args.get(1..).unwrap_or(&[]).to_vec()[..]),
"parse_transfer" => self.parse_transfer(args.get(0).cloned().unwrap_or(crate::Value::Null), &args.get(1..).unwrap_or(&[]).to_vec()[..]),
"parse_transfer_status" => self.parse_transfer_status(args.get(0).cloned().unwrap_or(crate::Value::Null)),
"redeem_gift_code" => self.redeem_gift_code(args.get(0).cloned().unwrap_or(crate::Value::Null), &args.get(1..).unwrap_or(&[]).to_vec()[..]).await,
"redeem_tokenized_asset" => self.redeem_tokenized_asset(args.get(0).cloned().unwrap_or(crate::Value::Null), args.get(1).cloned().unwrap_or(crate::Value::Null), &args.get(2..).unwrap_or(&[]).to_vec()[..]).await,
"reduce_margin" => self.reduce_margin(args.get(0).cloned().unwrap_or(crate::Value::Null), args.get(1).cloned().unwrap_or(crate::Value::Null), &args.get(2..).unwrap_or(&[]).to_vec()[..]).await,
"repay_cross_margin" => self.repay_cross_margin(args.get(0).cloned().unwrap_or(crate::Value::Null), args.get(1).cloned().unwrap_or(crate::Value::Null), &args.get(2..).unwrap_or(&[]).to_vec()[..]).await,
"repay_isolated_margin" => self.repay_isolated_margin(args.get(0).cloned().unwrap_or(crate::Value::Null), args.get(1).cloned().unwrap_or(crate::Value::Null), args.get(2).cloned().unwrap_or(crate::Value::Null), &args.get(3..).unwrap_or(&[]).to_vec()[..]).await,
"request" => self.request(args.get(0).cloned().unwrap_or(crate::Value::Null), &args.get(1..).unwrap_or(&[]).to_vec()[..]).await,
"safe_market" => self.safe_market(&args.get(0..).unwrap_or(&[]).to_vec()[..]),
"set_leverage" => self.set_leverage(args.get(0).cloned().unwrap_or(crate::Value::Null), &args.get(1..).unwrap_or(&[]).to_vec()[..]).await,
"set_margin_mode" => self.set_margin_mode(args.get(0).cloned().unwrap_or(crate::Value::Null), &args.get(1..).unwrap_or(&[]).to_vec()[..]).await,
"set_position_mode" => self.set_position_mode(args.get(0).cloned().unwrap_or(crate::Value::Null), &args.get(1..).unwrap_or(&[]).to_vec()[..]).await,
"sign" => self.sign(args.get(0).cloned().unwrap_or(crate::Value::Null), &args.get(1..).unwrap_or(&[]).to_vec()[..]),
"tokenized_convert_history" => self.tokenized_convert_history(&args.get(0..).unwrap_or(&[]).to_vec()[..]).await,
"tokenized_convert_status" => self.tokenized_convert_status(args.get(0).cloned().unwrap_or(crate::Value::Null), args.get(1).cloned().unwrap_or(crate::Value::Null), &args.get(2..).unwrap_or(&[]).to_vec()[..]).await,
"transfer" => self.transfer(args.get(0).cloned().unwrap_or(crate::Value::Null), args.get(1).cloned().unwrap_or(crate::Value::Null), args.get(2).cloned().unwrap_or(crate::Value::Null), args.get(3).cloned().unwrap_or(crate::Value::Null), &args.get(4..).unwrap_or(&[]).to_vec()[..]).await,
"verify_gift_code" => self.verify_gift_code(args.get(0).cloned().unwrap_or(crate::Value::Null), &args.get(1..).unwrap_or(&[]).to_vec()[..]).await,
"withdraw" => self.withdraw(args.get(0).cloned().unwrap_or(crate::Value::Null), args.get(1).cloned().unwrap_or(crate::Value::Null), args.get(2).cloned().unwrap_or(crate::Value::Null), &args.get(3..).unwrap_or(&[]).to_vec()[..]).await,
// Fall through to the base-only methods (cancelOrderWithClientOrderId, …).
_ => self.call_dynamic_base(method, args).await,
}
})
}
}
impl std::ops::Deref for BinanceCore {
type Target = crate::exchange::Exchange;
fn deref(&self) -> &crate::exchange::Exchange { &self.exchange }
}
impl std::ops::DerefMut for BinanceCore {
fn deref_mut(&mut self) -> &mut crate::exchange::Exchange { &mut self.exchange }
}
impl BinanceCore {
pub fn describe(&self) -> Value {
return self.deep_extend(self.super_describe(), &[Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("id".to_string(), Value::Str("binance".to_string()));
m.insert("name".to_string(), Value::Str("Binance".to_string()));
m.insert("countries".to_string(), Value::List(vec![]));
m.insert("rateLimit".to_string(), Value::Int(50));
m.insert("certified".to_string(), Value::Bool(true));
m.insert("pro".to_string(), Value::Bool(true));
m.insert("has".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("CORS".to_string(), Value::Null);
m.insert("spot".to_string(), Value::Bool(true));
m.insert("margin".to_string(), Value::Bool(true));
m.insert("swap".to_string(), Value::Bool(true));
m.insert("future".to_string(), Value::Bool(true));
m.insert("option".to_string(), Value::Bool(true));
m.insert("addMargin".to_string(), Value::Bool(true));
m.insert("borrowCrossMargin".to_string(), Value::Bool(true));
m.insert("borrowIsolatedMargin".to_string(), Value::Bool(true));
m.insert("cancelAllOrders".to_string(), Value::Bool(true));
m.insert("cancelOrder".to_string(), Value::Bool(true));
m.insert("cancelOrders".to_string(), Value::Bool(true));
m.insert("closeAllPositions".to_string(), Value::Bool(false));
m.insert("closePosition".to_string(), Value::Bool(false));
m.insert("createConvertTrade".to_string(), Value::Bool(true));
m.insert("createDepositAddress".to_string(), Value::Bool(false));
m.insert("createLimitBuyOrder".to_string(), Value::Bool(true));
m.insert("createLimitSellOrder".to_string(), Value::Bool(true));
m.insert("createMarketBuyOrder".to_string(), Value::Bool(true));
m.insert("createMarketBuyOrderWithCost".to_string(), Value::Bool(true));
m.insert("createMarketOrderWithCost".to_string(), Value::Bool(true));
m.insert("createMarketSellOrder".to_string(), Value::Bool(true));
m.insert("createMarketSellOrderWithCost".to_string(), Value::Bool(true));
m.insert("createOrder".to_string(), Value::Bool(true));
m.insert("createOrders".to_string(), Value::Bool(true));
m.insert("createOrderWithTakeProfitAndStopLoss".to_string(), Value::Bool(false));
m.insert("createPostOnlyOrder".to_string(), Value::Bool(true));
m.insert("createReduceOnlyOrder".to_string(), Value::Bool(true));
m.insert("createStopLimitOrder".to_string(), Value::Bool(true));
m.insert("createStopLossOrder".to_string(), Value::Bool(true));
m.insert("createStopMarketOrder".to_string(), Value::Bool(false));
m.insert("createStopOrder".to_string(), Value::Bool(true));
m.insert("createTakeProfitOrder".to_string(), Value::Bool(true));
m.insert("createTrailingPercentOrder".to_string(), Value::Bool(true));
m.insert("createTriggerOrder".to_string(), Value::Bool(true));
m.insert("editOrder".to_string(), Value::Bool(true));
m.insert("editOrders".to_string(), Value::Bool(true));
m.insert("fetchAccounts".to_string(), Value::Null);
m.insert("fetchADLRank".to_string(), Value::Bool(true));
m.insert("fetchAllGreeks".to_string(), Value::Bool(true));
m.insert("fetchBalance".to_string(), Value::Bool(true));
m.insert("fetchBidsAsks".to_string(), Value::Bool(true));
m.insert("fetchBorrowInterest".to_string(), Value::Bool(true));
m.insert("fetchBorrowRateHistories".to_string(), Value::Bool(false));
m.insert("fetchBorrowRateHistory".to_string(), Value::Bool(true));
m.insert("fetchCanceledAndClosedOrders".to_string(), Value::Str("emulated".to_string()));
m.insert("fetchCanceledOrders".to_string(), Value::Str("emulated".to_string()));
m.insert("fetchClosedOrder".to_string(), Value::Bool(false));
m.insert("fetchClosedOrders".to_string(), Value::Str("emulated".to_string()));
m.insert("fetchConvertCurrencies".to_string(), Value::Bool(true));
m.insert("fetchConvertQuote".to_string(), Value::Bool(true));
m.insert("fetchConvertTrade".to_string(), Value::Bool(true));
m.insert("fetchConvertTradeHistory".to_string(), Value::Bool(true));
m.insert("fetchCrossBorrowRate".to_string(), Value::Bool(true));
m.insert("fetchCrossBorrowRates".to_string(), Value::Bool(false));
m.insert("fetchCurrencies".to_string(), Value::Bool(true));
m.insert("fetchDeposit".to_string(), Value::Bool(false));
m.insert("fetchDepositAddress".to_string(), Value::Bool(true));
m.insert("fetchDepositAddresses".to_string(), Value::Bool(false));
m.insert("fetchDepositAddressesByNetwork".to_string(), Value::Bool(false));
m.insert("fetchDeposits".to_string(), Value::Bool(true));
m.insert("fetchDepositsWithdrawals".to_string(), Value::Bool(false));
m.insert("fetchDepositWithdrawFee".to_string(), Value::Str("emulated".to_string()));
m.insert("fetchDepositWithdrawFees".to_string(), Value::Bool(true));
m.insert("fetchFundingHistory".to_string(), Value::Bool(true));
m.insert("fetchFundingInterval".to_string(), Value::Str("emulated".to_string()));
m.insert("fetchFundingIntervals".to_string(), Value::Bool(true));
m.insert("fetchFundingRate".to_string(), Value::Bool(true));
m.insert("fetchFundingRateHistory".to_string(), Value::Bool(true));
m.insert("fetchFundingRates".to_string(), Value::Bool(true));
m.insert("fetchGreeks".to_string(), Value::Bool(true));
m.insert("fetchIndexOHLCV".to_string(), Value::Bool(true));
m.insert("fetchIsolatedBorrowRate".to_string(), Value::Str("emulated".to_string()));
m.insert("fetchIsolatedBorrowRates".to_string(), Value::Bool(true));
m.insert("fetchL3OrderBook".to_string(), Value::Bool(false));
m.insert("fetchLastPrices".to_string(), Value::Bool(true));
m.insert("fetchLedger".to_string(), Value::Bool(true));
m.insert("fetchLedgerEntry".to_string(), Value::Bool(true));
m.insert("fetchLeverage".to_string(), Value::Str("emulated".to_string()));
m.insert("fetchLeverages".to_string(), Value::Bool(true));
m.insert("fetchLeverageTiers".to_string(), Value::Bool(true));
m.insert("fetchLiquidations".to_string(), Value::Bool(false));
m.insert("fetchLongShortRatio".to_string(), Value::Bool(false));
m.insert("fetchLongShortRatioHistory".to_string(), Value::Bool(true));
m.insert("fetchMarginAdjustmentHistory".to_string(), Value::Bool(true));
m.insert("fetchMarginMode".to_string(), Value::Bool(true));
m.insert("fetchMarginModes".to_string(), Value::Bool(true));
m.insert("fetchMarketLeverageTiers".to_string(), Value::Str("emulated".to_string()));
m.insert("fetchMarkets".to_string(), Value::Bool(true));
m.insert("fetchMarkOHLCV".to_string(), Value::Bool(true));
m.insert("fetchMarkPrice".to_string(), Value::Bool(true));
m.insert("fetchMarkPrices".to_string(), Value::Bool(true));
m.insert("fetchMyLiquidations".to_string(), Value::Bool(true));
m.insert("fetchMySettlementHistory".to_string(), Value::Bool(true));
m.insert("fetchMyTrades".to_string(), Value::Bool(true));
m.insert("fetchOHLCV".to_string(), Value::Bool(true));
m.insert("fetchOpenInterest".to_string(), Value::Bool(true));
m.insert("fetchOpenInterestHistory".to_string(), Value::Bool(true));
m.insert("fetchOpenOrder".to_string(), Value::Bool(true));
m.insert("fetchOpenOrders".to_string(), Value::Bool(true));
m.insert("fetchOption".to_string(), Value::Bool(true));
m.insert("fetchOptionChain".to_string(), Value::Bool(false));
m.insert("fetchOrder".to_string(), Value::Bool(true));
m.insert("fetchOrderBook".to_string(), Value::Bool(true));
m.insert("fetchOrderBooks".to_string(), Value::Bool(false));
m.insert("fetchOrders".to_string(), Value::Bool(true));
m.insert("fetchOrderTrades".to_string(), Value::Bool(true));
m.insert("fetchPosition".to_string(), Value::Bool(true));
m.insert("fetchPositionADLRank".to_string(), Value::Bool(true));
m.insert("fetchPositionHistory".to_string(), Value::Bool(false));
m.insert("fetchPositionMode".to_string(), Value::Bool(true));
m.insert("fetchPositions".to_string(), Value::Bool(true));
m.insert("fetchPositionsADLRank".to_string(), Value::Bool(true));
m.insert("fetchPositionsHistory".to_string(), Value::Bool(false));
m.insert("fetchPositionsRisk".to_string(), Value::Bool(true));
m.insert("fetchPremiumIndexOHLCV".to_string(), Value::Bool(true));
m.insert("fetchSettlementHistory".to_string(), Value::Bool(true));
m.insert("fetchStatus".to_string(), Value::Bool(true));
m.insert("fetchTicker".to_string(), Value::Bool(true));
m.insert("fetchTickers".to_string(), Value::Bool(true));
m.insert("fetchTime".to_string(), Value::Bool(true));
m.insert("fetchTrades".to_string(), Value::Bool(true));
m.insert("fetchTradingFee".to_string(), Value::Bool(true));
m.insert("fetchTradingFees".to_string(), Value::Bool(true));
m.insert("fetchTradingLimits".to_string(), Value::Str("emulated".to_string()));
m.insert("fetchTransactionFee".to_string(), Value::Str("emulated".to_string()));
m.insert("fetchTransactionFees".to_string(), Value::Bool(true));
m.insert("fetchTransactions".to_string(), Value::Bool(false));
m.insert("fetchTransfer".to_string(), Value::Bool(false));
m.insert("fetchTransfers".to_string(), Value::Bool(true));
m.insert("fetchUnderlyingAssets".to_string(), Value::Bool(false));
m.insert("fetchVolatilityHistory".to_string(), Value::Bool(false));
m.insert("fetchWithdrawAddresses".to_string(), Value::Bool(false));
m.insert("fetchWithdrawal".to_string(), Value::Bool(false));
m.insert("fetchWithdrawals".to_string(), Value::Bool(true));
m.insert("fetchWithdrawalWhitelist".to_string(), Value::Bool(false));
m.insert("reduceMargin".to_string(), Value::Bool(true));
m.insert("repayCrossMargin".to_string(), Value::Bool(true));
m.insert("repayIsolatedMargin".to_string(), Value::Bool(true));
m.insert("sandbox".to_string(), Value::Bool(true));
m.insert("setLeverage".to_string(), Value::Bool(true));
m.insert("setMargin".to_string(), Value::Bool(false));
m.insert("setMarginMode".to_string(), Value::Bool(true));
m.insert("setPositionMode".to_string(), Value::Bool(true));
m.insert("signIn".to_string(), Value::Bool(false));
m.insert("transfer".to_string(), Value::Bool(true));
m.insert("withdraw".to_string(), Value::Bool(true));
m
}));
m.insert("timeframes".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("1s".to_string(), Value::Str("1s".to_string()));
m.insert("1m".to_string(), Value::Str("1m".to_string()));
m.insert("3m".to_string(), Value::Str("3m".to_string()));
m.insert("5m".to_string(), Value::Str("5m".to_string()));
m.insert("15m".to_string(), Value::Str("15m".to_string()));
m.insert("30m".to_string(), Value::Str("30m".to_string()));
m.insert("1h".to_string(), Value::Str("1h".to_string()));
m.insert("2h".to_string(), Value::Str("2h".to_string()));
m.insert("4h".to_string(), Value::Str("4h".to_string()));
m.insert("6h".to_string(), Value::Str("6h".to_string()));
m.insert("8h".to_string(), Value::Str("8h".to_string()));
m.insert("12h".to_string(), Value::Str("12h".to_string()));
m.insert("1d".to_string(), Value::Str("1d".to_string()));
m.insert("3d".to_string(), Value::Str("3d".to_string()));
m.insert("1w".to_string(), Value::Str("1w".to_string()));
m.insert("1M".to_string(), Value::Str("1M".to_string()));
m
}));
m.insert("urls".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("logo".to_string(), Value::Str("https://github.com/user-attachments/assets/e9419b93-ccb0-46aa-9bff-c883f096274b".to_string()));
m.insert("test".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("dapiPublic".to_string(), Value::Str("https://testnet.binancefuture.com/dapi/v1".to_string()));
m.insert("dapiPrivate".to_string(), Value::Str("https://testnet.binancefuture.com/dapi/v1".to_string()));
m.insert("dapiPrivateV2".to_string(), Value::Str("https://testnet.binancefuture.com/dapi/v2".to_string()));
m.insert("fapiPublic".to_string(), Value::Str("https://testnet.binancefuture.com/fapi/v1".to_string()));
m.insert("fapiPublicV2".to_string(), Value::Str("https://testnet.binancefuture.com/fapi/v2".to_string()));
m.insert("fapiPublicV3".to_string(), Value::Str("https://testnet.binancefuture.com/fapi/v3".to_string()));
m.insert("fapiPrivate".to_string(), Value::Str("https://testnet.binancefuture.com/fapi/v1".to_string()));
m.insert("fapiPrivateV2".to_string(), Value::Str("https://testnet.binancefuture.com/fapi/v2".to_string()));
m.insert("fapiPrivateV3".to_string(), Value::Str("https://testnet.binancefuture.com/fapi/v3".to_string()));
m.insert("public".to_string(), Value::Str("https://testnet.binance.vision/api/v3".to_string()));
m.insert("private".to_string(), Value::Str("https://testnet.binance.vision/api/v3".to_string()));
m.insert("v1".to_string(), Value::Str("https://testnet.binance.vision/api/v1".to_string()));
m
}));
m.insert("demo".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("dapiPublic".to_string(), Value::Str("https://demo-dapi.binance.com/dapi/v1".to_string()));
m.insert("dapiPrivate".to_string(), Value::Str("https://demo-dapi.binance.com/dapi/v1".to_string()));
m.insert("dapiPrivateV2".to_string(), Value::Str("https://demo-dapi.binance.com/dapi/v2".to_string()));
m.insert("fapiPublic".to_string(), Value::Str("https://demo-fapi.binance.com/fapi/v1".to_string()));
m.insert("fapiPublicV2".to_string(), Value::Str("https://demo-fapi.binance.com/fapi/v2".to_string()));
m.insert("fapiPublicV3".to_string(), Value::Str("https://demo-fapi.binance.com/fapi/v3".to_string()));
m.insert("fapiPrivate".to_string(), Value::Str("https://demo-fapi.binance.com/fapi/v1".to_string()));
m.insert("fapiPrivateV2".to_string(), Value::Str("https://demo-fapi.binance.com/fapi/v2".to_string()));
m.insert("fapiPrivateV3".to_string(), Value::Str("https://demo-fapi.binance.com/fapi/v3".to_string()));
m.insert("public".to_string(), Value::Str("https://demo-api.binance.com/api/v3".to_string()));
m.insert("private".to_string(), Value::Str("https://demo-api.binance.com/api/v3".to_string()));
m.insert("v1".to_string(), Value::Str("https://demo-api.binance.com/api/v1".to_string()));
m
}));
m.insert("api".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("sapi".to_string(), Value::Str("https://api.binance.com/sapi/v1".to_string()));
m.insert("sapiV2".to_string(), Value::Str("https://api.binance.com/sapi/v2".to_string()));
m.insert("sapiV3".to_string(), Value::Str("https://api.binance.com/sapi/v3".to_string()));
m.insert("sapiV4".to_string(), Value::Str("https://api.binance.com/sapi/v4".to_string()));
m.insert("dapiPublic".to_string(), Value::Str("https://dapi.binance.com/dapi/v1".to_string()));
m.insert("dapiPrivate".to_string(), Value::Str("https://dapi.binance.com/dapi/v1".to_string()));
m.insert("eapiPublic".to_string(), Value::Str("https://eapi.binance.com/eapi/v1".to_string()));
m.insert("eapiPrivate".to_string(), Value::Str("https://eapi.binance.com/eapi/v1".to_string()));
m.insert("dapiPrivateV2".to_string(), Value::Str("https://dapi.binance.com/dapi/v2".to_string()));
m.insert("dapiData".to_string(), Value::Str("https://dapi.binance.com/futures/data".to_string()));
m.insert("fapiPublic".to_string(), Value::Str("https://fapi.binance.com/fapi/v1".to_string()));
m.insert("fapiPublicV2".to_string(), Value::Str("https://fapi.binance.com/fapi/v2".to_string()));
m.insert("fapiPublicV3".to_string(), Value::Str("https://fapi.binance.com/fapi/v3".to_string()));
m.insert("fapiPrivate".to_string(), Value::Str("https://fapi.binance.com/fapi/v1".to_string()));
m.insert("fapiPrivateV2".to_string(), Value::Str("https://fapi.binance.com/fapi/v2".to_string()));
m.insert("fapiPrivateV3".to_string(), Value::Str("https://fapi.binance.com/fapi/v3".to_string()));
m.insert("fapiData".to_string(), Value::Str("https://fapi.binance.com/futures/data".to_string()));
m.insert("public".to_string(), Value::Str("https://api.binance.com/api/v3".to_string()));
m.insert("private".to_string(), Value::Str("https://api.binance.com/api/v3".to_string()));
m.insert("v1".to_string(), Value::Str("https://api.binance.com/api/v1".to_string()));
m.insert("papi".to_string(), Value::Str("https://papi.binance.com/papi/v1".to_string()));
m.insert("papiV2".to_string(), Value::Str("https://papi.binance.com/papi/v2".to_string()));
m
}));
m.insert("www".to_string(), Value::Str("https://www.binance.com".to_string()));
m.insert("referral".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("url".to_string(), Value::Str("https://accounts.binance.com/register?ref=CCXTCOM".to_string()));
m.insert("discount".to_string(), Value::Float(0.1));
m
}));
m.insert("doc".to_string(), Value::List(vec![Value::Str("https://developers.binance.com/en".to_string())]));
m.insert("api_management".to_string(), Value::Str("https://www.binance.com/en/usercenter/settings/api-management".to_string()));
m.insert("fees".to_string(), Value::Str("https://www.binance.com/en/fee/schedule".to_string()));
m
}));
m.insert("api".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("sapi".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("get".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("copyTrading/futures/userStatus".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(2));
m
}));
m.insert("copyTrading/futures/leadSymbol".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(2));
m
}));
m.insert("system/status".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Float(0.1));
m
}));
m.insert("accountSnapshot".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(240));
m
}));
m.insert("account/info".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Float(0.1));
m
}));
m.insert("margin/asset".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(1));
m
}));
m.insert("margin/pair".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(1));
m
}));
m.insert("margin/allAssets".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Float(0.1));
m
}));
m.insert("margin/allPairs".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Float(0.1));
m
}));
m.insert("margin/priceIndex".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(1));
m
}));
m.insert("spot/delist-schedule".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(10));
m
}));
m.insert("asset/assetDividend".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(1));
m
}));
m.insert("asset/dribblet".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Float(0.1));
m
}));
m.insert("asset/transfer".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Float(0.1));
m
}));
m.insert("asset/assetDetail".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Float(0.1));
m
}));
m.insert("asset/tradeFee".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Float(0.1));
m
}));
m.insert("asset/ledger-transfer/cloud-mining/queryByPage".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Float(4.0002));
m
}));
m.insert("asset/convert-transfer/queryByPage".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Float(0.033335));
m
}));
m.insert("asset/wallet/balance".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(6));
m
}));
m.insert("asset/custody/transfer-history".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(6));
m
}));
m.insert("margin/borrow-repay".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(1));
m
}));
m.insert("margin/loan".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(1));
m
}));
m.insert("margin/repay".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(1));
m
}));
m.insert("margin/account".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(1));
m
}));
m.insert("margin/transfer".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Float(0.1));
m
}));
m.insert("margin/interestHistory".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Float(0.1));
m
}));
m.insert("margin/forceLiquidationRec".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Float(0.1));
m
}));
m.insert("margin/order".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(1));
m
}));
m.insert("margin/openOrders".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(1));
m
}));
m.insert("margin/allOrders".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(20));
m
}));
m.insert("margin/myTrades".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(1));
m
}));
m.insert("margin/maxBorrowable".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(5));
m
}));
m.insert("margin/maxTransferable".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(5));
m
}));
m.insert("margin/tradeCoeff".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(1));
m
}));
m.insert("margin/isolated/transfer".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Float(0.1));
m
}));
m.insert("margin/isolated/account".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(1));
m
}));
m.insert("margin/isolated/pair".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(1));
m
}));
m.insert("margin/isolated/allPairs".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(1));
m
}));
m.insert("margin/isolated/accountLimit".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Float(0.1));
m
}));
m.insert("margin/interestRateHistory".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Float(0.1));
m
}));
m.insert("margin/orderList".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(1));
m
}));
m.insert("margin/allOrderList".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(20));
m
}));
m.insert("margin/openOrderList".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(1));
m
}));
m.insert("margin/crossMarginData".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Float(0.1));
m.insert("noCoin".to_string(), Value::Float(0.5));
m
}));
m.insert("margin/isolatedMarginData".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Float(0.1));
m.insert("noCoin".to_string(), Value::Int(1));
m
}));
m.insert("margin/isolatedMarginTier".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Float(0.1));
m
}));
m.insert("margin/rateLimit/order".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(2));
m
}));
m.insert("margin/dribblet".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Float(0.1));
m
}));
m.insert("margin/dust".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Float(20.001));
m
}));
m.insert("margin/crossMarginCollateralRatio".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(10));
m
}));
m.insert("margin/exchange-small-liability".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Float(0.6667));
m
}));
m.insert("margin/exchange-small-liability-history".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Float(0.6667));
m
}));
m.insert("margin/next-hourly-interest-rate".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Float(0.6667));
m
}));
m.insert("margin/capital-flow".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(10));
m
}));
m.insert("margin/delist-schedule".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(10));
m
}));
m.insert("margin/available-inventory".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Float(0.3334));
m
}));
m.insert("margin/leverageBracket".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Float(0.1));
m
}));
m.insert("loan/vip/loanable/data".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(40));
m
}));
m.insert("loan/vip/collateral/data".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(40));
m
}));
m.insert("loan/vip/request/data".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Float(2.6668));
m
}));
m.insert("loan/vip/request/interestRate".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Float(2.6668));
m
}));
m.insert("loan/income".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Float(40.002));
m
}));
m.insert("loan/ongoing/orders".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(40));
m
}));
m.insert("loan/ltv/adjustment/history".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(40));
m
}));
m.insert("loan/borrow/history".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(40));
m
}));
m.insert("loan/repay/history".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(40));
m
}));
m.insert("loan/loanable/data".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(40));
m
}));
m.insert("loan/collateral/data".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(40));
m
}));
m.insert("loan/repay/collateral/rate".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(600));
m
}));
m.insert("loan/flexible/ongoing/orders".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(30));
m
}));
m.insert("loan/flexible/borrow/history".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(40));
m
}));
m.insert("loan/flexible/repay/history".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(40));
m
}));
m.insert("loan/flexible/ltv/adjustment/history".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(40));
m
}));
m.insert("loan/vip/ongoing/orders".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(40));
m
}));
m.insert("loan/vip/repay/history".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(40));
m
}));
m.insert("loan/vip/collateral/account".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(600));
m
}));
m.insert("fiat/orders".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Float(600.03));
m
}));
m.insert("fiat/payments".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Float(0.1));
m
}));
m.insert("futures/transfer".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(1));
m
}));
m.insert("futures/histDataLink".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Float(0.1));
m
}));
m.insert("rebate/taxQuery".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Float(80.004));
m
}));
m.insert("capital/config/getall".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(1));
m
}));
m.insert("capital/deposit/address".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(1));
m
}));
m.insert("capital/deposit/address/list".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(1));
m
}));
m.insert("capital/deposit/hisrec".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Float(0.1));
m
}));
m.insert("capital/deposit/subAddress".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Float(0.1));
m
}));
m.insert("capital/deposit/subHisrec".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Float(0.1));
m
}));
m.insert("capital/withdraw/history".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(2));
m
}));
m.insert("capital/withdraw/address/list".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(10));
m
}));
m.insert("capital/contract/convertible-coins".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Float(4.0002));
m
}));
m.insert("convert/tradeFlow".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Float(20.001));
m
}));
m.insert("convert/exchangeInfo".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(50));
m
}));
m.insert("convert/assetInfo".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(10));
m
}));
m.insert("convert/orderStatus".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Float(0.6667));
m
}));
m.insert("convert/limit/queryOpenOrders".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Float(20.001));
m
}));
m.insert("account/status".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Float(0.1));
m
}));
m.insert("account/apiTradingStatus".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Float(0.1));
m
}));
m.insert("account/apiRestrictions/ipRestriction".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Float(0.1));
m
}));
m.insert("bnbBurn".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Float(0.1));
m
}));
m.insert("sub-account/futures/account".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(1));
m
}));
m.insert("sub-account/futures/accountSummary".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Float(0.1));
m
}));
m.insert("sub-account/futures/positionRisk".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(1));
m
}));
m.insert("sub-account/futures/internalTransfer".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Float(0.1));
m
}));
m.insert("sub-account/list".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Float(0.1));
m
}));
m.insert("sub-account/margin/account".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(1));
m
}));
m.insert("sub-account/margin/accountSummary".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(1));
m
}));
m.insert("sub-account/spotSummary".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Float(0.1));
m
}));
m.insert("sub-account/status".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(1));
m
}));
m.insert("sub-account/sub/transfer/history".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Float(0.1));
m
}));
m.insert("sub-account/transfer/subUserHistory".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Float(0.1));
m
}));
m.insert("sub-account/universalTransfer".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Float(0.1));
m
}));
m.insert("sub-account/apiRestrictions/ipRestriction/thirdPartyList".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(1));
m
}));
m.insert("sub-account/transaction-statistics".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Float(0.40002));
m
}));
m.insert("sub-account/subAccountApi/ipRestriction".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Float(20.001));
m
}));
m.insert("managed-subaccount/asset".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Float(0.1));
m
}));
m.insert("managed-subaccount/accountSnapshot".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(240));
m
}));
m.insert("managed-subaccount/queryTransLogForInvestor".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Float(0.1));
m
}));
m.insert("managed-subaccount/queryTransLogForTradeParent".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Float(0.40002));
m
}));
m.insert("managed-subaccount/fetch-future-asset".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Float(0.40002));
m
}));
m.insert("managed-subaccount/marginAsset".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Float(0.1));
m
}));
m.insert("managed-subaccount/info".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Float(0.40002));
m
}));
m.insert("managed-subaccount/deposit/address".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Float(0.006667));
m
}));
m.insert("managed-subaccount/query-trans-log".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Float(0.40002));
m
}));
m.insert("lending/daily/product/list".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Float(0.1));
m
}));
m.insert("lending/daily/userLeftQuota".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Float(0.1));
m
}));
m.insert("lending/daily/userRedemptionQuota".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Float(0.1));
m
}));
m.insert("lending/daily/token/position".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Float(0.1));
m
}));
m.insert("lending/union/account".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Float(0.1));
m
}));
m.insert("lending/union/purchaseRecord".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Float(0.1));
m
}));
m.insert("lending/union/redemptionRecord".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Float(0.1));
m
}));
m.insert("lending/union/interestHistory".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Float(0.1));
m
}));
m.insert("lending/project/list".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Float(0.1));
m
}));
m.insert("lending/project/position/list".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Float(0.1));
m
}));
m.insert("eth-staking/eth/history/stakingHistory".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(15));
m
}));
m.insert("eth-staking/eth/history/redemptionHistory".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(15));
m
}));
m.insert("eth-staking/eth/history/rewardsHistory".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(15));
m
}));
m.insert("eth-staking/eth/quota".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(15));
m
}));
m.insert("eth-staking/eth/history/rateHistory".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(15));
m
}));
m.insert("eth-staking/account".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(15));
m
}));
m.insert("eth-staking/wbeth/history/wrapHistory".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(15));
m
}));
m.insert("eth-staking/wbeth/history/unwrapHistory".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(15));
m
}));
m.insert("eth-staking/eth/history/wbethRewardsHistory".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(15));
m
}));
m.insert("sol-staking/sol/history/stakingHistory".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(15));
m
}));
m.insert("sol-staking/sol/history/redemptionHistory".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(15));
m
}));
m.insert("sol-staking/sol/history/bnsolRewardsHistory".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(15));
m
}));
m.insert("sol-staking/sol/history/rateHistory".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(15));
m
}));
m.insert("sol-staking/account".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(15));
m
}));
m.insert("sol-staking/sol/quota".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(15));
m
}));
m.insert("mining/pub/algoList".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Float(0.1));
m
}));
m.insert("mining/pub/coinList".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Float(0.1));
m
}));
m.insert("mining/worker/detail".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Float(0.5));
m
}));
m.insert("mining/worker/list".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Float(0.5));
m
}));
m.insert("mining/payment/list".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Float(0.5));
m
}));
m.insert("mining/statistics/user/status".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Float(0.5));
m
}));
m.insert("mining/statistics/user/list".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Float(0.5));
m
}));
m.insert("mining/payment/uid".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Float(0.5));
m
}));
m.insert("bswap/pools".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Float(0.1));
m
}));
m.insert("bswap/liquidity".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Float(0.1));
m.insert("noPoolId".to_string(), Value::Int(1));
m
}));
m.insert("bswap/liquidityOps".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Float(20.001));
m
}));
m.insert("bswap/quote".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Float(1.00005));
m
}));
m.insert("bswap/swap".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Float(20.001));
m
}));
m.insert("bswap/poolConfigure".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Float(1.00005));
m
}));
m.insert("bswap/addLiquidityPreview".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Float(1.00005));
m
}));
m.insert("bswap/removeLiquidityPreview".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Float(1.00005));
m
}));
m.insert("bswap/unclaimedRewards".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Float(6.667));
m
}));
m.insert("bswap/claimedHistory".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Float(6.667));
m
}));
m.insert("blvt/tokenInfo".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Float(0.1));
m
}));
m.insert("blvt/subscribe/record".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Float(0.1));
m
}));
m.insert("blvt/redeem/record".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Float(0.1));
m
}));
m.insert("blvt/userLimit".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Float(0.1));
m
}));
m.insert("apiReferral/ifNewUser".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(1));
m
}));
m.insert("apiReferral/customization".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(1));
m
}));
m.insert("apiReferral/userCustomization".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(1));
m
}));
m.insert("apiReferral/rebate/recentRecord".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(1));
m
}));
m.insert("apiReferral/rebate/historicalRecord".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(1));
m
}));
m.insert("apiReferral/kickback/recentRecord".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(1));
m
}));
m.insert("apiReferral/kickback/historicalRecord".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(1));
m
}));
m.insert("broker/subAccountApi".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(1));
m
}));
m.insert("broker/subAccount".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(1));
m
}));
m.insert("broker/subAccountApi/commission/futures".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(1));
m
}));
m.insert("broker/subAccountApi/commission/coinFutures".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(1));
m
}));
m.insert("broker/info".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(1));
m
}));
m.insert("broker/transfer".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(1));
m
}));
m.insert("broker/transfer/futures".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(1));
m
}));
m.insert("broker/rebate/recentRecord".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(1));
m
}));
m.insert("broker/rebate/historicalRecord".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(1));
m
}));
m.insert("broker/subAccount/bnbBurn/status".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(1));
m
}));
m.insert("broker/subAccount/depositHist".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(1));
m
}));
m.insert("broker/subAccount/spotSummary".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(1));
m
}));
m.insert("broker/subAccount/marginSummary".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(1));
m
}));
m.insert("broker/subAccount/futuresSummary".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(1));
m
}));
m.insert("broker/rebate/futures/recentRecord".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(1));
m
}));
m.insert("broker/subAccountApi/ipRestriction".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(1));
m
}));
m.insert("broker/universalTransfer".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(1));
m
}));
m.insert("account/apiRestrictions".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Float(0.1));
m
}));
m.insert("c2c/orderMatch/listUserOrderHistory".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Float(0.1));
m
}));
m.insert("nft/history/transactions".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Float(20.001));
m
}));
m.insert("nft/history/deposit".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Float(20.001));
m
}));
m.insert("nft/history/withdraw".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Float(20.001));
m
}));
m.insert("nft/user/getAsset".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Float(20.001));
m
}));
m.insert("pay/transactions".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Float(20.001));
m
}));
m.insert("giftcard/verify".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Float(0.1));
m
}));
m.insert("giftcard/cryptography/rsa-public-key".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Float(0.1));
m
}));
m.insert("giftcard/buyCode/token-limit".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Float(0.1));
m
}));
m.insert("algo/spot/openOrders".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Float(0.1));
m
}));
m.insert("algo/spot/historicalOrders".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Float(0.1));
m
}));
m.insert("algo/spot/subOrders".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Float(0.1));
m
}));
m.insert("algo/futures/openOrders".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Float(0.1));
m
}));
m.insert("algo/futures/historicalOrders".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Float(0.1));
m
}));
m.insert("algo/futures/subOrders".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Float(0.1));
m
}));
m.insert("portfolio/account".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Float(0.1));
m
}));
m.insert("portfolio/collateralRate".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(5));
m
}));
m.insert("portfolio/pmLoan".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Float(3.3335));
m
}));
m.insert("portfolio/interest-history".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Float(0.6667));
m
}));
m.insert("portfolio/asset-index-price".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Float(0.1));
m
}));
m.insert("portfolio/repay-futures-switch".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(3));
m
}));
m.insert("portfolio/margin-asset-leverage".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(5));
m
}));
m.insert("portfolio/balance".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(2));
m
}));
m.insert("portfolio/negative-balance-exchange-record".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(2));
m
}));
m.insert("portfolio/pmloan-history".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(5));
m
}));
m.insert("portfolio/earn-asset-balance".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(150));
m
}));
m.insert("portfolio/delta-mode".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(150));
m
}));
m.insert("staking/productList".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Float(0.1));
m
}));
m.insert("staking/position".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Float(0.1));
m
}));
m.insert("staking/stakingRecord".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Float(0.1));
m
}));
m.insert("staking/personalLeftQuota".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Float(0.1));
m
}));
m.insert("lending/auto-invest/target-asset/list".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Float(0.1));
m
}));
m.insert("lending/auto-invest/target-asset/roi/list".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Float(0.1));
m
}));
m.insert("lending/auto-invest/all/asset".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Float(0.1));
m
}));
m.insert("lending/auto-invest/source-asset/list".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Float(0.1));
m
}));
m.insert("lending/auto-invest/plan/list".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Float(0.1));
m
}));
m.insert("lending/auto-invest/plan/id".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Float(0.1));
m
}));
m.insert("lending/auto-invest/history/list".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Float(0.1));
m
}));
m.insert("lending/auto-invest/index/info".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Float(0.1));
m
}));
m.insert("lending/auto-invest/index/user-summary".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Float(0.1));
m
}));
m.insert("lending/auto-invest/one-off/status".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Float(0.1));
m
}));
m.insert("lending/auto-invest/redeem/history".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Float(0.1));
m
}));
m.insert("lending/auto-invest/rebalance/history".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Float(0.1));
m
}));
m.insert("simple-earn/flexible/list".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(15));
m
}));
m.insert("simple-earn/locked/list".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(15));
m
}));
m.insert("simple-earn/flexible/personalLeftQuota".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(15));
m
}));
m.insert("simple-earn/locked/personalLeftQuota".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(15));
m
}));
m.insert("simple-earn/flexible/subscriptionPreview".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(15));
m
}));
m.insert("simple-earn/locked/subscriptionPreview".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(15));
m
}));
m.insert("simple-earn/flexible/history/rateHistory".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(15));
m
}));
m.insert("simple-earn/flexible/position".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(15));
m
}));
m.insert("simple-earn/locked/position".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(15));
m
}));
m.insert("simple-earn/account".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(15));
m
}));
m.insert("simple-earn/flexible/history/subscriptionRecord".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(15));
m
}));
m.insert("simple-earn/locked/history/subscriptionRecord".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(15));
m
}));
m.insert("simple-earn/flexible/history/redemptionRecord".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(15));
m
}));
m.insert("simple-earn/locked/history/redemptionRecord".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(15));
m
}));
m.insert("simple-earn/flexible/history/rewardsRecord".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(15));
m
}));
m.insert("simple-earn/locked/history/rewardsRecord".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(15));
m
}));
m.insert("simple-earn/flexible/history/collateralRecord".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Float(0.1));
m
}));
m.insert("dci/product/list".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Float(0.1));
m
}));
m.insert("dci/product/positions".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Float(0.1));
m
}));
m.insert("dci/product/accounts".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Float(0.1));
m
}));
m.insert("accumulator/product/list".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Float(0.1));
m
}));
m.insert("accumulator/product/position/list".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Float(0.1));
m
}));
m.insert("accumulator/product/sum-holding".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Float(0.1));
m
}));
m.insert("equity/market/exchangeInfo".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Float(0.1));
m
}));
m.insert("equity/market/tokenized-assets".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Float(0.1));
m
}));
m.insert("equity/market/quote".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Float(0.1));
m
}));
m.insert("equity/order/open-orders".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Float(0.1));
m
}));
m.insert("equity/order/history".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Float(0.1));
m
}));
m.insert("equity/order/detail".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Float(0.1));
m
}));
m.insert("equity/trade/history".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Float(0.1));
m
}));
m.insert("equity/tokenized/convert-status".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Float(0.1));
m
}));
m.insert("equity/tokenized/history".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Float(0.1));
m
}));
m
}));
m.insert("post".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("asset/dust".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Float(0.06667));
m
}));
m.insert("asset/dust-btc".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Float(0.1));
m
}));
m.insert("asset/transfer".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Float(6.0003));
m
}));
m.insert("asset/get-funding-asset".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Float(0.1));
m
}));
m.insert("asset/convert-transfer".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Float(0.033335));
m
}));
m.insert("account/disableFastWithdrawSwitch".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Float(0.1));
m
}));
m.insert("account/enableFastWithdrawSwitch".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Float(0.1));
m
}));
m.insert("capital/withdraw/apply".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Float(4.0002));
m
}));
m.insert("capital/contract/convertible-coins".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Float(4.0002));
m
}));
m.insert("capital/deposit/credit-apply".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Float(0.1));
m
}));
m.insert("margin/borrow-repay".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Float(20.001));
m
}));
m.insert("margin/transfer".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Float(4.0002));
m
}));
m.insert("margin/loan".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Float(20.001));
m
}));
m.insert("margin/repay".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Float(20.001));
m
}));
m.insert("margin/order".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Float(0.040002));
m
}));
m.insert("margin/order/oco".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Float(0.040002));
m
}));
m.insert("margin/dust".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Float(20.001));
m
}));
m.insert("margin/exchange-small-liability".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Float(20.001));
m
}));
m.insert("margin/isolated/transfer".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Float(4.0002));
m
}));
m.insert("margin/isolated/account".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Float(2.0001));
m
}));
m.insert("margin/max-leverage".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(300));
m
}));
m.insert("bnbBurn".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Float(0.1));
m
}));
m.insert("sub-account/virtualSubAccount".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Float(0.1));
m
}));
m.insert("sub-account/margin/transfer".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Float(4.0002));
m
}));
m.insert("sub-account/margin/enable".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Float(0.1));
m
}));
m.insert("sub-account/futures/enable".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Float(0.1));
m
}));
m.insert("sub-account/futures/transfer".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Float(0.1));
m
}));
m.insert("sub-account/futures/internalTransfer".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Float(0.1));
m
}));
m.insert("sub-account/transfer/subToSub".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Float(0.1));
m
}));
m.insert("sub-account/transfer/subToMaster".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Float(0.1));
m
}));
m.insert("sub-account/universalTransfer".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Float(0.1));
m
}));
m.insert("sub-account/options/enable".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Float(0.1));
m
}));
m.insert("managed-subaccount/deposit".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Float(0.1));
m
}));
m.insert("managed-subaccount/withdraw".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Float(0.1));
m
}));
m.insert("userDataStream".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Float(0.1));
m
}));
m.insert("userDataStream/isolated".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Float(0.1));
m
}));
m.insert("userListenToken".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Float(0.1));
m
}));
m.insert("futures/transfer".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Float(0.1));
m
}));
m.insert("lending/customizedFixed/purchase".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Float(0.1));
m
}));
m.insert("lending/daily/purchase".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Float(0.1));
m
}));
m.insert("lending/daily/redeem".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Float(0.1));
m
}));
m.insert("bswap/liquidityAdd".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(60));
m
}));
m.insert("bswap/liquidityRemove".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(60));
m
}));
m.insert("bswap/swap".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(60));
m
}));
m.insert("bswap/claimRewards".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Float(6.667));
m
}));
m.insert("blvt/subscribe".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Float(0.1));
m
}));
m.insert("blvt/redeem".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Float(0.1));
m
}));
m.insert("apiReferral/customization".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(1));
m
}));
m.insert("apiReferral/userCustomization".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(1));
m
}));
m.insert("apiReferral/rebate/historicalRecord".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(1));
m
}));
m.insert("apiReferral/kickback/historicalRecord".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(1));
m
}));
m.insert("broker/subAccount".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(1));
m
}));
m.insert("broker/subAccount/margin".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(1));
m
}));
m.insert("broker/subAccount/futures".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(1));
m
}));
m.insert("broker/subAccountApi".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(1));
m
}));
m.insert("broker/subAccountApi/permission".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(1));
m
}));
m.insert("broker/subAccountApi/commission".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(1));
m
}));
m.insert("broker/subAccountApi/commission/futures".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(1));
m
}));
m.insert("broker/subAccountApi/commission/coinFutures".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(1));
m
}));
m.insert("broker/transfer".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(1));
m
}));
m.insert("broker/transfer/futures".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(1));
m
}));
m.insert("broker/rebate/historicalRecord".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(1));
m
}));
m.insert("broker/subAccount/bnbBurn/spot".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(1));
m
}));
m.insert("broker/subAccount/bnbBurn/marginInterest".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(1));
m
}));
m.insert("broker/subAccount/blvt".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(1));
m
}));
m.insert("broker/subAccountApi/ipRestriction".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(1));
m
}));
m.insert("broker/subAccountApi/ipRestriction/ipList".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(1));
m
}));
m.insert("broker/universalTransfer".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(1));
m
}));
m.insert("broker/subAccountApi/permission/universalTransfer".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(1));
m
}));
m.insert("broker/subAccountApi/permission/vanillaOptions".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(1));
m
}));
m.insert("giftcard/createCode".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Float(0.1));
m
}));
m.insert("giftcard/redeemCode".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Float(0.1));
m
}));
m.insert("giftcard/buyCode".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Float(0.1));
m
}));
m.insert("algo/spot/newOrderTwap".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Float(20.001));
m
}));
m.insert("algo/futures/newOrderVp".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Float(20.001));
m
}));
m.insert("algo/futures/newOrderTwap".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Float(20.001));
m
}));
m.insert("staking/purchase".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Float(0.1));
m
}));
m.insert("staking/redeem".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Float(0.1));
m
}));
m.insert("staking/setAutoStaking".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Float(0.1));
m
}));
m.insert("eth-staking/eth/stake".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(15));
m
}));
m.insert("eth-staking/eth/redeem".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(15));
m
}));
m.insert("eth-staking/wbeth/wrap".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(15));
m
}));
m.insert("sol-staking/sol/stake".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(15));
m
}));
m.insert("sol-staking/sol/redeem".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(15));
m
}));
m.insert("mining/hash-transfer/config".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Float(0.5));
m
}));
m.insert("mining/hash-transfer/config/cancel".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Float(0.5));
m
}));
m.insert("portfolio/repay".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Float(20.001));
m
}));
m.insert("loan/vip/renew".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Float(40.002));
m
}));
m.insert("loan/vip/borrow".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Float(40.002));
m
}));
m.insert("loan/borrow".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Float(40.002));
m
}));
m.insert("loan/repay".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Float(40.002));
m
}));
m.insert("loan/adjust/ltv".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Float(40.002));
m
}));
m.insert("loan/customize/margin_call".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Float(40.002));
m
}));
m.insert("loan/flexible/repay".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Float(40.002));
m
}));
m.insert("loan/flexible/adjust/ltv".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Float(40.002));
m
}));
m.insert("loan/vip/repay".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Float(40.002));
m
}));
m.insert("convert/getQuote".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Float(1.3334));
m
}));
m.insert("convert/acceptQuote".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Float(3.3335));
m
}));
m.insert("convert/limit/placeOrder".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Float(3.3335));
m
}));
m.insert("convert/limit/cancelOrder".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Float(1.3334));
m
}));
m.insert("portfolio/auto-collection".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(150));
m
}));
m.insert("portfolio/asset-collection".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(6));
m
}));
m.insert("portfolio/bnb-transfer".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(150));
m
}));
m.insert("portfolio/repay-futures-switch".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(150));
m
}));
m.insert("portfolio/repay-futures-negative-balance".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(150));
m
}));
m.insert("portfolio/mint".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(20));
m
}));
m.insert("portfolio/redeem".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(20));
m
}));
m.insert("portfolio/earn-asset-transfer".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(150));
m
}));
m.insert("portfolio/delta-mode".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(150));
m
}));
m.insert("lending/auto-invest/plan/add".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Float(0.1));
m
}));
m.insert("lending/auto-invest/plan/edit".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Float(0.1));
m
}));
m.insert("lending/auto-invest/plan/edit-status".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Float(0.1));
m
}));
m.insert("lending/auto-invest/one-off".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Float(0.1));
m
}));
m.insert("lending/auto-invest/redeem".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Float(0.1));
m
}));
m.insert("simple-earn/flexible/subscribe".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Float(0.1));
m
}));
m.insert("simple-earn/locked/subscribe".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Float(0.1));
m
}));
m.insert("simple-earn/flexible/redeem".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Float(0.1));
m
}));
m.insert("simple-earn/locked/redeem".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Float(0.1));
m
}));
m.insert("simple-earn/flexible/setAutoSubscribe".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(15));
m
}));
m.insert("simple-earn/locked/setAutoSubscribe".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(15));
m
}));
m.insert("simple-earn/locked/setRedeemOption".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(5));
m
}));
m.insert("dci/product/subscribe".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Float(0.1));
m
}));
m.insert("dci/product/auto_compound/edit".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Float(0.1));
m
}));
m.insert("accumulator/product/subscribe".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Float(0.1));
m
}));
m.insert("equity/order/place".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Float(0.1));
m
}));
m.insert("equity/order/cancel".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Float(0.1));
m
}));
m.insert("equity/order/cancel-all".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Float(0.1));
m
}));
m.insert("equity/tokenized/mint".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Float(0.1));
m
}));
m.insert("equity/tokenized/redeem".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Float(0.1));
m
}));
m.insert("equity/account/disclaimer".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Float(0.1));
m
}));
m.insert("equity/listenKey".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Float(0.1));
m
}));
m
}));
m.insert("put".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("userDataStream".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Float(0.1));
m
}));
m.insert("userDataStream/isolated".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Float(0.1));
m
}));
m
}));
m.insert("delete".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("margin/openOrders".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Float(0.1));
m
}));
m.insert("margin/order".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Float(0.006667));
m
}));
m.insert("margin/orderList".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Float(0.006667));
m
}));
m.insert("margin/isolated/account".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Float(2.0001));
m
}));
m.insert("userDataStream".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Float(0.1));
m
}));
m.insert("userDataStream/isolated".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Float(0.1));
m
}));
m.insert("broker/subAccountApi".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(1));
m
}));
m.insert("broker/subAccountApi/ipRestriction/ipList".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(1));
m
}));
m.insert("algo/spot/order".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Float(0.1));
m
}));
m.insert("algo/futures/order".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Float(0.1));
m
}));
m.insert("sub-account/subAccountApi/ipRestriction/ipList".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Float(20.001));
m
}));
m
}));
m
}));
m.insert("sapiV2".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("get".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("eth-staking/account".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(15));
m
}));
m.insert("sub-account/futures/account".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Float(0.1));
m
}));
m.insert("sub-account/futures/accountSummary".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(1));
m
}));
m.insert("sub-account/futures/positionRisk".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Float(0.1));
m
}));
m.insert("loan/flexible/ongoing/orders".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(30));
m
}));
m.insert("loan/flexible/borrow/history".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(40));
m
}));
m.insert("loan/flexible/repay/history".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(40));
m
}));
m.insert("loan/flexible/ltv/adjustment/history".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(40));
m
}));
m.insert("loan/flexible/loanable/data".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(40));
m
}));
m.insert("loan/flexible/collateral/data".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(40));
m
}));
m.insert("portfolio/account".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(2));
m
}));
m
}));
m.insert("post".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("eth-staking/eth/stake".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(15));
m
}));
m.insert("sub-account/subAccountApi/ipRestriction".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Float(20.001));
m
}));
m.insert("loan/flexible/borrow".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Float(40.002));
m
}));
m.insert("loan/flexible/repay".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Float(40.002));
m
}));
m.insert("loan/flexible/adjust/ltv".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Float(40.002));
m
}));
m
}));
m
}));
m.insert("sapiV3".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("get".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("sub-account/assets".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Float(0.40002));
m
}));
m
}));
m.insert("post".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("asset/getUserAsset".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Float(0.5));
m
}));
m
}));
m
}));
m.insert("sapiV4".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("get".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("sub-account/assets".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Float(0.40002));
m
}));
m
}));
m
}));
m.insert("dapiPublic".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("get".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("ping".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(1));
m
}));
m.insert("time".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(1));
m
}));
m.insert("exchangeInfo".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(1));
m
}));
m.insert("depth".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(2));
m.insert("byLimit".to_string(), Value::List(vec![Value::List(vec![Value::Int(50), Value::Int(2)]), Value::List(vec![Value::Int(100), Value::Int(5)]), Value::List(vec![Value::Int(500), Value::Int(10)]), Value::List(vec![Value::Int(1000), Value::Int(20)])]));
m
}));
m.insert("trades".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(5));
m
}));
m.insert("historicalTrades".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(20));
m
}));
m.insert("aggTrades".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(20));
m
}));
m.insert("premiumIndex".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(10));
m
}));
m.insert("fundingRate".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(1));
m
}));
m.insert("klines".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(1));
m.insert("byLimit".to_string(), Value::List(vec![Value::List(vec![Value::Int(99), Value::Int(1)]), Value::List(vec![Value::Int(499), Value::Int(2)]), Value::List(vec![Value::Int(1000), Value::Int(5)]), Value::List(vec![Value::Int(10000), Value::Int(10)])]));
m
}));
m.insert("continuousKlines".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(1));
m.insert("byLimit".to_string(), Value::List(vec![Value::List(vec![Value::Int(99), Value::Int(1)]), Value::List(vec![Value::Int(499), Value::Int(2)]), Value::List(vec![Value::Int(1000), Value::Int(5)]), Value::List(vec![Value::Int(10000), Value::Int(10)])]));
m
}));
m.insert("indexPriceKlines".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(1));
m.insert("byLimit".to_string(), Value::List(vec![Value::List(vec![Value::Int(99), Value::Int(1)]), Value::List(vec![Value::Int(499), Value::Int(2)]), Value::List(vec![Value::Int(1000), Value::Int(5)]), Value::List(vec![Value::Int(10000), Value::Int(10)])]));
m
}));
m.insert("markPriceKlines".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(1));
m.insert("byLimit".to_string(), Value::List(vec![Value::List(vec![Value::Int(99), Value::Int(1)]), Value::List(vec![Value::Int(499), Value::Int(2)]), Value::List(vec![Value::Int(1000), Value::Int(5)]), Value::List(vec![Value::Int(10000), Value::Int(10)])]));
m
}));
m.insert("premiumIndexKlines".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(1));
m.insert("byLimit".to_string(), Value::List(vec![Value::List(vec![Value::Int(99), Value::Int(1)]), Value::List(vec![Value::Int(499), Value::Int(2)]), Value::List(vec![Value::Int(1000), Value::Int(5)]), Value::List(vec![Value::Int(10000), Value::Int(10)])]));
m
}));
m.insert("ticker/24hr".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(1));
m.insert("noSymbol".to_string(), Value::Int(40));
m
}));
m.insert("ticker/price".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(1));
m.insert("noSymbol".to_string(), Value::Int(2));
m
}));
m.insert("ticker/bookTicker".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(2));
m.insert("noSymbol".to_string(), Value::Int(5));
m
}));
m.insert("constituents".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(2));
m
}));
m.insert("openInterest".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(1));
m
}));
m.insert("fundingInfo".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(1));
m
}));
m
}));
m
}));
m.insert("dapiData".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("get".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("delivery-price".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(1));
m
}));
m.insert("openInterestHist".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(1));
m
}));
m.insert("topLongShortAccountRatio".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(1));
m
}));
m.insert("topLongShortPositionRatio".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(1));
m
}));
m.insert("globalLongShortAccountRatio".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(1));
m
}));
m.insert("takerBuySellVol".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(1));
m
}));
m.insert("basis".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(1));
m
}));
m
}));
m
}));
m.insert("dapiPrivate".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("get".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("positionSide/dual".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(30));
m
}));
m.insert("orderAmendment".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(1));
m
}));
m.insert("order".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(1));
m
}));
m.insert("openOrder".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(1));
m
}));
m.insert("openOrders".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(1));
m.insert("noSymbol".to_string(), Value::Int(5));
m
}));
m.insert("openAlgoOrders".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(1));
m.insert("noSymbol".to_string(), Value::Int(40));
m
}));
m.insert("allOrders".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(5));
m
}));
m.insert("balance".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(1));
m
}));
m.insert("account".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(5));
m
}));
m.insert("positionMargin/history".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(1));
m
}));
m.insert("positionRisk".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(1));
m
}));
m.insert("userTrades".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(5));
m
}));
m.insert("income".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(20));
m
}));
m.insert("leverageBracket".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(2));
m.insert("noSymbol".to_string(), Value::Int(2));
m
}));
m.insert("forceOrders".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(20));
m.insert("noSymbol".to_string(), Value::Int(50));
m
}));
m.insert("adlQuantile".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(5));
m
}));
m.insert("commissionRate".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(20));
m
}));
m.insert("income/asyn".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(5));
m
}));
m.insert("income/asyn/id".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(5));
m
}));
m.insert("trade/asyn".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Float(0.5));
m
}));
m.insert("trade/asyn/id".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Float(0.5));
m
}));
m.insert("order/asyn".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Float(0.5));
m
}));
m.insert("order/asyn/id".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Float(0.5));
m
}));
m.insert("pmExchangeInfo".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Float(0.5));
m
}));
m.insert("pmAccountInfo".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Float(0.5));
m
}));
m
}));
m.insert("post".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("positionSide/dual".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(1));
m
}));
m.insert("order".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(4));
m
}));
m.insert("algoOrder".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(1));
m
}));
m.insert("batchOrders".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(5));
m
}));
m.insert("countdownCancelAll".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(10));
m
}));
m.insert("leverage".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(1));
m
}));
m.insert("marginType".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(1));
m
}));
m.insert("positionMargin".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(1));
m
}));
m.insert("listenKey".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(1));
m
}));
m
}));
m.insert("put".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("listenKey".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(1));
m
}));
m.insert("order".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(1));
m
}));
m.insert("batchOrders".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(5));
m
}));
m
}));
m.insert("delete".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("order".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(1));
m
}));
m.insert("algoOrder".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(1));
m
}));
m.insert("allOpenOrders".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(1));
m
}));
m.insert("batchOrders".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(5));
m
}));
m.insert("listenKey".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(1));
m
}));
m
}));
m
}));
m.insert("dapiPrivateV2".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("get".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("leverageBracket".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(1));
m
}));
m
}));
m
}));
m.insert("fapiPublic".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("get".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("ping".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(1));
m
}));
m.insert("time".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(1));
m
}));
m.insert("exchangeInfo".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(1));
m
}));
m.insert("depth".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(2));
m.insert("byLimit".to_string(), Value::List(vec![Value::List(vec![Value::Int(50), Value::Int(2)]), Value::List(vec![Value::Int(100), Value::Int(5)]), Value::List(vec![Value::Int(500), Value::Int(10)]), Value::List(vec![Value::Int(1000), Value::Int(20)])]));
m
}));
m.insert("rpiDepth".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(20));
m
}));
m.insert("trades".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(5));
m
}));
m.insert("historicalTrades".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(20));
m
}));
m.insert("aggTrades".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(20));
m
}));
m.insert("klines".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(1));
m.insert("byLimit".to_string(), Value::List(vec![Value::List(vec![Value::Int(99), Value::Int(1)]), Value::List(vec![Value::Int(499), Value::Int(2)]), Value::List(vec![Value::Int(1000), Value::Int(5)]), Value::List(vec![Value::Int(10000), Value::Int(10)])]));
m
}));
m.insert("continuousKlines".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(1));
m.insert("byLimit".to_string(), Value::List(vec![Value::List(vec![Value::Int(99), Value::Int(1)]), Value::List(vec![Value::Int(499), Value::Int(2)]), Value::List(vec![Value::Int(1000), Value::Int(5)]), Value::List(vec![Value::Int(10000), Value::Int(10)])]));
m
}));
m.insert("markPriceKlines".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(1));
m.insert("byLimit".to_string(), Value::List(vec![Value::List(vec![Value::Int(99), Value::Int(1)]), Value::List(vec![Value::Int(499), Value::Int(2)]), Value::List(vec![Value::Int(1000), Value::Int(5)]), Value::List(vec![Value::Int(10000), Value::Int(10)])]));
m
}));
m.insert("indexPriceKlines".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(1));
m.insert("byLimit".to_string(), Value::List(vec![Value::List(vec![Value::Int(99), Value::Int(1)]), Value::List(vec![Value::Int(499), Value::Int(2)]), Value::List(vec![Value::Int(1000), Value::Int(5)]), Value::List(vec![Value::Int(10000), Value::Int(10)])]));
m
}));
m.insert("premiumIndexKlines".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(1));
m.insert("byLimit".to_string(), Value::List(vec![Value::List(vec![Value::Int(99), Value::Int(1)]), Value::List(vec![Value::Int(499), Value::Int(2)]), Value::List(vec![Value::Int(1000), Value::Int(5)]), Value::List(vec![Value::Int(10000), Value::Int(10)])]));
m
}));
m.insert("fundingRate".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(1));
m
}));
m.insert("fundingInfo".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(1));
m
}));
m.insert("premiumIndex".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(1));
m
}));
m.insert("ticker/24hr".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(1));
m.insert("noSymbol".to_string(), Value::Int(40));
m
}));
m.insert("ticker/price".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(1));
m.insert("noSymbol".to_string(), Value::Int(2));
m
}));
m.insert("ticker/bookTicker".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(2));
m.insert("noSymbol".to_string(), Value::Int(5));
m
}));
m.insert("openInterest".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(1));
m
}));
m.insert("indexInfo".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(1));
m
}));
m.insert("assetIndex".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(1));
m.insert("noSymbol".to_string(), Value::Int(10));
m
}));
m.insert("constituents".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(2));
m
}));
m.insert("apiTradingStatus".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(1));
m.insert("noSymbol".to_string(), Value::Int(10));
m
}));
m.insert("lvtKlines".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(1));
m
}));
m.insert("convert/exchangeInfo".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(4));
m
}));
m.insert("insuranceBalance".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(1));
m
}));
m.insert("symbolAdlRisk".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(1));
m
}));
m.insert("tradingSchedule".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(5));
m
}));
m
}));
m
}));
m.insert("fapiData".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("get".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("delivery-price".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(1));
m
}));
m.insert("openInterestHist".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(1));
m
}));
m.insert("topLongShortAccountRatio".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(1));
m
}));
m.insert("topLongShortPositionRatio".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(1));
m
}));
m.insert("globalLongShortAccountRatio".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(1));
m
}));
m.insert("takerlongshortRatio".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(1));
m
}));
m.insert("basis".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(1));
m
}));
m
}));
m
}));
m.insert("fapiPrivate".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("get".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("forceOrders".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(20));
m.insert("noSymbol".to_string(), Value::Int(50));
m
}));
m.insert("allOrders".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(5));
m
}));
m.insert("openOrder".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(1));
m
}));
m.insert("openOrders".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(1));
m.insert("noSymbol".to_string(), Value::Int(40));
m
}));
m.insert("order".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(1));
m
}));
m.insert("account".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(5));
m
}));
m.insert("balance".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(5));
m
}));
m.insert("leverageBracket".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(1));
m
}));
m.insert("positionMargin/history".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(1));
m
}));
m.insert("positionRisk".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(5));
m
}));
m.insert("positionSide/dual".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(30));
m
}));
m.insert("userTrades".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(5));
m
}));
m.insert("income".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(30));
m
}));
m.insert("commissionRate".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(20));
m
}));
m.insert("rateLimit/order".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(1));
m
}));
m.insert("apiTradingStatus".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(1));
m
}));
m.insert("multiAssetsMargin".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(30));
m
}));
m.insert("apiReferral/ifNewUser".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(1));
m
}));
m.insert("apiReferral/customization".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(1));
m
}));
m.insert("apiReferral/userCustomization".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(1));
m
}));
m.insert("apiReferral/traderNum".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(1));
m
}));
m.insert("apiReferral/overview".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(1));
m
}));
m.insert("apiReferral/tradeVol".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(1));
m
}));
m.insert("apiReferral/rebateVol".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(1));
m
}));
m.insert("apiReferral/traderSummary".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(1));
m
}));
m.insert("adlQuantile".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(5));
m
}));
m.insert("pmAccountInfo".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(5));
m
}));
m.insert("orderAmendment".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(1));
m
}));
m.insert("income/asyn".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(1000));
m
}));
m.insert("income/asyn/id".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(10));
m
}));
m.insert("order/asyn".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(1000));
m
}));
m.insert("order/asyn/id".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(10));
m
}));
m.insert("trade/asyn".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(1000));
m
}));
m.insert("trade/asyn/id".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(10));
m
}));
m.insert("feeBurn".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(1));
m
}));
m.insert("symbolConfig".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(5));
m
}));
m.insert("accountConfig".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(5));
m
}));
m.insert("convert/orderStatus".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(5));
m
}));
m.insert("algoOrder".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(1));
m
}));
m.insert("openAlgoOrders".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(1));
m.insert("noSymbol".to_string(), Value::Int(40));
m
}));
m.insert("allAlgoOrders".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(5));
m
}));
m.insert("stock/contract".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(50));
m
}));
m
}));
m.insert("post".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("batchOrders".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(5));
m
}));
m.insert("positionSide/dual".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(1));
m
}));
m.insert("positionMargin".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(1));
m
}));
m.insert("marginType".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(1));
m
}));
m.insert("order".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(4));
m
}));
m.insert("order/test".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(1));
m
}));
m.insert("leverage".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(1));
m
}));
m.insert("listenKey".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(1));
m
}));
m.insert("countdownCancelAll".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(10));
m
}));
m.insert("multiAssetsMargin".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(1));
m
}));
m.insert("apiReferral/customization".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(1));
m
}));
m.insert("apiReferral/userCustomization".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(1));
m
}));
m.insert("feeBurn".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(1));
m
}));
m.insert("convert/getQuote".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(200));
m
}));
m.insert("convert/acceptQuote".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(20));
m
}));
m.insert("algoOrder".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(1));
m
}));
m
}));
m.insert("put".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("listenKey".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(1));
m
}));
m.insert("order".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(1));
m
}));
m.insert("batchOrders".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(5));
m
}));
m
}));
m.insert("delete".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("batchOrders".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(1));
m
}));
m.insert("order".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(1));
m
}));
m.insert("allOpenOrders".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(1));
m
}));
m.insert("listenKey".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(1));
m
}));
m.insert("algoOrder".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(1));
m
}));
m.insert("algoOpenOrders".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(1));
m
}));
m
}));
m
}));
m.insert("fapiPublicV2".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("get".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("ticker/price".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(0));
m
}));
m
}));
m
}));
m.insert("fapiPrivateV2".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("get".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("account".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(1));
m
}));
m.insert("balance".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(1));
m
}));
m.insert("positionRisk".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(1));
m
}));
m
}));
m
}));
m.insert("fapiPublicV3".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("get".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m
}));
m
}));
m.insert("fapiPrivateV3".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("get".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("account".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(1));
m
}));
m.insert("balance".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(1));
m
}));
m.insert("positionRisk".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(1));
m
}));
m
}));
m
}));
m.insert("eapiPublic".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("get".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("ping".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(1));
m
}));
m.insert("time".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(1));
m
}));
m.insert("exchangeInfo".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(1));
m
}));
m.insert("index".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(1));
m
}));
m.insert("ticker".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(5));
m
}));
m.insert("mark".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(5));
m
}));
m.insert("depth".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(1));
m
}));
m.insert("klines".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(1));
m
}));
m.insert("trades".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(5));
m
}));
m.insert("historicalTrades".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(20));
m
}));
m.insert("exerciseHistory".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(3));
m
}));
m.insert("openInterest".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(3));
m
}));
m
}));
m
}));
m.insert("eapiPrivate".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("get".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("account".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(3));
m
}));
m.insert("position".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(5));
m
}));
m.insert("openOrders".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(1));
m.insert("noSymbol".to_string(), Value::Int(40));
m
}));
m.insert("historyOrders".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(3));
m
}));
m.insert("userTrades".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(5));
m
}));
m.insert("exerciseRecord".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(5));
m
}));
m.insert("bill".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(1));
m
}));
m.insert("income/asyn".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(5));
m
}));
m.insert("income/asyn/id".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(5));
m
}));
m.insert("marginAccount".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(3));
m
}));
m.insert("mmp".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(1));
m
}));
m.insert("countdownCancelAll".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(1));
m
}));
m.insert("order".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(1));
m
}));
m.insert("block/order/orders".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(5));
m
}));
m.insert("block/order/execute".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(5));
m
}));
m.insert("block/user-trades".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(5));
m
}));
m.insert("blockTrades".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(5));
m
}));
m.insert("comission".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(5));
m
}));
m
}));
m.insert("post".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("order".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(1));
m
}));
m.insert("batchOrders".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(5));
m
}));
m.insert("listenKey".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(1));
m
}));
m.insert("mmpSet".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(1));
m
}));
m.insert("mmpReset".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(1));
m
}));
m.insert("countdownCancelAll".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(1));
m
}));
m.insert("countdownCancelAllHeartBeat".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(10));
m
}));
m.insert("block/order/create".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(5));
m
}));
m.insert("block/order/execute".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(5));
m
}));
m
}));
m.insert("put".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("listenKey".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(1));
m
}));
m.insert("block/order/create".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(5));
m
}));
m
}));
m.insert("delete".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("order".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(1));
m
}));
m.insert("batchOrders".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(1));
m
}));
m.insert("allOpenOrders".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(1));
m
}));
m.insert("allOpenOrdersByUnderlying".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(1));
m
}));
m.insert("listenKey".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(1));
m
}));
m.insert("block/order/create".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(5));
m
}));
m
}));
m
}));
m.insert("public".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("get".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("ping".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Float(0.2));
m
}));
m.insert("time".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Float(0.2));
m
}));
m.insert("depth".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(1));
m.insert("byLimit".to_string(), Value::List(vec![Value::List(vec![Value::Int(100), Value::Int(1)]), Value::List(vec![Value::Int(500), Value::Int(5)]), Value::List(vec![Value::Int(1000), Value::Int(10)]), Value::List(vec![Value::Int(5000), Value::Int(50)])]));
m
}));
m.insert("trades".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(2));
m
}));
m.insert("aggTrades".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Float(0.4));
m
}));
m.insert("historicalTrades".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(2));
m
}));
m.insert("klines".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Float(0.4));
m
}));
m.insert("uiKlines".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Float(0.4));
m
}));
m.insert("ticker/24hr".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Float(0.4));
m.insert("noSymbol".to_string(), Value::Int(16));
m
}));
m.insert("ticker".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Float(0.4));
m.insert("noSymbol".to_string(), Value::Int(16));
m
}));
m.insert("ticker/tradingDay".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Float(0.8));
m
}));
m.insert("ticker/price".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Float(0.4));
m.insert("noSymbol".to_string(), Value::Float(0.8));
m
}));
m.insert("ticker/bookTicker".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Float(0.4));
m.insert("noSymbol".to_string(), Value::Float(0.8));
m
}));
m.insert("exchangeInfo".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(4));
m
}));
m.insert("avgPrice".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Float(0.4));
m
}));
m
}));
m.insert("put".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("userDataStream".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Float(0.4));
m
}));
m
}));
m.insert("post".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("userDataStream".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Float(0.4));
m
}));
m
}));
m.insert("delete".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("userDataStream".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Float(0.4));
m
}));
m
}));
m
}));
m.insert("private".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("get".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("allOrderList".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(4));
m
}));
m.insert("openOrderList".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Float(1.2));
m
}));
m.insert("orderList".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Float(0.8));
m
}));
m.insert("order".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Float(0.8));
m
}));
m.insert("openOrders".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Float(1.2));
m.insert("noSymbol".to_string(), Value::Int(16));
m
}));
m.insert("allOrders".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(4));
m
}));
m.insert("account".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(4));
m
}));
m.insert("myTrades".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(4));
m
}));
m.insert("rateLimit/order".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(8));
m
}));
m.insert("myPreventedMatches".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(4));
m
}));
m.insert("myAllocations".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(4));
m
}));
m.insert("account/commission".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(4));
m
}));
m
}));
m.insert("post".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("order/oco".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Float(0.2));
m
}));
m.insert("orderList/oco".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Float(0.2));
m
}));
m.insert("orderList/oto".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Float(0.2));
m
}));
m.insert("orderList/otoco".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Float(0.2));
m
}));
m.insert("orderList/opo".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Float(0.2));
m
}));
m.insert("orderList/opoco".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Float(0.2));
m
}));
m.insert("sor/order".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Float(0.2));
m
}));
m.insert("sor/order/test".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Float(0.2));
m
}));
m.insert("order".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Float(0.2));
m
}));
m.insert("order/cancelReplace".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Float(0.2));
m
}));
m.insert("order/test".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Float(0.2));
m
}));
m
}));
m.insert("delete".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("openOrders".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Float(0.2));
m
}));
m.insert("orderList".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Float(0.2));
m
}));
m.insert("order".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Float(0.2));
m
}));
m
}));
m
}));
m.insert("papi".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("get".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("ping".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Float(0.2));
m
}));
m.insert("um/order".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(1));
m
}));
m.insert("um/openOrder".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(1));
m
}));
m.insert("um/openOrders".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(1));
m.insert("noSymbol".to_string(), Value::Int(40));
m
}));
m.insert("um/allOrders".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(5));
m
}));
m.insert("cm/order".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(1));
m
}));
m.insert("cm/openOrder".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(1));
m
}));
m.insert("cm/openOrders".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(1));
m.insert("noSymbol".to_string(), Value::Int(40));
m
}));
m.insert("cm/allOrders".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(20));
m
}));
m.insert("um/conditional/openOrder".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(1));
m
}));
m.insert("um/conditional/openOrders".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(1));
m.insert("noSymbol".to_string(), Value::Int(40));
m
}));
m.insert("um/conditional/orderHistory".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(1));
m
}));
m.insert("um/conditional/allOrders".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(1));
m.insert("noSymbol".to_string(), Value::Int(40));
m
}));
m.insert("cm/conditional/openOrder".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(1));
m
}));
m.insert("cm/conditional/openOrders".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(1));
m.insert("noSymbol".to_string(), Value::Int(40));
m
}));
m.insert("cm/conditional/orderHistory".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(1));
m
}));
m.insert("cm/conditional/allOrders".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(40));
m
}));
m.insert("margin/order".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(10));
m
}));
m.insert("margin/openOrders".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(5));
m
}));
m.insert("margin/allOrders".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(100));
m
}));
m.insert("margin/orderList".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(5));
m
}));
m.insert("margin/allOrderList".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(100));
m
}));
m.insert("margin/openOrderList".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(5));
m
}));
m.insert("margin/myTrades".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(5));
m
}));
m.insert("balance".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(4));
m
}));
m.insert("account".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(4));
m
}));
m.insert("margin/maxBorrowable".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(1));
m
}));
m.insert("margin/maxWithdraw".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(1));
m
}));
m.insert("um/positionRisk".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(1));
m
}));
m.insert("cm/positionRisk".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Float(0.2));
m
}));
m.insert("um/positionSide/dual".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(6));
m
}));
m.insert("cm/positionSide/dual".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(6));
m
}));
m.insert("um/userTrades".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(5));
m
}));
m.insert("cm/userTrades".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(20));
m
}));
m.insert("um/leverageBracket".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Float(0.2));
m
}));
m.insert("cm/leverageBracket".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Float(0.2));
m
}));
m.insert("margin/forceOrders".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(1));
m
}));
m.insert("um/forceOrders".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(20));
m.insert("noSymbol".to_string(), Value::Int(50));
m
}));
m.insert("cm/forceOrders".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(20));
m.insert("noSymbol".to_string(), Value::Int(50));
m
}));
m.insert("um/apiTradingStatus".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Float(0.2));
m.insert("noSymbol".to_string(), Value::Int(2));
m
}));
m.insert("um/commissionRate".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(4));
m
}));
m.insert("cm/commissionRate".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(4));
m
}));
m.insert("margin/marginLoan".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(2));
m
}));
m.insert("margin/repayLoan".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(2));
m
}));
m.insert("margin/marginInterestHistory".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Float(0.2));
m
}));
m.insert("portfolio/interest-history".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(10));
m
}));
m.insert("um/income".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(6));
m
}));
m.insert("cm/income".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(6));
m
}));
m.insert("um/account".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(1));
m
}));
m.insert("cm/account".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(1));
m
}));
m.insert("repay-futures-switch".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(6));
m
}));
m.insert("um/adlQuantile".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(5));
m
}));
m.insert("cm/adlQuantile".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(5));
m
}));
m.insert("um/trade/asyn".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(300));
m
}));
m.insert("um/trade/asyn/id".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(2));
m
}));
m.insert("um/order/asyn".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(300));
m
}));
m.insert("um/order/asyn/id".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(2));
m
}));
m.insert("um/income/asyn".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(300));
m
}));
m.insert("um/income/asyn/id".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(2));
m
}));
m.insert("um/orderAmendment".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(1));
m
}));
m.insert("cm/orderAmendment".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(1));
m
}));
m.insert("um/feeBurn".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(30));
m
}));
m.insert("um/accountConfig".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(1));
m
}));
m.insert("um/symbolConfig".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(1));
m
}));
m.insert("cm/accountConfig".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(1));
m
}));
m.insert("cm/symbolConfig".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(1));
m
}));
m.insert("rateLimit/order".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(1));
m
}));
m
}));
m.insert("post".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("um/order".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(1));
m
}));
m.insert("um/conditional/order".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(1));
m
}));
m.insert("cm/order".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(1));
m
}));
m.insert("cm/conditional/order".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(1));
m
}));
m.insert("margin/order".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(1));
m
}));
m.insert("marginLoan".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(100));
m
}));
m.insert("repayLoan".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(100));
m
}));
m.insert("margin/order/oco".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(1));
m
}));
m.insert("um/leverage".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Float(0.2));
m
}));
m.insert("cm/leverage".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Float(0.2));
m
}));
m.insert("um/positionSide/dual".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Float(0.2));
m
}));
m.insert("cm/positionSide/dual".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Float(0.2));
m
}));
m.insert("auto-collection".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(150));
m
}));
m.insert("bnb-transfer".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(150));
m
}));
m.insert("repay-futures-switch".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(150));
m
}));
m.insert("repay-futures-negative-balance".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(150));
m
}));
m.insert("listenKey".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Float(0.2));
m
}));
m.insert("asset-collection".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(6));
m
}));
m.insert("margin/repay-debt".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(3000));
m
}));
m.insert("um/feeBurn".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(1));
m
}));
m.insert("um/stock/contract".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(1));
m
}));
m
}));
m.insert("put".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("listenKey".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Float(0.2));
m
}));
m.insert("um/order".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(1));
m
}));
m.insert("cm/order".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(1));
m
}));
m
}));
m.insert("delete".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("um/order".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(1));
m
}));
m.insert("um/conditional/order".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(1));
m
}));
m.insert("um/allOpenOrders".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(1));
m
}));
m.insert("um/conditional/allOpenOrders".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(1));
m
}));
m.insert("cm/order".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(1));
m
}));
m.insert("cm/conditional/order".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(1));
m
}));
m.insert("cm/allOpenOrders".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(1));
m
}));
m.insert("cm/conditional/allOpenOrders".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(1));
m
}));
m.insert("margin/order".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(2));
m
}));
m.insert("margin/allOpenOrders".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(5));
m
}));
m.insert("margin/orderList".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(2));
m
}));
m.insert("listenKey".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Float(0.2));
m
}));
m
}));
m
}));
m.insert("papiV2".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("get".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("um/account".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(1));
m
}));
m
}));
m
}));
m
}));
m.insert("fees".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("trading".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("feeSide".to_string(), Value::Str("get".to_string()));
m.insert("tierBased".to_string(), Value::Bool(false));
m.insert("percentage".to_string(), Value::Bool(true));
m.insert("taker".to_string(), self.parse_number(Value::Str("0.001".to_string()), &[]));
m.insert("maker".to_string(), self.parse_number(Value::Str("0.001".to_string()), &[]));
m
}));
m.insert("linear".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("trading".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("feeSide".to_string(), Value::Str("quote".to_string()));
m.insert("tierBased".to_string(), Value::Bool(true));
m.insert("percentage".to_string(), Value::Bool(true));
m.insert("taker".to_string(), self.parse_number(Value::Str("0.000500".to_string()), &[]));
m.insert("maker".to_string(), self.parse_number(Value::Str("0.000200".to_string()), &[]));
m.insert("tiers".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("taker".to_string(), Value::List(vec![Value::List(vec![self.parse_number(Value::Str("0".to_string()), &[]), self.parse_number(Value::Str("0.000400".to_string()), &[])]), Value::List(vec![self.parse_number(Value::Str("250".to_string()), &[]), self.parse_number(Value::Str("0.000400".to_string()), &[])]), Value::List(vec![self.parse_number(Value::Str("2500".to_string()), &[]), self.parse_number(Value::Str("0.000350".to_string()), &[])]), Value::List(vec![self.parse_number(Value::Str("7500".to_string()), &[]), self.parse_number(Value::Str("0.000320".to_string()), &[])]), Value::List(vec![self.parse_number(Value::Str("22500".to_string()), &[]), self.parse_number(Value::Str("0.000300".to_string()), &[])]), Value::List(vec![self.parse_number(Value::Str("50000".to_string()), &[]), self.parse_number(Value::Str("0.000270".to_string()), &[])]), Value::List(vec![self.parse_number(Value::Str("100000".to_string()), &[]), self.parse_number(Value::Str("0.000250".to_string()), &[])]), Value::List(vec![self.parse_number(Value::Str("200000".to_string()), &[]), self.parse_number(Value::Str("0.000220".to_string()), &[])]), Value::List(vec![self.parse_number(Value::Str("400000".to_string()), &[]), self.parse_number(Value::Str("0.000200".to_string()), &[])]), Value::List(vec![self.parse_number(Value::Str("750000".to_string()), &[]), self.parse_number(Value::Str("0.000170".to_string()), &[])])]));
m.insert("maker".to_string(), Value::List(vec![Value::List(vec![self.parse_number(Value::Str("0".to_string()), &[]), self.parse_number(Value::Str("0.000200".to_string()), &[])]), Value::List(vec![self.parse_number(Value::Str("250".to_string()), &[]), self.parse_number(Value::Str("0.000160".to_string()), &[])]), Value::List(vec![self.parse_number(Value::Str("2500".to_string()), &[]), self.parse_number(Value::Str("0.000140".to_string()), &[])]), Value::List(vec![self.parse_number(Value::Str("7500".to_string()), &[]), self.parse_number(Value::Str("0.000120".to_string()), &[])]), Value::List(vec![self.parse_number(Value::Str("22500".to_string()), &[]), self.parse_number(Value::Str("0.000100".to_string()), &[])]), Value::List(vec![self.parse_number(Value::Str("50000".to_string()), &[]), self.parse_number(Value::Str("0.000080".to_string()), &[])]), Value::List(vec![self.parse_number(Value::Str("100000".to_string()), &[]), self.parse_number(Value::Str("0.000060".to_string()), &[])]), Value::List(vec![self.parse_number(Value::Str("200000".to_string()), &[]), self.parse_number(Value::Str("0.000040".to_string()), &[])]), Value::List(vec![self.parse_number(Value::Str("400000".to_string()), &[]), self.parse_number(Value::Str("0.000020".to_string()), &[])]), Value::List(vec![self.parse_number(Value::Str("750000".to_string()), &[]), self.parse_number(Value::Str("0".to_string()), &[])])]));
m
}));
m
}));
m
}));
m.insert("inverse".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("trading".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("feeSide".to_string(), Value::Str("base".to_string()));
m.insert("tierBased".to_string(), Value::Bool(true));
m.insert("percentage".to_string(), Value::Bool(true));
m.insert("taker".to_string(), self.parse_number(Value::Str("0.000500".to_string()), &[]));
m.insert("maker".to_string(), self.parse_number(Value::Str("0.000100".to_string()), &[]));
m.insert("tiers".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("taker".to_string(), Value::List(vec![Value::List(vec![self.parse_number(Value::Str("0".to_string()), &[]), self.parse_number(Value::Str("0.000500".to_string()), &[])]), Value::List(vec![self.parse_number(Value::Str("250".to_string()), &[]), self.parse_number(Value::Str("0.000450".to_string()), &[])]), Value::List(vec![self.parse_number(Value::Str("2500".to_string()), &[]), self.parse_number(Value::Str("0.000400".to_string()), &[])]), Value::List(vec![self.parse_number(Value::Str("7500".to_string()), &[]), self.parse_number(Value::Str("0.000300".to_string()), &[])]), Value::List(vec![self.parse_number(Value::Str("22500".to_string()), &[]), self.parse_number(Value::Str("0.000250".to_string()), &[])]), Value::List(vec![self.parse_number(Value::Str("50000".to_string()), &[]), self.parse_number(Value::Str("0.000240".to_string()), &[])]), Value::List(vec![self.parse_number(Value::Str("100000".to_string()), &[]), self.parse_number(Value::Str("0.000240".to_string()), &[])]), Value::List(vec![self.parse_number(Value::Str("200000".to_string()), &[]), self.parse_number(Value::Str("0.000240".to_string()), &[])]), Value::List(vec![self.parse_number(Value::Str("400000".to_string()), &[]), self.parse_number(Value::Str("0.000240".to_string()), &[])]), Value::List(vec![self.parse_number(Value::Str("750000".to_string()), &[]), self.parse_number(Value::Str("0.000240".to_string()), &[])])]));
m.insert("maker".to_string(), Value::List(vec![Value::List(vec![self.parse_number(Value::Str("0".to_string()), &[]), self.parse_number(Value::Str("0.000100".to_string()), &[])]), Value::List(vec![self.parse_number(Value::Str("250".to_string()), &[]), self.parse_number(Value::Str("0.000080".to_string()), &[])]), Value::List(vec![self.parse_number(Value::Str("2500".to_string()), &[]), self.parse_number(Value::Str("0.000050".to_string()), &[])]), Value::List(vec![self.parse_number(Value::Str("7500".to_string()), &[]), self.parse_number(Value::Str("0.0000030".to_string()), &[])]), Value::List(vec![self.parse_number(Value::Str("22500".to_string()), &[]), self.parse_number(Value::Str("0".to_string()), &[])]), Value::List(vec![self.parse_number(Value::Str("50000".to_string()), &[]), self.parse_number(Value::Str("-0.000050".to_string()), &[])]), Value::List(vec![self.parse_number(Value::Str("100000".to_string()), &[]), self.parse_number(Value::Str("-0.000060".to_string()), &[])]), Value::List(vec![self.parse_number(Value::Str("200000".to_string()), &[]), self.parse_number(Value::Str("-0.000070".to_string()), &[])]), Value::List(vec![self.parse_number(Value::Str("400000".to_string()), &[]), self.parse_number(Value::Str("-0.000080".to_string()), &[])]), Value::List(vec![self.parse_number(Value::Str("750000".to_string()), &[]), self.parse_number(Value::Str("-0.000090".to_string()), &[])])]));
m
}));
m
}));
m
}));
m.insert("option".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m
}));
m
}));
m.insert("currencies".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("BNFCR".to_string(), self.safe_currency_structure(Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("id".to_string(), Value::Str("BNFCR".to_string()));
m.insert("code".to_string(), Value::Str("BNFCR".to_string()));
m.insert("precision".to_string(), self.parse_number(Value::Str("0.001".to_string()), &[]));
m
})));
m
}));
m.insert("commonCurrencies".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("BCC".to_string(), Value::Str("BCC".to_string()));
m.insert("YOYO".to_string(), Value::Str("YOYOW".to_string()));
m
}));
m.insert("precisionMode".to_string(), Value::Int(crate::runtime::TICK_SIZE));
m.insert("options".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("sandboxMode".to_string(), Value::Bool(false));
m.insert("fetchMargins".to_string(), Value::Bool(true));
m.insert("fetchMarkets".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("types".to_string(), Value::List(vec![Value::Str("spot".to_string()), Value::Str("linear".to_string()), Value::Str("inverse".to_string())]));
m.insert("loadAllOptions".to_string(), Value::Bool(false));
m
}));
m.insert("fetchCurrencies".to_string(), Value::Bool(true));
m.insert("createOrder".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("timeInForce".to_string(), Value::Str("GTC".to_string()));
m.insert("warnOnSTPForInverse".to_string(), Value::Bool(true));
m.insert("quoteOrderQty".to_string(), Value::Bool(true));
m
}));
m.insert("defaultType".to_string(), Value::Str("spot".to_string()));
m.insert("defaultSubType".to_string(), Value::Null);
m.insert("hasAlreadyAuthenticatedSuccessfully".to_string(), Value::Bool(false));
m.insert("fetchOpenOrders".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("warnWithoutSymbol".to_string(), Value::Bool(true));
m
}));
m.insert("currencyToPrecisionRoundingMode".to_string(), Value::Int(crate::runtime::TRUNCATE));
m.insert("setMarginMode".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("throwMarginModeAlreadySet".to_string(), Value::Bool(true));
m
}));
m.insert("fetchPositions".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("method".to_string(), Value::Str("positionRisk".to_string()));
m
}));
m.insert("recvWindow".to_string(), multiply(&Value::Int(10), &Value::Int(1000)));
m.insert("timeDifference".to_string(), Value::Int(0));
m.insert("adjustForTimeDifference".to_string(), Value::Bool(false));
m.insert("newOrderRespType".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("market".to_string(), Value::Str("FULL".to_string()));
m.insert("limit".to_string(), Value::Str("FULL".to_string()));
m
}));
m.insert("broker".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("spot".to_string(), Value::Str("x-TKT5PX2F".to_string()));
m.insert("margin".to_string(), Value::Str("x-TKT5PX2F".to_string()));
m.insert("future".to_string(), Value::Str("x-cvBPrNm9".to_string()));
m.insert("delivery".to_string(), Value::Str("x-xcKtGhcu".to_string()));
m.insert("swap".to_string(), Value::Str("x-cvBPrNm9".to_string()));
m.insert("option".to_string(), Value::Str("x-xcKtGhcu".to_string()));
m.insert("inverse".to_string(), Value::Str("x-xcKtGhcu".to_string()));
m
}));
m.insert("accountsByType".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("main".to_string(), Value::Str("MAIN".to_string()));
m.insert("spot".to_string(), Value::Str("MAIN".to_string()));
m.insert("funding".to_string(), Value::Str("FUNDING".to_string()));
m.insert("margin".to_string(), Value::Str("MARGIN".to_string()));
m.insert("cross".to_string(), Value::Str("MARGIN".to_string()));
m.insert("future".to_string(), Value::Str("UMFUTURE".to_string()));
m.insert("delivery".to_string(), Value::Str("CMFUTURE".to_string()));
m.insert("linear".to_string(), Value::Str("UMFUTURE".to_string()));
m.insert("swap".to_string(), Value::Str("UMFUTURE".to_string()));
m.insert("inverse".to_string(), Value::Str("CMFUTURE".to_string()));
m.insert("option".to_string(), Value::Str("OPTION".to_string()));
m
}));
m.insert("accountsById".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("MAIN".to_string(), Value::Str("spot".to_string()));
m.insert("FUNDING".to_string(), Value::Str("funding".to_string()));
m.insert("MARGIN".to_string(), Value::Str("margin".to_string()));
m.insert("UMFUTURE".to_string(), Value::Str("linear".to_string()));
m.insert("CMFUTURE".to_string(), Value::Str("inverse".to_string()));
m.insert("OPTION".to_string(), Value::Str("option".to_string()));
m
}));
m.insert("networks".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("BTC".to_string(), Value::Str("BTC".to_string()));
m.insert("BTCSEGWIT".to_string(), Value::Str("SEGWITBTC".to_string()));
m.insert("BTCLIGHTNING".to_string(), Value::Str("LIGHTNING".to_string()));
m.insert("ERC20".to_string(), Value::Str("ETH".to_string()));
m.insert("ETH".to_string(), Value::Str("ETH".to_string()));
m.insert("TRC20".to_string(), Value::Str("TRX".to_string()));
m.insert("TRX".to_string(), Value::Str("TRX".to_string()));
m.insert("BEP2".to_string(), Value::Str("BNB".to_string()));
m.insert("BSC".to_string(), Value::Str("BSC".to_string()));
m.insert("BEP20".to_string(), Value::Str("BSC".to_string()));
m.insert("CHZ2".to_string(), Value::Str("CHZ2".to_string()));
m.insert("XRP".to_string(), Value::Str("XRP".to_string()));
m.insert("EOS".to_string(), Value::Str("EOS".to_string()));
m.insert("DOGE".to_string(), Value::Str("DOGE".to_string()));
m.insert("SOL".to_string(), Value::Str("SOL".to_string()));
m.insert("SONIC".to_string(), Value::Str("SONIC".to_string()));
m.insert("ARBITRUM".to_string(), Value::Str("ARBITRUM".to_string()));
m.insert("AVAXC".to_string(), Value::Str("AVAXC".to_string()));
m.insert("MATIC".to_string(), Value::Str("MATIC".to_string()));
m.insert("BASE".to_string(), Value::Str("BASE".to_string()));
m.insert("SUI".to_string(), Value::Str("SUI".to_string()));
m.insert("OP".to_string(), Value::Str("OPTIMISM".to_string()));
m.insert("OPTIMISM".to_string(), Value::Str("OPTIMISM".to_string()));
m.insert("NEAR".to_string(), Value::Str("NEAR".to_string()));
m.insert("APT".to_string(), Value::Str("APT".to_string()));
m.insert("SCROLL".to_string(), Value::Str("SCROLL".to_string()));
m.insert("KAVA".to_string(), Value::Str("KAVA".to_string()));
m.insert("XLM".to_string(), Value::Str("XLM".to_string()));
m.insert("RSK".to_string(), Value::Str("RSK".to_string()));
m.insert("SEI".to_string(), Value::Str("SEI".to_string()));
m.insert("TON".to_string(), Value::Str("TON".to_string()));
m.insert("ADA".to_string(), Value::Str("ADA".to_string()));
m.insert("ALGO".to_string(), Value::Str("ALGO".to_string()));
m.insert("RUNE".to_string(), Value::Str("RUNE".to_string()));
m.insert("OSMO".to_string(), Value::Str("OSMO".to_string()));
m.insert("CELO".to_string(), Value::Str("CELO".to_string()));
m.insert("HBAR".to_string(), Value::Str("HBAR".to_string()));
m.insert("ZKSYNCERA".to_string(), Value::Str("ZKSYNCERA".to_string()));
m.insert("KLAY".to_string(), Value::Str("KLAY".to_string()));
m.insert("ACA".to_string(), Value::Str("ACA".to_string()));
m.insert("STX".to_string(), Value::Str("STX".to_string()));
m.insert("XTZ".to_string(), Value::Str("XTZ".to_string()));
m.insert("METIS".to_string(), Value::Str("METIS".to_string()));
m.insert("EGLD".to_string(), Value::Str("EGLD".to_string()));
m.insert("ASTR".to_string(), Value::Str("ASTR".to_string()));
m.insert("CFX".to_string(), Value::Str("CFX".to_string()));
m.insert("SCRT".to_string(), Value::Str("SCRT".to_string()));
m.insert("ONT".to_string(), Value::Str("ONT".to_string()));
m.insert("ZEC".to_string(), Value::Str("ZEC".to_string()));
m.insert("XMR".to_string(), Value::Str("XMR".to_string()));
m.insert("BCH".to_string(), Value::Str("BCH".to_string()));
m.insert("LTC".to_string(), Value::Str("LTC".to_string()));
m.insert("TAO".to_string(), Value::Str("TAO".to_string()));
m.insert("WLD".to_string(), Value::Str("WLD".to_string()));
m.insert("ICP".to_string(), Value::Str("ICP".to_string()));
m.insert("FLR".to_string(), Value::Str("FLR".to_string()));
m.insert("COSMOS".to_string(), Value::Str("ATOM".to_string()));
m.insert("ATOM".to_string(), Value::Str("ATOM".to_string()));
m.insert("FIL".to_string(), Value::Str("FIL".to_string()));
m.insert("INJ".to_string(), Value::Str("INJ".to_string()));
m.insert("DASH".to_string(), Value::Str("DASH".to_string()));
m.insert("VET".to_string(), Value::Str("VET".to_string()));
m.insert("FET".to_string(), Value::Str("FET".to_string()));
m.insert("TIA".to_string(), Value::Str("TIA".to_string()));
m.insert("KAIA".to_string(), Value::Str("KAIA".to_string()));
m.insert("DCR".to_string(), Value::Str("DCR".to_string()));
m.insert("IOTA".to_string(), Value::Str("IOTA".to_string()));
m.insert("THETA".to_string(), Value::Str("THETA".to_string()));
m.insert("AR".to_string(), Value::Str("AR".to_string()));
m.insert("DYDX".to_string(), Value::Str("DYDX".to_string()));
m.insert("XEC".to_string(), Value::Str("XEC".to_string()));
m.insert("QTUM".to_string(), Value::Str("QTUM".to_string()));
m.insert("ENJ".to_string(), Value::Str("ENJ".to_string()));
m.insert("RVN".to_string(), Value::Str("RVN".to_string()));
m.insert("ZIL".to_string(), Value::Str("ZIL".to_string()));
m.insert("BERA".to_string(), Value::Str("BERA".to_string()));
m.insert("0G".to_string(), Value::Str("0G".to_string()));
m.insert("MINA".to_string(), Value::Str("MINA".to_string()));
m.insert("AXL".to_string(), Value::Str("AXL".to_string()));
m.insert("ROSE".to_string(), Value::Str("ROSE".to_string()));
m.insert("CKB".to_string(), Value::Str("CKB".to_string()));
m.insert("DGB".to_string(), Value::Str("DGB".to_string()));
m.insert("MOVE".to_string(), Value::Str("MOVE".to_string()));
m.insert("XVG".to_string(), Value::Str("XVG".to_string()));
m.insert("SC".to_string(), Value::Str("SC".to_string()));
m.insert("LINEA".to_string(), Value::Str("LINEA".to_string()));
m.insert("WAVES".to_string(), Value::Str("WAVES".to_string()));
m.insert("MANTA".to_string(), Value::Str("MANTA".to_string()));
m
}));
m.insert("networksById".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("TRX".to_string(), Value::Str("TRC20".to_string()));
m.insert("BSC".to_string(), Value::Str("BEP20".to_string()));
m.insert("ETH".to_string(), Value::Str("ERC20".to_string()));
m.insert("SOL".to_string(), Value::Str("SOL".to_string()));
m.insert("OPTIMISM".to_string(), Value::Str("OP".to_string()));
m
}));
m.insert("impliedNetworks".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("ETH".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("ERC20".to_string(), Value::Str("ETH".to_string()));
m
}));
m.insert("TRX".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("TRC20".to_string(), Value::Str("TRX".to_string()));
m
}));
m
}));
m.insert("legalMoney".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("MXN".to_string(), Value::Bool(true));
m.insert("UGX".to_string(), Value::Bool(true));
m.insert("SEK".to_string(), Value::Bool(true));
m.insert("CHF".to_string(), Value::Bool(true));
m.insert("VND".to_string(), Value::Bool(true));
m.insert("AED".to_string(), Value::Bool(true));
m.insert("DKK".to_string(), Value::Bool(true));
m.insert("KZT".to_string(), Value::Bool(true));
m.insert("HUF".to_string(), Value::Bool(true));
m.insert("PEN".to_string(), Value::Bool(true));
m.insert("PHP".to_string(), Value::Bool(true));
m.insert("USD".to_string(), Value::Bool(true));
m.insert("TRY".to_string(), Value::Bool(true));
m.insert("EUR".to_string(), Value::Bool(true));
m.insert("NGN".to_string(), Value::Bool(true));
m.insert("PLN".to_string(), Value::Bool(true));
m.insert("BRL".to_string(), Value::Bool(true));
m.insert("ZAR".to_string(), Value::Bool(true));
m.insert("KES".to_string(), Value::Bool(true));
m.insert("ARS".to_string(), Value::Bool(true));
m.insert("RUB".to_string(), Value::Bool(true));
m.insert("AUD".to_string(), Value::Bool(true));
m.insert("NOK".to_string(), Value::Bool(true));
m.insert("CZK".to_string(), Value::Bool(true));
m.insert("GBP".to_string(), Value::Bool(true));
m.insert("UAH".to_string(), Value::Bool(true));
m.insert("GHS".to_string(), Value::Bool(true));
m.insert("HKD".to_string(), Value::Bool(true));
m.insert("CAD".to_string(), Value::Bool(true));
m.insert("INR".to_string(), Value::Bool(true));
m.insert("JPY".to_string(), Value::Bool(true));
m.insert("NZD".to_string(), Value::Bool(true));
m
}));
m.insert("legalMoneyCurrenciesById".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("BUSD".to_string(), Value::Str("USD".to_string()));
m
}));
m.insert("defaultWithdrawPrecision".to_string(), Value::Float(1e-8));
m.insert("defaultFiatWithdrawPrecision".to_string(), Value::Float(0.01));
m
}));
m.insert("features".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("spot".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("sandbox".to_string(), Value::Bool(true));
m.insert("fetchCurrencies".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("private".to_string(), Value::Bool(true));
m
}));
m.insert("createOrder".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("marginMode".to_string(), Value::Bool(true));
m.insert("triggerPrice".to_string(), Value::Bool(true));
m.insert("triggerPriceType".to_string(), Value::Null);
m.insert("triggerDirection".to_string(), Value::Bool(false));
m.insert("stopLossPrice".to_string(), Value::Bool(true));
m.insert("takeProfitPrice".to_string(), Value::Bool(true));
m.insert("attachedStopLossTakeProfit".to_string(), Value::Null);
m.insert("timeInForce".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("IOC".to_string(), Value::Bool(true));
m.insert("FOK".to_string(), Value::Bool(true));
m.insert("PO".to_string(), Value::Bool(true));
m.insert("GTD".to_string(), Value::Bool(false));
m
}));
m.insert("hedged".to_string(), Value::Bool(true));
m.insert("leverage".to_string(), Value::Bool(false));
m.insert("marketBuyByCost".to_string(), Value::Bool(true));
m.insert("marketBuyRequiresPrice".to_string(), Value::Bool(false));
m.insert("selfTradePrevention".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("EXPIRE_MAKER".to_string(), Value::Bool(true));
m.insert("EXPIRE_TAKER".to_string(), Value::Bool(true));
m.insert("EXPIRE_BOTH".to_string(), Value::Bool(true));
m.insert("NONE".to_string(), Value::Bool(true));
m
}));
m.insert("trailing".to_string(), Value::Bool(false));
m.insert("icebergAmount".to_string(), Value::Bool(true));
m
}));
m.insert("createOrders".to_string(), Value::Null);
m.insert("fetchMyTrades".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("marginMode".to_string(), Value::Bool(false));
m.insert("limit".to_string(), Value::Int(1000));
m.insert("daysBack".to_string(), Value::Null);
m.insert("untilDays".to_string(), Value::Int(1));
m.insert("symbolRequired".to_string(), Value::Bool(true));
m
}));
m.insert("fetchOrder".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("marginMode".to_string(), Value::Bool(true));
m.insert("trigger".to_string(), Value::Bool(false));
m.insert("trailing".to_string(), Value::Bool(false));
m.insert("symbolRequired".to_string(), Value::Bool(true));
m
}));
m.insert("fetchOpenOrders".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("marginMode".to_string(), Value::Bool(true));
m.insert("limit".to_string(), Value::Null);
m.insert("trigger".to_string(), Value::Bool(false));
m.insert("trailing".to_string(), Value::Bool(false));
m.insert("symbolRequired".to_string(), Value::Bool(false));
m
}));
m.insert("fetchOrders".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("marginMode".to_string(), Value::Bool(true));
m.insert("limit".to_string(), Value::Int(1000));
m.insert("daysBack".to_string(), Value::Null);
m.insert("untilDays".to_string(), Value::Int(10000));
m.insert("trigger".to_string(), Value::Bool(false));
m.insert("trailing".to_string(), Value::Bool(false));
m.insert("symbolRequired".to_string(), Value::Bool(true));
m
}));
m.insert("fetchClosedOrders".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("marginMode".to_string(), Value::Bool(true));
m.insert("limit".to_string(), Value::Int(1000));
m.insert("daysBack".to_string(), Value::Null);
m.insert("daysBackCanceled".to_string(), Value::Null);
m.insert("untilDays".to_string(), Value::Int(10000));
m.insert("trigger".to_string(), Value::Bool(false));
m.insert("trailing".to_string(), Value::Bool(false));
m.insert("symbolRequired".to_string(), Value::Bool(true));
m
}));
m.insert("fetchOHLCV".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("limit".to_string(), Value::Int(1000));
m
}));
m
}));
m.insert("forDerivatives".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("sandbox".to_string(), Value::Bool(true));
m.insert("createOrder".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("marginMode".to_string(), Value::Bool(false));
m.insert("triggerPrice".to_string(), Value::Bool(true));
m.insert("triggerPriceType".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("mark".to_string(), Value::Bool(true));
m.insert("last".to_string(), Value::Bool(true));
m.insert("index".to_string(), Value::Bool(false));
m
}));
m.insert("stopLossPrice".to_string(), Value::Bool(true));
m.insert("takeProfitPrice".to_string(), Value::Bool(true));
m.insert("attachedStopLossTakeProfit".to_string(), Value::Null);
m.insert("timeInForce".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("IOC".to_string(), Value::Bool(true));
m.insert("FOK".to_string(), Value::Bool(true));
m.insert("PO".to_string(), Value::Bool(true));
m.insert("GTD".to_string(), Value::Bool(true));
m
}));
m.insert("hedged".to_string(), Value::Bool(true));
m.insert("selfTradePrevention".to_string(), Value::Bool(true));
m.insert("trailing".to_string(), Value::Bool(true));
m.insert("iceberg".to_string(), Value::Bool(false));
m.insert("leverage".to_string(), Value::Bool(false));
m.insert("marketBuyRequiresPrice".to_string(), Value::Bool(false));
m.insert("marketBuyByCost".to_string(), Value::Bool(true));
m
}));
m.insert("createOrders".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("max".to_string(), Value::Int(5));
m
}));
m.insert("fetchMyTrades".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("marginMode".to_string(), Value::Bool(false));
m.insert("daysBack".to_string(), Value::Null);
m.insert("limit".to_string(), Value::Int(1000));
m.insert("untilDays".to_string(), Value::Int(7));
m.insert("symbolRequired".to_string(), Value::Bool(true));
m
}));
m.insert("fetchOrder".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("marginMode".to_string(), Value::Bool(false));
m.insert("trigger".to_string(), Value::Bool(false));
m.insert("trailing".to_string(), Value::Bool(false));
m.insert("symbolRequired".to_string(), Value::Bool(true));
m
}));
m.insert("fetchOpenOrders".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("marginMode".to_string(), Value::Bool(true));
m.insert("limit".to_string(), Value::Int(500));
m.insert("trigger".to_string(), Value::Bool(false));
m.insert("trailing".to_string(), Value::Bool(false));
m.insert("symbolRequired".to_string(), Value::Bool(false));
m
}));
m.insert("fetchOrders".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("marginMode".to_string(), Value::Bool(true));
m.insert("limit".to_string(), Value::Int(1000));
m.insert("daysBack".to_string(), Value::Int(90));
m.insert("untilDays".to_string(), Value::Int(7));
m.insert("trigger".to_string(), Value::Bool(false));
m.insert("trailing".to_string(), Value::Bool(false));
m.insert("symbolRequired".to_string(), Value::Bool(true));
m
}));
m.insert("fetchClosedOrders".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("marginMode".to_string(), Value::Bool(true));
m.insert("limit".to_string(), Value::Int(1000));
m.insert("daysBack".to_string(), Value::Int(90));
m.insert("daysBackCanceled".to_string(), Value::Int(3));
m.insert("untilDays".to_string(), Value::Int(7));
m.insert("trigger".to_string(), Value::Bool(false));
m.insert("trailing".to_string(), Value::Bool(false));
m.insert("symbolRequired".to_string(), Value::Bool(true));
m
}));
m.insert("fetchOHLCV".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("limit".to_string(), Value::Int(500));
m
}));
m
}));
m.insert("swap".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("linear".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("extends".to_string(), Value::Str("forDerivatives".to_string()));
m
}));
m.insert("inverse".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("extends".to_string(), Value::Str("forDerivatives".to_string()));
m
}));
m
}));
m.insert("future".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("linear".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("extends".to_string(), Value::Str("forDerivatives".to_string()));
m
}));
m.insert("inverse".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("extends".to_string(), Value::Str("forDerivatives".to_string()));
m
}));
m
}));
m
}));
m.insert("exceptions".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("spot".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("exact".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("-1004".to_string(), Value::Str("OperationFailed".to_string()).clone());
m.insert("-1008".to_string(), Value::Str("OperationFailed".to_string()).clone());
m.insert("-1099".to_string(), Value::Str("AuthenticationError".to_string()).clone());
m.insert("-1108".to_string(), Value::Str("BadRequest".to_string()).clone());
m.insert("-1131".to_string(), Value::Str("BadRequest".to_string()).clone());
m.insert("-1134".to_string(), Value::Str("BadRequest".to_string()).clone());
m.insert("-1135".to_string(), Value::Str("BadRequest".to_string()).clone());
m.insert("-1145".to_string(), Value::Str("BadRequest".to_string()).clone());
m.insert("-1151".to_string(), Value::Str("BadSymbol".to_string()).clone());
m.insert("-2008".to_string(), Value::Str("AuthenticationError".to_string()).clone());
m.insert("-2016".to_string(), Value::Str("OperationRejected".to_string()).clone());
m.insert("-2021".to_string(), Value::Str("BadResponse".to_string()).clone());
m.insert("-2022".to_string(), Value::Str("BadResponse".to_string()).clone());
m.insert("-2026".to_string(), Value::Str("InvalidOrder".to_string()).clone());
m.insert("-3000".to_string(), Value::Str("OperationFailed".to_string()).clone());
m.insert("-3001".to_string(), Value::Str("AuthenticationError".to_string()).clone());
m.insert("-3002".to_string(), Value::Str("BadSymbol".to_string()).clone());
m.insert("-3003".to_string(), Value::Str("BadRequest".to_string()).clone());
m.insert("-3004".to_string(), Value::Str("OperationRejected".to_string()).clone());
m.insert("-3005".to_string(), Value::Str("BadRequest".to_string()).clone());
m.insert("-3006".to_string(), Value::Str("BadRequest".to_string()).clone());
m.insert("-3007".to_string(), Value::Str("OperationFailed".to_string()).clone());
m.insert("-3008".to_string(), Value::Str("BadRequest".to_string()).clone());
m.insert("-3009".to_string(), Value::Str("OperationRejected".to_string()).clone());
m.insert("-3010".to_string(), Value::Str("BadRequest".to_string()).clone());
m.insert("-3011".to_string(), Value::Str("BadRequest".to_string()).clone());
m.insert("-3012".to_string(), Value::Str("OperationRejected".to_string()).clone());
m.insert("-3013".to_string(), Value::Str("BadRequest".to_string()).clone());
m.insert("-3014".to_string(), Value::Str("AccountSuspended".to_string()).clone());
m.insert("-3015".to_string(), Value::Str("BadRequest".to_string()).clone());
m.insert("-3016".to_string(), Value::Str("BadRequest".to_string()).clone());
m.insert("-3017".to_string(), Value::Str("OperationRejected".to_string()).clone());
m.insert("-3018".to_string(), Value::Str("AccountSuspended".to_string()).clone());
m.insert("-3019".to_string(), Value::Str("AccountSuspended".to_string()).clone());
m.insert("-3020".to_string(), Value::Str("BadRequest".to_string()).clone());
m.insert("-3021".to_string(), Value::Str("BadRequest".to_string()).clone());
m.insert("-3022".to_string(), Value::Str("AccountSuspended".to_string()).clone());
m.insert("-3023".to_string(), Value::Str("OperationRejected".to_string()).clone());
m.insert("-3024".to_string(), Value::Str("OperationRejected".to_string()).clone());
m.insert("-3025".to_string(), Value::Str("BadRequest".to_string()).clone());
m.insert("-3026".to_string(), Value::Str("BadRequest".to_string()).clone());
m.insert("-3027".to_string(), Value::Str("BadSymbol".to_string()).clone());
m.insert("-3028".to_string(), Value::Str("BadSymbol".to_string()).clone());
m.insert("-3029".to_string(), Value::Str("OperationFailed".to_string()).clone());
m.insert("-3036".to_string(), Value::Str("AccountSuspended".to_string()).clone());
m.insert("-3037".to_string(), Value::Str("OperationFailed".to_string()).clone());
m.insert("-3038".to_string(), Value::Str("BadRequest".to_string()).clone());
m.insert("-3041".to_string(), Value::Str("InsufficientFunds".to_string()).clone());
m.insert("-3042".to_string(), Value::Str("BadRequest".to_string()).clone());
m.insert("-3043".to_string(), Value::Str("PermissionDenied".to_string()).clone());
m.insert("-3044".to_string(), Value::Str("OperationFailed".to_string()).clone());
m.insert("-3045".to_string(), Value::Str("OperationRejected".to_string()).clone());
m.insert("-3999".to_string(), Value::Str("PermissionDenied".to_string()).clone());
m.insert("-4000".to_string(), Value::Str("ExchangeError".to_string()).clone());
m.insert("-4001".to_string(), Value::Str("BadRequest".to_string()).clone());
m.insert("-4002".to_string(), Value::Str("BadRequest".to_string()).clone());
m.insert("-4003".to_string(), Value::Str("BadRequest".to_string()).clone());
m.insert("-4004".to_string(), Value::Str("AuthenticationError".to_string()).clone());
m.insert("-4005".to_string(), Value::Str("RateLimitExceeded".to_string()).clone());
m.insert("-4006".to_string(), Value::Str("BadRequest".to_string()).clone());
m.insert("-4007".to_string(), Value::Str("PermissionDenied".to_string()).clone());
m.insert("-4008".to_string(), Value::Str("PermissionDenied".to_string()).clone());
m.insert("-4009".to_string(), Value::Str("ExchangeError".to_string()).clone());
m.insert("-4010".to_string(), Value::Str("PermissionDenied".to_string()).clone());
m.insert("-4011".to_string(), Value::Str("BadRequest".to_string()).clone());
m.insert("-4012".to_string(), Value::Str("PermissionDenied".to_string()).clone());
m.insert("-4013".to_string(), Value::Str("AuthenticationError".to_string()).clone());
m.insert("-4014".to_string(), Value::Str("OperationRejected".to_string()).clone());
m.insert("-4015".to_string(), Value::Str("PermissionDenied".to_string()).clone());
m.insert("-4016".to_string(), Value::Str("PermissionDenied".to_string()).clone());
m.insert("-4017".to_string(), Value::Str("PermissionDenied".to_string()).clone());
m.insert("-4018".to_string(), Value::Str("BadSymbol".to_string()).clone());
m.insert("-4019".to_string(), Value::Str("BadRequest".to_string()).clone());
m.insert("-4020".to_string(), Value::Str("ExchangeError".to_string()).clone());
m.insert("-4021".to_string(), Value::Str("BadRequest".to_string()).clone());
m.insert("-4022".to_string(), Value::Str("BadRequest".to_string()).clone());
m.insert("-4023".to_string(), Value::Str("OperationRejected".to_string()).clone());
m.insert("-4024".to_string(), Value::Str("InsufficientFunds".to_string()).clone());
m.insert("-4025".to_string(), Value::Str("InsufficientFunds".to_string()).clone());
m.insert("-4026".to_string(), Value::Str("InsufficientFunds".to_string()).clone());
m.insert("-4027".to_string(), Value::Str("OperationFailed".to_string()).clone());
m.insert("-4028".to_string(), Value::Str("BadRequest".to_string()).clone());
m.insert("-4029".to_string(), Value::Str("BadRequest".to_string()).clone());
m.insert("-4030".to_string(), Value::Str("BadResponse".to_string()).clone());
m.insert("-4031".to_string(), Value::Str("OperationFailed".to_string()).clone());
m.insert("-4032".to_string(), Value::Str("OperationRejected".to_string()).clone());
m.insert("-4033".to_string(), Value::Str("BadRequest".to_string()).clone());
m.insert("-4034".to_string(), Value::Str("OperationRejected".to_string()).clone());
m.insert("-4035".to_string(), Value::Str("PermissionDenied".to_string()).clone());
m.insert("-4036".to_string(), Value::Str("PermissionDenied".to_string()).clone());
m.insert("-4037".to_string(), Value::Str("OperationFailed".to_string()).clone());
m.insert("-4038".to_string(), Value::Str("OperationFailed".to_string()).clone());
m.insert("-4039".to_string(), Value::Str("PermissionDenied".to_string()).clone());
m.insert("-4040".to_string(), Value::Str("OperationRejected".to_string()).clone());
m.insert("-4041".to_string(), Value::Str("OperationFailed".to_string()).clone());
m.insert("-4042".to_string(), Value::Str("OperationRejected".to_string()).clone());
m.insert("-4043".to_string(), Value::Str("OperationRejected".to_string()).clone());
m.insert("-4044".to_string(), Value::Str("PermissionDenied".to_string()).clone());
m.insert("-4045".to_string(), Value::Str("OperationFailed".to_string()).clone());
m.insert("-4046".to_string(), Value::Str("AuthenticationError".to_string()).clone());
m.insert("-4047".to_string(), Value::Str("BadRequest".to_string()).clone());
m.insert("-4048".to_string(), Value::Str("ExchangeError".to_string()).clone());
m.insert("-4049".to_string(), Value::Str("ExchangeError".to_string()).clone());
m.insert("-4050".to_string(), Value::Str("ExchangeError".to_string()).clone());
m.insert("-4051".to_string(), Value::Str("ExchangeError".to_string()).clone());
m.insert("-4052".to_string(), Value::Str("ExchangeError".to_string()).clone());
m.insert("-4053".to_string(), Value::Str("ExchangeError".to_string()).clone());
m.insert("-4054".to_string(), Value::Str("ExchangeError".to_string()).clone());
m.insert("-4055".to_string(), Value::Str("ExchangeError".to_string()).clone());
m.insert("-4056".to_string(), Value::Str("ExchangeError".to_string()).clone());
m.insert("-4057".to_string(), Value::Str("ExchangeError".to_string()).clone());
m.insert("-4058".to_string(), Value::Str("ExchangeError".to_string()).clone());
m.insert("-4059".to_string(), Value::Str("ExchangeError".to_string()).clone());
m.insert("-4060".to_string(), Value::Str("OperationFailed".to_string()).clone());
m.insert("-4061".to_string(), Value::Str("ExchangeError".to_string()).clone());
m.insert("-4062".to_string(), Value::Str("ExchangeError".to_string()).clone());
m.insert("-4063".to_string(), Value::Str("ExchangeError".to_string()).clone());
m.insert("-4064".to_string(), Value::Str("ExchangeError".to_string()).clone());
m.insert("-4065".to_string(), Value::Str("ExchangeError".to_string()).clone());
m.insert("-4066".to_string(), Value::Str("ExchangeError".to_string()).clone());
m.insert("-4067".to_string(), Value::Str("ExchangeError".to_string()).clone());
m.insert("-4068".to_string(), Value::Str("ExchangeError".to_string()).clone());
m.insert("-4069".to_string(), Value::Str("ExchangeError".to_string()).clone());
m.insert("-4070".to_string(), Value::Str("ExchangeError".to_string()).clone());
m.insert("-4071".to_string(), Value::Str("ExchangeError".to_string()).clone());
m.insert("-4072".to_string(), Value::Str("ExchangeError".to_string()).clone());
m.insert("-4073".to_string(), Value::Str("ExchangeError".to_string()).clone());
m.insert("-4074".to_string(), Value::Str("ExchangeError".to_string()).clone());
m.insert("-4075".to_string(), Value::Str("ExchangeError".to_string()).clone());
m.insert("-4076".to_string(), Value::Str("ExchangeError".to_string()).clone());
m.insert("-4077".to_string(), Value::Str("ExchangeError".to_string()).clone());
m.insert("-4078".to_string(), Value::Str("ExchangeError".to_string()).clone());
m.insert("-4079".to_string(), Value::Str("ExchangeError".to_string()).clone());
m.insert("-4080".to_string(), Value::Str("ExchangeError".to_string()).clone());
m.insert("-4081".to_string(), Value::Str("ExchangeError".to_string()).clone());
m.insert("-4082".to_string(), Value::Str("ExchangeError".to_string()).clone());
m.insert("-4083".to_string(), Value::Str("ExchangeError".to_string()).clone());
m.insert("-4084".to_string(), Value::Str("ExchangeError".to_string()).clone());
m.insert("-4085".to_string(), Value::Str("ExchangeError".to_string()).clone());
m.insert("-4086".to_string(), Value::Str("ExchangeError".to_string()).clone());
m.insert("-4087".to_string(), Value::Str("ExchangeError".to_string()).clone());
m.insert("-4088".to_string(), Value::Str("ExchangeError".to_string()).clone());
m.insert("-4089".to_string(), Value::Str("ExchangeError".to_string()).clone());
m.insert("-4091".to_string(), Value::Str("ExchangeError".to_string()).clone());
m.insert("-4092".to_string(), Value::Str("ExchangeError".to_string()).clone());
m.insert("-4093".to_string(), Value::Str("ExchangeError".to_string()).clone());
m.insert("-4094".to_string(), Value::Str("ExchangeError".to_string()).clone());
m.insert("-4095".to_string(), Value::Str("ExchangeError".to_string()).clone());
m.insert("-4096".to_string(), Value::Str("ExchangeError".to_string()).clone());
m.insert("-4097".to_string(), Value::Str("ExchangeError".to_string()).clone());
m.insert("-4098".to_string(), Value::Str("ExchangeError".to_string()).clone());
m.insert("-4099".to_string(), Value::Str("ExchangeError".to_string()).clone());
m.insert("-4101".to_string(), Value::Str("ExchangeError".to_string()).clone());
m.insert("-4102".to_string(), Value::Str("ExchangeError".to_string()).clone());
m.insert("-4103".to_string(), Value::Str("ExchangeError".to_string()).clone());
m.insert("-4104".to_string(), Value::Str("ExchangeError".to_string()).clone());
m.insert("-4105".to_string(), Value::Str("ExchangeError".to_string()).clone());
m.insert("-4106".to_string(), Value::Str("ExchangeError".to_string()).clone());
m.insert("-4107".to_string(), Value::Str("ExchangeError".to_string()).clone());
m.insert("-4108".to_string(), Value::Str("ExchangeError".to_string()).clone());
m.insert("-4109".to_string(), Value::Str("ExchangeError".to_string()).clone());
m.insert("-4110".to_string(), Value::Str("ExchangeError".to_string()).clone());
m.insert("-4112".to_string(), Value::Str("ExchangeError".to_string()).clone());
m.insert("-4113".to_string(), Value::Str("ExchangeError".to_string()).clone());
m.insert("-4114".to_string(), Value::Str("ExchangeError".to_string()).clone());
m.insert("-4115".to_string(), Value::Str("ExchangeError".to_string()).clone());
m.insert("-4116".to_string(), Value::Str("ExchangeError".to_string()).clone());
m.insert("-4117".to_string(), Value::Str("ExchangeError".to_string()).clone());
m.insert("-4118".to_string(), Value::Str("ExchangeError".to_string()).clone());
m.insert("-4119".to_string(), Value::Str("ExchangeError".to_string()).clone());
m.insert("-4120".to_string(), Value::Str("ExchangeError".to_string()).clone());
m.insert("-4121".to_string(), Value::Str("ExchangeError".to_string()).clone());
m.insert("-4122".to_string(), Value::Str("ExchangeError".to_string()).clone());
m.insert("-4123".to_string(), Value::Str("ExchangeError".to_string()).clone());
m.insert("-4124".to_string(), Value::Str("ExchangeError".to_string()).clone());
m.insert("-4125".to_string(), Value::Str("ExchangeError".to_string()).clone());
m.insert("-4126".to_string(), Value::Str("ExchangeError".to_string()).clone());
m.insert("-4127".to_string(), Value::Str("ExchangeError".to_string()).clone());
m.insert("-4128".to_string(), Value::Str("ExchangeError".to_string()).clone());
m.insert("-4129".to_string(), Value::Str("ExchangeError".to_string()).clone());
m.insert("-4130".to_string(), Value::Str("ExchangeError".to_string()).clone());
m.insert("-4131".to_string(), Value::Str("ExchangeError".to_string()).clone());
m.insert("-4132".to_string(), Value::Str("ExchangeError".to_string()).clone());
m.insert("-4133".to_string(), Value::Str("ExchangeError".to_string()).clone());
m.insert("-4134".to_string(), Value::Str("ExchangeError".to_string()).clone());
m.insert("-4135".to_string(), Value::Str("ExchangeError".to_string()).clone());
m.insert("-4136".to_string(), Value::Str("ExchangeError".to_string()).clone());
m.insert("-4137".to_string(), Value::Str("ExchangeError".to_string()).clone());
m.insert("-4138".to_string(), Value::Str("ExchangeError".to_string()).clone());
m.insert("-4139".to_string(), Value::Str("ExchangeError".to_string()).clone());
m.insert("-4141".to_string(), Value::Str("ExchangeError".to_string()).clone());
m.insert("-4142".to_string(), Value::Str("ExchangeError".to_string()).clone());
m.insert("-4143".to_string(), Value::Str("ExchangeError".to_string()).clone());
m.insert("-4144".to_string(), Value::Str("ExchangeError".to_string()).clone());
m.insert("-4145".to_string(), Value::Str("ExchangeError".to_string()).clone());
m.insert("-4146".to_string(), Value::Str("ExchangeError".to_string()).clone());
m.insert("-4147".to_string(), Value::Str("ExchangeError".to_string()).clone());
m.insert("-4148".to_string(), Value::Str("ExchangeError".to_string()).clone());
m.insert("-4149".to_string(), Value::Str("ExchangeError".to_string()).clone());
m.insert("-4150".to_string(), Value::Str("ExchangeError".to_string()).clone());
m.insert("-5001".to_string(), Value::Str("BadRequest".to_string()).clone());
m.insert("-5002".to_string(), Value::Str("InsufficientFunds".to_string()).clone());
m.insert("-5003".to_string(), Value::Str("InsufficientFunds".to_string()).clone());
m.insert("-5004".to_string(), Value::Str("OperationRejected".to_string()).clone());
m.insert("-5005".to_string(), Value::Str("OperationRejected".to_string()).clone());
m.insert("-5006".to_string(), Value::Str("OperationRejected".to_string()).clone());
m.insert("-5007".to_string(), Value::Str("BadRequest".to_string()).clone());
m.insert("-5008".to_string(), Value::Str("OperationRejected".to_string()).clone());
m.insert("-5009".to_string(), Value::Str("BadSymbol".to_string()).clone());
m.insert("-5010".to_string(), Value::Str("OperationFailed".to_string()).clone());
m.insert("-5011".to_string(), Value::Str("BadRequest".to_string()).clone());
m.insert("-5012".to_string(), Value::Str("OperationFailed".to_string()).clone());
m.insert("-5013".to_string(), Value::Str("InsufficientFunds".to_string()).clone());
m.insert("-5021".to_string(), Value::Str("BadRequest".to_string()).clone());
m.insert("-5022".to_string(), Value::Str("BadRequest".to_string()).clone());
m.insert("-6001".to_string(), Value::Str("BadSymbol".to_string()).clone());
m.insert("-6003".to_string(), Value::Str("PermissionDenied".to_string()).clone());
m.insert("-6004".to_string(), Value::Str("BadRequest".to_string()).clone());
m.insert("-6005".to_string(), Value::Str("BadRequest".to_string()).clone());
m.insert("-6006".to_string(), Value::Str("BadRequest".to_string()).clone());
m.insert("-6007".to_string(), Value::Str("OperationRejected".to_string()).clone());
m.insert("-6008".to_string(), Value::Str("OperationRejected".to_string()).clone());
m.insert("-6009".to_string(), Value::Str("RateLimitExceeded".to_string()).clone());
m.insert("-6011".to_string(), Value::Str("OperationRejected".to_string()).clone());
m.insert("-6012".to_string(), Value::Str("InsufficientFunds".to_string()).clone());
m.insert("-6013".to_string(), Value::Str("BadResponse".to_string()).clone());
m.insert("-6014".to_string(), Value::Str("OperationRejected".to_string()).clone());
m.insert("-6015".to_string(), Value::Str("BadRequest".to_string()).clone());
m.insert("-6016".to_string(), Value::Str("BadRequest".to_string()).clone());
m.insert("-6017".to_string(), Value::Str("PermissionDenied".to_string()).clone());
m.insert("-6018".to_string(), Value::Str("InsufficientFunds".to_string()).clone());
m.insert("-6019".to_string(), Value::Str("OperationRejected".to_string()).clone());
m.insert("-6020".to_string(), Value::Str("BadRequest".to_string()).clone());
m.insert("-7001".to_string(), Value::Str("BadRequest".to_string()).clone());
m.insert("-7002".to_string(), Value::Str("BadRequest".to_string()).clone());
m.insert("-10001".to_string(), Value::Str("OperationFailed".to_string()).clone());
m.insert("-10002".to_string(), Value::Str("BadRequest".to_string()).clone());
m.insert("-10005".to_string(), Value::Str("BadResponse".to_string()).clone());
m.insert("-10007".to_string(), Value::Str("BadRequest".to_string()).clone());
m.insert("-10008".to_string(), Value::Str("BadRequest".to_string()).clone());
m.insert("-10009".to_string(), Value::Str("BadRequest".to_string()).clone());
m.insert("-10010".to_string(), Value::Str("BadRequest".to_string()).clone());
m.insert("-10011".to_string(), Value::Str("InsufficientFunds".to_string()).clone());
m.insert("-10012".to_string(), Value::Str("BadRequest".to_string()).clone());
m.insert("-10013".to_string(), Value::Str("InsufficientFunds".to_string()).clone());
m.insert("-10015".to_string(), Value::Str("OperationFailed".to_string()).clone());
m.insert("-10016".to_string(), Value::Str("OperationFailed".to_string()).clone());
m.insert("-10017".to_string(), Value::Str("OperationRejected".to_string()).clone());
m.insert("-10018".to_string(), Value::Str("BadRequest".to_string()).clone());
m.insert("-10019".to_string(), Value::Str("BadRequest".to_string()).clone());
m.insert("-10020".to_string(), Value::Str("BadRequest".to_string()).clone());
m.insert("-10021".to_string(), Value::Str("InvalidOrder".to_string()).clone());
m.insert("-10022".to_string(), Value::Str("BadRequest".to_string()).clone());
m.insert("-10023".to_string(), Value::Str("OperationFailed".to_string()).clone());
m.insert("-10024".to_string(), Value::Str("BadRequest".to_string()).clone());
m.insert("-10025".to_string(), Value::Str("OperationFailed".to_string()).clone());
m.insert("-10026".to_string(), Value::Str("BadRequest".to_string()).clone());
m.insert("-10028".to_string(), Value::Str("BadRequest".to_string()).clone());
m.insert("-10029".to_string(), Value::Str("OperationRejected".to_string()).clone());
m.insert("-10030".to_string(), Value::Str("OperationRejected".to_string()).clone());
m.insert("-10031".to_string(), Value::Str("OperationRejected".to_string()).clone());
m.insert("-10032".to_string(), Value::Str("OperationFailed".to_string()).clone());
m.insert("-10034".to_string(), Value::Str("OperationRejected".to_string()).clone());
m.insert("-10039".to_string(), Value::Str("OperationRejected".to_string()).clone());
m.insert("-10040".to_string(), Value::Str("OperationRejected".to_string()).clone());
m.insert("-10041".to_string(), Value::Str("OperationFailed".to_string()).clone());
m.insert("-10042".to_string(), Value::Str("BadSymbol".to_string()).clone());
m.insert("-10043".to_string(), Value::Str("OperationRejected".to_string()).clone());
m.insert("-10044".to_string(), Value::Str("OperationRejected".to_string()).clone());
m.insert("-10045".to_string(), Value::Str("OperationRejected".to_string()).clone());
m.insert("-10046".to_string(), Value::Str("OperationRejected".to_string()).clone());
m.insert("-10047".to_string(), Value::Str("PermissionDenied".to_string()).clone());
m.insert("-11008".to_string(), Value::Str("OperationRejected".to_string()).clone());
m.insert("-12014".to_string(), Value::Str("RateLimitExceeded".to_string()).clone());
m.insert("-13000".to_string(), Value::Str("OperationRejected".to_string()).clone());
m.insert("-13001".to_string(), Value::Str("OperationRejected".to_string()).clone());
m.insert("-13002".to_string(), Value::Str("OperationRejected".to_string()).clone());
m.insert("-13003".to_string(), Value::Str("PermissionDenied".to_string()).clone());
m.insert("-13004".to_string(), Value::Str("OperationRejected".to_string()).clone());
m.insert("-13005".to_string(), Value::Str("OperationRejected".to_string()).clone());
m.insert("-13006".to_string(), Value::Str("OperationRejected".to_string()).clone());
m.insert("-13007".to_string(), Value::Str("PermissionDenied".to_string()).clone());
m.insert("-18002".to_string(), Value::Str("OperationRejected".to_string()).clone());
m.insert("-18003".to_string(), Value::Str("OperationRejected".to_string()).clone());
m.insert("-18004".to_string(), Value::Str("OperationRejected".to_string()).clone());
m.insert("-18005".to_string(), Value::Str("PermissionDenied".to_string()).clone());
m.insert("-18006".to_string(), Value::Str("OperationRejected".to_string()).clone());
m.insert("-18007".to_string(), Value::Str("OperationRejected".to_string()).clone());
m.insert("-21001".to_string(), Value::Str("BadRequest".to_string()).clone());
m.insert("-21002".to_string(), Value::Str("BadRequest".to_string()).clone());
m.insert("-21003".to_string(), Value::Str("BadResponse".to_string()).clone());
m.insert("-21004".to_string(), Value::Str("OperationRejected".to_string()).clone());
m.insert("-21005".to_string(), Value::Str("InsufficientFunds".to_string()).clone());
m.insert("-21006".to_string(), Value::Str("OperationFailed".to_string()).clone());
m.insert("-21007".to_string(), Value::Str("OperationFailed".to_string()).clone());
m.insert("-32603".to_string(), Value::Str("BadRequest".to_string()).clone());
m.insert("400002".to_string(), Value::Str("BadRequest".to_string()).clone());
m.insert("100001003".to_string(), Value::Str("AuthenticationError".to_string()).clone());
m.insert("200003903".to_string(), Value::Str("AuthenticationError".to_string()).clone());
m
}));
m
}));
m.insert("linear".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("exact".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("-1005".to_string(), Value::Str("PermissionDenied".to_string()).clone());
m.insert("-1008".to_string(), Value::Str("OperationFailed".to_string()).clone());
m.insert("-1011".to_string(), Value::Str("PermissionDenied".to_string()).clone());
m.insert("-1023".to_string(), Value::Str("BadRequest".to_string()).clone());
m.insert("-1099".to_string(), Value::Str("AuthenticationError".to_string()).clone());
m.insert("-1109".to_string(), Value::Str("PermissionDenied".to_string()).clone());
m.insert("-1110".to_string(), Value::Str("BadRequest".to_string()).clone());
m.insert("-1113".to_string(), Value::Str("BadRequest".to_string()).clone());
m.insert("-1122".to_string(), Value::Str("BadRequest".to_string()).clone());
m.insert("-1126".to_string(), Value::Str("BadSymbol".to_string()).clone());
m.insert("-1136".to_string(), Value::Str("BadRequest".to_string()).clone());
m.insert("-2012".to_string(), Value::Str("OperationFailed".to_string()).clone());
m.insert("-2016".to_string(), Value::Str("OperationRejected".to_string()).clone());
m.insert("-2017".to_string(), Value::Str("PermissionDenied".to_string()).clone());
m.insert("-2018".to_string(), Value::Str("InsufficientFunds".to_string()).clone());
m.insert("-2019".to_string(), Value::Str("InsufficientFunds".to_string()).clone());
m.insert("-2020".to_string(), Value::Str("OperationFailed".to_string()).clone());
m.insert("-2021".to_string(), Value::Str("OrderImmediatelyFillable".to_string()).clone());
m.insert("-2022".to_string(), Value::Str("InvalidOrder".to_string()).clone());
m.insert("-2023".to_string(), Value::Str("OperationFailed".to_string()).clone());
m.insert("-2024".to_string(), Value::Str("InsufficientFunds".to_string()).clone());
m.insert("-2025".to_string(), Value::Str("OperationRejected".to_string()).clone());
m.insert("-2026".to_string(), Value::Str("InvalidOrder".to_string()).clone());
m.insert("-2027".to_string(), Value::Str("OperationRejected".to_string()).clone());
m.insert("-2028".to_string(), Value::Str("OperationRejected".to_string()).clone());
m.insert("-4063".to_string(), Value::Str("BadRequest".to_string()).clone());
m.insert("-4064".to_string(), Value::Str("BadRequest".to_string()).clone());
m.insert("-4065".to_string(), Value::Str("BadRequest".to_string()).clone());
m.insert("-4066".to_string(), Value::Str("BadRequest".to_string()).clone());
m.insert("-4069".to_string(), Value::Str("BadRequest".to_string()).clone());
m.insert("-4070".to_string(), Value::Str("BadRequest".to_string()).clone());
m.insert("-4071".to_string(), Value::Str("BadRequest".to_string()).clone());
m.insert("-4072".to_string(), Value::Str("OperationRejected".to_string()).clone());
m.insert("-4073".to_string(), Value::Str("BadRequest".to_string()).clone());
m.insert("-4074".to_string(), Value::Str("OperationRejected".to_string()).clone());
m.insert("-4075".to_string(), Value::Str("BadRequest".to_string()).clone());
m.insert("-4076".to_string(), Value::Str("OperationRejected".to_string()).clone());
m.insert("-4077".to_string(), Value::Str("OperationRejected".to_string()).clone());
m.insert("-4078".to_string(), Value::Str("OperationFailed".to_string()).clone());
m.insert("-4079".to_string(), Value::Str("BadRequest".to_string()).clone());
m.insert("-4080".to_string(), Value::Str("PermissionDenied".to_string()).clone());
m.insert("-4081".to_string(), Value::Str("BadRequest".to_string()).clone());
m.insert("-4085".to_string(), Value::Str("BadRequest".to_string()).clone());
m.insert("-4087".to_string(), Value::Str("PermissionDenied".to_string()).clone());
m.insert("-4088".to_string(), Value::Str("PermissionDenied".to_string()).clone());
m.insert("-4114".to_string(), Value::Str("BadRequest".to_string()).clone());
m.insert("-4115".to_string(), Value::Str("BadRequest".to_string()).clone());
m.insert("-4116".to_string(), Value::Str("InvalidOrder".to_string()).clone());
m.insert("-4117".to_string(), Value::Str("OperationRejected".to_string()).clone());
m.insert("-4118".to_string(), Value::Str("OperationRejected".to_string()).clone());
m.insert("-4131".to_string(), Value::Str("OperationRejected".to_string()).clone());
m.insert("-4140".to_string(), Value::Str("BadRequest".to_string()).clone());
m.insert("-4141".to_string(), Value::Str("OperationRejected".to_string()).clone());
m.insert("-4144".to_string(), Value::Str("BadSymbol".to_string()).clone());
m.insert("-4164".to_string(), Value::Str("InvalidOrder".to_string()).clone());
m.insert("-4136".to_string(), Value::Str("InvalidOrder".to_string()).clone());
m.insert("-4165".to_string(), Value::Str("BadRequest".to_string()).clone());
m.insert("-4167".to_string(), Value::Str("BadRequest".to_string()).clone());
m.insert("-4168".to_string(), Value::Str("BadRequest".to_string()).clone());
m.insert("-4169".to_string(), Value::Str("OperationRejected".to_string()).clone());
m.insert("-4170".to_string(), Value::Str("OperationRejected".to_string()).clone());
m.insert("-4171".to_string(), Value::Str("OperationRejected".to_string()).clone());
m.insert("-4172".to_string(), Value::Str("OperationRejected".to_string()).clone());
m.insert("-4183".to_string(), Value::Str("BadRequest".to_string()).clone());
m.insert("-4184".to_string(), Value::Str("BadRequest".to_string()).clone());
m.insert("-4192".to_string(), Value::Str("PermissionDenied".to_string()).clone());
m.insert("-4202".to_string(), Value::Str("PermissionDenied".to_string()).clone());
m.insert("-4203".to_string(), Value::Str("PermissionDenied".to_string()).clone());
m.insert("-4205".to_string(), Value::Str("PermissionDenied".to_string()).clone());
m.insert("-4206".to_string(), Value::Str("PermissionDenied".to_string()).clone());
m.insert("-4208".to_string(), Value::Str("OperationRejected".to_string()).clone());
m.insert("-4209".to_string(), Value::Str("OperationRejected".to_string()).clone());
m.insert("-4210".to_string(), Value::Str("BadRequest".to_string()).clone());
m.insert("-4211".to_string(), Value::Str("BadRequest".to_string()).clone());
m.insert("-4400".to_string(), Value::Str("PermissionDenied".to_string()).clone());
m.insert("-4401".to_string(), Value::Str("PermissionDenied".to_string()).clone());
m.insert("-4402".to_string(), Value::Str("PermissionDenied".to_string()).clone());
m.insert("-4403".to_string(), Value::Str("PermissionDenied".to_string()).clone());
m.insert("-5021".to_string(), Value::Str("OrderNotFillable".to_string()).clone());
m.insert("-5022".to_string(), Value::Str("OrderNotFillable".to_string()).clone());
m.insert("-5024".to_string(), Value::Str("OperationRejected".to_string()).clone());
m.insert("-5025".to_string(), Value::Str("OperationRejected".to_string()).clone());
m.insert("-5026".to_string(), Value::Str("OperationRejected".to_string()).clone());
m.insert("-5027".to_string(), Value::Str("OperationRejected".to_string()).clone());
m.insert("-5028".to_string(), Value::Str("BadRequest".to_string()).clone());
m.insert("-5037".to_string(), Value::Str("BadRequest".to_string()).clone());
m.insert("-5038".to_string(), Value::Str("BadRequest".to_string()).clone());
m.insert("-5039".to_string(), Value::Str("BadRequest".to_string()).clone());
m.insert("-5040".to_string(), Value::Str("BadRequest".to_string()).clone());
m.insert("-5041".to_string(), Value::Str("OperationFailed".to_string()).clone());
m
}));
m
}));
m.insert("inverse".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("exact".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("-1005".to_string(), Value::Str("PermissionDenied".to_string()).clone());
m.insert("-1011".to_string(), Value::Str("PermissionDenied".to_string()).clone());
m.insert("-1023".to_string(), Value::Str("BadRequest".to_string()).clone());
m.insert("-1109".to_string(), Value::Str("AuthenticationError".to_string()).clone());
m.insert("-1110".to_string(), Value::Str("BadSymbol".to_string()).clone());
m.insert("-1113".to_string(), Value::Str("BadRequest".to_string()).clone());
m.insert("-1128".to_string(), Value::Str("BadRequest".to_string()).clone());
m.insert("-1136".to_string(), Value::Str("BadRequest".to_string()).clone());
m.insert("-2016".to_string(), Value::Str("OperationRejected".to_string()).clone());
m.insert("-2018".to_string(), Value::Str("InsufficientFunds".to_string()).clone());
m.insert("-2019".to_string(), Value::Str("InsufficientFunds".to_string()).clone());
m.insert("-2020".to_string(), Value::Str("OperationFailed".to_string()).clone());
m.insert("-2021".to_string(), Value::Str("OrderImmediatelyFillable".to_string()).clone());
m.insert("-2022".to_string(), Value::Str("InvalidOrder".to_string()).clone());
m.insert("-2023".to_string(), Value::Str("OperationFailed".to_string()).clone());
m.insert("-2024".to_string(), Value::Str("BadRequest".to_string()).clone());
m.insert("-2025".to_string(), Value::Str("OperationRejected".to_string()).clone());
m.insert("-2026".to_string(), Value::Str("InvalidOrder".to_string()).clone());
m.insert("-2027".to_string(), Value::Str("OperationRejected".to_string()).clone());
m.insert("-2028".to_string(), Value::Str("OperationRejected".to_string()).clone());
m.insert("-4086".to_string(), Value::Str("BadRequest".to_string()).clone());
m.insert("-4087".to_string(), Value::Str("BadSymbol".to_string()).clone());
m.insert("-4088".to_string(), Value::Str("BadRequest".to_string()).clone());
m.insert("-4089".to_string(), Value::Str("PermissionDenied".to_string()).clone());
m.insert("-4090".to_string(), Value::Str("PermissionDenied".to_string()).clone());
m.insert("-4110".to_string(), Value::Str("BadRequest".to_string()).clone());
m.insert("-4111".to_string(), Value::Str("BadRequest".to_string()).clone());
m.insert("-4112".to_string(), Value::Str("OperationRejected".to_string()).clone());
m.insert("-4113".to_string(), Value::Str("OperationRejected".to_string()).clone());
m.insert("-4150".to_string(), Value::Str("OperationRejected".to_string()).clone());
m.insert("-4151".to_string(), Value::Str("BadRequest".to_string()).clone());
m.insert("-4152".to_string(), Value::Str("BadRequest".to_string()).clone());
m.insert("-4154".to_string(), Value::Str("BadRequest".to_string()).clone());
m.insert("-4155".to_string(), Value::Str("BadRequest".to_string()).clone());
m.insert("-4178".to_string(), Value::Str("BadRequest".to_string()).clone());
m.insert("-4188".to_string(), Value::Str("BadRequest".to_string()).clone());
m.insert("-4192".to_string(), Value::Str("PermissionDenied".to_string()).clone());
m.insert("-4194".to_string(), Value::Str("PermissionDenied".to_string()).clone());
m.insert("-4195".to_string(), Value::Str("PermissionDenied".to_string()).clone());
m.insert("-4196".to_string(), Value::Str("BadRequest".to_string()).clone());
m.insert("-4197".to_string(), Value::Str("OperationRejected".to_string()).clone());
m.insert("-4198".to_string(), Value::Str("OperationRejected".to_string()).clone());
m.insert("-4199".to_string(), Value::Str("BadRequest".to_string()).clone());
m.insert("-4200".to_string(), Value::Str("PermissionDenied".to_string()).clone());
m.insert("-4201".to_string(), Value::Str("PermissionDenied".to_string()).clone());
m.insert("-4202".to_string(), Value::Str("OperationRejected".to_string()).clone());
m
}));
m
}));
m.insert("option".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("exact".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("-1003".to_string(), Value::Str("ExchangeError".to_string()).clone());
m.insert("-1004".to_string(), Value::Str("ExchangeError".to_string()).clone());
m.insert("-1006".to_string(), Value::Str("ExchangeError".to_string()).clone());
m.insert("-1007".to_string(), Value::Str("ExchangeError".to_string()).clone());
m.insert("-1008".to_string(), Value::Str("RateLimitExceeded".to_string()).clone());
m.insert("-1010".to_string(), Value::Str("ExchangeError".to_string()).clone());
m.insert("-1013".to_string(), Value::Str("ExchangeError".to_string()).clone());
m.insert("-1108".to_string(), Value::Str("ExchangeError".to_string()).clone());
m.insert("-1112".to_string(), Value::Str("ExchangeError".to_string()).clone());
m.insert("-1114".to_string(), Value::Str("ExchangeError".to_string()).clone());
m.insert("-1128".to_string(), Value::Str("BadSymbol".to_string()).clone());
m.insert("-1129".to_string(), Value::Str("BadSymbol".to_string()).clone());
m.insert("-1131".to_string(), Value::Str("BadRequest".to_string()).clone());
m.insert("-2011".to_string(), Value::Str("ExchangeError".to_string()).clone());
m.insert("-2018".to_string(), Value::Str("InsufficientFunds".to_string()).clone());
m.insert("-2027".to_string(), Value::Str("InsufficientFunds".to_string()).clone());
m.insert("-3029".to_string(), Value::Str("OperationFailed".to_string()).clone());
m.insert("-4006".to_string(), Value::Str("ExchangeError".to_string()).clone());
m.insert("-4007".to_string(), Value::Str("ExchangeError".to_string()).clone());
m.insert("-4008".to_string(), Value::Str("ExchangeError".to_string()).clone());
m.insert("-4009".to_string(), Value::Str("ExchangeError".to_string()).clone());
m.insert("-4010".to_string(), Value::Str("ExchangeError".to_string()).clone());
m.insert("-4011".to_string(), Value::Str("ExchangeError".to_string()).clone());
m.insert("-4012".to_string(), Value::Str("ExchangeError".to_string()).clone());
m.insert("-4014".to_string(), Value::Str("ExchangeError".to_string()).clone());
m.insert("-4015".to_string(), Value::Str("ExchangeError".to_string()).clone());
m.insert("-4016".to_string(), Value::Str("ExchangeError".to_string()).clone());
m.insert("-4017".to_string(), Value::Str("ExchangeError".to_string()).clone());
m.insert("-4018".to_string(), Value::Str("ExchangeError".to_string()).clone());
m.insert("-4019".to_string(), Value::Str("ExchangeError".to_string()).clone());
m.insert("-4020".to_string(), Value::Str("ExchangeError".to_string()).clone());
m.insert("-4021".to_string(), Value::Str("ExchangeError".to_string()).clone());
m.insert("-4022".to_string(), Value::Str("ExchangeError".to_string()).clone());
m.insert("-4023".to_string(), Value::Str("ExchangeError".to_string()).clone());
m.insert("-4024".to_string(), Value::Str("ExchangeError".to_string()).clone());
m.insert("-4025".to_string(), Value::Str("ExchangeError".to_string()).clone());
m.insert("-4026".to_string(), Value::Str("ExchangeError".to_string()).clone());
m.insert("-4027".to_string(), Value::Str("ExchangeError".to_string()).clone());
m.insert("-4028".to_string(), Value::Str("ExchangeError".to_string()).clone());
m.insert("-4031".to_string(), Value::Str("ExchangeError".to_string()).clone());
m.insert("-4032".to_string(), Value::Str("ExchangeError".to_string()).clone());
m.insert("-4033".to_string(), Value::Str("ExchangeError".to_string()).clone());
m.insert("-4034".to_string(), Value::Str("ExchangeError".to_string()).clone());
m.insert("-4035".to_string(), Value::Str("ExchangeError".to_string()).clone());
m.insert("-4036".to_string(), Value::Str("ExchangeError".to_string()).clone());
m.insert("-4037".to_string(), Value::Str("ExchangeError".to_string()).clone());
m.insert("-4038".to_string(), Value::Str("ExchangeError".to_string()).clone());
m.insert("-4039".to_string(), Value::Str("ExchangeError".to_string()).clone());
m.insert("-4040".to_string(), Value::Str("ExchangeError".to_string()).clone());
m.insert("-4041".to_string(), Value::Str("ExchangeError".to_string()).clone());
m.insert("-4042".to_string(), Value::Str("ExchangeError".to_string()).clone());
m.insert("-4043".to_string(), Value::Str("ExchangeError".to_string()).clone());
m.insert("-4044".to_string(), Value::Str("ExchangeError".to_string()).clone());
m.insert("-4045".to_string(), Value::Str("ExchangeError".to_string()).clone());
m.insert("-4046".to_string(), Value::Str("ExchangeError".to_string()).clone());
m.insert("-4047".to_string(), Value::Str("ExchangeError".to_string()).clone());
m.insert("-4048".to_string(), Value::Str("ExchangeError".to_string()).clone());
m.insert("-4049".to_string(), Value::Str("ExchangeError".to_string()).clone());
m.insert("-4050".to_string(), Value::Str("ExchangeError".to_string()).clone());
m.insert("-4051".to_string(), Value::Str("ExchangeError".to_string()).clone());
m.insert("-4052".to_string(), Value::Str("ExchangeError".to_string()).clone());
m.insert("-4053".to_string(), Value::Str("ExchangeError".to_string()).clone());
m.insert("-4054".to_string(), Value::Str("ExchangeError".to_string()).clone());
m.insert("-4056".to_string(), Value::Str("ExchangeError".to_string()).clone());
m.insert("-4057".to_string(), Value::Str("ExchangeError".to_string()).clone());
m.insert("-4058".to_string(), Value::Str("ExchangeError".to_string()).clone());
m.insert("-4059".to_string(), Value::Str("ExchangeError".to_string()).clone());
m.insert("-4060".to_string(), Value::Str("ExchangeError".to_string()).clone());
m.insert("-4061".to_string(), Value::Str("ExchangeError".to_string()).clone());
m.insert("-4062".to_string(), Value::Str("ExchangeError".to_string()).clone());
m.insert("-4063".to_string(), Value::Str("ExchangeError".to_string()).clone());
m.insert("-4064".to_string(), Value::Str("ExchangeError".to_string()).clone());
m.insert("-4065".to_string(), Value::Str("ExchangeError".to_string()).clone());
m.insert("-4066".to_string(), Value::Str("ExchangeError".to_string()).clone());
m.insert("-4067".to_string(), Value::Str("ExchangeError".to_string()).clone());
m.insert("-4068".to_string(), Value::Str("ExchangeError".to_string()).clone());
m.insert("-4069".to_string(), Value::Str("ExchangeError".to_string()).clone());
m.insert("-4070".to_string(), Value::Str("ExchangeError".to_string()).clone());
m.insert("-4071".to_string(), Value::Str("ExchangeError".to_string()).clone());
m.insert("-4072".to_string(), Value::Str("ExchangeError".to_string()).clone());
m.insert("-4073".to_string(), Value::Str("ExchangeError".to_string()).clone());
m.insert("-4074".to_string(), Value::Str("ExchangeError".to_string()).clone());
m.insert("-4075".to_string(), Value::Str("ExchangeError".to_string()).clone());
m.insert("-4076".to_string(), Value::Str("ExchangeError".to_string()).clone());
m.insert("-4077".to_string(), Value::Str("ExchangeError".to_string()).clone());
m.insert("-4078".to_string(), Value::Str("ExchangeError".to_string()).clone());
m.insert("-4079".to_string(), Value::Str("ExchangeError".to_string()).clone());
m.insert("-4080".to_string(), Value::Str("ExchangeError".to_string()).clone());
m.insert("-4081".to_string(), Value::Str("ExchangeError".to_string()).clone());
m.insert("-4082".to_string(), Value::Str("ExchangeError".to_string()).clone());
m.insert("-4083".to_string(), Value::Str("ExchangeError".to_string()).clone());
m.insert("-4084".to_string(), Value::Str("ExchangeError".to_string()).clone());
m.insert("-4085".to_string(), Value::Str("ExchangeError".to_string()).clone());
m.insert("-4086".to_string(), Value::Str("ExchangeError".to_string()).clone());
m.insert("-4087".to_string(), Value::Str("ExchangeError".to_string()).clone());
m.insert("-4088".to_string(), Value::Str("ExchangeError".to_string()).clone());
m.insert("-4089".to_string(), Value::Str("ExchangeError".to_string()).clone());
m.insert("-4091".to_string(), Value::Str("ExchangeError".to_string()).clone());
m.insert("-4092".to_string(), Value::Str("ExchangeError".to_string()).clone());
m.insert("-4093".to_string(), Value::Str("ExchangeError".to_string()).clone());
m.insert("-4094".to_string(), Value::Str("ExchangeError".to_string()).clone());
m.insert("-4095".to_string(), Value::Str("ExchangeError".to_string()).clone());
m.insert("-4096".to_string(), Value::Str("ExchangeError".to_string()).clone());
m.insert("-4097".to_string(), Value::Str("ExchangeError".to_string()).clone());
m.insert("-4098".to_string(), Value::Str("ExchangeError".to_string()).clone());
m.insert("-4099".to_string(), Value::Str("ExchangeError".to_string()).clone());
m.insert("-4101".to_string(), Value::Str("ExchangeError".to_string()).clone());
m.insert("-4102".to_string(), Value::Str("ExchangeError".to_string()).clone());
m.insert("-4103".to_string(), Value::Str("ExchangeError".to_string()).clone());
m.insert("-4104".to_string(), Value::Str("ExchangeError".to_string()).clone());
m.insert("-4105".to_string(), Value::Str("ExchangeError".to_string()).clone());
m.insert("-4106".to_string(), Value::Str("ExchangeError".to_string()).clone());
m.insert("-4107".to_string(), Value::Str("ExchangeError".to_string()).clone());
m.insert("-4108".to_string(), Value::Str("ExchangeError".to_string()).clone());
m.insert("-4109".to_string(), Value::Str("ExchangeError".to_string()).clone());
m.insert("-4110".to_string(), Value::Str("ExchangeError".to_string()).clone());
m.insert("-4112".to_string(), Value::Str("ExchangeError".to_string()).clone());
m.insert("-4113".to_string(), Value::Str("ExchangeError".to_string()).clone());
m.insert("-4114".to_string(), Value::Str("ExchangeError".to_string()).clone());
m.insert("-4115".to_string(), Value::Str("ExchangeError".to_string()).clone());
m.insert("-4116".to_string(), Value::Str("ExchangeError".to_string()).clone());
m.insert("-4117".to_string(), Value::Str("ExchangeError".to_string()).clone());
m.insert("-4118".to_string(), Value::Str("ExchangeError".to_string()).clone());
m.insert("-4119".to_string(), Value::Str("ExchangeError".to_string()).clone());
m.insert("-4120".to_string(), Value::Str("ExchangeError".to_string()).clone());
m.insert("-4121".to_string(), Value::Str("ExchangeError".to_string()).clone());
m.insert("-4122".to_string(), Value::Str("ExchangeError".to_string()).clone());
m.insert("-4123".to_string(), Value::Str("ExchangeError".to_string()).clone());
m.insert("-4124".to_string(), Value::Str("ExchangeError".to_string()).clone());
m.insert("-4125".to_string(), Value::Str("ExchangeError".to_string()).clone());
m.insert("-4126".to_string(), Value::Str("ExchangeError".to_string()).clone());
m.insert("-4127".to_string(), Value::Str("ExchangeError".to_string()).clone());
m.insert("-4128".to_string(), Value::Str("ExchangeError".to_string()).clone());
m.insert("-4129".to_string(), Value::Str("ExchangeError".to_string()).clone());
m.insert("-4130".to_string(), Value::Str("ExchangeError".to_string()).clone());
m.insert("-4131".to_string(), Value::Str("ExchangeError".to_string()).clone());
m.insert("-4132".to_string(), Value::Str("ExchangeError".to_string()).clone());
m.insert("-4133".to_string(), Value::Str("ExchangeError".to_string()).clone());
m.insert("-4134".to_string(), Value::Str("ExchangeError".to_string()).clone());
m.insert("-4135".to_string(), Value::Str("ExchangeError".to_string()).clone());
m.insert("-4136".to_string(), Value::Str("ExchangeError".to_string()).clone());
m.insert("-4137".to_string(), Value::Str("ExchangeError".to_string()).clone());
m.insert("-4138".to_string(), Value::Str("ExchangeError".to_string()).clone());
m.insert("-4139".to_string(), Value::Str("ExchangeError".to_string()).clone());
m.insert("-4141".to_string(), Value::Str("ExchangeError".to_string()).clone());
m.insert("-4142".to_string(), Value::Str("ExchangeError".to_string()).clone());
m.insert("-4143".to_string(), Value::Str("ExchangeError".to_string()).clone());
m.insert("-4144".to_string(), Value::Str("ExchangeError".to_string()).clone());
m.insert("-4145".to_string(), Value::Str("ExchangeError".to_string()).clone());
m.insert("-4146".to_string(), Value::Str("ExchangeError".to_string()).clone());
m.insert("-4147".to_string(), Value::Str("ExchangeError".to_string()).clone());
m.insert("-4148".to_string(), Value::Str("ExchangeError".to_string()).clone());
m.insert("-4149".to_string(), Value::Str("ExchangeError".to_string()).clone());
m.insert("-4150".to_string(), Value::Str("ExchangeError".to_string()).clone());
m.insert("-20121".to_string(), Value::Str("ExchangeError".to_string()).clone());
m.insert("-20124".to_string(), Value::Str("ExchangeError".to_string()).clone());
m.insert("-20130".to_string(), Value::Str("ExchangeError".to_string()).clone());
m.insert("-20132".to_string(), Value::Str("ExchangeError".to_string()).clone());
m.insert("-20194".to_string(), Value::Str("ExchangeError".to_string()).clone());
m.insert("-20195".to_string(), Value::Str("ExchangeError".to_string()).clone());
m.insert("-20196".to_string(), Value::Str("ExchangeError".to_string()).clone());
m.insert("-20198".to_string(), Value::Str("ExchangeError".to_string()).clone());
m.insert("-20204".to_string(), Value::Str("ExchangeError".to_string()).clone());
m
}));
m
}));
m.insert("portfolioMargin".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("exact".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("-1000".to_string(), Value::Str("OperationFailed".to_string()).clone());
m.insert("-1001".to_string(), Value::Str("ExchangeError".to_string()).clone());
m.insert("-1002".to_string(), Value::Str("PermissionDenied".to_string()).clone());
m.insert("-1003".to_string(), Value::Str("RateLimitExceeded".to_string()).clone());
m.insert("-1004".to_string(), Value::Str("BadRequest".to_string()).clone());
m.insert("-1005".to_string(), Value::Str("PermissionDenied".to_string()).clone());
m.insert("-1006".to_string(), Value::Str("BadResponse".to_string()).clone());
m.insert("-1007".to_string(), Value::Str("BadResponse".to_string()).clone());
m.insert("-1008".to_string(), Value::Str("OperationFailed".to_string()).clone());
m.insert("-1010".to_string(), Value::Str("ExchangeError".to_string()).clone());
m.insert("-1011".to_string(), Value::Str("PermissionDenied".to_string()).clone());
m.insert("-1013".to_string(), Value::Str("ExchangeError".to_string()).clone());
m.insert("-1014".to_string(), Value::Str("InvalidOrder".to_string()).clone());
m.insert("-1015".to_string(), Value::Str("InvalidOrder".to_string()).clone());
m.insert("-1016".to_string(), Value::Str("NotSupported".to_string()).clone());
m.insert("-1020".to_string(), Value::Str("NotSupported".to_string()).clone());
m.insert("-1021".to_string(), Value::Str("BadRequest".to_string()).clone());
m.insert("-1022".to_string(), Value::Str("BadRequest".to_string()).clone());
m.insert("-1023".to_string(), Value::Str("BadRequest".to_string()).clone());
m.insert("-1099".to_string(), Value::Str("OperationFailed".to_string()).clone());
m.insert("-1100".to_string(), Value::Str("BadRequest".to_string()).clone());
m.insert("-1101".to_string(), Value::Str("BadRequest".to_string()).clone());
m.insert("-1102".to_string(), Value::Str("BadRequest".to_string()).clone());
m.insert("-1103".to_string(), Value::Str("BadRequest".to_string()).clone());
m.insert("-1104".to_string(), Value::Str("BadRequest".to_string()).clone());
m.insert("-1105".to_string(), Value::Str("BadRequest".to_string()).clone());
m.insert("-1106".to_string(), Value::Str("BadRequest".to_string()).clone());
m.insert("-1108".to_string(), Value::Str("BadRequest".to_string()).clone());
m.insert("-1109".to_string(), Value::Str("BadRequest".to_string()).clone());
m.insert("-1110".to_string(), Value::Str("BadSymbol".to_string()).clone());
m.insert("-1111".to_string(), Value::Str("BadRequest".to_string()).clone());
m.insert("-1112".to_string(), Value::Str("BadRequest".to_string()).clone());
m.insert("-1113".to_string(), Value::Str("BadRequest".to_string()).clone());
m.insert("-1114".to_string(), Value::Str("BadRequest".to_string()).clone());
m.insert("-1115".to_string(), Value::Str("BadRequest".to_string()).clone());
m.insert("-1116".to_string(), Value::Str("BadRequest".to_string()).clone());
m.insert("-1117".to_string(), Value::Str("BadRequest".to_string()).clone());
m.insert("-1118".to_string(), Value::Str("BadRequest".to_string()).clone());
m.insert("-1119".to_string(), Value::Str("BadRequest".to_string()).clone());
m.insert("-1120".to_string(), Value::Str("BadRequest".to_string()).clone());
m.insert("-1121".to_string(), Value::Str("BadSymbol".to_string()).clone());
m.insert("-1125".to_string(), Value::Str("BadRequest".to_string()).clone());
m.insert("-1127".to_string(), Value::Str("BadRequest".to_string()).clone());
m.insert("-1128".to_string(), Value::Str("BadRequest".to_string()).clone());
m.insert("-1130".to_string(), Value::Str("BadRequest".to_string()).clone());
m.insert("-1131".to_string(), Value::Str("BadRequest".to_string()).clone());
m.insert("-1134".to_string(), Value::Str("BadRequest".to_string()).clone());
m.insert("-1136".to_string(), Value::Str("BadRequest".to_string()).clone());
m.insert("-1145".to_string(), Value::Str("BadRequest".to_string()).clone());
m.insert("-1151".to_string(), Value::Str("BadRequest".to_string()).clone());
m.insert("-2010".to_string(), Value::Str("InvalidOrder".to_string()).clone());
m.insert("-2011".to_string(), Value::Str("OperationRejected".to_string()).clone());
m.insert("-2013".to_string(), Value::Str("OrderNotFound".to_string()).clone());
m.insert("-2014".to_string(), Value::Str("OperationRejected".to_string()).clone());
m.insert("-2015".to_string(), Value::Str("OperationRejected".to_string()).clone());
m.insert("-2016".to_string(), Value::Str("OperationFailed".to_string()).clone());
m.insert("-2018".to_string(), Value::Str("OperationFailed".to_string()).clone());
m.insert("-2019".to_string(), Value::Str("OperationFailed".to_string()).clone());
m.insert("-2020".to_string(), Value::Str("OrderNotFillable".to_string()).clone());
m.insert("-2021".to_string(), Value::Str("OrderImmediatelyFillable".to_string()).clone());
m.insert("-2022".to_string(), Value::Str("InvalidOrder".to_string()).clone());
m.insert("-2023".to_string(), Value::Str("OperationFailed".to_string()).clone());
m.insert("-2024".to_string(), Value::Str("OperationRejected".to_string()).clone());
m.insert("-2025".to_string(), Value::Str("OperationRejected".to_string()).clone());
m.insert("-2026".to_string(), Value::Str("InvalidOrder".to_string()).clone());
m.insert("-2027".to_string(), Value::Str("OperationRejected".to_string()).clone());
m.insert("-2028".to_string(), Value::Str("OperationRejected".to_string()).clone());
m.insert("-4000".to_string(), Value::Str("BadRequest".to_string()).clone());
m.insert("-4001".to_string(), Value::Str("BadRequest".to_string()).clone());
m.insert("-4002".to_string(), Value::Str("BadRequest".to_string()).clone());
m.insert("-4003".to_string(), Value::Str("BadRequest".to_string()).clone());
m.insert("-4004".to_string(), Value::Str("BadRequest".to_string()).clone());
m.insert("-4005".to_string(), Value::Str("BadRequest".to_string()).clone());
m.insert("-4006".to_string(), Value::Str("BadRequest".to_string()).clone());
m.insert("-4007".to_string(), Value::Str("BadRequest".to_string()).clone());
m.insert("-4008".to_string(), Value::Str("BadRequest".to_string()).clone());
m.insert("-4009".to_string(), Value::Str("BadRequest".to_string()).clone());
m.insert("-4010".to_string(), Value::Str("BadRequest".to_string()).clone());
m.insert("-4011".to_string(), Value::Str("BadRequest".to_string()).clone());
m.insert("-4012".to_string(), Value::Str("BadRequest".to_string()).clone());
m.insert("-4013".to_string(), Value::Str("BadRequest".to_string()).clone());
m.insert("-4014".to_string(), Value::Str("BadRequest".to_string()).clone());
m.insert("-4015".to_string(), Value::Str("BadRequest".to_string()).clone());
m.insert("-4016".to_string(), Value::Str("BadRequest".to_string()).clone());
m.insert("-4017".to_string(), Value::Str("BadRequest".to_string()).clone());
m.insert("-4018".to_string(), Value::Str("BadRequest".to_string()).clone());
m.insert("-4019".to_string(), Value::Str("BadRequest".to_string()).clone());
m.insert("-4020".to_string(), Value::Str("BadRequest".to_string()).clone());
m.insert("-4021".to_string(), Value::Str("BadRequest".to_string()).clone());
m.insert("-4022".to_string(), Value::Str("BadRequest".to_string()).clone());
m.insert("-4023".to_string(), Value::Str("BadRequest".to_string()).clone());
m.insert("-4024".to_string(), Value::Str("BadRequest".to_string()).clone());
m.insert("-4025".to_string(), Value::Str("BadRequest".to_string()).clone());
m.insert("-4026".to_string(), Value::Str("BadRequest".to_string()).clone());
m.insert("-4027".to_string(), Value::Str("BadRequest".to_string()).clone());
m.insert("-4028".to_string(), Value::Str("BadRequest".to_string()).clone());
m.insert("-4029".to_string(), Value::Str("BadRequest".to_string()).clone());
m.insert("-4030".to_string(), Value::Str("BadRequest".to_string()).clone());
m.insert("-4031".to_string(), Value::Str("BadRequest".to_string()).clone());
m.insert("-4032".to_string(), Value::Str("BadRequest".to_string()).clone());
m.insert("-4033".to_string(), Value::Str("BadRequest".to_string()).clone());
m.insert("-4044".to_string(), Value::Str("BadRequest".to_string()).clone());
m.insert("-4045".to_string(), Value::Str("BadRequest".to_string()).clone());
m.insert("-4046".to_string(), Value::Str("BadRequest".to_string()).clone());
m.insert("-4047".to_string(), Value::Str("BadRequest".to_string()).clone());
m.insert("-4048".to_string(), Value::Str("BadRequest".to_string()).clone());
m.insert("-4049".to_string(), Value::Str("BadRequest".to_string()).clone());
m.insert("-4050".to_string(), Value::Str("BadRequest".to_string()).clone());
m.insert("-4051".to_string(), Value::Str("BadRequest".to_string()).clone());
m.insert("-4052".to_string(), Value::Str("BadRequest".to_string()).clone());
m.insert("-4053".to_string(), Value::Str("BadRequest".to_string()).clone());
m.insert("-4054".to_string(), Value::Str("BadRequest".to_string()).clone());
m.insert("-4055".to_string(), Value::Str("BadRequest".to_string()).clone());
m.insert("-4056".to_string(), Value::Str("PermissionDenied".to_string()).clone());
m.insert("-4057".to_string(), Value::Str("PermissionDenied".to_string()).clone());
m.insert("-4058".to_string(), Value::Str("BadRequest".to_string()).clone());
m.insert("-4059".to_string(), Value::Str("BadRequest".to_string()).clone());
m.insert("-4060".to_string(), Value::Str("BadRequest".to_string()).clone());
m.insert("-4061".to_string(), Value::Str("InvalidOrder".to_string()).clone());
m.insert("-4062".to_string(), Value::Str("BadRequest".to_string()).clone());
m.insert("-4063".to_string(), Value::Str("BadRequest".to_string()).clone());
m.insert("-4064".to_string(), Value::Str("BadRequest".to_string()).clone());
m.insert("-4065".to_string(), Value::Str("BadRequest".to_string()).clone());
m.insert("-4066".to_string(), Value::Str("BadRequest".to_string()).clone());
m.insert("-4067".to_string(), Value::Str("BadRequest".to_string()).clone());
m.insert("-4068".to_string(), Value::Str("BadRequest".to_string()).clone());
m.insert("-4069".to_string(), Value::Str("BadRequest".to_string()).clone());
m.insert("-4070".to_string(), Value::Str("BadRequest".to_string()).clone());
m.insert("-4071".to_string(), Value::Str("BadRequest".to_string()).clone());
m.insert("-4072".to_string(), Value::Str("OperationRejected".to_string()).clone());
m.insert("-4073".to_string(), Value::Str("BadRequest".to_string()).clone());
m.insert("-4074".to_string(), Value::Str("BadRequest".to_string()).clone());
m.insert("-4075".to_string(), Value::Str("BadRequest".to_string()).clone());
m.insert("-4076".to_string(), Value::Str("OperationRejected".to_string()).clone());
m.insert("-4077".to_string(), Value::Str("OperationRejected".to_string()).clone());
m.insert("-4078".to_string(), Value::Str("OperationFailed".to_string()).clone());
m.insert("-4079".to_string(), Value::Str("BadRequest".to_string()).clone());
m.insert("-4080".to_string(), Value::Str("PermissionDenied".to_string()).clone());
m.insert("-4081".to_string(), Value::Str("BadRequest".to_string()).clone());
m.insert("-4082".to_string(), Value::Str("BadRequest".to_string()).clone());
m.insert("-4083".to_string(), Value::Str("BadRequest".to_string()).clone());
m.insert("-4084".to_string(), Value::Str("NotSupported".to_string()).clone());
m.insert("-4085".to_string(), Value::Str("BadRequest".to_string()).clone());
m.insert("-4086".to_string(), Value::Str("BadRequest".to_string()).clone());
m.insert("-4087".to_string(), Value::Str("PermissionDenied".to_string()).clone());
m.insert("-4088".to_string(), Value::Str("PermissionDenied".to_string()).clone());
m.insert("-4104".to_string(), Value::Str("BadRequest".to_string()).clone());
m.insert("-4114".to_string(), Value::Str("BadRequest".to_string()).clone());
m.insert("-4115".to_string(), Value::Str("BadRequest".to_string()).clone());
m.insert("-4118".to_string(), Value::Str("OperationRejected".to_string()).clone());
m.insert("-4131".to_string(), Value::Str("OperationRejected".to_string()).clone());
m.insert("-4135".to_string(), Value::Str("BadRequest".to_string()).clone());
m.insert("-4137".to_string(), Value::Str("BadRequest".to_string()).clone());
m.insert("-4138".to_string(), Value::Str("BadRequest".to_string()).clone());
m.insert("-4139".to_string(), Value::Str("BadRequest".to_string()).clone());
m.insert("-4140".to_string(), Value::Str("OrderImmediatelyFillable".to_string()).clone());
m.insert("-4141".to_string(), Value::Str("BadRequest".to_string()).clone());
m.insert("-4142".to_string(), Value::Str("OrderImmediatelyFillable".to_string()).clone());
m.insert("-4144".to_string(), Value::Str("BadSymbol".to_string()).clone());
m.insert("-4161".to_string(), Value::Str("OperationRejected".to_string()).clone());
m.insert("-4164".to_string(), Value::Str("InvalidOrder".to_string()).clone());
m.insert("-4165".to_string(), Value::Str("BadRequest".to_string()).clone());
m.insert("-4183".to_string(), Value::Str("InvalidOrder".to_string()).clone());
m.insert("-4184".to_string(), Value::Str("InvalidOrder".to_string()).clone());
m.insert("-4408".to_string(), Value::Str("InvalidOrder".to_string()).clone());
m.insert("-5021".to_string(), Value::Str("OrderNotFillable".to_string()).clone());
m.insert("-5022".to_string(), Value::Str("OrderNotFillable".to_string()).clone());
m.insert("-5028".to_string(), Value::Str("OperationFailed".to_string()).clone());
m.insert("-5041".to_string(), Value::Str("RateLimitExceeded".to_string()).clone());
m
}));
m
}));
m.insert("exact".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("-1000".to_string(), Value::Str("OperationFailed".to_string()).clone());
m.insert("-1001".to_string(), Value::Str("OperationFailed".to_string()).clone());
m.insert("-1002".to_string(), Value::Str("AuthenticationError".to_string()).clone());
m.insert("-1003".to_string(), Value::Str("RateLimitExceeded".to_string()).clone());
m.insert("-1004".to_string(), Value::Str("OperationRejected".to_string()).clone());
m.insert("-1006".to_string(), Value::Str("OperationFailed".to_string()).clone());
m.insert("-1007".to_string(), Value::Str("RequestTimeout".to_string()).clone());
m.insert("-1010".to_string(), Value::Str("OperationFailed".to_string()).clone());
m.insert("-1013".to_string(), Value::Str("BadRequest".to_string()).clone());
m.insert("-1014".to_string(), Value::Str("InvalidOrder".to_string()).clone());
m.insert("-1015".to_string(), Value::Str("RateLimitExceeded".to_string()).clone());
m.insert("-1016".to_string(), Value::Str("BadRequest".to_string()).clone());
m.insert("-1020".to_string(), Value::Str("BadRequest".to_string()).clone());
m.insert("-1021".to_string(), Value::Str("InvalidNonce".to_string()).clone());
m.insert("-1022".to_string(), Value::Str("AuthenticationError".to_string()).clone());
m.insert("-1100".to_string(), Value::Str("BadRequest".to_string()).clone());
m.insert("-1101".to_string(), Value::Str("BadRequest".to_string()).clone());
m.insert("-1102".to_string(), Value::Str("BadRequest".to_string()).clone());
m.insert("-1103".to_string(), Value::Str("BadRequest".to_string()).clone());
m.insert("-1104".to_string(), Value::Str("BadRequest".to_string()).clone());
m.insert("-1105".to_string(), Value::Str("BadRequest".to_string()).clone());
m.insert("-1106".to_string(), Value::Str("BadRequest".to_string()).clone());
m.insert("-1108".to_string(), Value::Str("BadSymbol".to_string()).clone());
m.insert("-1111".to_string(), Value::Str("BadRequest".to_string()).clone());
m.insert("-1112".to_string(), Value::Str("OperationFailed".to_string()).clone());
m.insert("-1114".to_string(), Value::Str("BadRequest".to_string()).clone());
m.insert("-1115".to_string(), Value::Str("BadRequest".to_string()).clone());
m.insert("-1116".to_string(), Value::Str("BadRequest".to_string()).clone());
m.insert("-1117".to_string(), Value::Str("BadRequest".to_string()).clone());
m.insert("-1118".to_string(), Value::Str("BadRequest".to_string()).clone());
m.insert("-1119".to_string(), Value::Str("BadRequest".to_string()).clone());
m.insert("-1120".to_string(), Value::Str("BadRequest".to_string()).clone());
m.insert("-1121".to_string(), Value::Str("BadSymbol".to_string()).clone());
m.insert("-1125".to_string(), Value::Str("AuthenticationError".to_string()).clone());
m.insert("-1127".to_string(), Value::Str("BadRequest".to_string()).clone());
m.insert("-1128".to_string(), Value::Str("BadRequest".to_string()).clone());
m.insert("-1130".to_string(), Value::Str("BadRequest".to_string()).clone());
m.insert("-2010".to_string(), Value::Str("InvalidOrder".to_string()).clone());
m.insert("-2011".to_string(), Value::Str("OrderNotFound".to_string()).clone());
m.insert("-2013".to_string(), Value::Str("OrderNotFound".to_string()).clone());
m.insert("-2014".to_string(), Value::Str("AuthenticationError".to_string()).clone());
m.insert("-2015".to_string(), Value::Str("AuthenticationError".to_string()).clone());
m.insert("-4000".to_string(), Value::Str("InvalidOrder".to_string()).clone());
m.insert("-4001".to_string(), Value::Str("BadRequest".to_string()).clone());
m.insert("-4002".to_string(), Value::Str("BadRequest".to_string()).clone());
m.insert("-4003".to_string(), Value::Str("BadRequest".to_string()).clone());
m.insert("-4004".to_string(), Value::Str("BadRequest".to_string()).clone());
m.insert("-4005".to_string(), Value::Str("BadRequest".to_string()).clone());
m.insert("-4006".to_string(), Value::Str("BadRequest".to_string()).clone());
m.insert("-4007".to_string(), Value::Str("BadRequest".to_string()).clone());
m.insert("-4008".to_string(), Value::Str("BadRequest".to_string()).clone());
m.insert("-4009".to_string(), Value::Str("BadRequest".to_string()).clone());
m.insert("-4010".to_string(), Value::Str("BadRequest".to_string()).clone());
m.insert("-4011".to_string(), Value::Str("BadRequest".to_string()).clone());
m.insert("-4012".to_string(), Value::Str("BadRequest".to_string()).clone());
m.insert("-4013".to_string(), Value::Str("BadRequest".to_string()).clone());
m.insert("-4014".to_string(), Value::Str("BadRequest".to_string()).clone());
m.insert("-4015".to_string(), Value::Str("BadRequest".to_string()).clone());
m.insert("-4016".to_string(), Value::Str("BadRequest".to_string()).clone());
m.insert("-4017".to_string(), Value::Str("BadRequest".to_string()).clone());
m.insert("-4018".to_string(), Value::Str("BadRequest".to_string()).clone());
m.insert("-4019".to_string(), Value::Str("OperationRejected".to_string()).clone());
m.insert("-4020".to_string(), Value::Str("BadRequest".to_string()).clone());
m.insert("-4021".to_string(), Value::Str("BadRequest".to_string()).clone());
m.insert("-4022".to_string(), Value::Str("BadRequest".to_string()).clone());
m.insert("-4023".to_string(), Value::Str("BadRequest".to_string()).clone());
m.insert("-4024".to_string(), Value::Str("BadRequest".to_string()).clone());
m.insert("-4025".to_string(), Value::Str("BadRequest".to_string()).clone());
m.insert("-4026".to_string(), Value::Str("BadRequest".to_string()).clone());
m.insert("-4027".to_string(), Value::Str("BadRequest".to_string()).clone());
m.insert("-4028".to_string(), Value::Str("BadRequest".to_string()).clone());
m.insert("-4029".to_string(), Value::Str("BadRequest".to_string()).clone());
m.insert("-4030".to_string(), Value::Str("BadRequest".to_string()).clone());
m.insert("-4031".to_string(), Value::Str("BadRequest".to_string()).clone());
m.insert("-4032".to_string(), Value::Str("OperationRejected".to_string()).clone());
m.insert("-4033".to_string(), Value::Str("BadRequest".to_string()).clone());
m.insert("-4044".to_string(), Value::Str("BadRequest".to_string()).clone());
m.insert("-4045".to_string(), Value::Str("OperationRejected".to_string()).clone());
m.insert("-4046".to_string(), Value::Str("OperationRejected".to_string()).clone());
m.insert("-4047".to_string(), Value::Str("OperationRejected".to_string()).clone());
m.insert("-4048".to_string(), Value::Str("OperationRejected".to_string()).clone());
m.insert("-4049".to_string(), Value::Str("BadRequest".to_string()).clone());
m.insert("-4050".to_string(), Value::Str("InsufficientFunds".to_string()).clone());
m.insert("-4051".to_string(), Value::Str("InsufficientFunds".to_string()).clone());
m.insert("-4052".to_string(), Value::Str("OperationRejected".to_string()).clone());
m.insert("-4053".to_string(), Value::Str("BadRequest".to_string()).clone());
m.insert("-4054".to_string(), Value::Str("OperationRejected".to_string()).clone());
m.insert("-4055".to_string(), Value::Str("BadRequest".to_string()).clone());
m.insert("-4056".to_string(), Value::Str("AuthenticationError".to_string()).clone());
m.insert("-4057".to_string(), Value::Str("AuthenticationError".to_string()).clone());
m.insert("-4058".to_string(), Value::Str("BadRequest".to_string()).clone());
m.insert("-4059".to_string(), Value::Str("OperationRejected".to_string()).clone());
m.insert("-4060".to_string(), Value::Str("BadRequest".to_string()).clone());
m.insert("-4061".to_string(), Value::Str("OperationRejected".to_string()).clone());
m.insert("-4062".to_string(), Value::Str("BadRequest".to_string()).clone());
m.insert("-4067".to_string(), Value::Str("OperationRejected".to_string()).clone());
m.insert("-4068".to_string(), Value::Str("OperationRejected".to_string()).clone());
m.insert("-4082".to_string(), Value::Str("BadRequest".to_string()).clone());
m.insert("-4083".to_string(), Value::Str("OperationRejected".to_string()).clone());
m.insert("-4084".to_string(), Value::Str("BadRequest".to_string()).clone());
m.insert("-4086".to_string(), Value::Str("BadRequest".to_string()).clone());
m.insert("-4104".to_string(), Value::Str("BadRequest".to_string()).clone());
m.insert("-4135".to_string(), Value::Str("BadRequest".to_string()).clone());
m.insert("-4137".to_string(), Value::Str("BadRequest".to_string()).clone());
m.insert("-4138".to_string(), Value::Str("BadRequest".to_string()).clone());
m.insert("-4139".to_string(), Value::Str("BadRequest".to_string()).clone());
m.insert("-4142".to_string(), Value::Str("OrderImmediatelyFillable".to_string()).clone());
m.insert("-20121".to_string(), Value::Str("BadSymbol".to_string()).clone());
m.insert("-20124".to_string(), Value::Str("BadRequest".to_string()).clone());
m.insert("-20130".to_string(), Value::Str("BadRequest".to_string()).clone());
m.insert("-20132".to_string(), Value::Str("BadRequest".to_string()).clone());
m.insert("-20194".to_string(), Value::Str("BadRequest".to_string()).clone());
m.insert("-20195".to_string(), Value::Str("BadRequest".to_string()).clone());
m.insert("-20196".to_string(), Value::Str("BadRequest".to_string()).clone());
m.insert("-20198".to_string(), Value::Str("OperationRejected".to_string()).clone());
m.insert("-20204".to_string(), Value::Str("BadRequest".to_string()).clone());
m.insert("System is under maintenance.".to_string(), Value::Str("OnMaintenance".to_string()).clone());
m.insert("System abnormality".to_string(), Value::Str("OperationFailed".to_string()).clone());
m.insert("You are not authorized to execute this request.".to_string(), Value::Str("PermissionDenied".to_string()).clone());
m.insert("API key does not exist".to_string(), Value::Str("AuthenticationError".to_string()).clone());
m.insert("Order would trigger immediately.".to_string(), Value::Str("OrderImmediatelyFillable".to_string()).clone());
m.insert("Stop price would trigger immediately.".to_string(), Value::Str("OrderImmediatelyFillable".to_string()).clone());
m.insert("Order would immediately match and take.".to_string(), Value::Str("OrderImmediatelyFillable".to_string()).clone());
m.insert("Account has insufficient balance for requested action.".to_string(), Value::Str("InsufficientFunds".to_string()).clone());
m.insert("Rest API trading is not enabled.".to_string(), Value::Str("PermissionDenied".to_string()).clone());
m.insert("This account may not place or cancel orders.".to_string(), Value::Str("PermissionDenied".to_string()).clone());
m.insert("You don't have permission.".to_string(), Value::Str("PermissionDenied".to_string()).clone());
m.insert("Market is closed.".to_string(), Value::Str("MarketClosed".to_string()).clone());
m.insert("Too many requests. Please try again later.".to_string(), Value::Str("RateLimitExceeded".to_string()).clone());
m.insert("This action is disabled on this account.".to_string(), Value::Str("AccountSuspended".to_string()).clone());
m.insert("Limit orders require GTC for this phase.".to_string(), Value::Str("BadRequest".to_string()).clone());
m.insert("This order type is not possible in this trading phase.".to_string(), Value::Str("BadRequest".to_string()).clone());
m.insert("This type of sub-account exceeds the maximum number limit".to_string(), Value::Str("OperationRejected".to_string()).clone());
m.insert("This symbol is restricted for this account.".to_string(), Value::Str("PermissionDenied".to_string()).clone());
m.insert("This symbol is not permitted for this account.".to_string(), Value::Str("PermissionDenied".to_string()).clone());
m
}));
m.insert("broad".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("has no operation privilege".to_string(), Value::Str("PermissionDenied".to_string()).clone());
m.insert("MAX_POSITION".to_string(), Value::Str("BadRequest".to_string()).clone());
m.insert("PERCENT_PRICE_BY_SIDE".to_string(), Value::Str("InvalidOrder".to_string()).clone());
m
}));
m
}));
m.insert("rollingWindowSize".to_string(), Value::Int(60000));
m
})]);
Value::Null
}
pub fn is_inverse(&self, mut type_var: Value, optional_args: &[Value]) -> Value {
let mut subType = get_arg(optional_args, 0, Value::Null);
if is_equal(&subType, &Value::Null) {
return Value::Bool(is_equal(&type_var, &Value::Str("delivery".to_string())));
} else {
return Value::Bool(is_equal(&subType, &Value::Str("inverse".to_string())));
}
Value::Null
}
pub fn is_linear(&self, mut type_var: Value, optional_args: &[Value]) -> Value {
let mut subType = get_arg(optional_args, 0, Value::Null);
if is_equal(&subType, &Value::Null) {
return Value::Bool(is_true(&(is_equal(&type_var, &Value::Str("future".to_string())))) || is_true(&(is_equal(&type_var, &Value::Str("swap".to_string())))));
} else {
return Value::Bool(is_equal(&subType, &Value::Str("linear".to_string())));
}
Value::Null
}
pub fn set_sandbox_mode(&mut self, mut enable: Value) {
self.super_set_sandbox_mode(enable.clone());
add_element_to_object(&mut self.options, &Value::Str("sandboxMode".to_string()), enable.clone());
}
pub fn create_expired_option_market(&self, mut symbol: Value) -> Value {
// support expired option contracts
let mut settle: Value = Value::Str("USDT".to_string());
let mut optionParts: Value = split(&symbol, &Value::Str("-".to_string()));
let mut symbolBase: Value = split(&symbol, &Value::Str("/".to_string()));
let mut base: Value = Value::Null;
if is_greater_than(&get_index_of(&symbol, &Value::Str("/".to_string())), &negate(&Value::Int(1))) {
base = self.safe_string(symbolBase.clone(), Value::Int(0), &[]);
} else {
base = self.safe_string(optionParts.clone(), Value::Int(0), &[]);
}
let mut expiry: Value = self.safe_string(optionParts.clone(), Value::Int(1), &[]);
let mut strike: Value = self.safe_integer(optionParts.clone(), Value::Int(2), &[]);
let mut strikeAsString: Value = self.safe_string(optionParts.clone(), Value::Int(2), &[]);
let mut optionType: Value = self.safe_string(optionParts.clone(), Value::Int(3), &[]);
let mut datetime: Value = self.convert_expire_date(expiry.clone());
let mut timestamp: Value = self.parse8601(datetime.clone());
return Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("id".to_string(), add(&add(&add(&add(&add(&add(&base, &Value::Str("-".to_string())), &expiry), &Value::Str("-".to_string())), &strikeAsString), &Value::Str("-".to_string())), &optionType));
m.insert("symbol".to_string(), add(&add(&add(&add(&add(&add(&add(&add(&add(&add(&base, &Value::Str("/".to_string())), &settle), &Value::Str(":".to_string())), &settle), &Value::Str("-".to_string())), &expiry), &Value::Str("-".to_string())), &strikeAsString), &Value::Str("-".to_string())), &optionType));
m.insert("base".to_string(), base.clone());
m.insert("quote".to_string(), settle.clone());
m.insert("baseId".to_string(), base.clone());
m.insert("quoteId".to_string(), settle.clone());
m.insert("active".to_string(), Value::Null);
m.insert("type".to_string(), Value::Str("option".to_string()));
m.insert("linear".to_string(), Value::Null);
m.insert("inverse".to_string(), Value::Null);
m.insert("spot".to_string(), Value::Bool(false));
m.insert("swap".to_string(), Value::Bool(false));
m.insert("future".to_string(), Value::Bool(false));
m.insert("option".to_string(), Value::Bool(true));
m.insert("margin".to_string(), Value::Bool(false));
m.insert("contract".to_string(), Value::Bool(true));
m.insert("contractSize".to_string(), Value::Null);
m.insert("expiry".to_string(), timestamp.clone());
m.insert("expiryDatetime".to_string(), datetime.clone());
m.insert("optionType".to_string(), ternary(is_true(&(is_equal(&optionType, &Value::Str("C".to_string())))), Value::Str("call".to_string()), Value::Str("put".to_string())));
m.insert("strike".to_string(), strike.clone());
m.insert("settle".to_string(), settle.clone());
m.insert("settleId".to_string(), settle.clone());
m.insert("precision".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("amount".to_string(), Value::Null);
m.insert("price".to_string(), Value::Null);
m
}));
m.insert("limits".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("amount".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("min".to_string(), Value::Null);
m.insert("max".to_string(), Value::Null);
m
}));
m.insert("price".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("min".to_string(), Value::Null);
m.insert("max".to_string(), Value::Null);
m
}));
m.insert("cost".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("min".to_string(), Value::Null);
m.insert("max".to_string(), Value::Null);
m
}));
m
}));
m.insert("info".to_string(), Value::Null);
m
});
Value::Null
}
pub fn market(&self, mut symbol: Value) -> Value {
if is_equal(&symbol, &Value::Null) {
panic!("{}", crate::exchange_errors::arguments_required(add(&self.id, &Value::Str(" market() requires a symbol argument".to_string()))));
}
if is_equal(&self.markets, &Value::Null) {
panic!("{}", crate::exchange_errors::exchange_error(add(&self.id, &Value::Str(" markets not loaded".to_string()))));
}
// defaultType has legacy support on binance
let mut defaultType: Value = self.safe_string_k(self.options.clone(), "defaultType", &[]);
let mut defaultSubType: Value = self.safe_string_k(self.options.clone(), "defaultSubType", &[]);
let mut isLegacyLinear: bool = is_equal(&defaultType, &Value::Str("future".to_string()));
let mut isLegacyInverse: bool = is_equal(&defaultType, &Value::Str("delivery".to_string()));
let mut isLegacy: bool = is_true(&isLegacyLinear) || is_true(&isLegacyInverse);
if is_string(&symbol) {
if is_true(&(!is_equal(&self.markets, &Value::Null))) && is_true(&(Value::Bool(in_op(&self.markets, &symbol)))) {
let mut market: Value = get_value(&self.markets, &symbol);
// begin diff
if is_true(&isLegacy) && is_true(&(is_equal(&get_value(&market, &Value::Str("spot".to_string())), &Value::Bool(true)))) {
let mut settle: Value = ternary(is_true(&isLegacyLinear), get_value(&market, &Value::Str("quote".to_string())), get_value(&market, &Value::Str("base".to_string())));
let mut futuresSymbol: Value = add(&add(&symbol, &Value::Str(":".to_string())), &settle);
if is_true(&(!is_equal(&self.markets, &Value::Null))) && is_true(&(Value::Bool(in_op(&self.markets, &futuresSymbol)))) {
return get_value(&self.markets, &futuresSymbol);
}
} else {
return market;
}
} else if is_true(&(!is_equal(&self.markets_by_id, &Value::Null))) && is_true(&(Value::Bool(in_op(&self.markets_by_id, &symbol)))) {
let mut markets: Value = get_value(&self.markets_by_id, &symbol);
// begin diff
if is_true(&isLegacyLinear) {
defaultType = Value::Str("linear".to_string());
} else if is_true(&isLegacyInverse) {
defaultType = Value::Str("inverse".to_string());
} else if is_equal(&defaultType, &Value::Null) {
defaultType = defaultSubType.clone();
}
{
let mut i: Value = Value::Int(0);
let mut __for_first_246: bool = true;
while { if !__for_first_246 { i = add(&i, &Value::Int(1)); } __for_first_246 = false; is_less_than(&i, &get_array_length(&markets)) } {
let mut market: Value = get_value(&markets, &i);
let mut market: Value = get_value(&markets, &i);
if is_equal(&self.safe_value(market.clone(), defaultType.clone(), &[]), &Value::Bool(true)) {
return market;
}
}
}
return get_value(&markets, &Value::Int(0));
} else if is_true(&(is_greater_than(&get_index_of(&symbol, &Value::Str("/".to_string())), &negate(&Value::Int(1))))) && is_true(&(is_less_than(&get_index_of(&symbol, &Value::Str(":".to_string())), &Value::Int(0)))) {
if is_true(&(!is_equal(&defaultType, &Value::Null))) && is_true(&(!is_equal(&defaultType, &Value::Str("spot".to_string())))) {
// support legacy symbols
let mut basequoteVariable = split(&symbol, &Value::Str("/".to_string()));
let mut base: Value = get_value(&basequoteVariable, &Value::Int(0));
let mut quote: Value = get_value(&basequoteVariable, &Value::Int(1));
let mut settle: Value = ternary(is_true(&(is_equal("e, &Value::Str("USD".to_string())))), base.clone(), quote.clone());
let mut futuresSymbol: Value = add(&add(&symbol, &Value::Str(":".to_string())), &settle);
if is_true(&(!is_equal(&self.markets, &Value::Null))) && is_true(&(Value::Bool(in_op(&self.markets, &futuresSymbol)))) {
return get_value(&self.markets, &futuresSymbol);
}
}
} else if is_true(&(is_greater_than(&get_index_of(&symbol, &Value::Str("-C".to_string())), &negate(&Value::Int(1))))) || is_true(&(is_greater_than(&get_index_of(&symbol, &Value::Str("-P".to_string())), &negate(&Value::Int(1))))) {
return self.create_expired_option_market(symbol.clone());
}
}
panic!("{}", crate::exchange_errors::bad_symbol(add(&add(&self.id, &Value::Str(" does not have market symbol ".to_string())), &symbol)));
Value::Null
}
pub fn safe_market(&self, optional_args: &[Value]) -> Value {
let mut marketId = get_arg(optional_args, 0, Value::Null);
let mut market = get_arg(optional_args, 1, Value::Null);
let mut delimiter = get_arg(optional_args, 2, Value::Null);
let mut marketType = get_arg(optional_args, 3, Value::Null);
let mut isOption: bool = is_true(&(!is_equal(&marketId, &Value::Null))) && is_true(&(is_true(&(is_greater_than(&get_index_of(&marketId, &Value::Str("-C".to_string())), &negate(&Value::Int(1))))) || is_true(&(is_greater_than(&get_index_of(&marketId, &Value::Str("-P".to_string())), &negate(&Value::Int(1)))))));
if is_true(&isOption) && is_true(&(is_true(&(is_equal(&self.markets_by_id, &Value::Null))) || !is_true(&(Value::Bool(in_op(&self.markets_by_id, &marketId)))))) {
return self.create_expired_option_market(marketId.clone());
}
return self.super_safe_market(marketId.clone(), market.clone(), delimiter.clone(), marketType.clone());
Value::Null
}
pub fn nonce(&self) -> Value {
return subtract(&self.milliseconds(), &get_value(&self.options, &Value::Str("timeDifference".to_string())));
Value::Null
}
/*
* @method
* @name binance#mintTokenizedAsset
* @ignore
* @description mint a tokenized asset from an underlying equity holding
* @see https://developers.binance.com/en/docs/catalog/advanced-trading-stocks-trading/api/rest-api/tokenized#tokenized-mint
* @param {string} underlyingAsset underlying asset to mint into tokenized asset, ex. AAPL
* @param {string} underlyingAssetAmount quantity of the underlying asset to mint
* @param {object} [params] extra parameters specific to the exchange API endpoint
* @param {string} [params.clientOrderId] the clientOrderId of the order
* @param {int} [params.recvWindow] cannot be greater than 60000
* @returns {object} the response from the exchange
*/
pub async fn mint_tokenized_asset(&mut self, mut underlyingAsset: Value, mut underlyingAssetAmount: Value, optional_args: &[Value]) -> Value {
let mut params = get_arg(optional_args, 0, Value::Map({
let mut m = indexmap::IndexMap::new();
m
}));
let mut request: Value = Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("underlyingAsset".to_string(), underlyingAsset.clone());
m.insert("underlyingAssetAmount".to_string(), underlyingAssetAmount.clone());
m.insert("timestamp".to_string(), self.milliseconds());
m
});
let __ws_arg_0 = self.extend(request.clone(), &[params.clone()]);
let mut response: Value = self.sapi_post_equity_tokenized_redeem(&[__ws_arg_0]).await;
return response;
Value::Null
}
/*
* @method
* @name binance#redeemTokenizedAsset
* @ignore
* @description redeem a tokenized stock asset for the underlying asset
* @see https://developers.binance.com/en/docs/catalog/advanced-trading-stocks-trading/api/rest-api/tokenized#tokenized-redeem
* @param {string} tokenizedAsset tokenized asset to redeem, the onchain token identifier not the equity ticker ex. AAPLB
* @param {string} tokenizedAssetAmount quantity of the tokenized asset to redeem
* @param {object} [params] extra parameters specific to the exchange API endpoint
* @param {string} [params.clientOrderId] the clientOrderId of the order
* @param {int} [params.recvWindow] cannot be greater than 60000
* @returns {object} the response from the exchange
*/
pub async fn redeem_tokenized_asset(&mut self, mut tokenizedAsset: Value, mut tokenizedAssetAmount: Value, optional_args: &[Value]) -> Value {
let mut params = get_arg(optional_args, 0, Value::Map({
let mut m = indexmap::IndexMap::new();
m
}));
let mut request: Value = Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("tokenizedAsset".to_string(), tokenizedAsset.clone());
m.insert("tokenizedAssetAmount".to_string(), tokenizedAssetAmount.clone());
m.insert("timestamp".to_string(), self.milliseconds());
m
});
let __ws_arg_1 = self.extend(request.clone(), &[params.clone()]);
let mut response: Value = self.sapi_post_equity_tokenized_redeem(&[__ws_arg_1]).await;
return response;
Value::Null
}
/*
* @method
* @name binance#tokenizedConvertStatus
* @ignore
* @description check the status of redeeming or minting between a tokenized stock asset and the underlying asset
* @see https://developers.binance.com/en/docs/catalog/advanced-trading-stocks-trading/api/rest-api/tokenized#tokenized-convert-status
* @param {string} issuerRequestId the issuerRequestId returned from redeemTokenizedAsset or mintTokenizedAsset
* @param {string} convertType either MINT or REDEEM
* @param {object} [params] extra parameters specific to the exchange API endpoint
* @param {int} [params.recvWindow] cannot be greater than 60000
* @returns {object} the response from the exchange
*/
pub async fn tokenized_convert_status(&mut self, mut issuerRequestId: Value, mut convertType: Value, optional_args: &[Value]) -> Value {
let mut params = get_arg(optional_args, 0, Value::Map({
let mut m = indexmap::IndexMap::new();
m
}));
let mut request: Value = Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("issuerRequestId".to_string(), issuerRequestId.clone());
m.insert("convertType".to_string(), convertType.clone());
m.insert("timestamp".to_string(), self.milliseconds());
m
});
let __ws_arg_2 = self.extend(request.clone(), &[params.clone()]);
let mut response: Value = self.sapi_get_equity_tokenized_convert_status(&[__ws_arg_2]).await;
return response;
Value::Null
}
/*
* @method
* @name binance#tokenizedConvertHistory
* @ignore
* @description check the history of redeeming or minting between a tokenized stock asset and the underlying asset
* @see https://developers.binance.com/en/docs/catalog/advanced-trading-stocks-trading/api/rest-api/tokenized#tokenized-convert-history
* @param {int} [since] timestamp in ms of the earliest conversion to fetch
* @param {int} [limit] the maximum amount of conversions to fetch
* @param {object} [params] extra parameters specific to the exchange API endpoint
* @param {int} [params.recvWindow] cannot be greater than 60000
* @param {int} [params.endTime] timestamp in ms of the latest conversion to fetch
* @param {int} [params.lastTradeTokenId] last record id from the previous page
* @returns {object} the response from the exchange
*/
pub async fn tokenized_convert_history(&mut self, optional_args: &[Value]) -> Value {
let mut since = get_arg(optional_args, 0, Value::Null);
let mut limit = get_arg(optional_args, 1, Value::Null);
let mut params = get_arg(optional_args, 2, Value::Map({
let mut m = indexmap::IndexMap::new();
m
}));
let mut request: Value = Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("timestamp".to_string(), self.milliseconds());
m
});
if !is_equal(&since, &Value::Null) {
add_element_to_object(&mut request, &Value::Str("startTime".to_string()), since.clone());
}
if !is_equal(&limit, &Value::Null) {
add_element_to_object(&mut request, &Value::Str("size".to_string()), limit.clone());
}
{ let __destr_tmp = self.handle_until_option(Value::Str("endTime".to_string()), request.clone(), params.clone(), &[]); request = get_value(&__destr_tmp, &Value::Int(0)); params = get_value(&__destr_tmp, &Value::Int(1)); }
let __ws_arg_3 = self.extend(request.clone(), &[params.clone()]);
let mut response: Value = self.sapi_get_equity_tokenized_history(&[__ws_arg_3]).await;
return response;
Value::Null
}
/*
* @method
* @name binance#enableDemoTrading
* @description enables or disables demo trading mode
* @see https://www.binance.com/en/support/faq/detail/9be58f73e5e14338809e3b705b9687dd
* @see https://demo.binance.com/en/my/settings/api-management
* @param {boolean} [enable] true if demo trading should be enabled, false otherwise
*/
pub fn enable_demo_trading(&mut self, mut enable: Value) {
if is_true(&self.isSandboxModeEnabled) {
panic!("{}", crate::exchange_errors::not_supported(add(&self.id, &Value::Str(" demo trading is not supported in the sandbox environment. Please check https://www.binance.com/en/support/faq/detail/9be58f73e5e14338809e3b705b9687dd to see the differences".to_string()))));
}
if is_true(&enable) {
{ let __be_tmp = get_value(&self.urls, &Value::Str("api".to_string())); add_element_to_object(&mut self.urls, &Value::Str("apiBackupDemoTrading".to_string()), __be_tmp); };
{ let __be_tmp = get_value(&self.urls, &Value::Str("demo".to_string())); add_element_to_object(&mut self.urls, &Value::Str("api".to_string()), __be_tmp); };
} else if is_true(&Value::Bool(in_op(&self.urls, &Value::Str("apiBackupDemoTrading".to_string())))) {
{ let __be_tmp = get_value(&self.urls, &Value::Str("apiBackupDemoTrading".to_string())); add_element_to_object(&mut self.urls, &Value::Str("api".to_string()), __be_tmp); };
let mut newUrls: Value = self.omit(self.urls.clone(), Value::Str("apiBackupDemoTrading".to_string()), &[]);
self.urls = newUrls.clone();
}
add_element_to_object(&mut self.options, &Value::Str("enableDemoTrading".to_string()), enable.clone());
}
/*
* @method
* @name binance#fetchTime
* @description fetches the current integer timestamp in milliseconds from the exchange server
* @see https://developers.binance.com/docs/binance-spot-api-docs/rest-api/general-endpoints#check-server-time // spot
* @see https://developers.binance.com/docs/derivatives/usds-margined-futures/market-data/rest-api/Check-Server-Time // swap
* @see https://developers.binance.com/docs/derivatives/coin-margined-futures/market-data/rest-api/Check-Server-time // future
* @param {object} [params] extra parameters specific to the exchange API endpoint
* @param {string} [params.subType] "linear" or "inverse"
* @returns {int} the current integer timestamp in milliseconds from the exchange server
*/
pub async fn fetch_time(&mut self, optional_args: &[Value]) -> Value {
let mut params = get_arg(optional_args, 0, Value::Map({
let mut m = indexmap::IndexMap::new();
m
}));
let mut defaultType: Value = self.safe_string2(self.options.clone(), Value::Str("fetchTime".to_string()), Value::Str("defaultType".to_string()), &[Value::Str("spot".to_string())]);
let mut type_var: Value = self.safe_string_k(params.clone(), "type", &[defaultType.clone()]);
let mut query: Value = self.omit(params.clone(), Value::Str("type".to_string()), &[]);
let mut subType: Value = Value::Null;
{ let __destr_tmp = self.handle_sub_type_and_params(Value::Str("fetchTime".to_string()), &[Value::Null, params.clone()]); subType = get_value(&__destr_tmp, &Value::Int(0)); params = get_value(&__destr_tmp, &Value::Int(1)); }
let mut response: Value = Value::Null;
if is_true(&self.is_linear(type_var.clone(), &[subType.clone()])) {
response = self.fapi_public_get_time(&[query.clone()]).await;
} else if is_true(&self.is_inverse(type_var.clone(), &[subType.clone()])) {
response = self.dapi_public_get_time(&[query.clone()]).await;
} else {
response = self.public_get_time(&[query.clone()]).await;
}
return self.safe_integer_k(response.clone(), "serverTime", &[]);
Value::Null
}
/*
* @method
* @name binance#fetchCurrencies
* @description fetches all available currencies on an exchange
* @see https://developers.binance.com/docs/wallet/capital/all-coins-info
* @see https://developers.binance.com/docs/margin_trading/market-data/Get-All-Margin-Assets
* @param {object} [params] extra parameters specific to the exchange API endpoint
* @returns {object} an associative dictionary of currencies
*/
pub async fn fetch_currencies(&mut self, optional_args: &[Value]) -> Value {
let mut params = get_arg(optional_args, 0, Value::Map({
let mut m = indexmap::IndexMap::new();
m
}));
let mut fetchCurrenciesEnabled: Value = self.safe_bool_k(self.options.clone(), "fetchCurrencies", &[]);
if !is_equal(&fetchCurrenciesEnabled, &Value::Bool(true)) {
return Value::Map({
let mut m = indexmap::IndexMap::new();
m
});
}
// this endpoint requires authentication
// while fetchCurrencies is a public API method by design
// therefore we check the keys here
// and fallback to generating the currencies from the markets
if !is_true(&self.check_required_credentials(&[Value::Bool(false)])) {
return Value::Map({
let mut m = indexmap::IndexMap::new();
m
});
}
// sandbox/testnet does not support sapi endpoints
let mut apiBackup: Value = self.safe_value_k(self.urls.clone(), "apiBackup", &[]);
if !is_equal(&apiBackup, &Value::Null) {
return Value::Map({
let mut m = indexmap::IndexMap::new();
m
});
}
// demotrading does not support sapi endpoints
if is_true(&self.safe_bool_k(self.options.clone(), "enableDemoTrading", &[Value::Bool(false)])) {
return Value::Map({
let mut m = indexmap::IndexMap::new();
m
});
}
let mut promises: Value = Value::List(vec![self.sapi_get_capital_config_getall(&[params.clone()]).await]);
let mut fetchMargins: Value = self.safe_bool_k(self.options.clone(), "fetchMargins", &[Value::Bool(false)]);
if is_equal(&fetchMargins, &Value::Bool(true)) {
append_to_array(&mut promises, self.sapi_get_margin_all_pairs(&[params.clone()]).await);
}
let mut results: Value = promise_all(&promises).await;
let mut responseCurrencies: Value = get_value(&results, &Value::Int(0));
let mut marginablesById: Value = Value::Null;
if is_equal(&fetchMargins, &Value::Bool(true)) {
let mut responseMarginables: Value = get_value(&results, &Value::Int(1));
marginablesById = self.index_by(responseMarginables.clone(), Value::Str("assetName".to_string()));
}
return self.parse_currencies_custom(responseCurrencies.clone(), marginablesById.clone());
Value::Null
}
pub fn parse_currencies_custom(&self, mut responseCurrencies: Value, mut marginablesById: Value) -> Value {
let mut result: Value = Value::Map({
let mut m = indexmap::IndexMap::new();
m
});
{
let mut i: Value = Value::Int(0);
let mut __for_first_247: bool = true;
while { if !__for_first_247 { i = add(&i, &Value::Int(1)); } __for_first_247 = false; is_less_than(&i, &get_array_length(&responseCurrencies)) } {
let mut parsed: Value = self.parse_currency(get_value(&responseCurrencies, &i));
if is_equal(&parsed, &Value::Null) {
panic!("{}", crate::exchange_errors::exchange_error(add(&self.id, &Value::Str(" parseCurrenciesCustom() could not resolve parsed".to_string()))));
}
let mut code: Value = get_value(&parsed, &Value::Str("code".to_string()));
if is_equal(&parsed, &Value::Null) {
panic!("{}", crate::exchange_errors::exchange_error(add(&self.id, &Value::Str(" parseCurrenciesCustom() could not resolve parsed".to_string()))));
}
let mut marginEntry: Value = self.safe_dict(marginablesById.clone(), get_value(&parsed, &Value::Str("id".to_string())), &[]);
if is_equal(&parsed, &Value::Null) {
panic!("{}", crate::exchange_errors::exchange_error(add(&self.id, &Value::Str(" parseCurrenciesCustom() could not resolve parsed".to_string()))));
}
add_element_to_object(&mut parsed, &Value::Str("margin".to_string()), self.safe_bool_k(marginEntry.clone(), "isBorrowable", &[]));
add_element_to_object(&mut result, &code, parsed.clone());
}
}
return result;
Value::Null
}
pub fn parse_currency(&self, mut rawCurrency: Value) -> Value {
//
// {
// "coin": "LINK",
// "depositAllEnable": true,
// "withdrawAllEnable": true,
// "name": "ChainLink",
// "free": "0",
// "locked": "0",
// "freeze": "0",
// "withdrawing": "0",
// "ipoing": "0",
// "ipoable": "0",
// "storage": "0",
// "isLegalMoney": false,
// "trading": true,
// "networkList": [
// {
// "network": "BSC",
// "coin": "LINK",
// "withdrawIntegerMultiple": "0.00000001",
// "isDefault": false,
// "depositEnable": true,
// "withdrawEnable": true,
// "depositDesc": "",
// "withdrawDesc": "",
// "specialTips": "",
// "specialWithdrawTips": "The network you have selected is BSC. Please ensure that the withdrawal address supports the Binance Smart Chain network. You will lose your assets if the chosen platform does not support retrievals.",
// "name": "BNB Smart Chain (BEP20)",
// "resetAddressStatus": false,
// "addressRegex": "^(0x)[0-9A-Fa-f]{40}$",
// "addressRule": "",
// "memoRegex": "",
// "withdrawFee": "0.012",
// "withdrawMin": "0.024",
// "withdrawMax": "9999999999.99999999",
// "minConfirm": "15",
// "unLockConfirm": "0",
// "sameAddress": false,
// "estimatedArrivalTime": "5",
// "busy": false,
// "country": "AE,BINANCE_BAHRAIN_BSC"
// },
// {
// "network": "BNB",
// "coin": "LINK",
// "withdrawIntegerMultiple": "0.00000001",
// "isDefault": false,
// "depositEnable": true,
// "withdrawEnable": true,
// "depositDesc": "",
// "withdrawDesc": "",
// "specialTips": "Both a MEMO and an Address are required to successfully deposit your LINK BEP2 tokens to Binance.",
// "specialWithdrawTips": "",
// "name": "BNB Beacon Chain (BEP2)",
// "resetAddressStatus": false,
// "addressRegex": "^(bnb1)[0-9a-z]{38}$",
// "addressRule": "",
// "memoRegex": "^[0-9A-Za-z\\-_]{1,120}$",
// "withdrawFee": "0.003",
// "withdrawMin": "0.01",
// "withdrawMax": "10000000000",
// "minConfirm": "1",
// "unLockConfirm": "0",
// "sameAddress": true,
// "estimatedArrivalTime": "5",
// "busy": false,
// "country": "AE,BINANCE_BAHRAIN_BSC"
// },
// {
// "network": "ETH",
// "coin": "LINK",
// "withdrawIntegerMultiple": "0.00000001",
// "isDefault": true,
// "depositEnable": true,
// "withdrawEnable": true,
// "depositDesc": "",
// "withdrawDesc": "",
// "name": "Ethereum (ERC20)",
// "resetAddressStatus": false,
// "addressRegex": "^(0x)[0-9A-Fa-f]{40}$",
// "addressRule": "",
// "memoRegex": "",
// "withdrawFee": "0.55",
// "withdrawMin": "1.1",
// "withdrawMax": "10000000000",
// "minConfirm": "12",
// "unLockConfirm": "0",
// "sameAddress": false,
// "estimatedArrivalTime": "5",
// "busy": false,
// "country": "AE,BINANCE_BAHRAIN_BSC"
// }
// ]
// }
//
// some coins (e.g. ETH, BIGTIME, SONIC, etc) return extra fields under network entry
//
// "specialTips": "",
// "specialWithdrawTips": "",
// "withdrawInternalMin": "0",
// "contractAddressUrl": "https://etherscan.io/address/",
// "contractAddress": "0x64bc2ca1be492be7185faa2c8835d9b824c8a194"
//
let mut entry: Value = rawCurrency.clone();
let mut id: Value = self.safe_string_k(entry.clone(), "coin", &[]);
let mut name: Value = self.safe_string_k(entry.clone(), "name", &[]);
let mut code: Value = self.safe_currency_code(id.clone(), &[]);
let mut isFiat: Value = self.safe_bool_k(entry.clone(), "isLegalMoney", &[]);
let mut networkList: Value = self.safe_list_k(entry.clone(), "networkList", &[Value::List(vec![])]);
let mut fees: Value = Value::Map({
let mut m = indexmap::IndexMap::new();
m
});
let mut fee: Value = Value::Null;
let mut networks: Value = Value::Map({
let mut m = indexmap::IndexMap::new();
m
});
let mut isETF: bool = false;
{
let mut j: Value = Value::Int(0);
let mut __for_first_248: bool = true;
while { if !__for_first_248 { j = add(&j, &Value::Int(1)); } __for_first_248 = false; is_less_than(&j, &get_array_length(&networkList)) } {
let mut networkItem: Value = get_value(&networkList, &j);
let mut networkItem: Value = get_value(&networkList, &j);
let mut network: Value = self.safe_string_k(networkItem.clone(), "network", &[]);
let mut networkCode: Value = self.network_id_to_code(&[network.clone(), code.clone()]);
isETF = is_equal(&network, &Value::Str("ETF".to_string())); // ETF currencies (e.g. BTCUP, ETHDOWN) have only 1 "network" entry and are deterministic to set
// const name = this.safeString (networkItem, 'name');
let mut withdrawFee: Value = self.safe_number_k(networkItem.clone(), "withdrawFee", &[]);
let mut depositEnable: Value = self.safe_bool_k(networkItem.clone(), "depositEnable", &[]);
let mut withdrawEnable: Value = self.safe_bool_k(networkItem.clone(), "withdrawEnable", &[]);
if !is_equal(&networkCode, &Value::Null) {
add_element_to_object(&mut fees, &networkCode, withdrawFee.clone());
}
let mut isDefault: Value = self.safe_bool_k(networkItem.clone(), "isDefault", &[]);
if is_true(&(is_equal(&isDefault, &Value::Bool(true)))) || is_true(&(is_equal(&fee, &Value::Null))) {
fee = withdrawFee.clone();
}
// todo: default networks in "setMarkets" overload
// if (isDefault) {
// this.options['defaultNetworkCodesForCurrencies'][code] = networkCode;
// }
let mut withdrawPrecision: Value = self.omit_zero(self.safe_string2(networkItem.clone(), Value::Str("withdrawIntegerMultiple".to_string()), Value::Str("withdrawInternalMin".to_string()), &[]));
// zero values happen only on fiat or leveraged(ETF) tokens: https://t.me/binance_api_english/393075
if is_equal(&withdrawPrecision, &Value::Null) && is_true(&(is_equal(&isFiat, &Value::Bool(true)))) {
withdrawPrecision = self.safe_string_k(self.options.clone(), "defaultFiatWithdrawPrecision", &[]);
}
if !is_equal(&networkCode, &Value::Null) {
add_element_to_object(&mut networks, &networkCode, Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("info".to_string(), networkItem.clone());
m.insert("id".to_string(), network.clone());
m.insert("network".to_string(), networkCode.clone());
m.insert("active".to_string(), Value::Null);
m.insert("deposit".to_string(), depositEnable.clone());
m.insert("withdraw".to_string(), withdrawEnable.clone());
m.insert("fee".to_string(), withdrawFee.clone());
m.insert("precision".to_string(), self.parse_number(withdrawPrecision.clone(), &[]));
m.insert("limits".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("withdraw".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("min".to_string(), self.safe_number_k(networkItem.clone(), "withdrawMin", &[]));
m.insert("max".to_string(), self.safe_number_k(networkItem.clone(), "withdrawMax", &[]));
m
}));
m.insert("deposit".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("min".to_string(), self.safe_number_k(networkItem.clone(), "depositDust", &[]));
m.insert("max".to_string(), Value::Null);
m
}));
m
}));
m
}));
}
}
}
let mut type_var: Value = Value::Null;
if is_true(&isETF) {
type_var = Value::Str("other".to_string());
} else if is_equal(&isFiat, &Value::Bool(true)) {
type_var = Value::Str("fiat".to_string());
} else {
type_var = Value::Str("crypto".to_string());
}
let mut trading: Value = self.safe_bool_k(entry.clone(), "trading", &[]);
return self.safe_currency_structure(Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("id".to_string(), id.clone());
m.insert("name".to_string(), name.clone());
m.insert("code".to_string(), code.clone());
m.insert("type".to_string(), type_var.clone());
m.insert("precision".to_string(), Value::Null);
m.insert("info".to_string(), entry.clone());
m.insert("active".to_string(), trading.clone());
m.insert("deposit".to_string(), Value::Null);
m.insert("withdraw".to_string(), Value::Null);
m.insert("networks".to_string(), networks.clone());
m.insert("fee".to_string(), Value::Null);
m.insert("fees".to_string(), fees.clone());
m.insert("limits".to_string(), Value::Null);
m
}));
Value::Null
}
/*
* @method
* @name binance#fetchMarkets
* @description retrieves data on all markets for binance
* @see https://developers.binance.com/docs/binance-spot-api-docs/rest-api/general-endpoints#exchange-information // spot
* @see https://developers.binance.com/docs/derivatives/usds-margined-futures/market-data/rest-api/Exchange-Information // swap
* @see https://developers.binance.com/docs/derivatives/coin-margined-futures/market-data/rest-api/Exchange-Information // future
* @see https://developers.binance.com/docs/derivatives/option/market-data/Exchange-Information // option
* @see https://developers.binance.com/docs/margin_trading/market-data/Get-All-Cross-Margin-Pairs // cross margin
* @see https://developers.binance.com/docs/margin_trading/market-data/Get-All-Isolated-Margin-Symbol // isolated margin
* @see https://developers.binance.com/en/docs/catalog/advanced-trading-stocks-trading/api/rest-api/market-data#exchange-info // tokenized stocks
* @param {object} [params] extra parameters specific to the exchange API endpoint
* @returns {object[]} an array of objects representing market data
*/
pub async fn fetch_markets(&mut self, optional_args: &[Value]) -> Value {
let mut params = get_arg(optional_args, 0, Value::Map({
let mut m = indexmap::IndexMap::new();
m
}));
let mut promisesRaw: Value = Value::List(vec![]);
let mut rawFetchMarkets: Value = Value::Null;
let mut defaultTypes: Value = Value::List(vec![Value::Str("spot".to_string()), Value::Str("linear".to_string()), Value::Str("inverse".to_string())]);
let mut fetchMarketsOptions: Value = self.safe_dict_k(self.options.clone(), "fetchMarkets", &[]);
if !is_equal(&fetchMarketsOptions, &Value::Null) {
rawFetchMarkets = self.safe_list_k(fetchMarketsOptions.clone(), "types", &[defaultTypes.clone()]);
} else {
// for backward-compatibility
rawFetchMarkets = self.safe_list_k(self.options.clone(), "fetchMarkets", &[defaultTypes.clone()]);
}
let mut loadAllOptions: Value = self.handle_option(Value::Str("fetchMarkets".to_string()), Value::Str("loadAllOptions".to_string()), &[Value::Bool(false)]);
if is_equal(&loadAllOptions, &Value::Bool(true)) {
if !is_true(&self.in_array(Value::Str("option".to_string()), rawFetchMarkets.clone())) {
append_to_array(&mut rawFetchMarkets, Value::Str("option".to_string()));
}
}
let mut sandboxMode: Value = self.safe_bool_k(self.options.clone(), "sandboxMode", &[Value::Bool(false)]);
let mut demoMode: Value = self.safe_bool_k(self.options.clone(), "enableDemoTrading", &[Value::Bool(false)]);
let mut isDemoEnv: Value = Value::Bool(is_true(&(is_equal(&demoMode, &Value::Bool(true)))) || is_true(&(is_equal(&sandboxMode, &Value::Bool(true)))));
let mut fetchMarkets: Value = Value::List(vec![]);
{
let mut i: Value = Value::Int(0);
let mut __for_first_249: bool = true;
while { if !__for_first_249 { i = add(&i, &Value::Int(1)); } __for_first_249 = false; is_less_than(&i, &get_array_length(&rawFetchMarkets)) } {
let mut type_var: Value = get_value(&rawFetchMarkets, &i);
let mut type_var: Value = get_value(&rawFetchMarkets, &i);
if is_equal(&type_var, &Value::Str("option".to_string())) && is_true(&(is_equal(&isDemoEnv, &Value::Bool(true)))) {
continue;
}
append_to_array(&mut fetchMarkets, type_var.clone());
}
}
let mut fetchMargins: Value = self.safe_bool_k(self.options.clone(), "fetchMargins", &[Value::Bool(false)]);
{
let mut i: Value = Value::Int(0);
let mut __for_first_250: bool = true;
while { if !__for_first_250 { i = add(&i, &Value::Int(1)); } __for_first_250 = false; is_less_than(&i, &get_array_length(&fetchMarkets)) } {
let mut marketType: Value = get_value(&fetchMarkets, &i);
let mut marketType: Value = get_value(&fetchMarkets, &i);
if is_equal(&marketType, &Value::Str("spot".to_string())) {
append_to_array(&mut promisesRaw, self.public_get_exchange_info(&[params.clone()]).await);
if is_true(&(is_equal(&fetchMargins, &Value::Bool(true)))) && is_true(&self.check_required_credentials(&[Value::Bool(false)])) && is_true(&(!is_equal(&isDemoEnv, &Value::Bool(true)))) {
append_to_array(&mut promisesRaw, self.sapi_get_margin_all_pairs(&[params.clone()]).await);
append_to_array(&mut promisesRaw, self.sapi_get_margin_isolated_all_pairs(&[params.clone()]).await);
}
} else if is_equal(&marketType, &Value::Str("linear".to_string())) {
append_to_array(&mut promisesRaw, self.fapi_public_get_exchange_info(&[params.clone()]).await);
} else if is_equal(&marketType, &Value::Str("inverse".to_string())) {
append_to_array(&mut promisesRaw, self.dapi_public_get_exchange_info(&[params.clone()]).await);
} else if is_equal(&marketType, &Value::Str("option".to_string())) {
append_to_array(&mut promisesRaw, self.eapi_public_get_exchange_info(&[params.clone()]).await);
} else if is_equal(&marketType, &Value::Str("stock".to_string())) {
if is_true(&(!is_equal(&isDemoEnv, &Value::Bool(true)))) && is_true(&(!is_equal(&self.apiKey, &Value::Null) && !is_equal(&self.apiKey, &Value::Str("".to_string())))) {
append_to_array(&mut promisesRaw, self.sapi_get_equity_market_exchange_info(&[params.clone()]).await);
}
} else {
panic!("{}", crate::exchange_errors::exchange_error(add(&add(&add(&self.id, &Value::Str(" fetchMarkets() this.options fetchMarkets \"".to_string())), &marketType), &Value::Str("\" is not a supported market type".to_string()))));
}
}
}
let mut results: Value = promise_all(&promisesRaw).await;
let mut markets: Value = Value::List(vec![]);
add_element_to_object(&mut self.options, &Value::Str("crossMarginPairsData".to_string()), Value::List(vec![]));
add_element_to_object(&mut self.options, &Value::Str("isolatedMarginPairsData".to_string()), Value::List(vec![]));
{
let mut i: Value = Value::Int(0);
let mut __for_first_251: bool = true;
while { if !__for_first_251 { i = add(&i, &Value::Int(1)); } __for_first_251 = false; is_less_than(&i, &get_array_length(&results)) } {
let mut res: Value = self.safe_value(results.clone(), i.clone(), &[]);
if is_true(&(is_equal(&fetchMargins, &Value::Bool(true)))) && is_true(&Value::Bool(is_array(&res))) {
let mut keysList: Value = object_keys(&self.index_by(res.clone(), Value::Str("symbol".to_string())));
let mut length: Value = get_array_length(&get_value(&self.options, &Value::Str("crossMarginPairsData".to_string())));
// first one is the cross-margin promise
if is_equal(&length, &Value::Int(0)) {
add_element_to_object(&mut self.options, &Value::Str("crossMarginPairsData".to_string()), keysList.clone());
} else {
add_element_to_object(&mut self.options, &Value::Str("isolatedMarginPairsData".to_string()), keysList.clone());
}
} else {
let mut resultMarkets: Value = self.safe_list2(res.clone(), Value::Str("symbols".to_string()), Value::Str("optionSymbols".to_string()), &[Value::List(vec![])]);
markets = self.array_concat(markets.clone(), resultMarkets.clone());
}
}
}
//
// spot / margin
//
// {
// "timezone":"UTC",
// "serverTime":1575416692969,
// "rateLimits":[
// {"rateLimitType":"REQUEST_WEIGHT","interval":"MINUTE","intervalNum":1,"limit":1200},
// {"rateLimitType":"ORDERS","interval":"SECOND","intervalNum":10,"limit":100},
// {"rateLimitType":"ORDERS","interval":"DAY","intervalNum":1,"limit":200000}
// ],
// "exchangeFilters":[],
// "symbols":[
// {
// "symbol":"ETHBTC",
// "status":"TRADING",
// "baseAsset":"ETH",
// "baseAssetPrecision":8,
// "quoteAsset":"BTC",
// "quotePrecision":8,
// "baseCommissionPrecision":8,
// "quoteCommissionPrecision":8,
// "orderTypes":["LIMIT","LIMIT_MAKER","MARKET","STOP_LOSS_LIMIT","TAKE_PROFIT_LIMIT"],
// "icebergAllowed":true,
// "ocoAllowed":true,
// "quoteOrderQtyMarketAllowed":true,
// "allowTrailingStop":false,
// "isSpotTradingAllowed":true,
// "isMarginTradingAllowed":true,
// "filters":[
// {"filterType":"PRICE_FILTER","minPrice":"0.00000100","maxPrice":"100000.00000000","tickSize":"0.00000100"},
// {"filterType":"PERCENT_PRICE","multiplierUp":"5","multiplierDown":"0.2","avgPriceMins":5},
// {"filterType":"LOT_SIZE","minQty":"0.00100000","maxQty":"100000.00000000","stepSize":"0.00100000"},
// {"filterType":"MIN_NOTIONAL","minNotional":"0.00010000","applyToMarket":true,"avgPriceMins":5},
// {"filterType":"ICEBERG_PARTS","limit":10},
// {"filterType":"MARKET_LOT_SIZE","minQty":"0.00000000","maxQty":"63100.00000000","stepSize":"0.00000000"},
// {"filterType":"MAX_NUM_ORDERS","maxNumOrders":200},
// {"filterType":"MAX_NUM_ALGO_ORDERS","maxNumAlgoOrders":5}
// ],
// "permissions":["SPOT","MARGIN"]}
// },
// ],
// }
//
// cross & isolated pairs response:
//
// [
// {
// symbol: "BTCUSDT",
// base: "BTC",
// quote: "USDT",
// isMarginTrade: true,
// isBuyAllowed: true,
// isSellAllowed: true,
// id: "376870555451677893", // doesn't exist in isolated
// },
// ]
//
// futures/usdt-margined (fapi)
//
// {
// "timezone":"UTC",
// "serverTime":1575417244353,
// "rateLimits":[
// {"rateLimitType":"REQUEST_WEIGHT","interval":"MINUTE","intervalNum":1,"limit":1200},
// {"rateLimitType":"ORDERS","interval":"MINUTE","intervalNum":1,"limit":1200}
// ],
// "exchangeFilters":[],
// "symbols":[
// {
// "symbol":"BTCUSDT",
// "status":"TRADING",
// "maintMarginPercent":"2.5000",
// "requiredMarginPercent":"5.0000",
// "baseAsset":"BTC",
// "quoteAsset":"USDT",
// "pricePrecision":2,
// "quantityPrecision":3,
// "baseAssetPrecision":8,
// "quotePrecision":8,
// "filters":[
// {"minPrice":"0.01","maxPrice":"100000","filterType":"PRICE_FILTER","tickSize":"0.01"},
// {"stepSize":"0.001","filterType":"LOT_SIZE","maxQty":"1000","minQty":"0.001"},
// {"stepSize":"0.001","filterType":"MARKET_LOT_SIZE","maxQty":"1000","minQty":"0.001"},
// {"limit":200,"filterType":"MAX_NUM_ORDERS"},
// {"multiplierDown":"0.8500","multiplierUp":"1.1500","multiplierDecimal":"4","filterType":"PERCENT_PRICE"}
// ],
// "orderTypes":["LIMIT","MARKET","STOP"],
// "timeInForce":["GTC","IOC","FOK","GTX"]
// }
// ]
// }
//
// delivery/coin-margined (dapi)
//
// {
// "timezone": "UTC",
// "serverTime": 1597667052958,
// "rateLimits": [
// {"rateLimitType":"REQUEST_WEIGHT","interval":"MINUTE","intervalNum":1,"limit":6000},
// {"rateLimitType":"ORDERS","interval":"MINUTE","intervalNum":1,"limit":6000}
// ],
// "exchangeFilters": [],
// "symbols": [
// {
// "symbol": "BTCUSD_200925",
// "pair": "BTCUSD",
// "contractType": "CURRENT_QUARTER",
// "deliveryDate": 1601020800000,
// "onboardDate": 1590739200000,
// "contractStatus": "TRADING",
// "contractSize": 100,
// "marginAsset": "BTC",
// "maintMarginPercent": "2.5000",
// "requiredMarginPercent": "5.0000",
// "baseAsset": "BTC",
// "quoteAsset": "USD",
// "pricePrecision": 1,
// "quantityPrecision": 0,
// "baseAssetPrecision": 8,
// "quotePrecision": 8,
// "equalQtyPrecision": 4,
// "filters": [
// {"minPrice":"0.1","maxPrice":"100000","filterType":"PRICE_FILTER","tickSize":"0.1"},
// {"stepSize":"1","filterType":"LOT_SIZE","maxQty":"100000","minQty":"1"},
// {"stepSize":"0","filterType":"MARKET_LOT_SIZE","maxQty":"100000","minQty":"1"},
// {"limit":200,"filterType":"MAX_NUM_ORDERS"},
// {"multiplierDown":"0.9500","multiplierUp":"1.0500","multiplierDecimal":"4","filterType":"PERCENT_PRICE"}
// ],
// "orderTypes": ["LIMIT","MARKET","STOP","STOP_MARKET","TAKE_PROFIT","TAKE_PROFIT_MARKET","TRAILING_STOP_MARKET"],
// "timeInForce": ["GTC","IOC","FOK","GTX"]
// },
// {
// "symbol": "BTCUSD_PERP",
// "pair": "BTCUSD",
// "contractType": "PERPETUAL",
// "deliveryDate": 4133404800000,
// "onboardDate": 1596006000000,
// "contractStatus": "TRADING",
// "contractSize": 100,
// "marginAsset": "BTC",
// "maintMarginPercent": "2.5000",
// "requiredMarginPercent": "5.0000",
// "baseAsset": "BTC",
// "quoteAsset": "USD",
// "pricePrecision": 1,
// "quantityPrecision": 0,
// "baseAssetPrecision": 8,
// "quotePrecision": 8,
// "equalQtyPrecision": 4,
// "filters": [
// {"minPrice":"0.1","maxPrice":"100000","filterType":"PRICE_FILTER","tickSize":"0.1"},
// {"stepSize":"1","filterType":"LOT_SIZE","maxQty":"100000","minQty":"1"},
// {"stepSize":"1","filterType":"MARKET_LOT_SIZE","maxQty":"100000","minQty":"1"},
// {"limit":200,"filterType":"MAX_NUM_ORDERS"},
// {"multiplierDown":"0.8500","multiplierUp":"1.1500","multiplierDecimal":"4","filterType":"PERCENT_PRICE"}
// ],
// "orderTypes": ["LIMIT","MARKET","STOP","STOP_MARKET","TAKE_PROFIT","TAKE_PROFIT_MARKET","TRAILING_STOP_MARKET"],
// "timeInForce": ["GTC","IOC","FOK","GTX"]
// }
// ]
// }
//
// options (eapi)
//
// {
// "timezone": "UTC",
// "serverTime": 1675912490405,
// "optionContracts": [
// {
// "id": 1,
// "baseAsset": "SOL",
// "quoteAsset": "USDT",
// "underlying": "SOLUSDT",
// "settleAsset": "USDT"
// },
// ...
// ],
// "optionAssets": [
// {"id":1,"name":"USDT"}
// ],
// "optionSymbols": [
// {
// "contractId": 3,
// "expiryDate": 1677225600000,
// "filters": [
// {"filterType":"PRICE_FILTER","minPrice":"724.6","maxPrice":"919.2","tickSize":"0.1"},
// {"filterType":"LOT_SIZE","minQty":"0.01","maxQty":"1001","stepSize":"0.01"}
// ],
// "id": 2474,
// "symbol": "ETH-230224-800-C",
// "side": "CALL",
// "strikePrice": "800.00000000",
// "underlying": "ETHUSDT",
// "unit": 1,
// "makerFeeRate": "0.00020000",
// "takerFeeRate": "0.00020000",
// "minQty": "0.01",
// "maxQty": "1000",
// "initialMargin": "0.15000000",
// "maintenanceMargin": "0.07500000",
// "minInitialMargin": "0.10000000",
// "minMaintenanceMargin": "0.05000000",
// "priceScale": 1,
// "quantityScale": 2,
// "quoteAsset": "USDT"
// },
// ...
// ],
// "rateLimits": [
// {"rateLimitType":"REQUEST_WEIGHT","interval":"MINUTE","intervalNum":1,"limit":400},
// {"rateLimitType":"ORDERS","interval":"MINUTE","intervalNum":1,"limit":100},
// {"rateLimitType":"ORDERS","interval":"SECOND","intervalNum":10,"limit":30}
// ]
// }
//
// spot tokenized equities
//
// {
// "timezone": "UTC",
// "symbols": [
// {
// "symbol": "A",
// "tradability": "BUY_SELL",
// "tradabilityUpdateTime": 1778468796000,
// "overnightSupported": true,
// "fractionable": true,
// "fractionableEh": true,
// "extendedSession": true,
// "maxNumOrders": 200,
// "stepSize": "0.000000001",
// "multiplierUp": "1.1000",
// "multiplierDown": "0.9000",
// "maxQty": "1000000.000000000",
// "minNotional": "5.00000000",
// "maxNotional": "1000000.00000000",
// "listingTime": 1778468966000
// },
// ]
// }
//
if is_equal(&get_value(&self.options, &Value::Str("adjustForTimeDifference".to_string())), &Value::Bool(true)) {
self.load_time_difference(&[]).await;
}
let mut result: Value = Value::List(vec![]);
{
let mut i: Value = Value::Int(0);
let mut __for_first_252: bool = true;
while { if !__for_first_252 { i = add(&i, &Value::Int(1)); } __for_first_252 = false; is_less_than(&i, &get_array_length(&markets)) } {
append_to_array(&mut result, self.parse_market(get_value(&markets, &i)));
}
}
return result;
Value::Null
}
pub fn parse_market(&self, mut market: Value) -> Value {
let mut swap: Value = Value::Bool(false);
let mut future: Value = Value::Bool(false);
let mut option: Value = Value::Bool(false);
let mut underlying: Value = self.safe_string_k(market.clone(), "underlying", &[]);
let mut id: Value = self.safe_string_k(market.clone(), "symbol", &[]);
if is_equal(&id, &Value::Null) {
panic!("{}", crate::exchange_errors::exchange_error(add(&self.id, &Value::Str(" parseMarket() missing id".to_string()))));
}
let mut optionParts: Value = split(&id, &Value::Str("-".to_string()));
let mut optionBase: Value = self.safe_string(optionParts.clone(), Value::Int(0), &[]);
let mut lowercaseId: Value = self.safe_string_lower(market.clone(), Value::Str("symbol".to_string()), &[]);
let mut baseId: Value = self.safe_string_k(market.clone(), "baseAsset", &[optionBase.clone()]);
let mut quoteId: Value = self.safe_string_k(market.clone(), "quoteAsset", &[]);
let mut stock: Value = Value::Bool(false);
if is_true(&Value::Bool(in_op(&market, &Value::Str("tradability".to_string())))) {
quoteId = Value::Str("USDC".to_string());
stock = Value::Bool(true);
}
let mut base: Value = self.safe_currency_code(baseId.clone(), &[]);
let mut quote: Value = self.safe_currency_code(quoteId.clone(), &[]);
let mut contractType: Value = self.safe_string_k(market.clone(), "contractType", &[]);
let mut contract: Value = (Value::Bool(in_op(&market, &Value::Str("contractType".to_string()))));
let mut expiry: Value = self.safe_integer2(market.clone(), Value::Str("deliveryDate".to_string()), Value::Str("expiryDate".to_string()), &[]);
let mut settleId: Value = self.safe_string_k(market.clone(), "marginAsset", &[]);
if is_true(&(is_equal(&contractType, &Value::Str("PERPETUAL".to_string())))) || is_true(&(is_equal(&expiry, &Value::Int(4133404800000)))) {
expiry = Value::Null;
swap = Value::Bool(true);
} else if !is_equal(&underlying, &Value::Null) {
contract = Value::Bool(true);
option = Value::Bool(true);
settleId = ternary(is_true(&(is_equal(&settleId, &Value::Null))), Value::Str("USDT".to_string()), settleId.clone());
} else if !is_equal(&expiry, &Value::Null) {
future = Value::Bool(true);
}
let mut settle: Value = self.safe_currency_code(settleId.clone(), &[]);
let mut spot: Value = Value::Bool(!is_true(&contract));
let mut filters: Value = self.safe_list_k(market.clone(), "filters", &[Value::List(vec![])]);
let mut filtersByType: Value = self.index_by(filters.clone(), Value::Str("filterType".to_string()));
let mut status: Value = self.safe_string2(market.clone(), Value::Str("status".to_string()), Value::Str("contractStatus".to_string()), &[]);
let mut contractSize: Value = Value::Null;
let mut fees: Value = self.fees.clone();
let mut linear: Value = Value::Null;
let mut inverse: Value = Value::Null;
let mut symbol: Value = add(&add(&base, &Value::Str("/".to_string())), "e);
let mut strike: Value = Value::Null;
if is_true(&contract) {
if is_true(&swap) {
symbol = add(&add(&symbol, &Value::Str(":".to_string())), &settle);
} else if is_true(&future) {
symbol = add(&add(&add(&add(&symbol, &Value::Str(":".to_string())), &settle), &Value::Str("-".to_string())), &self.yymmdd(expiry.clone(), &[]));
} else if is_true(&option) {
strike = self.number_to_string(self.parse_to_numeric(self.safe_string_k(market.clone(), "strikePrice", &[])));
symbol = add(&add(&add(&add(&add(&add(&add(&add(&symbol, &Value::Str(":".to_string())), &settle), &Value::Str("-".to_string())), &self.yymmdd(expiry.clone(), &[])), &Value::Str("-".to_string())), &strike), &Value::Str("-".to_string())), &self.safe_string(optionParts.clone(), Value::Int(3), &[]));
}
contractSize = self.safe_number2(market.clone(), Value::Str("contractSize".to_string()), Value::Str("unit".to_string()), &[self.parse_number(Value::Str("1".to_string()), &[])]);
linear = Value::Bool(is_equal(&settle, "e));
inverse = Value::Bool(is_equal(&settle, &base));
let mut feesType: Value = ternary(is_true(&linear), Value::Str("linear".to_string()), Value::Str("inverse".to_string()));
fees = self.safe_dict(self.fees.clone(), feesType.clone(), &[Value::Map({
let mut m = indexmap::IndexMap::new();
m
})]);
}
let mut active: Value = Value::Bool(is_equal(&status, &Value::Str("TRADING".to_string())));
if is_true(&spot) {
let mut permissions: Value = self.safe_list_k(market.clone(), "permissions", &[Value::List(vec![])]);
{
let mut j: Value = Value::Int(0);
let mut __for_first_253: bool = true;
while { if !__for_first_253 { j = add(&j, &Value::Int(1)); } __for_first_253 = false; is_less_than(&j, &get_array_length(&permissions)) } {
if is_equal(&get_value(&permissions, &j), &Value::Str("TRD_GRP_003".to_string())) {
active = Value::Bool(false);
break;
}
}
}
}
let mut isMarginTradingAllowed: Value = self.safe_bool_k(market.clone(), "isMarginTradingAllowed", &[Value::Bool(false)]);
let mut marginModes: Value = Value::Null;
if is_true(&spot) {
let mut hasCrossMargin: Value = self.in_array(id.clone(), get_value(&self.options, &Value::Str("crossMarginPairsData".to_string())));
let mut hasIsolatedMargin: Value = self.in_array(id.clone(), get_value(&self.options, &Value::Str("isolatedMarginPairsData".to_string())));
marginModes = Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cross".to_string(), hasCrossMargin.clone());
m.insert("isolated".to_string(), hasIsolatedMargin.clone());
m
});
} else if is_true(&(is_equal(&linear, &Value::Bool(true)))) || is_true(&(is_equal(&inverse, &Value::Bool(true)))) {
marginModes = Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cross".to_string(), Value::Bool(true));
m.insert("isolated".to_string(), Value::Bool(true));
m
});
}
let mut unifiedType: Value = Value::Null;
if is_true(&spot) {
unifiedType = Value::Str("spot".to_string());
} else if is_true(&swap) {
unifiedType = Value::Str("swap".to_string());
} else if is_true(&future) {
unifiedType = Value::Str("future".to_string());
} else if is_true(&option) {
unifiedType = Value::Str("option".to_string());
active = Value::Null;
}
let mut parsedStrike: Value = Value::Null;
if !is_equal(&strike, &Value::Null) {
parsedStrike = self.parse_to_numeric(strike.clone());
}
let mut tradability: Value = self.safe_string_k(market.clone(), "tradability", &[]);
if !is_equal(&tradability, &Value::Null) {
if !is_equal(&tradability, &Value::Str("NONE".to_string())) {
active = Value::Bool(true);
}
}
let mut entry: Value = Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("id".to_string(), id.clone());
m.insert("lowercaseId".to_string(), lowercaseId.clone());
m.insert("symbol".to_string(), symbol.clone());
m.insert("base".to_string(), base.clone());
m.insert("quote".to_string(), quote.clone());
m.insert("settle".to_string(), settle.clone());
m.insert("baseId".to_string(), baseId.clone());
m.insert("quoteId".to_string(), quoteId.clone());
m.insert("settleId".to_string(), settleId.clone());
m.insert("type".to_string(), unifiedType.clone());
m.insert("spot".to_string(), spot.clone());
m.insert("margin".to_string(), Value::Bool(is_true(&spot) && is_true(&isMarginTradingAllowed)));
m.insert("marginModes".to_string(), marginModes.clone());
m.insert("swap".to_string(), swap.clone());
m.insert("future".to_string(), future.clone());
m.insert("option".to_string(), option.clone());
m.insert("stock".to_string(), stock.clone());
m.insert("active".to_string(), active.clone());
m.insert("contract".to_string(), contract.clone());
m.insert("linear".to_string(), linear.clone());
m.insert("inverse".to_string(), inverse.clone());
m.insert("taker".to_string(), get_value(&get_value(&fees, &Value::Str("trading".to_string())), &Value::Str("taker".to_string())));
m.insert("maker".to_string(), get_value(&get_value(&fees, &Value::Str("trading".to_string())), &Value::Str("maker".to_string())));
m.insert("contractSize".to_string(), contractSize.clone());
m.insert("expiry".to_string(), expiry.clone());
m.insert("expiryDatetime".to_string(), self.iso8601(expiry.clone()));
m.insert("strike".to_string(), parsedStrike.clone());
m.insert("optionType".to_string(), self.safe_string_lower(market.clone(), Value::Str("side".to_string()), &[]));
m.insert("precision".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("amount".to_string(), self.parse_number(self.parse_precision(&[self.safe_string2(market.clone(), Value::Str("quantityPrecision".to_string()), Value::Str("quantityScale".to_string()), &[])]), &[]));
m.insert("price".to_string(), self.parse_number(self.parse_precision(&[self.safe_string2(market.clone(), Value::Str("pricePrecision".to_string()), Value::Str("priceScale".to_string()), &[])]), &[]));
m.insert("base".to_string(), self.parse_number(self.parse_precision(&[self.safe_string_k(market.clone(), "baseAssetPrecision", &[])]), &[]));
m.insert("quote".to_string(), self.parse_number(self.parse_precision(&[self.safe_string_k(market.clone(), "quotePrecision", &[])]), &[]));
m
}));
m.insert("limits".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("leverage".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("min".to_string(), Value::Null);
m.insert("max".to_string(), Value::Null);
m
}));
m.insert("amount".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("min".to_string(), self.safe_number_k(market.clone(), "minQty", &[]));
m.insert("max".to_string(), self.safe_number_k(market.clone(), "maxQty", &[]));
m
}));
m.insert("price".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("min".to_string(), Value::Null);
m.insert("max".to_string(), Value::Null);
m
}));
m.insert("cost".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("min".to_string(), self.safe_number_k(market.clone(), "minNotional", &[]));
m.insert("max".to_string(), self.safe_number_k(market.clone(), "maxNotional", &[]));
m
}));
m
}));
m.insert("info".to_string(), market.clone());
m.insert("created".to_string(), self.safe_integer2(market.clone(), Value::Str("onboardDate".to_string()), Value::Str("listingTime".to_string()), &[]));
m
});
let mut stepSize: Value = self.safe_number_k(market.clone(), "stepSize", &[]);
if !is_equal(&stepSize, &Value::Null) {
add_element_to_object(get_value_mut(&mut entry, &Value::Str("precision".to_string())), &Value::Str("amount".to_string()), stepSize.clone());
}
if is_true(&Value::Bool(in_op(&filtersByType, &Value::Str("PRICE_FILTER".to_string())))) {
let mut filter: Value = self.safe_dict_k(filtersByType.clone(), "PRICE_FILTER", &[Value::Map({
let mut m = indexmap::IndexMap::new();
m
})]);
// PRICE_FILTER reports zero values for maxPrice
// since they updated filter types in November 2018
// https://github.com/ccxt/ccxt/issues/4286
// therefore limits['price']['max'] doesn't have any meaningful value except undefined
add_element_to_object(get_value_mut(&mut entry, &Value::Str("limits".to_string())), &Value::Str("price".to_string()), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("min".to_string(), self.safe_number_k(filter.clone(), "minPrice", &[]));
m.insert("max".to_string(), self.safe_number_k(filter.clone(), "maxPrice", &[]));
m
}));
add_element_to_object(get_value_mut(&mut entry, &Value::Str("precision".to_string())), &Value::Str("price".to_string()), self.safe_number_k(filter.clone(), "tickSize", &[]));
}
if is_true(&Value::Bool(in_op(&filtersByType, &Value::Str("LOT_SIZE".to_string())))) {
let mut filter: Value = self.safe_dict_k(filtersByType.clone(), "LOT_SIZE", &[Value::Map({
let mut m = indexmap::IndexMap::new();
m
})]);
add_element_to_object(get_value_mut(&mut entry, &Value::Str("precision".to_string())), &Value::Str("amount".to_string()), self.safe_number_k(filter.clone(), "stepSize", &[]));
add_element_to_object(get_value_mut(&mut entry, &Value::Str("limits".to_string())), &Value::Str("amount".to_string()), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("min".to_string(), self.safe_number_k(filter.clone(), "minQty", &[]));
m.insert("max".to_string(), self.safe_number_k(filter.clone(), "maxQty", &[]));
m
}));
}
if is_true(&Value::Bool(in_op(&filtersByType, &Value::Str("MARKET_LOT_SIZE".to_string())))) {
let mut filter: Value = self.safe_dict_k(filtersByType.clone(), "MARKET_LOT_SIZE", &[Value::Map({
let mut m = indexmap::IndexMap::new();
m
})]);
add_element_to_object(get_value_mut(&mut entry, &Value::Str("limits".to_string())), &Value::Str("market".to_string()), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("min".to_string(), self.safe_number_k(filter.clone(), "minQty", &[]));
m.insert("max".to_string(), self.safe_number_k(filter.clone(), "maxQty", &[]));
m
}));
}
if is_true(&(Value::Bool(in_op(&filtersByType, &Value::Str("MIN_NOTIONAL".to_string()))))) || is_true(&(Value::Bool(in_op(&filtersByType, &Value::Str("NOTIONAL".to_string()))))) {
let mut filter: Value = self.safe_dict2(filtersByType.clone(), Value::Str("MIN_NOTIONAL".to_string()), Value::Str("NOTIONAL".to_string()), &[Value::Map({
let mut m = indexmap::IndexMap::new();
m
})]);
add_element_to_object(get_value_mut(get_value_mut(&mut entry, &Value::Str("limits".to_string())), &Value::Str("cost".to_string())), &Value::Str("min".to_string()), self.safe_number2(filter.clone(), Value::Str("minNotional".to_string()), Value::Str("notional".to_string()), &[]));
add_element_to_object(get_value_mut(get_value_mut(&mut entry, &Value::Str("limits".to_string())), &Value::Str("cost".to_string())), &Value::Str("max".to_string()), self.safe_number_k(filter.clone(), "maxNotional", &[]));
}
return self.safe_market_structure(&[entry.clone()]);
Value::Null
}
pub fn parse_balance_helper(&self, mut entry: Value) -> Value {
let mut account: Value = self.account();
add_element_to_object(&mut account, &Value::Str("used".to_string()), self.safe_string_k(entry.clone(), "locked", &[]));
add_element_to_object(&mut account, &Value::Str("free".to_string()), self.safe_string_k(entry.clone(), "free", &[]));
let mut interest: Value = self.safe_string_k(entry.clone(), "interest", &[]);
let mut debt: Value = self.safe_string_k(entry.clone(), "borrowed", &[]);
add_element_to_object(&mut account, &Value::Str("debt".to_string()), crate::precise::Precise::stringAdd(&debt, &interest));
return account;
Value::Null
}
pub fn parse_balance_custom(&self, mut response: Value, optional_args: &[Value]) -> Value {
let mut type_var = get_arg(optional_args, 0, Value::Null);
let mut marginMode = get_arg(optional_args, 1, Value::Null);
let mut isPortfolioMargin = get_arg(optional_args, 2, Value::Bool(false));
let mut result: Value = Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("info".to_string(), response.clone());
m
});
let mut timestamp: Value = Value::Null;
let mut isolated: bool = is_equal(&marginMode, &Value::Str("isolated".to_string()));
let mut cross: bool = is_true(&(is_equal(&type_var, &Value::Str("margin".to_string())))) || is_true(&(is_equal(&marginMode, &Value::Str("cross".to_string()))));
if is_true(&isPortfolioMargin) {
{
let mut i: Value = Value::Int(0);
let mut __for_first_254: bool = true;
while { if !__for_first_254 { i = add(&i, &Value::Int(1)); } __for_first_254 = false; is_less_than(&i, &get_array_length(&response)) } {
let mut entry: Value = get_value(&response, &i);
let mut entry: Value = get_value(&response, &i);
let mut account: Value = self.account();
let mut currencyId: Value = self.safe_string_k(entry.clone(), "asset", &[]);
let mut code: Value = self.safe_currency_code(currencyId.clone(), &[]);
if is_equal(&type_var, &Value::Str("linear".to_string())) {
add_element_to_object(&mut account, &Value::Str("free".to_string()), self.safe_string_k(entry.clone(), "umWalletBalance", &[]));
add_element_to_object(&mut account, &Value::Str("used".to_string()), self.safe_string_k(entry.clone(), "umUnrealizedPNL", &[]));
} else if is_equal(&type_var, &Value::Str("inverse".to_string())) {
add_element_to_object(&mut account, &Value::Str("free".to_string()), self.safe_string_k(entry.clone(), "cmWalletBalance", &[]));
add_element_to_object(&mut account, &Value::Str("used".to_string()), self.safe_string_k(entry.clone(), "cmUnrealizedPNL", &[]));
} else if is_true(&cross) {
let mut borrowed: Value = self.safe_string_k(entry.clone(), "crossMarginBorrowed", &[]);
let mut interest: Value = self.safe_string_k(entry.clone(), "crossMarginInterest", &[]);
add_element_to_object(&mut account, &Value::Str("debt".to_string()), crate::precise::Precise::stringAdd(&borrowed, &interest));
add_element_to_object(&mut account, &Value::Str("free".to_string()), self.safe_string_k(entry.clone(), "crossMarginFree", &[]));
add_element_to_object(&mut account, &Value::Str("used".to_string()), self.safe_string_k(entry.clone(), "crossMarginLocked", &[]));
add_element_to_object(&mut account, &Value::Str("total".to_string()), self.safe_string_k(entry.clone(), "crossMarginAsset", &[]));
} else {
let mut usedLinear: Value = self.safe_string_k(entry.clone(), "umUnrealizedPNL", &[]);
let mut usedInverse: Value = self.safe_string_k(entry.clone(), "cmUnrealizedPNL", &[]);
let mut totalUsed: Value = crate::precise::Precise::stringAdd(&usedLinear, &usedInverse);
let mut totalWalletBalance: Value = self.safe_string_k(entry.clone(), "totalWalletBalance", &[]);
add_element_to_object(&mut account, &Value::Str("total".to_string()), crate::precise::Precise::stringAdd(&totalUsed, &totalWalletBalance));
}
if !is_equal(&code, &Value::Null) {
add_element_to_object(&mut result, &code, account.clone());
}
}
}
} else if !is_true(&isolated) && is_true(&(is_true(&(is_equal(&type_var, &Value::Str("spot".to_string())))) || is_true(&cross))) {
timestamp = self.safe_integer_k(response.clone(), "updateTime", &[]);
let mut balances: Value = self.safe_list2(response.clone(), Value::Str("balances".to_string()), Value::Str("userAssets".to_string()), &[Value::List(vec![])]);
{
let mut i: Value = Value::Int(0);
let mut __for_first_255: bool = true;
while { if !__for_first_255 { i = add(&i, &Value::Int(1)); } __for_first_255 = false; is_less_than(&i, &get_array_length(&balances)) } {
let mut balance: Value = get_value(&balances, &i);
let mut balance: Value = get_value(&balances, &i);
let mut currencyId: Value = self.safe_string_k(balance.clone(), "asset", &[]);
let mut code: Value = self.safe_currency_code(currencyId.clone(), &[]);
let mut account: Value = self.account();
add_element_to_object(&mut account, &Value::Str("free".to_string()), self.safe_string_k(balance.clone(), "free", &[]));
add_element_to_object(&mut account, &Value::Str("used".to_string()), self.safe_string_k(balance.clone(), "locked", &[]));
if is_true(&cross) {
let mut debt: Value = self.safe_string_k(balance.clone(), "borrowed", &[]);
let mut interest: Value = self.safe_string_k(balance.clone(), "interest", &[]);
add_element_to_object(&mut account, &Value::Str("debt".to_string()), crate::precise::Precise::stringAdd(&debt, &interest));
}
if !is_equal(&code, &Value::Null) {
add_element_to_object(&mut result, &code, account.clone());
}
}
}
} else if is_true(&isolated) {
let mut assets: Value = self.safe_list_k(response.clone(), "assets", &[Value::List(vec![])]);
{
let mut i: Value = Value::Int(0);
let mut __for_first_256: bool = true;
while { if !__for_first_256 { i = add(&i, &Value::Int(1)); } __for_first_256 = false; is_less_than(&i, &get_array_length(&assets)) } {
let mut asset: Value = get_value(&assets, &i);
let mut asset: Value = get_value(&assets, &i);
let mut base: Value = self.safe_dict_k(asset.clone(), "baseAsset", &[Value::Map({
let mut m = indexmap::IndexMap::new();
m
})]);
let mut quote: Value = self.safe_dict_k(asset.clone(), "quoteAsset", &[Value::Map({
let mut m = indexmap::IndexMap::new();
m
})]);
let mut baseCode: Value = self.safe_currency_code(self.safe_string_k(base.clone(), "asset", &[]), &[]);
let mut quoteCode: Value = self.safe_currency_code(self.safe_string_k(quote.clone(), "asset", &[]), &[]);
if !is_equal(&baseCode, &Value::Null) {
result = self.merge_balance_account(result.clone(), baseCode.clone(), self.parse_balance_helper(base.clone()));
}
if !is_equal("eCode, &Value::Null) {
result = self.merge_balance_account(result.clone(), quoteCode.clone(), self.parse_balance_helper(quote.clone()));
}
}
}
} else if is_equal(&type_var, &Value::Str("savings".to_string())) {
let mut positionAmountVos: Value = self.safe_list_k(response.clone(), "positionAmountVos", &[Value::List(vec![])]);
{
let mut i: Value = Value::Int(0);
let mut __for_first_257: bool = true;
while { if !__for_first_257 { i = add(&i, &Value::Int(1)); } __for_first_257 = false; is_less_than(&i, &get_array_length(&positionAmountVos)) } {
let mut entry: Value = get_value(&positionAmountVos, &i);
let mut entry: Value = get_value(&positionAmountVos, &i);
let mut currencyId: Value = self.safe_string_k(entry.clone(), "asset", &[]);
let mut code: Value = self.safe_currency_code(currencyId.clone(), &[]);
let mut account: Value = self.account();
let mut usedAndTotal: Value = self.safe_string_k(entry.clone(), "amount", &[]);
add_element_to_object(&mut account, &Value::Str("total".to_string()), usedAndTotal.clone());
add_element_to_object(&mut account, &Value::Str("used".to_string()), usedAndTotal.clone());
if !is_equal(&code, &Value::Null) {
add_element_to_object(&mut result, &code, account.clone());
}
}
}
} else if is_equal(&type_var, &Value::Str("funding".to_string())) {
{
let mut i: Value = Value::Int(0);
let mut __for_first_258: bool = true;
while { if !__for_first_258 { i = add(&i, &Value::Int(1)); } __for_first_258 = false; is_less_than(&i, &get_array_length(&response)) } {
let mut entry: Value = get_value(&response, &i);
let mut entry: Value = get_value(&response, &i);
let mut account: Value = self.account();
let mut currencyId: Value = self.safe_string_k(entry.clone(), "asset", &[]);
let mut code: Value = self.safe_currency_code(currencyId.clone(), &[]);
add_element_to_object(&mut account, &Value::Str("free".to_string()), self.safe_string_k(entry.clone(), "free", &[]));
let mut frozen: Value = self.safe_string_k(entry.clone(), "freeze", &[]);
let mut withdrawing: Value = self.safe_string_k(entry.clone(), "withdrawing", &[]);
let mut locked: Value = self.safe_string_k(entry.clone(), "locked", &[]);
add_element_to_object(&mut account, &Value::Str("used".to_string()), crate::precise::Precise::stringAdd(&frozen, &crate::precise::Precise::stringAdd(&locked, &withdrawing)));
if !is_equal(&code, &Value::Null) {
add_element_to_object(&mut result, &code, account.clone());
}
}
}
} else {
let mut balances: Value = response.clone();
if !is_true(&Value::Bool(is_array(&response))) {
balances = self.safe_list_k(response.clone(), "assets", &[Value::List(vec![])]);
}
{
let mut i: Value = Value::Int(0);
let mut __for_first_259: bool = true;
while { if !__for_first_259 { i = add(&i, &Value::Int(1)); } __for_first_259 = false; is_less_than(&i, &get_array_length(&balances)) } {
let mut balance: Value = get_value(&balances, &i);
let mut balance: Value = get_value(&balances, &i);
// skip stale/uninitialized assets, whose updateTime is 0, their balances are not valid (see https://github.com/ccxt/ccxt/issues/27997)
let mut updateTime: Value = self.safe_integer_k(balance.clone(), "updateTime", &[]);
if is_equal(&updateTime, &Value::Int(0)) {
continue;
}
let mut currencyId: Value = self.safe_string_k(balance.clone(), "asset", &[]);
let mut code: Value = self.safe_currency_code(currencyId.clone(), &[]);
let mut account: Value = self.account();
add_element_to_object(&mut account, &Value::Str("free".to_string()), self.safe_string_k(balance.clone(), "availableBalance", &[]));
add_element_to_object(&mut account, &Value::Str("used".to_string()), self.safe_string_k(balance.clone(), "initialMargin", &[]));
add_element_to_object(&mut account, &Value::Str("total".to_string()), self.safe_string2(balance.clone(), Value::Str("marginBalance".to_string()), Value::Str("balance".to_string()), &[]));
if !is_equal(&code, &Value::Null) {
add_element_to_object(&mut result, &code, account.clone());
}
}
}
}
add_element_to_object(&mut result, &Value::Str("timestamp".to_string()), timestamp.clone());
add_element_to_object(&mut result, &Value::Str("datetime".to_string()), self.iso8601(timestamp.clone()));
return self.safe_balance(result.clone());
Value::Null
}
/*
* @method
* @name binance#fetchBalance
* @description query for balance and get the amount of funds available for trading or funds locked in orders
* @see https://developers.binance.com/docs/binance-spot-api-docs/rest-api/account-endpoints#account-information-user_data // spot
* @see https://developers.binance.com/docs/margin_trading/account/Query-Cross-Margin-Account-Details // cross margin
* @see https://developers.binance.com/docs/margin_trading/account/Query-Isolated-Margin-Account-Info // isolated margin
* @see https://developers.binance.com/docs/wallet/asset/funding-wallet // funding
* @see https://developers.binance.com/docs/derivatives/usds-margined-futures/account/rest-api/Futures-Account-Balance-V2 // swap
* @see https://developers.binance.com/docs/derivatives/coin-margined-futures/account/rest-api/Futures-Account-Balance // future
* @see https://developers.binance.com/docs/derivatives/option/account/Option-Account-Information // option
* @see https://developers.binance.com/docs/derivatives/portfolio-margin/account/Account-Balance // portfolio margin
* @param {object} [params] extra parameters specific to the exchange API endpoint
* @param {string} [params.type] 'future', 'delivery', 'savings', 'funding', or 'spot' or 'papi'
* @param {string} [params.marginMode] 'cross' or 'isolated', for margin trading, uses this.options.defaultMarginMode if not passed, defaults to undefined/None/null
* @param {string[]|undefined} [params.symbols] unified market symbols, only used in isolated margin mode
* @param {boolean} [params.portfolioMargin] set to true if you would like to fetch the balance for a portfolio margin account
* @param {string} [params.subType] 'linear' or 'inverse'
* @returns {object} a [balance structure]{@link https://docs.ccxt.com/?id=balance-structure}
*/
pub async fn fetch_balance(&mut self, optional_args: &[Value]) -> Value {
let mut params = get_arg(optional_args, 0, Value::Map({
let mut m = indexmap::IndexMap::new();
m
}));
if is_equal(&self.markets, &Value::Null) {
self.load_markets(&[]).await;
}
let mut defaultType: Value = self.safe_string2(self.options.clone(), Value::Str("fetchBalance".to_string()), Value::Str("defaultType".to_string()), &[Value::Str("spot".to_string())]);
let mut type_var: Value = self.safe_string_k(params.clone(), "type", &[defaultType.clone()]);
let mut subType: Value = Value::Null;
{ let __destr_tmp = self.handle_sub_type_and_params(Value::Str("fetchBalance".to_string()), &[Value::Null, params.clone()]); subType = get_value(&__destr_tmp, &Value::Int(0)); params = get_value(&__destr_tmp, &Value::Int(1)); }
let mut isPortfolioMargin: Value = Value::Null;
{ let __destr_tmp = self.handle_option_and_params2(params.clone(), Value::Str("fetchBalance".to_string()), Value::Str("papi".to_string()), Value::Str("portfolioMargin".to_string()), &[Value::Bool(false)]); isPortfolioMargin = get_value(&__destr_tmp, &Value::Int(0)); params = get_value(&__destr_tmp, &Value::Int(1)); }
let mut marginMode: Value = Value::Null;
let mut query: Value = Value::Null;
{ let __destr_tmp = self.handle_margin_mode_and_params(Value::Str("fetchBalance".to_string()), &[params.clone()]); marginMode = get_value(&__destr_tmp, &Value::Int(0)); query = get_value(&__destr_tmp, &Value::Int(1)); }
query = self.omit(query.clone(), Value::Str("type".to_string()), &[]);
let mut response: Value = Value::Null;
let mut request: Value = Value::Map({
let mut m = indexmap::IndexMap::new();
m
});
if is_true(&isPortfolioMargin) || is_true(&(is_equal(&type_var, &Value::Str("papi".to_string())))) {
if is_true(&self.is_linear(type_var.clone(), &[subType.clone()])) {
type_var = Value::Str("linear".to_string());
} else if is_true(&self.is_inverse(type_var.clone(), &[subType.clone()])) {
type_var = Value::Str("inverse".to_string());
}
isPortfolioMargin = Value::Bool(true);
let __ws_arg_4 = self.extend(request.clone(), &[query.clone()]);
response = self.papi_get_balance(&[__ws_arg_4]).await;
} else if is_true(&self.is_linear(type_var.clone(), &[subType.clone()])) {
type_var = Value::Str("linear".to_string());
let mut useV2: Value = Value::Null;
{ let __destr_tmp = self.handle_option_and_params(params.clone(), Value::Str("fetchBalance".to_string()), Value::Str("useV2".to_string()), &[Value::Bool(false)]); useV2 = get_value(&__destr_tmp, &Value::Int(0)); params = get_value(&__destr_tmp, &Value::Int(1)); }
params = self.extend(request.clone(), &[query.clone()]);
if !is_true(&useV2) {
response = self.fapi_private_v3_get_account(&[params.clone()]).await;
} else {
response = self.fapi_private_v2_get_account(&[params.clone()]).await;
}
} else if is_true(&self.is_inverse(type_var.clone(), &[subType.clone()])) {
type_var = Value::Str("inverse".to_string());
let __ws_arg_5 = self.extend(request.clone(), &[query.clone()]);
response = self.dapi_private_get_account(&[__ws_arg_5]).await;
} else if is_equal(&marginMode, &Value::Str("isolated".to_string())) {
let mut paramSymbols: Value = self.safe_list_k(params.clone(), "symbols", &[]);
query = self.omit(query.clone(), Value::Str("symbols".to_string()), &[]);
if !is_equal(¶mSymbols, &Value::Null) {
let mut symbols: Value = Value::Str("".to_string());
if is_true(&Value::Bool(is_array(¶mSymbols))) {
let mut mid: Value = self.market_id(get_value(¶mSymbols, &Value::Int(0)));
if !is_equal(&mid, &Value::Null) {
symbols = mid.clone();
}
{
let mut i: Value = Value::Int(1);
let mut __for_first_260: bool = true;
while { if !__for_first_260 { i = add(&i, &Value::Int(1)); } __for_first_260 = false; is_less_than(&i, &get_array_length(¶mSymbols)) } {
let mut symbol: Value = get_value(¶mSymbols, &i);
let mut symbol: Value = get_value(¶mSymbols, &i);
let mut id: Value = self.market_id(symbol.clone());
if !is_equal(&id, &Value::Null) {
symbols = add(&symbols, &add(&Value::Str(",".to_string()), &id));
}
}
}
} else {
symbols = paramSymbols.clone();
}
add_element_to_object(&mut request, &Value::Str("symbols".to_string()), symbols.clone());
}
let __ws_arg_6 = self.extend(request.clone(), &[query.clone()]);
response = self.sapi_get_margin_isolated_account(&[__ws_arg_6]).await;
} else if is_true(&(is_equal(&type_var, &Value::Str("margin".to_string())))) || is_true(&(is_equal(&marginMode, &Value::Str("cross".to_string())))) {
let __ws_arg_7 = self.extend(request.clone(), &[query.clone()]);
response = self.sapi_get_margin_account(&[__ws_arg_7]).await;
} else if is_equal(&type_var, &Value::Str("savings".to_string())) {
let __ws_arg_8 = self.extend(request.clone(), &[query.clone()]);
response = self.sapi_get_lending_union_account(&[__ws_arg_8]).await;
} else if is_equal(&type_var, &Value::Str("funding".to_string())) {
let __ws_arg_9 = self.extend(request.clone(), &[query.clone()]);
response = self.sapi_post_asset_get_funding_asset(&[__ws_arg_9]).await;
} else {
let __ws_arg_10 = self.extend(request.clone(), &[query.clone()]);
response = self.private_get_account(&[__ws_arg_10]).await;
}
return self.parse_balance_custom(response.clone(), &[type_var.clone(), marginMode.clone(), isPortfolioMargin.clone()]);
Value::Null
}
/*
* @method
* @name binance#fetchOrderBook
* @description fetches information on open orders with bid (buy) and ask (sell) prices, volumes and other data
* @see https://developers.binance.com/docs/binance-spot-api-docs/rest-api/market-data-endpoints#order-book // spot
* @see https://developers.binance.com/docs/derivatives/usds-margined-futures/market-data/rest-api/Order-Book // swap
* @see https://developers.binance.com/docs/derivatives/usds-margined-futures/market-data/rest-api/Order-Book-RPI // swap rpi
* @see https://developers.binance.com/docs/derivatives/coin-margined-futures/market-data/rest-api/Order-Book // future
* @see https://developers.binance.com/docs/derivatives/option/market-data/Order-Book // option
* @param {string} symbol unified symbol of the market to fetch the order book for
* @param {int} [limit] the maximum amount of order book entries to return
* @param {object} [params] extra parameters specific to the exchange API endpoint
* @param {boolean} [params.rpi] *future only* set to true to use the RPI endpoint
* @returns {object} an [order book structure]{@link https://docs.ccxt.com/?id=order-book-structure}
*/
pub async fn fetch_order_book(&mut self, mut symbol: Value, optional_args: &[Value]) -> Value {
let mut limit = get_arg(optional_args, 0, Value::Null);
let mut params = get_arg(optional_args, 1, Value::Map({
let mut m = indexmap::IndexMap::new();
m
}));
if is_equal(&self.markets, &Value::Null) {
self.load_markets(&[]).await;
}
let mut market: Value = self.market(symbol.clone());
let mut request: Value = Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("symbol".to_string(), get_value(&market, &Value::Str("id".to_string())));
m
});
if !is_equal(&limit, &Value::Null) {
add_element_to_object(&mut request, &Value::Str("limit".to_string()), limit.clone()); // default 100, max 5000, see https://github.com/binance/binance-spot-api-docs/blob/master/rest-api.md#order-book
}
let mut response: Value = Value::Null;
if is_equal(&get_value(&market, &Value::Str("option".to_string())), &Value::Bool(true)) {
let __ws_arg_11 = self.extend(request.clone(), &[params.clone()]);
response = self.eapi_public_get_depth(&[__ws_arg_11]).await;
} else if is_equal(&get_value(&market, &Value::Str("linear".to_string())), &Value::Bool(true)) {
let mut rpi: Value = self.safe_value_k(params.clone(), "rpi", &[Value::Bool(false)]);
params = self.omit(params.clone(), Value::Str("rpi".to_string()), &[]);
if is_equal(&rpi, &Value::Bool(true)) {
// rpi limit only supports 1000
add_element_to_object(&mut request, &Value::Str("limit".to_string()), Value::Int(1000));
let __ws_arg_12 = self.extend(request.clone(), &[params.clone()]);
response = self.fapi_public_get_rpi_depth(&[__ws_arg_12]).await;
} else {
let __ws_arg_13 = self.extend(request.clone(), &[params.clone()]);
response = self.fapi_public_get_depth(&[__ws_arg_13]).await;
}
} else if is_equal(&get_value(&market, &Value::Str("inverse".to_string())), &Value::Bool(true)) {
let __ws_arg_14 = self.extend(request.clone(), &[params.clone()]);
response = self.dapi_public_get_depth(&[__ws_arg_14]).await;
} else {
let __ws_arg_15 = self.extend(request.clone(), &[params.clone()]);
response = self.public_get_depth(&[__ws_arg_15]).await;
}
//
// future
//
// {
// "lastUpdateId":333598053905,
// "E":1618631511986,
// "T":1618631511964,
// "bids":[
// ["2493.56","20.189"],
// ["2493.54","1.000"],
// ["2493.51","0.005"]
// ],
// "asks":[
// ["2493.57","0.877"],
// ["2493.62","0.063"],
// ["2493.71","12.054"],
// ]
// }
//
// options (eapi)
//
// {
// "bids": [
// ["108.7","16.08"],
// ["106","21.29"],
// ["82.4","0.02"]
// ],
// "asks": [
// ["111.4","19.52"],
// ["119.9","17.6"],
// ["141.2","31"]
// ],
// "T": 1676771382078,
// "u": 1015939
// }
//
let mut timestamp: Value = self.safe_integer_k(response.clone(), "T", &[]);
let mut orderbook: Value = self.parse_order_book(response.clone(), symbol.clone(), &[timestamp.clone()]);
add_element_to_object(&mut orderbook, &Value::Str("nonce".to_string()), self.safe_integer2(response.clone(), Value::Str("lastUpdateId".to_string()), Value::Str("u".to_string()), &[]));
return orderbook;
Value::Null
}
pub fn parse_ticker(&self, mut ticker: Value, optional_args: &[Value]) -> Value {
let mut market = get_arg(optional_args, 0, Value::Null);
// markPrices
//
// {
// "symbol": "BTCUSDT",
// "markPrice": "11793.63104563", // mark price
// "indexPrice": "11781.80495970", // index price
// "estimatedSettlePrice": "11781.16138815", // Estimated Settle Price, only useful in the last hour before the settlement starts
// "lastFundingRate": "0.00038246", // This is the lastest estimated funding rate
// "nextFundingTime": 1597392000000,
// "interestRate": "0.00010000",
// "time": 1597370495002
// }
//
// spot - ticker
//
// {
// "symbol": "BTCUSDT",
// "priceChange": "-188.18000000",
// "priceChangePercent": "-0.159",
// "weightedAvgPrice": "118356.64734074",
// "lastPrice": "118449.03000000",
// "prevClosePrice": "118637.22000000", // field absent in rolling ticker
// "lastQty": "0.00731000", // field absent in rolling ticker
// "bidPrice": "118449.02000000", // field absent in rolling ticker
// "bidQty": "7.15931000", // field absent in rolling ticker
// "askPrice": "118449.03000000", // field absent in rolling ticker
// "askQty": "0.09592000", // field absent in rolling ticker
// "openPrice": "118637.21000000",
// "highPrice": "119273.36000000",
// "lowPrice": "117427.50000000",
// "volume": "14741.41491000",
// "quoteVolume": "1744744445.80640740",
// "openTime": "1753701474013",
// "closeTime": "1753787874013",
// "firstId": "5116031635",
// "lastId": "5117964946",
// "count": "1933312"
// }
//
// usdm tickers
//
// {
// "symbol": "SUSDT",
// "priceChange": "-0.0229000",
// "priceChangePercent": "-6.777",
// "weightedAvgPrice": "0.3210035",
// "lastPrice": "0.3150000",
// "lastQty": "16",
// "openPrice": "0.3379000",
// "highPrice": "0.3411000",
// "lowPrice": "0.3071000",
// "volume": "120588225",
// "quoteVolume": "38709237.2289000",
// "openTime": "1753701720000",
// "closeTime": "1753788172414",
// "firstId": "72234973",
// "lastId": "72423677",
// "count": "188700"
// }
//
// coinm
//
// {
// "baseVolume": "214549.95171161",
// "closeTime": "1621965286847",
// "count": "1283779",
// "firstId": "152560106",
// "highPrice": "39938.3",
// "lastId": "153843955",
// "lastPrice": "37993.4",
// "lastQty": "1",
// "lowPrice": "36457.2",
// "openPrice": "37783.4",
// "openTime": "1621878840000",
// "pair": "BTCUSD",
// "priceChange": "210.0",
// "priceChangePercent": "0.556",
// "symbol": "BTCUSD_PERP",
// "volume": "81990451",
// "weightedAvgPrice": "38215.08713747"
// }
//
// eapi: fetchTicker, fetchTickers
//
// {
// "symbol": "ETH-230510-1825-C",
// "priceChange": "-5.1",
// "priceChangePercent": "-0.1854",
// "lastPrice": "22.4",
// "lastQty": "0",
// "open": "27.5",
// "high": "34.1",
// "low": "22.4",
// "volume": "6.83",
// "amount": "201.44",
// "bidPrice": "21.9",
// "askPrice": "22.4",
// "openTime": 1683614771898,
// "closeTime": 1683695017784,
// "firstTradeId": 12,
// "tradeCount": 22,
// "strikePrice": "1825",
// "exercisePrice": "1845.95341176"
// }
//
// spot bidsAsks
//
// {
// "symbol":"ETHBTC",
// "bidPrice":"0.07466800",
// "bidQty":"5.31990000",
// "askPrice":"0.07466900",
// "askQty":"10.93540000"
// }
//
// usdm bidsAsks
//
// {
// "symbol":"BTCUSDT",
// "bidPrice":"21321.90",
// "bidQty":"33.592",
// "askPrice":"21322.00",
// "askQty":"1.427",
// "time":"1673899207538"
// }
//
// coinm bidsAsks
//
// {
// "symbol":"BTCUSD_PERP",
// "pair":"BTCUSD",
// "bidPrice":"21301.2",
// "bidQty":"188",
// "askPrice":"21301.3",
// "askQty":"10302",
// "time":"1673899278514"
// }
//
// fetchTicker: tokenized equities
//
// {
// "symbol": "AAPL",
// "bidPrice": "339.51",
// "askPrice": "339.6",
// "bidSize": 45,
// "askSize": 90
// }
//
let mut timestamp: Value = self.safe_integer2(ticker.clone(), Value::Str("closeTime".to_string()), Value::Str("time".to_string()), &[]);
let mut marketType: Value = Value::Null;
if is_true(&(Value::Bool(in_op(&ticker, &Value::Str("time".to_string()))))) {
marketType = Value::Str("contract".to_string());
}
if is_equal(&marketType, &Value::Null) {
marketType = ternary(is_true(&(Value::Bool(in_op(&ticker, &Value::Str("bidQty".to_string()))))), Value::Str("spot".to_string()), Value::Str("contract".to_string()));
}
let mut marketId: Value = self.safe_string_k(ticker.clone(), "symbol", &[]);
let mut symbol: Value = self.safe_symbol(marketId.clone(), &[market.clone(), Value::Null, marketType.clone()]);
let mut last: Value = self.safe_string_k(ticker.clone(), "lastPrice", &[]);
let mut wAvg: Value = self.safe_string_k(ticker.clone(), "weightedAvgPrice", &[]);
let mut isCoinm: Value = (Value::Bool(in_op(&ticker, &Value::Str("baseVolume".to_string()))));
let mut baseVolume: Value = Value::Null;
let mut quoteVolume: Value = Value::Null;
if is_true(&isCoinm) {
baseVolume = self.safe_string_k(ticker.clone(), "baseVolume", &[]);
// 'volume' field in inverse markets is not quoteVolume, but traded amount (per contracts)
quoteVolume = crate::precise::Precise::stringMul(&baseVolume, &wAvg);
} else {
baseVolume = self.safe_string_k(ticker.clone(), "volume", &[]);
quoteVolume = self.safe_string2(ticker.clone(), Value::Str("quoteVolume".to_string()), Value::Str("amount".to_string()), &[]);
}
return self.safe_ticker(Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("symbol".to_string(), symbol.clone());
m.insert("timestamp".to_string(), timestamp.clone());
m.insert("datetime".to_string(), self.iso8601(timestamp.clone()));
m.insert("high".to_string(), self.safe_string2(ticker.clone(), Value::Str("highPrice".to_string()), Value::Str("high".to_string()), &[]));
m.insert("low".to_string(), self.safe_string2(ticker.clone(), Value::Str("lowPrice".to_string()), Value::Str("low".to_string()), &[]));
m.insert("bid".to_string(), self.safe_string_k(ticker.clone(), "bidPrice", &[]));
m.insert("bidVolume".to_string(), self.safe_string2(ticker.clone(), Value::Str("bidQty".to_string()), Value::Str("bidSize".to_string()), &[]));
m.insert("ask".to_string(), self.safe_string_k(ticker.clone(), "askPrice", &[]));
m.insert("askVolume".to_string(), self.safe_string2(ticker.clone(), Value::Str("askQty".to_string()), Value::Str("askSize".to_string()), &[]));
m.insert("vwap".to_string(), wAvg.clone());
m.insert("open".to_string(), self.safe_string2(ticker.clone(), Value::Str("openPrice".to_string()), Value::Str("open".to_string()), &[]));
m.insert("close".to_string(), last.clone());
m.insert("last".to_string(), last.clone());
m.insert("previousClose".to_string(), self.safe_string_k(ticker.clone(), "prevClosePrice", &[]));
m.insert("change".to_string(), self.safe_string_k(ticker.clone(), "priceChange", &[]));
m.insert("percentage".to_string(), self.safe_string_k(ticker.clone(), "priceChangePercent", &[]));
m.insert("average".to_string(), Value::Null);
m.insert("baseVolume".to_string(), baseVolume.clone());
m.insert("quoteVolume".to_string(), quoteVolume.clone());
m.insert("markPrice".to_string(), self.safe_string_k(ticker.clone(), "markPrice", &[]));
m.insert("indexPrice".to_string(), self.safe_string_k(ticker.clone(), "indexPrice", &[]));
m.insert("info".to_string(), ticker.clone());
m
}), &[market.clone()]);
Value::Null
}
/*
* @method
* @name binance#fetchStatus
* @description the latest known information on the availability of the exchange API
* @see https://developers.binance.com/docs/wallet/others/system-status
* @param {object} [params] extra parameters specific to the exchange API endpoint
* @returns {object} a [status structure]{@link https://docs.ccxt.com/?id=exchange-status-structure}
*/
pub async fn fetch_status(&mut self, optional_args: &[Value]) -> Value {
let mut params = get_arg(optional_args, 0, Value::Map({
let mut m = indexmap::IndexMap::new();
m
}));
let mut response: Value = self.sapi_get_system_status(&[params.clone()]).await;
//
// {
// "status": 0, // 0: normal,1:system maintenance
// "msg": "normal" // "normal", "system_maintenance"
// }
//
let mut statusRaw: Value = self.safe_string_k(response.clone(), "status", &[]);
return Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("status".to_string(), self.safe_string(Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("0".to_string(), Value::Str("ok".to_string()));
m.insert("1".to_string(), Value::Str("maintenance".to_string()));
m
}), statusRaw.clone(), &[statusRaw.clone()]));
m.insert("updated".to_string(), Value::Null);
m.insert("eta".to_string(), Value::Null);
m.insert("url".to_string(), Value::Null);
m.insert("info".to_string(), response.clone());
m
});
Value::Null
}
/*
* @method
* @name binance#fetchTicker
* @description fetches a price ticker, a statistical calculation with the information calculated over the past 24 hours for a specific market
* @see https://developers.binance.com/docs/binance-spot-api-docs/rest-api/market-data-endpoints#24hr-ticker-price-change-statistics // spot
* @see https://developers.binance.com/docs/binance-spot-api-docs/rest-api/market-data-endpoints#rolling-window-price-change-statistics // spot
* @see https://developers.binance.com/docs/derivatives/usds-margined-futures/market-data/rest-api/24hr-Ticker-Price-Change-Statistics // swap
* @see https://developers.binance.com/docs/derivatives/coin-margined-futures/market-data/rest-api/24hr-Ticker-Price-Change-Statistics // future
* @see https://developers.binance.com/docs/derivatives/option/market-data/24hr-Ticker-Price-Change-Statistics // option
* @see https://developers.binance.com/en/docs/catalog/advanced-trading-stocks-trading/api/rest-api/market-data#latest-quote // stock
* @param {string} symbol unified symbol of the market to fetch the ticker for
* @param {object} [params] extra parameters specific to the exchange API endpoint
* @param {boolean} [params.rolling] (spot only) default false, if true, uses the rolling 24 hour ticker endpoint /api/v3/ticker
* @returns {object} a [ticker structure]{@link https://docs.ccxt.com/?id=ticker-structure}
*/
pub async fn fetch_ticker(&mut self, mut symbol: Value, optional_args: &[Value]) -> Value {
let mut params = get_arg(optional_args, 0, Value::Map({
let mut m = indexmap::IndexMap::new();
m
}));
if is_equal(&self.markets, &Value::Null) {
self.load_markets(&[]).await;
}
let mut market: Value = self.market(symbol.clone());
let mut request: Value = Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("symbol".to_string(), get_value(&market, &Value::Str("id".to_string())));
m
});
let mut response: Value = Value::Null;
if is_equal(&get_value(&market, &Value::Str("option".to_string())), &Value::Bool(true)) {
let __ws_arg_16 = self.extend(request.clone(), &[params.clone()]);
response = self.eapi_public_get_ticker(&[__ws_arg_16]).await;
} else if is_equal(&get_value(&market, &Value::Str("linear".to_string())), &Value::Bool(true)) {
let __ws_arg_17 = self.extend(request.clone(), &[params.clone()]);
response = self.fapi_public_get_ticker24hr(&[__ws_arg_17]).await;
} else if is_equal(&get_value(&market, &Value::Str("inverse".to_string())), &Value::Bool(true)) {
let __ws_arg_18 = self.extend(request.clone(), &[params.clone()]);
response = self.dapi_public_get_ticker24hr(&[__ws_arg_18]).await;
} else {
let mut stock: Value = self.safe_bool_k(market.clone(), "stock", &[Value::Bool(false)]);
if is_equal(&stock, &Value::Bool(true)) {
let __ws_arg_19 = self.extend(request.clone(), &[params.clone()]);
response = self.sapi_get_equity_market_quote(&[__ws_arg_19]).await;
} else {
let mut rolling: Value = self.safe_bool_k(params.clone(), "rolling", &[Value::Bool(false)]);
params = self.omit(params.clone(), Value::Str("rolling".to_string()), &[]);
if is_equal(&rolling, &Value::Bool(true)) {
let __ws_arg_20 = self.extend(request.clone(), &[params.clone()]);
response = self.public_get_ticker(&[__ws_arg_20]).await;
} else {
let __ws_arg_21 = self.extend(request.clone(), &[params.clone()]);
response = self.public_get_ticker24hr(&[__ws_arg_21]).await;
}
}
}
if is_true(&Value::Bool(is_array(&response))) {
let mut firstTicker: Value = self.safe_dict(response.clone(), Value::Int(0), &[Value::Map({
let mut m = indexmap::IndexMap::new();
m
})]);
return self.parse_ticker(firstTicker.clone(), &[market.clone()]);
}
if is_equal(&response, &Value::Null) {
panic!("{}", crate::exchange_errors::null_response(add(&self.id, &Value::Str(" fetchTicker() returned empty response".to_string()))));
}
return self.parse_ticker(response.clone(), &[market.clone()]);
Value::Null
}
/*
* @method
* @name binance#fetchBidsAsks
* @description fetches the bid and ask price and volume for multiple markets
* @see https://developers.binance.com/docs/binance-spot-api-docs/rest-api/market-data-endpoints#symbol-order-book-ticker // spot
* @see https://developers.binance.com/docs/derivatives/usds-margined-futures/market-data/rest-api/Symbol-Order-Book-Ticker // swap
* @see https://developers.binance.com/docs/derivatives/coin-margined-futures/market-data/rest-api/Symbol-Order-Book-Ticker // future
* @see https://developers.binance.com/docs/derivatives/options-trading/market-data/24hr-Ticker-Price-Change-Statistics // option
* @param {string[]|undefined} symbols unified symbols of the markets to fetch the bids and asks for, all markets are returned if not assigned
* @param {object} [params] extra parameters specific to the exchange API endpoint
* @param {string} [params.subType] "linear" or "inverse"
* @returns {object} a dictionary of [ticker structures]{@link https://docs.ccxt.com/?id=ticker-structure}
*/
pub async fn fetch_bids_asks(&mut self, optional_args: &[Value]) -> Value {
let mut symbols = get_arg(optional_args, 0, Value::Null);
let mut params = get_arg(optional_args, 1, Value::Map({
let mut m = indexmap::IndexMap::new();
m
}));
if is_equal(&self.markets, &Value::Null) {
self.load_markets(&[]).await;
}
symbols = self.market_symbols(&[symbols.clone(), Value::Null, Value::Bool(true), Value::Bool(true), Value::Bool(true)]);
let mut market: Value = self.get_market_from_symbols(&[symbols.clone()]);
let mut type_var: Value = Value::Null;
{ let __destr_tmp = self.handle_market_type_and_params(Value::Str("fetchBidsAsks".to_string()), &[market.clone(), params.clone()]); type_var = get_value(&__destr_tmp, &Value::Int(0)); params = get_value(&__destr_tmp, &Value::Int(1)); }
let mut subType: Value = Value::Null;
{ let __destr_tmp = self.handle_sub_type_and_params(Value::Str("fetchBidsAsks".to_string()), &[market.clone(), params.clone()]); subType = get_value(&__destr_tmp, &Value::Int(0)); params = get_value(&__destr_tmp, &Value::Int(1)); }
let mut request: Value = Value::Map({
let mut m = indexmap::IndexMap::new();
m
});
if is_true(&(!is_equal(&symbols, &Value::Null))) && is_true(&(is_true(&self.is_linear(type_var.clone(), &[subType.clone()])) || is_true(&self.is_inverse(type_var.clone(), &[subType.clone()])))) {
let mut symbolsLength: Value = get_array_length(&symbols);
if is_equal(&symbolsLength, &Value::Int(1)) {
add_element_to_object(&mut request, &Value::Str("symbol".to_string()), self.market_id(get_value(&symbols, &Value::Int(0))));
}
}
let mut response: Value = Value::Null;
if is_equal(&type_var, &Value::Str("option".to_string())) {
response = self.eapi_public_get_ticker(&[params.clone()]).await;
} else if is_true(&self.is_linear(type_var.clone(), &[subType.clone()])) {
let __ws_arg_22 = self.extend(request.clone(), &[params.clone()]);
response = self.fapi_public_get_ticker_book_ticker(&[__ws_arg_22]).await;
} else if is_true(&self.is_inverse(type_var.clone(), &[subType.clone()])) {
let __ws_arg_23 = self.extend(request.clone(), &[params.clone()]);
response = self.dapi_public_get_ticker_book_ticker(&[__ws_arg_23]).await;
} else if is_equal(&type_var, &Value::Str("spot".to_string())) {
if !is_equal(&symbols, &Value::Null) {
add_element_to_object(&mut request, &Value::Str("symbols".to_string()), self.json(self.market_ids(&[symbols.clone()])));
}
let __ws_arg_24 = self.extend(request.clone(), &[params.clone()]);
response = self.public_get_ticker_book_ticker(&[__ws_arg_24]).await;
} else {
panic!("{}", crate::exchange_errors::not_supported(add(&add(&add(&self.id, &Value::Str(" fetchBidsAsks() does not support ".to_string())), &type_var), &Value::Str(" markets yet".to_string()))));
}
if !is_true(&Value::Bool(is_array(&response))) {
response = Value::List(vec![response.clone()]);
}
return self.parse_tickers(response.clone(), &[symbols.clone()]);
Value::Null
}
/*
* @method
* @name binance#fetchLastPrices
* @description fetches the last price for multiple markets
* @see https://developers.binance.com/docs/binance-spot-api-docs/rest-api/market-data-endpoints#symbol-price-ticker // spot
* @see https://developers.binance.com/docs/derivatives/usds-margined-futures/market-data/rest-api/Symbol-Price-Ticker // swap
* @see https://developers.binance.com/docs/derivatives/coin-margined-futures/market-data/rest-api/Symbol-Price-Ticker // future
* @param {string[]|undefined} symbols unified symbols of the markets to fetch the last prices
* @param {object} [params] extra parameters specific to the exchange API endpoint
* @param {string} [params.subType] "linear" or "inverse"
* @returns {object} a dictionary of lastprices structures
*/
pub async fn fetch_last_prices(&mut self, optional_args: &[Value]) -> Value {
let mut symbols = get_arg(optional_args, 0, Value::Null);
let mut params = get_arg(optional_args, 1, Value::Map({
let mut m = indexmap::IndexMap::new();
m
}));
if is_equal(&self.markets, &Value::Null) {
self.load_markets(&[]).await;
}
symbols = self.market_symbols(&[symbols.clone(), Value::Null, Value::Bool(true), Value::Bool(true), Value::Bool(true)]);
let mut market: Value = self.get_market_from_symbols(&[symbols.clone()]);
let mut type_var: Value = Value::Null;
{ let __destr_tmp = self.handle_market_type_and_params(Value::Str("fetchLastPrices".to_string()), &[market.clone(), params.clone()]); type_var = get_value(&__destr_tmp, &Value::Int(0)); params = get_value(&__destr_tmp, &Value::Int(1)); }
let mut subType: Value = Value::Null;
{ let __destr_tmp = self.handle_sub_type_and_params(Value::Str("fetchLastPrices".to_string()), &[market.clone(), params.clone()]); subType = get_value(&__destr_tmp, &Value::Int(0)); params = get_value(&__destr_tmp, &Value::Int(1)); }
let mut response: Value = Value::Null;
if is_true(&self.is_linear(type_var.clone(), &[subType.clone()])) {
response = self.fapi_public_v2_get_ticker_price(&[params.clone()]).await;
} else if is_true(&self.is_inverse(type_var.clone(), &[subType.clone()])) {
response = self.dapi_public_get_ticker_price(&[params.clone()]).await;
} else if is_equal(&type_var, &Value::Str("spot".to_string())) {
response = self.public_get_ticker_price(&[params.clone()]).await;
} else {
panic!("{}", crate::exchange_errors::not_supported(add(&add(&add(&self.id, &Value::Str(" fetchLastPrices() does not support ".to_string())), &type_var), &Value::Str(" markets yet".to_string()))));
}
return self.parse_last_prices(response.clone(), &[symbols.clone()]);
Value::Null
}
pub fn parse_last_price(&self, mut entry: Value, optional_args: &[Value]) -> Value {
let mut market = get_arg(optional_args, 0, Value::Null);
//
// spot
//
// {
// "symbol": "LTCBTC",
// "price": "4.00000200"
// }
//
// usdm (swap/future)
//
// {
// "symbol": "BTCUSDT",
// "price": "6000.01",
// "time": 1589437530011
// }
//
//
// coinm (swap/future)
//
// {
// "symbol": "BTCUSD_200626", // symbol ("BTCUSD_200626", "BTCUSD_PERP", etc..)
// "ps": "BTCUSD", // pair
// "price": "9647.8",
// "time": 1591257246176
// }
//
let mut timestamp: Value = self.safe_integer_k(entry.clone(), "time", &[]);
let mut type_var: Value = ternary(is_true(&(is_equal(×tamp, &Value::Null))), Value::Str("spot".to_string()), Value::Str("swap".to_string()));
let mut marketId: Value = self.safe_string_k(entry.clone(), "symbol", &[]);
market = self.safe_market(&[marketId.clone(), market.clone(), Value::Null, type_var.clone()]);
return Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("symbol".to_string(), get_value(&market, &Value::Str("symbol".to_string())));
m.insert("timestamp".to_string(), timestamp.clone());
m.insert("datetime".to_string(), self.iso8601(timestamp.clone()));
m.insert("price".to_string(), self.safe_number_omit_zero(entry.clone(), Value::Str("price".to_string()), &[]));
m.insert("side".to_string(), Value::Null);
m.insert("info".to_string(), entry.clone());
m
});
Value::Null
}
/*
* @method
* @name binance#fetchTickers
* @description fetches price tickers for multiple markets, statistical information calculated over the past 24 hours for each market
* @see https://developers.binance.com/docs/binance-spot-api-docs/rest-api/market-data-endpoints#24hr-ticker-price-change-statistics // spot
* @see https://developers.binance.com/docs/derivatives/usds-margined-futures/market-data/rest-api/24hr-Ticker-Price-Change-Statistics // swap
* @see https://developers.binance.com/docs/derivatives/coin-margined-futures/market-data/rest-api/24hr-Ticker-Price-Change-Statistics // future
* @see https://developers.binance.com/docs/derivatives/option/market-data/24hr-Ticker-Price-Change-Statistics // option
* @param {string[]} [symbols] unified symbols of the markets to fetch the ticker for, all market tickers are returned if not assigned
* @param {object} [params] extra parameters specific to the exchange API endpoint
* @param {string} [params.subType] "linear" or "inverse"
* @param {string} [params.type] 'spot', 'option', use params["subType"] for swap and future markets
* @returns {object} a dictionary of [ticker structures]{@link https://docs.ccxt.com/?id=ticker-structure}
*/
pub async fn fetch_tickers(&mut self, optional_args: &[Value]) -> Value {
let mut symbols = get_arg(optional_args, 0, Value::Null);
let mut params = get_arg(optional_args, 1, Value::Map({
let mut m = indexmap::IndexMap::new();
m
}));
if is_equal(&self.markets, &Value::Null) {
self.load_markets(&[]).await;
}
symbols = self.market_symbols(&[symbols.clone(), Value::Null, Value::Bool(true), Value::Bool(true), Value::Bool(true)]);
let mut market: Value = self.get_market_from_symbols(&[symbols.clone()]);
let mut type_var: Value = Value::Null;
{ let __destr_tmp = self.handle_market_type_and_params(Value::Str("fetchTickers".to_string()), &[market.clone(), params.clone()]); type_var = get_value(&__destr_tmp, &Value::Int(0)); params = get_value(&__destr_tmp, &Value::Int(1)); }
let mut subType: Value = Value::Null;
{ let __destr_tmp = self.handle_sub_type_and_params(Value::Str("fetchTickers".to_string()), &[market.clone(), params.clone()]); subType = get_value(&__destr_tmp, &Value::Int(0)); params = get_value(&__destr_tmp, &Value::Int(1)); }
let mut response: Value = Value::Null;
if is_true(&self.is_linear(type_var.clone(), &[subType.clone()])) {
response = self.fapi_public_get_ticker24hr(&[params.clone()]).await;
} else if is_true(&self.is_inverse(type_var.clone(), &[subType.clone()])) {
response = self.dapi_public_get_ticker24hr(&[params.clone()]).await;
} else if is_equal(&type_var, &Value::Str("spot".to_string())) {
let mut rolling: Value = self.safe_bool_k(params.clone(), "rolling", &[Value::Bool(false)]);
params = self.omit(params.clone(), Value::Str("rolling".to_string()), &[]);
if is_equal(&rolling, &Value::Bool(true)) {
symbols = self.market_symbols(&[symbols.clone()]);
let mut request: Value = Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("symbols".to_string(), self.json(self.market_ids(&[symbols.clone()])));
m
});
let __ws_arg_25 = self.extend(request.clone(), &[params.clone()]);
response = self.public_get_ticker(&[__ws_arg_25]).await;
return self.parse_tickers_for_rolling(response.clone(), symbols.clone());
} else {
let mut request: Value = Value::Map({
let mut m = indexmap::IndexMap::new();
m
});
if !is_equal(&symbols, &Value::Null) {
add_element_to_object(&mut request, &Value::Str("symbols".to_string()), self.json(self.market_ids(&[symbols.clone()])));
}
let __ws_arg_26 = self.extend(request.clone(), &[params.clone()]);
response = self.public_get_ticker24hr(&[__ws_arg_26]).await;
}
} else if is_equal(&type_var, &Value::Str("option".to_string())) {
response = self.eapi_public_get_ticker(&[params.clone()]).await;
} else {
panic!("{}", crate::exchange_errors::not_supported(add(&add(&add(&self.id, &Value::Str(" fetchTickers() does not support ".to_string())), &type_var), &Value::Str(" markets yet".to_string()))));
}
return self.parse_tickers(response.clone(), &[symbols.clone()]);
Value::Null
}
pub fn parse_tickers_for_rolling(&self, mut response: Value, mut symbols: Value) -> Value {
let mut results: Value = Value::List(vec![]);
{
let mut i: Value = Value::Int(0);
let mut __for_first_261: bool = true;
while { if !__for_first_261 { i = add(&i, &Value::Int(1)); } __for_first_261 = false; is_less_than(&i, &get_array_length(&response)) } {
let mut marketId: Value = self.safe_string_k(get_value(&response, &i), "symbol", &[]);
let mut tickerMarket: Value = self.safe_market(&[marketId.clone(), Value::Null, Value::Null, Value::Str("spot".to_string())]);
let mut parsedTicker: Value = self.parse_ticker(get_value(&response, &i), &[]);
add_element_to_object(&mut parsedTicker, &Value::Str("symbol".to_string()), get_value(&tickerMarket, &Value::Str("symbol".to_string())));
append_to_array(&mut results, parsedTicker.clone());
}
}
return self.filter_by_array(results.clone(), Value::Str("symbol".to_string()), &[symbols.clone()]);
Value::Null
}
/*
* @method
* @name binance#fetchMarkPrice
* @description fetches mark price for the market
* @see https://developers.binance.com/docs/derivatives/coin-margined-futures/market-data/rest-api/Index-Price-and-Mark-Price
* @see https://developers.binance.com/docs/derivatives/usds-margined-futures/market-data/rest-api/Mark-Price
* @see https://developers.binance.com/docs/derivatives/options-trading/market-data/Option-Mark-Price
* @param {string} symbol unified symbol of the market to fetch the ticker for
* @param {object} [params] extra parameters specific to the exchange API endpoint
* @param {string} [params.subType] "linear" or "inverse"
* @returns {object} a dictionary of [ticker structures]{@link https://docs.ccxt.com/?id=ticker-structure}
*/
pub async fn fetch_mark_price(&mut self, mut symbol: Value, optional_args: &[Value]) -> Value {
let mut params = get_arg(optional_args, 0, Value::Map({
let mut m = indexmap::IndexMap::new();
m
}));
if is_equal(&self.markets, &Value::Null) {
self.load_markets(&[]).await;
}
let mut market: Value = self.market(symbol.clone());
let mut type_var: Value = Value::Null;
{ let __destr_tmp = self.handle_market_type_and_params(Value::Str("fetchMarkPrice".to_string()), &[market.clone(), params.clone(), Value::Str("swap".to_string())]); type_var = get_value(&__destr_tmp, &Value::Int(0)); params = get_value(&__destr_tmp, &Value::Int(1)); }
let mut subType: Value = Value::Null;
{ let __destr_tmp = self.handle_sub_type_and_params(Value::Str("fetchMarkPrice".to_string()), &[market.clone(), params.clone(), Value::Str("linear".to_string())]); subType = get_value(&__destr_tmp, &Value::Int(0)); params = get_value(&__destr_tmp, &Value::Int(1)); }
let mut request: Value = Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("symbol".to_string(), get_value(&market, &Value::Str("id".to_string())));
m
});
let mut response: Value = Value::Null;
if is_equal(&get_value(&market, &Value::Str("option".to_string())), &Value::Bool(true)) {
let __ws_arg_27 = self.extend(request.clone(), &[params.clone()]);
response = self.eapi_public_get_mark(&[__ws_arg_27]).await;
} else if is_true(&self.is_linear(type_var.clone(), &[subType.clone()])) {
let __ws_arg_28 = self.extend(request.clone(), &[params.clone()]);
response = self.fapi_public_get_premium_index(&[__ws_arg_28]).await;
} else if is_true(&self.is_inverse(type_var.clone(), &[subType.clone()])) {
let __ws_arg_29 = self.extend(request.clone(), &[params.clone()]);
response = self.dapi_public_get_premium_index(&[__ws_arg_29]).await;
} else {
panic!("{}", crate::exchange_errors::not_supported(add(&add(&add(&self.id, &Value::Str(" fetchMarkPrice() does not support ".to_string())), &type_var), &Value::Str(" markets yet".to_string()))));
}
if is_true(&Value::Bool(is_array(&response))) {
return self.parse_ticker(self.safe_dict(response.clone(), Value::Int(0), &[Value::Map({
let mut m = indexmap::IndexMap::new();
m
})]), &[market.clone()]);
}
if is_equal(&response, &Value::Null) {
panic!("{}", crate::exchange_errors::null_response(add(&self.id, &Value::Str(" fetchMarkPrice() returned empty response".to_string()))));
}
return self.parse_ticker(response.clone(), &[market.clone()]);
Value::Null
}
/*
* @method
* @name binance#fetchMarkPrices
* @description fetches mark prices for multiple markets
* @see https://developers.binance.com/docs/derivatives/coin-margined-futures/market-data/rest-api/Index-Price-and-Mark-Price
* @see https://developers.binance.com/docs/derivatives/usds-margined-futures/market-data/rest-api/Mark-Price
* @see https://developers.binance.com/docs/derivatives/options-trading/market-data/Option-Mark-Price
* @param {string[]} [symbols] unified symbols of the markets to fetch the ticker for, all market tickers are returned if not assigned
* @param {object} [params] extra parameters specific to the exchange API endpoint
* @param {string} [params.subType] "linear" or "inverse"
* @returns {object} a dictionary of [ticker structures]{@link https://docs.ccxt.com/?id=ticker-structure}
*/
pub async fn fetch_mark_prices(&mut self, optional_args: &[Value]) -> Value {
let mut symbols = get_arg(optional_args, 0, Value::Null);
let mut params = get_arg(optional_args, 1, Value::Map({
let mut m = indexmap::IndexMap::new();
m
}));
if is_equal(&self.markets, &Value::Null) {
self.load_markets(&[]).await;
}
symbols = self.market_symbols(&[symbols.clone(), Value::Null, Value::Bool(true), Value::Bool(true), Value::Bool(true)]);
let mut market: Value = self.get_market_from_symbols(&[symbols.clone()]);
let mut type_var: Value = Value::Null;
{ let __destr_tmp = self.handle_market_type_and_params(Value::Str("fetchMarkPrices".to_string()), &[market.clone(), params.clone(), Value::Str("swap".to_string())]); type_var = get_value(&__destr_tmp, &Value::Int(0)); params = get_value(&__destr_tmp, &Value::Int(1)); }
let mut subType: Value = Value::Null;
{ let __destr_tmp = self.handle_sub_type_and_params(Value::Str("fetchMarkPrices".to_string()), &[market.clone(), params.clone(), Value::Str("linear".to_string())]); subType = get_value(&__destr_tmp, &Value::Int(0)); params = get_value(&__destr_tmp, &Value::Int(1)); }
let mut response: Value = Value::Null;
if is_equal(&type_var, &Value::Str("option".to_string())) {
response = self.eapi_public_get_mark(&[params.clone()]).await;
} else if is_true(&self.is_linear(type_var.clone(), &[subType.clone()])) {
response = self.fapi_public_get_premium_index(&[params.clone()]).await;
} else if is_true(&self.is_inverse(type_var.clone(), &[subType.clone()])) {
response = self.dapi_public_get_premium_index(&[params.clone()]).await;
} else {
panic!("{}", crate::exchange_errors::not_supported(add(&add(&add(&self.id, &Value::Str(" fetchMarkPrices() does not support ".to_string())), &type_var), &Value::Str(" markets yet".to_string()))));
}
return self.parse_tickers(response.clone(), &[symbols.clone()]);
Value::Null
}
pub fn parse_ohlcv(&self, mut ohlcv: Value, optional_args: &[Value]) -> Value {
let mut market = get_arg(optional_args, 0, Value::Null);
// when api method = publicGetKlines || fapiPublicGetKlines || dapiPublicGetKlines
// [
// 1591478520000, // open time
// "0.02501300", // open
// "0.02501800", // high
// "0.02500000", // low
// "0.02500000", // close
// "22.19000000", // volume
// 1591478579999, // close time
// "0.55490906", // quote asset volume, base asset volume for dapi
// 40, // number of trades
// "10.92900000", // taker buy base asset volume
// "0.27336462", // taker buy quote asset volume
// "0" // ignore
// ]
//
// when api method = fapiPublicGetMarkPriceKlines || fapiPublicGetIndexPriceKlines
// [
// [
// 1591256460000, // Open time
// "9653.29201333", // Open
// "9654.56401333", // High
// "9653.07367333", // Low
// "9653.07367333", // Close (or latest price)
// "0", // Ignore
// 1591256519999, // Close time
// "0", // Ignore
// 60, // Number of basic data
// "0", // Ignore
// "0", // Ignore
// "0" // Ignore
// ]
// ]
//
// options
//
// {
// "open": "32.2",
// "high": "32.2",
// "low": "32.2",
// "close": "32.2",
// "volume": "0",
// "interval": "5m",
// "tradeCount": 0,
// "takerVolume": "0",
// "takerAmount": "0",
// "amount": "0",
// "openTime": 1677096900000,
// "closeTime": 1677097200000
// }
//
let mut inverse: Value = self.safe_bool_k(market.clone(), "inverse", &[]);
let mut volumeIndex: Value = ternary(is_true(&(is_equal(&inverse, &Value::Bool(true)))), Value::Int(7), Value::Int(5));
return Value::List(vec![self.safe_integer2(ohlcv.clone(), Value::Int(0), Value::Str("openTime".to_string()), &[]), self.safe_number2(ohlcv.clone(), Value::Int(1), Value::Str("open".to_string()), &[]), self.safe_number2(ohlcv.clone(), Value::Int(2), Value::Str("high".to_string()), &[]), self.safe_number2(ohlcv.clone(), Value::Int(3), Value::Str("low".to_string()), &[]), self.safe_number2(ohlcv.clone(), Value::Int(4), Value::Str("close".to_string()), &[]), self.safe_number2(ohlcv.clone(), volumeIndex.clone(), Value::Str("volume".to_string()), &[])]);
Value::Null
}
/*
* @method
* @name binance#fetchOHLCV
* @description fetches historical candlestick data containing the open, high, low, and close price, and the volume of a market
* @see https://developers.binance.com/docs/binance-spot-api-docs/rest-api/market-data-endpoints#klinecandlestick-data
* @see https://developers.binance.com/docs/derivatives/option/market-data/Kline-Candlestick-Data
* @see https://developers.binance.com/docs/derivatives/usds-margined-futures/market-data/rest-api/Kline-Candlestick-Data
* @see https://developers.binance.com/docs/derivatives/usds-margined-futures/market-data/rest-api/Index-Price-Kline-Candlestick-Data
* @see https://developers.binance.com/docs/derivatives/usds-margined-futures/market-data/rest-api/Mark-Price-Kline-Candlestick-Data
* @see https://developers.binance.com/docs/derivatives/usds-margined-futures/market-data/rest-api/Premium-Index-Kline-Data
* @see https://developers.binance.com/docs/derivatives/coin-margined-futures/market-data/rest-api/Kline-Candlestick-Data
* @see https://developers.binance.com/docs/derivatives/coin-margined-futures/market-data/rest-api/Index-Price-Kline-Candlestick-Data
* @see https://developers.binance.com/docs/derivatives/coin-margined-futures/market-data/rest-api/Mark-Price-Kline-Candlestick-Data
* @see https://developers.binance.com/docs/derivatives/coin-margined-futures/market-data/rest-api/Premium-Index-Kline-Data
* @param {string} symbol unified symbol of the market to fetch OHLCV data for
* @param {string} timeframe the length of time each candle represents
* @param {int} [since] timestamp in ms of the earliest candle to fetch
* @param {int} [limit] the maximum amount of candles to fetch
* @param {object} [params] extra parameters specific to the exchange API endpoint
* @param {string} [params.price] "mark" or "index" for mark price and index price candles
* @param {int} [params.until] timestamp in ms of the latest candle to fetch
* @param {boolean} [params.paginate] default false, when true will automatically paginate by calling this endpoint multiple times. See in the docs all the [available parameters](https://github.com/ccxt/ccxt/wiki/Manual#pagination-params)
* @returns {int[][]} A list of candles ordered as timestamp, open, high, low, close, volume
*/
pub async fn fetch_ohlcv(&mut self, mut symbol: Value, optional_args: &[Value]) -> Value {
let mut timeframe = get_arg(optional_args, 0, Value::Str("1m".to_string()));
let mut since = get_arg(optional_args, 1, Value::Null);
let mut limit = get_arg(optional_args, 2, Value::Null);
let mut params = get_arg(optional_args, 3, Value::Map({
let mut m = indexmap::IndexMap::new();
m
}));
if is_equal(&self.markets, &Value::Null) {
self.load_markets(&[]).await;
}
let mut paginate: Value = Value::Bool(false);
{ let __destr_tmp = self.handle_option_and_params(params.clone(), Value::Str("fetchOHLCV".to_string()), Value::Str("paginate".to_string()), &[Value::Bool(false)]); paginate = get_value(&__destr_tmp, &Value::Int(0)); params = get_value(&__destr_tmp, &Value::Int(1)); }
if is_true(&paginate) {
return self.fetch_paginated_call_deterministic(Value::Str("fetchOHLCV".to_string()), &[symbol.clone(), since.clone(), limit.clone(), timeframe.clone(), params.clone(), Value::Int(1000)]).await;
}
let mut market: Value = self.market(symbol.clone());
// binance docs say that the default limit 500, max 1500 for futures, max 1000 for spot markets
// the reality is that the time range wider than 500 candles won't work right
let mut defaultLimit: Value = Value::Int(500);
let mut maxLimit: Value = Value::Int(1000);
let mut price: Value = self.safe_string_k(params.clone(), "price", &[]);
let mut until: Value = self.safe_integer_k(params.clone(), "until", &[]);
params = self.omit(params.clone(), Value::List(vec![Value::Str("price".to_string()), Value::Str("until".to_string())]), &[]);
if !is_equal(&since, &Value::Null) && !is_equal(&until, &Value::Null) && is_equal(&limit, &Value::Null) {
limit = maxLimit.clone();
}
limit = ternary(is_true(&(is_equal(&limit, &Value::Null))), defaultLimit.clone(), crate::runtime::Math::min(&limit, &maxLimit));
let mut request: Value = Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("interval".to_string(), self.safe_string(self.timeframes.clone(), timeframe.clone(), &[timeframe.clone()]));
m.insert("limit".to_string(), limit.clone());
m
});
let mut marketId: Value = get_value(&market, &Value::Str("id".to_string()));
if is_equal(&marketId, &Value::Null) {
panic!("{}", crate::exchange_errors::exchange_error(add(&self.id, &Value::Str(" fetchOHLCV() missing marketId".to_string()))));
}
if is_equal(&price, &Value::Str("index".to_string())) {
let mut parts: Value = split(&marketId, &Value::Str("_".to_string()));
let mut pair: Value = self.safe_string(parts.clone(), Value::Int(0), &[]);
add_element_to_object(&mut request, &Value::Str("pair".to_string()), pair.clone()); // Index price takes this argument instead of symbol
} else {
add_element_to_object(&mut request, &Value::Str("symbol".to_string()), marketId.clone());
}
// const duration = this.parseTimeframe (timeframe);
if !is_equal(&since, &Value::Null) {
add_element_to_object(&mut request, &Value::Str("startTime".to_string()), since.clone());
//
// It didn't work before without the endTime
// https://github.com/ccxt/ccxt/issues/8454
//
if is_equal(&get_value(&market, &Value::Str("inverse".to_string())), &Value::Bool(true)) {
if is_greater_than(&since, &Value::Int(0)) {
let mut duration: Value = self.parse_timeframe(timeframe.clone());
let mut endTime: Value = self.sum(&[since.clone(), subtract(&multiply(&multiply(&limit, &duration), &Value::Int(1000)), &Value::Int(1))]);
let mut now: Value = self.milliseconds();
add_element_to_object(&mut request, &Value::Str("endTime".to_string()), crate::runtime::Math::min(&now, &endTime));
}
}
}
if !is_equal(&until, &Value::Null) {
add_element_to_object(&mut request, &Value::Str("endTime".to_string()), until.clone());
}
let mut response: Value = Value::Null;
if is_equal(&get_value(&market, &Value::Str("option".to_string())), &Value::Bool(true)) {
let __ws_arg_30 = self.extend(request.clone(), &[params.clone()]);
response = self.eapi_public_get_klines(&[__ws_arg_30]).await;
} else if is_equal(&price, &Value::Str("mark".to_string())) {
if is_equal(&get_value(&market, &Value::Str("inverse".to_string())), &Value::Bool(true)) {
let __ws_arg_31 = self.extend(request.clone(), &[params.clone()]);
response = self.dapi_public_get_mark_price_klines(&[__ws_arg_31]).await;
} else {
let __ws_arg_32 = self.extend(request.clone(), &[params.clone()]);
response = self.fapi_public_get_mark_price_klines(&[__ws_arg_32]).await;
}
} else if is_equal(&price, &Value::Str("index".to_string())) {
if is_equal(&get_value(&market, &Value::Str("inverse".to_string())), &Value::Bool(true)) {
let __ws_arg_33 = self.extend(request.clone(), &[params.clone()]);
response = self.dapi_public_get_index_price_klines(&[__ws_arg_33]).await;
} else {
let __ws_arg_34 = self.extend(request.clone(), &[params.clone()]);
response = self.fapi_public_get_index_price_klines(&[__ws_arg_34]).await;
}
} else if is_equal(&price, &Value::Str("premiumIndex".to_string())) {
if is_equal(&get_value(&market, &Value::Str("inverse".to_string())), &Value::Bool(true)) {
let __ws_arg_35 = self.extend(request.clone(), &[params.clone()]);
response = self.dapi_public_get_premium_index_klines(&[__ws_arg_35]).await;
} else {
let __ws_arg_36 = self.extend(request.clone(), &[params.clone()]);
response = self.fapi_public_get_premium_index_klines(&[__ws_arg_36]).await;
}
} else if is_equal(&get_value(&market, &Value::Str("linear".to_string())), &Value::Bool(true)) {
let __ws_arg_37 = self.extend(request.clone(), &[params.clone()]);
response = self.fapi_public_get_klines(&[__ws_arg_37]).await;
} else if is_equal(&get_value(&market, &Value::Str("inverse".to_string())), &Value::Bool(true)) {
let __ws_arg_38 = self.extend(request.clone(), &[params.clone()]);
response = self.dapi_public_get_klines(&[__ws_arg_38]).await;
} else {
let __ws_arg_39 = self.extend(request.clone(), &[params.clone()]);
response = self.public_get_klines(&[__ws_arg_39]).await;
}
//
// [
// [1591478520000,"0.02501300","0.02501800","0.02500000","0.02500000","22.19000000",1591478579999,"0.55490906",40,"10.92900000","0.27336462","0"],
// [1591478580000,"0.02499600","0.02500900","0.02499400","0.02500300","21.34700000",1591478639999,"0.53370468",24,"7.53800000","0.18850725","0"],
// [1591478640000,"0.02500800","0.02501100","0.02500300","0.02500800","154.14200000",1591478699999,"3.85405839",97,"5.32300000","0.13312641","0"],
// ]
//
// options (eapi)
//
// [
// {
// "open": "32.2",
// "high": "32.2",
// "low": "32.2",
// "close": "32.2",
// "volume": "0",
// "interval": "5m",
// "tradeCount": 0,
// "takerVolume": "0",
// "takerAmount": "0",
// "amount": "0",
// "openTime": 1677096900000,
// "closeTime": 1677097200000
// }
// ]
//
let mut candles: Value = self.parse_ohlc_vs(self.to_array(response.clone()), &[market.clone(), timeframe.clone(), since.clone(), limit.clone()]);
return candles;
Value::Null
}
pub fn parse_trade(&self, mut trade: Value, optional_args: &[Value]) -> Value {
let mut market = get_arg(optional_args, 0, Value::Null);
if is_true(&Value::Bool(in_op(&trade, &Value::Str("isDustTrade".to_string())))) {
return self.parse_dust_trade(trade.clone(), &[market.clone()]);
}
//
// aggregate trades
// https://github.com/binance-exchange/binance-official-api-docs/blob/master/rest-api.md#compressedaggregate-trades-list
//
// {
// "a": 26129, // Aggregate tradeId
// "p": "0.01633102", // Price
// "q": "4.70443515", // Quantity
// "f": 27781, // First tradeId
// "l": 27781, // Last tradeId
// "T": 1498793709153, // Timestamp
// "m": true, // Was the buyer the maker?
// "M": true // Was the trade the best price match?
// }
//
// REST: aggregate trades for swap & future (both linear and inverse)
//
// {
// "a": "269772814",
// "p": "25864.1",
// "q": "3",
// "f": "662149354",
// "l": "662149355",
// "T": "1694209776022",
// "m": false,
// }
//
// recent public trades and old public trades
// https://github.com/binance-exchange/binance-official-api-docs/blob/master/rest-api.md#recent-trades-list
// https://github.com/binance-exchange/binance-official-api-docs/blob/master/rest-api.md#old-trade-lookup-market_data
//
// {
// "id": 28457,
// "price": "4.00000100",
// "qty": "12.00000000",
// "time": 1499865549590,
// "isBuyerMaker": true,
// "isBestMatch": true
// }
//
// private trades
// https://github.com/binance-exchange/binance-official-api-docs/blob/master/rest-api.md#account-trade-list-user_data
//
// {
// "symbol": "BNBBTC",
// "id": 28457,
// "orderId": 100234,
// "price": "4.00000100",
// "qty": "12.00000000",
// "commission": "10.10000000",
// "commissionAsset": "BNB",
// "time": 1499865549590,
// "isBuyer": true,
// "isMaker": false,
// "isBestMatch": true
// }
//
// futures trades
//
// {
// "accountId": 20,
// "buyer": False,
// "commission": "-0.07819010",
// "commissionAsset": "USDT",
// "counterPartyId": 653,
// "id": 698759,
// "maker": False,
// "orderId": 25851813,
// "price": "7819.01",
// "qty": "0.002",
// "quoteQty": "0.01563",
// "realizedPnl": "-0.91539999",
// "side": "SELL",
// "symbol": "BTCUSDT",
// "time": 1569514978020
// }
// {
// "symbol": "BTCUSDT",
// "id": 477128891,
// "orderId": 13809777875,
// "side": "SELL",
// "price": "38479.55",
// "qty": "0.001",
// "realizedPnl": "-0.00009534",
// "marginAsset": "USDT",
// "quoteQty": "38.47955",
// "commission": "-0.00076959",
// "commissionAsset": "USDT",
// "time": 1612733566708,
// "positionSide": "BOTH",
// "maker": true,
// "buyer": false
// }
//
// { respType: FULL }
//
// {
// "price": "4000.00000000",
// "qty": "1.00000000",
// "commission": "4.00000000",
// "commissionAsset": "USDT",
// "tradeId": "1234",
// }
//
// options: fetchMyTrades
//
// {
// "id": 1125899906844226012,
// "tradeId": 73,
// "orderId": 4638761100843040768,
// "symbol": "ETH-230211-1500-C",
// "price": "18.70000000",
// "quantity": "-0.57000000",
// "fee": "0.17305890",
// "realizedProfit": "-3.53400000",
// "side": "SELL",
// "type": "LIMIT",
// "volatility": "0.30000000",
// "liquidity": "MAKER",
// "time": 1676085216845,
// "priceScale": 1,
// "quantityScale": 2,
// "optionSide": "CALL",
// "quoteAsset": "USDT"
// }
//
// options: fetchTrades
//
// {
// "id": 1,
// "symbol": "ETH-230216-1500-C",
// "price": "35.5",
// "qty": "0.03",
// "quoteQty": "1.065",
// "side": 1,
// "time": 1676366446072
// }
//
// fetchMyTrades: linear portfolio margin
//
// {
// "symbol": "BTCUSDT",
// "id": 4575108247,
// "orderId": 261942655610,
// "side": "SELL",
// "price": "47263.40",
// "qty": "0.010",
// "realizedPnl": "27.38400000",
// "marginAsset": "USDT",
// "quoteQty": "472.63",
// "commission": "0.18905360",
// "commissionAsset": "USDT",
// "time": 1707530039409,
// "buyer": false,
// "maker": false,
// "positionSide": "LONG"
// }
//
// fetchMyTrades: inverse portfolio margin
//
// {
// "symbol": "ETHUSD_PERP",
// "id": 701907838,
// "orderId": 71548909034,
// "pair": "ETHUSD",
// "side": "SELL",
// "price": "2498.15",
// "qty": "1",
// "realizedPnl": "0.00012517",
// "marginAsset": "ETH",
// "baseQty": "0.00400296",
// "commission": "0.00000160",
// "commissionAsset": "ETH",
// "time": 1707530317519,
// "positionSide": "LONG",
// "buyer": false,
// "maker": false
// }
//
// fetchMyTrades: spot margin portfolio margin
//
// {
// "symbol": "ADAUSDT",
// "id": 470227543,
// "orderId": 4421170947,
// "price": "0.53880000",
// "qty": "10.00000000",
// "quoteQty": "5.38800000",
// "commission": "0.00538800",
// "commissionAsset": "USDT",
// "time": 1707545780522,
// "isBuyer": false,
// "isMaker": false,
// "isBestMatch": true
// }
//
// fetchMyTrades: tokenized equities
//
// {
// "executionId": "cc942eb9-eaa0-47e7-8273-2a9bc10c5741",
// "orderId": "ef66a86f-202b-4b41-b15c-e1c90f975f17",
// "symbol": "AAPL",
// "quote": "USDC",
// "side": "BUY",
// "orderType": "MARKET",
// "price": "309.16",
// "qty": "0.0576724",
// "total": "17.83",
// "executionAt": 1785936600545,
// "updatedAt": 1785936601012
// }
//
let mut timestamp: Value = self.safe_integer_n(trade.clone(), Value::List(vec![Value::Str("T".to_string()), Value::Str("time".to_string()), Value::Str("executionAt".to_string())]), &[]);
let mut amount: Value = self.safe_string2(trade.clone(), Value::Str("q".to_string()), Value::Str("qty".to_string()), &[]);
amount = self.safe_string_k(trade.clone(), "quantity", &[amount.clone()]);
let mut marketId: Value = self.safe_string_k(trade.clone(), "symbol", &[]);
let mut isSpotTrade: bool = is_true(&(Value::Bool(in_op(&trade, &Value::Str("isIsolated".to_string()))))) || is_true(&(Value::Bool(in_op(&trade, &Value::Str("M".to_string()))))) || is_true(&(Value::Bool(in_op(&trade, &Value::Str("orderListId".to_string()))))) || is_true(&(Value::Bool(in_op(&trade, &Value::Str("isMaker".to_string())))));
let mut marketType: Value = ternary(is_true(&isSpotTrade), Value::Str("spot".to_string()), Value::Str("contract".to_string()));
market = self.safe_market(&[marketId.clone(), market.clone(), Value::Null, marketType.clone()]);
let mut symbol: Value = get_value(&market, &Value::Str("symbol".to_string()));
let mut side: Value = Value::Null;
let mut buyerMaker: Value = self.safe_bool2(trade.clone(), Value::Str("m".to_string()), Value::Str("isBuyerMaker".to_string()), &[]);
let mut takerOrMaker: Value = Value::Null;
if !is_equal(&buyerMaker, &Value::Null) {
side = ternary(is_true(&buyerMaker), Value::Str("sell".to_string()), Value::Str("buy".to_string())); // this is reversed intentionally
} else if is_true(&Value::Bool(in_op(&trade, &Value::Str("side".to_string())))) {
side = self.safe_string_lower(trade.clone(), Value::Str("side".to_string()), &[]);
} else {
if is_true(&Value::Bool(in_op(&trade, &Value::Str("isBuyer".to_string())))) {
side = ternary(is_true(&(is_equal(&get_value(&trade, &Value::Str("isBuyer".to_string())), &Value::Bool(true)))), Value::Str("buy".to_string()), Value::Str("sell".to_string())); // this is a true side
}
}
let mut fee: Value = Value::Null;
if is_true(&Value::Bool(in_op(&trade, &Value::Str("commission".to_string())))) {
fee = Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), self.safe_string_k(trade.clone(), "commission", &[]));
m.insert("currency".to_string(), self.safe_currency_code(self.safe_string_k(trade.clone(), "commissionAsset", &[]), &[]));
m
});
}
if is_true(&Value::Bool(in_op(&trade, &Value::Str("isMaker".to_string())))) {
takerOrMaker = ternary(is_true(&(is_equal(&get_value(&trade, &Value::Str("isMaker".to_string())), &Value::Bool(true)))), Value::Str("maker".to_string()), Value::Str("taker".to_string()));
}
if is_true(&Value::Bool(in_op(&trade, &Value::Str("maker".to_string())))) {
takerOrMaker = ternary(is_true(&(is_equal(&get_value(&trade, &Value::Str("maker".to_string())), &Value::Bool(true)))), Value::Str("maker".to_string()), Value::Str("taker".to_string()));
}
if is_true(&(Value::Bool(in_op(&trade, &Value::Str("optionSide".to_string()))))) || is_true(&(is_equal(&get_value(&market, &Value::Str("option".to_string())), &Value::Bool(true)))) {
let mut settle: Value = self.safe_currency_code(self.safe_string_k(trade.clone(), "quoteAsset", &[Value::Str("USDT".to_string())]), &[]);
takerOrMaker = self.safe_string_lower(trade.clone(), Value::Str("liquidity".to_string()), &[]);
if is_true(&Value::Bool(in_op(&trade, &Value::Str("fee".to_string())))) {
fee = Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), self.safe_string_k(trade.clone(), "fee", &[]));
m.insert("currency".to_string(), settle.clone());
m
});
}
if is_true(&(!is_equal(&side, &Value::Str("buy".to_string())))) && is_true(&(!is_equal(&side, &Value::Str("sell".to_string())))) {
side = ternary(is_true(&(is_equal(&side, &Value::Str("1".to_string())))), Value::Str("buy".to_string()), Value::Str("sell".to_string()));
}
if is_true(&Value::Bool(in_op(&trade, &Value::Str("optionSide".to_string())))) {
if !is_equal(&side, &Value::Str("buy".to_string())) {
amount = crate::precise::Precise::stringMul(&Value::Str("-1".to_string()), &amount);
}
}
}
return self.safe_trade(Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("info".to_string(), trade.clone());
m.insert("timestamp".to_string(), timestamp.clone());
m.insert("datetime".to_string(), self.iso8601(timestamp.clone()));
m.insert("symbol".to_string(), symbol.clone());
m.insert("id".to_string(), self.safe_string_n(trade.clone(), Value::List(vec![Value::Str("t".to_string()), Value::Str("a".to_string()), Value::Str("tradeId".to_string()), Value::Str("id".to_string()), Value::Str("executionId".to_string())]), &[]));
m.insert("order".to_string(), self.safe_string_k(trade.clone(), "orderId", &[]));
m.insert("type".to_string(), self.safe_string_lower2(trade.clone(), Value::Str("type".to_string()), Value::Str("orderType".to_string()), &[]));
m.insert("side".to_string(), side.clone());
m.insert("takerOrMaker".to_string(), takerOrMaker.clone());
m.insert("price".to_string(), self.safe_string2(trade.clone(), Value::Str("p".to_string()), Value::Str("price".to_string()), &[]));
m.insert("amount".to_string(), amount.clone());
m.insert("cost".to_string(), self.safe_string_n(trade.clone(), Value::List(vec![Value::Str("quoteQty".to_string()), Value::Str("baseQty".to_string()), Value::Str("total".to_string())]), &[]));
m.insert("fee".to_string(), fee.clone());
m
}), &[market.clone()]);
Value::Null
}
/*
* @method
* @name binance#fetchTrades
* @description get the list of most recent trades for a particular symbol
* Default fetchTradesMethod
* @see https://developers.binance.com/docs/binance-spot-api-docs/rest-api/market-data-endpoints#compressedaggregate-trades-list // publicGetAggTrades (spot)
* @see https://developers.binance.com/docs/derivatives/usds-margined-futures/market-data/rest-api/Compressed-Aggregate-Trades-List // fapiPublicGetAggTrades (swap)
* @see https://developers.binance.com/docs/derivatives/coin-margined-futures/market-data/rest-api/Compressed-Aggregate-Trades-List // dapiPublicGetAggTrades (future)
* @see https://developers.binance.com/docs/derivatives/option/market-data/Recent-Trades-List // eapiPublicGetTrades (option)
* Other fetchTradesMethod
* @see https://developers.binance.com/docs/binance-spot-api-docs/rest-api/market-data-endpoints#recent-trades-list // publicGetTrades (spot)
* @see https://developers.binance.com/docs/derivatives/usds-margined-futures/market-data/rest-api/Recent-Trades-List // fapiPublicGetTrades (swap)
* @see https://developers.binance.com/docs/derivatives/coin-margined-futures/market-data/rest-api/Recent-Trades-List // dapiPublicGetTrades (future)
* @see https://developers.binance.com/docs/binance-spot-api-docs/rest-api/market-data-endpoints#old-trade-lookup // publicGetHistoricalTrades (spot)
* @see https://developers.binance.com/docs/derivatives/usds-margined-futures/market-data/rest-api/Old-Trades-Lookup // fapiPublicGetHistoricalTrades (swap)
* @see https://developers.binance.com/docs/derivatives/coin-margined-futures/market-data/rest-api/Old-Trades-Lookup // dapiPublicGetHistoricalTrades (future)
* @see https://developers.binance.com/docs/derivatives/option/market-data/Old-Trades-Lookup // eapiPublicGetHistoricalTrades (option)
* @param {string} symbol unified symbol of the market to fetch trades for
* @param {int} [since] only used when fetchTradesMethod is 'publicGetAggTrades', 'fapiPublicGetAggTrades', or 'dapiPublicGetAggTrades'
* @param {int} [limit] default 500, max 1000
* @param {object} [params] extra parameters specific to the exchange API endpoint
* @param {int} [params.until] only used when fetchTradesMethod is 'publicGetAggTrades', 'fapiPublicGetAggTrades', or 'dapiPublicGetAggTrades'
* @param {int} [params.fetchTradesMethod] 'publicGetAggTrades' (spot default), 'fapiPublicGetAggTrades' (swap default), 'dapiPublicGetAggTrades' (future default), 'eapiPublicGetTrades' (option default), 'publicGetTrades', 'fapiPublicGetTrades', 'dapiPublicGetTrades', 'publicGetHistoricalTrades', 'fapiPublicGetHistoricalTrades', 'dapiPublicGetHistoricalTrades', 'eapiPublicGetHistoricalTrades'
* @param {boolean} [params.paginate] default false, when true will automatically paginate by calling this endpoint multiple times. See in the docs all the [availble parameters](https://github.com/ccxt/ccxt/wiki/Manual#pagination-params)
*
* EXCHANGE SPECIFIC PARAMETERS
* @param {int} [params.fromId] trade id to fetch from, default gets most recent trades, not used when fetchTradesMethod is 'publicGetTrades', 'fapiPublicGetTrades', 'dapiPublicGetTrades', or 'eapiPublicGetTrades'
* @returns {Trade[]} a list of [trade structures]{@link https://docs.ccxt.com/?id=public-trades}
*/
pub async fn fetch_trades(&mut self, mut symbol: Value, optional_args: &[Value]) -> Value {
let mut since = get_arg(optional_args, 0, Value::Null);
let mut limit = get_arg(optional_args, 1, Value::Null);
let mut params = get_arg(optional_args, 2, Value::Map({
let mut m = indexmap::IndexMap::new();
m
}));
if is_equal(&self.markets, &Value::Null) {
self.load_markets(&[]).await;
}
let mut paginate: Value = Value::Bool(false);
{ let __destr_tmp = self.handle_option_and_params(params.clone(), Value::Str("fetchTrades".to_string()), Value::Str("paginate".to_string()), &[]); paginate = get_value(&__destr_tmp, &Value::Int(0)); params = get_value(&__destr_tmp, &Value::Int(1)); }
if is_true(&paginate) {
return self.fetch_paginated_call_dynamic(Value::Str("fetchTrades".to_string()), &[symbol.clone(), since.clone(), limit.clone(), params.clone()]).await;
}
let mut market: Value = self.market(symbol.clone());
let mut request: Value = Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("symbol".to_string(), get_value(&market, &Value::Str("id".to_string())));
m
});
if !is_equal(&get_value(&market, &Value::Str("option".to_string())), &Value::Bool(true)) {
if !is_equal(&since, &Value::Null) {
add_element_to_object(&mut request, &Value::Str("startTime".to_string()), since.clone());
// https://github.com/ccxt/ccxt/issues/6400
// https://github.com/binance-exchange/binance-official-api-docs/blob/master/rest-api.md#compressedaggregate-trades-list
add_element_to_object(&mut request, &Value::Str("endTime".to_string()), self.sum(&[since.clone(), Value::Int(3600000)]));
}
let mut until: Value = self.safe_integer_k(params.clone(), "until", &[]);
if !is_equal(&until, &Value::Null) {
add_element_to_object(&mut request, &Value::Str("endTime".to_string()), until.clone());
}
}
let mut method: Value = self.safe_string_k(self.options.clone(), "fetchTradesMethod", &[]);
method = self.safe_string2(params.clone(), Value::Str("fetchTradesMethod".to_string()), Value::Str("method".to_string()), &[method.clone()]);
if !is_equal(&limit, &Value::Null) {
let mut isFutureOrSwap: Value = Value::Bool(is_true(&(is_equal(&get_value(&market, &Value::Str("swap".to_string())), &Value::Bool(true)))) || is_true(&(is_equal(&get_value(&market, &Value::Str("future".to_string())), &Value::Bool(true)))));
let mut isHistoricalEndpoint: bool = is_true(&(!is_equal(&method, &Value::Null))) && is_true(&(is_greater_than_or_equal(&get_index_of(&method, &Value::Str("GetHistoricalTrades".to_string())), &Value::Int(0))));
let mut maxLimitForContractHistorical: Value = ternary(is_true(&isHistoricalEndpoint), Value::Int(500), Value::Int(1000));
add_element_to_object(&mut request, &Value::Str("limit".to_string()), ternary(is_true(&(is_equal(&isFutureOrSwap, &Value::Bool(true)))), crate::runtime::Math::min(&limit, &maxLimitForContractHistorical), limit.clone())); // default = 500, maximum = 1000
}
params = self.omit(params.clone(), Value::List(vec![Value::Str("until".to_string()), Value::Str("fetchTradesMethod".to_string())]), &[]);
if is_equal(&method, &Value::Null) {
if is_equal(&get_value(&market, &Value::Str("option".to_string())), &Value::Bool(true)) {
method = Value::Str("eapiPublicGetTrades".to_string());
} else if is_equal(&get_value(&market, &Value::Str("linear".to_string())), &Value::Bool(true)) {
method = Value::Str("fapiPublicGetAggTrades".to_string());
} else if is_equal(&get_value(&market, &Value::Str("inverse".to_string())), &Value::Bool(true)) {
method = Value::Str("dapiPublicGetAggTrades".to_string());
} else {
method = Value::Str("publicGetAggTrades".to_string());
}
}
let mut response: Value = Value::Null;
if is_equal(&method, &Value::Str("publicGetAggTrades".to_string())) {
let __ws_arg_40 = self.extend(request.clone(), &[params.clone()]);
response = self.public_get_agg_trades(&[__ws_arg_40]).await;
} else if is_equal(&method, &Value::Str("publicGetTrades".to_string())) {
let __ws_arg_41 = self.extend(request.clone(), &[params.clone()]);
response = self.public_get_trades(&[__ws_arg_41]).await;
} else if is_equal(&method, &Value::Str("publicGetHistoricalTrades".to_string())) {
let __ws_arg_42 = self.extend(request.clone(), &[params.clone()]);
response = self.public_get_historical_trades(&[__ws_arg_42]).await;
} else if is_equal(&method, &Value::Str("fapiPublicGetAggTrades".to_string())) {
let __ws_arg_43 = self.extend(request.clone(), &[params.clone()]);
response = self.fapi_public_get_agg_trades(&[__ws_arg_43]).await;
} else if is_equal(&method, &Value::Str("fapiPublicGetTrades".to_string())) {
let __ws_arg_44 = self.extend(request.clone(), &[params.clone()]);
response = self.fapi_public_get_trades(&[__ws_arg_44]).await;
} else if is_equal(&method, &Value::Str("fapiPublicGetHistoricalTrades".to_string())) {
let __ws_arg_45 = self.extend(request.clone(), &[params.clone()]);
response = self.fapi_public_get_historical_trades(&[__ws_arg_45]).await;
} else if is_equal(&method, &Value::Str("dapiPublicGetAggTrades".to_string())) {
let __ws_arg_46 = self.extend(request.clone(), &[params.clone()]);
response = self.dapi_public_get_agg_trades(&[__ws_arg_46]).await;
} else if is_equal(&method, &Value::Str("dapiPublicGetTrades".to_string())) {
let __ws_arg_47 = self.extend(request.clone(), &[params.clone()]);
response = self.dapi_public_get_trades(&[__ws_arg_47]).await;
} else if is_equal(&method, &Value::Str("dapiPublicGetHistoricalTrades".to_string())) {
let __ws_arg_48 = self.extend(request.clone(), &[params.clone()]);
response = self.dapi_public_get_historical_trades(&[__ws_arg_48]).await;
} else if is_equal(&method, &Value::Str("eapiPublicGetTrades".to_string())) {
let __ws_arg_49 = self.extend(request.clone(), &[params.clone()]);
response = self.eapi_public_get_trades(&[__ws_arg_49]).await;
} else if is_equal(&method, &Value::Str("eapiPublicGetHistoricalTrades".to_string())) {
let __ws_arg_50 = self.extend(request.clone(), &[params.clone()]);
response = self.eapi_public_get_historical_trades(&[__ws_arg_50]).await;
} else {
panic!("{}", crate::exchange_errors::not_supported(add(&self.id, &Value::Str(" fetchTrades() does not support this method".to_string()))));
}
//
// Caveats:
// - default limit (500) applies only if no other parameters set, trades up
// to the maximum limit may be returned to satisfy other parameters
// - if both limit and time window is set and time window contains more
// trades than the limit then the last trades from the window are returned
// - "tradeId" accepted and returned by this method is "aggregate" trade id
// which is different from actual trade id
// - setting both fromId and time window results in error
//
// aggregate trades
//
// [
// {
// "a": 26129, // Aggregate tradeId
// "p": "0.01633102", // Price
// "q": "4.70443515", // Quantity
// "f": 27781, // First tradeId
// "l": 27781, // Last tradeId
// "T": 1498793709153, // Timestamp
// "m": true, // Was the buyer the maker?
// "M": true // Was the trade the best price match?
// }
// ]
//
// inverse (swap & future)
//
// [
// {
// "a": "269772814",
// "p": "25864.1",
// "q": "3",
// "f": "662149354",
// "l": "662149355",
// "T": "1694209776022",
// "m": false,
// },
// ]
//
// recent public trades and historical public trades
//
// [
// {
// "id": 28457,
// "price": "4.00000100",
// "qty": "12.00000000",
// "time": 1499865549590,
// "isBuyerMaker": true,
// "isBestMatch": true
// }
// ]
//
// options (eapi)
//
// [
// {
// "id": 1,
// "symbol": "ETH-230216-1500-C",
// "price": "35.5",
// "qty": "0.03",
// "quoteQty": "1.065",
// "side": 1,
// "time": 1676366446072
// },
// ]
//
let mut responseList: Value = Value::List(vec![]);
if !is_equal(&response, &Value::Null) {
responseList = self.to_array(response.clone());
}
return self.parse_trades(responseList.clone(), &[market.clone(), since.clone(), limit.clone()]);
Value::Null
}
/*
* @method
* @name binance#editSpotOrder
* @ignore
* @description edit a trade order
* @see https://developers.binance.com/docs/binance-spot-api-docs/rest-api/trading-endpoints#cancel-an-existing-order-and-send-a-new-order-trade
* @param {string} id cancel order id
* @param {string} symbol unified symbol of the market to create an order in
* @param {string} type 'market' or 'limit' or 'STOP_LOSS' or 'STOP_LOSS_LIMIT' or 'TAKE_PROFIT' or 'TAKE_PROFIT_LIMIT' or 'STOP'
* @param {string} side 'buy' or 'sell'
* @param {float} amount how much of currency you want to trade in units of base currency
* @param {float} [price] the price at which the order is to be fulfilled, in units of the quote currency, ignored in market orders
* @param {object} [params] extra parameters specific to the exchange API endpoint
* @param {string} [params.marginMode] 'cross' or 'isolated', for spot margin trading
* @returns {object} an [order structure]{@link https://docs.ccxt.com/?id=order-structure}
*/
pub async fn edit_spot_order(&mut self, mut id: Value, mut symbol: Value, mut type_var: Value, mut side: Value, mut amount: Value, optional_args: &[Value]) -> Value {
let mut price = get_arg(optional_args, 0, Value::Null);
let mut params = get_arg(optional_args, 1, Value::Map({
let mut m = indexmap::IndexMap::new();
m
}));
if is_equal(&self.markets, &Value::Null) {
self.load_markets(&[]).await;
}
let mut market: Value = self.market(symbol.clone());
if !is_equal(&get_value(&market, &Value::Str("spot".to_string())), &Value::Bool(true)) {
panic!("{}", crate::exchange_errors::not_supported(add(&add(&add(&self.id, &Value::Str(" editSpotOrder() does not support ".to_string())), &get_value(&market, &Value::Str("type".to_string()))), &Value::Str(" orders".to_string()))));
}
let mut payload: Value = self.edit_spot_order_request(id.clone(), symbol.clone(), type_var.clone(), side.clone(), amount.clone(), &[price.clone(), params.clone()]);
let mut response: Value = self.private_post_order_cancel_replace(&[payload.clone()]).await;
//
// spot
//
// {
// "cancelResult": "SUCCESS",
// "newOrderResult": "SUCCESS",
// "cancelResponse": {
// "symbol": "BTCUSDT",
// "origClientOrderId": "web_3f6286480b194b079870ac75fb6978b7",
// "orderId": 16383156620,
// "orderListId": -1,
// "clientOrderId": "Azt6foVTTgHPNhqBf41TTt",
// "price": "14000.00000000",
// "origQty": "0.00110000",
// "executedQty": "0.00000000",
// "cummulativeQuoteQty": "0.00000000",
// "status": "CANCELED",
// "timeInForce": "GTC",
// "type": "LIMIT",
// "side": "BUY"
// },
// "newOrderResponse": {
// "symbol": "BTCUSDT",
// "orderId": 16383176297,
// "orderListId": -1,
// "clientOrderId": "x-TKT5PX2F22ecb58eb9074fb1be018c",
// "transactTime": 1670891847932,
// "price": "13500.00000000",
// "origQty": "0.00085000",
// "executedQty": "0.00000000",
// "cummulativeQuoteQty": "0.00000000",
// "status": "NEW",
// "timeInForce": "GTC",
// "type": "LIMIT",
// "side": "BUY",
// "fills": []
// }
// }
//
let mut data: Value = self.safe_dict_k(response.clone(), "newOrderResponse", &[Value::Map({
let mut m = indexmap::IndexMap::new();
m
})]);
return self.parse_order(data.clone(), &[market.clone()]);
Value::Null
}
pub fn edit_spot_order_request(&self, mut id: Value, mut symbol: Value, mut type_var: Value, mut side: Value, mut amount: Value, optional_args: &[Value]) -> Value {
let mut price = get_arg(optional_args, 0, Value::Null);
let mut params = get_arg(optional_args, 1, Value::Map({
let mut m = indexmap::IndexMap::new();
m
}));
if is_equal(&type_var, &Value::Null) {
panic!("{}", crate::exchange_errors::arguments_required(add(&self.id, &Value::Str(" requires a type argument".to_string()))));
}
if is_equal(&side, &Value::Null) {
panic!("{}", crate::exchange_errors::arguments_required(add(&self.id, &Value::Str(" requires a side argument".to_string()))));
}
/*
* @method
* @ignore
* @name binance#editSpotOrderRequest
* @description helper function to build request for editSpotOrder
* @param {string} id order id to be edited
* @param {string} symbol unified symbol of the market to create an order in
* @param {string} type 'market' or 'limit' or 'STOP_LOSS' or 'STOP_LOSS_LIMIT' or 'TAKE_PROFIT' or 'TAKE_PROFIT_LIMIT' or 'STOP'
* @param {string} side 'buy' or 'sell'
* @param {float} amount how much of currency you want to trade in units of base currency
* @param {float} [price] the price at which the order is to be fulfilled, in units of the quote currency, ignored in market orders
* @param {object} params extra parameters specific to the exchange API endpoint
* @param {string} [params.marginMode] 'cross' or 'isolated', for spot margin trading
* @returns {object} request to be sent to the exchange
*/
let mut market: Value = self.market(symbol.clone());
let mut clientOrderId: Value = self.safe_string_n(params.clone(), Value::List(vec![Value::Str("newClientOrderId".to_string()), Value::Str("clientOrderId".to_string()), Value::Str("origClientOrderId".to_string())]), &[]);
if is_equal(&side, &Value::Null) {
panic!("{}", crate::exchange_errors::arguments_required(add(&self.id, &Value::Str(" editSpotOrderRequest() requires a side argument".to_string()))));
}
let mut request: Value = Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("symbol".to_string(), get_value(&market, &Value::Str("id".to_string())));
m.insert("side".to_string(), to_upper(&side));
m
});
let mut initialUppercaseType: Value = to_upper(&type_var);
let mut uppercaseType: Value = initialUppercaseType.clone();
let mut postOnly: Value = self.is_post_only(Value::Bool(is_equal(&initialUppercaseType, &Value::Str("MARKET".to_string()))), Value::Bool(is_equal(&initialUppercaseType, &Value::Str("LIMIT_MAKER".to_string()))), &[params.clone()]);
if is_true(&postOnly) {
uppercaseType = Value::Str("LIMIT_MAKER".to_string());
}
let mut triggerPrice: Value = self.safe_number2(params.clone(), Value::Str("stopPrice".to_string()), Value::Str("triggerPrice".to_string()), &[]);
if !is_equal(&triggerPrice, &Value::Null) {
if is_equal(&uppercaseType, &Value::Str("MARKET".to_string())) {
uppercaseType = Value::Str("STOP_LOSS".to_string());
} else if is_equal(&uppercaseType, &Value::Str("LIMIT".to_string())) {
uppercaseType = Value::Str("STOP_LOSS_LIMIT".to_string());
}
}
add_element_to_object(&mut request, &Value::Str("type".to_string()), uppercaseType.clone());
let mut validOrderTypes: Value = self.safe_list(get_value(&market, &Value::Str("info".to_string())), Value::Str("orderTypes".to_string()), &[Value::List(vec![])]);
if !is_true(&self.in_array(uppercaseType.clone(), validOrderTypes.clone())) {
if !is_equal(&initialUppercaseType, &uppercaseType) {
panic!("{}", crate::exchange_errors::invalid_order(add(&add(&add(&add(&add(&self.id, &Value::Str(" triggerPrice parameter is not allowed for ".to_string())), &symbol), &Value::Str(" ".to_string())), &type_var), &Value::Str(" orders".to_string()))));
} else {
panic!("{}", crate::exchange_errors::invalid_order(add(&add(&add(&add(&add(&self.id, &Value::Str(" ".to_string())), &type_var), &Value::Str(" is not a valid order type for the ".to_string())), &symbol), &Value::Str(" market".to_string()))));
}
}
if is_equal(&clientOrderId, &Value::Null) {
let mut broker: Value = self.safe_dict_k(self.options.clone(), "broker", &[]);
if !is_equal(&broker, &Value::Null) {
let mut brokerId: Value = self.safe_string_k(broker.clone(), "spot", &[]);
if !is_equal(&brokerId, &Value::Null) {
add_element_to_object(&mut request, &Value::Str("newClientOrderId".to_string()), add(&brokerId, &self.uuid22(&[])));
}
}
} else {
add_element_to_object(&mut request, &Value::Str("newClientOrderId".to_string()), clientOrderId.clone());
}
add_element_to_object(&mut request, &Value::Str("newOrderRespType".to_string()), self.safe_value(get_value(&self.options, &Value::Str("newOrderRespType".to_string())), type_var.clone(), &[Value::Str("RESULT".to_string())])); // 'ACK' for order id, 'RESULT' for full order or 'FULL' for order with fills
let mut timeInForceIsRequired: bool = false;
let mut priceIsRequired: bool = false;
let mut triggerPriceIsRequired: bool = false;
let mut quantityIsRequired: bool = false;
if is_equal(&uppercaseType, &Value::Str("MARKET".to_string())) {
let mut quoteOrderQty: Value = self.handle_option(Value::Str("createOrder".to_string()), Value::Str("quoteOrderQty".to_string()), &[Value::Bool(true)]);
if is_equal("eOrderQty, &Value::Bool(true)) {
let mut quoteOrderQtyNew: Value = self.safe_value2(params.clone(), Value::Str("quoteOrderQty".to_string()), Value::Str("cost".to_string()), &[]);
let mut precision: Value = get_value(&get_value(&market, &Value::Str("precision".to_string())), &Value::Str("price".to_string()));
if !is_equal("eOrderQtyNew, &Value::Null) {
add_element_to_object(&mut request, &Value::Str("quoteOrderQty".to_string()), self.decimal_to_precision(quoteOrderQtyNew.clone(), Value::Int(crate::runtime::TRUNCATE), precision.clone(), &[self.precisionMode.clone()]));
} else if !is_equal(&price, &Value::Null) {
let mut amountString: Value = self.number_to_string(amount.clone());
let mut priceString: Value = self.number_to_string(price.clone());
let mut quoteOrderQuantity: Value = crate::precise::Precise::stringMul(&amountString, &priceString);
add_element_to_object(&mut request, &Value::Str("quoteOrderQty".to_string()), self.decimal_to_precision(quoteOrderQuantity.clone(), Value::Int(crate::runtime::TRUNCATE), precision.clone(), &[self.precisionMode.clone()]));
} else {
quantityIsRequired = true;
}
} else {
quantityIsRequired = true;
}
} else if is_equal(&uppercaseType, &Value::Str("LIMIT".to_string())) {
priceIsRequired = true;
timeInForceIsRequired = true;
quantityIsRequired = true;
} else if is_true(&(is_equal(&uppercaseType, &Value::Str("STOP_LOSS".to_string())))) || is_true(&(is_equal(&uppercaseType, &Value::Str("TAKE_PROFIT".to_string())))) {
triggerPriceIsRequired = true;
quantityIsRequired = true;
} else if is_true(&(is_equal(&uppercaseType, &Value::Str("STOP_LOSS_LIMIT".to_string())))) || is_true(&(is_equal(&uppercaseType, &Value::Str("TAKE_PROFIT_LIMIT".to_string())))) {
quantityIsRequired = true;
triggerPriceIsRequired = true;
priceIsRequired = true;
timeInForceIsRequired = true;
} else if is_equal(&uppercaseType, &Value::Str("LIMIT_MAKER".to_string())) {
priceIsRequired = true;
quantityIsRequired = true;
}
if is_true(&quantityIsRequired) {
add_element_to_object(&mut request, &Value::Str("quantity".to_string()), self.amount_to_precision(symbol.clone(), amount.clone()));
}
if is_true(&priceIsRequired) {
if is_equal(&price, &Value::Null) {
panic!("{}", crate::exchange_errors::invalid_order(add(&add(&add(&self.id, &Value::Str(" editOrder() requires a price argument for a ".to_string())), &type_var), &Value::Str(" order".to_string()))));
}
add_element_to_object(&mut request, &Value::Str("price".to_string()), self.price_to_precision(symbol.clone(), price.clone()));
}
if is_true(&timeInForceIsRequired) && is_true(&(is_equal(&self.safe_string_k(params.clone(), "timeInForce", &[]), &Value::Null))) {
add_element_to_object(&mut request, &Value::Str("timeInForce".to_string()), self.handle_option(Value::Str("createOrder".to_string()), Value::Str("timeInForce".to_string()), &[])); // 'GTC' = Good To Cancel (default), 'IOC' = Immediate Or Cancel
}
if is_true(&triggerPriceIsRequired) {
if is_equal(&triggerPrice, &Value::Null) {
panic!("{}", crate::exchange_errors::invalid_order(add(&add(&add(&self.id, &Value::Str(" editOrder() requires a triggerPrice extra param for a ".to_string())), &type_var), &Value::Str(" order".to_string()))));
} else {
add_element_to_object(&mut request, &Value::Str("stopPrice".to_string()), self.price_to_precision(symbol.clone(), triggerPrice.clone()));
}
}
add_element_to_object(&mut request, &Value::Str("cancelReplaceMode".to_string()), Value::Str("STOP_ON_FAILURE".to_string())); // If the cancel request fails, the new order placement will not be attempted.
let mut cancelId: Value = self.safe_string2(params.clone(), Value::Str("cancelNewClientOrderId".to_string()), Value::Str("cancelOrigClientOrderId".to_string()), &[]);
if is_equal(&cancelId, &Value::Null) {
add_element_to_object(&mut request, &Value::Str("cancelOrderId".to_string()), id.clone()); // user can provide either cancelOrderId, cancelOrigClientOrderId or cancelOrigClientOrderId
}
// remove timeInForce from params because PO is only used by this.isPostOnly and it's not a valid value for Binance
if is_equal(&self.safe_string_k(params.clone(), "timeInForce", &[]), &Value::Str("PO".to_string())) {
params = self.omit(params.clone(), Value::List(vec![Value::Str("timeInForce".to_string())]), &[]);
}
params = self.omit(params.clone(), Value::List(vec![Value::Str("quoteOrderQty".to_string()), Value::Str("cost".to_string()), Value::Str("stopPrice".to_string()), Value::Str("newClientOrderId".to_string()), Value::Str("clientOrderId".to_string()), Value::Str("postOnly".to_string())]), &[]);
return self.extend(request.clone(), &[params.clone()]);
Value::Null
}
pub fn edit_contract_order_request(&self, mut id: Value, mut symbol: Value, mut type_var: Value, mut side: Value, mut amount: Value, optional_args: &[Value]) -> Value {
let mut price = get_arg(optional_args, 0, Value::Null);
let mut params = get_arg(optional_args, 1, Value::Map({
let mut m = indexmap::IndexMap::new();
m
}));
if is_equal(&type_var, &Value::Null) {
panic!("{}", crate::exchange_errors::arguments_required(add(&self.id, &Value::Str(" requires a type argument".to_string()))));
}
if is_equal(&side, &Value::Null) {
panic!("{}", crate::exchange_errors::arguments_required(add(&self.id, &Value::Str(" requires a side argument".to_string()))));
}
if is_true(&(is_equal(&price, &Value::Null))) && !is_true(&(Value::Bool(in_op(¶ms, &Value::Str("priceMatch".to_string()))))) {
panic!("{}", crate::exchange_errors::arguments_required(add(&self.id, &Value::Str(" editOrder() and editOrderWs() require a price argument for swap orders".to_string()))));
}
let mut market: Value = self.market(symbol.clone());
if !is_equal(&get_value(&market, &Value::Str("contract".to_string())), &Value::Bool(true)) {
panic!("{}", crate::exchange_errors::not_supported(add(&add(&add(&self.id, &Value::Str(" editContractOrder() does not support ".to_string())), &get_value(&market, &Value::Str("type".to_string()))), &Value::Str(" orders".to_string()))));
}
if is_equal(&side, &Value::Null) {
panic!("{}", crate::exchange_errors::arguments_required(add(&self.id, &Value::Str(" editContractOrder() requires a side argument".to_string()))));
}
let mut request: Value = Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("symbol".to_string(), get_value(&market, &Value::Str("id".to_string())));
m.insert("side".to_string(), to_upper(&side));
m.insert("orderId".to_string(), id.clone());
m.insert("quantity".to_string(), self.amount_to_precision(symbol.clone(), amount.clone()));
m
});
let mut clientOrderId: Value = self.safe_string_n(params.clone(), Value::List(vec![Value::Str("newClientOrderId".to_string()), Value::Str("clientOrderId".to_string()), Value::Str("origClientOrderId".to_string())]), &[]);
if !is_equal(&price, &Value::Null) {
add_element_to_object(&mut request, &Value::Str("price".to_string()), self.price_to_precision(symbol.clone(), price.clone()));
}
if !is_equal(&clientOrderId, &Value::Null) {
add_element_to_object(&mut request, &Value::Str("origClientOrderId".to_string()), clientOrderId.clone());
}
params = self.omit(params.clone(), Value::List(vec![Value::Str("clientOrderId".to_string()), Value::Str("newClientOrderId".to_string())]), &[]);
return request;
Value::Null
}
/*
* @method
* @name binance#editContractOrder
* @description edit a trade order
* @see https://developers.binance.com/docs/derivatives/usds-margined-futures/trade/rest-api/Modify-Order
* @see https://developers.binance.com/docs/derivatives/coin-margined-futures/trade/rest-api/Modify-Order
* @see https://developers.binance.com/docs/derivatives/portfolio-margin/trade/Modify-UM-Order
* @see https://developers.binance.com/docs/derivatives/portfolio-margin/trade/Modify-CM-Order
* @param {string} id cancel order id
* @param {string} symbol unified symbol of the market to create an order in
* @param {string} type 'market' or 'limit'
* @param {string} side 'buy' or 'sell'
* @param {float} amount how much of currency you want to trade in units of base currency
* @param {float} [price] the price at which the order is to be fulfilled, in units of the quote currency, ignored in market orders
* @param {object} [params] extra parameters specific to the exchange API endpoint
* @param {boolean} [params.portfolioMargin] set to true if you would like to edit an order in a portfolio margin account
* @returns {object} an [order structure]{@link https://docs.ccxt.com/?id=order-structure}
*/
pub async fn edit_contract_order(&mut self, mut id: Value, mut symbol: Value, mut type_var: Value, mut side: Value, mut amount: Value, optional_args: &[Value]) -> Value {
let mut price = get_arg(optional_args, 0, Value::Null);
let mut params = get_arg(optional_args, 1, Value::Map({
let mut m = indexmap::IndexMap::new();
m
}));
if is_equal(&self.markets, &Value::Null) {
self.load_markets(&[]).await;
}
let mut market: Value = self.market(symbol.clone());
let mut isPortfolioMargin: Value = Value::Null;
{ let __destr_tmp = self.handle_option_and_params2(params.clone(), Value::Str("editContractOrder".to_string()), Value::Str("papi".to_string()), Value::Str("portfolioMargin".to_string()), &[Value::Bool(false)]); isPortfolioMargin = get_value(&__destr_tmp, &Value::Int(0)); params = get_value(&__destr_tmp, &Value::Int(1)); }
let mut request: Value = self.edit_contract_order_request(id.clone(), symbol.clone(), type_var.clone(), side.clone(), amount.clone(), &[price.clone(), params.clone()]);
let mut response: Value = Value::Null;
if is_equal(&get_value(&market, &Value::Str("linear".to_string())), &Value::Bool(true)) {
if is_true(&isPortfolioMargin) {
let __ws_arg_51 = self.extend(request.clone(), &[params.clone()]);
response = self.papi_put_um_order(&[__ws_arg_51]).await;
} else {
let __ws_arg_52 = self.extend(request.clone(), &[params.clone()]);
response = self.fapi_private_put_order(&[__ws_arg_52]).await;
}
} else if is_equal(&get_value(&market, &Value::Str("inverse".to_string())), &Value::Bool(true)) {
if is_true(&isPortfolioMargin) {
let __ws_arg_53 = self.extend(request.clone(), &[params.clone()]);
response = self.papi_put_cm_order(&[__ws_arg_53]).await;
} else {
let __ws_arg_54 = self.extend(request.clone(), &[params.clone()]);
response = self.dapi_private_put_order(&[__ws_arg_54]).await;
}
}
//
// swap and future
//
// {
// "orderId": 151007482392,
// "symbol": "BTCUSDT",
// "status": "NEW",
// "clientOrderId": "web_pCCGp9AIHjziKLlpGpXI",
// "price": "25000",
// "avgPrice": "0.00000",
// "origQty": "0.001",
// "executedQty": "0",
// "cumQty": "0",
// "cumQuote": "0",
// "timeInForce": "GTC",
// "type": "LIMIT",
// "reduceOnly": false,
// "closePosition": false,
// "side": "BUY",
// "positionSide": "BOTH",
// "stopPrice": "0",
// "workingType": "CONTRACT_PRICE",
// "priceProtect": false,
// "origType": "LIMIT",
// "updateTime": 1684300587845
// }
//
if is_equal(&response, &Value::Null) {
panic!("{}", crate::exchange_errors::null_response(add(&self.id, &Value::Str(" parseOrder() returned empty response".to_string()))));
}
return self.parse_order(response.clone(), &[market.clone()]);
Value::Null
}
/*
* @method
* @name binance#editOrder
* @description edit a trade order
* @see https://developers.binance.com/docs/binance-spot-api-docs/rest-api/trading-endpoints#cancel-an-existing-order-and-send-a-new-order-trade
* @see https://developers.binance.com/docs/derivatives/usds-margined-futures/trade/rest-api/Modify-Order
* @see https://developers.binance.com/docs/derivatives/coin-margined-futures/trade/rest-api/Modify-Order
* @param {string} id cancel order id
* @param {string} symbol unified symbol of the market to create an order in
* @param {string} type 'market' or 'limit'
* @param {string} side 'buy' or 'sell'
* @param {float} amount how much of currency you want to trade in units of base currency
* @param {float} [price] the price at which the order is to be fulfilled, in units of the quote currency, ignored in market orders
* @param {object} [params] extra parameters specific to the exchange API endpoint
* @returns {object} an [order structure]{@link https://docs.ccxt.com/?id=order-structure}
*/
pub async fn edit_order(&mut self, mut id: Value, mut symbol: Value, mut type_var: Value, mut side: Value, optional_args: &[Value]) -> Value {
let mut amount = get_arg(optional_args, 0, Value::Null);
let mut price = get_arg(optional_args, 1, Value::Null);
let mut params = get_arg(optional_args, 2, Value::Map({
let mut m = indexmap::IndexMap::new();
m
}));
if is_equal(&self.markets, &Value::Null) {
self.load_markets(&[]).await;
}
let mut market: Value = self.market(symbol.clone());
if is_equal(&get_value(&market, &Value::Str("option".to_string())), &Value::Bool(true)) {
panic!("{}", crate::exchange_errors::not_supported(add(&add(&add(&self.id, &Value::Str(" editOrder() does not support ".to_string())), &get_value(&market, &Value::Str("type".to_string()))), &Value::Str(" orders".to_string()))));
}
if is_equal(&get_value(&market, &Value::Str("spot".to_string())), &Value::Bool(true)) {
return self.edit_spot_order(id.clone(), symbol.clone(), type_var.clone(), side.clone(), amount.clone(), &[price.clone(), params.clone()]).await;
} else {
return self.edit_contract_order(id.clone(), symbol.clone(), type_var.clone(), side.clone(), amount.clone(), &[price.clone(), params.clone()]).await;
}
Value::Null
}
/*
* @method
* @name binance#editOrders
* @description edit a list of trade orders
* @see https://developers.binance.com/docs/derivatives/usds-margined-futures/trade/rest-api/Modify-Multiple-Orders
* @see https://developers.binance.com/docs/derivatives/coin-margined-futures/trade/rest-api/Modify-Multiple-Orders
* @param {Array} orders list of orders to create, each object should contain the parameters required by createOrder, namely symbol, type, side, amount, price and params
* @param {object} [params] extra parameters specific to the exchange API endpoint
* @returns {object} an [order structure]{@link https://docs.ccxt.com/?id=order-structure}
*/
pub async fn edit_orders(&mut self, mut orders: Value, optional_args: &[Value]) -> Value {
let mut params = get_arg(optional_args, 0, Value::Map({
let mut m = indexmap::IndexMap::new();
m
}));
if is_equal(&self.markets, &Value::Null) {
self.load_markets(&[]).await;
}
let mut ordersRequests: Value = Value::List(vec![]);
let mut orderSymbols: Value = Value::List(vec![]);
{
let mut i: Value = Value::Int(0);
let mut __for_first_262: bool = true;
while { if !__for_first_262 { i = add(&i, &Value::Int(1)); } __for_first_262 = false; is_less_than(&i, &get_array_length(&orders)) } {
let mut rawOrder: Value = get_value(&orders, &i);
let mut rawOrder: Value = get_value(&orders, &i);
let mut marketId: Value = self.safe_string_k(rawOrder.clone(), "symbol", &[]);
append_to_array(&mut orderSymbols, marketId.clone());
let mut id: Value = self.safe_string_k(rawOrder.clone(), "id", &[]);
let mut type_var: Value = self.safe_string_k(rawOrder.clone(), "type", &[]);
let mut side: Value = self.safe_string_k(rawOrder.clone(), "side", &[]);
let mut amount: Value = self.safe_value_k(rawOrder.clone(), "amount", &[]);
let mut price: Value = self.safe_value_k(rawOrder.clone(), "price", &[]);
let mut orderParams: Value = self.safe_dict_k(rawOrder.clone(), "params", &[Value::Map({
let mut m = indexmap::IndexMap::new();
m
})]);
let mut isPortfolioMargin: Value = Value::Null;
{ let __destr_tmp = self.handle_option_and_params2(orderParams.clone(), Value::Str("editOrders".to_string()), Value::Str("papi".to_string()), Value::Str("portfolioMargin".to_string()), &[Value::Bool(false)]); isPortfolioMargin = get_value(&__destr_tmp, &Value::Int(0)); orderParams = get_value(&__destr_tmp, &Value::Int(1)); }
if is_true(&isPortfolioMargin) {
panic!("{}", crate::exchange_errors::not_supported(add(&self.id, &Value::Str(" editOrders() does not support portfolio margin orders".to_string()))));
}
let mut orderRequest: Value = self.edit_contract_order_request(id.clone(), marketId.clone(), type_var.clone(), side.clone(), amount.clone(), &[price.clone(), orderParams.clone()]);
append_to_array(&mut ordersRequests, orderRequest.clone());
}
}
orderSymbols = self.market_symbols(&[orderSymbols.clone(), Value::Null, Value::Bool(false), Value::Bool(true), Value::Bool(true)]);
let mut market: Value = self.market(get_value(&orderSymbols, &Value::Int(0)));
if is_true(&(is_equal(&get_value(&market, &Value::Str("spot".to_string())), &Value::Bool(true)))) || is_true(&(is_equal(&get_value(&market, &Value::Str("option".to_string())), &Value::Bool(true)))) {
panic!("{}", crate::exchange_errors::not_supported(add(&add(&add(&self.id, &Value::Str(" editOrders() does not support ".to_string())), &get_value(&market, &Value::Str("type".to_string()))), &Value::Str(" orders".to_string()))));
}
let mut response: Value = Value::Null;
let mut request: Value = Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("batchOrders".to_string(), ordersRequests.clone());
m
});
request = self.extend(request.clone(), &[params.clone()]);
if is_equal(&get_value(&market, &Value::Str("linear".to_string())), &Value::Bool(true)) {
response = self.fapi_private_put_batch_orders(&[request.clone()]).await;
} else if is_equal(&get_value(&market, &Value::Str("inverse".to_string())), &Value::Bool(true)) {
response = self.dapi_private_put_batch_orders(&[request.clone()]).await;
}
return self.parse_orders(response.clone(), &[]);
Value::Null
}
pub fn parse_order_status(&self, mut status: Value) -> Value {
let mut statuses: Value = Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("NEW".to_string(), Value::Str("open".to_string()));
m.insert("PARTIALLY_FILLED".to_string(), Value::Str("open".to_string()));
m.insert("ACCEPTED".to_string(), Value::Str("open".to_string()));
m.insert("TRIGGERING".to_string(), Value::Str("open".to_string()));
m.insert("FILLED".to_string(), Value::Str("closed".to_string()));
m.insert("TRIGGERED".to_string(), Value::Str("closed".to_string()));
m.insert("FINISHED".to_string(), Value::Str("closed".to_string()));
m.insert("CANCELED".to_string(), Value::Str("canceled".to_string()));
m.insert("CANCELLED".to_string(), Value::Str("canceled".to_string()));
m.insert("PENDING_CANCEL".to_string(), Value::Str("canceling".to_string()));
m.insert("REJECTED".to_string(), Value::Str("rejected".to_string()));
m.insert("EXPIRED".to_string(), Value::Str("expired".to_string()));
m.insert("EXPIRED_IN_MATCH".to_string(), Value::Str("expired".to_string()));
m.insert("S".to_string(), Value::Str("ok".to_string()));
m.insert("F".to_string(), Value::Str("rejected".to_string()));
m
});
return self.safe_string(statuses.clone(), status.clone(), &[status.clone()]);
Value::Null
}
pub fn parse_order_type_by_market(&self, mut type_var: Value, mut marketType: Value) -> Value {
let mut types: Value = Value::Map({
let mut m = indexmap::IndexMap::new();
m
});
if is_true(&(!is_equal(&marketType, &Value::Null))) && is_equal(&marketType, &Value::Str("spot".to_string())) {
types = Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("limit_maker".to_string(), Value::Str("limit".to_string()));
m.insert("stop_loss_limit".to_string(), Value::Str("limit".to_string()));
m.insert("stop_loss".to_string(), Value::Str("market".to_string()));
m.insert("take_profit_limit".to_string(), Value::Str("limit".to_string()));
m.insert("take_profit".to_string(), Value::Str("market".to_string()));
m
});
} else {
types = Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("limit_maker".to_string(), Value::Str("limit".to_string()));
m.insert("stop".to_string(), Value::Str("limit".to_string()));
m.insert("stop_market".to_string(), Value::Str("market".to_string()));
m.insert("take_profit".to_string(), Value::Str("limit".to_string()));
m.insert("take_profit_market".to_string(), Value::Str("market".to_string()));
m.insert("trailing_stop_market".to_string(), Value::Str("market".to_string()));
m
});
}
return self.safe_string(types.clone(), type_var.clone(), &[type_var.clone()]);
Value::Null
}
pub fn parse_order(&self, mut order: Value, optional_args: &[Value]) -> Value {
let mut market = get_arg(optional_args, 0, Value::Null);
//
// spot
//
// {
// "symbol": "LTCBTC",
// "orderId": 1,
// "clientOrderId": "myOrder1",
// "price": "0.1",
// "origQty": "1.0",
// "executedQty": "0.0",
// "cummulativeQuoteQty": "0.0",
// "status": "NEW",
// "timeInForce": "GTC",
// "type": "LIMIT",
// "side": "BUY",
// "stopPrice": "0.0",
// "icebergQty": "0.0",
// "time": 1499827319559,
// "updateTime": 1499827319559,
// "isWorking": true
// }
//
// spot: editOrder
//
// {
// "symbol": "BTCUSDT",
// "orderId": 16383176297,
// "orderListId": -1,
// "clientOrderId": "x-TKT5PX2F22ecb58eb9074fb1be018c",
// "transactTime": 1670891847932,
// "price": "13500.00000000",
// "origQty": "0.00085000",
// "executedQty": "0.00000000",
// "cummulativeQuoteQty": "0.00000000",
// "status": "NEW",
// "timeInForce": "GTC",
// "type": "LIMIT",
// "side": "BUY",
// "fills": []
// }
//
// swap and future: editOrder
//
// {
// "orderId": 151007482392,
// "symbol": "BTCUSDT",
// "status": "NEW",
// "clientOrderId": "web_pCCGp9AIHjziKLlpGpXI",
// "price": "25000",
// "avgPrice": "0.00000",
// "origQty": "0.001",
// "executedQty": "0",
// "cumQty": "0",
// "cumQuote": "0",
// "timeInForce": "GTC",
// "type": "LIMIT",
// "reduceOnly": false,
// "closePosition": false,
// "side": "BUY",
// "positionSide": "BOTH",
// "stopPrice": "0",
// "workingType": "CONTRACT_PRICE",
// "priceProtect": false,
// "origType": "LIMIT",
// "updateTime": 1684300587845
// }
//
// futures
//
// {
// "symbol": "BTCUSDT",
// "orderId": 1,
// "clientOrderId": "myOrder1",
// "price": "0.1",
// "origQty": "1.0",
// "executedQty": "1.0",
// "cumQuote": "10.0",
// "status": "NEW",
// "timeInForce": "GTC",
// "type": "LIMIT",
// "side": "BUY",
// "stopPrice": "0.0",
// "updateTime": 1499827319559
// }
//
// createOrder with { "newOrderRespType": "FULL" }
//
// {
// "symbol": "BTCUSDT",
// "orderId": 5403233939,
// "orderListId": -1,
// "clientOrderId": "x-TKT5PX2F5e669e75b6c14f69a2c43e",
// "transactTime": 1617151923742,
// "price": "0.00000000",
// "origQty": "0.00050000",
// "executedQty": "0.00050000",
// "cummulativeQuoteQty": "29.47081500",
// "status": "FILLED",
// "timeInForce": "GTC",
// "type": "MARKET",
// "side": "BUY",
// "fills": [
// {
// "price": "58941.63000000",
// "qty": "0.00050000",
// "commission": "0.00007050",
// "commissionAsset": "BNB",
// "tradeId": 737466631
// }
// ]
// }
//
// delivery
//
// {
// "orderId": "18742727411",
// "symbol": "ETHUSD_PERP",
// "pair": "ETHUSD",
// "status": "FILLED",
// "clientOrderId": "x-xcKtGhcu3e2d1503fdd543b3b02419",
// "price": "0",
// "avgPrice": "4522.14",
// "origQty": "1",
// "executedQty": "1",
// "cumBase": "0.00221134",
// "timeInForce": "GTC",
// "type": "MARKET",
// "reduceOnly": false,
// "closePosition": false,
// "side": "SELL",
// "positionSide": "BOTH",
// "stopPrice": "0",
// "workingType": "CONTRACT_PRICE",
// "priceProtect": false,
// "origType": "MARKET",
// "time": "1636061952660",
// "updateTime": "1636061952660"
// }
//
// option: createOrder, fetchOrder, fetchOpenOrders, fetchOrders
//
// {
// "orderId": 4728833085436977152,
// "symbol": "ETH-230211-1500-C",
// "price": "10.0",
// "quantity": "1.00",
// "executedQty": "0.00",
// "fee": "0",
// "side": "BUY",
// "type": "LIMIT",
// "timeInForce": "GTC",
// "reduceOnly": false,
// "postOnly": false,
// "createTime": 1676083034462,
// "updateTime": 1676083034462,
// "status": "ACCEPTED",
// "avgPrice": "0",
// "source": "API",
// "clientOrderId": "",
// "priceScale": 1,
// "quantityScale": 2,
// "optionSide": "CALL",
// "quoteAsset": "USDT",
// "lastTrade": {"id":"69","time":"1676084430567","price":"24.9","qty":"1.00"},
// "mmp": false
// }
//
// cancelOrders/createOrders
//
// {
// "code": -4005,
// "msg": "Quantity greater than max quantity."
// }
//
// createOrder, fetchOpenOrders, fetchOrder, cancelOrder, fetchOrders: portfolio margin linear swap and future
//
// {
// "symbol": "BTCUSDT",
// "side": "BUY",
// "executedQty": "0.000",
// "orderId": 258649539704,
// "goodTillDate": 0,
// "avgPrice": "0",
// "origQty": "0.010",
// "clientOrderId": "x-xcKtGhcu02573c6f15e544e990057b",
// "positionSide": "BOTH",
// "cumQty": "0.000",
// "updateTime": 1707110415436,
// "type": "LIMIT",
// "reduceOnly": false,
// "price": "35000.00",
// "cumQuote": "0.00000",
// "selfTradePreventionMode": "NONE",
// "timeInForce": "GTC",
// "status": "NEW"
// }
//
// createOrder, fetchOpenOrders, fetchOrder, cancelOrder, fetchOrders: portfolio margin inverse swap and future
//
// {
// "symbol": "ETHUSD_PERP",
// "side": "BUY",
// "cumBase": "0",
// "executedQty": "0",
// "orderId": 71275227732,
// "avgPrice": "0.00",
// "origQty": "1",
// "clientOrderId": "x-xcKtGhcuca5af3acfb5044198c5398",
// "positionSide": "BOTH",
// "cumQty": "0",
// "updateTime": 1707110994334,
// "type": "LIMIT",
// "pair": "ETHUSD",
// "reduceOnly": false,
// "price": "2000",
// "timeInForce": "GTC",
// "status": "NEW"
// }
//
// createOrder, fetchOpenOrders, fetchOpenOrder: portfolio margin linear swap and future conditional
//
// {
// "newClientStrategyId": "x-xcKtGhcu27f109953d6e4dc0974006",
// "strategyId": 3645916,
// "strategyStatus": "NEW",
// "strategyType": "STOP",
// "origQty": "0.010",
// "price": "35000.00",
// "reduceOnly": false,
// "side": "BUY",
// "positionSide": "BOTH",
// "stopPrice": "45000.00",
// "symbol": "BTCUSDT",
// "timeInForce": "GTC",
// "bookTime": 1707112625879,
// "updateTime": 1707112625879,
// "workingType": "CONTRACT_PRICE",
// "priceProtect": false,
// "goodTillDate": 0,
// "selfTradePreventionMode": "NONE"
// }
//
// createOrder, fetchOpenOrders: portfolio margin inverse swap and future conditional
//
// {
// "newClientStrategyId": "x-xcKtGhcuc6b86f053bb34933850739",
// "strategyId": 1423462,
// "strategyStatus": "NEW",
// "strategyType": "STOP",
// "origQty": "1",
// "price": "2000",
// "reduceOnly": false,
// "side": "BUY",
// "positionSide": "BOTH",
// "stopPrice": "3000",
// "symbol": "ETHUSD_PERP",
// "timeInForce": "GTC",
// "bookTime": 1707113098840,
// "updateTime": 1707113098840,
// "workingType": "CONTRACT_PRICE",
// "priceProtect": false
// }
//
// createOrder, cancelAllOrders, cancelOrder: portfolio margin spot margin
//
// {
// "clientOrderId": "x-TKT5PX2Fe9ef29d8346440f0b28b86",
// "cummulativeQuoteQty": "0.00000000",
// "executedQty": "0.00000000",
// "fills": [],
// "orderId": 24684460474,
// "origQty": "0.00100000",
// "price": "35000.00000000",
// "selfTradePreventionMode": "EXPIRE_MAKER",
// "side": "BUY",
// "status": "NEW",
// "symbol": "BTCUSDT",
// "timeInForce": "GTC",
// "transactTime": 1707113538870,
// "type": "LIMIT"
// }
//
// fetchOpenOrders, fetchOrder, fetchOrders: portfolio margin spot margin
//
// {
// "symbol": "BTCUSDT",
// "orderId": 24700763749,
// "clientOrderId": "x-TKT5PX2F6f724c2a4af6425f98c7b6",
// "price": "35000.00000000",
// "origQty": "0.00100000",
// "executedQty": "0.00000000",
// "cummulativeQuoteQty": "0.00000000",
// "status": "NEW",
// "timeInForce": "GTC",
// "type": "LIMIT",
// "side": "BUY",
// "stopPrice": "0.00000000",
// "icebergQty": "0.00000000",
// "time": 1707199187679,
// "updateTime": 1707199187679,
// "isWorking": true,
// "accountId": 200180970,
// "selfTradePreventionMode": "EXPIRE_MAKER",
// "preventedMatchId": null,
// "preventedQuantity": null
// }
//
// cancelOrder: portfolio margin linear and inverse swap conditional
//
// {
// "strategyId": 3733211,
// "newClientStrategyId": "x-xcKtGhcuaf166172ed504cd1bc0396",
// "strategyType": "STOP",
// "strategyStatus": "CANCELED",
// "origQty": "0.010",
// "price": "35000.00",
// "reduceOnly": false,
// "side": "BUY",
// "positionSide": "BOTH",
// "stopPrice": "50000.00", // ignored with trailing orders
// "symbol": "BTCUSDT",
// "timeInForce": "GTC",
// "activatePrice": null, // only return with trailing orders
// "priceRate": null, // only return with trailing orders
// "bookTime": 1707270098774,
// "updateTime": 1707270119261,
// "workingType": "CONTRACT_PRICE",
// "priceProtect": false,
// "goodTillDate": 0,
// "selfTradePreventionMode": "NONE"
// }
//
// fetchOrders: portfolio margin linear and inverse swap conditional
//
// {
// "newClientStrategyId": "x-xcKtGhcuaf166172ed504cd1bc0396",
// "strategyId": 3733211,
// "strategyStatus": "CANCELLED",
// "strategyType": "STOP",
// "origQty": "0.010",
// "price": "35000",
// "orderId": 0,
// "reduceOnly": false,
// "side": "BUY",
// "positionSide": "BOTH",
// "stopPrice": "50000",
// "symbol": "BTCUSDT",
// "type": "LIMIT",
// "bookTime": 1707270098774,
// "updateTime": 1707270119261,
// "timeInForce": "GTC",
// "triggerTime": 0,
// "workingType": "CONTRACT_PRICE",
// "priceProtect": false,
// "goodTillDate": 0,
// "selfTradePreventionMode": "NONE"
// }
//
// fetchOpenOrder: linear swap
//
// {
// "orderId": 3697213934,
// "symbol": "BTCUSDT",
// "status": "NEW",
// "clientOrderId": "x-xcKtGhcufb20c5a7761a4aa09aa156",
// "price": "33000.00",
// "avgPrice": "0.00000",
// "origQty": "0.010",
// "executedQty": "0.000",
// "cumQuote": "0.00000",
// "timeInForce": "GTC",
// "type": "LIMIT",
// "reduceOnly": false,
// "closePosition": false,
// "side": "BUY",
// "positionSide": "BOTH",
// "stopPrice": "0.00",
// "workingType": "CONTRACT_PRICE",
// "priceProtect": false,
// "origType": "LIMIT",
// "priceMatch": "NONE",
// "selfTradePreventionMode": "NONE",
// "goodTillDate": 0,
// "time": 1707892893502,
// "updateTime": 1707892893515
// }
//
// fetchOpenOrder: inverse swap
//
// {
// "orderId": 597368542,
// "symbol": "BTCUSD_PERP",
// "pair": "BTCUSD",
// "status": "NEW",
// "clientOrderId": "x-xcKtGhcubbde7ba93b1a4ab881eff3",
// "price": "35000",
// "avgPrice": "0",
// "origQty": "1",
// "executedQty": "0",
// "cumBase": "0",
// "timeInForce": "GTC",
// "type": "LIMIT",
// "reduceOnly": false,
// "closePosition": false,
// "side": "BUY",
// "positionSide": "BOTH",
// "stopPrice": "0",
// "workingType": "CONTRACT_PRICE",
// "priceProtect": false,
// "origType": "LIMIT",
// "time": 1707893453199,
// "updateTime": 1707893453199
// }
//
// fetchOpenOrder: linear portfolio margin
//
// {
// "orderId": 264895013409,
// "symbol": "BTCUSDT",
// "status": "NEW",
// "clientOrderId": "x-xcKtGhcu6278f1adbdf14f74ab432e",
// "price": "35000",
// "avgPrice": "0",
// "origQty": "0.010",
// "executedQty": "0",
// "cumQuote": "0",
// "timeInForce": "GTC",
// "type": "LIMIT",
// "reduceOnly": false,
// "side": "BUY",
// "positionSide": "LONG",
// "origType": "LIMIT",
// "time": 1707893839364,
// "updateTime": 1707893839364,
// "goodTillDate": 0,
// "selfTradePreventionMode": "NONE"
// }
//
// fetchOpenOrder: inverse portfolio margin
//
// {
// "orderId": 71790316950,
// "symbol": "ETHUSD_PERP",
// "pair": "ETHUSD",
// "status": "NEW",
// "clientOrderId": "x-xcKtGhcuec11030474204ab08ba2c2",
// "price": "2500",
// "avgPrice": "0",
// "origQty": "1",
// "executedQty": "0",
// "cumBase": "0",
// "timeInForce": "GTC",
// "type": "LIMIT",
// "reduceOnly": false,
// "side": "BUY",
// "positionSide": "LONG",
// "origType": "LIMIT",
// "time": 1707894181694,
// "updateTime": 1707894181694
// }
//
// fetchOpenOrder: inverse portfolio margin conditional
//
// {
// "newClientStrategyId": "x-xcKtGhcu2da9c765294b433994ffce",
// "strategyId": 1423501,
// "strategyStatus": "NEW",
// "strategyType": "STOP",
// "origQty": "1",
// "price": "2500",
// "reduceOnly": false,
// "side": "BUY",
// "positionSide": "LONG",
// "stopPrice": "4000",
// "symbol": "ETHUSD_PERP",
// "bookTime": 1707894782679,
// "updateTime": 1707894782679,
// "timeInForce": "GTC",
// "workingType": "CONTRACT_PRICE",
// "priceProtect": false
// }
//
// createOrder, fetchOrder, fetchOpenOrders, fetchOrders, cancelOrderWs, createOrderWs: linear swap conditional order
//
// {
// "algoId": 3358,
// "clientAlgoId": "yT58zmV3DSzMBQxc5tAJXU",
// "algoType": "CONDITIONAL",
// "orderType": "STOP",
// "symbol": "BTCUSDT",
// "side": "BUY",
// "positionSide": "BOTH",
// "timeInForce": "GTC",
// "quantity": "0.002",
// "algoStatus": "NEW",
// "triggerPrice": "100000.00",
// "price": "102000.00",
// "icebergQuantity": null,
// "selfTradePreventionMode": "EXPIRE_MAKER",
// "workingType": "CONTRACT_PRICE",
// "priceMatch": "NONE",
// "closePosition": false,
// "priceProtect": false,
// "reduceOnly": false,
// "createTime": 1763458576201,
// "updateTime": 1763458576201,
// "triggerTime": 0,
// "goodTillDate": 0
// }
//
// cancelOrder: linear swap conditional
//
// {
// "algoId": 3358,
// "clientAlgoId": "yT58zmV3DSzMBQxc5tAJXU",
// "code": "200",
// "msg": "success"
// }
//
// createOrder: tokenized equities
//
// {
// "status": "S",
// "orderId": "edf82072-9f42-4d47-b09e-602c8f1b35c9",
// "clientOrderId": "x-TKT5PX2F989bcdc4d06c430e92b8f4"
// }
//
// cancelOrder: tokenized equities
//
// {
// "orderId": "edf82072-9f42-4d47-b09e-602c8f1b35c9",
// "status": "S"
// }
//
// fetchOpenOrders: tokenized equities
//
// {
// "orderId": "edf82072-9f42-4d47-b09e-602c8f1b35c9",
// "symbol": "AAPL",
// "quoteAsset": "USDC",
// "side": "BUY",
// "orderType": "LIMIT",
// "limitPrice": "290",
// "qty": "0.05",
// "filledQty": "0",
// "filledNotional": "0",
// "totalCost": "14.67",
// "filledPercent": "0",
// "status": "NEW",
// "session": "24H",
// "createdAt": 1785924334509,
// "updatedAt": 1785924334514
// }
//
// fetchOrders: tokenized equities
//
// {
// "orderId": "1ef94d47-0c95-4785-9834-37376312834e",
// "symbol": "AAPL",
// "quote": "USDC",
// "side": "BUY",
// "orderType": "LIMIT",
// "limitPrice": "290",
// "qty": "0.05",
// "filledQty": "0",
// "filledTotal": "0",
// "fee": "0",
// "session": "24H",
// "status": "CANCELED",
// "createdAt": 1785925755841,
// "updatedAt": 1785925792975
// }
//
// fetchOrder: tokenized equities
//
// {
// "orderId": "edf82072-9f42-4d47-b09e-602c8f1b35c9",
// "symbol": "AAPL",
// "quote": "USDC",
// "side": "BUY",
// "orderType": "LIMIT",
// "limitPrice": "290",
// "qty": "0.05",
// "filledQty": "0",
// "filledTotal": "0",
// "session": "24H",
// "status": "NEW",
// "createdAt": 1785924334509,
// "updatedAt": 1785924334514,
// "clientOrderId": "x-TKT5PX2F989bcdc4d06c430e92b8f4",
// "trades": []
// }
//
let mut code: Value = self.safe_string_k(order.clone(), "code", &[]);
if !is_equal(&code, &Value::Null) {
// cancelOrders/createOrders might have a partial success
let mut msg: Value = self.safe_string_k(order.clone(), "msg", &[]);
if is_true(&(!is_equal(&code, &Value::Str("200".to_string())))) && !is_true(&(is_true(&(is_equal(&msg, &Value::Str("success".to_string())))) || is_true(&(is_equal(&msg, &Value::Str("The operation of cancel all open order is done.".to_string())))))) {
return self.safe_order(Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("info".to_string(), order.clone());
m.insert("status".to_string(), Value::Str("rejected".to_string()));
m
}), &[market.clone()]);
}
}
let mut status: Value = self.parse_order_status(self.safe_string_n(order.clone(), Value::List(vec![Value::Str("status".to_string()), Value::Str("strategyStatus".to_string()), Value::Str("algoStatus".to_string())]), &[]));
let mut marketId: Value = self.safe_string_k(order.clone(), "symbol", &[]);
let mut isContract: bool = is_true(&(Value::Bool(in_op(&order, &Value::Str("positionSide".to_string()))))) || is_true(&(Value::Bool(in_op(&order, &Value::Str("cumQuote".to_string())))));
let mut marketType: Value = ternary(is_true(&isContract), Value::Str("contract".to_string()), Value::Str("spot".to_string()));
let mut symbol: Value = self.safe_symbol(marketId.clone(), &[market.clone(), Value::Null, marketType.clone()]);
let mut filled: Value = self.safe_string2(order.clone(), Value::Str("executedQty".to_string()), Value::Str("filledQty".to_string()), &[Value::Str("0".to_string())]);
let mut timestamp: Value = self.safe_integer_n(order.clone(), Value::List(vec![Value::Str("time".to_string()), Value::Str("createTime".to_string()), Value::Str("workingTime".to_string()), Value::Str("transactTime".to_string()), Value::Str("updateTime".to_string()), Value::Str("createdAt".to_string())]), &[]); // order of the keys matters here
let mut lastTradeTimestamp: Value = Value::Null;
if is_true(&(Value::Bool(in_op(&order, &Value::Str("transactTime".to_string()))))) || is_true(&(Value::Bool(in_op(&order, &Value::Str("updateTime".to_string()))))) || is_true(&(Value::Bool(in_op(&order, &Value::Str("updatedAt".to_string()))))) {
let mut timestampValue: Value = self.safe_integer_n(order.clone(), Value::List(vec![Value::Str("updateTime".to_string()), Value::Str("transactTime".to_string()), Value::Str("updatedAt".to_string())]), &[]);
if is_equal(&status, &Value::Str("open".to_string())) {
if is_true(&crate::precise::Precise::stringGt(&filled, &Value::Str("0".to_string()))) {
lastTradeTimestamp = timestampValue.clone();
}
} else if is_equal(&status, &Value::Str("closed".to_string())) {
lastTradeTimestamp = timestampValue.clone();
}
}
let mut lastUpdateTimestamp: Value = self.safe_integer_n(order.clone(), Value::List(vec![Value::Str("transactTime".to_string()), Value::Str("updateTime".to_string()), Value::Str("updatedAt".to_string())]), &[]);
let mut average: Value = self.safe_string2(order.clone(), Value::Str("avgPrice".to_string()), Value::Str("avgFilledPrice".to_string()), &[]);
let mut price: Value = self.safe_string2(order.clone(), Value::Str("price".to_string()), Value::Str("limitPrice".to_string()), &[]);
let mut amount: Value = self.safe_string_n(order.clone(), Value::List(vec![Value::Str("origQty".to_string()), Value::Str("quantity".to_string()), Value::Str("qty".to_string())]), &[]);
// - Spot/Margin market: cummulativeQuoteQty
// - Futures market: cumQuote.
// Note this is not the actual cost, since Binance futures uses leverage to calculate margins.
let mut cost: Value = self.safe_string2(order.clone(), Value::Str("cummulativeQuoteQty".to_string()), Value::Str("cumQuote".to_string()), &[]);
cost = self.safe_string_k(order.clone(), "cumBase", &[cost.clone()]);
let mut type_var: Value = self.safe_string_lower2(order.clone(), Value::Str("type".to_string()), Value::Str("orderType".to_string()), &[]);
let mut side: Value = self.safe_string_lower(order.clone(), Value::Str("side".to_string()), &[]);
let mut fills: Value = self.safe_list2(order.clone(), Value::Str("fills".to_string()), Value::Str("trades".to_string()), &[Value::List(vec![])]);
let mut timeInForce: Value = self.safe_string_k(order.clone(), "timeInForce", &[]);
if is_equal(&timeInForce, &Value::Str("GTX".to_string())) {
// GTX means "Good Till Crossing" and is an equivalent way of saying Post Only
timeInForce = Value::Str("PO".to_string());
}
let mut postOnly: Value = Value::Bool(is_true(&(is_equal(&type_var, &Value::Str("limit_maker".to_string())))) || is_true(&(is_equal(&timeInForce, &Value::Str("PO".to_string())))));
let mut stopPriceString: Value = self.safe_string2(order.clone(), Value::Str("stopPrice".to_string()), Value::Str("triggerPrice".to_string()), &[]);
let mut triggerPrice: Value = self.parse_number(self.omit_zero(stopPriceString.clone()), &[]);
let mut feeCost: Value = self.safe_number_k(order.clone(), "fee", &[]);
let mut fee: Value = Value::Null;
if !is_equal(&feeCost, &Value::Null) {
fee = Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("currency".to_string(), self.safe_string2(order.clone(), Value::Str("quoteAsset".to_string()), Value::Str("quote".to_string()), &[]));
m.insert("cost".to_string(), feeCost.clone());
m.insert("rate".to_string(), Value::Null);
m
});
}
return self.safe_order(Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("info".to_string(), order.clone());
m.insert("id".to_string(), self.safe_string_n(order.clone(), Value::List(vec![Value::Str("strategyId".to_string()), Value::Str("orderId".to_string()), Value::Str("algoId".to_string())]), &[]));
m.insert("clientOrderId".to_string(), self.safe_string_n(order.clone(), Value::List(vec![Value::Str("clientOrderId".to_string()), Value::Str("newClientStrategyId".to_string()), Value::Str("clientAlgoId".to_string())]), &[]));
m.insert("timestamp".to_string(), timestamp.clone());
m.insert("datetime".to_string(), self.iso8601(timestamp.clone()));
m.insert("lastTradeTimestamp".to_string(), lastTradeTimestamp.clone());
m.insert("lastUpdateTimestamp".to_string(), lastUpdateTimestamp.clone());
m.insert("symbol".to_string(), symbol.clone());
m.insert("type".to_string(), self.parse_order_type_by_market(type_var.clone(), marketType.clone()));
m.insert("timeInForce".to_string(), timeInForce.clone());
m.insert("postOnly".to_string(), postOnly.clone());
m.insert("reduceOnly".to_string(), self.safe_bool_k(order.clone(), "reduceOnly", &[]));
m.insert("side".to_string(), side.clone());
m.insert("price".to_string(), price.clone());
m.insert("triggerPrice".to_string(), triggerPrice.clone());
m.insert("amount".to_string(), amount.clone());
m.insert("cost".to_string(), cost.clone());
m.insert("average".to_string(), average.clone());
m.insert("filled".to_string(), filled.clone());
m.insert("remaining".to_string(), Value::Null);
m.insert("status".to_string(), status.clone());
m.insert("fee".to_string(), fee.clone());
m.insert("trades".to_string(), fills.clone());
m
}), &[market.clone()]);
Value::Null
}
/*
* @method
* @name binance#createOrders
* @description *contract only* create a list of trade orders
* @see https://developers.binance.com/docs/derivatives/coin-margined-futures/trade/rest-api/Place-Multiple-Orders
* @see https://developers.binance.com/docs/derivatives/usds-margined-futures/trade/rest-api/Place-Multiple-Orders
* @see https://developers.binance.com/docs/derivatives/option/trade/Place-Multiple-Orders
* @param {Array} orders list of orders to create, each object should contain the parameters required by createOrder, namely symbol, type, side, amount, price and params
* @param {object} [params] extra parameters specific to the exchange API endpoint
* @returns {object} an [order structure]{@link https://docs.ccxt.com/?id=order-structure}
*/
pub async fn create_orders(&mut self, mut orders: Value, optional_args: &[Value]) -> Value {
let mut params = get_arg(optional_args, 0, Value::Map({
let mut m = indexmap::IndexMap::new();
m
}));
if is_equal(&self.markets, &Value::Null) {
self.load_markets(&[]).await;
}
let mut ordersRequests: Value = Value::List(vec![]);
let mut orderSymbols: Value = Value::List(vec![]);
{
let mut i: Value = Value::Int(0);
let mut __for_first_263: bool = true;
while { if !__for_first_263 { i = add(&i, &Value::Int(1)); } __for_first_263 = false; is_less_than(&i, &get_array_length(&orders)) } {
let mut rawOrder: Value = get_value(&orders, &i);
let mut rawOrder: Value = get_value(&orders, &i);
let mut marketId: Value = self.safe_string_k(rawOrder.clone(), "symbol", &[]);
append_to_array(&mut orderSymbols, marketId.clone());
let mut type_var: Value = self.safe_string_k(rawOrder.clone(), "type", &[]);
let mut side: Value = self.safe_string_k(rawOrder.clone(), "side", &[]);
let mut amount: Value = self.safe_value_k(rawOrder.clone(), "amount", &[]);
let mut price: Value = self.safe_value_k(rawOrder.clone(), "price", &[]);
let mut orderParams: Value = self.safe_dict_k(rawOrder.clone(), "params", &[Value::Map({
let mut m = indexmap::IndexMap::new();
m
})]);
let mut orderRequest: Value = self.create_order_request(marketId.clone(), type_var.clone(), side.clone(), amount.clone(), &[price.clone(), orderParams.clone()]);
append_to_array(&mut ordersRequests, orderRequest.clone());
}
}
orderSymbols = self.market_symbols(&[orderSymbols.clone(), Value::Null, Value::Bool(false), Value::Bool(true), Value::Bool(true)]);
let mut market: Value = self.market(get_value(&orderSymbols, &Value::Int(0)));
if is_equal(&get_value(&market, &Value::Str("spot".to_string())), &Value::Bool(true)) {
panic!("{}", crate::exchange_errors::not_supported(add(&add(&add(&self.id, &Value::Str(" createOrders() does not support ".to_string())), &get_value(&market, &Value::Str("type".to_string()))), &Value::Str(" orders".to_string()))));
}
let mut response: Value = Value::Null;
let mut request: Value = Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("batchOrders".to_string(), ordersRequests.clone());
m
});
request = self.extend(request.clone(), &[params.clone()]);
if is_equal(&get_value(&market, &Value::Str("linear".to_string())), &Value::Bool(true)) {
response = self.fapi_private_post_batch_orders(&[request.clone()]).await;
} else if is_equal(&get_value(&market, &Value::Str("option".to_string())), &Value::Bool(true)) {
response = self.eapi_private_post_batch_orders(&[request.clone()]).await;
} else {
response = self.dapi_private_post_batch_orders(&[request.clone()]).await;
}
return self.parse_orders(response.clone(), &[]);
Value::Null
}
/*
* @method
* @name binance#createOrder
* @description create a trade order
* @see https://developers.binance.com/docs/binance-spot-api-docs/rest-api/trading-endpoints#new-order-trade
* @see https://developers.binance.com/docs/binance-spot-api-docs/testnet/rest-api/trading-endpoints#test-new-order-trade
* @see https://developers.binance.com/docs/derivatives/usds-margined-futures/trade/rest-api/New-Order
* @see https://developers.binance.com/docs/derivatives/coin-margined-futures/trade/rest-api
* @see https://developers.binance.com/docs/derivatives/option/trade/New-Order
* @see https://developers.binance.com/docs/binance-spot-api-docs/rest-api/trading-endpoints#sor
* @see https://developers.binance.com/docs/binance-spot-api-docs/testnet/rest-api/trading-endpoints#sor
* @see https://developers.binance.com/docs/derivatives/portfolio-margin/trade/New-UM-Order
* @see https://developers.binance.com/docs/derivatives/portfolio-margin/trade/New-CM-Order
* @see https://developers.binance.com/docs/derivatives/portfolio-margin/trade/New-Margin-Order
* @see https://developers.binance.com/docs/derivatives/portfolio-margin/trade/New-UM-Conditional-Order
* @see https://developers.binance.com/docs/derivatives/portfolio-margin/trade/New-CM-Conditional-Order
* @see https://developers.binance.com/docs/derivatives/usds-margined-futures/trade/rest-api/New-Algo-Order
* @see https://developers.binance.com/en/docs/catalog/advanced-trading-stocks-trading/api/rest-api/trade#place-equity-order
* @param {string} symbol unified symbol of the market to create an order in
* @param {string} type 'market' or 'limit' or 'STOP_LOSS' or 'STOP_LOSS_LIMIT' or 'TAKE_PROFIT' or 'TAKE_PROFIT_LIMIT' or 'STOP'
* @param {string} side 'buy' or 'sell'
* @param {float} amount how much of you want to trade in units of the base currency
* @param {float} [price] the price that the order is to be fulfilled, in units of the quote currency, ignored in market orders
* @param {object} [params] extra parameters specific to the exchange API endpoint
* @param {string} [params.reduceOnly] for swap and future reduceOnly is a string 'true' or 'false' that cant be sent with close position set to true or in hedge mode. For spot margin and option reduceOnly is a boolean.
* @param {string} [params.marginMode] 'cross' or 'isolated', for spot margin trading
* @param {boolean} [params.sor] *spot only* whether to use SOR (Smart Order Routing) or not, default is false
* @param {boolean} [params.test] *spot only* whether to use the test endpoint or not, default is false
* @param {float} [params.trailingPercent] the percent to trail away from the current market price
* @param {float} [params.trailingTriggerPrice] the price to trigger a trailing order, default uses the price argument
* @param {float} [params.triggerPrice] the price that a trigger order is triggered at
* @param {float} [params.stopLossPrice] the price that a stop loss order is triggered at
* @param {float} [params.takeProfitPrice] the price that a take profit order is triggered at
* @param {boolean} [params.portfolioMargin] set to true if you would like to create an order in a portfolio margin account
* @param {string} [params.selfTradePrevention] set unified value for stp, one of NONE, EXPIRE_MAKER, EXPIRE_TAKER or EXPIRE_BOTH
* @param {float} [params.icebergAmount] set iceberg amount for limit orders
* @param {string} [params.stopLossOrTakeProfit] 'stopLoss' or 'takeProfit', required for spot trailing orders
* @param {string} [params.positionSide] *swap and portfolio margin only* "BOTH" for one-way mode, "LONG" for buy side of hedged mode, "SHORT" for sell side of hedged mode
* @param {bool} [params.hedged] *swap and portfolio margin only* true for hedged mode, false for one way mode, default is false
* @param {string} [params.clientOrderId] the clientOrderId of the order
* @param {string} [params.tradingSession] *stock only* required for limit orders, RTH, EXTENDED or 24H, default is 24H
* @returns {object} an [order structure]{@link https://docs.ccxt.com/?id=order-structure}
*/
pub async fn create_order(&mut self, mut symbol: Value, mut type_var: Value, mut side: Value, mut amount: Value, optional_args: &[Value]) -> Value {
let mut price = get_arg(optional_args, 0, Value::Null);
let mut params = get_arg(optional_args, 1, Value::Map({
let mut m = indexmap::IndexMap::new();
m
}));
if is_equal(&self.markets, &Value::Null) {
self.load_markets(&[]).await;
}
let mut market: Value = self.market(symbol.clone());
// don't handle/omit params here, omitting happens inside createOrderRequest
let mut marketType: Value = self.safe_string_k(params.clone(), "type", &[get_value(&market, &Value::Str("type".to_string()))]);
let mut marginMode: Value = self.safe_string_k(params.clone(), "marginMode", &[]);
let mut porfolioOptionsValue: Value = self.safe_bool2(self.options.clone(), Value::Str("papi".to_string()), Value::Str("portfolioMargin".to_string()), &[Value::Bool(false)]);
let mut isPortfolioMargin: Value = self.safe_bool2(params.clone(), Value::Str("papi".to_string()), Value::Str("portfolioMargin".to_string()), &[porfolioOptionsValue.clone()]);
let mut triggerPrice: Value = self.safe_string2(params.clone(), Value::Str("triggerPrice".to_string()), Value::Str("stopPrice".to_string()), &[]);
let mut stopLossPrice: Value = self.safe_string_k(params.clone(), "stopLossPrice", &[]);
let mut takeProfitPrice: Value = self.safe_string_k(params.clone(), "takeProfitPrice", &[]);
let mut trailingPercent: Value = self.safe_string2(params.clone(), Value::Str("trailingPercent".to_string()), Value::Str("callbackRate".to_string()), &[]);
let mut isTrailingPercentOrder: bool = !is_equal(&trailingPercent, &Value::Null);
let mut isStopLoss: bool = !is_equal(&stopLossPrice, &Value::Null);
let mut isTakeProfit: bool = !is_equal(&takeProfitPrice, &Value::Null);
let mut isConditional: bool = is_true(&(!is_equal(&triggerPrice, &Value::Null))) || is_true(&isTrailingPercentOrder) || is_true(&isStopLoss) || is_true(&isTakeProfit);
let mut sor: Value = self.safe_bool2(params.clone(), Value::Str("sor".to_string()), Value::Str("SOR".to_string()), &[Value::Bool(false)]);
let mut test: Value = self.safe_bool_k(params.clone(), "test", &[Value::Bool(false)]);
let mut stock: Value = self.safe_bool_k(market.clone(), "stock", &[Value::Bool(false)]);
params = self.omit(params.clone(), Value::List(vec![Value::Str("sor".to_string()), Value::Str("SOR".to_string()), Value::Str("test".to_string())]), &[]);
// if (isPortfolioMargin) {
// params['portfolioMargin'] = isPortfolioMargin;
// }
let mut request: Value = self.create_order_request(symbol.clone(), type_var.clone(), side.clone(), amount.clone(), &[price.clone(), params.clone()]);
let mut response: Value = Value::Null;
if is_equal(&get_value(&market, &Value::Str("option".to_string())), &Value::Bool(true)) {
response = self.eapi_private_post_order(&[request.clone()]).await;
} else if is_equal(&sor, &Value::Bool(true)) {
if is_equal(&test, &Value::Bool(true)) {
response = self.private_post_sor_order_test(&[request.clone()]).await;
} else {
response = self.private_post_sor_order(&[request.clone()]).await;
}
} else if is_equal(&get_value(&market, &Value::Str("linear".to_string())), &Value::Bool(true)) {
if is_equal(&isPortfolioMargin, &Value::Bool(true)) {
if is_true(&isConditional) {
response = self.papi_post_um_conditional_order(&[request.clone()]).await;
} else {
response = self.papi_post_um_order(&[request.clone()]).await;
}
} else {
if is_true(&isConditional) {
add_element_to_object(&mut request, &Value::Str("algoType".to_string()), Value::Str("CONDITIONAL".to_string()));
response = self.fapi_private_post_algo_order(&[request.clone()]).await;
} else {
response = self.fapi_private_post_order(&[request.clone()]).await;
}
}
} else if is_equal(&get_value(&market, &Value::Str("inverse".to_string())), &Value::Bool(true)) {
if is_equal(&isPortfolioMargin, &Value::Bool(true)) {
if is_true(&isConditional) {
response = self.papi_post_cm_conditional_order(&[request.clone()]).await;
} else {
response = self.papi_post_cm_order(&[request.clone()]).await;
}
} else {
if is_true(&isConditional) {
add_element_to_object(&mut request, &Value::Str("algoType".to_string()), Value::Str("CONDITIONAL".to_string()));
response = self.dapi_private_post_algo_order(&[request.clone()]).await;
} else {
response = self.dapi_private_post_order(&[request.clone()]).await;
}
}
} else if is_equal(&marketType, &Value::Str("margin".to_string())) || !is_equal(&marginMode, &Value::Null) || is_true(&(is_equal(&isPortfolioMargin, &Value::Bool(true)))) {
if is_equal(&isPortfolioMargin, &Value::Bool(true)) {
response = self.papi_post_margin_order(&[request.clone()]).await;
} else {
response = self.sapi_post_margin_order(&[request.clone()]).await;
}
} else {
if is_equal(&stock, &Value::Bool(true)) {
response = self.sapi_post_equity_order_place(&[request.clone()]).await;
} else if is_equal(&test, &Value::Bool(true)) {
response = self.private_post_order_test(&[request.clone()]).await;
} else {
response = self.private_post_order(&[request.clone()]).await;
}
}
if is_equal(&response, &Value::Null) {
panic!("{}", crate::exchange_errors::null_response(add(&self.id, &Value::Str(" parseOrder() returned empty response".to_string()))));
}
return self.parse_order(response.clone(), &[market.clone()]);
Value::Null
}
/*
* @method
* @ignore
* @name binance#createOrderRequest
* @description helper function to build the request
* @param {string} symbol unified symbol of the market to create an order in
* @param {string} type 'market' or 'limit'
* @param {string} side 'buy' or 'sell'
* @param {float} amount how much you want to trade in units of the base currency
* @param {float} [price] the price that the order is to be fulfilled, in units of the quote currency, ignored in market orders
* @param {object} [params] extra parameters specific to the exchange API endpoint
* @returns {object} request to be sent to the exchange
*/
pub fn create_order_request(&self, mut symbol: Value, mut type_var: Value, mut side: Value, mut amount: Value, optional_args: &[Value]) -> Value {
let mut price = get_arg(optional_args, 0, Value::Null);
let mut params = get_arg(optional_args, 1, Value::Map({
let mut m = indexmap::IndexMap::new();
m
}));
if is_equal(&type_var, &Value::Null) {
panic!("{}", crate::exchange_errors::arguments_required(add(&self.id, &Value::Str(" requires a type argument".to_string()))));
}
if is_equal(&side, &Value::Null) {
panic!("{}", crate::exchange_errors::arguments_required(add(&self.id, &Value::Str(" requires a side argument".to_string()))));
}
let mut market: Value = self.market(symbol.clone());
let mut marketType: Value = self.safe_string_k(params.clone(), "type", &[get_value(&market, &Value::Str("type".to_string()))]);
let mut stock: Value = self.safe_bool_k(market.clone(), "stock", &[Value::Bool(false)]);
let mut clientOrderId: Value = self.safe_string_n(params.clone(), Value::List(vec![Value::Str("clientAlgoId".to_string()), Value::Str("newClientOrderId".to_string()), Value::Str("clientOrderId".to_string())]), &[]);
let mut initialUppercaseType: Value = to_upper(&type_var);
let mut isMarketOrder: Value = Value::Bool(is_equal(&initialUppercaseType, &Value::Str("MARKET".to_string())));
let mut isLimitOrder: bool = is_equal(&initialUppercaseType, &Value::Str("LIMIT".to_string()));
let mut upperCaseSide: Value = to_upper(&side);
let mut request: Value = Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("symbol".to_string(), get_value(&market, &Value::Str("id".to_string())));
m.insert("side".to_string(), upperCaseSide.clone());
m
});
let mut isPortfolioMargin: Value = Value::Null;
{ let __destr_tmp = self.handle_option_and_params2(params.clone(), Value::Str("createOrder".to_string()), Value::Str("papi".to_string()), Value::Str("portfolioMargin".to_string()), &[Value::Bool(false)]); isPortfolioMargin = get_value(&__destr_tmp, &Value::Int(0)); params = get_value(&__destr_tmp, &Value::Int(1)); }
let mut marginMode: Value = Value::Null;
{ let __destr_tmp = self.handle_margin_mode_and_params(Value::Str("createOrder".to_string()), &[params.clone()]); marginMode = get_value(&__destr_tmp, &Value::Int(0)); params = get_value(&__destr_tmp, &Value::Int(1)); }
let mut reduceOnly: Value = self.safe_bool_k(params.clone(), "reduceOnly", &[Value::Bool(false)]);
if is_equal(&reduceOnly, &Value::Bool(true)) {
if is_equal(&marketType, &Value::Str("margin".to_string())) || is_true(&(is_true(&(!is_equal(&get_value(&market, &Value::Str("contract".to_string())), &Value::Bool(true)))) && is_true(&(!is_equal(&marginMode, &Value::Null))))) {
params = self.omit(params.clone(), Value::Str("reduceOnly".to_string()), &[]);
add_element_to_object(&mut request, &Value::Str("sideEffectType".to_string()), Value::Str("AUTO_REPAY".to_string()));
}
}
let mut triggerPrice: Value = self.safe_string2(params.clone(), Value::Str("triggerPrice".to_string()), Value::Str("stopPrice".to_string()), &[]);
let mut stopLossPrice: Value = self.safe_string_k(params.clone(), "stopLossPrice", &[triggerPrice.clone()]); // fallback to stopLoss
let mut takeProfitPrice: Value = self.safe_string_k(params.clone(), "takeProfitPrice", &[]);
let mut trailingDelta: Value = self.safe_string_k(params.clone(), "trailingDelta", &[]);
let mut trailingTriggerPrice: Value = self.safe_string2(params.clone(), Value::Str("trailingTriggerPrice".to_string()), Value::Str("activationPrice".to_string()), &[]);
let mut trailingPercent: Value = self.safe_string_n(params.clone(), Value::List(vec![Value::Str("trailingPercent".to_string()), Value::Str("callbackRate".to_string()), Value::Str("trailingDelta".to_string())]), &[]);
let mut priceMatch: Value = self.safe_string_k(params.clone(), "priceMatch", &[]);
let mut isTrailingPercentOrder: bool = !is_equal(&trailingPercent, &Value::Null);
let mut isStopLoss: bool = !is_equal(&stopLossPrice, &Value::Null) || !is_equal(&trailingDelta, &Value::Null);
let mut isTakeProfit: bool = !is_equal(&takeProfitPrice, &Value::Null);
let mut isTriggerOrder: bool = !is_equal(&triggerPrice, &Value::Null);
let mut isConditional: bool = is_true(&isTriggerOrder) || is_true(&isTrailingPercentOrder) || is_true(&isStopLoss) || is_true(&isTakeProfit);
let mut isPortfolioMarginConditional: bool = is_true(&isPortfolioMargin) && is_true(&isConditional);
let mut isPriceMatch: bool = !is_equal(&priceMatch, &Value::Null);
let mut priceRequiredForTrailing: bool = true;
let mut uppercaseType: Value = to_upper(&type_var);
let mut stopPrice: Value = Value::Null;
if is_true(&isTrailingPercentOrder) {
if is_equal(&get_value(&market, &Value::Str("swap".to_string())), &Value::Bool(true)) {
uppercaseType = Value::Str("TRAILING_STOP_MARKET".to_string());
add_element_to_object(&mut request, &Value::Str("callbackRate".to_string()), trailingPercent.clone());
if !is_equal(&trailingTriggerPrice, &Value::Null) {
add_element_to_object(&mut request, &Value::Str("activationPrice".to_string()), self.price_to_precision(symbol.clone(), trailingTriggerPrice.clone()));
}
} else {
if is_true(&(!is_equal(&uppercaseType, &Value::Str("STOP_LOSS".to_string())))) && is_true(&(!is_equal(&uppercaseType, &Value::Str("TAKE_PROFIT".to_string())))) && is_true(&(!is_equal(&uppercaseType, &Value::Str("STOP_LOSS_LIMIT".to_string())))) && is_true(&(!is_equal(&uppercaseType, &Value::Str("TAKE_PROFIT_LIMIT".to_string())))) {
let mut stopLossOrTakeProfit: Value = self.safe_string_k(params.clone(), "stopLossOrTakeProfit", &[]);
params = self.omit(params.clone(), Value::Str("stopLossOrTakeProfit".to_string()), &[]);
if is_true(&(!is_equal(&stopLossOrTakeProfit, &Value::Str("stopLoss".to_string())))) && is_true(&(!is_equal(&stopLossOrTakeProfit, &Value::Str("takeProfit".to_string())))) {
panic!("{}", crate::exchange_errors::invalid_order(add(&add(&self.id, &symbol), &Value::Str(" trailingPercent orders require a stopLossOrTakeProfit parameter of either stopLoss or takeProfit".to_string()))));
}
if is_true(&isMarketOrder) {
if is_equal(&stopLossOrTakeProfit, &Value::Str("stopLoss".to_string())) {
uppercaseType = Value::Str("STOP_LOSS".to_string());
} else if is_equal(&stopLossOrTakeProfit, &Value::Str("takeProfit".to_string())) {
uppercaseType = Value::Str("TAKE_PROFIT".to_string());
}
} else {
if is_equal(&stopLossOrTakeProfit, &Value::Str("stopLoss".to_string())) {
uppercaseType = Value::Str("STOP_LOSS_LIMIT".to_string());
} else if is_equal(&stopLossOrTakeProfit, &Value::Str("takeProfit".to_string())) {
uppercaseType = Value::Str("TAKE_PROFIT_LIMIT".to_string());
}
}
}
if is_true(&(is_equal(&uppercaseType, &Value::Str("STOP_LOSS".to_string())))) || is_true(&(is_equal(&uppercaseType, &Value::Str("TAKE_PROFIT".to_string())))) {
priceRequiredForTrailing = false;
}
if !is_equal(&trailingTriggerPrice, &Value::Null) {
stopPrice = self.price_to_precision(symbol.clone(), trailingTriggerPrice.clone());
}
let mut trailingPercentConverted: Value = crate::precise::Precise::stringMul(&trailingPercent, &Value::Str("100".to_string()));
add_element_to_object(&mut request, &Value::Str("trailingDelta".to_string()), trailingPercentConverted.clone());
}
} else if is_true(&isStopLoss) {
stopPrice = stopLossPrice.clone();
if is_true(&isMarketOrder) {
// spot STOP_LOSS market orders are not a valid order type
uppercaseType = ternary(is_true(&(is_equal(&get_value(&market, &Value::Str("contract".to_string())), &Value::Bool(true)))), Value::Str("STOP_MARKET".to_string()), Value::Str("STOP_LOSS".to_string()));
} else if is_true(&isLimitOrder) {
uppercaseType = ternary(is_true(&(is_equal(&get_value(&market, &Value::Str("contract".to_string())), &Value::Bool(true)))), Value::Str("STOP".to_string()), Value::Str("STOP_LOSS_LIMIT".to_string()));
}
} else if is_true(&isTakeProfit) {
stopPrice = takeProfitPrice.clone();
if is_true(&isMarketOrder) {
// spot TAKE_PROFIT market orders are not a valid order type
uppercaseType = ternary(is_true(&(is_equal(&get_value(&market, &Value::Str("contract".to_string())), &Value::Bool(true)))), Value::Str("TAKE_PROFIT_MARKET".to_string()), Value::Str("TAKE_PROFIT".to_string()));
} else if is_true(&isLimitOrder) {
uppercaseType = ternary(is_true(&(is_equal(&get_value(&market, &Value::Str("contract".to_string())), &Value::Bool(true)))), Value::Str("TAKE_PROFIT".to_string()), Value::Str("TAKE_PROFIT_LIMIT".to_string()));
}
}
if is_equal(&get_value(&market, &Value::Str("option".to_string())), &Value::Bool(true)) {
if is_equal(&type_var, &Value::Str("market".to_string())) {
panic!("{}", crate::exchange_errors::invalid_order(add(&add(&add(&add(&add(&self.id, &Value::Str(" ".to_string())), &type_var), &Value::Str(" is not a valid order type for the ".to_string())), &symbol), &Value::Str(" market".to_string()))));
}
} else {
let mut validOrderTypes: Value = self.safe_list(get_value(&market, &Value::Str("info".to_string())), Value::Str("orderTypes".to_string()), &[Value::List(vec![])]);
if is_equal(&stock, &Value::Bool(true)) {
validOrderTypes = Value::List(vec![Value::Str("LIMIT".to_string()), Value::Str("MARKET".to_string())]);
}
if !is_true(&self.in_array(uppercaseType.clone(), validOrderTypes.clone())) {
if !is_equal(&initialUppercaseType, &uppercaseType) {
panic!("{}", crate::exchange_errors::invalid_order(add(&add(&add(&add(&add(&self.id, &Value::Str(" triggerPrice parameter is not allowed for ".to_string())), &symbol), &Value::Str(" ".to_string())), &type_var), &Value::Str(" orders".to_string()))));
} else {
panic!("{}", crate::exchange_errors::invalid_order(add(&add(&add(&add(&add(&self.id, &Value::Str(" ".to_string())), &type_var), &Value::Str(" is not a valid order type for the ".to_string())), &symbol), &Value::Str(" market".to_string()))));
}
}
}
let mut clientOrderIdRequest: Value = ternary(is_true(&isPortfolioMarginConditional), Value::Str("newClientStrategyId".to_string()), Value::Str("newClientOrderId".to_string()));
if is_true(&(is_equal(&get_value(&market, &Value::Str("linear".to_string())), &Value::Bool(true)))) && is_true(&(is_equal(&get_value(&market, &Value::Str("swap".to_string())), &Value::Bool(true)))) && is_true(&isConditional) && !is_true(&isPortfolioMargin) {
clientOrderIdRequest = Value::Str("clientAlgoId".to_string());
} else if is_equal(&stock, &Value::Bool(true)) {
clientOrderIdRequest = Value::Str("clientOrderId".to_string());
}
if is_equal(&clientOrderId, &Value::Null) {
let mut broker: Value = self.safe_dict_k(self.options.clone(), "broker", &[Value::Map({
let mut m = indexmap::IndexMap::new();
m
})]);
let mut defaultId: Value = ternary(is_true(&(is_equal(&get_value(&market, &Value::Str("contract".to_string())), &Value::Bool(true)))), Value::Str("x-xcKtGhcu".to_string()), Value::Str("x-TKT5PX2F".to_string()));
let mut idMarketType: Value = Value::Str("spot".to_string());
if is_equal(&get_value(&market, &Value::Str("contract".to_string())), &Value::Bool(true)) {
let mut isLinearSwap: bool = is_true(&(is_equal(&get_value(&market, &Value::Str("swap".to_string())), &Value::Bool(true)))) && is_true(&(is_equal(&get_value(&market, &Value::Str("linear".to_string())), &Value::Bool(true))));
idMarketType = ternary(is_true(&isLinearSwap), Value::Str("swap".to_string()), Value::Str("inverse".to_string()));
}
let mut brokerId: Value = self.safe_string(broker.clone(), idMarketType.clone(), &[defaultId.clone()]);
add_element_to_object(&mut request, &clientOrderIdRequest, add(&brokerId, &self.uuid22(&[])));
} else {
add_element_to_object(&mut request, &clientOrderIdRequest, clientOrderId.clone());
}
let mut postOnly: Value = Value::Null;
if !is_true(&isPortfolioMargin) {
postOnly = self.is_post_only(isMarketOrder.clone(), Value::Bool(is_equal(&initialUppercaseType, &Value::Str("LIMIT_MAKER".to_string()))), &[params.clone()]);
if is_true(&(is_equal(&get_value(&market, &Value::Str("spot".to_string())), &Value::Bool(true)))) || is_equal(&marketType, &Value::Str("margin".to_string())) {
// only supported for spot/margin api (all margin markets are spot markets)
if is_true(&postOnly) {
uppercaseType = Value::Str("LIMIT_MAKER".to_string());
}
if is_equal(&marginMode, &Value::Str("isolated".to_string())) {
add_element_to_object(&mut request, &Value::Str("isIsolated".to_string()), Value::Bool(true));
}
}
} else {
postOnly = self.is_post_only(isMarketOrder.clone(), Value::Bool(is_equal(&initialUppercaseType, &Value::Str("LIMIT_MAKER".to_string()))), &[params.clone()]);
if is_true(&postOnly) {
if !is_equal(&get_value(&market, &Value::Str("contract".to_string())), &Value::Bool(true)) {
uppercaseType = Value::Str("LIMIT_MAKER".to_string());
} else {
add_element_to_object(&mut request, &Value::Str("timeInForce".to_string()), Value::Str("GTX".to_string()));
}
}
}
// handle newOrderRespType response type
if is_true(&(is_true(&(is_equal(&marketType, &Value::Str("spot".to_string())))) || is_true(&(is_equal(&marketType, &Value::Str("margin".to_string())))))) && !is_true(&isPortfolioMargin) && is_true(&(!is_equal(&stock, &Value::Bool(true)))) {
add_element_to_object(&mut request, &Value::Str("newOrderRespType".to_string()), self.safe_string(get_value(&self.options, &Value::Str("newOrderRespType".to_string())), type_var.clone(), &[Value::Str("FULL".to_string())])); // 'ACK' for order id, 'RESULT' for full order or 'FULL' for order with fills
} else if !is_equal(&stock, &Value::Bool(true)) {
// swap, futures and options
add_element_to_object(&mut request, &Value::Str("newOrderRespType".to_string()), Value::Str("RESULT".to_string())); // "ACK", "RESULT", default "ACK"
}
let mut typeRequest: Value = ternary(is_true(&isPortfolioMarginConditional), Value::Str("strategyType".to_string()), Value::Str("type".to_string()));
if is_equal(&stock, &Value::Bool(true)) {
typeRequest = Value::Str("orderType".to_string());
}
add_element_to_object(&mut request, &typeRequest, uppercaseType.clone());
// additional required fields depending on the order type
let mut closePosition: Value = self.safe_bool_k(params.clone(), "closePosition", &[Value::Bool(false)]);
let mut timeInForceIsRequired: bool = false;
let mut priceIsRequired: bool = false;
let mut triggerPriceIsRequired: bool = false;
let mut quantityIsRequired: bool = false;
//
// spot/margin
//
// LIMIT timeInForce, quantity, price
// MARKET quantity or quoteOrderQty
// STOP_LOSS quantity, stopPrice
// STOP_LOSS_LIMIT timeInForce, quantity, price, stopPrice
// TAKE_PROFIT quantity, stopPrice
// TAKE_PROFIT_LIMIT timeInForce, quantity, price, stopPrice
// LIMIT_MAKER quantity, price
//
// futures
//
// LIMIT timeInForce, quantity, price
// MARKET quantity
// STOP/TAKE_PROFIT quantity, price, stopPrice
// STOP_MARKET stopPrice
// TAKE_PROFIT_MARKET stopPrice
// TRAILING_STOP_MARKET callbackRate
//
if is_equal(&uppercaseType, &Value::Str("MARKET".to_string())) {
if is_equal(&stock, &Value::Bool(true)) {
if is_equal(&upperCaseSide, &Value::Str("BUY".to_string())) {
let mut precision: Value = self.safe_value(get_value(&market, &Value::Str("precision".to_string())), Value::Str("price".to_string()), &[]);
let mut quoteOrderQtyNew: Value = self.safe_string2(params.clone(), Value::Str("quoteOrderQty".to_string()), Value::Str("cost".to_string()), &[]);
let mut notional: Value = Value::Null;
if !is_equal("eOrderQtyNew, &Value::Null) {
notional = quoteOrderQtyNew.clone();
} else if !is_equal(&price, &Value::Null) {
let mut amountString: Value = self.number_to_string(amount.clone());
let mut priceString: Value = self.number_to_string(price.clone());
notional = crate::precise::Precise::stringMul(&amountString, &priceString);
} else {
notional = self.number_to_string(amount.clone());
}
if is_equal(&precision, &Value::Null) {
add_element_to_object(&mut request, &Value::Str("notional".to_string()), notional.clone());
} else {
add_element_to_object(&mut request, &Value::Str("notional".to_string()), self.decimal_to_precision(notional.clone(), Value::Int(crate::runtime::TRUNCATE), precision.clone(), &[self.precisionMode.clone()]));
}
} else {
// Redeem stock to underlying using sapiPostEquityTokenizedRedeem or call redeemTokenizedAsset (tokenizedAsset, tokenizedAssetAmount, params)
// Poll sapiGetEquityTokenizedConvertStatus with the returned issuerRequestId and convertType REDEEM until status is S or call tokenizedConvertStatus (issuerRequestId, convertType, params)
// Then you can place a sell order
let mut marketAmountPrecision: Value = self.safe_string(get_value(&market, &Value::Str("precision".to_string())), Value::Str("amount".to_string()), &[]);
if !is_equal(&marketAmountPrecision, &Value::Null) {
add_element_to_object(&mut request, &Value::Str("quantity".to_string()), self.amount_to_precision(symbol.clone(), amount.clone()));
} else {
add_element_to_object(&mut request, &Value::Str("quantity".to_string()), self.parse_to_numeric(amount.clone()));
}
}
} else if is_equal(&get_value(&market, &Value::Str("spot".to_string())), &Value::Bool(true)) {
let mut quoteOrderQty: Value = self.handle_option(Value::Str("createOrder".to_string()), Value::Str("quoteOrderQty".to_string()), &[Value::Bool(true)]);
if is_equal("eOrderQty, &Value::Bool(true)) {
let mut quoteOrderQtyNew: Value = self.safe_string2(params.clone(), Value::Str("quoteOrderQty".to_string()), Value::Str("cost".to_string()), &[]);
let mut precision: Value = self.safe_value(get_value(&market, &Value::Str("precision".to_string())), Value::Str("price".to_string()), &[]);
if !is_equal("eOrderQtyNew, &Value::Null) {
add_element_to_object(&mut request, &Value::Str("quoteOrderQty".to_string()), self.decimal_to_precision(quoteOrderQtyNew.clone(), Value::Int(crate::runtime::TRUNCATE), precision.clone(), &[self.precisionMode.clone()]));
} else if !is_equal(&price, &Value::Null) {
let mut amountString: Value = self.number_to_string(amount.clone());
let mut priceString: Value = self.number_to_string(price.clone());
let mut quoteOrderQuantity: Value = crate::precise::Precise::stringMul(&amountString, &priceString);
add_element_to_object(&mut request, &Value::Str("quoteOrderQty".to_string()), self.decimal_to_precision(quoteOrderQuantity.clone(), Value::Int(crate::runtime::TRUNCATE), precision.clone(), &[self.precisionMode.clone()]));
} else {
quantityIsRequired = true;
}
} else {
quantityIsRequired = true;
}
} else {
quantityIsRequired = true;
}
} else if is_equal(&uppercaseType, &Value::Str("LIMIT".to_string())) {
if is_equal(&stock, &Value::Bool(true)) {
let mut tradingSession: Value = self.safe_string_k(params.clone(), "tradingSession", &[Value::Str("24H".to_string())]);
add_element_to_object(&mut request, &Value::Str("tradingSession".to_string()), tradingSession.clone());
}
priceIsRequired = true;
timeInForceIsRequired = true;
quantityIsRequired = true;
} else if is_true(&(is_equal(&uppercaseType, &Value::Str("STOP_LOSS".to_string())))) || is_true(&(is_equal(&uppercaseType, &Value::Str("TAKE_PROFIT".to_string())))) {
triggerPriceIsRequired = true;
quantityIsRequired = true;
if is_true(&(is_true(&(is_equal(&get_value(&market, &Value::Str("linear".to_string())), &Value::Bool(true)))) || is_true(&(is_equal(&get_value(&market, &Value::Str("inverse".to_string())), &Value::Bool(true)))))) && is_true(&priceRequiredForTrailing) {
priceIsRequired = true;
}
} else if is_true(&(is_equal(&uppercaseType, &Value::Str("STOP_LOSS_LIMIT".to_string())))) || is_true(&(is_equal(&uppercaseType, &Value::Str("TAKE_PROFIT_LIMIT".to_string())))) {
quantityIsRequired = true;
triggerPriceIsRequired = true;
priceIsRequired = true;
timeInForceIsRequired = true;
} else if is_equal(&uppercaseType, &Value::Str("LIMIT_MAKER".to_string())) {
priceIsRequired = true;
quantityIsRequired = true;
} else if is_equal(&uppercaseType, &Value::Str("STOP".to_string())) {
quantityIsRequired = true;
triggerPriceIsRequired = true;
priceIsRequired = true;
} else if is_true(&(is_equal(&uppercaseType, &Value::Str("STOP_MARKET".to_string())))) || is_true(&(is_equal(&uppercaseType, &Value::Str("TAKE_PROFIT_MARKET".to_string())))) {
if !is_equal(&closePosition, &Value::Bool(true)) {
quantityIsRequired = true;
}
triggerPriceIsRequired = true;
} else if is_equal(&uppercaseType, &Value::Str("TRAILING_STOP_MARKET".to_string())) {
if !is_equal(&closePosition, &Value::Bool(true)) {
quantityIsRequired = true;
}
if is_equal(&trailingPercent, &Value::Null) {
panic!("{}", crate::exchange_errors::invalid_order(add(&add(&add(&self.id, &Value::Str(" createOrder() requires a trailingPercent param for a ".to_string())), &type_var), &Value::Str(" order".to_string()))));
}
}
if is_true(&quantityIsRequired) {
let mut marketAmountPrecision: Value = self.safe_string(get_value(&market, &Value::Str("precision".to_string())), Value::Str("amount".to_string()), &[]);
let mut isPrecisionAvailable: bool = !is_equal(&marketAmountPrecision, &Value::Null);
if is_true(&isPrecisionAvailable) {
add_element_to_object(&mut request, &Value::Str("quantity".to_string()), self.amount_to_precision(symbol.clone(), amount.clone()));
} else {
add_element_to_object(&mut request, &Value::Str("quantity".to_string()), self.parse_to_numeric(amount.clone())); // some options don't have the precision available
}
}
if is_true(&priceIsRequired) && !is_true(&isPriceMatch) {
if is_equal(&price, &Value::Null) {
panic!("{}", crate::exchange_errors::invalid_order(add(&add(&add(&self.id, &Value::Str(" createOrder() requires a price argument for a ".to_string())), &type_var), &Value::Str(" order".to_string()))));
}
let mut pricePrecision: Value = self.safe_string(get_value(&market, &Value::Str("precision".to_string())), Value::Str("price".to_string()), &[]);
let mut isPricePrecisionAvailable: bool = !is_equal(&pricePrecision, &Value::Null);
if is_true(&isPricePrecisionAvailable) {
add_element_to_object(&mut request, &Value::Str("price".to_string()), self.price_to_precision(symbol.clone(), price.clone()));
} else {
add_element_to_object(&mut request, &Value::Str("price".to_string()), self.parse_to_numeric(price.clone())); // some options don't have the precision available
}
}
if is_true(&triggerPriceIsRequired) {
if is_equal(&get_value(&market, &Value::Str("contract".to_string())), &Value::Bool(true)) {
if is_equal(&stopPrice, &Value::Null) {
panic!("{}", crate::exchange_errors::invalid_order(add(&add(&add(&self.id, &Value::Str(" createOrder() requires a triggerPrice extra param for a ".to_string())), &type_var), &Value::Str(" order".to_string()))));
}
} else {
// check for delta price as well
if is_equal(&trailingDelta, &Value::Null) && is_equal(&stopPrice, &Value::Null) && is_equal(&trailingPercent, &Value::Null) {
panic!("{}", crate::exchange_errors::invalid_order(add(&add(&add(&self.id, &Value::Str(" createOrder() requires a triggerPrice, trailingDelta or trailingPercent param for a ".to_string())), &type_var), &Value::Str(" order".to_string()))));
}
}
if !is_equal(&stopPrice, &Value::Null) {
if is_true(&(is_equal(&get_value(&market, &Value::Str("swap".to_string())), &Value::Bool(true)))) && !is_true(&isPortfolioMargin) {
add_element_to_object(&mut request, &Value::Str("triggerPrice".to_string()), self.price_to_precision(symbol.clone(), stopPrice.clone()));
} else {
add_element_to_object(&mut request, &Value::Str("stopPrice".to_string()), self.price_to_precision(symbol.clone(), stopPrice.clone()));
}
}
}
if is_true(&timeInForceIsRequired) && is_true(&(is_equal(&self.safe_string_k(params.clone(), "timeInForce", &[]), &Value::Null))) && is_true(&(is_equal(&self.safe_string_k(request.clone(), "timeInForce", &[]), &Value::Null))) {
add_element_to_object(&mut request, &Value::Str("timeInForce".to_string()), self.handle_option(Value::Str("createOrder".to_string()), Value::Str("timeInForce".to_string()), &[])); // 'GTC' = Good To Cancel (default), 'IOC' = Immediate Or Cancel
}
if !is_true(&isPortfolioMargin) && is_true(&(is_equal(&get_value(&market, &Value::Str("contract".to_string())), &Value::Bool(true)))) && is_true(&postOnly) {
add_element_to_object(&mut request, &Value::Str("timeInForce".to_string()), Value::Str("GTX".to_string()));
}
// remove timeInForce from params because PO is only used by this.isPostOnly and it's not a valid value for Binance
if is_equal(&self.safe_string_k(params.clone(), "timeInForce", &[]), &Value::Str("PO".to_string())) {
params = self.omit(params.clone(), Value::Str("timeInForce".to_string()), &[]);
}
let mut hedged: Value = self.safe_bool_k(params.clone(), "hedged", &[Value::Bool(false)]);
if is_true(&(!is_equal(&get_value(&market, &Value::Str("spot".to_string())), &Value::Bool(true)))) && is_true(&(!is_equal(&get_value(&market, &Value::Str("option".to_string())), &Value::Bool(true)))) && is_true(&(is_equal(&hedged, &Value::Bool(true)))) {
if is_equal(&reduceOnly, &Value::Bool(true)) {
params = self.omit(params.clone(), Value::Str("reduceOnly".to_string()), &[]);
side = ternary(is_true(&(is_equal(&side, &Value::Str("buy".to_string())))), Value::Str("sell".to_string()), Value::Str("buy".to_string()));
}
add_element_to_object(&mut request, &Value::Str("positionSide".to_string()), ternary(is_true(&(is_equal(&side, &Value::Str("buy".to_string())))), Value::Str("LONG".to_string()), Value::Str("SHORT".to_string())));
}
// unified stp
let mut selfTradePrevention: Value = Value::Null;
{ let __destr_tmp = self.handle_option_and_params(params.clone(), Value::Str("createOrder".to_string()), Value::Str("selfTradePrevention".to_string()), &[]); selfTradePrevention = get_value(&__destr_tmp, &Value::Int(0)); params = get_value(&__destr_tmp, &Value::Int(1)); }
if !is_equal(&selfTradePrevention, &Value::Null) {
let mut warnOnStpForInverse: Value = self.handle_option(Value::Str("createOrder".to_string()), Value::Str("warnOnSTPForInverse".to_string()), &[]);
if is_true(&(is_equal(&get_value(&market, &Value::Str("inverse".to_string())), &Value::Bool(true)))) && is_true(&(is_equal(&warnOnStpForInverse, &Value::Bool(true)))) {
panic!("{}", crate::exchange_errors::not_supported(add(&self.id, &Value::Str(" createOrder() selfTradePrevention is not supported for inverse markets. selfTradePrevention for inverse markets is taken from linear market. To disable this warning set the .options[\"createOrder\"][\"warnOnSTPForInverse\"] to false.".to_string()))));
}
add_element_to_object(&mut request, &Value::Str("selfTradePreventionMode".to_string()), to_upper(&selfTradePrevention)); // binance enums exactly match the unified ccxt enums (but needs uppercase)
}
// unified iceberg
let mut icebergAmount: Value = self.safe_number_k(params.clone(), "icebergAmount", &[]);
if !is_equal(&icebergAmount, &Value::Null) {
if is_equal(&get_value(&market, &Value::Str("spot".to_string())), &Value::Bool(true)) {
add_element_to_object(&mut request, &Value::Str("icebergQty".to_string()), self.amount_to_precision(symbol.clone(), icebergAmount.clone()));
}
}
let mut requestParams: Value = self.omit(params.clone(), Value::List(vec![Value::Str("type".to_string()), Value::Str("newClientOrderId".to_string()), Value::Str("clientOrderId".to_string()), Value::Str("postOnly".to_string()), Value::Str("stopLossPrice".to_string()), Value::Str("takeProfitPrice".to_string()), Value::Str("stopPrice".to_string()), Value::Str("triggerPrice".to_string()), Value::Str("trailingTriggerPrice".to_string()), Value::Str("trailingPercent".to_string()), Value::Str("quoteOrderQty".to_string()), Value::Str("cost".to_string()), Value::Str("test".to_string()), Value::Str("hedged".to_string()), Value::Str("icebergAmount".to_string())]), &[]);
return self.extend(request.clone(), &[requestParams.clone()]);
Value::Null
}
/*
* @method
* @name binance#createMarketOrderWithCost
* @description create a market order by providing the symbol, side and cost
* @see https://developers.binance.com/docs/binance-spot-api-docs/rest-api/trading-endpoints#new-order-trade
* @param {string} symbol unified symbol of the market to create an order in
* @param {string} side 'buy' or 'sell'
* @param {float} cost how much you want to trade in units of the quote currency
* @param {object} [params] extra parameters specific to the exchange API endpoint
* @returns {object} an [order structure]{@link https://docs.ccxt.com/?id=order-structure}
*/
pub async fn create_market_order_with_cost(&mut self, mut symbol: Value, mut side: Value, mut cost: Value, optional_args: &[Value]) -> Value {
let mut params = get_arg(optional_args, 0, Value::Map({
let mut m = indexmap::IndexMap::new();
m
}));
if is_equal(&self.markets, &Value::Null) {
self.load_markets(&[]).await;
}
let mut market: Value = self.market(symbol.clone());
if !is_equal(&get_value(&market, &Value::Str("spot".to_string())), &Value::Bool(true)) {
panic!("{}", crate::exchange_errors::not_supported(add(&self.id, &Value::Str(" createMarketOrderWithCost() supports spot orders only".to_string()))));
}
let mut req: Value = Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), cost.clone());
m
});
let __ws_arg_55 = self.extend(req.clone(), &[params.clone()]);
return self.create_order(symbol.clone(), Value::Str("market".to_string()), side.clone(), cost.clone(), &[Value::Null, __ws_arg_55]).await;
Value::Null
}
/*
* @method
* @name binance#createMarketBuyOrderWithCost
* @description create a market buy order by providing the symbol and cost
* @see https://developers.binance.com/docs/binance-spot-api-docs/rest-api/trading-endpoints#new-order-trade
* @param {string} symbol unified symbol of the market to create an order in
* @param {float} cost how much you want to trade in units of the quote currency
* @param {object} [params] extra parameters specific to the exchange API endpoint
* @returns {object} an [order structure]{@link https://docs.ccxt.com/?id=order-structure}
*/
pub async fn create_market_buy_order_with_cost(&mut self, mut symbol: Value, mut cost: Value, optional_args: &[Value]) -> Value {
let mut params = get_arg(optional_args, 0, Value::Map({
let mut m = indexmap::IndexMap::new();
m
}));
if is_equal(&self.markets, &Value::Null) {
self.load_markets(&[]).await;
}
let mut market: Value = self.market(symbol.clone());
if !is_equal(&get_value(&market, &Value::Str("spot".to_string())), &Value::Bool(true)) {
panic!("{}", crate::exchange_errors::not_supported(add(&self.id, &Value::Str(" createMarketBuyOrderWithCost() supports spot orders only".to_string()))));
}
let mut req: Value = Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), cost.clone());
m
});
let __ws_arg_56 = self.extend(req.clone(), &[params.clone()]);
return self.create_order(symbol.clone(), Value::Str("market".to_string()), Value::Str("buy".to_string()), cost.clone(), &[Value::Null, __ws_arg_56]).await;
Value::Null
}
/*
* @method
* @name binance#createMarketSellOrderWithCost
* @description create a market sell order by providing the symbol and cost
* @see https://developers.binance.com/docs/binance-spot-api-docs/rest-api/trading-endpoints#new-order-trade
* @param {string} symbol unified symbol of the market to create an order in
* @param {float} cost how much you want to trade in units of the quote currency
* @param {object} [params] extra parameters specific to the exchange API endpoint
* @returns {object} an [order structure]{@link https://docs.ccxt.com/?id=order-structure}
*/
pub async fn create_market_sell_order_with_cost(&mut self, mut symbol: Value, mut cost: Value, optional_args: &[Value]) -> Value {
let mut params = get_arg(optional_args, 0, Value::Map({
let mut m = indexmap::IndexMap::new();
m
}));
if is_equal(&self.markets, &Value::Null) {
self.load_markets(&[]).await;
}
let mut market: Value = self.market(symbol.clone());
if !is_equal(&get_value(&market, &Value::Str("spot".to_string())), &Value::Bool(true)) {
panic!("{}", crate::exchange_errors::not_supported(add(&self.id, &Value::Str(" createMarketSellOrderWithCost() supports spot orders only".to_string()))));
}
add_element_to_object(&mut params, &Value::Str("quoteOrderQty".to_string()), cost.clone());
return self.create_order(symbol.clone(), Value::Str("market".to_string()), Value::Str("sell".to_string()), cost.clone(), &[Value::Null, params.clone()]).await;
Value::Null
}
/*
* @method
* @name binance#fetchOrder
* @description fetches information on an order made by the user
* @see https://developers.binance.com/docs/binance-spot-api-docs/rest-api/trading-endpoints#query-order-user_data
* @see https://developers.binance.com/docs/derivatives/usds-margined-futures/trade/rest-api/Query-Order
* @see https://developers.binance.com/docs/derivatives/coin-margined-futures/trade/rest-api/Query-Order
* @see https://developers.binance.com/docs/derivatives/option/trade/Query-Single-Order
* @see https://developers.binance.com/docs/margin_trading/trade/Query-Margin-Account-Order
* @see https://developers.binance.com/docs/derivatives/portfolio-margin/trade/Query-UM-Order
* @see https://developers.binance.com/docs/derivatives/portfolio-margin/trade/Query-CM-Order
* @see https://developers.binance.com/docs/derivatives/usds-margined-futures/trade/rest-api/Query-Algo-Order
* @see https://developers.binance.com/en/docs/catalog/advanced-trading-stocks-trading/api/rest-api/trade#equity-order-detail
* @param {string} id the order id
* @param {string} symbol unified symbol of the market the order was made in
* @param {object} [params] extra parameters specific to the exchange API endpoint
* @param {string} [params.marginMode] 'cross' or 'isolated', for spot margin trading
* @param {boolean} [params.portfolioMargin] set to true if you would like to fetch an order in a portfolio margin account
* @param {boolean} [params.trigger] set to true if you would like to fetch a trigger or conditional order
* @param {boolean} [params.stock] set to true if you would like to fetch tokenized stock orders
* @returns {object} An [order structure]{@link https://docs.ccxt.com/?id=order-structure}
*/
pub async fn fetch_order(&mut self, mut id: Value, optional_args: &[Value]) -> Value {
let mut symbol = get_arg(optional_args, 0, Value::Null);
let mut params = get_arg(optional_args, 1, Value::Map({
let mut m = indexmap::IndexMap::new();
m
}));
if is_equal(&self.markets, &Value::Null) {
self.load_markets(&[]).await;
}
let mut request: Value = Value::Map({
let mut m = indexmap::IndexMap::new();
m
});
let mut market: Value = Value::Null;
let mut stock: Value = Value::Null;
{ let __destr_tmp = self.handle_option_and_params(params.clone(), Value::Str("fetchOrder".to_string()), Value::Str("stock".to_string()), &[Value::Bool(false)]); stock = get_value(&__destr_tmp, &Value::Int(0)); params = get_value(&__destr_tmp, &Value::Int(1)); }
if !is_equal(&symbol, &Value::Null) {
market = self.market(symbol.clone());
stock = self.safe_bool_k(market.clone(), "stock", &[Value::Bool(false)]);
if !is_equal(&stock, &Value::Bool(true)) {
add_element_to_object(&mut request, &Value::Str("symbol".to_string()), get_value(&market, &Value::Str("id".to_string())));
}
} else {
panic!("{}", crate::exchange_errors::arguments_required(add(&self.id, &Value::Str(" fetchOrder() requires a symbol argument".to_string()))));
}
let mut type_var: Value = Value::Null;
{ let __destr_tmp = self.handle_market_type_and_params(Value::Str("fetchOrder".to_string()), &[market.clone(), params.clone(), Value::Str("spot".to_string())]); type_var = get_value(&__destr_tmp, &Value::Int(0)); params = get_value(&__destr_tmp, &Value::Int(1)); }
let mut subType: Value = Value::Null;
{ let __destr_tmp = self.handle_sub_type_and_params(Value::Str("fetchOrder".to_string()), &[market.clone(), params.clone()]); subType = get_value(&__destr_tmp, &Value::Int(0)); params = get_value(&__destr_tmp, &Value::Int(1)); }
let mut marginMode: Value = Value::Null;
{ let __destr_tmp = self.handle_margin_mode_and_params(Value::Str("fetchOrder".to_string()), &[params.clone()]); marginMode = get_value(&__destr_tmp, &Value::Int(0)); params = get_value(&__destr_tmp, &Value::Int(1)); }
let mut isPortfolioMargin: Value = Value::Null;
{ let __destr_tmp = self.handle_option_and_params2(params.clone(), Value::Str("fetchOrder".to_string()), Value::Str("papi".to_string()), Value::Str("portfolioMargin".to_string()), &[Value::Bool(false)]); isPortfolioMargin = get_value(&__destr_tmp, &Value::Int(0)); params = get_value(&__destr_tmp, &Value::Int(1)); }
let mut isConditional: Value = self.safe_bool_n(params.clone(), Value::List(vec![Value::Str("stop".to_string()), Value::Str("trigger".to_string()), Value::Str("conditional".to_string())]), &[]);
let mut isOptionType: bool = is_equal(&type_var, &Value::Str("option".to_string()));
let mut isLinearType: Value = self.is_linear(type_var.clone(), &[subType.clone()]);
let mut isInverseType: Value = self.is_inverse(type_var.clone(), &[subType.clone()]);
let mut isLinearSwapConditional: Value = Value::Bool(is_true(&isLinearType) && is_true(&(!is_equal(&market, &Value::Null))) && is_true(&(is_equal(&get_value(&market, &Value::Str("swap".to_string())), &Value::Bool(true)))) && is_true(&(is_equal(&isConditional, &Value::Bool(true)))) && is_true(&(!is_equal(&isPortfolioMargin, &Value::Bool(true)))));
let mut clientOrderId: Value = self.safe_string_n(params.clone(), Value::List(vec![Value::Str("origClientOrderId".to_string()), Value::Str("clientOrderId".to_string()), Value::Str("clientAlgoId".to_string())]), &[]);
if !is_equal(&clientOrderId, &Value::Null) {
if is_true(&isOptionType) {
add_element_to_object(&mut request, &Value::Str("clientOrderId".to_string()), clientOrderId.clone());
} else if is_equal(&isLinearSwapConditional, &Value::Bool(true)) {
add_element_to_object(&mut request, &Value::Str("clientAlgoId".to_string()), clientOrderId.clone());
} else {
add_element_to_object(&mut request, &Value::Str("origClientOrderId".to_string()), clientOrderId.clone());
}
} else if is_equal(&isLinearSwapConditional, &Value::Bool(true)) {
add_element_to_object(&mut request, &Value::Str("algoId".to_string()), id.clone());
} else {
add_element_to_object(&mut request, &Value::Str("orderId".to_string()), id.clone());
}
params = self.omit(params.clone(), Value::List(vec![Value::Str("clientOrderId".to_string()), Value::Str("origClientOrderId".to_string()), Value::Str("stop".to_string()), Value::Str("trigger".to_string()), Value::Str("conditional".to_string()), Value::Str("clientAlgoId".to_string())]), &[]);
let mut response: Value = Value::Null;
if is_true(&isOptionType) {
let __ws_arg_57 = self.extend(request.clone(), &[params.clone()]);
response = self.eapi_private_get_order(&[__ws_arg_57]).await;
} else if is_true(&isLinearType) {
if is_true(&isPortfolioMargin) {
let __ws_arg_58 = self.extend(request.clone(), &[params.clone()]);
response = self.papi_get_um_order(&[__ws_arg_58]).await;
} else {
if is_equal(&isConditional, &Value::Bool(true)) {
let __ws_arg_59 = self.extend(request.clone(), &[params.clone()]);
response = self.fapi_private_get_algo_order(&[__ws_arg_59]).await;
} else {
let __ws_arg_60 = self.extend(request.clone(), &[params.clone()]);
response = self.fapi_private_get_order(&[__ws_arg_60]).await;
}
}
} else if is_true(&isInverseType) {
if is_true(&isPortfolioMargin) {
let __ws_arg_61 = self.extend(request.clone(), &[params.clone()]);
response = self.papi_get_cm_order(&[__ws_arg_61]).await;
} else {
let __ws_arg_62 = self.extend(request.clone(), &[params.clone()]);
response = self.dapi_private_get_order(&[__ws_arg_62]).await;
}
} else if is_true(&(is_equal(&type_var, &Value::Str("margin".to_string())))) || is_true(&(!is_equal(&marginMode, &Value::Null))) || is_true(&isPortfolioMargin) {
if is_true(&isPortfolioMargin) {
let __ws_arg_63 = self.extend(request.clone(), &[params.clone()]);
response = self.papi_get_margin_order(&[__ws_arg_63]).await;
} else {
if is_equal(&marginMode, &Value::Str("isolated".to_string())) {
add_element_to_object(&mut request, &Value::Str("isIsolated".to_string()), Value::Bool(true));
}
let __ws_arg_64 = self.extend(request.clone(), &[params.clone()]);
response = self.sapi_get_margin_order(&[__ws_arg_64]).await;
}
} else if is_equal(&stock, &Value::Bool(true)) {
let __ws_arg_65 = self.extend(request.clone(), &[params.clone()]);
response = self.sapi_get_equity_order_detail(&[__ws_arg_65]).await;
} else {
let __ws_arg_66 = self.extend(request.clone(), &[params.clone()]);
response = self.private_get_order(&[__ws_arg_66]).await;
}
if is_equal(&response, &Value::Null) {
panic!("{}", crate::exchange_errors::null_response(add(&self.id, &Value::Str(" parseOrder() returned empty response".to_string()))));
}
return self.parse_order(response.clone(), &[market.clone()]);
Value::Null
}
/*
* @method
* @name binance#fetchOrders
* @description fetches information on multiple orders made by the user
* @see https://developers.binance.com/docs/binance-spot-api-docs/rest-api/trading-endpoints#all-orders-user_data
* @see https://developers.binance.com/docs/derivatives/usds-margined-futures/trade/rest-api/All-Orders
* @see https://developers.binance.com/docs/derivatives/coin-margined-futures/trade/rest-api/All-Orders
* @see https://developers.binance.com/docs/derivatives/option/trade/Query-Option-Order-History
* @see https://developers.binance.com/docs/margin_trading/trade/Query-Margin-Account-All-Orders
* @see https://developers.binance.com/docs/derivatives/portfolio-margin/trade/Query-All-UM-Orders
* @see https://developers.binance.com/docs/derivatives/portfolio-margin/trade/Query-All-CM-Orders
* @see https://developers.binance.com/docs/derivatives/portfolio-margin/trade/Query-All-UM-Conditional-Orders
* @see https://developers.binance.com/docs/derivatives/portfolio-margin/trade/Query-All-CM-Conditional-Orders
* @see https://developers.binance.com/docs/derivatives/usds-margined-futures/trade/rest-api/Query-All-Algo-Orders
* @see https://developers.binance.com/en/docs/catalog/advanced-trading-stocks-trading/api/rest-api/trade#equity-order-history
* @param {string} symbol unified market symbol of the market orders were made in
* @param {int} [since] the earliest time in ms to fetch orders for
* @param {int} [limit] the maximum number of order structures to retrieve
* @param {object} [params] extra parameters specific to the exchange API endpoint
* @param {string} [params.marginMode] 'cross' or 'isolated', for spot margin trading
* @param {int} [params.until] the latest time in ms to fetch orders for
* @param {boolean} [params.paginate] default false, when true will automatically paginate by calling this endpoint multiple times. See in the docs all the [available parameters](https://github.com/ccxt/ccxt/wiki/Manual#pagination-params)
* @param {boolean} [params.portfolioMargin] set to true if you would like to fetch orders in a portfolio margin account
* @param {boolean} [params.trigger] set to true if you would like to fetch portfolio margin account trigger or conditional orders
* @param {boolean} [params.stock] set to true if you would like to fetch tokenized stock orders
* @returns {Order[]} a list of [order structures]{@link https://docs.ccxt.com/?id=order-structure}
*/
pub async fn fetch_orders(&mut self, optional_args: &[Value]) -> Value {
let mut symbol = get_arg(optional_args, 0, Value::Null);
let mut since = get_arg(optional_args, 1, Value::Null);
let mut limit = get_arg(optional_args, 2, Value::Null);
let mut params = get_arg(optional_args, 3, Value::Map({
let mut m = indexmap::IndexMap::new();
m
}));
if is_equal(&self.markets, &Value::Null) {
self.load_markets(&[]).await;
}
let mut paginate: Value = Value::Bool(false);
{ let __destr_tmp = self.handle_option_and_params(params.clone(), Value::Str("fetchOrders".to_string()), Value::Str("paginate".to_string()), &[]); paginate = get_value(&__destr_tmp, &Value::Int(0)); params = get_value(&__destr_tmp, &Value::Int(1)); }
if is_true(&paginate) {
return self.fetch_paginated_call_dynamic(Value::Str("fetchOrders".to_string()), &[symbol.clone(), since.clone(), limit.clone(), params.clone()]).await;
}
let mut request: Value = Value::Map({
let mut m = indexmap::IndexMap::new();
m
});
let mut market: Value = Value::Null;
let mut stock: Value = Value::Null;
{ let __destr_tmp = self.handle_option_and_params(params.clone(), Value::Str("fetchOrders".to_string()), Value::Str("stock".to_string()), &[Value::Bool(false)]); stock = get_value(&__destr_tmp, &Value::Int(0)); params = get_value(&__destr_tmp, &Value::Int(1)); }
if !is_equal(&symbol, &Value::Null) {
market = self.market(symbol.clone());
stock = self.safe_bool_k(market.clone(), "stock", &[Value::Bool(false)]);
add_element_to_object(&mut request, &Value::Str("symbol".to_string()), get_value(&market, &Value::Str("id".to_string())));
} else if !is_true(&stock) {
panic!("{}", crate::exchange_errors::arguments_required(add(&self.id, &Value::Str(" fetchOrders() requires a symbol argument".to_string()))));
}
let mut type_var: Value = Value::Null;
{ let __destr_tmp = self.handle_market_type_and_params(Value::Str("fetchOrders".to_string()), &[market.clone(), params.clone(), Value::Str("spot".to_string())]); type_var = get_value(&__destr_tmp, &Value::Int(0)); params = get_value(&__destr_tmp, &Value::Int(1)); }
let mut subType: Value = Value::Null;
{ let __destr_tmp = self.handle_sub_type_and_params(Value::Str("fetchOrders".to_string()), &[market.clone(), params.clone()]); subType = get_value(&__destr_tmp, &Value::Int(0)); params = get_value(&__destr_tmp, &Value::Int(1)); }
let mut marginMode: Value = Value::Null;
{ let __destr_tmp = self.handle_margin_mode_and_params(Value::Str("fetchOrders".to_string()), &[params.clone()]); marginMode = get_value(&__destr_tmp, &Value::Int(0)); params = get_value(&__destr_tmp, &Value::Int(1)); }
let mut isPortfolioMargin: Value = Value::Null;
{ let __destr_tmp = self.handle_option_and_params2(params.clone(), Value::Str("fetchOrders".to_string()), Value::Str("papi".to_string()), Value::Str("portfolioMargin".to_string()), &[Value::Bool(false)]); isPortfolioMargin = get_value(&__destr_tmp, &Value::Int(0)); params = get_value(&__destr_tmp, &Value::Int(1)); }
let mut isConditional: Value = self.safe_bool_n(params.clone(), Value::List(vec![Value::Str("stop".to_string()), Value::Str("trigger".to_string()), Value::Str("conditional".to_string())]), &[]);
let mut isOptionType: bool = is_equal(&type_var, &Value::Str("option".to_string()));
let mut isLinearType: Value = self.is_linear(type_var.clone(), &[subType.clone()]);
let mut isInverseType: Value = self.is_inverse(type_var.clone(), &[subType.clone()]);
let mut until: Value = self.safe_integer_n(params.clone(), Value::List(vec![Value::Str("until".to_string()), Value::Str("till".to_string()), Value::Str("endTime".to_string())]), &[]);
params = self.omit(params.clone(), Value::List(vec![Value::Str("stop".to_string()), Value::Str("trigger".to_string()), Value::Str("conditional".to_string()), Value::Str("until".to_string()), Value::Str("till".to_string()), Value::Str("endTime".to_string())]), &[]);
if !is_equal(&since, &Value::Null) {
add_element_to_object(&mut request, &Value::Str("startTime".to_string()), since.clone());
}
if !is_equal(&limit, &Value::Null) {
if is_equal(&stock, &Value::Bool(true)) {
limit = crate::runtime::Math::min(&limit, &Value::Int(100)); // max 100
add_element_to_object(&mut request, &Value::Str("size".to_string()), limit.clone());
} else {
add_element_to_object(&mut request, &Value::Str("limit".to_string()), limit.clone());
}
}
if !is_equal(&until, &Value::Null) {
add_element_to_object(&mut request, &Value::Str("endTime".to_string()), until.clone());
}
if is_equal(&stock, &Value::Bool(true)) {
if is_equal(&until, &Value::Null) {
until = self.milliseconds();
add_element_to_object(&mut request, &Value::Str("endTime".to_string()), until.clone());
}
if is_equal(&since, &Value::Null) {
let mut oneWeek: Value = multiply(&multiply(&multiply(&multiply(&Value::Int(7), &Value::Int(24)), &Value::Int(60)), &Value::Int(60)), &Value::Int(1000));
add_element_to_object(&mut request, &Value::Str("startTime".to_string()), subtract(&until, &oneWeek));
}
}
let mut response: Value = Value::Null;
if is_true(&isOptionType) {
let __ws_arg_67 = self.extend(request.clone(), &[params.clone()]);
response = self.eapi_private_get_history_orders(&[__ws_arg_67]).await;
} else if is_true(&isLinearType) {
if is_true(&isPortfolioMargin) {
if is_equal(&isConditional, &Value::Bool(true)) {
let __ws_arg_68 = self.extend(request.clone(), &[params.clone()]);
response = self.papi_get_um_conditional_all_orders(&[__ws_arg_68]).await;
} else {
let __ws_arg_69 = self.extend(request.clone(), &[params.clone()]);
response = self.papi_get_um_all_orders(&[__ws_arg_69]).await;
}
} else {
if is_equal(&isConditional, &Value::Bool(true)) {
let __ws_arg_70 = self.extend(request.clone(), &[params.clone()]);
response = self.fapi_private_get_all_algo_orders(&[__ws_arg_70]).await;
} else {
let __ws_arg_71 = self.extend(request.clone(), &[params.clone()]);
response = self.fapi_private_get_all_orders(&[__ws_arg_71]).await;
}
}
} else if is_true(&isInverseType) {
if is_true(&isPortfolioMargin) {
if is_equal(&isConditional, &Value::Bool(true)) {
let __ws_arg_72 = self.extend(request.clone(), &[params.clone()]);
response = self.papi_get_cm_conditional_all_orders(&[__ws_arg_72]).await;
} else {
let __ws_arg_73 = self.extend(request.clone(), &[params.clone()]);
response = self.papi_get_cm_all_orders(&[__ws_arg_73]).await;
}
} else {
let __ws_arg_74 = self.extend(request.clone(), &[params.clone()]);
response = self.dapi_private_get_all_orders(&[__ws_arg_74]).await;
}
} else {
if is_true(&isPortfolioMargin) {
let __ws_arg_75 = self.extend(request.clone(), &[params.clone()]);
response = self.papi_get_margin_all_orders(&[__ws_arg_75]).await;
} else if is_equal(&type_var, &Value::Str("margin".to_string())) || !is_equal(&marginMode, &Value::Null) {
if is_equal(&marginMode, &Value::Str("isolated".to_string())) {
add_element_to_object(&mut request, &Value::Str("isIsolated".to_string()), Value::Bool(true));
}
let __ws_arg_76 = self.extend(request.clone(), &[params.clone()]);
response = self.sapi_get_margin_all_orders(&[__ws_arg_76]).await;
} else if is_equal(&stock, &Value::Bool(true)) {
let __ws_arg_77 = self.extend(request.clone(), &[params.clone()]);
response = self.sapi_get_equity_order_history(&[__ws_arg_77]).await;
} else {
let __ws_arg_78 = self.extend(request.clone(), &[params.clone()]);
response = self.private_get_all_orders(&[__ws_arg_78]).await;
}
}
//
// spot
//
// [
// {
// "symbol": "LTCBTC",
// "orderId": 1,
// "clientOrderId": "myOrder1",
// "price": "0.1",
// "origQty": "1.0",
// "executedQty": "0.0",
// "cummulativeQuoteQty": "0.0",
// "status": "NEW",
// "timeInForce": "GTC",
// "type": "LIMIT",
// "side": "BUY",
// "stopPrice": "0.0",
// "icebergQty": "0.0",
// "time": 1499827319559,
// "updateTime": 1499827319559,
// "isWorking": true
// }
// ]
//
// futures
//
// [
// {
// "symbol": "BTCUSDT",
// "orderId": 1,
// "clientOrderId": "myOrder1",
// "price": "0.1",
// "origQty": "1.0",
// "executedQty": "1.0",
// "cumQuote": "10.0",
// "status": "NEW",
// "timeInForce": "GTC",
// "type": "LIMIT",
// "side": "BUY",
// "stopPrice": "0.0",
// "updateTime": 1499827319559
// }
// ]
//
// options
//
// [
// {
// "orderId": 4728833085436977152,
// "symbol": "ETH-230211-1500-C",
// "price": "10.0",
// "quantity": "1.00",
// "executedQty": "0.00",
// "fee": "0",
// "side": "BUY",
// "type": "LIMIT",
// "timeInForce": "GTC",
// "reduceOnly": false,
// "postOnly": false,
// "createTime": 1676083034462,
// "updateTime": 1676083034462,
// "status": "ACCEPTED",
// "avgPrice": "0",
// "source": "API",
// "clientOrderId": "",
// "priceScale": 1,
// "quantityScale": 2,
// "optionSide": "CALL",
// "quoteAsset": "USDT",
// "lastTrade": {"id":"69","time":"1676084430567","price":"24.9","qty":"1.00"},
// "mmp": false
// }
// ]
//
// inverse portfolio margin
//
// [
// {
// "orderId": 71328442983,
// "symbol": "ETHUSD_PERP",
// "pair": "ETHUSD",
// "status": "CANCELED",
// "clientOrderId": "x-xcKtGhcu4b3e3d8515dd4dc5ba9ccc",
// "price": "2000",
// "avgPrice": "0.00",
// "origQty": "1",
// "executedQty": "0",
// "cumBase": "0",
// "timeInForce": "GTC",
// "type": "LIMIT",
// "reduceOnly": false,
// "side": "BUY",
// "origType": "LIMIT",
// "time": 1707197843046,
// "updateTime": 1707197941373,
// "positionSide": "BOTH"
// },
// ]
//
// linear portfolio margin
//
// [
// {
// "orderId": 259235347005,
// "symbol": "BTCUSDT",
// "status": "CANCELED",
// "clientOrderId": "x-xcKtGhcu402881c9103f42bdb4183b",
// "price": "35000",
// "avgPrice": "0.00000",
// "origQty": "0.010",
// "executedQty": "0",
// "cumQuote": "0",
// "timeInForce": "GTC",
// "type": "LIMIT",
// "reduceOnly": false,
// "side": "BUY",
// "origType": "LIMIT",
// "time": 1707194702167,
// "updateTime": 1707197804748,
// "positionSide": "BOTH",
// "selfTradePreventionMode": "NONE",
// "goodTillDate": 0
// },
// ]
//
// conditional portfolio margin
//
// [
// {
// "newClientStrategyId": "x-xcKtGhcuaf166172ed504cd1bc0396",
// "strategyId": 3733211,
// "strategyStatus": "CANCELLED",
// "strategyType": "STOP",
// "origQty": "0.010",
// "price": "35000",
// "orderId": 0,
// "reduceOnly": false,
// "side": "BUY",
// "positionSide": "BOTH",
// "stopPrice": "50000",
// "symbol": "BTCUSDT",
// "type": "LIMIT",
// "bookTime": 1707270098774,
// "updateTime": 1707270119261,
// "timeInForce": "GTC",
// "triggerTime": 0,
// "workingType": "CONTRACT_PRICE",
// "priceProtect": false,
// "goodTillDate": 0,
// "selfTradePreventionMode": "NONE"
// },
// ]
//
// spot margin portfolio margin
//
// [
// {
// "symbol": "BTCUSDT",
// "orderId": 24684460474,
// "clientOrderId": "x-TKT5PX2Fe9ef29d8346440f0b28b86",
// "price": "35000.00000000",
// "origQty": "0.00100000",
// "executedQty": "0.00000000",
// "cummulativeQuoteQty": "0.00000000",
// "status": "CANCELED",
// "timeInForce": "GTC",
// "type": "LIMIT",
// "side": "BUY",
// "stopPrice": "0.00000000",
// "icebergQty": "0.00000000",
// "time": 1707113538870,
// "updateTime": 1707113797688,
// "isWorking": true,
// "accountId": 200180970,
// "selfTradePreventionMode": "EXPIRE_MAKER",
// "preventedMatchId": null,
// "preventedQuantity": null
// },
// ]
//
// stock
//
// {
// "page": 1,
// "size": 20,
// "total": 2,
// "rows": [
// {
// "orderId": "1ef94d47-0c95-4785-9834-37376312834e",
// "symbol": "AAPL",
// "quote": "USDC",
// "side": "BUY",
// "orderType": "LIMIT",
// "limitPrice": "290",
// "qty": "0.05",
// "filledQty": "0",
// "filledTotal": "0",
// "fee": "0",
// "session": "24H",
// "status": "CANCELED",
// "createdAt": 1785925755841,
// "updatedAt": 1785925792975
// },
// ]
// }
//
if is_equal(&stock, &Value::Bool(true)) {
let mut result: Value = self.safe_list_k(response.clone(), "rows", &[Value::List(vec![])]);
return self.parse_orders(result.clone(), &[market.clone(), since.clone(), limit.clone()]);
}
return self.parse_orders(response.clone(), &[market.clone(), since.clone(), limit.clone()]);
Value::Null
}
/*
* @method
* @name binance#fetchOpenOrders
* @description fetch all unfilled currently open orders
* @see https://developers.binance.com/docs/binance-spot-api-docs/rest-api/trading-endpoints#current-open-orders-user_data
* @see https://developers.binance.com/docs/derivatives/usds-margined-futures/trade/rest-api/Current-All-Open-Orders
* @see https://developers.binance.com/docs/derivatives/coin-margined-futures/trade/rest-api/Current-All-Open-Orders
* @see https://developers.binance.com/docs/derivatives/option/trade/Query-Current-Open-Option-Orders
* @see https://developers.binance.com/docs/margin_trading/trade/Query-Margin-Account-Open-Orders
* @see https://developers.binance.com/docs/derivatives/portfolio-margin/trade/Query-All-Current-UM-Open-Orders
* @see https://developers.binance.com/docs/derivatives/portfolio-margin/trade/Query-All-Current-UM-Open-Conditional-Orders
* @see https://developers.binance.com/docs/derivatives/portfolio-margin/trade/Query-All-Current-CM-Open-Orders
* @see https://developers.binance.com/docs/derivatives/portfolio-margin/trade/Query-All-Current-CM-Open-Conditional-Orders
* @see https://developers.binance.com/docs/derivatives/usds-margined-futures/trade/rest-api/Current-All-Algo-Open-Orders
* @see https://developers.binance.com/en/docs/catalog/advanced-trading-stocks-trading/api/rest-api/trade#current-open-orders
* @param {string} [symbol] unified market symbol
* @param {int} [since] the earliest time in ms to fetch open orders for
* @param {int} [limit] the maximum number of open orders structures to retrieve
* @param {object} [params] extra parameters specific to the exchange API endpoint
* @param {string} [params.marginMode] 'cross' or 'isolated', for spot margin trading
* @param {boolean} [params.portfolioMargin] set to true if you would like to fetch open orders in the portfolio margin account
* @param {boolean} [params.trigger] set to true if you would like to fetch portfolio margin account conditional orders
* @param {boolean} [params.stock] set to true if you would like to fetch tokenized stock orders
* @param {string} [params.subType] "linear" or "inverse"
* @returns {Order[]} a list of [order structures]{@link https://docs.ccxt.com/?id=order-structure}
*/
pub async fn fetch_open_orders(&mut self, optional_args: &[Value]) -> Value {
let mut symbol = get_arg(optional_args, 0, Value::Null);
let mut since = get_arg(optional_args, 1, Value::Null);
let mut limit = get_arg(optional_args, 2, Value::Null);
let mut params = get_arg(optional_args, 3, Value::Map({
let mut m = indexmap::IndexMap::new();
m
}));
if is_equal(&self.markets, &Value::Null) {
self.load_markets(&[]).await;
}
let mut market: Value = Value::Null;
let mut type_var: Value = Value::Null;
let mut request: Value = Value::Map({
let mut m = indexmap::IndexMap::new();
m
});
let mut marginMode: Value = Value::Null;
{ let __destr_tmp = self.handle_margin_mode_and_params(Value::Str("fetchOpenOrders".to_string()), &[params.clone()]); marginMode = get_value(&__destr_tmp, &Value::Int(0)); params = get_value(&__destr_tmp, &Value::Int(1)); }
let mut isPortfolioMargin: Value = Value::Null;
{ let __destr_tmp = self.handle_option_and_params2(params.clone(), Value::Str("fetchOpenOrders".to_string()), Value::Str("papi".to_string()), Value::Str("portfolioMargin".to_string()), &[Value::Bool(false)]); isPortfolioMargin = get_value(&__destr_tmp, &Value::Int(0)); params = get_value(&__destr_tmp, &Value::Int(1)); }
let mut isConditional: Value = self.safe_bool_n(params.clone(), Value::List(vec![Value::Str("stop".to_string()), Value::Str("trigger".to_string()), Value::Str("conditional".to_string())]), &[]);
let mut stock: Value = Value::Null;
{ let __destr_tmp = self.handle_option_and_params(params.clone(), Value::Str("fetchOpenOrders".to_string()), Value::Str("stock".to_string()), &[Value::Bool(false)]); stock = get_value(&__destr_tmp, &Value::Int(0)); params = get_value(&__destr_tmp, &Value::Int(1)); }
if !is_equal(&symbol, &Value::Null) {
market = self.market(symbol.clone());
stock = self.safe_bool_k(market.clone(), "stock", &[Value::Bool(false)]);
if !is_equal(&stock, &Value::Bool(true)) {
add_element_to_object(&mut request, &Value::Str("symbol".to_string()), get_value(&market, &Value::Str("id".to_string())));
}
} else if !is_true(&stock) {
let mut warnWithoutSymbol: Value = self.safe_bool(get_value(&self.options, &Value::Str("fetchOpenOrders".to_string())), Value::Str("warnWithoutSymbol".to_string()), &[]);
let mut optValue: Value = self.safe_bool_k(self.options.clone(), "warnOnFetchOpenOrdersWithoutSymbol", &[]); // for backward compatibility
if is_true(&(is_equal(&optValue, &Value::Bool(true)))) || is_true(&(is_equal(&optValue, &Value::Null) && is_true(&(is_equal(&warnWithoutSymbol, &Value::Bool(true)))))) {
panic!("{}", crate::exchange_errors::exchange_error(add(&add(&add(&self.id, &Value::Str(" fetchOpenOrders() WARNING: fetching open orders without specifying a symbol has stricter rate limits (10 times more for spot, 40 times more for other markets) compared to requesting with symbol argument. To acknowledge this warning, set ".to_string())), &self.id), &Value::Str(".options[\"fetchOpenOrders\"][\"warnWithoutSymbol\"] = false to suppress this warning message.".to_string()))));
}
}
{ let __destr_tmp = self.handle_market_type_and_params(Value::Str("fetchOpenOrders".to_string()), &[market.clone(), params.clone(), Value::Str("spot".to_string())]); type_var = get_value(&__destr_tmp, &Value::Int(0)); params = get_value(&__destr_tmp, &Value::Int(1)); }
let mut subType: Value = Value::Null;
{ let __destr_tmp = self.handle_sub_type_and_params(Value::Str("fetchOpenOrders".to_string()), &[market.clone(), params.clone()]); subType = get_value(&__destr_tmp, &Value::Int(0)); params = get_value(&__destr_tmp, &Value::Int(1)); }
params = self.omit(params.clone(), Value::List(vec![Value::Str("stop".to_string()), Value::Str("trigger".to_string()), Value::Str("conditional".to_string())]), &[]);
let mut response: Value = Value::Null;
if is_equal(&type_var, &Value::Str("option".to_string())) {
if !is_equal(&since, &Value::Null) {
add_element_to_object(&mut request, &Value::Str("startTime".to_string()), since.clone());
}
if !is_equal(&limit, &Value::Null) {
add_element_to_object(&mut request, &Value::Str("limit".to_string()), limit.clone());
}
let __ws_arg_79 = self.extend(request.clone(), &[params.clone()]);
response = self.eapi_private_get_open_orders(&[__ws_arg_79]).await;
} else if is_true(&self.is_linear(type_var.clone(), &[subType.clone()])) {
if is_true(&isPortfolioMargin) {
if is_equal(&isConditional, &Value::Bool(true)) {
let __ws_arg_80 = self.extend(request.clone(), &[params.clone()]);
response = self.papi_get_um_conditional_open_orders(&[__ws_arg_80]).await;
} else {
let __ws_arg_81 = self.extend(request.clone(), &[params.clone()]);
response = self.papi_get_um_open_orders(&[__ws_arg_81]).await;
}
} else {
if is_equal(&isConditional, &Value::Bool(true)) {
let __ws_arg_82 = self.extend(request.clone(), &[params.clone()]);
response = self.fapi_private_get_open_algo_orders(&[__ws_arg_82]).await;
} else {
let __ws_arg_83 = self.extend(request.clone(), &[params.clone()]);
response = self.fapi_private_get_open_orders(&[__ws_arg_83]).await;
}
}
} else if is_true(&self.is_inverse(type_var.clone(), &[subType.clone()])) {
if is_true(&isPortfolioMargin) {
if is_equal(&isConditional, &Value::Bool(true)) {
let __ws_arg_84 = self.extend(request.clone(), &[params.clone()]);
response = self.papi_get_cm_conditional_open_orders(&[__ws_arg_84]).await;
} else {
let __ws_arg_85 = self.extend(request.clone(), &[params.clone()]);
response = self.papi_get_cm_open_orders(&[__ws_arg_85]).await;
}
} else {
if is_equal(&isConditional, &Value::Bool(true)) {
let __ws_arg_86 = self.extend(request.clone(), &[params.clone()]);
response = self.dapi_private_get_open_algo_orders(&[__ws_arg_86]).await;
} else {
let __ws_arg_87 = self.extend(request.clone(), &[params.clone()]);
response = self.dapi_private_get_open_orders(&[__ws_arg_87]).await;
}
}
} else if is_equal(&type_var, &Value::Str("margin".to_string())) || !is_equal(&marginMode, &Value::Null) || is_true(&isPortfolioMargin) {
if is_true(&isPortfolioMargin) {
let __ws_arg_88 = self.extend(request.clone(), &[params.clone()]);
response = self.papi_get_margin_open_orders(&[__ws_arg_88]).await;
} else {
if is_equal(&marginMode, &Value::Str("isolated".to_string())) {
add_element_to_object(&mut request, &Value::Str("isIsolated".to_string()), Value::Bool(true));
if is_equal(&symbol, &Value::Null) {
panic!("{}", crate::exchange_errors::arguments_required(add(&self.id, &Value::Str(" fetchOpenOrders() requires a symbol argument for isolated markets".to_string()))));
}
}
let __ws_arg_89 = self.extend(request.clone(), &[params.clone()]);
response = self.sapi_get_margin_open_orders(&[__ws_arg_89]).await;
}
} else if is_equal(&stock, &Value::Bool(true)) {
let __ws_arg_90 = self.extend(request.clone(), &[params.clone()]);
response = self.sapi_get_equity_order_open_orders(&[__ws_arg_90]).await;
} else {
let __ws_arg_91 = self.extend(request.clone(), &[params.clone()]);
response = self.private_get_open_orders(&[__ws_arg_91]).await;
}
return self.parse_orders(response.clone(), &[market.clone(), since.clone(), limit.clone()]);
Value::Null
}
/*
* @method
* @name binance#fetchOpenOrder
* @description fetch an open order by the id
* @see https://developers.binance.com/docs/derivatives/usds-margined-futures/trade/rest-api/Query-Current-Open-Order
* @see https://developers.binance.com/docs/derivatives/coin-margined-futures/trade/rest-api/Query-Current-Open-Order
* @see https://developers.binance.com/docs/derivatives/portfolio-margin/trade/Query-Current-UM-Open-Order
* @see https://developers.binance.com/docs/derivatives/portfolio-margin/trade/Query-Current-UM-Open-Conditional-Order
* @see https://developers.binance.com/docs/derivatives/portfolio-margin/trade/Query-Current-CM-Open-Order
* @see https://developers.binance.com/docs/derivatives/portfolio-margin/trade/Query-Current-CM-Open-Conditional-Order
* @param {string} id order id
* @param {string} symbol unified market symbol
* @param {object} [params] extra parameters specific to the exchange API endpoint
* @param {string} [params.trigger] set to true if you would like to fetch portfolio margin account stop or conditional orders
* @param {boolean} [params.portfolioMargin] set to true if you would like to fetch for a portfolio margin account
* @returns {object} an [order structure]{@link https://docs.ccxt.com/?id=order-structure}
*/
pub async fn fetch_open_order(&mut self, mut id: Value, optional_args: &[Value]) -> Value {
let mut symbol = get_arg(optional_args, 0, Value::Null);
let mut params = get_arg(optional_args, 1, Value::Map({
let mut m = indexmap::IndexMap::new();
m
}));
if is_equal(&symbol, &Value::Null) {
panic!("{}", crate::exchange_errors::arguments_required(add(&self.id, &Value::Str(" fetchOpenOrder() requires a symbol argument".to_string()))));
}
if is_equal(&self.markets, &Value::Null) {
self.load_markets(&[]).await;
}
let mut market: Value = self.market(symbol.clone());
let mut request: Value = Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("symbol".to_string(), get_value(&market, &Value::Str("id".to_string())));
m
});
let mut isPortfolioMargin: Value = Value::Null;
{ let __destr_tmp = self.handle_option_and_params2(params.clone(), Value::Str("fetchOpenOrder".to_string()), Value::Str("papi".to_string()), Value::Str("portfolioMargin".to_string()), &[Value::Bool(false)]); isPortfolioMargin = get_value(&__destr_tmp, &Value::Int(0)); params = get_value(&__destr_tmp, &Value::Int(1)); }
let mut isConditional: Value = self.safe_bool_n(params.clone(), Value::List(vec![Value::Str("stop".to_string()), Value::Str("trigger".to_string()), Value::Str("conditional".to_string())]), &[]);
params = self.omit(params.clone(), Value::List(vec![Value::Str("stop".to_string()), Value::Str("trigger".to_string()), Value::Str("conditional".to_string())]), &[]);
let mut isPortfolioMarginConditional: Value = Value::Bool(is_true(&isPortfolioMargin) && is_true(&isConditional));
let mut orderIdRequest: Value = ternary(is_true(&(is_equal(&isPortfolioMarginConditional, &Value::Bool(true)))), Value::Str("strategyId".to_string()), Value::Str("orderId".to_string()));
add_element_to_object(&mut request, &orderIdRequest, id.clone());
let mut response: Value = Value::Null;
if is_equal(&get_value(&market, &Value::Str("linear".to_string())), &Value::Bool(true)) {
if is_true(&isPortfolioMargin) {
if is_equal(&isConditional, &Value::Bool(true)) {
let __ws_arg_92 = self.extend(request.clone(), &[params.clone()]);
response = self.papi_get_um_conditional_open_order(&[__ws_arg_92]).await;
} else {
let __ws_arg_93 = self.extend(request.clone(), &[params.clone()]);
response = self.papi_get_um_open_order(&[__ws_arg_93]).await;
}
} else {
let __ws_arg_94 = self.extend(request.clone(), &[params.clone()]);
response = self.fapi_private_get_open_order(&[__ws_arg_94]).await;
}
} else if is_equal(&get_value(&market, &Value::Str("inverse".to_string())), &Value::Bool(true)) {
if is_true(&isPortfolioMargin) {
if is_equal(&isConditional, &Value::Bool(true)) {
let __ws_arg_95 = self.extend(request.clone(), &[params.clone()]);
response = self.papi_get_cm_conditional_open_order(&[__ws_arg_95]).await;
} else {
let __ws_arg_96 = self.extend(request.clone(), &[params.clone()]);
response = self.papi_get_cm_open_order(&[__ws_arg_96]).await;
}
} else {
let __ws_arg_97 = self.extend(request.clone(), &[params.clone()]);
response = self.dapi_private_get_open_order(&[__ws_arg_97]).await;
}
} else {
if is_equal(&get_value(&market, &Value::Str("option".to_string())), &Value::Bool(true)) {
panic!("{}", crate::exchange_errors::not_supported(add(&self.id, &Value::Str(" fetchOpenOrder() does not support option markets".to_string()))));
} else if is_equal(&get_value(&market, &Value::Str("spot".to_string())), &Value::Bool(true)) {
panic!("{}", crate::exchange_errors::not_supported(add(&self.id, &Value::Str(" fetchOpenOrder() does not support spot markets".to_string()))));
}
}
//
// linear swap
//
// {
// "orderId": 3697213934,
// "symbol": "BTCUSDT",
// "status": "NEW",
// "clientOrderId": "x-xcKtGhcufb20c5a7761a4aa09aa156",
// "price": "33000.00",
// "avgPrice": "0.00000",
// "origQty": "0.010",
// "executedQty": "0.000",
// "cumQuote": "0.00000",
// "timeInForce": "GTC",
// "type": "LIMIT",
// "reduceOnly": false,
// "closePosition": false,
// "side": "BUY",
// "positionSide": "BOTH",
// "stopPrice": "0.00",
// "workingType": "CONTRACT_PRICE",
// "priceProtect": false,
// "origType": "LIMIT",
// "priceMatch": "NONE",
// "selfTradePreventionMode": "NONE",
// "goodTillDate": 0,
// "time": 1707892893502,
// "updateTime": 1707892893515
// }
//
// inverse swap
//
// {
// "orderId": 597368542,
// "symbol": "BTCUSD_PERP",
// "pair": "BTCUSD",
// "status": "NEW",
// "clientOrderId": "x-xcKtGhcubbde7ba93b1a4ab881eff3",
// "price": "35000",
// "avgPrice": "0",
// "origQty": "1",
// "executedQty": "0",
// "cumBase": "0",
// "timeInForce": "GTC",
// "type": "LIMIT",
// "reduceOnly": false,
// "closePosition": false,
// "side": "BUY",
// "positionSide": "BOTH",
// "stopPrice": "0",
// "workingType": "CONTRACT_PRICE",
// "priceProtect": false,
// "origType": "LIMIT",
// "time": 1707893453199,
// "updateTime": 1707893453199
// }
//
// linear portfolio margin
//
// {
// "orderId": 264895013409,
// "symbol": "BTCUSDT",
// "status": "NEW",
// "clientOrderId": "x-xcKtGhcu6278f1adbdf14f74ab432e",
// "price": "35000",
// "avgPrice": "0",
// "origQty": "0.010",
// "executedQty": "0",
// "cumQuote": "0",
// "timeInForce": "GTC",
// "type": "LIMIT",
// "reduceOnly": false,
// "side": "BUY",
// "positionSide": "LONG",
// "origType": "LIMIT",
// "time": 1707893839364,
// "updateTime": 1707893839364,
// "goodTillDate": 0,
// "selfTradePreventionMode": "NONE"
// }
//
// inverse portfolio margin
//
// {
// "orderId": 71790316950,
// "symbol": "ETHUSD_PERP",
// "pair": "ETHUSD",
// "status": "NEW",
// "clientOrderId": "x-xcKtGhcuec11030474204ab08ba2c2",
// "price": "2500",
// "avgPrice": "0",
// "origQty": "1",
// "executedQty": "0",
// "cumBase": "0",
// "timeInForce": "GTC",
// "type": "LIMIT",
// "reduceOnly": false,
// "side": "BUY",
// "positionSide": "LONG",
// "origType": "LIMIT",
// "time": 1707894181694,
// "updateTime": 1707894181694
// }
//
// linear portfolio margin conditional
//
// {
// "newClientStrategyId": "x-xcKtGhcu2205fde44418483ca21874",
// "strategyId": 4084339,
// "strategyStatus": "NEW",
// "strategyType": "STOP",
// "origQty": "0.010",
// "price": "35000",
// "reduceOnly": false,
// "side": "BUY",
// "positionSide": "LONG",
// "stopPrice": "60000",
// "symbol": "BTCUSDT",
// "bookTime": 1707894490094,
// "updateTime": 1707894490094,
// "timeInForce": "GTC",
// "workingType": "CONTRACT_PRICE",
// "priceProtect": false,
// "goodTillDate": 0,
// "selfTradePreventionMode": "NONE"
// }
//
// inverse portfolio margin conditional
//
// {
// "newClientStrategyId": "x-xcKtGhcu2da9c765294b433994ffce",
// "strategyId": 1423501,
// "strategyStatus": "NEW",
// "strategyType": "STOP",
// "origQty": "1",
// "price": "2500",
// "reduceOnly": false,
// "side": "BUY",
// "positionSide": "LONG",
// "stopPrice": "4000",
// "symbol": "ETHUSD_PERP",
// "bookTime": 1707894782679,
// "updateTime": 1707894782679,
// "timeInForce": "GTC",
// "workingType": "CONTRACT_PRICE",
// "priceProtect": false
// }
//
if is_equal(&response, &Value::Null) {
panic!("{}", crate::exchange_errors::null_response(add(&self.id, &Value::Str(" parseOrder() returned empty response".to_string()))));
}
return self.parse_order(response.clone(), &[market.clone()]);
Value::Null
}
/*
* @method
* @name binance#fetchClosedOrders
* @description fetches information on multiple closed orders made by the user
* @see https://developers.binance.com/docs/binance-spot-api-docs/rest-api/trading-endpoints#all-orders-user_data
* @see https://developers.binance.com/docs/derivatives/usds-margined-futures/trade/rest-api/All-Orders
* @see https://developers.binance.com/docs/derivatives/coin-margined-futures/trade/rest-api/All-Orders
* @see https://developers.binance.com/docs/derivatives/option/trade/Query-Option-Order-History
* @see https://developers.binance.com/docs/margin_trading/trade/Query-Margin-Account-All-Orders
* @see https://developers.binance.com/docs/derivatives/portfolio-margin/trade/Query-All-UM-Orders
* @see https://developers.binance.com/docs/derivatives/portfolio-margin/trade/Query-All-CM-Orders
* @see https://developers.binance.com/docs/derivatives/portfolio-margin/trade/Query-All-UM-Conditional-Orders
* @see https://developers.binance.com/docs/derivatives/portfolio-margin/trade/Query-All-CM-Conditional-Orders
* @see https://developers.binance.com/en/docs/catalog/advanced-trading-stocks-trading/api/rest-api/trade#equity-order-history
* @param {string} [symbol] unified market symbol of the market orders were made in
* @param {int} [since] the earliest time in ms to fetch orders for
* @param {int} [limit] the maximum number of order structures to retrieve
* @param {object} [params] extra parameters specific to the exchange API endpoint
* @param {boolean} [params.paginate] default false, when true will automatically paginate by calling this endpoint multiple times. See in the docs all the [available parameters](https://github.com/ccxt/ccxt/wiki/Manual#pagination-params)
* @param {boolean} [params.portfolioMargin] set to true if you would like to fetch orders in a portfolio margin account
* @param {boolean} [params.trigger] set to true if you would like to fetch portfolio margin account trigger or conditional orders
* @param {boolean} [params.stock] set to true if you would like to fetch tokenized stock orders
* @returns {Order[]} a list of [order structures]{@link https://docs.ccxt.com/?id=order-structure}
*/
pub async fn fetch_closed_orders(&mut self, optional_args: &[Value]) -> Value {
let mut symbol = get_arg(optional_args, 0, Value::Null);
let mut since = get_arg(optional_args, 1, Value::Null);
let mut limit = get_arg(optional_args, 2, Value::Null);
let mut params = get_arg(optional_args, 3, Value::Map({
let mut m = indexmap::IndexMap::new();
m
}));
let mut market: Value = Value::Null;
let mut stock: Value = Value::Null;
{ let __destr_tmp = self.handle_option_and_params(params.clone(), Value::Str("fetchClosedOrders".to_string()), Value::Str("stock".to_string()), &[Value::Bool(false)]); stock = get_value(&__destr_tmp, &Value::Int(0)); params = get_value(&__destr_tmp, &Value::Int(1)); }
if !is_equal(&symbol, &Value::Null) {
market = self.market(symbol.clone());
stock = self.safe_bool_k(market.clone(), "stock", &[Value::Bool(false)]);
} else if !is_true(&stock) {
panic!("{}", crate::exchange_errors::arguments_required(add(&self.id, &Value::Str(" fetchClosedOrders() requires a symbol argument".to_string()))));
}
if is_equal(&stock, &Value::Bool(true)) {
add_element_to_object(&mut params, &Value::Str("stock".to_string()), Value::Bool(true));
add_element_to_object(&mut params, &Value::Str("orderStatus".to_string()), Value::Str("FILLED".to_string()));
}
let mut orders: Value = self.fetch_orders(&[symbol.clone(), since.clone(), Value::Null, params.clone()]).await;
let mut filteredOrders: Value = self.filter_by(orders.clone(), Value::Str("status".to_string()), Value::Str("closed".to_string()), &[]);
return self.filter_by_since_limit(filteredOrders.clone(), &[since.clone(), limit.clone()]);
Value::Null
}
/*
* @method
* @name binance#fetchCanceledOrders
* @description fetches information on multiple canceled orders made by the user
* @see https://developers.binance.com/docs/binance-spot-api-docs/rest-api/trading-endpoints#all-orders-user_data
* @see https://developers.binance.com/docs/derivatives/usds-margined-futures/trade/rest-api/All-Orders
* @see https://developers.binance.com/docs/derivatives/coin-margined-futures/trade/rest-api/All-Orders
* @see https://developers.binance.com/docs/derivatives/option/trade/Query-Option-Order-History
* @see https://developers.binance.com/docs/margin_trading/trade/Query-Margin-Account-All-Orders
* @see https://developers.binance.com/docs/derivatives/portfolio-margin/trade/Query-All-UM-Orders
* @see https://developers.binance.com/docs/derivatives/portfolio-margin/trade/Query-All-CM-Orders
* @see https://developers.binance.com/docs/derivatives/portfolio-margin/trade/Query-All-UM-Conditional-Orders
* @see https://developers.binance.com/docs/derivatives/portfolio-margin/trade/Query-All-CM-Conditional-Orders
* @see https://developers.binance.com/en/docs/catalog/advanced-trading-stocks-trading/api/rest-api/trade#equity-order-history
* @param {string} [symbol] unified market symbol of the market the orders were made in
* @param {int} [since] the earliest time in ms to fetch orders for
* @param {int} [limit] the maximum number of order structures to retrieve
* @param {object} [params] extra parameters specific to the exchange API endpoint
* @param {boolean} [params.paginate] default false, when true will automatically paginate by calling this endpoint multiple times. See in the docs all the [available parameters](https://github.com/ccxt/ccxt/wiki/Manual#pagination-params)
* @param {boolean} [params.portfolioMargin] set to true if you would like to fetch orders in a portfolio margin account
* @param {boolean} [params.trigger] set to true if you would like to fetch portfolio margin account trigger or conditional orders
* @param {boolean} [params.stock] set to true if you would like to fetch tokenized stock orders
* @returns {object[]} a list of [order structures]{@link https://docs.ccxt.com/?id=order-structure}
*/
pub async fn fetch_canceled_orders(&mut self, optional_args: &[Value]) -> Value {
let mut symbol = get_arg(optional_args, 0, Value::Null);
let mut since = get_arg(optional_args, 1, Value::Null);
let mut limit = get_arg(optional_args, 2, Value::Null);
let mut params = get_arg(optional_args, 3, Value::Map({
let mut m = indexmap::IndexMap::new();
m
}));
let mut market: Value = Value::Null;
let mut stock: Value = Value::Null;
{ let __destr_tmp = self.handle_option_and_params(params.clone(), Value::Str("fetchCanceledOrders".to_string()), Value::Str("stock".to_string()), &[Value::Bool(false)]); stock = get_value(&__destr_tmp, &Value::Int(0)); params = get_value(&__destr_tmp, &Value::Int(1)); }
if !is_equal(&symbol, &Value::Null) {
market = self.market(symbol.clone());
stock = self.safe_bool_k(market.clone(), "stock", &[Value::Bool(false)]);
} else if !is_true(&stock) {
panic!("{}", crate::exchange_errors::arguments_required(add(&self.id, &Value::Str(" fetchCanceledOrders() requires a symbol argument".to_string()))));
}
if is_equal(&stock, &Value::Bool(true)) {
add_element_to_object(&mut params, &Value::Str("stock".to_string()), Value::Bool(true));
add_element_to_object(&mut params, &Value::Str("orderStatus".to_string()), Value::Str("CANCELED".to_string()));
}
let mut orders: Value = self.fetch_orders(&[symbol.clone(), since.clone(), Value::Null, params.clone()]).await;
let mut filteredOrders: Value = self.filter_by(orders.clone(), Value::Str("status".to_string()), Value::Str("canceled".to_string()), &[]);
return self.filter_by_since_limit(filteredOrders.clone(), &[since.clone(), limit.clone()]);
Value::Null
}
/*
* @method
* @name binance#fetchCanceledAndClosedOrders
* @description fetches information on multiple canceled orders made by the user
* @see https://developers.binance.com/docs/binance-spot-api-docs/rest-api/trading-endpoints#all-orders-user_data
* @see https://developers.binance.com/docs/derivatives/usds-margined-futures/trade/rest-api/All-Orders
* @see https://developers.binance.com/docs/derivatives/coin-margined-futures/trade/rest-api/All-Orders
* @see https://developers.binance.com/docs/derivatives/option/trade/Query-Option-Order-History
* @see https://developers.binance.com/docs/margin_trading/trade/Query-Margin-Account-All-Orders
* @see https://developers.binance.com/docs/derivatives/portfolio-margin/trade/Query-All-UM-Orders
* @see https://developers.binance.com/docs/derivatives/portfolio-margin/trade/Query-All-CM-Orders
* @see https://developers.binance.com/docs/derivatives/portfolio-margin/trade/Query-All-UM-Conditional-Orders
* @see https://developers.binance.com/docs/derivatives/portfolio-margin/trade/Query-All-CM-Conditional-Orders
* @see https://developers.binance.com/en/docs/catalog/advanced-trading-stocks-trading/api/rest-api/trade#equity-order-history
* @param {string} [symbol] unified market symbol of the market the orders were made in
* @param {int} [since] the earliest time in ms to fetch orders for
* @param {int} [limit] the maximum number of order structures to retrieve
* @param {object} [params] extra parameters specific to the exchange API endpoint
* @param {boolean} [params.paginate] default false, when true will automatically paginate by calling this endpoint multiple times. See in the docs all the [available parameters](https://github.com/ccxt/ccxt/wiki/Manual#pagination-params)
* @param {boolean} [params.portfolioMargin] set to true if you would like to fetch orders in a portfolio margin account
* @param {boolean} [params.trigger] set to true if you would like to fetch portfolio margin account trigger or conditional orders
* @param {boolean} [params.stock] set to true if you would like to fetch tokenized stock orders
* @returns {object[]} a list of [order structures]{@link https://docs.ccxt.com/?id=order-structure}
*/
pub async fn fetch_canceled_and_closed_orders(&mut self, optional_args: &[Value]) -> Value {
let mut symbol = get_arg(optional_args, 0, Value::Null);
let mut since = get_arg(optional_args, 1, Value::Null);
let mut limit = get_arg(optional_args, 2, Value::Null);
let mut params = get_arg(optional_args, 3, Value::Map({
let mut m = indexmap::IndexMap::new();
m
}));
let mut market: Value = Value::Null;
let mut stock: Value = Value::Null;
{ let __destr_tmp = self.handle_option_and_params(params.clone(), Value::Str("fetchCanceledAndClosedOrders".to_string()), Value::Str("stock".to_string()), &[Value::Bool(false)]); stock = get_value(&__destr_tmp, &Value::Int(0)); params = get_value(&__destr_tmp, &Value::Int(1)); }
if !is_equal(&symbol, &Value::Null) {
market = self.market(symbol.clone());
stock = self.safe_bool_k(market.clone(), "stock", &[Value::Bool(false)]);
} else if !is_true(&stock) {
panic!("{}", crate::exchange_errors::arguments_required(add(&self.id, &Value::Str(" fetchCanceledAndClosedOrders() requires a symbol argument".to_string()))));
}
if is_equal(&stock, &Value::Bool(true)) {
add_element_to_object(&mut params, &Value::Str("stock".to_string()), Value::Bool(true));
add_element_to_object(&mut params, &Value::Str("orderStatus".to_string()), Value::Str("FILLED,CANCELED".to_string()));
}
let mut orders: Value = self.fetch_orders(&[symbol.clone(), since.clone(), Value::Null, params.clone()]).await;
let mut canceledOrders: Value = self.filter_by(orders.clone(), Value::Str("status".to_string()), Value::Str("canceled".to_string()), &[]);
let mut closedOrders: Value = self.filter_by(orders.clone(), Value::Str("status".to_string()), Value::Str("closed".to_string()), &[]);
let mut filteredOrders: Value = self.array_concat(canceledOrders.clone(), closedOrders.clone());
let mut sortedOrders: Value = self.sort_by(filteredOrders.clone(), Value::Str("timestamp".to_string()), &[]);
return self.filter_by_since_limit(sortedOrders.clone(), &[since.clone(), limit.clone()]);
Value::Null
}
/*
* @method
* @name binance#cancelOrder
* @description cancels an open order
* @see https://developers.binance.com/docs/binance-spot-api-docs/rest-api/trading-endpoints#cancel-order-trade
* @see https://developers.binance.com/docs/derivatives/usds-margined-futures/trade/rest-api/Cancel-Order
* @see https://developers.binance.com/docs/derivatives/coin-margined-futures/trade/rest-api/Cancel-Order
* @see https://developers.binance.com/docs/derivatives/option/trade/Cancel-Option-Order
* @see https://developers.binance.com/docs/margin_trading/trade/Margin-Account-Cancel-Order
* @see https://developers.binance.com/docs/derivatives/portfolio-margin/trade/Cancel-UM-Order
* @see https://developers.binance.com/docs/derivatives/portfolio-margin/trade/Cancel-CM-Order
* @see https://developers.binance.com/docs/derivatives/portfolio-margin/trade/Cancel-UM-Conditional-Order
* @see https://developers.binance.com/docs/derivatives/portfolio-margin/trade/Cancel-CM-Conditional-Order
* @see https://developers.binance.com/docs/derivatives/portfolio-margin/trade/Cancel-Margin-Account-Order
* @see https://developers.binance.com/docs/derivatives/usds-margined-futures/trade/rest-api/Cancel-Algo-Order
* @see https://developers.binance.com/en/docs/catalog/advanced-trading-stocks-trading/api/rest-api/trade#cancel-equity-order
* @param {string} id order id
* @param {string} symbol unified symbol of the market the order was made in
* @param {object} [params] extra parameters specific to the exchange API endpoint
* @param {boolean} [params.portfolioMargin] set to true if you would like to cancel an order in a portfolio margin account
* @param {boolean} [params.trigger] set to true if you would like to cancel a portfolio margin account conditional order
* @param {boolean} [params.stock] set to true if you would like to cancel a tokenized stock order
* @returns {object} An [order structure]{@link https://docs.ccxt.com/?id=order-structure}
*/
pub async fn cancel_order(&mut self, mut id: Value, optional_args: &[Value]) -> Value {
let mut symbol = get_arg(optional_args, 0, Value::Null);
let mut params = get_arg(optional_args, 1, Value::Map({
let mut m = indexmap::IndexMap::new();
m
}));
if is_equal(&self.markets, &Value::Null) {
self.load_markets(&[]).await;
}
let mut request: Value = Value::Map({
let mut m = indexmap::IndexMap::new();
m
});
let mut market: Value = Value::Null;
let mut stock: Value = Value::Null;
{ let __destr_tmp = self.handle_option_and_params(params.clone(), Value::Str("cancelOrder".to_string()), Value::Str("stock".to_string()), &[Value::Bool(false)]); stock = get_value(&__destr_tmp, &Value::Int(0)); params = get_value(&__destr_tmp, &Value::Int(1)); }
if !is_equal(&symbol, &Value::Null) {
market = self.market(symbol.clone());
stock = self.safe_bool_k(market.clone(), "stock", &[Value::Bool(false)]);
if !is_equal(&stock, &Value::Bool(true)) {
add_element_to_object(&mut request, &Value::Str("symbol".to_string()), get_value(&market, &Value::Str("id".to_string())));
}
} else {
panic!("{}", crate::exchange_errors::arguments_required(add(&self.id, &Value::Str(" cancelOrder() requires a symbol argument".to_string()))));
}
let mut type_var: Value = Value::Null;
{ let __destr_tmp = self.handle_market_type_and_params(Value::Str("cancelOrder".to_string()), &[market.clone(), params.clone(), Value::Str("spot".to_string())]); type_var = get_value(&__destr_tmp, &Value::Int(0)); params = get_value(&__destr_tmp, &Value::Int(1)); }
let mut subType: Value = Value::Null;
{ let __destr_tmp = self.handle_sub_type_and_params(Value::Str("cancelOrder".to_string()), &[market.clone(), params.clone()]); subType = get_value(&__destr_tmp, &Value::Int(0)); params = get_value(&__destr_tmp, &Value::Int(1)); }
let mut marginMode: Value = Value::Null;
{ let __destr_tmp = self.handle_margin_mode_and_params(Value::Str("cancelOrder".to_string()), &[params.clone()]); marginMode = get_value(&__destr_tmp, &Value::Int(0)); params = get_value(&__destr_tmp, &Value::Int(1)); }
let mut isPortfolioMargin: Value = Value::Null;
{ let __destr_tmp = self.handle_option_and_params2(params.clone(), Value::Str("cancelOrder".to_string()), Value::Str("papi".to_string()), Value::Str("portfolioMargin".to_string()), &[Value::Bool(false)]); isPortfolioMargin = get_value(&__destr_tmp, &Value::Int(0)); params = get_value(&__destr_tmp, &Value::Int(1)); }
let mut isConditional: Value = self.safe_bool_n(params.clone(), Value::List(vec![Value::Str("stop".to_string()), Value::Str("trigger".to_string()), Value::Str("conditional".to_string())]), &[]);
let mut isOptionType: bool = is_equal(&type_var, &Value::Str("option".to_string()));
let mut isLinearType: Value = self.is_linear(type_var.clone(), &[subType.clone()]);
let mut isInverseType: Value = self.is_inverse(type_var.clone(), &[subType.clone()]);
let mut isSwapConditional: Value = Value::Bool(is_true(&(!is_equal(&market, &Value::Null))) && is_true(&(is_equal(&get_value(&market, &Value::Str("swap".to_string())), &Value::Bool(true)))) && is_true(&(is_equal(&isConditional, &Value::Bool(true)))) && is_true(&(!is_equal(&isPortfolioMargin, &Value::Bool(true)))));
let mut clientOrderId: Value = self.safe_string_n(params.clone(), Value::List(vec![Value::Str("origClientOrderId".to_string()), Value::Str("clientOrderId".to_string()), Value::Str("newClientStrategyId".to_string()), Value::Str("clientAlgoId".to_string())]), &[]);
if !is_equal(&clientOrderId, &Value::Null) {
if is_true(&isOptionType) {
add_element_to_object(&mut request, &Value::Str("clientOrderId".to_string()), clientOrderId.clone());
} else if is_equal(&isSwapConditional, &Value::Bool(true)) {
add_element_to_object(&mut request, &Value::Str("clientAlgoId".to_string()), clientOrderId.clone());
} else {
if is_true(&isPortfolioMargin) && is_true(&(is_equal(&isConditional, &Value::Bool(true)))) {
add_element_to_object(&mut request, &Value::Str("newClientStrategyId".to_string()), clientOrderId.clone());
} else {
add_element_to_object(&mut request, &Value::Str("origClientOrderId".to_string()), clientOrderId.clone());
}
}
} else {
if is_true(&isPortfolioMargin) && is_true(&(is_equal(&isConditional, &Value::Bool(true)))) {
add_element_to_object(&mut request, &Value::Str("strategyId".to_string()), id.clone());
} else if is_equal(&isSwapConditional, &Value::Bool(true)) {
add_element_to_object(&mut request, &Value::Str("algoId".to_string()), id.clone());
} else {
add_element_to_object(&mut request, &Value::Str("orderId".to_string()), id.clone());
}
}
params = self.omit(params.clone(), Value::List(vec![Value::Str("origClientOrderId".to_string()), Value::Str("clientOrderId".to_string()), Value::Str("newClientStrategyId".to_string()), Value::Str("stop".to_string()), Value::Str("trigger".to_string()), Value::Str("conditional".to_string()), Value::Str("clientAlgoId".to_string())]), &[]);
let mut response: Value = Value::Null;
if is_true(&isOptionType) {
let __ws_arg_98 = self.extend(request.clone(), &[params.clone()]);
response = self.eapi_private_delete_order(&[__ws_arg_98]).await;
} else if is_true(&isLinearType) {
if is_true(&isPortfolioMargin) {
if is_equal(&isConditional, &Value::Bool(true)) {
let __ws_arg_99 = self.extend(request.clone(), &[params.clone()]);
response = self.papi_delete_um_conditional_order(&[__ws_arg_99]).await;
} else {
let __ws_arg_100 = self.extend(request.clone(), &[params.clone()]);
response = self.papi_delete_um_order(&[__ws_arg_100]).await;
}
} else {
if is_equal(&isConditional, &Value::Bool(true)) {
let __ws_arg_101 = self.extend(request.clone(), &[params.clone()]);
response = self.fapi_private_delete_algo_order(&[__ws_arg_101]).await;
} else {
let __ws_arg_102 = self.extend(request.clone(), &[params.clone()]);
response = self.fapi_private_delete_order(&[__ws_arg_102]).await;
}
}
} else if is_true(&isInverseType) {
if is_true(&isPortfolioMargin) {
if is_equal(&isConditional, &Value::Bool(true)) {
let __ws_arg_103 = self.extend(request.clone(), &[params.clone()]);
response = self.papi_delete_cm_conditional_order(&[__ws_arg_103]).await;
} else {
let __ws_arg_104 = self.extend(request.clone(), &[params.clone()]);
response = self.papi_delete_cm_order(&[__ws_arg_104]).await;
}
} else {
if is_equal(&isConditional, &Value::Bool(true)) {
let __ws_arg_105 = self.extend(request.clone(), &[params.clone()]);
response = self.dapi_private_delete_algo_order(&[__ws_arg_105]).await;
} else {
let __ws_arg_106 = self.extend(request.clone(), &[params.clone()]);
response = self.dapi_private_delete_order(&[__ws_arg_106]).await;
}
}
} else if is_true(&(is_equal(&type_var, &Value::Str("margin".to_string())))) || is_true(&(!is_equal(&marginMode, &Value::Null))) || is_true(&isPortfolioMargin) {
if is_true(&isPortfolioMargin) {
let __ws_arg_107 = self.extend(request.clone(), &[params.clone()]);
response = self.papi_delete_margin_order(&[__ws_arg_107]).await;
} else {
if is_equal(&marginMode, &Value::Str("isolated".to_string())) {
add_element_to_object(&mut request, &Value::Str("isIsolated".to_string()), Value::Bool(true));
}
let __ws_arg_108 = self.extend(request.clone(), &[params.clone()]);
response = self.sapi_delete_margin_order(&[__ws_arg_108]).await;
}
} else if is_equal(&stock, &Value::Bool(true)) {
let __ws_arg_109 = self.extend(request.clone(), &[params.clone()]);
response = self.sapi_post_equity_order_cancel(&[__ws_arg_109]).await;
} else {
let __ws_arg_110 = self.extend(request.clone(), &[params.clone()]);
response = self.private_delete_order(&[__ws_arg_110]).await;
}
if is_equal(&response, &Value::Null) {
panic!("{}", crate::exchange_errors::null_response(add(&self.id, &Value::Str(" parseOrder() returned empty response".to_string()))));
}
return self.parse_order(response.clone(), &[market.clone()]);
Value::Null
}
/*
* @method
* @name binance#cancelAllOrders
* @description cancel all open orders in a market
* @see https://developers.binance.com/docs/binance-spot-api-docs/rest-api/trading-endpoints#cancel-all-open-orders-on-a-symbol-trade
* @see https://developers.binance.com/docs/derivatives/usds-margined-futures/trade/rest-api/Cancel-All-Open-Orders
* @see https://developers.binance.com/docs/derivatives/coin-margined-futures/trade/rest-api/Cancel-All-Open-Orders
* @see https://developers.binance.com/docs/derivatives/option/trade/Cancel-all-Option-orders-on-specific-symbol
* @see https://developers.binance.com/docs/margin_trading/trade/Margin-Account-Cancel-All-Open-Orders
* @see https://developers.binance.com/docs/derivatives/portfolio-margin/trade/Cancel-All-UM-Open-Orders
* @see https://developers.binance.com/docs/derivatives/portfolio-margin/trade/Cancel-All-UM-Open-Conditional-Orders
* @see https://developers.binance.com/docs/derivatives/portfolio-margin/trade/Cancel-All-CM-Open-Orders
* @see https://developers.binance.com/docs/derivatives/portfolio-margin/trade/Cancel-All-CM-Open-Conditional-Orders
* @see https://developers.binance.com/docs/derivatives/portfolio-margin/trade/Cancel-Margin-Account-All-Open-Orders-on-a-Symbol
* @see https://developers.binance.com/docs/derivatives/usds-margined-futures/trade/rest-api/Cancel-All-Algo-Open-Orders
* @see https://developers.binance.com/en/docs/catalog/advanced-trading-stocks-trading/api/rest-api/trade#cancel-all-equity-orders
* @param {string} symbol unified market symbol of the market to cancel orders in
* @param {object} [params] extra parameters specific to the exchange API endpoint
* @param {string} [params.marginMode] 'cross' or 'isolated', for spot margin trading
* @param {boolean} [params.portfolioMargin] set to true if you would like to cancel orders in a portfolio margin account
* @param {boolean} [params.trigger] set to true if you would like to cancel portfolio margin account conditional orders
* @param {boolean} [params.stock] set to true if you would like to cancel tokenized stock orders
* @returns {object[]} a list of [order structures]{@link https://docs.ccxt.com/?id=order-structure}
*/
pub async fn cancel_all_orders(&mut self, optional_args: &[Value]) -> Value {
let mut symbol = get_arg(optional_args, 0, Value::Null);
let mut params = get_arg(optional_args, 1, Value::Map({
let mut m = indexmap::IndexMap::new();
m
}));
if is_equal(&self.markets, &Value::Null) {
self.load_markets(&[]).await;
}
let mut request: Value = Value::Map({
let mut m = indexmap::IndexMap::new();
m
});
let mut market: Value = Value::Null;
let mut stock: Value = Value::Null;
{ let __destr_tmp = self.handle_option_and_params(params.clone(), Value::Str("cancelAllOrders".to_string()), Value::Str("stock".to_string()), &[Value::Bool(false)]); stock = get_value(&__destr_tmp, &Value::Int(0)); params = get_value(&__destr_tmp, &Value::Int(1)); }
if !is_equal(&symbol, &Value::Null) {
market = self.market(symbol.clone());
stock = self.safe_bool_k(market.clone(), "stock", &[Value::Bool(false)]);
if !is_equal(&stock, &Value::Bool(true)) {
add_element_to_object(&mut request, &Value::Str("symbol".to_string()), get_value(&market, &Value::Str("id".to_string())));
}
} else {
panic!("{}", crate::exchange_errors::arguments_required(add(&self.id, &Value::Str(" cancelAllOrders() requires a symbol argument".to_string()))));
}
let mut isPortfolioMargin: Value = Value::Null;
{ let __destr_tmp = self.handle_option_and_params2(params.clone(), Value::Str("cancelAllOrders".to_string()), Value::Str("papi".to_string()), Value::Str("portfolioMargin".to_string()), &[Value::Bool(false)]); isPortfolioMargin = get_value(&__destr_tmp, &Value::Int(0)); params = get_value(&__destr_tmp, &Value::Int(1)); }
let mut isConditional: Value = self.safe_bool_n(params.clone(), Value::List(vec![Value::Str("stop".to_string()), Value::Str("trigger".to_string()), Value::Str("conditional".to_string())]), &[]);
let mut type_var: Value = Value::Null;
{ let __destr_tmp = self.handle_market_type_and_params(Value::Str("cancelAllOrders".to_string()), &[market.clone(), params.clone(), Value::Str("spot".to_string())]); type_var = get_value(&__destr_tmp, &Value::Int(0)); params = get_value(&__destr_tmp, &Value::Int(1)); }
let mut subType: Value = Value::Null;
{ let __destr_tmp = self.handle_sub_type_and_params(Value::Str("cancelAllOrders".to_string()), &[market.clone(), params.clone()]); subType = get_value(&__destr_tmp, &Value::Int(0)); params = get_value(&__destr_tmp, &Value::Int(1)); }
let mut isOptionType: bool = is_equal(&type_var, &Value::Str("option".to_string()));
let mut isLinearType: Value = self.is_linear(type_var.clone(), &[subType.clone()]);
let mut isInverseType: Value = self.is_inverse(type_var.clone(), &[subType.clone()]);
params = self.omit(params.clone(), Value::List(vec![Value::Str("stop".to_string()), Value::Str("trigger".to_string()), Value::Str("conditional".to_string())]), &[]);
let mut marginMode: Value = Value::Null;
{ let __destr_tmp = self.handle_margin_mode_and_params(Value::Str("cancelAllOrders".to_string()), &[params.clone()]); marginMode = get_value(&__destr_tmp, &Value::Int(0)); params = get_value(&__destr_tmp, &Value::Int(1)); }
let mut response: Value = Value::Null;
if is_true(&isOptionType) {
let __ws_arg_111 = self.extend(request.clone(), &[params.clone()]);
response = self.eapi_private_delete_all_open_orders(&[__ws_arg_111]).await;
} else if is_true(&isLinearType) {
if is_true(&isPortfolioMargin) {
if is_equal(&isConditional, &Value::Bool(true)) {
let __ws_arg_112 = self.extend(request.clone(), &[params.clone()]);
response = self.papi_delete_um_conditional_all_open_orders(&[__ws_arg_112]).await;
} else {
let __ws_arg_113 = self.extend(request.clone(), &[params.clone()]);
response = self.papi_delete_um_all_open_orders(&[__ws_arg_113]).await;
}
} else {
if is_equal(&isConditional, &Value::Bool(true)) {
let __ws_arg_114 = self.extend(request.clone(), &[params.clone()]);
response = self.fapi_private_delete_algo_open_orders(&[__ws_arg_114]).await;
} else {
let __ws_arg_115 = self.extend(request.clone(), &[params.clone()]);
response = self.fapi_private_delete_all_open_orders(&[__ws_arg_115]).await;
}
}
} else if is_true(&isInverseType) {
if is_true(&isPortfolioMargin) {
if is_equal(&isConditional, &Value::Bool(true)) {
let __ws_arg_116 = self.extend(request.clone(), &[params.clone()]);
response = self.papi_delete_cm_conditional_all_open_orders(&[__ws_arg_116]).await;
} else {
let __ws_arg_117 = self.extend(request.clone(), &[params.clone()]);
response = self.papi_delete_cm_all_open_orders(&[__ws_arg_117]).await;
}
} else {
let __ws_arg_118 = self.extend(request.clone(), &[params.clone()]);
response = self.dapi_private_delete_all_open_orders(&[__ws_arg_118]).await;
}
} else if is_true(&(is_equal(&type_var, &Value::Str("margin".to_string())))) || is_true(&(!is_equal(&marginMode, &Value::Null))) || is_true(&isPortfolioMargin) {
if is_true(&isPortfolioMargin) {
let __ws_arg_119 = self.extend(request.clone(), &[params.clone()]);
response = self.papi_delete_margin_all_open_orders(&[__ws_arg_119]).await;
} else {
if is_equal(&marginMode, &Value::Str("isolated".to_string())) {
add_element_to_object(&mut request, &Value::Str("isIsolated".to_string()), Value::Bool(true));
}
let __ws_arg_120 = self.extend(request.clone(), &[params.clone()]);
response = self.sapi_delete_margin_open_orders(&[__ws_arg_120]).await;
}
} else if is_equal(&stock, &Value::Bool(true)) {
let __ws_arg_121 = self.extend(request.clone(), &[params.clone()]);
response = self.sapi_post_equity_order_cancel_all(&[__ws_arg_121]).await;
} else {
let __ws_arg_122 = self.extend(request.clone(), &[params.clone()]);
response = self.private_delete_open_orders(&[__ws_arg_122]).await;
}
if is_true(&Value::Bool(is_array(&response))) {
return self.parse_orders(response.clone(), &[market.clone()]);
} else {
let mut order: Value = self.safe_order(Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("info".to_string(), response.clone());
m
}), &[]);
return Value::List(vec![order.clone()]);
}
Value::Null
}
/*
* @method
* @name binance#cancelOrders
* @description cancel multiple orders
* @see https://developers.binance.com/docs/derivatives/usds-margined-futures/trade/rest-api/Cancel-Multiple-Orders
* @see https://developers.binance.com/docs/derivatives/coin-margined-futures/trade/rest-api/Cancel-Multiple-Orders
* @param {string[]} ids order ids
* @param {string} [symbol] unified market symbol
* @param {object} [params] extra parameters specific to the exchange API endpoint
* @param {string[]} [params.clientOrderIds] alternative to ids, array of client order ids
*
* EXCHANGE SPECIFIC PARAMETERS
* @param {string[]} [params.origClientOrderIdList] max length 10 e.g. ["my_id_1","my_id_2"], encode the double quotes. No space after comma
* @param {int[]} [params.recvWindow]
* @returns {object} an list of [order structures]{@link https://docs.ccxt.com/?id=order-structure}
*/
pub async fn cancel_orders(&mut self, mut ids: Value, optional_args: &[Value]) -> Value {
let mut symbol = get_arg(optional_args, 0, Value::Null);
let mut params = get_arg(optional_args, 1, Value::Map({
let mut m = indexmap::IndexMap::new();
m
}));
if is_equal(&symbol, &Value::Null) {
panic!("{}", crate::exchange_errors::arguments_required(add(&self.id, &Value::Str(" cancelOrders() requires a symbol argument".to_string()))));
}
if is_equal(&self.markets, &Value::Null) {
self.load_markets(&[]).await;
}
let mut market: Value = self.market(symbol.clone());
if !is_equal(&get_value(&market, &Value::Str("contract".to_string())), &Value::Bool(true)) {
panic!("{}", crate::exchange_errors::bad_request(add(&self.id, &Value::Str(" cancelOrders is only supported for swap markets.".to_string()))));
}
let mut request: Value = Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("symbol".to_string(), get_value(&market, &Value::Str("id".to_string())));
m
});
let mut origClientOrderIdList: Value = self.safe_list2(params.clone(), Value::Str("origClientOrderIdList".to_string()), Value::Str("clientOrderIds".to_string()), &[]);
if !is_equal(&origClientOrderIdList, &Value::Null) {
params = self.omit(params.clone(), Value::List(vec![Value::Str("clientOrderIds".to_string())]), &[]);
add_element_to_object(&mut request, &Value::Str("origClientOrderIdList".to_string()), origClientOrderIdList.clone());
} else {
add_element_to_object(&mut request, &Value::Str("orderidlist".to_string()), ids.clone());
}
let mut response: Value = Value::Null;
if is_equal(&get_value(&market, &Value::Str("linear".to_string())), &Value::Bool(true)) {
let __ws_arg_123 = self.extend(request.clone(), &[params.clone()]);
response = self.fapi_private_delete_batch_orders(&[__ws_arg_123]).await;
} else if is_equal(&get_value(&market, &Value::Str("inverse".to_string())), &Value::Bool(true)) {
let __ws_arg_124 = self.extend(request.clone(), &[params.clone()]);
response = self.dapi_private_delete_batch_orders(&[__ws_arg_124]).await;
}
return self.parse_orders(response.clone(), &[market.clone()]);
Value::Null
}
/*
* @method
* @name binance#fetchOrderTrades
* @description fetch all the trades made from a single order
* @see https://developers.binance.com/docs/binance-spot-api-docs/rest-api/account-endpoints#account-trade-list-user_data
* @see https://developers.binance.com/docs/derivatives/usds-margined-futures/trade/rest-api/Account-Trade-List
* @see https://developers.binance.com/docs/derivatives/coin-margined-futures/trade/rest-api/Account-Trade-List
* @see https://developers.binance.com/docs/margin_trading/trade/Query-Margin-Account-Trade-List
* @param {string} id order id
* @param {string} symbol unified market symbol
* @param {int} [since] the earliest time in ms to fetch trades for
* @param {int} [limit] the maximum number of trades to retrieve
* @param {object} [params] extra parameters specific to the exchange API endpoint
* @returns {object[]} a list of [trade structures]{@link https://docs.ccxt.com/?id=trade-structure}
*/
pub async fn fetch_order_trades(&mut self, mut id: Value, optional_args: &[Value]) -> Value {
let mut symbol = get_arg(optional_args, 0, Value::Null);
let mut since = get_arg(optional_args, 1, Value::Null);
let mut limit = get_arg(optional_args, 2, Value::Null);
let mut params = get_arg(optional_args, 3, Value::Map({
let mut m = indexmap::IndexMap::new();
m
}));
if is_equal(&symbol, &Value::Null) {
panic!("{}", crate::exchange_errors::arguments_required(add(&self.id, &Value::Str(" fetchOrderTrades() requires a symbol argument".to_string()))));
}
if is_equal(&self.markets, &Value::Null) {
self.load_markets(&[]).await;
}
let mut market: Value = self.market(symbol.clone());
let mut type_var: Value = self.safe_string_k(params.clone(), "type", &[get_value(&market, &Value::Str("type".to_string()))]);
params = self.omit(params.clone(), Value::Str("type".to_string()), &[]);
if !is_equal(&type_var, &Value::Str("spot".to_string())) {
panic!("{}", crate::exchange_errors::not_supported(add(&self.id, &Value::Str(" fetchOrderTrades() supports spot markets only".to_string()))));
}
let mut request: Value = Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("orderId".to_string(), id.clone());
m
});
let __ws_arg_125 = self.extend(request.clone(), &[params.clone()]);
return self.fetch_my_trades(&[symbol.clone(), since.clone(), limit.clone(), __ws_arg_125]).await;
Value::Null
}
/*
* @method
* @name binance#fetchMyTrades
* @description fetch all trades made by the user
* @see https://developers.binance.com/docs/binance-spot-api-docs/rest-api/account-endpoints#account-trade-list-user_data
* @see https://developers.binance.com/docs/derivatives/usds-margined-futures/trade/rest-api/Account-Trade-List
* @see https://developers.binance.com/docs/derivatives/coin-margined-futures/trade/rest-api/Account-Trade-List
* @see https://developers.binance.com/docs/margin_trading/trade/Query-Margin-Account-Trade-List
* @see https://developers.binance.com/docs/derivatives/option/trade/Account-Trade-List
* @see https://developers.binance.com/docs/derivatives/portfolio-margin/trade/UM-Account-Trade-List
* @see https://developers.binance.com/docs/derivatives/portfolio-margin/trade/CM-Account-Trade-List
* @see https://developers.binance.com/en/docs/catalog/advanced-trading-stocks-trading/api/rest-api/trade#equity-trade-history
* @param {string} [symbol] unified market symbol
* @param {int} [since] the earliest time in ms to fetch trades for
* @param {int} [limit] the maximum number of trades structures to retrieve
* @param {object} [params] extra parameters specific to the exchange API endpoint
* @param {boolean} [params.paginate] default false, when true will automatically paginate by calling this endpoint multiple times. See in the docs all the [available parameters](https://github.com/ccxt/ccxt/wiki/Manual#pagination-params)
* @param {int} [params.until] the latest time in ms to fetch entries for
* @param {boolean} [params.portfolioMargin] set to true if you would like to fetch trades for a portfolio margin account
* @param {boolean} [params.stock] set to true if you would like to fetch tokenized stock trades
* @returns {Trade[]} a list of [trade structures]{@link https://docs.ccxt.com/?id=trade-structure}
*/
pub async fn fetch_my_trades(&mut self, optional_args: &[Value]) -> Value {
let mut symbol = get_arg(optional_args, 0, Value::Null);
let mut since = get_arg(optional_args, 1, Value::Null);
let mut limit = get_arg(optional_args, 2, Value::Null);
let mut params = get_arg(optional_args, 3, Value::Map({
let mut m = indexmap::IndexMap::new();
m
}));
if is_equal(&self.markets, &Value::Null) {
self.load_markets(&[]).await;
}
let mut paginate: Value = Value::Bool(false);
{ let __destr_tmp = self.handle_option_and_params(params.clone(), Value::Str("fetchMyTrades".to_string()), Value::Str("paginate".to_string()), &[]); paginate = get_value(&__destr_tmp, &Value::Int(0)); params = get_value(&__destr_tmp, &Value::Int(1)); }
if is_true(&paginate) {
return self.fetch_paginated_call_dynamic(Value::Str("fetchMyTrades".to_string()), &[symbol.clone(), since.clone(), limit.clone(), params.clone()]).await;
}
let mut request: Value = Value::Map({
let mut m = indexmap::IndexMap::new();
m
});
let mut market: Value = Value::Null;
let mut type_var: Value = Value::Null;
let mut marginMode: Value = Value::Null;
let mut stock: Value = Value::Null;
{ let __destr_tmp = self.handle_option_and_params(params.clone(), Value::Str("fetchMyTrades".to_string()), Value::Str("stock".to_string()), &[Value::Bool(false)]); stock = get_value(&__destr_tmp, &Value::Int(0)); params = get_value(&__destr_tmp, &Value::Int(1)); }
if !is_equal(&symbol, &Value::Null) {
market = self.market(symbol.clone());
stock = self.safe_bool_k(market.clone(), "stock", &[Value::Bool(false)]);
add_element_to_object(&mut request, &Value::Str("symbol".to_string()), get_value(&market, &Value::Str("id".to_string())));
}
{ let __destr_tmp = self.handle_market_type_and_params(Value::Str("fetchMyTrades".to_string()), &[market.clone(), params.clone()]); type_var = get_value(&__destr_tmp, &Value::Int(0)); params = get_value(&__destr_tmp, &Value::Int(1)); }
if is_true(&(!is_equal(&stock, &Value::Bool(true)))) && is_true(&(!is_equal(&type_var, &Value::Str("option".to_string())))) && is_true(&(is_equal(&symbol, &Value::Null))) {
panic!("{}", crate::exchange_errors::arguments_required(add(&self.id, &Value::Str(" fetchMyTrades() requires a symbol argument".to_string()))));
}
let mut endTime: Value = self.safe_integer2(params.clone(), Value::Str("until".to_string()), Value::Str("endTime".to_string()), &[]);
if !is_equal(&since, &Value::Null) {
let mut startTime: Value = since.clone();
add_element_to_object(&mut request, &Value::Str("startTime".to_string()), startTime.clone());
// If startTime and endTime are both not sent, then the last 7 days' data will be returned.
// The time between startTime and endTime cannot be longer than 7 days.
// The parameter fromId cannot be sent with startTime or endTime.
let mut currentTimestamp: Value = self.milliseconds();
let mut oneWeek: Value = multiply(&multiply(&multiply(&multiply(&Value::Int(7), &Value::Int(24)), &Value::Int(60)), &Value::Int(60)), &Value::Int(1000));
if is_greater_than_or_equal(&(subtract(¤tTimestamp, &startTime)), &oneWeek) {
if is_true(&(is_equal(&endTime, &Value::Null))) && is_true(&(is_equal(&self.safe_bool_k(market.clone(), "linear", &[]), &Value::Bool(true)))) {
endTime = self.sum(&[startTime.clone(), oneWeek.clone()]);
let mut endTimeValue: Value = ternary(is_true(&(is_equal(&endTime, &Value::Null))), Value::Int(0), endTime.clone());
endTime = crate::runtime::Math::min(&endTimeValue, ¤tTimestamp);
}
}
}
if !is_equal(&endTime, &Value::Null) {
add_element_to_object(&mut request, &Value::Str("endTime".to_string()), endTime.clone());
params = self.omit(params.clone(), Value::List(vec![Value::Str("endTime".to_string()), Value::Str("until".to_string())]), &[]);
}
if !is_equal(&limit, &Value::Null) {
if is_true(&(is_equal(&type_var, &Value::Str("option".to_string())))) || is_true(&(is_equal(&self.safe_bool_k(market.clone(), "contract", &[]), &Value::Bool(true)))) {
limit = crate::runtime::Math::min(&limit, &Value::Int(1000)); // above 1000, returns error
}
if is_equal(&stock, &Value::Bool(true)) {
limit = crate::runtime::Math::min(&limit, &Value::Int(100)); // max 100
add_element_to_object(&mut request, &Value::Str("size".to_string()), limit.clone());
} else {
add_element_to_object(&mut request, &Value::Str("limit".to_string()), limit.clone());
}
}
let mut response: Value = Value::Null;
if is_equal(&type_var, &Value::Str("option".to_string())) {
let __ws_arg_126 = self.extend(request.clone(), &[params.clone()]);
response = self.eapi_private_get_user_trades(&[__ws_arg_126]).await;
} else {
{ let __destr_tmp = self.handle_margin_mode_and_params(Value::Str("fetchMyTrades".to_string()), &[params.clone()]); marginMode = get_value(&__destr_tmp, &Value::Int(0)); params = get_value(&__destr_tmp, &Value::Int(1)); }
let mut isPortfolioMargin: Value = Value::Null;
{ let __destr_tmp = self.handle_option_and_params2(params.clone(), Value::Str("fetchMyTrades".to_string()), Value::Str("papi".to_string()), Value::Str("portfolioMargin".to_string()), &[Value::Bool(false)]); isPortfolioMargin = get_value(&__destr_tmp, &Value::Int(0)); params = get_value(&__destr_tmp, &Value::Int(1)); }
if is_equal(&stock, &Value::Bool(true)) {
if is_equal(&endTime, &Value::Null) {
endTime = self.milliseconds();
add_element_to_object(&mut request, &Value::Str("endTime".to_string()), endTime.clone());
}
if is_equal(&since, &Value::Null) {
let mut oneWeek: Value = multiply(&multiply(&multiply(&multiply(&Value::Int(7), &Value::Int(24)), &Value::Int(60)), &Value::Int(60)), &Value::Int(1000));
add_element_to_object(&mut request, &Value::Str("startTime".to_string()), subtract(&endTime, &oneWeek));
}
let __ws_arg_127 = self.extend(request.clone(), &[params.clone()]);
response = self.sapi_get_equity_trade_history(&[__ws_arg_127]).await;
} else if is_equal(&type_var, &Value::Str("spot".to_string())) || is_equal(&type_var, &Value::Str("margin".to_string())) {
if is_true(&isPortfolioMargin) {
let __ws_arg_128 = self.extend(request.clone(), &[params.clone()]);
response = self.papi_get_margin_my_trades(&[__ws_arg_128]).await;
} else if is_true(&(is_equal(&type_var, &Value::Str("margin".to_string())))) || is_true(&(!is_equal(&marginMode, &Value::Null))) {
if is_equal(&marginMode, &Value::Str("isolated".to_string())) {
add_element_to_object(&mut request, &Value::Str("isIsolated".to_string()), Value::Bool(true));
}
let __ws_arg_129 = self.extend(request.clone(), &[params.clone()]);
response = self.sapi_get_margin_my_trades(&[__ws_arg_129]).await;
} else {
let __ws_arg_130 = self.extend(request.clone(), &[params.clone()]);
response = self.private_get_my_trades(&[__ws_arg_130]).await;
}
} else if is_equal(&self.safe_bool_k(market.clone(), "linear", &[]), &Value::Bool(true)) {
if is_true(&isPortfolioMargin) {
let __ws_arg_131 = self.extend(request.clone(), &[params.clone()]);
response = self.papi_get_um_user_trades(&[__ws_arg_131]).await;
} else {
let __ws_arg_132 = self.extend(request.clone(), &[params.clone()]);
response = self.fapi_private_get_user_trades(&[__ws_arg_132]).await;
}
} else if is_equal(&self.safe_bool_k(market.clone(), "inverse", &[]), &Value::Bool(true)) {
if is_true(&isPortfolioMargin) {
let __ws_arg_133 = self.extend(request.clone(), &[params.clone()]);
response = self.papi_get_cm_user_trades(&[__ws_arg_133]).await;
} else {
let __ws_arg_134 = self.extend(request.clone(), &[params.clone()]);
response = self.dapi_private_get_user_trades(&[__ws_arg_134]).await;
}
}
}
//
// spot trade
//
// [
// {
// "symbol": "BNBBTC",
// "id": 28457,
// "orderId": 100234,
// "price": "4.00000100",
// "qty": "12.00000000",
// "commission": "10.10000000",
// "commissionAsset": "BNB",
// "time": 1499865549590,
// "isBuyer": true,
// "isMaker": false,
// "isBestMatch": true,
// }
// ]
//
// futures trade
//
// [
// {
// "accountId": 20,
// "buyer": False,
// "commission": "-0.07819010",
// "commissionAsset": "USDT",
// "counterPartyId": 653,
// "id": 698759,
// "maker": False,
// "orderId": 25851813,
// "price": "7819.01",
// "qty": "0.002",
// "quoteQty": "0.01563",
// "realizedPnl": "-0.91539999",
// "side": "SELL",
// "symbol": "BTCUSDT",
// "time": 1569514978020
// }
// ]
//
// options (eapi)
//
// [
// {
// "id": 1125899906844226012,
// "tradeId": 73,
// "orderId": 4638761100843040768,
// "symbol": "ETH-230211-1500-C",
// "price": "18.70000000",
// "quantity": "-0.57000000",
// "fee": "0.17305890",
// "realizedProfit": "-3.53400000",
// "side": "SELL",
// "type": "LIMIT",
// "volatility": "0.30000000",
// "liquidity": "MAKER",
// "time": 1676085216845,
// "priceScale": 1,
// "quantityScale": 2,
// "optionSide": "CALL",
// "quoteAsset": "USDT"
// }
// ]
//
// linear portfolio margin
//
// [
// {
// "symbol": "BTCUSDT",
// "id": 4575108247,
// "orderId": 261942655610,
// "side": "SELL",
// "price": "47263.40",
// "qty": "0.010",
// "realizedPnl": "27.38400000",
// "marginAsset": "USDT",
// "quoteQty": "472.63",
// "commission": "0.18905360",
// "commissionAsset": "USDT",
// "time": 1707530039409,
// "buyer": false,
// "maker": false,
// "positionSide": "LONG"
// }
// ]
//
// inverse portfolio margin
//
// [
// {
// "symbol": "ETHUSD_PERP",
// "id": 701907838,
// "orderId": 71548909034,
// "pair": "ETHUSD",
// "side": "SELL",
// "price": "2498.15",
// "qty": "1",
// "realizedPnl": "0.00012517",
// "marginAsset": "ETH",
// "baseQty": "0.00400296",
// "commission": "0.00000160",
// "commissionAsset": "ETH",
// "time": 1707530317519,
// "positionSide": "LONG",
// "buyer": false,
// "maker": false
// }
// ]
//
// spot margin portfolio margin
//
// [
// {
// "symbol": "ADAUSDT",
// "id": 470227543,
// "orderId": 4421170947,
// "price": "0.53880000",
// "qty": "10.00000000",
// "quoteQty": "5.38800000",
// "commission": "0.00538800",
// "commissionAsset": "USDT",
// "time": 1707545780522,
// "isBuyer": false,
// "isMaker": false,
// "isBestMatch": true
// }
// ]
//
// tokenized equities
//
// {
// "page": 1,
// "size": 20,
// "total": 1,
// "rows": [
// {
// "executionId": "cc942eb9-eaa0-47e7-8273-2a9bc10c5741",
// "orderId": "ef66a86f-202b-4b41-b15c-e1c90f975f17",
// "symbol": "AAPL",
// "quote": "USDC",
// "side": "BUY",
// "orderType": "MARKET",
// "price": "309.16",
// "qty": "0.0576724",
// "total": "17.83",
// "executionAt": 1785936600545,
// "updatedAt": 1785936601012
// }
// ]
// }
let mut responseList: Value = Value::List(vec![]);
if !is_equal(&response, &Value::Null) {
if is_equal(&stock, &Value::Bool(true)) {
let mut rows: Value = self.safe_list_k(response.clone(), "rows", &[Value::List(vec![])]);
responseList = rows.clone();
} else {
responseList = self.to_array(response.clone());
}
}
return self.parse_trades(responseList.clone(), &[market.clone(), since.clone(), limit.clone()]);
Value::Null
}
/*
* @method
* @name binance#fetchMyDustTrades
* @description fetch all dust trades made by the user
* @see https://developers.binance.com/docs/wallet/asset/dust-log
* @param {string} symbol not used by fetchMyDustTrades ()
* @param {int} [since] the earliest time in ms to fetch my dust trades for
* @param {int} [limit] the maximum number of dust trades to retrieve
* @param {object} [params] extra parameters specific to the exchange API endpoint
* @param {string} [params.type] 'spot' or 'margin', default spot
* @returns {object[]} a list of [trade structures]{@link https://docs.ccxt.com/?id=trade-structure}
*/
pub async fn fetch_my_dust_trades(&mut self, optional_args: &[Value]) -> Value {
let mut symbol = get_arg(optional_args, 0, Value::Null);
let mut since = get_arg(optional_args, 1, Value::Null);
let mut limit = get_arg(optional_args, 2, Value::Null);
let mut params = get_arg(optional_args, 3, Value::Map({
let mut m = indexmap::IndexMap::new();
m
}));
//
// Binance provides an opportunity to trade insignificant (i.e. non-tradable and non-withdrawable)
// token leftovers (of any asset) into `BNB` coin which in turn can be used to pay trading fees with it.
// The corresponding trades history is called the `Dust Log` and can be requested via the following end-point:
// https://github.com/binance-exchange/binance-official-api-docs/blob/master/wapi-api.md#dustlog-user_data
//
if is_equal(&self.markets, &Value::Null) {
self.load_markets(&[]).await;
}
let mut request: Value = Value::Map({
let mut m = indexmap::IndexMap::new();
m
});
if !is_equal(&since, &Value::Null) {
add_element_to_object(&mut request, &Value::Str("startTime".to_string()), since.clone());
add_element_to_object(&mut request, &Value::Str("endTime".to_string()), self.sum(&[since.clone(), Value::Int(7776000000)]));
}
let mut accountType: Value = self.safe_string_upper(params.clone(), Value::Str("type".to_string()), &[]);
params = self.omit(params.clone(), Value::Str("type".to_string()), &[]);
if !is_equal(&accountType, &Value::Null) {
add_element_to_object(&mut request, &Value::Str("accountType".to_string()), accountType.clone());
}
let __ws_arg_135 = self.extend(request.clone(), &[params.clone()]);
let mut response: Value = self.sapi_get_asset_dribblet(&[__ws_arg_135]).await;
// {
// "total": "4",
// "userAssetDribblets": [
// {
// "operateTime": "1627575731000",
// "totalServiceChargeAmount": "0.00001453",
// "totalTransferedAmount": "0.00072693",
// "transId": "70899815863",
// "userAssetDribbletDetails": [
// {
// "fromAsset": "LTC",
// "amount": "0.000006",
// "transferedAmount": "0.00000267",
// "serviceChargeAmount": "0.00000005",
// "operateTime": "1627575731000",
// "transId": "70899815863"
// },
// {
// "fromAsset": "GBP",
// "amount": "0.15949157",
// "transferedAmount": "0.00072426",
// "serviceChargeAmount": "0.00001448",
// "operateTime": "1627575731000",
// "transId": "70899815863"
// }
// ]
// },
// ]
// }
let mut results: Value = self.safe_list_k(response.clone(), "userAssetDribblets", &[Value::List(vec![])]);
let mut rows: Value = self.safe_integer_k(response.clone(), "total", &[Value::Int(0)]);
let mut data: Value = Value::List(vec![]);
{
let mut i: Value = Value::Int(0);
let mut __for_first_265: bool = true;
while { if !__for_first_265 { i = add(&i, &Value::Int(1)); } __for_first_265 = false; is_less_than(&i, &rows) } {
let mut logs: Value = self.safe_list_k(get_value(&results, &i), "userAssetDribbletDetails", &[Value::List(vec![])]);
{
let mut j: Value = Value::Int(0);
let mut __for_first_264: bool = true;
while { if !__for_first_264 { j = add(&j, &Value::Int(1)); } __for_first_264 = false; is_less_than(&j, &get_array_length(&logs)) } {
add_element_to_object(get_value_mut(&mut logs, &j), &Value::Str("isDustTrade".to_string()), Value::Bool(true));
append_to_array(&mut data, get_value(&logs, &j));
}
}
}
}
let mut trades: Value = self.parse_trades(data.clone(), &[Value::Null, since.clone(), limit.clone()]);
return self.filter_by_since_limit(trades.clone(), &[since.clone(), limit.clone()]);
Value::Null
}
pub fn parse_dust_trade(&self, mut trade: Value, optional_args: &[Value]) -> Value {
let mut market = get_arg(optional_args, 0, Value::Null);
//
// {
// "fromAsset": "USDT",
// "amount": "0.009669",
// "transferedAmount": "0.00002992",
// "serviceChargeAmount": "0.00000059",
// "operateTime": "1628076010000",
// "transId": "71416578712",
// "isDustTrade": true
// }
//
let mut orderId: Value = self.safe_string_k(trade.clone(), "transId", &[]);
let mut timestamp: Value = self.safe_integer_k(trade.clone(), "operateTime", &[]);
let mut currencyId: Value = self.safe_string_k(trade.clone(), "fromAsset", &[]);
let mut tradedCurrency: Value = self.safe_currency_code(currencyId.clone(), &[]);
let mut bnb: Value = self.currency(Value::Str("BNB".to_string()));
let mut earnedCurrency: Value = get_value(&bnb, &Value::Str("code".to_string()));
let mut applicantSymbol: Value = add(&add(&earnedCurrency, &Value::Str("/".to_string())), &tradedCurrency);
let mut tradedCurrencyIsQuote: bool = false;
if is_true(&(!is_equal(&self.markets, &Value::Null))) && is_true(&(Value::Bool(in_op(&self.markets, &applicantSymbol)))) {
tradedCurrencyIsQuote = true;
}
let mut feeCostString: Value = self.safe_string_k(trade.clone(), "serviceChargeAmount", &[]);
let mut fee: Value = Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("currency".to_string(), earnedCurrency.clone());
m.insert("cost".to_string(), self.parse_number(feeCostString.clone(), &[]));
m
});
let mut symbol: Value = Value::Null;
let mut amountString: Value = Value::Null;
let mut costString: Value = Value::Null;
let mut side: Value = Value::Null;
if is_true(&tradedCurrencyIsQuote) {
symbol = applicantSymbol.clone();
amountString = self.safe_string_k(trade.clone(), "transferedAmount", &[]);
costString = self.safe_string_k(trade.clone(), "amount", &[]);
side = Value::Str("buy".to_string());
} else {
symbol = add(&add(&tradedCurrency, &Value::Str("/".to_string())), &earnedCurrency);
amountString = self.safe_string_k(trade.clone(), "amount", &[]);
costString = self.safe_string_k(trade.clone(), "transferedAmount", &[]);
side = Value::Str("sell".to_string());
}
let mut priceString: Value = Value::Null;
if !is_equal(&costString, &Value::Null) {
if is_true(&(!is_equal(&amountString, &Value::Null))) && is_true(&(!is_equal(&amountString, &Value::Str("".to_string())))) {
priceString = crate::precise::Precise::stringDiv(&costString, &amountString);
}
}
let mut id: Value = Value::Null;
let mut amount: Value = self.parse_number(amountString.clone(), &[]);
let mut price: Value = self.parse_number(priceString.clone(), &[]);
let mut cost: Value = self.parse_number(costString.clone(), &[]);
let mut type_var: Value = Value::Null;
let mut takerOrMaker: Value = Value::Null;
return Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("id".to_string(), id.clone());
m.insert("timestamp".to_string(), timestamp.clone());
m.insert("datetime".to_string(), self.iso8601(timestamp.clone()));
m.insert("symbol".to_string(), symbol.clone());
m.insert("order".to_string(), orderId.clone());
m.insert("type".to_string(), type_var.clone());
m.insert("takerOrMaker".to_string(), takerOrMaker.clone());
m.insert("side".to_string(), side.clone());
m.insert("amount".to_string(), amount.clone());
m.insert("price".to_string(), price.clone());
m.insert("cost".to_string(), cost.clone());
m.insert("fee".to_string(), fee.clone());
m.insert("info".to_string(), trade.clone());
m
});
Value::Null
}
/*
* @method
* @name binance#fetchDeposits
* @description fetch all deposits made to an account
* @see https://developers.binance.com/docs/wallet/capital/deposite-history
* @see https://developers.binance.com/docs/fiat/rest-api/Get-Fiat-Deposit-Withdraw-History
* @param {string} code unified currency code
* @param {int} [since] the earliest time in ms to fetch deposits for
* @param {int} [limit] the maximum number of deposits structures to retrieve
* @param {object} [params] extra parameters specific to the exchange API endpoint
* @param {bool} [params.fiat] if true, only fiat deposits will be returned
* @param {int} [params.until] the latest time in ms to fetch entries for
* @param {boolean} [params.paginate] default false, when true will automatically paginate by calling this endpoint multiple times. See in the docs all the [available parameters](https://github.com/ccxt/ccxt/wiki/Manual#pagination-params)
* @returns {object[]} a list of [transaction structures]{@link https://docs.ccxt.com/?id=transaction-structure}
*/
pub async fn fetch_deposits(&mut self, optional_args: &[Value]) -> Value {
let mut code = get_arg(optional_args, 0, Value::Null);
let mut since = get_arg(optional_args, 1, Value::Null);
let mut limit = get_arg(optional_args, 2, Value::Null);
let mut params = get_arg(optional_args, 3, Value::Map({
let mut m = indexmap::IndexMap::new();
m
}));
if is_equal(&self.markets, &Value::Null) {
self.load_markets(&[]).await;
}
let mut paginate: Value = Value::Bool(false);
{ let __destr_tmp = self.handle_option_and_params(params.clone(), Value::Str("fetchDeposits".to_string()), Value::Str("paginate".to_string()), &[]); paginate = get_value(&__destr_tmp, &Value::Int(0)); params = get_value(&__destr_tmp, &Value::Int(1)); }
if is_true(&paginate) {
return self.fetch_paginated_call_dynamic(Value::Str("fetchDeposits".to_string()), &[code.clone(), since.clone(), limit.clone(), params.clone()]).await;
}
let mut currency: Value = Value::Null;
let mut response: Value = Value::Null;
let mut request: Value = Value::Map({
let mut m = indexmap::IndexMap::new();
m
});
let mut legalMoney: Value = self.safe_dict_k(self.options.clone(), "legalMoney", &[Value::Map({
let mut m = indexmap::IndexMap::new();
m
})]);
let mut fiatOnly: Value = self.safe_bool_k(params.clone(), "fiat", &[Value::Bool(false)]);
params = self.omit(params.clone(), Value::Str("fiatOnly".to_string()), &[]);
let mut until: Value = self.safe_integer_k(params.clone(), "until", &[]);
params = self.omit(params.clone(), Value::Str("until".to_string()), &[]);
if is_true(&(is_equal(&fiatOnly, &Value::Bool(true)))) || is_true(&(is_true(&(!is_equal(&code, &Value::Null))) && is_true(&(Value::Bool(in_op(&legalMoney, &code)))))) {
if !is_equal(&code, &Value::Null) {
currency = self.currency(code.clone());
}
add_element_to_object(&mut request, &Value::Str("transactionType".to_string()), Value::Int(0));
if !is_equal(&since, &Value::Null) {
add_element_to_object(&mut request, &Value::Str("beginTime".to_string()), since.clone());
}
if !is_equal(&until, &Value::Null) {
add_element_to_object(&mut request, &Value::Str("endTime".to_string()), until.clone());
}
let __ws_arg_136 = self.extend(request.clone(), &[params.clone()]);
let mut raw: Value = self.sapi_get_fiat_orders(&[__ws_arg_136]).await;
response = self.safe_list_k(raw.clone(), "data", &[Value::List(vec![])]);
} else {
if !is_equal(&code, &Value::Null) {
currency = self.currency(code.clone());
add_element_to_object(&mut request, &Value::Str("coin".to_string()), get_value(¤cy, &Value::Str("id".to_string())));
}
if !is_equal(&since, &Value::Null) {
add_element_to_object(&mut request, &Value::Str("startTime".to_string()), since.clone());
// max 3 months range https://github.com/ccxt/ccxt/issues/6495
let mut endTime: Value = self.sum(&[since.clone(), Value::Int(7776000000)]);
if !is_equal(&until, &Value::Null) {
endTime = crate::runtime::Math::min(&endTime, &until);
}
add_element_to_object(&mut request, &Value::Str("endTime".to_string()), endTime.clone());
}
if !is_equal(&limit, &Value::Null) {
add_element_to_object(&mut request, &Value::Str("limit".to_string()), limit.clone());
}
let __ws_arg_137 = self.extend(request.clone(), &[params.clone()]);
response = self.sapi_get_capital_deposit_hisrec(&[__ws_arg_137]).await;
}
if is_equal(&response, &Value::Null) {
panic!("{}", crate::exchange_errors::null_response(add(&self.id, &Value::Str(" method() returned empty response".to_string()))));
}
let mut responseList: Value = Value::List(vec![]);
if !is_equal(&response, &Value::Null) {
responseList = self.to_array(response.clone());
}
{
let mut i: Value = Value::Int(0);
let mut __for_first_266: bool = true;
while { if !__for_first_266 { i = add(&i, &Value::Int(1)); } __for_first_266 = false; is_less_than(&i, &get_array_length(&responseList)) } {
add_element_to_object(get_value_mut(&mut responseList, &i), &Value::Str("type".to_string()), Value::Str("deposit".to_string()));
}
}
return self.parse_transactions(responseList.clone(), &[currency.clone(), since.clone(), limit.clone()]);
Value::Null
}
/*
* @method
* @name binance#fetchWithdrawals
* @description fetch all withdrawals made from an account
* @see https://developers.binance.com/docs/wallet/capital/withdraw-history
* @see https://developers.binance.com/docs/fiat/rest-api/Get-Fiat-Deposit-Withdraw-History
* @param {string} code unified currency code
* @param {int} [since] the earliest time in ms to fetch withdrawals for
* @param {int} [limit] the maximum number of withdrawals structures to retrieve
* @param {object} [params] extra parameters specific to the exchange API endpoint
* @param {bool} [params.fiat] if true, only fiat withdrawals will be returned
* @param {int} [params.until] the latest time in ms to fetch withdrawals for
* @param {boolean} [params.paginate] default false, when true will automatically paginate by calling this endpoint multiple times. See in the docs all the [available parameters](https://github.com/ccxt/ccxt/wiki/Manual#pagination-params)
* @returns {object[]} a list of [transaction structures]{@link https://docs.ccxt.com/?id=transaction-structure}
*/
pub async fn fetch_withdrawals(&mut self, optional_args: &[Value]) -> Value {
let mut code = get_arg(optional_args, 0, Value::Null);
let mut since = get_arg(optional_args, 1, Value::Null);
let mut limit = get_arg(optional_args, 2, Value::Null);
let mut params = get_arg(optional_args, 3, Value::Map({
let mut m = indexmap::IndexMap::new();
m
}));
if is_equal(&self.markets, &Value::Null) {
self.load_markets(&[]).await;
}
let mut paginate: Value = Value::Bool(false);
{ let __destr_tmp = self.handle_option_and_params(params.clone(), Value::Str("fetchWithdrawals".to_string()), Value::Str("paginate".to_string()), &[]); paginate = get_value(&__destr_tmp, &Value::Int(0)); params = get_value(&__destr_tmp, &Value::Int(1)); }
if is_true(&paginate) {
return self.fetch_paginated_call_dynamic(Value::Str("fetchWithdrawals".to_string()), &[code.clone(), since.clone(), limit.clone(), params.clone()]).await;
}
let mut legalMoney: Value = self.safe_dict_k(self.options.clone(), "legalMoney", &[Value::Map({
let mut m = indexmap::IndexMap::new();
m
})]);
let mut fiatOnly: Value = self.safe_bool_k(params.clone(), "fiat", &[Value::Bool(false)]);
params = self.omit(params.clone(), Value::Str("fiatOnly".to_string()), &[]);
let mut request: Value = Value::Map({
let mut m = indexmap::IndexMap::new();
m
});
let mut until: Value = self.safe_integer_k(params.clone(), "until", &[]);
if !is_equal(&until, &Value::Null) {
params = self.omit(params.clone(), Value::Str("until".to_string()), &[]);
add_element_to_object(&mut request, &Value::Str("endTime".to_string()), until.clone());
}
let mut response: Value = Value::Null;
let mut currency: Value = Value::Null;
if is_true(&(is_equal(&fiatOnly, &Value::Bool(true)))) || is_true(&(is_true(&(!is_equal(&code, &Value::Null))) && is_true(&(Value::Bool(in_op(&legalMoney, &code)))))) {
if !is_equal(&code, &Value::Null) {
currency = self.currency(code.clone());
}
add_element_to_object(&mut request, &Value::Str("transactionType".to_string()), Value::Int(1));
if !is_equal(&since, &Value::Null) {
add_element_to_object(&mut request, &Value::Str("beginTime".to_string()), since.clone());
}
let __ws_arg_138 = self.extend(request.clone(), &[params.clone()]);
let mut raw: Value = self.sapi_get_fiat_orders(&[__ws_arg_138]).await;
response = self.safe_list_k(raw.clone(), "data", &[Value::List(vec![])]);
} else {
if !is_equal(&code, &Value::Null) {
currency = self.currency(code.clone());
add_element_to_object(&mut request, &Value::Str("coin".to_string()), get_value(¤cy, &Value::Str("id".to_string())));
}
if !is_equal(&since, &Value::Null) {
add_element_to_object(&mut request, &Value::Str("startTime".to_string()), since.clone());
// max 3 months range https://github.com/ccxt/ccxt/issues/6495
add_element_to_object(&mut request, &Value::Str("endTime".to_string()), self.sum(&[since.clone(), Value::Int(7776000000)]));
}
if !is_equal(&limit, &Value::Null) {
add_element_to_object(&mut request, &Value::Str("limit".to_string()), limit.clone());
}
let __ws_arg_139 = self.extend(request.clone(), &[params.clone()]);
response = self.sapi_get_capital_withdraw_history(&[__ws_arg_139]).await;
}
if is_equal(&response, &Value::Null) {
panic!("{}", crate::exchange_errors::null_response(add(&self.id, &Value::Str(" method() returned empty response".to_string()))));
}
if is_string(&response) {
response = self.parse_json_value(response.clone());
}
let mut responseList: Value = Value::List(vec![]);
if !is_equal(&response, &Value::Null) {
responseList = self.to_array(response.clone());
}
{
let mut i: Value = Value::Int(0);
let mut __for_first_267: bool = true;
while { if !__for_first_267 { i = add(&i, &Value::Int(1)); } __for_first_267 = false; is_less_than(&i, &get_array_length(&responseList)) } {
add_element_to_object(get_value_mut(&mut responseList, &i), &Value::Str("type".to_string()), Value::Str("withdrawal".to_string()));
}
}
return self.parse_transactions(responseList.clone(), &[currency.clone(), since.clone(), limit.clone()]);
Value::Null
}
pub fn parse_transaction_status_by_type(&self, mut status: Value, optional_args: &[Value]) -> Value {
let mut type_var = get_arg(optional_args, 0, Value::Null);
if is_equal(&type_var, &Value::Null) {
return status;
}
let mut statusesByType: Value = Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("deposit".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("0".to_string(), Value::Str("pending".to_string()));
m.insert("1".to_string(), Value::Str("ok".to_string()));
m.insert("6".to_string(), Value::Str("ok".to_string()));
m.insert("Processing".to_string(), Value::Str("pending".to_string()));
m.insert("Failed".to_string(), Value::Str("failed".to_string()));
m.insert("Successful".to_string(), Value::Str("ok".to_string()));
m.insert("Refunding".to_string(), Value::Str("canceled".to_string()));
m.insert("Refunded".to_string(), Value::Str("canceled".to_string()));
m.insert("Refund Failed".to_string(), Value::Str("failed".to_string()));
m
}));
m.insert("withdrawal".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("0".to_string(), Value::Str("pending".to_string()));
m.insert("1".to_string(), Value::Str("canceled".to_string()));
m.insert("2".to_string(), Value::Str("pending".to_string()));
m.insert("3".to_string(), Value::Str("failed".to_string()));
m.insert("4".to_string(), Value::Str("pending".to_string()));
m.insert("5".to_string(), Value::Str("failed".to_string()));
m.insert("6".to_string(), Value::Str("ok".to_string()));
m.insert("Processing".to_string(), Value::Str("pending".to_string()));
m.insert("Failed".to_string(), Value::Str("failed".to_string()));
m.insert("Successful".to_string(), Value::Str("ok".to_string()));
m.insert("Refunding".to_string(), Value::Str("canceled".to_string()));
m.insert("Refunded".to_string(), Value::Str("canceled".to_string()));
m.insert("Refund Failed".to_string(), Value::Str("failed".to_string()));
m
}));
m
});
let mut statuses: Value = self.safe_dict(statusesByType.clone(), type_var.clone(), &[Value::Map({
let mut m = indexmap::IndexMap::new();
m
})]);
return self.safe_string(statuses.clone(), status.clone(), &[status.clone()]);
Value::Null
}
pub fn parse_transaction(&self, mut transaction: Value, optional_args: &[Value]) -> Value {
let mut currency = get_arg(optional_args, 0, Value::Null);
//
// fetchDeposits
//
// {
// "amount": "4500",
// "coin": "USDT",
// "network": "BSC",
// "status": 1,
// "address": "0xc9c923c87347ca0f3451d6d308ce84f691b9f501",
// "addressTag": "",
// "txId": "Internal transfer 51376627901",
// "insertTime": 1618394381000,
// "transferType": 1,
// "confirmTimes": "1/15"
// }
//
// fetchWithdrawals
//
// {
// "id": "69e53ad305124b96b43668ceab158a18",
// "amount": "28.75",
// "transactionFee": "0.25",
// "coin": "XRP",
// "status": 6,
// "address": "r3T75fuLjX51mmfb5Sk1kMNuhBgBPJsjza",
// "addressTag": "101286922",
// "txId": "19A5B24ED0B697E4F0E9CD09FCB007170A605BC93C9280B9E6379C5E6EF0F65A",
// "applyTime": "2021-04-15 12:09:16",
// "network": "XRP",
// "transferType": 0
// }
//
// fiat transaction
// withdraw
// {
// "orderNo": "CJW684897551397171200",
// "fiatCurrency": "GBP",
// "indicatedAmount": "29.99",
// "amount": "28.49",
// "totalFee": "1.50",
// "method": "bank transfer",
// "status": "Successful",
// "createTime": 1614898701000,
// "updateTime": 1614898820000
// }
//
// deposit
// {
// "orderNo": "25ced37075c1470ba8939d0df2316e23",
// "fiatCurrency": "EUR",
// "transactionType": 0,
// "indicatedAmount": "15.00",
// "amount": "15.00",
// "totalFee": "0.00",
// "method": "card",
// "status": "Failed",
// "createTime": "1627501026000",
// "updateTime": "1627501027000"
// }
//
// withdraw
//
// { id: "9a67628b16ba4988ae20d329333f16bc" }
//
let mut id: Value = self.safe_string2(transaction.clone(), Value::Str("id".to_string()), Value::Str("orderNo".to_string()), &[]);
let mut address: Value = self.safe_string_k(transaction.clone(), "address", &[]);
let mut tag: Value = self.safe_string_k(transaction.clone(), "addressTag", &[]); // set but unused
if !is_equal(&tag, &Value::Null) {
if is_less_than(&get_array_length(&tag), &Value::Int(1)) {
tag = Value::Null;
}
}
let mut txid: Value = self.safe_string_k(transaction.clone(), "txId", &[]);
if is_true(&(!is_equal(&txid, &Value::Null))) && is_true(&(is_greater_than_or_equal(&get_index_of(&txid, &Value::Str("Internal transfer ".to_string())), &Value::Int(0)))) {
txid = slice(&txid, &Value::Int(18), &Value::Null);
}
let mut currencyId: Value = self.safe_string2(transaction.clone(), Value::Str("coin".to_string()), Value::Str("fiatCurrency".to_string()), &[]);
let mut code: Value = self.safe_currency_code(currencyId.clone(), &[currency.clone()]);
let mut timestamp: Value = Value::Null;
timestamp = self.safe_integer2(transaction.clone(), Value::Str("insertTime".to_string()), Value::Str("createTime".to_string()), &[]);
if is_equal(×tamp, &Value::Null) {
timestamp = self.parse8601(self.safe_string_k(transaction.clone(), "applyTime", &[]));
}
let mut updated: Value = self.safe_integer2(transaction.clone(), Value::Str("successTime".to_string()), Value::Str("updateTime".to_string()), &[]);
let mut type_var: Value = self.safe_string_k(transaction.clone(), "type", &[]);
if is_equal(&type_var, &Value::Null) {
let mut txType: Value = self.safe_string_k(transaction.clone(), "transactionType", &[]);
if !is_equal(&txType, &Value::Null) {
type_var = ternary(is_true(&(is_equal(&txType, &Value::Str("0".to_string())))), Value::Str("deposit".to_string()), Value::Str("withdrawal".to_string()));
}
let mut legalMoneyCurrenciesById: Value = self.safe_dict_k(self.options.clone(), "legalMoneyCurrenciesById", &[]);
code = self.safe_string(legalMoneyCurrenciesById.clone(), code.clone(), &[code.clone()]);
}
let mut status: Value = self.parse_transaction_status_by_type(self.safe_string_k(transaction.clone(), "status", &[]), &[type_var.clone()]);
let mut amount: Value = self.safe_number_k(transaction.clone(), "amount", &[]);
let mut feeCost: Value = self.safe_number2(transaction.clone(), Value::Str("transactionFee".to_string()), Value::Str("totalFee".to_string()), &[]);
let mut fee: Value = Value::Null;
if !is_equal(&feeCost, &Value::Null) {
fee = Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("currency".to_string(), code.clone());
m.insert("cost".to_string(), feeCost.clone());
m
});
}
let mut internalInteger: Value = self.safe_integer_k(transaction.clone(), "transferType", &[]);
let mut internal: Value = Value::Null;
if !is_equal(&internalInteger, &Value::Null) {
internal = ternary(is_true(&(!is_equal(&internalInteger, &Value::Int(0)))), Value::Bool(true), Value::Bool(false));
}
let mut networkId: Value = self.safe_string_k(transaction.clone(), "network", &[]);
let mut network: Value = self.network_id_to_code(&[networkId.clone(), code.clone()]);
return Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("info".to_string(), transaction.clone());
m.insert("id".to_string(), id.clone());
m.insert("txid".to_string(), txid.clone());
m.insert("timestamp".to_string(), timestamp.clone());
m.insert("datetime".to_string(), self.iso8601(timestamp.clone()));
m.insert("network".to_string(), network.clone());
m.insert("address".to_string(), address.clone());
m.insert("addressTo".to_string(), address.clone());
m.insert("addressFrom".to_string(), Value::Null);
m.insert("tag".to_string(), tag.clone());
m.insert("tagTo".to_string(), tag.clone());
m.insert("tagFrom".to_string(), Value::Null);
m.insert("type".to_string(), type_var.clone());
m.insert("amount".to_string(), amount.clone());
m.insert("currency".to_string(), code.clone());
m.insert("status".to_string(), status.clone());
m.insert("updated".to_string(), updated.clone());
m.insert("internal".to_string(), internal.clone());
m.insert("comment".to_string(), Value::Null);
m.insert("fee".to_string(), fee.clone());
m
});
Value::Null
}
pub fn parse_transfer_status(&self, mut status: Value) -> Value {
let mut statuses: Value = Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("CONFIRMED".to_string(), Value::Str("ok".to_string()));
m
});
return self.safe_string(statuses.clone(), status.clone(), &[status.clone()]);
Value::Null
}
pub fn parse_transfer(&self, mut transfer: Value, optional_args: &[Value]) -> Value {
let mut currency = get_arg(optional_args, 0, Value::Null);
//
// transfer
//
// {
// "tranId":13526853623
// }
//
// fetchTransfers
//
// {
// "timestamp": 1614640878000,
// "asset": "USDT",
// "amount": "25",
// "type": "MAIN_UMFUTURE",
// "status": "CONFIRMED",
// "tranId": 43000126248
// }
//
// {
// "orderType": "C2C", // Enum:PAY(C2B Merchant Acquiring Payment), PAY_REFUND(C2B Merchant Acquiring Payment,refund), C2C(C2C Transfer Payment),CRYPTO_BOX(Crypto box), CRYPTO_BOX_RF(Crypto Box, refund), C2C_HOLDING(Transfer to new Binance user), C2C_HOLDING_RF(Transfer to new Binance user,refund), PAYOUT(B2C Disbursement Payment), REMITTANCE(Send cash)
// "transactionId": "M_P_71505104267788288",
// "transactionTime": 1610090460133, //trade timestamp
// "amount": "23.72469206", //order amount(up to 8 decimal places), positive is income, negative is expenditure
// "currency": "BNB",
// "walletType": 1, //main wallet type, 1 for funding wallet, 2 for spot wallet, 3 for fiat wallet, 4 or 6 for card payment, 5 for earn wallet
// "walletTypes": [1,2], //array format,there are multiple values when using combination payment
// "fundsDetail": [ // details
// {
// "currency": "USDT", //asset
// "amount": "1.2",
// "walletAssetCost":[ //details of asset cost per wallet
// {"1":"0.6"},
// {"2":"0.6"}
// ]
// },
// {
// "currency": "ETH",
// "amount": "0.0001",
// "walletAssetCost":[
// {"1":"0.00005"},
// {"2":"0.00005"}
// ]
// }
// ],
// "payerInfo":{
// "name":"Jack", //nickname or merchant name
// "type":"USER", //account type,USER for personal,MERCHANT for merchant
// "binanceId":"12345678", //binance uid
// "accountId":"67736251" //binance pay id
// },
// "receiverInfo":{
// "name":"Alan", //nickname or merchant name
// "type":"MERCHANT", //account type,USER for personal,MERCHANT for merchant
// "email":"alan@binance.com", //email
// "binanceId":"34355667", //binance uid
// "accountId":"21326891", //binance pay id
// "countryCode":"1", //International area code
// "phoneNumber":"8057651210",
// "mobileCode":"US", //country code
// "extend":[ //extension field
// "institutionName": "",
// "cardNumber": "",
// "digitalWalletId": ""
// ]
// }
// }
let mut id: Value = self.safe_string2(transfer.clone(), Value::Str("tranId".to_string()), Value::Str("transactionId".to_string()), &[]);
let mut currencyId: Value = self.safe_string2(transfer.clone(), Value::Str("asset".to_string()), Value::Str("currency".to_string()), &[]);
let mut code: Value = self.safe_currency_code(currencyId.clone(), &[currency.clone()]);
let mut amount: Value = self.safe_number_k(transfer.clone(), "amount", &[]);
let mut type_var: Value = self.safe_string_k(transfer.clone(), "type", &[]);
let mut fromAccount: Value = Value::Null;
let mut toAccount: Value = Value::Null;
let mut accountsById: Value = self.safe_dict_k(self.options.clone(), "accountsById", &[Value::Map({
let mut m = indexmap::IndexMap::new();
m
})]);
if !is_equal(&type_var, &Value::Null) {
let mut parts: Value = split(&type_var, &Value::Str("_".to_string()));
fromAccount = self.safe_value(parts.clone(), Value::Int(0), &[]);
toAccount = self.safe_value(parts.clone(), Value::Int(1), &[]);
fromAccount = self.safe_string(accountsById.clone(), fromAccount.clone(), &[fromAccount.clone()]);
toAccount = self.safe_string(accountsById.clone(), toAccount.clone(), &[toAccount.clone()]);
}
let mut walletType: Value = self.safe_integer_k(transfer.clone(), "walletType", &[]);
if !is_equal(&walletType, &Value::Null) {
let mut payer: Value = self.safe_dict_k(transfer.clone(), "payerInfo", &[Value::Map({
let mut m = indexmap::IndexMap::new();
m
})]);
let mut receiver: Value = self.safe_dict_k(transfer.clone(), "receiverInfo", &[Value::Map({
let mut m = indexmap::IndexMap::new();
m
})]);
fromAccount = self.safe_string_k(payer.clone(), "accountId", &[]);
toAccount = self.safe_string_k(receiver.clone(), "accountId", &[]);
}
let mut timestamp: Value = self.safe_integer2(transfer.clone(), Value::Str("timestamp".to_string()), Value::Str("transactionTime".to_string()), &[]);
let mut status: Value = self.parse_transfer_status(self.safe_string_k(transfer.clone(), "status", &[]));
return Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("info".to_string(), transfer.clone());
m.insert("id".to_string(), id.clone());
m.insert("timestamp".to_string(), timestamp.clone());
m.insert("datetime".to_string(), self.iso8601(timestamp.clone()));
m.insert("currency".to_string(), code.clone());
m.insert("amount".to_string(), amount.clone());
m.insert("fromAccount".to_string(), fromAccount.clone());
m.insert("toAccount".to_string(), toAccount.clone());
m.insert("status".to_string(), status.clone());
m
});
Value::Null
}
pub fn parse_income(&self, mut income: Value, optional_args: &[Value]) -> Value {
let mut market = get_arg(optional_args, 0, Value::Null);
//
// {
// "symbol": "ETHUSDT",
// "incomeType": "FUNDING_FEE",
// "income": "0.00134317",
// "asset": "USDT",
// "time": "1621584000000",
// "info": "FUNDING_FEE",
// "tranId": "4480321991774044580",
// "tradeId": ""
// }
//
let mut marketId: Value = self.safe_string_k(income.clone(), "symbol", &[]);
let mut currencyId: Value = self.safe_string_k(income.clone(), "asset", &[]);
let mut timestamp: Value = self.safe_integer_k(income.clone(), "time", &[]);
return Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("info".to_string(), income.clone());
m.insert("symbol".to_string(), self.safe_symbol(marketId.clone(), &[market.clone(), Value::Null, Value::Str("swap".to_string())]));
m.insert("code".to_string(), self.safe_currency_code(currencyId.clone(), &[]));
m.insert("timestamp".to_string(), timestamp.clone());
m.insert("datetime".to_string(), self.iso8601(timestamp.clone()));
m.insert("id".to_string(), self.safe_string_k(income.clone(), "tranId", &[]));
m.insert("amount".to_string(), self.safe_number_k(income.clone(), "income", &[]));
m
});
Value::Null
}
/*
* @method
* @name binance#transfer
* @description transfer currency internally between wallets on the same account
* @see https://developers.binance.com/docs/wallet/asset/user-universal-transfer
* @param {string} code unified currency code
* @param {float} amount amount to transfer
* @param {string} fromAccount account to transfer from
* @param {string} toAccount account to transfer to
* @param {object} [params] extra parameters specific to the exchange API endpoint
* @param {string} [params.type] exchange specific transfer type
* @param {string} [params.symbol] the unified symbol, required for isolated margin transfers
* @returns {object} a [transfer structure]{@link https://docs.ccxt.com/?id=transfer-structure}
*/
pub async fn transfer(&mut self, mut code: Value, mut amount: Value, mut fromAccount: Value, mut toAccount: Value, optional_args: &[Value]) -> Value {
let mut params = get_arg(optional_args, 0, Value::Map({
let mut m = indexmap::IndexMap::new();
m
}));
if is_equal(&self.markets, &Value::Null) {
self.load_markets(&[]).await;
}
let mut currency: Value = self.currency(code.clone());
let mut request: Value = Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("asset".to_string(), get_value(¤cy, &Value::Str("id".to_string())));
m.insert("amount".to_string(), self.currency_to_precision(code.clone(), amount.clone(), &[]));
m
});
add_element_to_object(&mut request, &Value::Str("type".to_string()), self.safe_string_k(params.clone(), "type", &[]));
params = self.omit(params.clone(), Value::Str("type".to_string()), &[]);
if is_equal(&get_value(&request, &Value::Str("type".to_string())), &Value::Null) {
let mut symbol: Value = self.safe_string_k(params.clone(), "symbol", &[]);
let mut market: Value = Value::Null;
if !is_equal(&symbol, &Value::Null) {
market = self.market(symbol.clone());
params = self.omit(params.clone(), Value::Str("symbol".to_string()), &[]);
}
let mut fromId: Value = to_upper(&self.convert_type_to_account(fromAccount.clone()));
let mut toId: Value = to_upper(&self.convert_type_to_account(toAccount.clone()));
let mut isolatedSymbol: Value = Value::Null;
if !is_equal(&market, &Value::Null) {
isolatedSymbol = get_value(&market, &Value::Str("id".to_string()));
}
if is_equal(&fromId, &Value::Str("ISOLATED".to_string())) {
if is_equal(&symbol, &Value::Null) {
panic!("{}", crate::exchange_errors::arguments_required(add(&add(&self.id, &Value::Str(" transfer () requires params[\"symbol\"] when fromAccount is ".to_string())), &fromAccount)));
}
}
if is_equal(&toId, &Value::Str("ISOLATED".to_string())) {
if is_equal(&symbol, &Value::Null) {
panic!("{}", crate::exchange_errors::arguments_required(add(&add(&self.id, &Value::Str(" transfer () requires params[\"symbol\"] when toAccount is ".to_string())), &toAccount)));
}
}
let mut accountsById: Value = self.safe_dict_k(self.options.clone(), "accountsById", &[Value::Map({
let mut m = indexmap::IndexMap::new();
m
})]);
let mut fromIsolated: bool = !is_true(&(Value::Bool(in_op(&accountsById, &fromId))));
let mut toIsolated: bool = !is_true(&(Value::Bool(in_op(&accountsById, &toId))));
if is_true(&fromIsolated) && is_true(&(is_equal(&market, &Value::Null))) {
isolatedSymbol = fromId.clone(); // allow user provide symbol as the from/to account
}
if is_true(&toIsolated) && is_true(&(is_equal(&market, &Value::Null))) {
isolatedSymbol = toId.clone();
}
if is_true(&fromIsolated) || is_true(&toIsolated) {
let mut fromFuture: bool = is_equal(&fromId, &Value::Str("UMFUTURE".to_string())) || is_equal(&fromId, &Value::Str("CMFUTURE".to_string()));
let mut toFuture: bool = is_equal(&toId, &Value::Str("UMFUTURE".to_string())) || is_equal(&toId, &Value::Str("CMFUTURE".to_string()));
let mut fromSpot: bool = is_equal(&fromId, &Value::Str("MAIN".to_string()));
let mut toSpot: bool = is_equal(&toId, &Value::Str("MAIN".to_string()));
let mut funding: bool = is_equal(&fromId, &Value::Str("FUNDING".to_string())) || is_equal(&toId, &Value::Str("FUNDING".to_string()));
let mut option: bool = is_equal(&fromId, &Value::Str("OPTION".to_string())) || is_equal(&toId, &Value::Str("OPTION".to_string()));
let mut prohibitedWithIsolated: bool = is_true(&fromFuture) || is_true(&toFuture) || is_true(&funding) || is_true(&option);
if is_true(&(is_true(&fromIsolated) || is_true(&toIsolated))) && is_true(&prohibitedWithIsolated) {
panic!("{}", crate::exchange_errors::bad_request(add(&add(&add(&add(&self.id, &Value::Str(" transfer () does not allow transfers between ".to_string())), &fromAccount), &Value::Str(" and ".to_string())), &toAccount)));
} else if is_true(&toSpot) && is_true(&fromIsolated) {
fromId = Value::Str("ISOLATED_MARGIN".to_string());
add_element_to_object(&mut request, &Value::Str("fromSymbol".to_string()), isolatedSymbol.clone());
} else if is_true(&fromSpot) && is_true(&toIsolated) {
toId = Value::Str("ISOLATED_MARGIN".to_string());
add_element_to_object(&mut request, &Value::Str("toSymbol".to_string()), isolatedSymbol.clone());
} else {
if is_true(&fromIsolated) && is_true(&toIsolated) {
add_element_to_object(&mut request, &Value::Str("fromSymbol".to_string()), fromId.clone());
add_element_to_object(&mut request, &Value::Str("toSymbol".to_string()), toId.clone());
fromId = Value::Str("ISOLATEDMARGIN".to_string());
toId = Value::Str("ISOLATEDMARGIN".to_string());
} else {
if is_true(&fromIsolated) {
add_element_to_object(&mut request, &Value::Str("fromSymbol".to_string()), isolatedSymbol.clone());
fromId = Value::Str("ISOLATEDMARGIN".to_string());
}
if is_true(&toIsolated) {
add_element_to_object(&mut request, &Value::Str("toSymbol".to_string()), isolatedSymbol.clone());
toId = Value::Str("ISOLATEDMARGIN".to_string());
}
}
}
add_element_to_object(&mut request, &Value::Str("type".to_string()), add(&add(&fromId, &Value::Str("_".to_string())), &toId));
} else {
add_element_to_object(&mut request, &Value::Str("type".to_string()), add(&add(&fromId, &Value::Str("_".to_string())), &toId));
}
}
let __ws_arg_140 = self.extend(request.clone(), &[params.clone()]);
let mut response: Value = self.sapi_post_asset_transfer(&[__ws_arg_140]).await;
return self.parse_transfer(response.clone(), &[currency.clone()]);
Value::Null
}
/*
* @method
* @name binance#fetchTransfers
* @description fetch a history of internal transfers made on an account
* @see https://developers.binance.com/docs/wallet/asset/query-user-universal-transfer
* @param {string} code unified currency code of the currency transferred
* @param {int} [since] the earliest time in ms to fetch transfers for
* @param {int} [limit] the maximum number of transfers structures to retrieve
* @param {object} [params] extra parameters specific to the exchange API endpoint
* @param {int} [params.until] the latest time in ms to fetch transfers for
* @param {boolean} [params.paginate] default false, when true will automatically paginate by calling this endpoint multiple times. See in the docs all the [available parameters](https://github.com/ccxt/ccxt/wiki/Manual#pagination-params)
* @param {boolean} [params.internal] default false, when true will fetch pay trade history
* @returns {object[]} a list of [transfer structures]{@link https://docs.ccxt.com/?id=transfer-structure}
*/
pub async fn fetch_transfers(&mut self, optional_args: &[Value]) -> Value {
let mut code = get_arg(optional_args, 0, Value::Null);
let mut since = get_arg(optional_args, 1, Value::Null);
let mut limit = get_arg(optional_args, 2, Value::Null);
let mut params = get_arg(optional_args, 3, Value::Map({
let mut m = indexmap::IndexMap::new();
m
}));
if is_equal(&self.markets, &Value::Null) {
self.load_markets(&[]).await;
}
let mut internal: Value = self.safe_bool_k(params.clone(), "internal", &[]);
params = self.omit(params.clone(), Value::Str("internal".to_string()), &[]);
let mut paginate: Value = Value::Bool(false);
{ let __destr_tmp = self.handle_option_and_params(params.clone(), Value::Str("fetchTransfers".to_string()), Value::Str("paginate".to_string()), &[]); paginate = get_value(&__destr_tmp, &Value::Int(0)); params = get_value(&__destr_tmp, &Value::Int(1)); }
if is_true(&paginate) && is_true(&(!is_equal(&internal, &Value::Bool(true)))) {
return self.fetch_paginated_call_dynamic(Value::Str("fetchTransfers".to_string()), &[code.clone(), since.clone(), limit.clone(), params.clone()]).await;
}
let mut currency: Value = Value::Null;
if !is_equal(&code, &Value::Null) {
currency = self.currency(code.clone());
}
let mut request: Value = Value::Map({
let mut m = indexmap::IndexMap::new();
m
});
let mut limitKey: Value = Value::Str("limit".to_string());
if !is_equal(&internal, &Value::Bool(true)) {
let mut defaultType: Value = self.safe_string2(self.options.clone(), Value::Str("fetchTransfers".to_string()), Value::Str("defaultType".to_string()), &[Value::Str("spot".to_string())]);
let mut fromAccount: Value = self.safe_string_k(params.clone(), "fromAccount", &[defaultType.clone()]);
let mut defaultTo: Value = ternary(is_true(&(is_equal(&fromAccount, &Value::Str("future".to_string())))), Value::Str("spot".to_string()), Value::Str("future".to_string()));
let mut toAccount: Value = self.safe_string_k(params.clone(), "toAccount", &[defaultTo.clone()]);
let mut type_var: Value = self.safe_string_k(params.clone(), "type", &[]);
let mut accountsByType: Value = self.safe_dict_k(self.options.clone(), "accountsByType", &[Value::Map({
let mut m = indexmap::IndexMap::new();
m
})]);
let mut fromId: Value = self.safe_string(accountsByType.clone(), fromAccount.clone(), &[]);
let mut toId: Value = self.safe_string(accountsByType.clone(), toAccount.clone(), &[]);
if is_equal(&type_var, &Value::Null) {
if is_equal(&fromId, &Value::Null) {
let mut keys: Value = object_keys(&accountsByType);
panic!("{}", crate::exchange_errors::exchange_error(add(&add(&self.id, &Value::Str(" fromAccount parameter must be one of ".to_string())), &join(&keys, &Value::Str(", ".to_string())))));
}
if is_equal(&toId, &Value::Null) {
let mut keys: Value = object_keys(&accountsByType);
panic!("{}", crate::exchange_errors::exchange_error(add(&add(&self.id, &Value::Str(" toAccount parameter must be one of ".to_string())), &join(&keys, &Value::Str(", ".to_string())))));
}
type_var = add(&add(&fromId, &Value::Str("_".to_string())), &toId);
}
add_element_to_object(&mut request, &Value::Str("type".to_string()), type_var.clone());
limitKey = Value::Str("size".to_string());
}
if !is_equal(&limit, &Value::Null) {
add_element_to_object(&mut request, &limitKey, limit.clone());
}
if !is_equal(&since, &Value::Null) {
add_element_to_object(&mut request, &Value::Str("startTime".to_string()), since.clone());
}
let mut until: Value = self.safe_integer_k(params.clone(), "until", &[]);
if !is_equal(&until, &Value::Null) {
params = self.omit(params.clone(), Value::Str("until".to_string()), &[]);
add_element_to_object(&mut request, &Value::Str("endTime".to_string()), until.clone());
}
let mut response: Value = Value::Null;
if is_equal(&internal, &Value::Bool(true)) {
let __ws_arg_141 = self.extend(request.clone(), &[params.clone()]);
response = self.sapi_get_pay_transactions(&[__ws_arg_141]).await;
} else {
let __ws_arg_142 = self.extend(request.clone(), &[params.clone()]);
response = self.sapi_get_asset_transfer(&[__ws_arg_142]).await;
}
let mut rows: Value = self.safe_list2(response.clone(), Value::Str("rows".to_string()), Value::Str("data".to_string()), &[Value::List(vec![])]);
return self.parse_transfers(rows.clone(), &[currency.clone(), since.clone(), limit.clone()]);
Value::Null
}
/*
* @method
* @name binance#fetchDepositAddress
* @description fetch the deposit address for a currency associated with this account
* @see https://developers.binance.com/docs/wallet/capital/deposite-address
* @param {string} code unified currency code
* @param {object} [params] extra parameters specific to the exchange API endpoint
* @param {string} [params.network] network for fetch deposit address
* @returns {object} an [address structure]{@link https://docs.ccxt.com/?id=address-structure}
*/
pub async fn fetch_deposit_address(&mut self, mut code: Value, optional_args: &[Value]) -> Value {
let mut params = get_arg(optional_args, 0, Value::Map({
let mut m = indexmap::IndexMap::new();
m
}));
if is_equal(&self.markets, &Value::Null) {
self.load_markets(&[]).await;
}
let mut currency: Value = self.currency(code.clone());
let mut request: Value = Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("coin".to_string(), get_value(¤cy, &Value::Str("id".to_string())));
m
});
let mut networkCode: Value = Value::Null;
{ let __destr_tmp = self.handle_network_code_and_params(params.clone()); networkCode = get_value(&__destr_tmp, &Value::Int(0)); params = get_value(&__destr_tmp, &Value::Int(1)); }
if !is_equal(&networkCode, &Value::Null) {
add_element_to_object(&mut request, &Value::Str("network".to_string()), self.network_code_to_id(networkCode.clone(), &[get_value(¤cy, &Value::Str("code".to_string()))]));
}
// has support for the 'network' parameter
let __ws_arg_143 = self.extend(request.clone(), &[params.clone()]);
let mut response: Value = self.sapi_get_capital_deposit_address(&[__ws_arg_143]).await;
return self.parse_deposit_address(response.clone(), &[currency.clone()]);
Value::Null
}
pub fn parse_deposit_address(&self, mut response: Value, optional_args: &[Value]) -> Value {
let mut currency = get_arg(optional_args, 0, Value::Null);
//
// {
// "coin": "XRP",
// "address": "rEb8TK3gBgk5auZkwc6sHnwrGVJH8DuaLh",
// "tag": "108618262",
// "url": "https://bithomp.com/explorer/rEb8TK3gBgk5auZkwc6sHnwrGVJH8DuaLh"
// }
//
let mut url: Value = self.safe_string_k(response.clone(), "url", &[]);
let mut address: Value = self.safe_string_k(response.clone(), "address", &[]);
let mut currencyId: Value = self.safe_string_k(response.clone(), "currency", &[]);
let mut code: Value = self.safe_currency_code(currencyId.clone(), &[currency.clone()]);
// deposit-address endpoint provides only network url (not network ID/CODE)
// so we should map the url to network (their data is inside currencies)
let mut networkCode: Value = self.get_network_code_by_network_url(code.clone(), &[url.clone()]);
let mut tag: Value = self.safe_string_k(response.clone(), "tag", &[Value::Str("".to_string())]);
if is_equal(&get_array_length(&tag), &Value::Int(0)) {
tag = Value::Null;
}
self.check_address(&[address.clone()]);
return Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("info".to_string(), response.clone());
m.insert("currency".to_string(), code.clone());
m.insert("network".to_string(), networkCode.clone());
m.insert("address".to_string(), address.clone());
m.insert("tag".to_string(), tag.clone());
m
});
Value::Null
}
/*
* @method
* @name binance#fetchTransactionFees
* @deprecated
* @description please use fetchDepositWithdrawFees instead
* @see https://developers.binance.com/docs/wallet/capital/all-coins-info
* @param {string[]|undefined} codes not used by fetchTransactionFees ()
* @param {object} [params] extra parameters specific to the exchange API endpoint
* @returns {object[]} a list of [fee structures]{@link https://docs.ccxt.com/?id=fee-structure}
*/
pub async fn fetch_transaction_fees(&mut self, optional_args: &[Value]) -> Value {
let mut codes = get_arg(optional_args, 0, Value::Null);
let mut params = get_arg(optional_args, 1, Value::Map({
let mut m = indexmap::IndexMap::new();
m
}));
if is_equal(&self.markets, &Value::Null) {
self.load_markets(&[]).await;
}
let mut response: Value = self.sapi_get_capital_config_getall(&[params.clone()]).await;
//
// [
// {
// "coin": "BAT",
// "depositAllEnable": true,
// "withdrawAllEnable": true,
// "name": "Basic Attention Token",
// "free": "0",
// "locked": "0",
// "freeze": "0",
// "withdrawing": "0",
// "ipoing": "0",
// "ipoable": "0",
// "storage": "0",
// "isLegalMoney": false,
// "trading": true,
// "networkList": [
// {
// "network": "BNB",
// "coin": "BAT",
// "withdrawIntegerMultiple": "0.00000001",
// "isDefault": false,
// "depositEnable": true,
// "withdrawEnable": true,
// "depositDesc": '',
// "withdrawDesc": '',
// "specialTips": "The name of this asset is Basic Attention Token (BAT). Both a MEMO and an Address are required to successfully deposit your BEP2 tokens to Binance.",
// "name": "BEP2",
// "resetAddressStatus": false,
// "addressRegex": "^(bnb1)[0-9a-z]{38}$",
// "memoRegex": "^[0-9A-Za-z\\-_]{1,120}$",
// "withdrawFee": "0.27",
// "withdrawMin": "0.54",
// "withdrawMax": "10000000000",
// "minConfirm": "1",
// "unLockConfirm": "0"
// },
// {
// "network": "BSC",
// "coin": "BAT",
// "withdrawIntegerMultiple": "0.00000001",
// "isDefault": false,
// "depositEnable": true,
// "withdrawEnable": true,
// "depositDesc": '',
// "withdrawDesc": '',
// "specialTips": "The name of this asset is Basic Attention Token. Please ensure you are depositing Basic Attention Token (BAT) tokens under the contract address ending in 9766e.",
// "name": "BEP20 (BSC)",
// "resetAddressStatus": false,
// "addressRegex": "^(0x)[0-9A-Fa-f]{40}$",
// "memoRegex": '',
// "withdrawFee": "0.27",
// "withdrawMin": "0.54",
// "withdrawMax": "10000000000",
// "minConfirm": "15",
// "unLockConfirm": "0"
// },
// {
// "network": "ETH",
// "coin": "BAT",
// "withdrawIntegerMultiple": "0.00000001",
// "isDefault": true,
// "depositEnable": true,
// "withdrawEnable": true,
// "depositDesc": '',
// "withdrawDesc": '',
// "specialTips": "The name of this asset is Basic Attention Token. Please ensure you are depositing Basic Attention Token (BAT) tokens under the contract address ending in 887ef.",
// "name": "ERC20",
// "resetAddressStatus": false,
// "addressRegex": "^(0x)[0-9A-Fa-f]{40}$",
// "memoRegex": '',
// "withdrawFee": "27",
// "withdrawMin": "54",
// "withdrawMax": "10000000000",
// "minConfirm": "12",
// "unLockConfirm": "0"
// }
// ]
// }
// ]
//
let mut withdrawFees: Value = Value::Map({
let mut m = indexmap::IndexMap::new();
m
});
let mut coins: Value = self.to_array(response.clone());
{
let mut i: Value = Value::Int(0);
let mut __for_first_269: bool = true;
while { if !__for_first_269 { i = add(&i, &Value::Int(1)); } __for_first_269 = false; is_less_than(&i, &get_array_length(&coins)) } {
let mut entry: Value = get_value(&coins, &i);
let mut entry: Value = get_value(&coins, &i);
let mut currencyId: Value = self.safe_string_k(entry.clone(), "coin", &[]);
let mut code: Value = self.safe_currency_code(currencyId.clone(), &[]);
let mut networkList: Value = self.safe_list_k(entry.clone(), "networkList", &[Value::List(vec![])]);
if !is_equal(&code, &Value::Null) {
add_element_to_object(&mut withdrawFees, &code, Value::Map({
let mut m = indexmap::IndexMap::new();
m
}));
}
{
let mut j: Value = Value::Int(0);
let mut __for_first_268: bool = true;
while { if !__for_first_268 { j = add(&j, &Value::Int(1)); } __for_first_268 = false; is_less_than(&j, &get_array_length(&networkList)) } {
let mut networkEntry: Value = get_value(&networkList, &j);
let mut networkEntry: Value = get_value(&networkList, &j);
let mut networkId: Value = self.safe_string_k(networkEntry.clone(), "network", &[]);
let mut networkCode: Value = self.safe_currency_code(networkId.clone(), &[]);
let mut fee: Value = self.safe_number_k(networkEntry.clone(), "withdrawFee", &[]);
if is_true(&(!is_equal(&code, &Value::Null))) && is_true(&(!is_equal(&networkCode, &Value::Null))) {
add_element_to_object(get_value_mut(&mut withdrawFees, &code), &networkCode, fee.clone());
}
}
}
}
}
return Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("withdraw".to_string(), withdrawFees.clone());
m.insert("deposit".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m
}));
m.insert("info".to_string(), response.clone());
m
});
Value::Null
}
/*
* @method
* @name binance#fetchDepositWithdrawFees
* @description fetch deposit and withdraw fees
* @see https://developers.binance.com/docs/wallet/capital/all-coins-info
* @param {string[]|undefined} codes not used by fetchDepositWithdrawFees ()
* @param {object} [params] extra parameters specific to the exchange API endpoint
* @returns {object[]} a list of [fee structures]{@link https://docs.ccxt.com/?id=fee-structure}
*/
pub async fn fetch_deposit_withdraw_fees(&mut self, optional_args: &[Value]) -> Value {
let mut codes = get_arg(optional_args, 0, Value::Null);
let mut params = get_arg(optional_args, 1, Value::Map({
let mut m = indexmap::IndexMap::new();
m
}));
if is_equal(&self.markets, &Value::Null) {
self.load_markets(&[]).await;
}
let mut response: Value = self.sapi_get_capital_config_getall(&[params.clone()]).await;
return self.parse_deposit_withdraw_fees(response.clone(), &[codes.clone(), Value::Str("coin".to_string())]);
Value::Null
}
pub fn parse_deposit_withdraw_fee(&self, mut fee: Value, optional_args: &[Value]) -> Value {
let mut currency = get_arg(optional_args, 0, Value::Null);
//
// {
// "coin": "BAT",
// "depositAllEnable": true,
// "withdrawAllEnable": true,
// "name": "Basic Attention Token",
// "free": "0",
// "locked": "0",
// "freeze": "0",
// "withdrawing": "0",
// "ipoing": "0",
// "ipoable": "0",
// "storage": "0",
// "isLegalMoney": false,
// "trading": true,
// "networkList": [
// {
// "network": "BNB",
// "coin": "BAT",
// "withdrawIntegerMultiple": "0.00000001",
// "isDefault": false,
// "depositEnable": true,
// "withdrawEnable": true,
// "depositDesc": '',
// "withdrawDesc": '',
// "specialTips": "The name of this asset is Basic Attention Token (BAT). Both a MEMO and an Address are required to successfully deposit your BEP2 tokens to Binance.",
// "name": "BEP2",
// "resetAddressStatus": false,
// "addressRegex": "^(bnb1)[0-9a-z]{38}$",
// "memoRegex": "^[0-9A-Za-z\\-_]{1,120}$",
// "withdrawFee": "0.27",
// "withdrawMin": "0.54",
// "withdrawMax": "10000000000",
// "minConfirm": "1",
// "unLockConfirm": "0"
// },
// ...
// ]
// }
//
let mut code: Value = self.safe_string_k(currency.clone(), "code", &[]);
let mut networkList: Value = self.safe_list_k(fee.clone(), "networkList", &[Value::List(vec![])]);
let mut result: Value = self.deposit_withdraw_fee(fee.clone());
{
let mut j: Value = Value::Int(0);
let mut __for_first_270: bool = true;
while { if !__for_first_270 { j = add(&j, &Value::Int(1)); } __for_first_270 = false; is_less_than(&j, &get_array_length(&networkList)) } {
let mut networkEntry: Value = get_value(&networkList, &j);
let mut networkEntry: Value = get_value(&networkList, &j);
let mut networkId: Value = self.safe_string_k(networkEntry.clone(), "network", &[]);
let mut networkCode: Value = self.network_id_to_code(&[networkId.clone(), code.clone()]);
let mut withdrawFee: Value = self.safe_number_k(networkEntry.clone(), "withdrawFee", &[]);
let mut isDefault: Value = self.safe_bool_k(networkEntry.clone(), "isDefault", &[]);
if is_equal(&isDefault, &Value::Bool(true)) {
add_element_to_object(&mut result, &Value::Str("withdraw".to_string()), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("fee".to_string(), withdrawFee.clone());
m.insert("percentage".to_string(), Value::Null);
m
}));
}
if !is_equal(&networkCode, &Value::Null) {
add_element_to_object(get_value_mut(&mut result, &Value::Str("networks".to_string())), &networkCode, Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("withdraw".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("fee".to_string(), withdrawFee.clone());
m.insert("percentage".to_string(), Value::Null);
m
}));
m.insert("deposit".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("fee".to_string(), Value::Null);
m.insert("percentage".to_string(), Value::Null);
m
}));
m
}));
}
}
}
return result;
Value::Null
}
/*
* @method
* @name binance#withdraw
* @description make a withdrawal
* @see https://developers.binance.com/docs/wallet/capital/withdraw
* @param {string} code unified currency code
* @param {float} amount the amount to withdraw
* @param {string} address the address to withdraw to
* @param {string} tag
* @param {object} [params] extra parameters specific to the exchange API endpoint
* @returns {object} a [transaction structure]{@link https://docs.ccxt.com/?id=transaction-structure}
*/
pub async fn withdraw(&mut self, mut code: Value, mut amount: Value, mut address: Value, optional_args: &[Value]) -> Value {
let mut tag = get_arg(optional_args, 0, Value::Null);
let mut params = get_arg(optional_args, 1, Value::Map({
let mut m = indexmap::IndexMap::new();
m
}));
{ let __destr_tmp = self.handle_withdraw_tag_and_params(tag.clone(), params.clone()); tag = get_value(&__destr_tmp, &Value::Int(0)); params = get_value(&__destr_tmp, &Value::Int(1)); }
self.check_address(&[address.clone()]);
if is_equal(&self.markets, &Value::Null) {
self.load_markets(&[]).await;
}
let mut currency: Value = self.currency(code.clone());
let mut request: Value = Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("coin".to_string(), get_value(¤cy, &Value::Str("id".to_string())));
m.insert("address".to_string(), address.clone());
m
});
if !is_equal(&tag, &Value::Null) {
add_element_to_object(&mut request, &Value::Str("addressTag".to_string()), tag.clone());
}
let mut networkCode: Value = Value::Null;
{ let __destr_tmp = self.handle_network_code_and_params(params.clone()); networkCode = get_value(&__destr_tmp, &Value::Int(0)); params = get_value(&__destr_tmp, &Value::Int(1)); }
if !is_equal(&networkCode, &Value::Null) {
add_element_to_object(&mut request, &Value::Str("network".to_string()), self.network_code_to_id(networkCode.clone(), &[get_value(¤cy, &Value::Str("code".to_string()))]));
}
add_element_to_object(&mut request, &Value::Str("amount".to_string()), self.currency_to_precision(get_value(¤cy, &Value::Str("code".to_string())), amount.clone(), &[networkCode.clone()]));
let __ws_arg_144 = self.extend(request.clone(), &[params.clone()]);
let mut response: Value = self.sapi_post_capital_withdraw_apply(&[__ws_arg_144]).await;
return self.parse_transaction(response.clone(), &[currency.clone()]);
Value::Null
}
pub fn parse_trading_fee(&self, mut fee: Value, optional_args: &[Value]) -> Value {
let mut market = get_arg(optional_args, 0, Value::Null);
//
// spot
// [
// {
// "symbol": "BTCUSDT",
// "makerCommission": "0.001",
// "takerCommission": "0.001"
// }
// ]
//
// swap
// {
// "symbol": "BTCUSD_PERP",
// "makerCommissionRate": "0.00015", // 0.015%
// "takerCommissionRate": "0.00040" // 0.040%
// }
//
let mut marketId: Value = self.safe_string_k(fee.clone(), "symbol", &[]);
let mut symbol: Value = self.safe_symbol(marketId.clone(), &[market.clone(), Value::Null, Value::Str("spot".to_string())]);
return Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("info".to_string(), fee.clone());
m.insert("symbol".to_string(), symbol.clone());
m.insert("maker".to_string(), self.safe_number2(fee.clone(), Value::Str("makerCommission".to_string()), Value::Str("makerCommissionRate".to_string()), &[]));
m.insert("taker".to_string(), self.safe_number2(fee.clone(), Value::Str("takerCommission".to_string()), Value::Str("takerCommissionRate".to_string()), &[]));
m.insert("percentage".to_string(), Value::Null);
m.insert("tierBased".to_string(), Value::Null);
m
});
Value::Null
}
/*
* @method
* @name binance#fetchTradingFee
* @description fetch the trading fees for a market
* @see https://developers.binance.com/docs/wallet/asset/trade-fee
* @see https://developers.binance.com/docs/derivatives/usds-margined-futures/account/rest-api/User-Commission-Rate
* @see https://developers.binance.com/docs/derivatives/coin-margined-futures/account/rest-api/User-Commission-Rate
* @see https://developers.binance.com/docs/derivatives/portfolio-margin/account/Get-User-Commission-Rate-for-UM
* @see https://developers.binance.com/docs/derivatives/portfolio-margin/account/Get-User-Commission-Rate-for-CM
* @param {string} symbol unified market symbol
* @param {object} [params] extra parameters specific to the exchange API endpoint
* @param {boolean} [params.portfolioMargin] set to true if you would like to fetch trading fees in a portfolio margin account
* @param {string} [params.subType] "linear" or "inverse"
* @returns {object} a [fee structure]{@link https://docs.ccxt.com/?id=fee-structure}
*/
pub async fn fetch_trading_fee(&mut self, mut symbol: Value, optional_args: &[Value]) -> Value {
let mut params = get_arg(optional_args, 0, Value::Map({
let mut m = indexmap::IndexMap::new();
m
}));
if is_equal(&self.markets, &Value::Null) {
self.load_markets(&[]).await;
}
let mut market: Value = self.market(symbol.clone());
let mut type_var: Value = get_value(&market, &Value::Str("type".to_string()));
let mut subType: Value = Value::Null;
{ let __destr_tmp = self.handle_sub_type_and_params(Value::Str("fetchTradingFee".to_string()), &[market.clone(), params.clone()]); subType = get_value(&__destr_tmp, &Value::Int(0)); params = get_value(&__destr_tmp, &Value::Int(1)); }
let mut isPortfolioMargin: Value = Value::Null;
{ let __destr_tmp = self.handle_option_and_params2(params.clone(), Value::Str("fetchTradingFee".to_string()), Value::Str("papi".to_string()), Value::Str("portfolioMargin".to_string()), &[Value::Bool(false)]); isPortfolioMargin = get_value(&__destr_tmp, &Value::Int(0)); params = get_value(&__destr_tmp, &Value::Int(1)); }
let mut isLinear: Value = self.is_linear(type_var.clone(), &[subType.clone()]);
let mut isInverse: Value = self.is_inverse(type_var.clone(), &[subType.clone()]);
let mut request: Value = Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("symbol".to_string(), get_value(&market, &Value::Str("id".to_string())));
m
});
let mut response: Value = Value::Null;
if is_true(&isLinear) {
if is_true(&isPortfolioMargin) {
let __ws_arg_145 = self.extend(request.clone(), &[params.clone()]);
response = self.papi_get_um_commission_rate(&[__ws_arg_145]).await;
} else {
let __ws_arg_146 = self.extend(request.clone(), &[params.clone()]);
response = self.fapi_private_get_commission_rate(&[__ws_arg_146]).await;
}
} else if is_true(&isInverse) {
if is_true(&isPortfolioMargin) {
let __ws_arg_147 = self.extend(request.clone(), &[params.clone()]);
response = self.papi_get_cm_commission_rate(&[__ws_arg_147]).await;
} else {
let __ws_arg_148 = self.extend(request.clone(), &[params.clone()]);
response = self.dapi_private_get_commission_rate(&[__ws_arg_148]).await;
}
} else {
let __ws_arg_149 = self.extend(request.clone(), &[params.clone()]);
response = self.sapi_get_asset_trade_fee(&[__ws_arg_149]).await;
}
//
// spot
//
// [
// {
// "symbol": "BTCUSDT",
// "makerCommission": "0.001",
// "takerCommission": "0.001"
// }
// ]
//
// swap
//
// {
// "symbol": "BTCUSD_PERP",
// "makerCommissionRate": "0.00015", // 0.015%
// "takerCommissionRate": "0.00040" // 0.040%
// }
//
let mut data: Value = response.clone();
if is_true(&Value::Bool(is_array(&data))) {
data = self.safe_dict(data.clone(), Value::Int(0), &[Value::Map({
let mut m = indexmap::IndexMap::new();
m
})]);
}
if is_equal(&data, &Value::Null) {
panic!("{}", crate::exchange_errors::null_response(add(&self.id, &Value::Str(" parseTradingFee() returned empty response".to_string()))));
}
return self.parse_trading_fee(data.clone(), &[market.clone()]);
Value::Null
}
/*
* @method
* @name binance#fetchTradingFees
* @description fetch the trading fees for multiple markets
* @see https://developers.binance.com/docs/wallet/asset/trade-fee
* @see https://developers.binance.com/docs/derivatives/usds-margined-futures/account/rest-api/Account-Information-V2
* @see https://developers.binance.com/docs/derivatives/coin-margined-futures/account/rest-api/Account-Information
* @see https://developers.binance.com/docs/derivatives/usds-margined-futures/account/rest-api/Account-Config
* @param {object} [params] extra parameters specific to the exchange API endpoint
* @param {string} [params.subType] "linear" or "inverse"
* @returns {object} a dictionary of [fee structures]{@link https://docs.ccxt.com/?id=fee-structure} indexed by market symbols
*/
pub async fn fetch_trading_fees(&mut self, optional_args: &[Value]) -> Value {
let mut params = get_arg(optional_args, 0, Value::Map({
let mut m = indexmap::IndexMap::new();
m
}));
if is_equal(&self.markets, &Value::Null) {
self.load_markets(&[]).await;
}
let mut type_var: Value = Value::Null;
{ let __destr_tmp = self.handle_market_type_and_params(Value::Str("fetchTradingFees".to_string()), &[Value::Null, params.clone()]); type_var = get_value(&__destr_tmp, &Value::Int(0)); params = get_value(&__destr_tmp, &Value::Int(1)); }
let mut subType: Value = Value::Null;
{ let __destr_tmp = self.handle_sub_type_and_params(Value::Str("fetchTradingFees".to_string()), &[Value::Null, params.clone(), Value::Str("linear".to_string())]); subType = get_value(&__destr_tmp, &Value::Int(0)); params = get_value(&__destr_tmp, &Value::Int(1)); }
let mut isSpotOrMargin: bool = is_true(&(is_equal(&type_var, &Value::Str("spot".to_string())))) || is_true(&(is_equal(&type_var, &Value::Str("margin".to_string()))));
let mut isLinear: Value = self.is_linear(type_var.clone(), &[subType.clone()]);
let mut isInverse: Value = self.is_inverse(type_var.clone(), &[subType.clone()]);
let mut response: Value = Value::Null;
if is_true(&isSpotOrMargin) {
response = self.sapi_get_asset_trade_fee(&[params.clone()]).await;
} else if is_true(&isLinear) {
response = self.fapi_private_get_account_config(&[params.clone()]).await;
} else if is_true(&isInverse) {
response = self.dapi_private_get_account(&[params.clone()]).await;
}
//
// sapi / spot
//
// [
// {
// "symbol": "ZRXBNB",
// "makerCommission": "0.001",
// "takerCommission": "0.001"
// },
// {
// "symbol": "ZRXBTC",
// "makerCommission": "0.001",
// "takerCommission": "0.001"
// },
// ]
//
// fapi / future / linear
//
// {
// "feeTier": 0, // account commisssion tier
// "canTrade": true, // if can trade
// "canDeposit": true, // if can transfer in asset
// "canWithdraw": true, // if can transfer out asset
// "updateTime": 0,
// "totalInitialMargin": "0.00000000", // total initial margin required with current mark price (useless with isolated positions), only for USDT asset
// "totalMaintMargin": "0.00000000", // total maintenance margin required, only for USDT asset
// "totalWalletBalance": "23.72469206", // total wallet balance, only for USDT asset
// "totalUnrealizedProfit": "0.00000000", // total unrealized profit, only for USDT asset
// "totalMarginBalance": "23.72469206", // total margin balance, only for USDT asset
// "totalPositionInitialMargin": "0.00000000", // initial margin required for positions with current mark price, only for USDT asset
// "totalOpenOrderInitialMargin": "0.00000000", // initial margin required for open orders with current mark price, only for USDT asset
// "totalCrossWalletBalance": "23.72469206", // crossed wallet balance, only for USDT asset
// "totalCrossUnPnl": "0.00000000", // unrealized profit of crossed positions, only for USDT asset
// "availableBalance": "23.72469206", // available balance, only for USDT asset
// "maxWithdrawAmount": "23.72469206" // maximum amount for transfer out, only for USDT asset
// ...
// }
//
// dapi / delivery / inverse
//
// {
// "canDeposit": true,
// "canTrade": true,
// "canWithdraw": true,
// "feeTier": 2,
// "updateTime": 0
// }
//
if is_true(&isSpotOrMargin) {
//
// [
// {
// "symbol": "ZRXBNB",
// "makerCommission": "0.001",
// "takerCommission": "0.001"
// },
// {
// "symbol": "ZRXBTC",
// "makerCommission": "0.001",
// "takerCommission": "0.001"
// },
// ]
//
let mut result: Value = Value::Map({
let mut m = indexmap::IndexMap::new();
m
});
if is_equal(&response, &Value::Null) {
panic!("{}", crate::exchange_errors::null_response(add(&self.id, &Value::Str(" method() returned empty response".to_string()))));
}
let mut fees: Value = self.to_array(response.clone());
{
let mut i: Value = Value::Int(0);
let mut __for_first_271: bool = true;
while { if !__for_first_271 { i = add(&i, &Value::Int(1)); } __for_first_271 = false; is_less_than(&i, &get_array_length(&fees)) } {
let mut fee: Value = self.parse_trading_fee(get_value(&fees, &i), &[]);
let mut symbol: Value = get_value(&fee, &Value::Str("symbol".to_string()));
if !is_equal(&symbol, &Value::Null) {
add_element_to_object(&mut result, &symbol, fee.clone());
}
}
}
return result;
} else if is_true(&isLinear) {
//
// {
// "feeTier": 0, // account commisssion tier
// "canTrade": true, // if can trade
// "canDeposit": true, // if can transfer in asset
// "canWithdraw": true, // if can transfer out asset
// "updateTime": 0,
// "totalInitialMargin": "0.00000000", // total initial margin required with current mark price (useless with isolated positions), only for USDT asset
// "totalMaintMargin": "0.00000000", // total maintenance margin required, only for USDT asset
// "totalWalletBalance": "23.72469206", // total wallet balance, only for USDT asset
// "totalUnrealizedProfit": "0.00000000", // total unrealized profit, only for USDT asset
// "totalMarginBalance": "23.72469206", // total margin balance, only for USDT asset
// "totalPositionInitialMargin": "0.00000000", // initial margin required for positions with current mark price, only for USDT asset
// "totalOpenOrderInitialMargin": "0.00000000", // initial margin required for open orders with current mark price, only for USDT asset
// "totalCrossWalletBalance": "23.72469206", // crossed wallet balance, only for USDT asset
// "totalCrossUnPnl": "0.00000000", // unrealized profit of crossed positions, only for USDT asset
// "availableBalance": "23.72469206", // available balance, only for USDT asset
// "maxWithdrawAmount": "23.72469206" // maximum amount for transfer out, only for USDT asset
// ...
// }
//
let mut markets: Value = self.markets.clone();
if is_equal(&markets, &Value::Null) {
panic!("{}", crate::exchange_errors::exchange_error(add(&self.id, &Value::Str(" markets not loaded".to_string()))));
}
let mut symbols: Value = object_keys(&markets);
let mut result: Value = Value::Map({
let mut m = indexmap::IndexMap::new();
m
});
let mut feeTier: Value = self.safe_integer_k(response.clone(), "feeTier", &[]);
let mut feeTiers: Value = get_value(&get_value(&get_value(&self.fees, &Value::Str("linear".to_string())), &Value::Str("trading".to_string())), &Value::Str("tiers".to_string()));
let mut maker: Value = get_value(&get_value(&get_value(&feeTiers, &Value::Str("maker".to_string())), &feeTier), &Value::Int(1));
let mut taker: Value = get_value(&get_value(&get_value(&feeTiers, &Value::Str("taker".to_string())), &feeTier), &Value::Int(1));
{
let mut i: Value = Value::Int(0);
let mut __for_first_272: bool = true;
while { if !__for_first_272 { i = add(&i, &Value::Int(1)); } __for_first_272 = false; is_less_than(&i, &get_array_length(&symbols)) } {
let mut symbol: Value = get_value(&symbols, &i);
let mut symbol: Value = get_value(&symbols, &i);
let mut market: Value = get_value(&markets, &symbol);
let mut market: Value = get_value(&markets, &symbol);
if is_equal(&get_value(&market, &Value::Str("linear".to_string())), &Value::Bool(true)) {
add_element_to_object(&mut result, &symbol, Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("info".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("feeTier".to_string(), feeTier.clone());
m
}));
m.insert("symbol".to_string(), symbol.clone());
m.insert("maker".to_string(), maker.clone());
m.insert("taker".to_string(), taker.clone());
m
}));
}
}
}
return result;
} else if is_true(&isInverse) {
//
// {
// "canDeposit": true,
// "canTrade": true,
// "canWithdraw": true,
// "feeTier": 2,
// "updateTime": 0
// }
//
let mut markets: Value = self.markets.clone();
if is_equal(&markets, &Value::Null) {
panic!("{}", crate::exchange_errors::exchange_error(add(&self.id, &Value::Str(" markets not loaded".to_string()))));
}
let mut symbols: Value = object_keys(&markets);
let mut result: Value = Value::Map({
let mut m = indexmap::IndexMap::new();
m
});
let mut feeTier: Value = self.safe_integer_k(response.clone(), "feeTier", &[]);
let mut feeTiers: Value = get_value(&get_value(&get_value(&self.fees, &Value::Str("inverse".to_string())), &Value::Str("trading".to_string())), &Value::Str("tiers".to_string()));
let mut maker: Value = get_value(&get_value(&get_value(&feeTiers, &Value::Str("maker".to_string())), &feeTier), &Value::Int(1));
let mut taker: Value = get_value(&get_value(&get_value(&feeTiers, &Value::Str("taker".to_string())), &feeTier), &Value::Int(1));
{
let mut i: Value = Value::Int(0);
let mut __for_first_273: bool = true;
while { if !__for_first_273 { i = add(&i, &Value::Int(1)); } __for_first_273 = false; is_less_than(&i, &get_array_length(&symbols)) } {
let mut symbol: Value = get_value(&symbols, &i);
let mut symbol: Value = get_value(&symbols, &i);
let mut market: Value = get_value(&markets, &symbol);
let mut market: Value = get_value(&markets, &symbol);
if is_equal(&get_value(&market, &Value::Str("inverse".to_string())), &Value::Bool(true)) {
add_element_to_object(&mut result, &symbol, Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("info".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("feeTier".to_string(), feeTier.clone());
m
}));
m.insert("symbol".to_string(), symbol.clone());
m.insert("maker".to_string(), maker.clone());
m.insert("taker".to_string(), taker.clone());
m
}));
}
}
}
return result;
}
panic!("{}", crate::exchange_errors::not_supported(add(&add(&add(&self.id, &Value::Str(" fetchTradingFees() is not supported for ".to_string())), &type_var), &Value::Str(" markets".to_string()))));
Value::Null
}
/*
* @method
* @name binance#futuresTransfer
* @ignore
* @description transfer between futures account
* @see https://developers.binance.com/docs/derivatives/usds-margined-futures/account/rest-api/New-Future-Account-Transfer
* @param {string} code unified currency code
* @param {float} amount the amount to transfer
* @param {string} type 1 - transfer from spot account to USDT-Ⓜ futures account, 2 - transfer from USDT-Ⓜ futures account to spot account, 3 - transfer from spot account to COIN-Ⓜ futures account, 4 - transfer from COIN-Ⓜ futures account to spot account
* @param {object} [params] extra parameters specific to the exchange API endpoint
* @param {float} params.recvWindow
* @returns {object} a [transfer structure]{@link https://docs.ccxt.com/?id=futures-transfer-structure}
*/
pub async fn futures_transfer(&mut self, mut code: Value, mut amount: Value, mut type_var: Value, optional_args: &[Value]) -> Value {
let mut params = get_arg(optional_args, 0, Value::Map({
let mut m = indexmap::IndexMap::new();
m
}));
if is_true(&(is_less_than(&type_var, &Value::Int(1)))) || is_true(&(is_greater_than(&type_var, &Value::Int(4)))) {
panic!("{}", crate::exchange_errors::arguments_required(add(&self.id, &Value::Str(" type must be between 1 and 4".to_string()))));
}
if is_equal(&self.markets, &Value::Null) {
self.load_markets(&[]).await;
}
let mut currency: Value = self.currency(code.clone());
let mut request: Value = Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("asset".to_string(), get_value(¤cy, &Value::Str("id".to_string())));
m.insert("amount".to_string(), amount.clone());
m.insert("type".to_string(), type_var.clone());
m
});
let __ws_arg_150 = self.extend(request.clone(), &[params.clone()]);
let mut response: Value = self.sapi_post_futures_transfer(&[__ws_arg_150]).await;
return self.parse_transfer(response.clone(), &[currency.clone()]);
Value::Null
}
/*
* @method
* @name binance#fetchFundingRate
* @description fetch the current funding rate
* @see https://developers.binance.com/docs/derivatives/usds-margined-futures/market-data/rest-api/Mark-Price
* @see https://developers.binance.com/docs/derivatives/coin-margined-futures/market-data/rest-api/Index-Price-and-Mark-Price
* @param {string} symbol unified market symbol
* @param {object} [params] extra parameters specific to the exchange API endpoint
* @returns {object} a [funding rate structure]{@link https://docs.ccxt.com/?id=funding-rate-structure}
*/
pub async fn fetch_funding_rate(&mut self, mut symbol: Value, optional_args: &[Value]) -> Value {
let mut params = get_arg(optional_args, 0, Value::Map({
let mut m = indexmap::IndexMap::new();
m
}));
if is_equal(&self.markets, &Value::Null) {
self.load_markets(&[]).await;
}
let mut market: Value = self.market(symbol.clone());
let mut request: Value = Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("symbol".to_string(), get_value(&market, &Value::Str("id".to_string())));
m
});
let mut response: Value = Value::Null;
if is_equal(&get_value(&market, &Value::Str("linear".to_string())), &Value::Bool(true)) {
let __ws_arg_151 = self.extend(request.clone(), &[params.clone()]);
response = self.fapi_public_get_premium_index(&[__ws_arg_151]).await;
} else if is_equal(&get_value(&market, &Value::Str("inverse".to_string())), &Value::Bool(true)) {
let __ws_arg_152 = self.extend(request.clone(), &[params.clone()]);
response = self.dapi_public_get_premium_index(&[__ws_arg_152]).await;
} else {
panic!("{}", crate::exchange_errors::not_supported(add(&self.id, &Value::Str(" fetchFundingRate() supports linear and inverse contracts only".to_string()))));
}
if is_equal(&response, &Value::Null) {
panic!("{}", crate::exchange_errors::null_response(add(&self.id, &Value::Str(" fetchFundingRate() returned empty response".to_string()))));
}
if is_equal(&get_value(&market, &Value::Str("inverse".to_string())), &Value::Bool(true)) {
response = get_value(&response, &Value::Int(0));
}
return self.parse_funding_rate(response.clone(), &[market.clone()]);
Value::Null
}
/*
* @method
* @name binance#fetchFundingRateHistory
* @description fetches historical funding rate prices
* @see https://developers.binance.com/docs/derivatives/usds-margined-futures/market-data/rest-api/Get-Funding-Rate-History
* @see https://developers.binance.com/docs/derivatives/coin-margined-futures/market-data/rest-api/Get-Funding-Rate-History-of-Perpetual-Futures
* @param {string} symbol unified symbol of the market to fetch the funding rate history for
* @param {int} [since] timestamp in ms of the earliest funding rate to fetch
* @param {int} [limit] the maximum amount of [funding rate structures]{@link https://docs.ccxt.com/?id=funding-rate-history-structure} to fetch
* @param {object} [params] extra parameters specific to the exchange API endpoint
* @param {int} [params.until] timestamp in ms of the latest funding rate
* @param {boolean} [params.paginate] default false, when true will automatically paginate by calling this endpoint multiple times. See in the docs all the [available parameters](https://github.com/ccxt/ccxt/wiki/Manual#pagination-params)
* @param {string} [params.subType] "linear" or "inverse"
* @returns {object[]} a list of [funding rate structures]{@link https://docs.ccxt.com/?id=funding-rate-history-structure}
*/
pub async fn fetch_funding_rate_history(&mut self, optional_args: &[Value]) -> Value {
let mut symbol = get_arg(optional_args, 0, Value::Null);
let mut since = get_arg(optional_args, 1, Value::Null);
let mut limit = get_arg(optional_args, 2, Value::Null);
let mut params = get_arg(optional_args, 3, Value::Map({
let mut m = indexmap::IndexMap::new();
m
}));
if is_equal(&self.markets, &Value::Null) {
self.load_markets(&[]).await;
}
let mut request: Value = Value::Map({
let mut m = indexmap::IndexMap::new();
m
});
let mut paginate: Value = Value::Bool(false);
{ let __destr_tmp = self.handle_option_and_params(params.clone(), Value::Str("fetchFundingRateHistory".to_string()), Value::Str("paginate".to_string()), &[]); paginate = get_value(&__destr_tmp, &Value::Int(0)); params = get_value(&__destr_tmp, &Value::Int(1)); }
if is_true(&paginate) {
return self.fetch_paginated_call_deterministic(Value::Str("fetchFundingRateHistory".to_string()), &[symbol.clone(), since.clone(), limit.clone(), Value::Str("8h".to_string()), params.clone()]).await;
}
let mut defaultType: Value = self.safe_string2(self.options.clone(), Value::Str("fetchFundingRateHistory".to_string()), Value::Str("defaultType".to_string()), &[Value::Str("future".to_string())]);
let mut type_var: Value = self.safe_string_k(params.clone(), "type", &[defaultType.clone()]);
let mut market: Value = Value::Null;
if !is_equal(&symbol, &Value::Null) {
market = self.market(symbol.clone());
symbol = get_value(&market, &Value::Str("symbol".to_string()));
add_element_to_object(&mut request, &Value::Str("symbol".to_string()), get_value(&market, &Value::Str("id".to_string())));
}
let mut subType: Value = Value::Null;
{ let __destr_tmp = self.handle_sub_type_and_params(Value::Str("fetchFundingRateHistory".to_string()), &[market.clone(), params.clone(), Value::Str("linear".to_string())]); subType = get_value(&__destr_tmp, &Value::Int(0)); params = get_value(&__destr_tmp, &Value::Int(1)); }
params = self.omit(params.clone(), Value::Str("type".to_string()), &[]);
if !is_equal(&since, &Value::Null) {
add_element_to_object(&mut request, &Value::Str("startTime".to_string()), since.clone());
}
let mut until: Value = self.safe_integer_k(params.clone(), "until", &[]); // unified in milliseconds
let mut endTime: Value = self.safe_integer_k(params.clone(), "endTime", &[until.clone()]); // exchange-specific in milliseconds
params = self.omit(params.clone(), Value::List(vec![Value::Str("endTime".to_string()), Value::Str("until".to_string())]), &[]);
if !is_equal(&endTime, &Value::Null) {
add_element_to_object(&mut request, &Value::Str("endTime".to_string()), endTime.clone());
}
if !is_equal(&limit, &Value::Null) {
add_element_to_object(&mut request, &Value::Str("limit".to_string()), limit.clone());
}
let mut response: Value = Value::Null;
if is_true(&self.is_linear(type_var.clone(), &[subType.clone()])) {
let __ws_arg_153 = self.extend(request.clone(), &[params.clone()]);
response = self.fapi_public_get_funding_rate(&[__ws_arg_153]).await;
} else if is_true(&self.is_inverse(type_var.clone(), &[subType.clone()])) {
let __ws_arg_154 = self.extend(request.clone(), &[params.clone()]);
response = self.dapi_public_get_funding_rate(&[__ws_arg_154]).await;
} else {
panic!("{}", crate::exchange_errors::not_supported(add(&add(&add(&self.id, &Value::Str(" fetchFundingRateHistory() is not supported for ".to_string())), &type_var), &Value::Str(" markets".to_string()))));
}
return self.parse_funding_rate_histories(response.clone(), &[market.clone(), since.clone(), limit.clone()]);
Value::Null
}
pub fn parse_funding_rate_history(&self, mut contract: Value, optional_args: &[Value]) -> Value {
let mut market = get_arg(optional_args, 0, Value::Null);
//
// {
// "symbol": "BTCUSDT",
// "fundingRate": "0.00063521",
// "fundingTime": "1621267200000",
// }
//
let mut timestamp: Value = self.safe_integer_k(contract.clone(), "fundingTime", &[]);
return Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("info".to_string(), contract.clone());
m.insert("symbol".to_string(), self.safe_symbol(self.safe_string_k(contract.clone(), "symbol", &[]), &[Value::Null, Value::Null, Value::Str("swap".to_string())]));
m.insert("fundingRate".to_string(), self.safe_number_k(contract.clone(), "fundingRate", &[]));
m.insert("timestamp".to_string(), timestamp.clone());
m.insert("datetime".to_string(), self.iso8601(timestamp.clone()));
m
});
Value::Null
}
/*
* @method
* @name binance#fetchFundingRates
* @description fetch the funding rate for multiple markets
* @see https://developers.binance.com/docs/derivatives/usds-margined-futures/market-data/rest-api/Mark-Price
* @see https://developers.binance.com/docs/derivatives/coin-margined-futures/market-data/rest-api/Index-Price-and-Mark-Price
* @param {string[]|undefined} symbols list of unified market symbols
* @param {object} [params] extra parameters specific to the exchange API endpoint
* @param {string} [params.subType] "linear" or "inverse"
* @returns {object[]} a list of [funding rate structures]{@link https://docs.ccxt.com/?id=funding-rates-structure}, indexed by market symbols
*/
pub async fn fetch_funding_rates(&mut self, optional_args: &[Value]) -> Value {
let mut symbols = get_arg(optional_args, 0, Value::Null);
let mut params = get_arg(optional_args, 1, Value::Map({
let mut m = indexmap::IndexMap::new();
m
}));
if is_equal(&self.markets, &Value::Null) {
self.load_markets(&[]).await;
}
symbols = self.market_symbols(&[symbols.clone()]);
let mut defaultType: Value = self.safe_string2(self.options.clone(), Value::Str("fetchFundingRates".to_string()), Value::Str("defaultType".to_string()), &[Value::Str("future".to_string())]);
let mut type_var: Value = self.safe_string_k(params.clone(), "type", &[defaultType.clone()]);
let mut subType: Value = Value::Null;
{ let __destr_tmp = self.handle_sub_type_and_params(Value::Str("fetchFundingRates".to_string()), &[Value::Null, params.clone(), Value::Str("linear".to_string())]); subType = get_value(&__destr_tmp, &Value::Int(0)); params = get_value(&__destr_tmp, &Value::Int(1)); }
let mut query: Value = self.omit(params.clone(), Value::Str("type".to_string()), &[]);
let mut response: Value = Value::Null;
if is_true(&self.is_linear(type_var.clone(), &[subType.clone()])) {
response = self.fapi_public_get_premium_index(&[query.clone()]).await;
} else if is_true(&self.is_inverse(type_var.clone(), &[subType.clone()])) {
response = self.dapi_public_get_premium_index(&[query.clone()]).await;
} else {
panic!("{}", crate::exchange_errors::not_supported(add(&self.id, &Value::Str(" fetchFundingRates() supports linear and inverse contracts only".to_string()))));
}
return self.parse_funding_rates(response.clone(), &[symbols.clone()]);
Value::Null
}
pub fn parse_funding_rate(&self, mut contract: Value, optional_args: &[Value]) -> Value {
let mut market = get_arg(optional_args, 0, Value::Null);
// ensure it matches with https://www.binance.com/en/futures/funding-history/0
//
// fetchFundingRate, fetchFundingRates
//
// {
// "symbol": "BTCUSDT",
// "markPrice": "45802.81129892",
// "indexPrice": "45745.47701915",
// "estimatedSettlePrice": "45133.91753671",
// "lastFundingRate": "0.00063521",
// "interestRate": "0.00010000",
// "nextFundingTime": "1621267200000",
// "time": "1621252344001"
// }
//
// fetchFundingInterval, fetchFundingIntervals
//
// {
// "symbol": "BLZUSDT",
// "adjustedFundingRateCap": "0.03000000",
// "adjustedFundingRateFloor": "-0.03000000",
// "fundingIntervalHours": 4,
// "disclaimer": false
// }
//
let mut timestamp: Value = self.safe_integer_k(contract.clone(), "time", &[]);
let mut marketId: Value = self.safe_string_k(contract.clone(), "symbol", &[]);
let mut symbol: Value = self.safe_symbol(marketId.clone(), &[market.clone(), Value::Null, Value::Str("contract".to_string())]);
let mut markPrice: Value = self.safe_number_k(contract.clone(), "markPrice", &[]);
let mut indexPrice: Value = self.safe_number_k(contract.clone(), "indexPrice", &[]);
let mut interestRate: Value = self.safe_number_k(contract.clone(), "interestRate", &[]);
let mut estimatedSettlePrice: Value = self.safe_number_k(contract.clone(), "estimatedSettlePrice", &[]);
let mut fundingRate: Value = self.safe_number_k(contract.clone(), "lastFundingRate", &[]);
let mut fundingTime: Value = self.safe_integer_k(contract.clone(), "nextFundingTime", &[]);
let mut interval: Value = self.safe_string_k(contract.clone(), "fundingIntervalHours", &[]);
let mut intervalString: Value = Value::Null;
if !is_equal(&interval, &Value::Null) {
intervalString = add(&interval, &Value::Str("h".to_string()));
}
return Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("info".to_string(), contract.clone());
m.insert("symbol".to_string(), symbol.clone());
m.insert("markPrice".to_string(), markPrice.clone());
m.insert("indexPrice".to_string(), indexPrice.clone());
m.insert("interestRate".to_string(), interestRate.clone());
m.insert("estimatedSettlePrice".to_string(), estimatedSettlePrice.clone());
m.insert("timestamp".to_string(), timestamp.clone());
m.insert("datetime".to_string(), self.iso8601(timestamp.clone()));
m.insert("fundingRate".to_string(), fundingRate.clone());
m.insert("fundingTimestamp".to_string(), fundingTime.clone());
m.insert("fundingDatetime".to_string(), self.iso8601(fundingTime.clone()));
m.insert("nextFundingRate".to_string(), Value::Null);
m.insert("nextFundingTimestamp".to_string(), Value::Null);
m.insert("nextFundingDatetime".to_string(), Value::Null);
m.insert("previousFundingRate".to_string(), Value::Null);
m.insert("previousFundingTimestamp".to_string(), Value::Null);
m.insert("previousFundingDatetime".to_string(), Value::Null);
m.insert("interval".to_string(), intervalString.clone());
m
});
Value::Null
}
pub fn parse_account_positions(&self, mut account: Value, optional_args: &[Value]) -> Value {
let mut filterClosed = get_arg(optional_args, 0, Value::Bool(false));
let mut positions: Value = self.safe_list_k(account.clone(), "positions", &[Value::List(vec![])]);
let mut assets: Value = self.safe_list_k(account.clone(), "assets", &[Value::List(vec![])]);
let mut balances: Value = Value::Map({
let mut m = indexmap::IndexMap::new();
m
});
{
let mut i: Value = Value::Int(0);
let mut __for_first_274: bool = true;
while { if !__for_first_274 { i = add(&i, &Value::Int(1)); } __for_first_274 = false; is_less_than(&i, &get_array_length(&assets)) } {
let mut entry: Value = get_value(&assets, &i);
let mut entry: Value = get_value(&assets, &i);
let mut currencyId: Value = self.safe_string_k(entry.clone(), "asset", &[]);
let mut code: Value = self.safe_currency_code(currencyId.clone(), &[]);
let mut crossWalletBalance: Value = self.safe_string_k(entry.clone(), "crossWalletBalance", &[]);
let mut crossUnPnl: Value = self.safe_string_k(entry.clone(), "crossUnPnl", &[]);
if !is_equal(&code, &Value::Null) {
add_element_to_object(&mut balances, &code, Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("crossMargin".to_string(), crate::precise::Precise::stringAdd(&crossWalletBalance, &crossUnPnl));
m.insert("crossWalletBalance".to_string(), crossWalletBalance.clone());
m
}));
}
}
}
let mut result: Value = Value::List(vec![]);
{
let mut i: Value = Value::Int(0);
let mut __for_first_275: bool = true;
while { if !__for_first_275 { i = add(&i, &Value::Int(1)); } __for_first_275 = false; is_less_than(&i, &get_array_length(&positions)) } {
let mut position: Value = get_value(&positions, &i);
let mut position: Value = get_value(&positions, &i);
let mut marketId: Value = self.safe_string_k(position.clone(), "symbol", &[]);
let mut market: Value = self.safe_market(&[marketId.clone(), Value::Null, Value::Null, Value::Str("contract".to_string())]);
let mut code: Value = ternary(is_true(&(is_equal(&get_value(&market, &Value::Str("linear".to_string())), &Value::Bool(true)))), get_value(&market, &Value::Str("quote".to_string())), get_value(&market, &Value::Str("base".to_string())));
let mut maintenanceMargin: Value = self.safe_string_k(position.clone(), "maintMargin", &[]);
// check for maintenance margin so empty positions are not returned
let mut isPositionOpen: bool = is_true(&(!is_equal(&maintenanceMargin, &Value::Str("0".to_string())))) && is_true(&(!is_equal(&maintenanceMargin, &Value::Str("0.00000000".to_string()))));
if !is_true(&filterClosed) || is_true(&isPositionOpen) {
// sometimes not all the codes are correctly returned...
if is_true(&Value::Bool(in_op(&balances, &code))) {
let __ws_arg_155 = self.extend(position.clone(), &[Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("crossMargin".to_string(), get_value(&get_value(&balances, &code), &Value::Str("crossMargin".to_string())));
m.insert("crossWalletBalance".to_string(), get_value(&get_value(&balances, &code), &Value::Str("crossWalletBalance".to_string())));
m
})]);
let mut parsed: Value = self.parse_account_position(__ws_arg_155, &[market.clone()]);
append_to_array(&mut result, parsed.clone());
}
}
}
}
return result;
Value::Null
}
pub fn parse_account_position(&self, mut position: Value, optional_args: &[Value]) -> Value {
let mut market = get_arg(optional_args, 0, Value::Null);
//
// usdm
//
// v3 (similar for cross & isolated)
//
// {
// "symbol": "WLDUSDT",
// "positionSide": "BOTH",
// "positionAmt": "-849",
// "unrealizedProfit": "11.17920750",
// "notional": "-1992.46079250",
// "isolatedMargin": "0",
// "isolatedWallet": "0",
// "initialMargin": "99.62303962",
// "maintMargin": "11.95476475",
// "updateTime": "1721995760449"
// "leverage": "50", // in v2
// "entryPrice": "2.34", // in v2
// "positionInitialMargin": "118.82116614", // in v2
// "openOrderInitialMargin": "0", // in v2
// "isolated": false, // in v2
// "breakEvenPrice": "2.3395788", // in v2
// "maxNotional": "25000", // in v2
// "bidNotional": "0", // in v2
// "askNotional": "0" // in v2
// }
//
// coinm
//
// {
// "symbol": "BTCUSD_210625",
// "initialMargin": "0.00024393",
// "maintMargin": "0.00002439",
// "unrealizedProfit": "-0.00000163",
// "positionInitialMargin": "0.00024393",
// "openOrderInitialMargin": "0",
// "leverage": "10",
// "isolated": false,
// "positionSide": "BOTH",
// "entryPrice": "41021.20000069",
// "maxQty": "100",
// "notionalValue": "0.00243939",
// "isolatedWallet": "0",
// "crossMargin": "0.314"
// "crossWalletBalance": "34",
// }
//
// linear portfolio margin
//
// {
// "symbol": "CTSIUSDT",
// "initialMargin": "0",
// "maintMargin": "0",
// "unrealizedProfit": "0.00000000",
// "positionInitialMargin": "0",
// "openOrderInitialMargin": "0",
// "leverage": "20",
// "entryPrice": "0.0",
// "maxNotional": "25000",
// "bidNotional": "0",
// "askNotional": "0",
// "positionSide": "SHORT",
// "positionAmt": "0",
// "updateTime": 0,
// "notional": "0",
// "breakEvenPrice": "0.0"
// }
//
// inverse portfolio margin
//
// {
// "symbol": "TRXUSD_PERP",
// "initialMargin": "0",
// "maintMargin": "0",
// "unrealizedProfit": "0.00000000",
// "positionInitialMargin": "0",
// "openOrderInitialMargin": "0",
// "leverage": "20",
// "entryPrice": "0.00000000",
// "positionSide": "SHORT",
// "positionAmt": "0",
// "maxQty": "5000000",
// "updateTime": 0,
// "notionalValue": "0",
// "breakEvenPrice": "0.00000000"
// }
//
let mut marketId: Value = self.safe_string_k(position.clone(), "symbol", &[]);
market = self.safe_market(&[marketId.clone(), market.clone(), Value::Null, Value::Str("contract".to_string())]);
let mut symbol: Value = self.safe_string_k(market.clone(), "symbol", &[]);
let mut leverageString: Value = self.omit_zero(self.safe_string_k(position.clone(), "leverage", &[])); // portfolio-margin accounts may return leverage "0", see #29244
let mut leverage: Value = ternary(is_true(&(!is_equal(&leverageString, &Value::Null))), crate::runtime::parse_int(&leverageString), Value::Null);
let mut initialMarginString: Value = self.safe_string_k(position.clone(), "initialMargin", &[]);
let mut initialMargin: Value = self.parse_number(initialMarginString.clone(), &[]);
let mut initialMarginPercentageString: Value = Value::Null;
if !is_equal(&leverageString, &Value::Null) {
initialMarginPercentageString = crate::precise::Precise::stringDivPrec(&Value::Str("1".to_string()), &leverageString, &Value::Int(8));
if is_equal(&leverage, &Value::Null) {
panic!("{}", crate::exchange_errors::exchange_error(add(&self.id, &Value::Str(" method() missing leverage".to_string()))));
}
let mut rational: Value = self.is_round_number(mod_val(&Value::Int(1000), &leverage));
if !is_true(&rational) {
initialMarginPercentageString = crate::precise::Precise::stringDivPrec(&crate::precise::Precise::stringAdd(&initialMarginPercentageString, &Value::Str("1e-8".to_string())), &Value::Str("1".to_string()), &Value::Int(8));
}
}
// as oppose to notionalValue
let mut usdm: Value = (Value::Bool(in_op(&position, &Value::Str("notional".to_string()))));
let mut maintenanceMarginString: Value = self.safe_string_k(position.clone(), "maintMargin", &[]);
let mut maintenanceMargin: Value = self.parse_number(maintenanceMarginString.clone(), &[]);
let mut entryPriceString: Value = self.safe_string_k(position.clone(), "entryPrice", &[]);
let mut entryPrice: Value = self.parse_number(entryPriceString.clone(), &[]);
let mut notionalString: Value = self.safe_string2(position.clone(), Value::Str("notional".to_string()), Value::Str("notionalValue".to_string()), &[]);
let mut notionalStringAbs: Value = crate::precise::Precise::stringAbs(¬ionalString);
let mut notional: Value = self.parse_number(notionalStringAbs.clone(), &[]);
let mut contractsString: Value = self.safe_string_k(position.clone(), "positionAmt", &[]);
let mut contractsStringAbs: Value = crate::precise::Precise::stringAbs(&contractsString);
if is_equal(&contractsString, &Value::Null) {
let mut entryNotional: Value = crate::precise::Precise::stringMul(&crate::precise::Precise::stringMul(&leverageString, &initialMarginString), &entryPriceString);
let mut contractSizeNew: Value = self.safe_string_k(market.clone(), "contractSize", &[]);
contractsString = crate::precise::Precise::stringDiv(&entryNotional, &contractSizeNew);
contractsStringAbs = crate::precise::Precise::stringDivPrec(&crate::precise::Precise::stringAdd(&contractsString, &Value::Str("0.5".to_string())), &Value::Str("1".to_string()), &Value::Int(0));
}
let mut contracts: Value = self.parse_number(contractsStringAbs.clone(), &[]);
let mut leverageBrackets: Value = self.safe_dict_k(self.options.clone(), "leverageBrackets", &[Value::Map({
let mut m = indexmap::IndexMap::new();
m
})]);
let mut leverageBracket: Value = self.safe_list(leverageBrackets.clone(), symbol.clone(), &[Value::List(vec![])]);
let mut maintenanceMarginPercentageString: Value = Value::Null;
{
let mut i: Value = Value::Int(0);
let mut __for_first_276: bool = true;
while { if !__for_first_276 { i = add(&i, &Value::Int(1)); } __for_first_276 = false; is_less_than(&i, &get_array_length(&leverageBracket)) } {
let mut bracket: Value = get_value(&leverageBracket, &i);
let mut bracket: Value = get_value(&leverageBracket, &i);
if is_true(&crate::precise::Precise::stringLt(¬ionalStringAbs, &get_value(&bracket, &Value::Int(0)))) {
break;
}
maintenanceMarginPercentageString = get_value(&bracket, &Value::Int(1));
}
}
let mut maintenanceMarginPercentage: Value = self.parse_number(maintenanceMarginPercentageString.clone(), &[]);
let mut unrealizedPnlString: Value = self.safe_string_k(position.clone(), "unrealizedProfit", &[]);
let mut unrealizedPnl: Value = self.parse_number(unrealizedPnlString.clone(), &[]);
let mut timestamp: Value = self.safe_integer_k(position.clone(), "updateTime", &[]);
if is_equal(×tamp, &Value::Int(0)) {
timestamp = Value::Null;
}
let mut isolated: Value = self.safe_bool_k(position.clone(), "isolated", &[]);
if is_equal(&isolated, &Value::Null) {
let mut isolatedMarginRaw: Value = self.safe_string_k(position.clone(), "isolatedMargin", &[]);
isolated = Value::Bool(!is_true(&crate::precise::Precise::stringEq(&isolatedMarginRaw, &Value::Str("0".to_string()))));
}
let mut marginMode: Value = Value::Null;
let mut collateralString: Value = Value::Null;
let mut walletBalance: Value = Value::Null;
if is_true(&isolated) {
marginMode = Value::Str("isolated".to_string());
walletBalance = self.safe_string_k(position.clone(), "isolatedWallet", &[]);
collateralString = crate::precise::Precise::stringAdd(&walletBalance, &unrealizedPnlString);
} else {
marginMode = Value::Str("cross".to_string());
walletBalance = self.safe_string_k(position.clone(), "crossWalletBalance", &[]);
collateralString = self.safe_string_k(position.clone(), "crossMargin", &[]);
}
let mut collateral: Value = self.parse_number(collateralString.clone(), &[]);
let mut marginRatio: Value = Value::Null;
let mut side: Value = Value::Null;
let mut percentage: Value = Value::Null;
let mut liquidationPriceStringRaw: Value = Value::Null;
let mut liquidationPrice: Value = Value::Null;
let mut contractSize: Value = self.safe_value_k(market.clone(), "contractSize", &[]);
let mut contractSizeString: Value = self.number_to_string(contractSize.clone());
if is_true(&crate::precise::Precise::stringEquals(¬ionalString, &Value::Str("0".to_string()))) {
entryPrice = Value::Null;
} else {
side = ternary(is_true(&crate::precise::Precise::stringLt(¬ionalString, &Value::Str("0".to_string()))), Value::Str("short".to_string()), Value::Str("long".to_string()));
marginRatio = self.parse_number(crate::precise::Precise::stringDivPrec(&crate::precise::Precise::stringAdd(&crate::precise::Precise::stringDiv(&maintenanceMarginString, &collateralString), &Value::Str("5e-5".to_string())), &Value::Str("1".to_string()), &Value::Int(4)), &[]);
percentage = self.parse_number(crate::precise::Precise::stringMul(&crate::precise::Precise::stringDivPrec(&unrealizedPnlString, &initialMarginString, &Value::Int(4)), &Value::Str("100".to_string())), &[]);
if is_true(&usdm) {
// calculate liquidation price
//
// liquidationPrice = (walletBalance / (contracts * (±1 + mmp))) + (±entryPrice / (±1 + mmp))
//
// mmp = maintenanceMarginPercentage
// where ± is negative for long and positive for short
// TODO: calculate liquidation price for coinm contracts
let mut onePlusMaintenanceMarginPercentageString: Value = Value::Null;
let mut entryPriceSignString: Value = entryPriceString.clone();
if is_equal(&side, &Value::Str("short".to_string())) {
onePlusMaintenanceMarginPercentageString = crate::precise::Precise::stringAdd(&Value::Str("1".to_string()), &maintenanceMarginPercentageString);
} else {
onePlusMaintenanceMarginPercentageString = crate::precise::Precise::stringAdd(&Value::Str("-1".to_string()), &maintenanceMarginPercentageString);
entryPriceSignString = crate::precise::Precise::stringMul(&Value::Str("-1".to_string()), &entryPriceSignString);
}
let mut leftSide: Value = crate::precise::Precise::stringDiv(&walletBalance, &crate::precise::Precise::stringMul(&contractsStringAbs, &onePlusMaintenanceMarginPercentageString));
let mut rightSide: Value = crate::precise::Precise::stringDiv(&entryPriceSignString, &onePlusMaintenanceMarginPercentageString);
liquidationPriceStringRaw = crate::precise::Precise::stringAdd(&leftSide, &rightSide);
} else {
// calculate liquidation price
//
// liquidationPrice = (contracts * contractSize(±1 - mmp)) / (±1/entryPrice * contracts * contractSize - walletBalance)
//
let mut onePlusMaintenanceMarginPercentageString: Value = Value::Null;
let mut entryPriceSignString: Value = entryPriceString.clone();
if is_equal(&side, &Value::Str("short".to_string())) {
onePlusMaintenanceMarginPercentageString = crate::precise::Precise::stringSub(&Value::Str("1".to_string()), &maintenanceMarginPercentageString);
} else {
onePlusMaintenanceMarginPercentageString = crate::precise::Precise::stringSub(&Value::Str("-1".to_string()), &maintenanceMarginPercentageString);
entryPriceSignString = crate::precise::Precise::stringMul(&Value::Str("-1".to_string()), &entryPriceSignString);
}
let mut size: Value = crate::precise::Precise::stringMul(&contractsStringAbs, &contractSizeString);
let mut leftSide: Value = crate::precise::Precise::stringMul(&size, &onePlusMaintenanceMarginPercentageString);
let mut rightSide: Value = crate::precise::Precise::stringSub(&crate::precise::Precise::stringMul(&crate::precise::Precise::stringDiv(&Value::Str("1".to_string()), &entryPriceSignString), &size), &walletBalance);
liquidationPriceStringRaw = crate::precise::Precise::stringDiv(&leftSide, &rightSide);
}
let mut pricePrecision: Value = self.precision_from_string(self.safe_string(get_value(&market, &Value::Str("precision".to_string())), Value::Str("price".to_string()), &[]));
let mut pricePrecisionPlusOne: Value = add(&pricePrecision, &Value::Int(1));
let mut pricePrecisionPlusOneString: Value = to_string_val(&pricePrecisionPlusOne);
// round half up
let mut rounder = Precise::new(add(&Value::Str("5e-".to_string()), &pricePrecisionPlusOneString));
let mut rounderString: Value = to_string_val(&rounder);
let mut liquidationPriceRoundedString: Value = crate::precise::Precise::stringAdd(&rounderString, &liquidationPriceStringRaw);
let mut truncatedLiquidationPrice: Value = crate::precise::Precise::stringDivPrec(&liquidationPriceRoundedString, &Value::Str("1".to_string()), &pricePrecision);
if !is_equal(&truncatedLiquidationPrice, &Value::Null) && is_equal(&get_value(&truncatedLiquidationPrice, &Value::Int(0)), &Value::Str("-".to_string())) {
// user cannot be liquidated
// since he has more collateral than the size of the position
truncatedLiquidationPrice = Value::Null;
}
liquidationPrice = self.parse_number(truncatedLiquidationPrice.clone(), &[]);
}
let mut positionSide: Value = self.safe_string_k(position.clone(), "positionSide", &[]);
let mut hedged: Value = Value::Bool(!is_equal(&positionSide, &Value::Str("BOTH".to_string())));
return Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("info".to_string(), position.clone());
m.insert("id".to_string(), Value::Null);
m.insert("symbol".to_string(), symbol.clone());
m.insert("timestamp".to_string(), timestamp.clone());
m.insert("datetime".to_string(), self.iso8601(timestamp.clone()));
m.insert("initialMargin".to_string(), initialMargin.clone());
m.insert("initialMarginPercentage".to_string(), self.parse_number(initialMarginPercentageString.clone(), &[]));
m.insert("maintenanceMargin".to_string(), maintenanceMargin.clone());
m.insert("maintenanceMarginPercentage".to_string(), maintenanceMarginPercentage.clone());
m.insert("entryPrice".to_string(), entryPrice.clone());
m.insert("notional".to_string(), notional.clone());
m.insert("leverage".to_string(), self.parse_number(leverageString.clone(), &[]));
m.insert("unrealizedPnl".to_string(), unrealizedPnl.clone());
m.insert("contracts".to_string(), contracts.clone());
m.insert("contractSize".to_string(), contractSize.clone());
m.insert("marginRatio".to_string(), marginRatio.clone());
m.insert("liquidationPrice".to_string(), liquidationPrice.clone());
m.insert("markPrice".to_string(), Value::Null);
m.insert("collateral".to_string(), collateral.clone());
m.insert("marginMode".to_string(), marginMode.clone());
m.insert("side".to_string(), side.clone());
m.insert("hedged".to_string(), hedged.clone());
m.insert("percentage".to_string(), percentage.clone());
m
});
Value::Null
}
pub fn parse_position_risk(&self, mut position: Value, optional_args: &[Value]) -> Value {
let mut market = get_arg(optional_args, 0, Value::Null);
//
// usdm
//
// {
// symbol: "WLDUSDT",
// positionSide: "BOTH",
// positionAmt: "5",
// entryPrice: "2.3483",
// breakEvenPrice: "2.349356735",
// markPrice: "2.39560000",
// unRealizedProfit: "0.23650000",
// liquidationPrice: "0",
// isolatedMargin: "0",
// notional: "11.97800000",
// isolatedWallet: "0",
// updateTime: "1722062678998",
// initialMargin: "2.39560000", // not in v2
// maintMargin: "0.07186800", // not in v2
// positionInitialMargin: "2.39560000", // not in v2
// openOrderInitialMargin: "0", // not in v2
// adl: "2", // not in v2
// bidNotional: "0", // not in v2
// askNotional: "0", // not in v2
// marginAsset: "USDT", // not in v2
// // the below fields are only in v2
// leverage: "5",
// maxNotionalValue: "6000000",
// marginType: "cross",
// isAutoAddMargin: "false",
// isolated: false,
// adlQuantile: "2",
//
// coinm
//
// {
// "symbol": "BTCUSD_PERP",
// "positionAmt": "2",
// "entryPrice": "37643.10000021",
// "markPrice": "38103.05510455",
// "unRealizedProfit": "0.00006413",
// "liquidationPrice": "25119.97445760",
// "leverage": "2",
// "maxQty": "1500",
// "marginType": "isolated",
// "isolatedMargin": "0.00274471",
// "isAutoAddMargin": "false",
// "positionSide": "BOTH",
// "notionalValue": "0.00524892",
// "isolatedWallet": "0.00268058"
// }
//
// inverse portfolio margin
//
// {
// "symbol": "ETHUSD_PERP",
// "positionAmt": "1",
// "entryPrice": "2422.400000007",
// "markPrice": "2424.51267823",
// "unRealizedProfit": "0.0000036",
// "liquidationPrice": "293.57678898",
// "leverage": "100",
// "positionSide": "LONG",
// "updateTime": 1707371941861,
// "maxQty": "15",
// "notionalValue": "0.00412454",
// "breakEvenPrice": "2423.368960034"
// }
//
// linear portfolio margin
//
// {
// "symbol": "BTCUSDT",
// "positionAmt": "0.01",
// "entryPrice": "44525.0",
// "markPrice": "45464.1735922",
// "unRealizedProfit": "9.39173592",
// "liquidationPrice": "38007.16308568",
// "leverage": "100",
// "positionSide": "LONG",
// "updateTime": 1707371879042,
// "maxNotionalValue": "500000.0",
// "notional": "454.64173592",
// "breakEvenPrice": "44542.81"
// }
//
let mut marketId: Value = self.safe_string_k(position.clone(), "symbol", &[]);
market = self.safe_market(&[marketId.clone(), market.clone(), Value::Null, Value::Str("contract".to_string())]);
let mut symbol: Value = self.safe_string_k(market.clone(), "symbol", &[]);
let mut isolatedMarginString: Value = self.safe_string_k(position.clone(), "isolatedMargin", &[]);
let mut leverageBrackets: Value = self.safe_dict_k(self.options.clone(), "leverageBrackets", &[Value::Map({
let mut m = indexmap::IndexMap::new();
m
})]);
let mut leverageBracket: Value = self.safe_list(leverageBrackets.clone(), symbol.clone(), &[Value::List(vec![])]);
let mut notionalString: Value = self.safe_string2(position.clone(), Value::Str("notional".to_string()), Value::Str("notionalValue".to_string()), &[]);
let mut notionalStringAbs: Value = crate::precise::Precise::stringAbs(¬ionalString);
let mut maintenanceMarginPercentageString: Value = Value::Null;
{
let mut i: Value = Value::Int(0);
let mut __for_first_277: bool = true;
while { if !__for_first_277 { i = add(&i, &Value::Int(1)); } __for_first_277 = false; is_less_than(&i, &get_array_length(&leverageBracket)) } {
let mut bracket: Value = get_value(&leverageBracket, &i);
let mut bracket: Value = get_value(&leverageBracket, &i);
if is_true(&crate::precise::Precise::stringLt(¬ionalStringAbs, &get_value(&bracket, &Value::Int(0)))) {
break;
}
maintenanceMarginPercentageString = get_value(&bracket, &Value::Int(1));
}
}
let mut notional: Value = self.parse_number(notionalStringAbs.clone(), &[]);
let mut contractsAbs: Value = crate::precise::Precise::stringAbs(&self.safe_string_k(position.clone(), "positionAmt", &[]));
let mut contracts: Value = self.parse_number(contractsAbs.clone(), &[]);
let mut unrealizedPnlString: Value = self.safe_string_k(position.clone(), "unRealizedProfit", &[]);
let mut unrealizedPnl: Value = self.parse_number(unrealizedPnlString.clone(), &[]);
let mut liquidationPriceString: Value = self.omit_zero(self.safe_string_k(position.clone(), "liquidationPrice", &[]));
let mut liquidationPrice: Value = self.parse_number(liquidationPriceString.clone(), &[]);
let mut collateralString: Value = Value::Null;
let mut marginMode: Value = self.safe_string_k(position.clone(), "marginType", &[]);
if is_equal(&marginMode, &Value::Null) && !is_equal(&isolatedMarginString, &Value::Null) {
marginMode = ternary(is_true(&crate::precise::Precise::stringEq(&isolatedMarginString, &Value::Str("0".to_string()))), Value::Str("cross".to_string()), Value::Str("isolated".to_string()));
}
let mut side: Value = Value::Null;
if is_true(&crate::precise::Precise::stringGt(¬ionalString, &Value::Str("0".to_string()))) {
side = Value::Str("long".to_string());
} else if is_true(&crate::precise::Precise::stringLt(¬ionalString, &Value::Str("0".to_string()))) {
side = Value::Str("short".to_string());
}
let mut entryPriceString: Value = self.safe_string_k(position.clone(), "entryPrice", &[]);
let mut entryPrice: Value = self.parse_number(entryPriceString.clone(), &[]);
let mut contractSize: Value = self.safe_value_k(market.clone(), "contractSize", &[]);
let mut contractSizeString: Value = self.number_to_string(contractSize.clone());
// as oppose to notionalValue
let mut linear: Value = (Value::Bool(in_op(&position, &Value::Str("notional".to_string()))));
if is_equal(&marginMode, &Value::Str("cross".to_string())) {
// calculate collateral
let mut precision: Value = self.safe_dict_k(market.clone(), "precision", &[Value::Map({
let mut m = indexmap::IndexMap::new();
m
})]);
let mut basePrecisionValue: Value = self.safe_string_k(precision.clone(), "base", &[]);
let mut quotePrecisionValue: Value = self.safe_string2(precision.clone(), Value::Str("quote".to_string()), Value::Str("price".to_string()), &[]);
let mut precisionIsUndefined: bool = is_true(&(is_equal(&basePrecisionValue, &Value::Null))) && is_true(&(is_equal("ePrecisionValue, &Value::Null)));
if !is_true(&precisionIsUndefined) {
if is_true(&linear) {
// walletBalance = (liquidationPrice * (±1 + mmp) ± entryPrice) * contracts
let mut onePlusMaintenanceMarginPercentageString: Value = Value::Null;
let mut entryPriceSignString: Value = entryPriceString.clone();
if is_equal(&side, &Value::Str("short".to_string())) {
onePlusMaintenanceMarginPercentageString = crate::precise::Precise::stringAdd(&Value::Str("1".to_string()), &maintenanceMarginPercentageString);
entryPriceSignString = crate::precise::Precise::stringMul(&Value::Str("-1".to_string()), &entryPriceSignString);
} else {
onePlusMaintenanceMarginPercentageString = crate::precise::Precise::stringAdd(&Value::Str("-1".to_string()), &maintenanceMarginPercentageString);
}
let mut inner: Value = crate::precise::Precise::stringMul(&liquidationPriceString, &onePlusMaintenanceMarginPercentageString);
let mut leftSide: Value = crate::precise::Precise::stringAdd(&inner, &entryPriceSignString);
let mut quotePrecision: Value = self.precision_from_string(self.safe_string2(precision.clone(), Value::Str("quote".to_string()), Value::Str("price".to_string()), &[]));
if !is_equal("ePrecision, &Value::Null) {
collateralString = crate::precise::Precise::stringDivPrec(&crate::precise::Precise::stringMul(&leftSide, &contractsAbs), &Value::Str("1".to_string()), "ePrecision);
}
} else {
// walletBalance = (contracts * contractSize) * (±1/entryPrice - (±1 - mmp) / liquidationPrice)
let mut onePlusMaintenanceMarginPercentageString: Value = Value::Null;
let mut entryPriceSignString: Value = entryPriceString.clone();
if is_equal(&side, &Value::Str("short".to_string())) {
onePlusMaintenanceMarginPercentageString = crate::precise::Precise::stringSub(&Value::Str("1".to_string()), &maintenanceMarginPercentageString);
} else {
onePlusMaintenanceMarginPercentageString = crate::precise::Precise::stringSub(&Value::Str("-1".to_string()), &maintenanceMarginPercentageString);
entryPriceSignString = crate::precise::Precise::stringMul(&Value::Str("-1".to_string()), &entryPriceSignString);
}
let mut leftSide: Value = crate::precise::Precise::stringMul(&contractsAbs, &contractSizeString);
let mut rightSide: Value = crate::precise::Precise::stringSub(&crate::precise::Precise::stringDiv(&Value::Str("1".to_string()), &entryPriceSignString), &crate::precise::Precise::stringDiv(&onePlusMaintenanceMarginPercentageString, &liquidationPriceString));
let mut basePrecision: Value = self.precision_from_string(self.safe_string_k(precision.clone(), "base", &[]));
if !is_equal(&basePrecision, &Value::Null) {
collateralString = crate::precise::Precise::stringDivPrec(&crate::precise::Precise::stringMul(&leftSide, &rightSide), &Value::Str("1".to_string()), &basePrecision);
}
}
}
} else {
collateralString = self.safe_string_k(position.clone(), "isolatedMargin", &[]);
}
collateralString = ternary(is_true(&(is_equal(&collateralString, &Value::Null))), Value::Str("0".to_string()), collateralString.clone());
let mut collateral: Value = self.parse_number(collateralString.clone(), &[]);
let mut markPrice: Value = self.parse_number(self.omit_zero(self.safe_string_k(position.clone(), "markPrice", &[])), &[]);
let mut timestamp: Value = self.safe_integer_k(position.clone(), "updateTime", &[]);
if is_equal(×tamp, &Value::Int(0)) {
timestamp = Value::Null;
}
let mut maintenanceMarginPercentage: Value = self.parse_number(maintenanceMarginPercentageString.clone(), &[]);
let mut maintenanceMarginString: Value = crate::precise::Precise::stringMul(&maintenanceMarginPercentageString, ¬ionalStringAbs);
if is_equal(&maintenanceMarginString, &Value::Null) {
// for a while, this new value was a backup to the existing calculations, but in future we might prioritize this
maintenanceMarginString = self.safe_string_k(position.clone(), "maintMargin", &[]);
}
let mut maintenanceMargin: Value = self.parse_number(maintenanceMarginString.clone(), &[]);
let mut initialMarginString: Value = Value::Null;
let mut initialMarginPercentageString: Value = Value::Null;
let mut leverageString: Value = self.omit_zero(self.safe_string_k(position.clone(), "leverage", &[])); // portfolio-margin accounts may return leverage "0", see #29244
if !is_equal(&leverageString, &Value::Null) {
let mut leverage: Value = crate::runtime::parse_int(&leverageString);
let mut rational: Value = self.is_round_number(mod_val(&Value::Int(1000), &leverage));
initialMarginPercentageString = crate::precise::Precise::stringDivPrec(&Value::Str("1".to_string()), &leverageString, &Value::Int(8));
if !is_true(&rational) {
initialMarginPercentageString = crate::precise::Precise::stringAdd(&initialMarginPercentageString, &Value::Str("1e-8".to_string()));
}
let mut unrounded: Value = crate::precise::Precise::stringMul(¬ionalStringAbs, &initialMarginPercentageString);
initialMarginString = crate::precise::Precise::stringDivPrec(&unrounded, &Value::Str("1".to_string()), &Value::Int(8));
} else {
initialMarginString = self.safe_string_k(position.clone(), "initialMargin", &[]);
let mut unrounded: Value = crate::precise::Precise::stringMul(&initialMarginString, &Value::Str("1".to_string()));
initialMarginPercentageString = crate::precise::Precise::stringDivPrec(&unrounded, ¬ionalStringAbs, &Value::Int(8));
}
let mut marginRatio: Value = Value::Null;
let mut percentage: Value = Value::Null;
if !is_true(&crate::precise::Precise::stringEquals(&collateralString, &Value::Str("0".to_string()))) {
marginRatio = self.parse_number(crate::precise::Precise::stringDivPrec(&crate::precise::Precise::stringAdd(&crate::precise::Precise::stringDiv(&maintenanceMarginString, &collateralString), &Value::Str("5e-5".to_string())), &Value::Str("1".to_string()), &Value::Int(4)), &[]);
percentage = self.parse_number(crate::precise::Precise::stringMul(&crate::precise::Precise::stringDivPrec(&unrealizedPnlString, &initialMarginString, &Value::Int(4)), &Value::Str("100".to_string())), &[]);
}
let mut positionSide: Value = self.safe_string_k(position.clone(), "positionSide", &[]);
let mut hedged: Value = Value::Bool(!is_equal(&positionSide, &Value::Str("BOTH".to_string())));
return self.safe_position(Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("info".to_string(), position.clone());
m.insert("id".to_string(), Value::Null);
m.insert("symbol".to_string(), symbol.clone());
m.insert("contracts".to_string(), contracts.clone());
m.insert("contractSize".to_string(), contractSize.clone());
m.insert("unrealizedPnl".to_string(), unrealizedPnl.clone());
m.insert("leverage".to_string(), self.parse_number(leverageString.clone(), &[]));
m.insert("liquidationPrice".to_string(), liquidationPrice.clone());
m.insert("collateral".to_string(), collateral.clone());
m.insert("notional".to_string(), notional.clone());
m.insert("markPrice".to_string(), markPrice.clone());
m.insert("entryPrice".to_string(), entryPrice.clone());
m.insert("timestamp".to_string(), timestamp.clone());
m.insert("initialMargin".to_string(), self.parse_number(initialMarginString.clone(), &[]));
m.insert("initialMarginPercentage".to_string(), self.parse_number(initialMarginPercentageString.clone(), &[]));
m.insert("maintenanceMargin".to_string(), maintenanceMargin.clone());
m.insert("maintenanceMarginPercentage".to_string(), maintenanceMarginPercentage.clone());
m.insert("marginRatio".to_string(), marginRatio.clone());
m.insert("datetime".to_string(), self.iso8601(timestamp.clone()));
m.insert("marginMode".to_string(), marginMode.clone());
m.insert("marginType".to_string(), marginMode.clone());
m.insert("side".to_string(), side.clone());
m.insert("hedged".to_string(), hedged.clone());
m.insert("percentage".to_string(), percentage.clone());
m.insert("stopLossPrice".to_string(), Value::Null);
m.insert("takeProfitPrice".to_string(), Value::Null);
m
}));
Value::Null
}
pub async fn load_leverage_brackets(&mut self, optional_args: &[Value]) -> Value {
let mut reload = get_arg(optional_args, 0, Value::Bool(false));
let mut params = get_arg(optional_args, 1, Value::Map({
let mut m = indexmap::IndexMap::new();
m
}));
if is_equal(&self.markets, &Value::Null) {
self.load_markets(&[]).await;
}
// by default cache the leverage bracket
// it contains useful stuff like the maintenance margin and initial margin for positions
let mut leverageBrackets: Value = self.safe_dict_k(self.options.clone(), "leverageBrackets", &[]);
if is_true(&(is_equal(&leverageBrackets, &Value::Null))) || is_true(&(reload)) {
let mut defaultType: Value = self.safe_string_k(self.options.clone(), "defaultType", &[Value::Str("future".to_string())]);
let mut type_var: Value = self.safe_string_k(params.clone(), "type", &[defaultType.clone()]);
let mut query: Value = self.omit(params.clone(), Value::Str("type".to_string()), &[]);
let mut subType: Value = Value::Null;
{ let __destr_tmp = self.handle_sub_type_and_params(Value::Str("loadLeverageBrackets".to_string()), &[Value::Null, params.clone(), Value::Str("linear".to_string())]); subType = get_value(&__destr_tmp, &Value::Int(0)); params = get_value(&__destr_tmp, &Value::Int(1)); }
let mut isPortfolioMargin: Value = Value::Null;
{ let __destr_tmp = self.handle_option_and_params2(params.clone(), Value::Str("loadLeverageBrackets".to_string()), Value::Str("papi".to_string()), Value::Str("portfolioMargin".to_string()), &[Value::Bool(false)]); isPortfolioMargin = get_value(&__destr_tmp, &Value::Int(0)); params = get_value(&__destr_tmp, &Value::Int(1)); }
let mut response: Value = Value::Null;
if is_true(&self.is_linear(type_var.clone(), &[subType.clone()])) {
if is_true(&isPortfolioMargin) {
response = self.papi_get_um_leverage_bracket(&[query.clone()]).await;
} else {
response = self.fapi_private_get_leverage_bracket(&[query.clone()]).await;
}
} else if is_true(&self.is_inverse(type_var.clone(), &[subType.clone()])) {
if is_true(&isPortfolioMargin) {
response = self.papi_get_cm_leverage_bracket(&[query.clone()]).await;
} else {
response = self.dapi_private_v2_get_leverage_bracket(&[query.clone()]).await;
}
} else {
panic!("{}", crate::exchange_errors::not_supported(add(&self.id, &Value::Str(" loadLeverageBrackets() supports linear and inverse contracts only".to_string()))));
}
{ let __be_tmp = self.create_safe_dictionary(&[]); add_element_to_object(&mut self.options, &Value::Str("leverageBrackets".to_string()), __be_tmp); };
if is_equal(&response, &Value::Null) {
panic!("{}", crate::exchange_errors::null_response(add(&self.id, &Value::Str(" loadLeverageBrackets() returned empty response".to_string()))));
}
let mut entries: Value = self.to_array(response.clone());
{
let mut i: Value = Value::Int(0);
let mut __for_first_279: bool = true;
while { if !__for_first_279 { i = add(&i, &Value::Int(1)); } __for_first_279 = false; is_less_than(&i, &get_array_length(&entries)) } {
let mut entry: Value = get_value(&entries, &i);
let mut entry: Value = get_value(&entries, &i);
let mut marketId: Value = self.safe_string_k(entry.clone(), "symbol", &[]);
let mut symbol: Value = self.safe_symbol(marketId.clone(), &[Value::Null, Value::Null, Value::Str("contract".to_string())]);
let mut brackets: Value = self.safe_list_k(entry.clone(), "brackets", &[Value::List(vec![])]);
let mut result: Value = Value::List(vec![]);
{
let mut j: Value = Value::Int(0);
let mut __for_first_278: bool = true;
while { if !__for_first_278 { j = add(&j, &Value::Int(1)); } __for_first_278 = false; is_less_than(&j, &get_array_length(&brackets)) } {
let mut bracket: Value = get_value(&brackets, &j);
let mut bracket: Value = get_value(&brackets, &j);
let mut floorValue: Value = self.safe_string2(bracket.clone(), Value::Str("notionalFloor".to_string()), Value::Str("qtyFloor".to_string()), &[]);
let mut maintenanceMarginPercentage: Value = self.safe_string_k(bracket.clone(), "maintMarginRatio", &[]);
append_to_array(&mut result, Value::List(vec![floorValue.clone(), maintenanceMarginPercentage.clone()]));
}
}
add_element_to_object(get_value_mut(&mut self.options, &Value::Str("leverageBrackets".to_string())), &symbol, result.clone());
}
}
}
return get_value(&self.options, &Value::Str("leverageBrackets".to_string()));
Value::Null
}
/*
* @method
* @name binance#fetchLeverageTiers
* @description retrieve information on the maximum leverage, and maintenance margin for trades of varying trade sizes
* @see https://developers.binance.com/docs/derivatives/usds-margined-futures/account/rest-api/Notional-and-Leverage-Brackets
* @see https://developers.binance.com/docs/derivatives/coin-margined-futures/account/rest-api/Notional-Bracket-for-Pair
* @see https://developers.binance.com/docs/derivatives/portfolio-margin/account/UM-Notional-and-Leverage-Brackets
* @see https://developers.binance.com/docs/derivatives/portfolio-margin/account/CM-Notional-and-Leverage-Brackets
* @param {string[]|undefined} symbols list of unified market symbols
* @param {object} [params] extra parameters specific to the exchange API endpoint
* @param {boolean} [params.portfolioMargin] set to true if you would like to fetch the leverage tiers for a portfolio margin account
* @param {string} [params.subType] "linear" or "inverse"
* @returns {object} a dictionary of [leverage tiers structures]{@link https://docs.ccxt.com/?id=leverage-tiers-structure}, indexed by market symbols
*/
pub async fn fetch_leverage_tiers(&mut self, optional_args: &[Value]) -> Value {
let mut symbols = get_arg(optional_args, 0, Value::Null);
let mut params = get_arg(optional_args, 1, Value::Map({
let mut m = indexmap::IndexMap::new();
m
}));
if is_equal(&self.markets, &Value::Null) {
self.load_markets(&[]).await;
}
let mut type_var: Value = Value::Null;
{ let __destr_tmp = self.handle_market_type_and_params(Value::Str("fetchLeverageTiers".to_string()), &[Value::Null, params.clone()]); type_var = get_value(&__destr_tmp, &Value::Int(0)); params = get_value(&__destr_tmp, &Value::Int(1)); }
let mut subType: Value = Value::Null;
{ let __destr_tmp = self.handle_sub_type_and_params(Value::Str("fetchLeverageTiers".to_string()), &[Value::Null, params.clone(), Value::Str("linear".to_string())]); subType = get_value(&__destr_tmp, &Value::Int(0)); params = get_value(&__destr_tmp, &Value::Int(1)); }
let mut isPortfolioMargin: Value = Value::Null;
{ let __destr_tmp = self.handle_option_and_params2(params.clone(), Value::Str("fetchLeverageTiers".to_string()), Value::Str("papi".to_string()), Value::Str("portfolioMargin".to_string()), &[Value::Bool(false)]); isPortfolioMargin = get_value(&__destr_tmp, &Value::Int(0)); params = get_value(&__destr_tmp, &Value::Int(1)); }
let mut response: Value = Value::Null;
if is_true(&self.is_linear(type_var.clone(), &[subType.clone()])) {
if is_true(&isPortfolioMargin) {
response = self.papi_get_um_leverage_bracket(&[params.clone()]).await;
} else {
response = self.fapi_private_get_leverage_bracket(&[params.clone()]).await;
}
} else if is_true(&self.is_inverse(type_var.clone(), &[subType.clone()])) {
if is_true(&isPortfolioMargin) {
response = self.papi_get_cm_leverage_bracket(&[params.clone()]).await;
} else {
response = self.dapi_private_v2_get_leverage_bracket(&[params.clone()]).await;
}
} else {
panic!("{}", crate::exchange_errors::not_supported(add(&self.id, &Value::Str(" fetchLeverageTiers() supports linear and inverse contracts only".to_string()))));
}
return self.parse_leverage_tiers(response.clone(), &[symbols.clone(), Value::Str("symbol".to_string())]);
Value::Null
}
pub fn parse_market_leverage_tiers(&self, mut info: Value, optional_args: &[Value]) -> Value {
let mut market = get_arg(optional_args, 0, Value::Null);
/*
* @ignore
* @method
* @param {object} info Exchange response for 1 market
* @param {object} market CCXT market
*/
//
// {
// "symbol": "SUSHIUSDT",
// "brackets": [
// {
// "bracket": 1,
// "initialLeverage": 50,
// "notionalCap": 50000,
// "notionalFloor": 0,
// "maintMarginRatio": 0.01,
// "cum": 0.0
// },
// ...
// ]
// }
//
let mut marketId: Value = self.safe_string_k(info.clone(), "symbol", &[]);
market = self.safe_market(&[marketId.clone(), market.clone(), Value::Null, Value::Str("contract".to_string())]);
let mut brackets: Value = self.safe_list_k(info.clone(), "brackets", &[Value::List(vec![])]);
let mut tiers: Value = Value::List(vec![]);
{
let mut j: Value = Value::Int(0);
let mut __for_first_280: bool = true;
while { if !__for_first_280 { j = add(&j, &Value::Int(1)); } __for_first_280 = false; is_less_than(&j, &get_array_length(&brackets)) } {
let mut bracket: Value = get_value(&brackets, &j);
let mut bracket: Value = get_value(&brackets, &j);
append_to_array(&mut tiers, Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("tier".to_string(), self.safe_number_k(bracket.clone(), "bracket", &[]));
m.insert("symbol".to_string(), self.safe_symbol(marketId.clone(), &[market.clone()]));
m.insert("currency".to_string(), get_value(&market, &Value::Str("quote".to_string())));
m.insert("minNotional".to_string(), self.safe_number2(bracket.clone(), Value::Str("notionalFloor".to_string()), Value::Str("qtyFloor".to_string()), &[]));
m.insert("maxNotional".to_string(), self.safe_number2(bracket.clone(), Value::Str("notionalCap".to_string()), Value::Str("qtyCap".to_string()), &[]));
m.insert("maintenanceMarginRate".to_string(), self.safe_number_k(bracket.clone(), "maintMarginRatio", &[]));
m.insert("maxLeverage".to_string(), self.safe_number_k(bracket.clone(), "initialLeverage", &[]));
m.insert("info".to_string(), bracket.clone());
m
}));
}
}
return tiers;
Value::Null
}
/*
* @method
* @name binance#fetchPosition
* @description fetch data on an open position
* @see https://developers.binance.com/docs/derivatives/option/trade/Option-Position-Information
* @param {string} symbol unified market symbol of the market the position is held in
* @param {object} [params] extra parameters specific to the exchange API endpoint
* @returns {object} a [position structure]{@link https://docs.ccxt.com/?id=position-structure}
*/
pub async fn fetch_position(&mut self, mut symbol: Value, optional_args: &[Value]) -> Value {
let mut params = get_arg(optional_args, 0, Value::Map({
let mut m = indexmap::IndexMap::new();
m
}));
if is_equal(&self.markets, &Value::Null) {
self.load_markets(&[]).await;
}
let mut market: Value = self.market(symbol.clone());
if !is_equal(&get_value(&market, &Value::Str("option".to_string())), &Value::Bool(true)) {
panic!("{}", crate::exchange_errors::not_supported(add(&self.id, &Value::Str(" fetchPosition() supports option markets only".to_string()))));
}
let mut request: Value = Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("symbol".to_string(), get_value(&market, &Value::Str("id".to_string())));
m
});
let __ws_arg_156 = self.extend(request.clone(), &[params.clone()]);
let mut response: Value = self.eapi_private_get_position(&[__ws_arg_156]).await;
return self.parse_option_position(self.safe_dict(response.clone(), Value::Int(0), &[Value::Map({
let mut m = indexmap::IndexMap::new();
m
})]), &[market.clone()]);
Value::Null
}
/*
* @method
* @name binance#fetchOptionPositions
* @description fetch data on open options positions
* @see https://developers.binance.com/docs/derivatives/option/trade/Option-Position-Information
* @param {string[]|undefined} symbols list of unified market symbols
* @param {object} [params] extra parameters specific to the exchange API endpoint
* @returns {object[]} a list of [position structures]{@link https://docs.ccxt.com/?id=position-structure}
*/
pub async fn fetch_option_positions(&mut self, optional_args: &[Value]) -> Value {
let mut symbols = get_arg(optional_args, 0, Value::Null);
let mut params = get_arg(optional_args, 1, Value::Map({
let mut m = indexmap::IndexMap::new();
m
}));
if is_equal(&self.markets, &Value::Null) {
self.load_markets(&[]).await;
}
symbols = self.market_symbols(&[symbols.clone()]);
let mut request: Value = Value::Map({
let mut m = indexmap::IndexMap::new();
m
});
let mut market: Value = Value::Null;
if !is_equal(&symbols, &Value::Null) {
let mut symbol: Value = Value::Null;
if is_true(&Value::Bool(is_array(&symbols))) {
let mut symbolsLength: Value = get_array_length(&symbols);
if is_greater_than(&symbolsLength, &Value::Int(1)) {
panic!("{}", crate::exchange_errors::bad_request(add(&self.id, &Value::Str(" fetchPositions() symbols argument cannot contain more than 1 symbol".to_string()))));
}
symbol = get_value(&symbols, &Value::Int(0));
} else {
symbol = symbols.clone();
}
market = self.market(symbol.clone());
add_element_to_object(&mut request, &Value::Str("symbol".to_string()), get_value(&market, &Value::Str("id".to_string())));
}
let __ws_arg_157 = self.extend(request.clone(), &[params.clone()]);
let mut response: Value = self.eapi_private_get_position(&[__ws_arg_157]).await;
//
// [
// {
// "entryPrice": "27.70000000",
// "symbol": "ETH-230426-1850-C",
// "side": "LONG",
// "quantity": "0.50000000",
// "reducibleQty": "0.50000000",
// "markValue": "10.250000000",
// "ror": "-0.2599",
// "unrealizedPNL": "-3.600000000",
// "markPrice": "20.5",
// "strikePrice": "1850.00000000",
// "positionCost": "13.85000000",
// "expiryDate": 1682496000000,
// "priceScale": 1,
// "quantityScale": 2,
// "optionSide": "CALL",
// "quoteAsset": "USDT",
// "time": 1682492427106
// }
// ]
//
let mut result: Value = Value::List(vec![]);
let mut positions: Value = self.to_array(response.clone());
{
let mut i: Value = Value::Int(0);
let mut __for_first_281: bool = true;
while { if !__for_first_281 { i = add(&i, &Value::Int(1)); } __for_first_281 = false; is_less_than(&i, &get_array_length(&positions)) } {
append_to_array(&mut result, self.parse_option_position(get_value(&positions, &i), &[market.clone()]));
}
}
return self.filter_by_array_positions(result.clone(), Value::Str("symbol".to_string()), &[symbols.clone(), Value::Bool(false)]);
Value::Null
}
pub fn parse_option_position(&self, mut position: Value, optional_args: &[Value]) -> Value {
let mut market = get_arg(optional_args, 0, Value::Null);
//
// {
// "entryPrice": "27.70000000",
// "symbol": "ETH-230426-1850-C",
// "side": "LONG",
// "quantity": "0.50000000",
// "reducibleQty": "0.50000000",
// "markValue": "10.250000000",
// "ror": "-0.2599",
// "unrealizedPNL": "-3.600000000",
// "markPrice": "20.5",
// "strikePrice": "1850.00000000",
// "positionCost": "13.85000000",
// "expiryDate": 1682496000000,
// "priceScale": 1,
// "quantityScale": 2,
// "optionSide": "CALL",
// "quoteAsset": "USDT",
// "time": 1682492427106
// }
//
let mut marketId: Value = self.safe_string_k(position.clone(), "symbol", &[]);
market = self.safe_market(&[marketId.clone(), market.clone(), Value::Null, Value::Str("swap".to_string())]);
let mut symbol: Value = get_value(&market, &Value::Str("symbol".to_string()));
let mut side: Value = self.safe_string_lower(position.clone(), Value::Str("side".to_string()), &[]);
let mut quantity: Value = self.safe_string_k(position.clone(), "quantity", &[]);
if !is_equal(&side, &Value::Str("long".to_string())) {
quantity = crate::precise::Precise::stringMul(&Value::Str("-1".to_string()), &quantity);
}
let mut timestamp: Value = self.safe_integer_k(position.clone(), "time", &[]);
return self.safe_position(Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("info".to_string(), position.clone());
m.insert("id".to_string(), Value::Null);
m.insert("symbol".to_string(), symbol.clone());
m.insert("entryPrice".to_string(), self.safe_number_k(position.clone(), "entryPrice", &[]));
m.insert("markPrice".to_string(), self.safe_number_k(position.clone(), "markPrice", &[]));
m.insert("notional".to_string(), self.safe_number_k(position.clone(), "markValue", &[]));
m.insert("collateral".to_string(), self.safe_number_k(position.clone(), "positionCost", &[]));
m.insert("unrealizedPnl".to_string(), self.safe_number_k(position.clone(), "unrealizedPNL", &[]));
m.insert("side".to_string(), side.clone());
m.insert("contracts".to_string(), self.parse_number(quantity.clone(), &[]));
m.insert("contractSize".to_string(), Value::Null);
m.insert("timestamp".to_string(), timestamp.clone());
m.insert("datetime".to_string(), self.iso8601(timestamp.clone()));
m.insert("hedged".to_string(), Value::Null);
m.insert("maintenanceMargin".to_string(), Value::Null);
m.insert("maintenanceMarginPercentage".to_string(), Value::Null);
m.insert("initialMargin".to_string(), Value::Null);
m.insert("initialMarginPercentage".to_string(), Value::Null);
m.insert("leverage".to_string(), Value::Null);
m.insert("liquidationPrice".to_string(), Value::Null);
m.insert("marginRatio".to_string(), Value::Null);
m.insert("marginMode".to_string(), Value::Null);
m.insert("percentage".to_string(), Value::Null);
m
}));
Value::Null
}
/*
* @method
* @name binance#fetchPositions
* @description fetch all open positions
* @see https://developers.binance.com/docs/derivatives/usds-margined-futures/account/rest-api/Account-Information-V2
* @see https://developers.binance.com/docs/derivatives/coin-margined-futures/account/rest-api/Account-Information
* @see https://developers.binance.com/docs/derivatives/usds-margined-futures/trade/rest-api/Position-Information-V2
* @see https://developers.binance.com/docs/derivatives/coin-margined-futures/trade/rest-api/Position-Information
* @see https://developers.binance.com/docs/derivatives/option/trade/Option-Position-Information
* @param {string[]} [symbols] list of unified market symbols
* @param {object} [params] extra parameters specific to the exchange API endpoint
* @param {object} [params.params] extra parameters specific to the exchange API endpoint
* @param {string} [params.method] method name to call, "positionRisk", "account" or "option", default is "positionRisk"
* @param {bool} [params.useV2] set to true if you want to use the obsolete endpoint, where some more additional fields were provided
* @returns {object[]} a list of [position structure]{@link https://docs.ccxt.com/?id=position-structure}
*/
pub async fn fetch_positions(&mut self, optional_args: &[Value]) -> Value {
let mut symbols = get_arg(optional_args, 0, Value::Null);
let mut params = get_arg(optional_args, 1, Value::Map({
let mut m = indexmap::IndexMap::new();
m
}));
let mut defaultMethod: Value = Value::Null;
{ let __destr_tmp = self.handle_option_and_params(params.clone(), Value::Str("fetchPositions".to_string()), Value::Str("method".to_string()), &[]); defaultMethod = get_value(&__destr_tmp, &Value::Int(0)); params = get_value(&__destr_tmp, &Value::Int(1)); }; // check if there is a key in options|params
if is_equal(&defaultMethod, &Value::Null) {
// check if .options['fetchPositions'] dict exist at all
let mut options: Value = self.safe_dict_k(self.options.clone(), "fetchPositions", &[]);
if is_equal(&options, &Value::Null) {
// if undefined, for backward compatibility, check if it is a string
defaultMethod = self.safe_string_k(self.options.clone(), "fetchPositions", &[Value::Str("positionRisk".to_string())]);
} else {
// if it is a dict, then it doesn't seem to have any 'method', so set default value
defaultMethod = Value::Str("positionRisk".to_string());
}
}
if is_equal(&defaultMethod, &Value::Str("positionRisk".to_string())) {
return self.fetch_positions_risk(&[symbols.clone(), params.clone()]).await;
} else if is_equal(&defaultMethod, &Value::Str("account".to_string())) {
return self.fetch_account_positions(&[symbols.clone(), params.clone()]).await;
} else if is_equal(&defaultMethod, &Value::Str("option".to_string())) {
return self.fetch_option_positions(&[symbols.clone(), params.clone()]).await;
} else {
panic!("{}", crate::exchange_errors::not_supported(add(&add(&add(&self.id, &Value::Str(".options[\"fetchPositions\"][\"method\"] or params[\"method\"] = \"".to_string())), &defaultMethod), &Value::Str("\" is invalid, please choose between \"account\", \"positionRisk\" and \"option\"".to_string()))));
}
Value::Null
}
/*
* @method
* @name binance#fetchAccountPositions
* @ignore
* @description fetch account positions
* @see https://developers.binance.com/docs/derivatives/usds-margined-futures/account/rest-api/Account-Information-V2
* @see https://developers.binance.com/docs/derivatives/coin-margined-futures/account/rest-api/Account-Information
* @see https://developers.binance.com/docs/derivatives/usds-margined-futures/trade/rest-api/Position-Information-V2
* @see https://developers.binance.com/docs/derivatives/coin-margined-futures/trade/rest-api/Position-Information
* @see https://developers.binance.com/docs/derivatives/usds-margined-futures/account/rest-api/Account-Information-V3
* @param {string[]} [symbols] list of unified market symbols
* @param {object} [params] extra parameters specific to the exchange API endpoint
* @param {boolean} [params.portfolioMargin] set to true if you would like to fetch positions in a portfolio margin account
* @param {string} [params.subType] "linear" or "inverse"
* @param {boolean} [params.filterClosed] set to true if you would like to filter out closed positions, default is false
* @param {boolean} [params.useV2] set to true if you want to use obsolete endpoint, where some more additional fields were provided
* @returns {object} data on account positions
*/
pub async fn fetch_account_positions(&mut self, optional_args: &[Value]) -> Value {
let mut symbols = get_arg(optional_args, 0, Value::Null);
let mut params = get_arg(optional_args, 1, Value::Map({
let mut m = indexmap::IndexMap::new();
m
}));
if !is_equal(&symbols, &Value::Null) {
if !is_true(&Value::Bool(is_array(&symbols))) {
panic!("{}", crate::exchange_errors::arguments_required(add(&self.id, &Value::Str(" fetchPositions() requires an array argument for symbols".to_string()))));
}
}
if is_equal(&self.markets, &Value::Null) {
self.load_markets(&[]).await;
}
self.load_leverage_brackets(&[Value::Bool(false), params.clone()]).await;
let mut defaultType: Value = self.safe_string_k(self.options.clone(), "defaultType", &[Value::Str("future".to_string())]);
let mut type_var: Value = self.safe_string_k(params.clone(), "type", &[defaultType.clone()]);
params = self.omit(params.clone(), Value::Str("type".to_string()), &[]);
let mut subType: Value = Value::Null;
{ let __destr_tmp = self.handle_sub_type_and_params(Value::Str("fetchAccountPositions".to_string()), &[Value::Null, params.clone(), Value::Str("linear".to_string())]); subType = get_value(&__destr_tmp, &Value::Int(0)); params = get_value(&__destr_tmp, &Value::Int(1)); }
let mut isPortfolioMargin: Value = Value::Null;
{ let __destr_tmp = self.handle_option_and_params2(params.clone(), Value::Str("fetchAccountPositions".to_string()), Value::Str("papi".to_string()), Value::Str("portfolioMargin".to_string()), &[Value::Bool(false)]); isPortfolioMargin = get_value(&__destr_tmp, &Value::Int(0)); params = get_value(&__destr_tmp, &Value::Int(1)); }
let mut response: Value = Value::Null;
if is_true(&self.is_linear(type_var.clone(), &[subType.clone()])) {
if is_true(&isPortfolioMargin) {
response = self.papi_v2_get_um_account(&[params.clone()]).await;
} else {
let mut useV2: Value = Value::Null;
{ let __destr_tmp = self.handle_option_and_params(params.clone(), Value::Str("fetchAccountPositions".to_string()), Value::Str("useV2".to_string()), &[Value::Bool(false)]); useV2 = get_value(&__destr_tmp, &Value::Int(0)); params = get_value(&__destr_tmp, &Value::Int(1)); }
if !is_true(&useV2) {
response = self.fapi_private_v3_get_account(&[params.clone()]).await;
} else {
response = self.fapi_private_v2_get_account(&[params.clone()]).await;
}
}
} else if is_true(&self.is_inverse(type_var.clone(), &[subType.clone()])) {
if is_true(&isPortfolioMargin) {
response = self.papi_get_cm_account(&[params.clone()]).await;
} else {
response = self.dapi_private_get_account(&[params.clone()]).await;
}
} else {
panic!("{}", crate::exchange_errors::not_supported(add(&self.id, &Value::Str(" fetchPositions() supports linear and inverse contracts only".to_string()))));
}
let mut filterClosed: Value = Value::Null;
{ let __destr_tmp = self.handle_option_and_params(params.clone(), Value::Str("fetchAccountPositions".to_string()), Value::Str("filterClosed".to_string()), &[Value::Bool(false)]); filterClosed = get_value(&__destr_tmp, &Value::Int(0)); params = get_value(&__destr_tmp, &Value::Int(1)); }
let mut result: Value = self.parse_account_positions(response.clone(), &[filterClosed.clone()]);
symbols = self.market_symbols(&[symbols.clone()]);
return self.filter_by_array_positions(result.clone(), Value::Str("symbol".to_string()), &[symbols.clone(), Value::Bool(false)]);
Value::Null
}
/*
* @method
* @name binance#fetchPositionsRisk
* @ignore
* @description fetch positions risk
* @see https://developers.binance.com/docs/derivatives/usds-margined-futures/trade/rest-api/Position-Information-V2
* @see https://developers.binance.com/docs/derivatives/coin-margined-futures/trade/rest-api/Position-Information
* @see https://developers.binance.com/docs/derivatives/portfolio-margin/account/Query-UM-Position-Information
* @see https://developers.binance.com/docs/derivatives/portfolio-margin/account/Query-CM-Position-Information
* @see https://developers.binance.com/docs/derivatives/usds-margined-futures/trade/rest-api/Position-Information-V3
* @param {string[]|undefined} symbols list of unified market symbols
* @param {object} [params] extra parameters specific to the exchange API endpoint
* @param {boolean} [params.portfolioMargin] set to true if you would like to fetch positions for a portfolio margin account
* @param {string} [params.subType] "linear" or "inverse"
* @param {bool} [params.useV2] set to true if you want to use the obsolete endpoint, where some more additional fields were provided
* @returns {object} data on the positions risk
*/
pub async fn fetch_positions_risk(&mut self, optional_args: &[Value]) -> Value {
let mut symbols = get_arg(optional_args, 0, Value::Null);
let mut params = get_arg(optional_args, 1, Value::Map({
let mut m = indexmap::IndexMap::new();
m
}));
if !is_equal(&symbols, &Value::Null) {
if !is_true(&Value::Bool(is_array(&symbols))) {
panic!("{}", crate::exchange_errors::arguments_required(add(&self.id, &Value::Str(" fetchPositionsRisk() requires an array argument for symbols".to_string()))));
}
}
if is_equal(&self.markets, &Value::Null) {
self.load_markets(&[]).await;
}
self.load_leverage_brackets(&[Value::Bool(false), params.clone()]).await;
let mut request: Value = Value::Map({
let mut m = indexmap::IndexMap::new();
m
});
let mut defaultType: Value = Value::Str("future".to_string());
defaultType = self.safe_string_k(self.options.clone(), "defaultType", &[defaultType.clone()]);
let mut type_var: Value = self.safe_string_k(params.clone(), "type", &[defaultType.clone()]);
let mut subType: Value = Value::Null;
{ let __destr_tmp = self.handle_sub_type_and_params(Value::Str("fetchPositionsRisk".to_string()), &[Value::Null, params.clone(), Value::Str("linear".to_string())]); subType = get_value(&__destr_tmp, &Value::Int(0)); params = get_value(&__destr_tmp, &Value::Int(1)); }
let mut isPortfolioMargin: Value = Value::Null;
{ let __destr_tmp = self.handle_option_and_params2(params.clone(), Value::Str("fetchPositionsRisk".to_string()), Value::Str("papi".to_string()), Value::Str("portfolioMargin".to_string()), &[Value::Bool(false)]); isPortfolioMargin = get_value(&__destr_tmp, &Value::Int(0)); params = get_value(&__destr_tmp, &Value::Int(1)); }
params = self.omit(params.clone(), Value::Str("type".to_string()), &[]);
let mut response: Value = Value::Null;
if is_true(&self.is_linear(type_var.clone(), &[subType.clone()])) {
if is_true(&isPortfolioMargin) {
let __ws_arg_158 = self.extend(request.clone(), &[params.clone()]);
response = self.papi_get_um_position_risk(&[__ws_arg_158]).await;
} else {
let mut useV2: Value = Value::Null;
{ let __destr_tmp = self.handle_option_and_params(params.clone(), Value::Str("fetchPositionsRisk".to_string()), Value::Str("useV2".to_string()), &[Value::Bool(false)]); useV2 = get_value(&__destr_tmp, &Value::Int(0)); params = get_value(&__destr_tmp, &Value::Int(1)); }
params = self.extend(request.clone(), &[params.clone()]);
if !is_true(&useV2) {
response = self.fapi_private_v3_get_position_risk(&[params.clone()]).await;
} else {
response = self.fapi_private_v2_get_position_risk(&[params.clone()]).await;
}
}
} else if is_true(&self.is_inverse(type_var.clone(), &[subType.clone()])) {
if is_true(&isPortfolioMargin) {
let __ws_arg_159 = self.extend(request.clone(), &[params.clone()]);
response = self.papi_get_cm_position_risk(&[__ws_arg_159]).await;
} else {
let __ws_arg_160 = self.extend(request.clone(), &[params.clone()]);
response = self.dapi_private_get_position_risk(&[__ws_arg_160]).await;
}
} else {
panic!("{}", crate::exchange_errors::not_supported(add(&self.id, &Value::Str(" fetchPositionsRisk() supports linear and inverse contracts only".to_string()))));
}
// ### Response examples ###
//
// For One-way position mode:
//
// [
// {
// "symbol": "BTCUSDT",
// "positionSide": "BOTH",
// "positionAmt": "0.000",
// "entryPrice": "0.00000",
// "markPrice": "6679.50671178",
// "unRealizedProfit": "0.00000000",
// "liquidationPrice": "0",
// "isolatedMargin": "0.00000000",
// "marginType": "isolated",
// "isAutoAddMargin": "false",
// "leverage": "10",
// "maxNotionalValue": "20000000",
// "updateTime": 0
// }
// ]
//
// For Hedge position mode:
//
// [
// {
// "entryPrice": "6563.66500",
// "marginType": "isolated",
// "isAutoAddMargin": "false",
// "isolatedMargin": "15517.54150468",
// "leverage": "10",
// "liquidationPrice": "5930.78",
// "markPrice": "6679.50671178",
// "maxNotionalValue": "20000000",
// "positionSide": "LONG",
// "positionAmt": "20.000", // negative value for 'SHORT'
// "symbol": "BTCUSDT",
// "unRealizedProfit": "2316.83423560"
// "updateTime": 1625474304765
// },
// .. second dict is similar, but with `positionSide: SHORT`
// ]
//
// inverse portfolio margin:
//
// [
// {
// "symbol": "ETHUSD_PERP",
// "positionAmt": "1",
// "entryPrice": "2422.400000007",
// "markPrice": "2424.51267823",
// "unRealizedProfit": "0.0000036",
// "liquidationPrice": "293.57678898",
// "leverage": "100",
// "positionSide": "LONG",
// "updateTime": 1707371941861,
// "maxQty": "15",
// "notionalValue": "0.00412454",
// "breakEvenPrice": "2423.368960034"
// }
// ]
//
// linear portfolio margin:
//
// [
// {
// "symbol": "BTCUSDT",
// "positionAmt": "0.01",
// "entryPrice": "44525.0",
// "markPrice": "45464.1735922",
// "unRealizedProfit": "9.39173592",
// "liquidationPrice": "38007.16308568",
// "leverage": "100",
// "positionSide": "LONG",
// "updateTime": 1707371879042,
// "maxNotionalValue": "500000.0",
// "notional": "454.64173592",
// "breakEvenPrice": "44542.81"
// }
// ]
//
let mut result: Value = Value::List(vec![]);
if is_equal(&response, &Value::Null) {
panic!("{}", crate::exchange_errors::null_response(add(&self.id, &Value::Str(" method() returned empty response".to_string()))));
}
let mut positions: Value = self.to_array(response.clone());
{
let mut i: Value = Value::Int(0);
let mut __for_first_282: bool = true;
while { if !__for_first_282 { i = add(&i, &Value::Int(1)); } __for_first_282 = false; is_less_than(&i, &get_array_length(&positions)) } {
let mut rawPosition: Value = get_value(&positions, &i);
let mut rawPosition: Value = get_value(&positions, &i);
let mut entryPriceString: Value = self.safe_string_k(rawPosition.clone(), "entryPrice", &[]);
if is_true(&crate::precise::Precise::stringGt(&entryPriceString, &Value::Str("0".to_string()))) {
append_to_array(&mut result, self.parse_position_risk(rawPosition.clone(), &[]));
}
}
}
symbols = self.market_symbols(&[symbols.clone()]);
return self.filter_by_array_positions(result.clone(), Value::Str("symbol".to_string()), &[symbols.clone(), Value::Bool(false)]);
Value::Null
}
/*
* @method
* @name binance#fetchFundingHistory
* @description fetch the history of funding payments paid and received on this account
* @see https://developers.binance.com/docs/derivatives/usds-margined-futures/account/rest-api/Get-Income-History
* @see https://developers.binance.com/docs/derivatives/coin-margined-futures/account/rest-api/Get-Income-History
* @see https://developers.binance.com/docs/derivatives/portfolio-margin/account/Get-UM-Income-History
* @see https://developers.binance.com/docs/derivatives/portfolio-margin/account/Get-CM-Income-History
* @param {string} symbol unified market symbol
* @param {int} [since] the earliest time in ms to fetch funding history for
* @param {int} [limit] the maximum number of funding history structures to retrieve
* @param {object} [params] extra parameters specific to the exchange API endpoint
* @param {int} [params.until] timestamp in ms of the latest funding history entry
* @param {boolean} [params.portfolioMargin] set to true if you would like to fetch the funding history for a portfolio margin account
* @param {string} [params.subType] "linear" or "inverse"
* @returns {object} a [funding history structure]{@link https://docs.ccxt.com/?id=funding-history-structure}
*/
pub async fn fetch_funding_history(&mut self, optional_args: &[Value]) -> Value {
let mut symbol = get_arg(optional_args, 0, Value::Null);
let mut since = get_arg(optional_args, 1, Value::Null);
let mut limit = get_arg(optional_args, 2, Value::Null);
let mut params = get_arg(optional_args, 3, Value::Map({
let mut m = indexmap::IndexMap::new();
m
}));
if is_equal(&self.markets, &Value::Null) {
self.load_markets(&[]).await;
}
let mut market: Value = Value::Null;
let mut request: Value = Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("incomeType".to_string(), Value::Str("FUNDING_FEE".to_string()));
m
});
if !is_equal(&symbol, &Value::Null) {
market = self.market(symbol.clone());
add_element_to_object(&mut request, &Value::Str("symbol".to_string()), get_value(&market, &Value::Str("id".to_string())));
if !is_equal(&get_value(&market, &Value::Str("swap".to_string())), &Value::Bool(true)) {
panic!("{}", crate::exchange_errors::not_supported(add(&self.id, &Value::Str(" fetchFundingHistory() supports swap contracts only".to_string()))));
}
}
let mut subType: Value = Value::Null;
{ let __destr_tmp = self.handle_sub_type_and_params(Value::Str("fetchFundingHistory".to_string()), &[market.clone(), params.clone(), Value::Str("linear".to_string())]); subType = get_value(&__destr_tmp, &Value::Int(0)); params = get_value(&__destr_tmp, &Value::Int(1)); }
let mut isPortfolioMargin: Value = Value::Null;
{ let __destr_tmp = self.handle_option_and_params2(params.clone(), Value::Str("fetchFundingHistory".to_string()), Value::Str("papi".to_string()), Value::Str("portfolioMargin".to_string()), &[Value::Bool(false)]); isPortfolioMargin = get_value(&__destr_tmp, &Value::Int(0)); params = get_value(&__destr_tmp, &Value::Int(1)); }
{ let __destr_tmp = self.handle_until_option(Value::Str("endTime".to_string()), request.clone(), params.clone(), &[]); request = get_value(&__destr_tmp, &Value::Int(0)); params = get_value(&__destr_tmp, &Value::Int(1)); }
if !is_equal(&since, &Value::Null) {
add_element_to_object(&mut request, &Value::Str("startTime".to_string()), since.clone());
}
if !is_equal(&limit, &Value::Null) {
add_element_to_object(&mut request, &Value::Str("limit".to_string()), limit.clone());
}
let mut defaultType: Value = self.safe_string2(self.options.clone(), Value::Str("fetchFundingHistory".to_string()), Value::Str("defaultType".to_string()), &[Value::Str("future".to_string())]);
let mut type_var: Value = self.safe_string_k(params.clone(), "type", &[defaultType.clone()]);
params = self.omit(params.clone(), Value::Str("type".to_string()), &[]);
let mut response: Value = Value::Null;
if is_true(&self.is_linear(type_var.clone(), &[subType.clone()])) {
if is_true(&isPortfolioMargin) {
let __ws_arg_161 = self.extend(request.clone(), &[params.clone()]);
response = self.papi_get_um_income(&[__ws_arg_161]).await;
} else {
let __ws_arg_162 = self.extend(request.clone(), &[params.clone()]);
response = self.fapi_private_get_income(&[__ws_arg_162]).await;
}
} else if is_true(&self.is_inverse(type_var.clone(), &[subType.clone()])) {
if is_true(&isPortfolioMargin) {
let __ws_arg_163 = self.extend(request.clone(), &[params.clone()]);
response = self.papi_get_cm_income(&[__ws_arg_163]).await;
} else {
let __ws_arg_164 = self.extend(request.clone(), &[params.clone()]);
response = self.dapi_private_get_income(&[__ws_arg_164]).await;
}
} else {
panic!("{}", crate::exchange_errors::not_supported(add(&self.id, &Value::Str(" fetchFundingHistory() supports linear and inverse contracts only".to_string()))));
}
return self.parse_incomes(response.clone(), &[market.clone(), since.clone(), limit.clone()]);
Value::Null
}
/*
* @method
* @name binance#setLeverage
* @description set the level of leverage for a market
* @see https://developers.binance.com/docs/derivatives/usds-margined-futures/trade/rest-api/Change-Initial-Leverage
* @see https://developers.binance.com/docs/derivatives/coin-margined-futures/trade/rest-api/Change-Initial-Leverage
* @see https://developers.binance.com/docs/derivatives/portfolio-margin/account/Change-UM-Initial-Leverage
* @see https://developers.binance.com/docs/derivatives/portfolio-margin/account/Change-CM-Initial-Leverage
* @param {float} leverage the rate of leverage
* @param {string} symbol unified market symbol
* @param {object} [params] extra parameters specific to the exchange API endpoint
* @param {boolean} [params.portfolioMargin] set to true if you would like to set the leverage for a trading pair in a portfolio margin account
* @returns {object} response from the exchange
*/
pub async fn set_leverage(&mut self, mut leverage: Value, optional_args: &[Value]) -> Value {
let mut symbol = get_arg(optional_args, 0, Value::Null);
let mut params = get_arg(optional_args, 1, Value::Map({
let mut m = indexmap::IndexMap::new();
m
}));
if is_equal(&symbol, &Value::Null) {
panic!("{}", crate::exchange_errors::arguments_required(add(&self.id, &Value::Str(" setLeverage() requires a symbol argument".to_string()))));
}
// WARNING: THIS WILL INCREASE LIQUIDATION PRICE FOR OPEN ISOLATED LONG POSITIONS
// AND DECREASE LIQUIDATION PRICE FOR OPEN ISOLATED SHORT POSITIONS
if is_true(&(is_less_than(&leverage, &Value::Int(1)))) || is_true(&(is_greater_than(&leverage, &Value::Int(125)))) {
panic!("{}", crate::exchange_errors::bad_request(add(&self.id, &Value::Str(" leverage should be between 1 and 125".to_string()))));
}
if is_equal(&self.markets, &Value::Null) {
self.load_markets(&[]).await;
}
let mut market: Value = self.market(symbol.clone());
let mut request: Value = Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("symbol".to_string(), get_value(&market, &Value::Str("id".to_string())));
m.insert("leverage".to_string(), leverage.clone());
m
});
let mut isPortfolioMargin: Value = Value::Null;
{ let __destr_tmp = self.handle_option_and_params2(params.clone(), Value::Str("setLeverage".to_string()), Value::Str("papi".to_string()), Value::Str("portfolioMargin".to_string()), &[Value::Bool(false)]); isPortfolioMargin = get_value(&__destr_tmp, &Value::Int(0)); params = get_value(&__destr_tmp, &Value::Int(1)); }
let mut response: Value = Value::Null;
if is_equal(&get_value(&market, &Value::Str("linear".to_string())), &Value::Bool(true)) {
if is_true(&isPortfolioMargin) {
let __ws_arg_165 = self.extend(request.clone(), &[params.clone()]);
response = self.papi_post_um_leverage(&[__ws_arg_165]).await;
} else {
let __ws_arg_166 = self.extend(request.clone(), &[params.clone()]);
response = self.fapi_private_post_leverage(&[__ws_arg_166]).await;
}
} else if is_equal(&get_value(&market, &Value::Str("inverse".to_string())), &Value::Bool(true)) {
if is_true(&isPortfolioMargin) {
let __ws_arg_167 = self.extend(request.clone(), &[params.clone()]);
response = self.papi_post_cm_leverage(&[__ws_arg_167]).await;
} else {
let __ws_arg_168 = self.extend(request.clone(), &[params.clone()]);
response = self.dapi_private_post_leverage(&[__ws_arg_168]).await;
}
} else {
panic!("{}", crate::exchange_errors::not_supported(add(&self.id, &Value::Str(" setLeverage() supports linear and inverse contracts only".to_string()))));
}
if is_equal(&response, &Value::Null) {
panic!("{}", crate::exchange_errors::null_response(add(&self.id, &Value::Str(" setLeverage() returned empty response".to_string()))));
}
return response;
Value::Null
}
/*
* @method
* @name binance#setMarginMode
* @description set margin mode to 'cross' or 'isolated'
* @see https://developers.binance.com/docs/derivatives/usds-margined-futures/trade/rest-api/Change-Margin-Type
* @see https://developers.binance.com/docs/derivatives/coin-margined-futures/trade/rest-api/Change-Margin-Type
* @param {string} marginMode 'cross' or 'isolated'
* @param {string} symbol unified market symbol
* @param {object} [params] extra parameters specific to the exchange API endpoint
* @returns {object} response from the exchange
*/
pub async fn set_margin_mode(&mut self, mut marginMode: Value, optional_args: &[Value]) -> Value {
let mut symbol = get_arg(optional_args, 0, Value::Null);
let mut params = get_arg(optional_args, 1, Value::Map({
let mut m = indexmap::IndexMap::new();
m
}));
if is_equal(&symbol, &Value::Null) {
panic!("{}", crate::exchange_errors::arguments_required(add(&self.id, &Value::Str(" setMarginMode() requires a symbol argument".to_string()))));
}
//
// { "code": -4048 , "msg": "Margin type cannot be changed if there exists position." }
//
// or
//
// { "code": 200, "msg": "success" }
//
marginMode = to_upper(&marginMode);
if is_equal(&marginMode, &Value::Str("CROSS".to_string())) {
marginMode = Value::Str("CROSSED".to_string());
}
if is_true(&(!is_equal(&marginMode, &Value::Str("ISOLATED".to_string())))) && is_true(&(!is_equal(&marginMode, &Value::Str("CROSSED".to_string())))) {
panic!("{}", crate::exchange_errors::bad_request(add(&self.id, &Value::Str(" marginMode must be either isolated or cross".to_string()))));
}
if is_equal(&self.markets, &Value::Null) {
self.load_markets(&[]).await;
}
let mut market: Value = self.market(symbol.clone());
let mut request: Value = Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("symbol".to_string(), get_value(&market, &Value::Str("id".to_string())));
m.insert("marginType".to_string(), marginMode.clone());
m
});
let mut response: Value = Value::Null;
let _try_result = futures::FutureExt::catch_unwind(std::panic::AssertUnwindSafe(async {
if is_equal(&get_value(&market, &Value::Str("linear".to_string())), &Value::Bool(true)) {
let __ws_arg_169 = self.extend(request.clone(), &[params.clone()]);
response = self.fapi_private_post_margin_type(&[__ws_arg_169]).await;
} else if is_equal(&get_value(&market, &Value::Str("inverse".to_string())), &Value::Bool(true)) {
let __ws_arg_170 = self.extend(request.clone(), &[params.clone()]);
response = self.dapi_private_post_margin_type(&[__ws_arg_170]).await;
} else {
panic!("{}", crate::exchange_errors::not_supported(add(&self.id, &Value::Str(" setMarginMode() supports linear and inverse contracts only".to_string()))));
}
#[allow(unreachable_code)] { Value::Null }})).await;
if let Err(_try_err) = _try_result { let e: Value = panic_to_value(_try_err);
// not an error
// https://github.com/ccxt/ccxt/issues/11268
// https://github.com/ccxt/ccxt/pull/11624
// POST https://fapi.binance.com/fapi/v1/marginType 400 Bad Request
// binanceusdm
if is_true(&is_instance(&e, &Value::Str("MarginModeAlreadySet".to_string()))) {
let mut throwMarginModeAlreadySet: Value = self.handle_option(Value::Str("setMarginMode".to_string()), Value::Str("throwMarginModeAlreadySet".to_string()), &[Value::Bool(false)]);
if is_equal(&throwMarginModeAlreadySet, &Value::Bool(true)) {
panic!("{}", e);
} else {
response = Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("code".to_string(), negate(&Value::Int(4046)));
m.insert("msg".to_string(), Value::Str("No need to change margin type.".to_string()));
m
});
}
} else {
panic!("{}", e);
}
}
if is_equal(&response, &Value::Null) {
panic!("{}", crate::exchange_errors::null_response(add(&self.id, &Value::Str(" setMarginMode() returned empty response".to_string()))));
}
return response;
Value::Null
}
/*
* @method
* @name binance#setPositionMode
* @description set hedged to true or false for a market
* @see https://developers.binance.com/docs/derivatives/usds-margined-futures/trade/rest-api/Change-Position-Mode
* @see https://developers.binance.com/docs/derivatives/coin-margined-futures/trade/rest-api/Change-Position-Mode
* @see https://developers.binance.com/docs/derivatives/portfolio-margin/account/Get-UM-Current-Position-Mode
* @see https://developers.binance.com/docs/derivatives/portfolio-margin/account/Get-CM-Current-Position-Mode
* @param {bool} hedged set to true to use dualSidePosition
* @param {string} symbol not used by setPositionMode ()
* @param {object} [params] extra parameters specific to the exchange API endpoint
* @param {boolean} [params.portfolioMargin] set to true if you would like to set the position mode for a portfolio margin account
* @param {string} [params.subType] "linear" or "inverse"
* @returns {object} response from the exchange
*/
pub async fn set_position_mode(&mut self, mut hedged: Value, optional_args: &[Value]) -> Value {
let mut symbol = get_arg(optional_args, 0, Value::Null);
let mut params = get_arg(optional_args, 1, Value::Map({
let mut m = indexmap::IndexMap::new();
m
}));
let mut market: Value = Value::Null;
if !is_equal(&symbol, &Value::Null) {
market = self.market(symbol.clone());
}
let mut type_var: Value = Value::Null;
{ let __destr_tmp = self.handle_market_type_and_params(Value::Str("setPositionMode".to_string()), &[market.clone(), params.clone()]); type_var = get_value(&__destr_tmp, &Value::Int(0)); params = get_value(&__destr_tmp, &Value::Int(1)); }
let mut subType: Value = Value::Null;
{ let __destr_tmp = self.handle_sub_type_and_params(Value::Str("setPositionMode".to_string()), &[market.clone(), params.clone()]); subType = get_value(&__destr_tmp, &Value::Int(0)); params = get_value(&__destr_tmp, &Value::Int(1)); }
let mut isPortfolioMargin: Value = Value::Null;
{ let __destr_tmp = self.handle_option_and_params2(params.clone(), Value::Str("setPositionMode".to_string()), Value::Str("papi".to_string()), Value::Str("portfolioMargin".to_string()), &[Value::Bool(false)]); isPortfolioMargin = get_value(&__destr_tmp, &Value::Int(0)); params = get_value(&__destr_tmp, &Value::Int(1)); }
let mut dualSidePosition: Value = Value::Null;
if is_true(&hedged) {
dualSidePosition = Value::Str("true".to_string());
} else {
dualSidePosition = Value::Str("false".to_string());
}
let mut request: Value = Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("dualSidePosition".to_string(), dualSidePosition.clone());
m
});
let mut response: Value = Value::Null;
if is_true(&self.is_inverse(type_var.clone(), &[subType.clone()])) {
if is_true(&isPortfolioMargin) {
let __ws_arg_171 = self.extend(request.clone(), &[params.clone()]);
response = self.papi_post_cm_position_side_dual(&[__ws_arg_171]).await;
} else {
let __ws_arg_172 = self.extend(request.clone(), &[params.clone()]);
response = self.dapi_private_post_position_side_dual(&[__ws_arg_172]).await;
}
} else if is_true(&self.is_linear(type_var.clone(), &[subType.clone()])) {
if is_true(&isPortfolioMargin) {
let __ws_arg_173 = self.extend(request.clone(), &[params.clone()]);
response = self.papi_post_um_position_side_dual(&[__ws_arg_173]).await;
} else {
let __ws_arg_174 = self.extend(request.clone(), &[params.clone()]);
response = self.fapi_private_post_position_side_dual(&[__ws_arg_174]).await;
}
} else {
panic!("{}", crate::exchange_errors::bad_request(add(&self.id, &Value::Str(" setPositionMode() supports linear and inverse contracts only".to_string()))));
}
//
// {
// "code": 200,
// "msg": "success"
// }
//
if is_equal(&response, &Value::Null) {
panic!("{}", crate::exchange_errors::null_response(add(&self.id, &Value::Str(" setPositionMode() returned empty response".to_string()))));
}
return response;
Value::Null
}
/*
* @method
* @name binance#fetchLeverages
* @description fetch the set leverage for all markets
* @see https://developers.binance.com/docs/derivatives/usds-margined-futures/account/rest-api/Account-Information-V2
* @see https://developers.binance.com/docs/derivatives/coin-margined-futures/account/rest-api/Account-Information
* @see https://developers.binance.com/docs/derivatives/portfolio-margin/account/Get-UM-Account-Detail
* @see https://developers.binance.com/docs/derivatives/portfolio-margin/account/Get-CM-Account-Detail
* @see https://developers.binance.com/docs/derivatives/usds-margined-futures/account/rest-api/Symbol-Config
* @param {string[]} [symbols] a list of unified market symbols
* @param {object} [params] extra parameters specific to the exchange API endpoint
* @param {string} [params.subType] "linear" or "inverse"
* @returns {object} a list of [leverage structures]{@link https://docs.ccxt.com/?id=leverage-structure}
*/
pub async fn fetch_leverages(&mut self, optional_args: &[Value]) -> Value {
let mut symbols = get_arg(optional_args, 0, Value::Null);
let mut params = get_arg(optional_args, 1, Value::Map({
let mut m = indexmap::IndexMap::new();
m
}));
if is_equal(&self.markets, &Value::Null) {
self.load_markets(&[]).await;
}
self.load_leverage_brackets(&[Value::Bool(false), params.clone()]).await;
let mut type_var: Value = Value::Null;
{ let __destr_tmp = self.handle_market_type_and_params(Value::Str("fetchLeverages".to_string()), &[Value::Null, params.clone()]); type_var = get_value(&__destr_tmp, &Value::Int(0)); params = get_value(&__destr_tmp, &Value::Int(1)); }
let mut subType: Value = Value::Null;
{ let __destr_tmp = self.handle_sub_type_and_params(Value::Str("fetchLeverages".to_string()), &[Value::Null, params.clone(), Value::Str("linear".to_string())]); subType = get_value(&__destr_tmp, &Value::Int(0)); params = get_value(&__destr_tmp, &Value::Int(1)); }
let mut isPortfolioMargin: Value = Value::Null;
{ let __destr_tmp = self.handle_option_and_params2(params.clone(), Value::Str("fetchLeverages".to_string()), Value::Str("papi".to_string()), Value::Str("portfolioMargin".to_string()), &[Value::Bool(false)]); isPortfolioMargin = get_value(&__destr_tmp, &Value::Int(0)); params = get_value(&__destr_tmp, &Value::Int(1)); }
let mut response: Value = Value::Null;
if is_true(&self.is_linear(type_var.clone(), &[subType.clone()])) {
if is_true(&isPortfolioMargin) {
response = self.papi_get_um_account(&[params.clone()]).await;
} else {
response = self.fapi_private_get_symbol_config(&[params.clone()]).await;
}
} else if is_true(&self.is_inverse(type_var.clone(), &[subType.clone()])) {
if is_true(&isPortfolioMargin) {
response = self.papi_get_cm_account(&[params.clone()]).await;
} else {
response = self.dapi_private_get_account(&[params.clone()]).await;
}
} else {
panic!("{}", crate::exchange_errors::not_supported(add(&self.id, &Value::Str(" fetchLeverages() supports linear and inverse contracts only".to_string()))));
}
let mut leverages: Value = self.safe_list_k(response.clone(), "positions", &[Value::List(vec![])]);
if is_true(&Value::Bool(is_array(&response))) {
leverages = response.clone();
}
return self.parse_leverages(leverages.clone(), &[symbols.clone(), Value::Str("symbol".to_string())]);
Value::Null
}
pub fn parse_leverage(&self, mut leverage: Value, optional_args: &[Value]) -> Value {
let mut market = get_arg(optional_args, 0, Value::Null);
let mut marketId: Value = self.safe_string_k(leverage.clone(), "symbol", &[]);
let mut marginModeRaw: Value = self.safe_bool_k(leverage.clone(), "isolated", &[]);
let mut marginMode: Value = Value::Null;
if !is_equal(&marginModeRaw, &Value::Null) {
marginMode = ternary(is_true(&marginModeRaw), Value::Str("isolated".to_string()), Value::Str("cross".to_string()));
}
let mut marginTypeRaw: Value = self.safe_string_lower(leverage.clone(), Value::Str("marginType".to_string()), &[]);
if !is_equal(&marginTypeRaw, &Value::Null) {
marginMode = ternary(is_true(&(is_equal(&marginTypeRaw, &Value::Str("crossed".to_string())))), Value::Str("cross".to_string()), Value::Str("isolated".to_string()));
}
let mut side: Value = self.safe_string_lower(leverage.clone(), Value::Str("positionSide".to_string()), &[]);
let mut longLeverage: Value = Value::Null;
let mut shortLeverage: Value = Value::Null;
let mut leverageValue: Value = self.safe_integer_k(leverage.clone(), "leverage", &[]);
if is_true(&(is_equal(&side, &Value::Null))) || is_true(&(is_equal(&side, &Value::Str("both".to_string())))) {
longLeverage = leverageValue.clone();
shortLeverage = leverageValue.clone();
} else if is_equal(&side, &Value::Str("long".to_string())) {
longLeverage = leverageValue.clone();
} else if is_equal(&side, &Value::Str("short".to_string())) {
shortLeverage = leverageValue.clone();
}
return Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("info".to_string(), leverage.clone());
m.insert("symbol".to_string(), self.safe_symbol(marketId.clone(), &[market.clone()]));
m.insert("marginMode".to_string(), marginMode.clone());
m.insert("longLeverage".to_string(), longLeverage.clone());
m.insert("shortLeverage".to_string(), shortLeverage.clone());
m
});
Value::Null
}
/*
* @method
* @name binance#fetchSettlementHistory
* @description fetches historical settlement records
* @see https://developers.binance.com/docs/derivatives/option/market-data/Historical-Exercise-Records
* @param {string} symbol unified market symbol of the settlement history
* @param {int} [since] timestamp in ms
* @param {int} [limit] number of records, default 100, max 100
* @param {object} [params] exchange specific params
* @returns {object[]} a list of [settlement history objects]{@link https://docs.ccxt.com/?id=settlement-history-structure}
*/
pub async fn fetch_settlement_history(&mut self, optional_args: &[Value]) -> Value {
let mut symbol = get_arg(optional_args, 0, Value::Null);
let mut since = get_arg(optional_args, 1, Value::Null);
let mut limit = get_arg(optional_args, 2, Value::Null);
let mut params = get_arg(optional_args, 3, Value::Map({
let mut m = indexmap::IndexMap::new();
m
}));
if is_equal(&self.markets, &Value::Null) {
self.load_markets(&[]).await;
}
let mut market: Value = ternary(is_true(&(is_equal(&symbol, &Value::Null))), Value::Null, self.market(symbol.clone()));
let mut type_var: Value = Value::Null;
{ let __destr_tmp = self.handle_market_type_and_params(Value::Str("fetchSettlementHistory".to_string()), &[market.clone(), params.clone()]); type_var = get_value(&__destr_tmp, &Value::Int(0)); params = get_value(&__destr_tmp, &Value::Int(1)); }
if !is_equal(&type_var, &Value::Str("option".to_string())) {
panic!("{}", crate::exchange_errors::not_supported(add(&self.id, &Value::Str(" fetchSettlementHistory() supports option markets only".to_string()))));
}
let mut request: Value = Value::Map({
let mut m = indexmap::IndexMap::new();
m
});
if !is_equal(&symbol, &Value::Null) {
symbol = self.safe_string_k(market.clone(), "symbol", &[]);
add_element_to_object(&mut request, &Value::Str("underlying".to_string()), add(&self.safe_string_k(market.clone(), "baseId", &[Value::Str("".to_string())]), &self.safe_string_k(market.clone(), "quoteId", &[Value::Str("".to_string())])));
}
if !is_equal(&since, &Value::Null) {
add_element_to_object(&mut request, &Value::Str("startTime".to_string()), since.clone());
}
if !is_equal(&limit, &Value::Null) {
add_element_to_object(&mut request, &Value::Str("limit".to_string()), limit.clone());
}
let __ws_arg_175 = self.extend(request.clone(), &[params.clone()]);
let mut response: Value = self.eapi_public_get_exercise_history(&[__ws_arg_175]).await;
//
// [
// {
// "symbol": "ETH-230223-1900-P",
// "strikePrice": "1900",
// "realStrikePrice": "1665.5897334",
// "expiryDate": 1677139200000,
// "strikeResult": "REALISTIC_VALUE_STRICKEN"
// }
// ]
//
let mut settlements: Value = self.parse_settlements(response.clone(), market.clone());
let mut sorted: Value = self.sort_by(settlements.clone(), Value::Str("timestamp".to_string()), &[]);
return self.filter_by_symbol_since_limit(sorted.clone(), &[symbol.clone(), since.clone(), limit.clone()]);
Value::Null
}
/*
* @method
* @name binance#fetchMySettlementHistory
* @description fetches historical settlement records of the user
* @see https://developers.binance.com/docs/derivatives/option/trade/User-Exercise-Record
* @param {string} symbol unified market symbol of the settlement history
* @param {int} [since] timestamp in ms
* @param {int} [limit] number of records
* @param {object} [params] exchange specific params
* @returns {object[]} a list of [settlement history objects]
*/
pub async fn fetch_my_settlement_history(&mut self, optional_args: &[Value]) -> Value {
let mut symbol = get_arg(optional_args, 0, Value::Null);
let mut since = get_arg(optional_args, 1, Value::Null);
let mut limit = get_arg(optional_args, 2, Value::Null);
let mut params = get_arg(optional_args, 3, Value::Map({
let mut m = indexmap::IndexMap::new();
m
}));
if is_equal(&self.markets, &Value::Null) {
self.load_markets(&[]).await;
}
let mut market: Value = ternary(is_true(&(is_equal(&symbol, &Value::Null))), Value::Null, self.market(symbol.clone()));
let mut type_var: Value = Value::Null;
{ let __destr_tmp = self.handle_market_type_and_params(Value::Str("fetchMySettlementHistory".to_string()), &[market.clone(), params.clone()]); type_var = get_value(&__destr_tmp, &Value::Int(0)); params = get_value(&__destr_tmp, &Value::Int(1)); }
if !is_equal(&type_var, &Value::Str("option".to_string())) {
panic!("{}", crate::exchange_errors::not_supported(add(&self.id, &Value::Str(" fetchMySettlementHistory() supports option markets only".to_string()))));
}
let mut request: Value = Value::Map({
let mut m = indexmap::IndexMap::new();
m
});
if !is_equal(&symbol, &Value::Null) {
add_element_to_object(&mut request, &Value::Str("symbol".to_string()), self.safe_string_k(market.clone(), "id", &[]));
symbol = self.safe_string_k(market.clone(), "symbol", &[]);
}
if !is_equal(&since, &Value::Null) {
add_element_to_object(&mut request, &Value::Str("startTime".to_string()), since.clone());
}
if !is_equal(&limit, &Value::Null) {
add_element_to_object(&mut request, &Value::Str("limit".to_string()), limit.clone());
}
let __ws_arg_176 = self.extend(request.clone(), &[params.clone()]);
let mut response: Value = self.eapi_private_get_exercise_record(&[__ws_arg_176]).await;
//
// [
// {
// "id": "1125899906842897036",
// "currency": "USDT",
// "symbol": "BTC-230728-30000-C",
// "exercisePrice": "30000.00000000",
// "markPrice": "29160.71284993",
// "quantity": "1.00000000",
// "amount": "0.00000000",
// "fee": "0.00000000",
// "createDate": 1690531200000,
// "priceScale": 0,
// "quantityScale": 2,
// "optionSide": "CALL",
// "positionSide": "LONG",
// "quoteAsset": "USDT"
// }
// ]
//
let mut settlements: Value = self.parse_settlements(response.clone(), market.clone());
let mut sorted: Value = self.sort_by(settlements.clone(), Value::Str("timestamp".to_string()), &[]);
return self.filter_by_symbol_since_limit(sorted.clone(), &[symbol.clone(), since.clone(), limit.clone()]);
Value::Null
}
pub fn parse_settlement(&self, mut settlement: Value, mut market: Value) -> Value {
//
// fetchSettlementHistory
//
// {
// "symbol": "ETH-230223-1900-P",
// "strikePrice": "1900",
// "realStrikePrice": "1665.5897334",
// "expiryDate": 1677139200000,
// "strikeResult": "REALISTIC_VALUE_STRICKEN"
// }
//
// fetchMySettlementHistory
//
// {
// "id": "1125899906842897036",
// "currency": "USDT",
// "symbol": "BTC-230728-30000-C",
// "exercisePrice": "30000.00000000",
// "markPrice": "29160.71284993",
// "quantity": "1.00000000",
// "amount": "0.00000000",
// "fee": "0.00000000",
// "createDate": 1690531200000,
// "priceScale": 0,
// "quantityScale": 2,
// "optionSide": "CALL",
// "positionSide": "LONG",
// "quoteAsset": "USDT"
// }
//
let mut timestamp: Value = self.safe_integer2(settlement.clone(), Value::Str("expiryDate".to_string()), Value::Str("createDate".to_string()), &[]);
let mut marketId: Value = self.safe_string_k(settlement.clone(), "symbol", &[]);
return Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("info".to_string(), settlement.clone());
m.insert("symbol".to_string(), self.safe_symbol(marketId.clone(), &[market.clone()]));
m.insert("price".to_string(), self.safe_number2(settlement.clone(), Value::Str("realStrikePrice".to_string()), Value::Str("exercisePrice".to_string()), &[]));
m.insert("timestamp".to_string(), timestamp.clone());
m.insert("datetime".to_string(), self.iso8601(timestamp.clone()));
m
});
Value::Null
}
pub fn parse_settlements(&self, mut settlements: Value, mut market: Value) -> Value {
//
// fetchSettlementHistory
//
// [
// {
// "symbol": "ETH-230223-1900-P",
// "strikePrice": "1900",
// "realStrikePrice": "1665.5897334",
// "expiryDate": 1677139200000,
// "strikeResult": "EXTRINSIC_VALUE_EXPIRED"
// }
// ]
//
// fetchMySettlementHistory
//
// [
// {
// "id": "1125899906842897036",
// "currency": "USDT",
// "symbol": "BTC-230728-30000-C",
// "exercisePrice": "30000.00000000",
// "markPrice": "29160.71284993",
// "quantity": "1.00000000",
// "amount": "0.00000000",
// "fee": "0.00000000",
// "createDate": 1690531200000,
// "priceScale": 0,
// "quantityScale": 2,
// "optionSide": "CALL",
// "positionSide": "LONG",
// "quoteAsset": "USDT"
// }
// ]
//
let mut result: Value = Value::List(vec![]);
{
let mut i: Value = Value::Int(0);
let mut __for_first_283: bool = true;
while { if !__for_first_283 { i = add(&i, &Value::Int(1)); } __for_first_283 = false; is_less_than(&i, &get_array_length(&settlements)) } {
append_to_array(&mut result, self.parse_settlement(get_value(&settlements, &i), market.clone()));
}
}
return result;
Value::Null
}
/*
* @method
* @name binance#fetchLedgerEntry
* @description fetch the history of changes, actions done by the user or operations that altered the balance of the user
* @see https://developers.binance.com/docs/derivatives/option/account/Account-Funding-Flow
* @param {string} id the identification number of the ledger entry
* @param {string} code unified currency code
* @param {object} [params] extra parameters specific to the exchange API endpoint
* @returns {object} a [ledger structure]{@link https://docs.ccxt.com/?id=ledger-entry-structure}
*/
pub async fn fetch_ledger_entry(&mut self, mut id: Value, optional_args: &[Value]) -> Value {
let mut code = get_arg(optional_args, 0, Value::Null);
let mut params = get_arg(optional_args, 1, Value::Map({
let mut m = indexmap::IndexMap::new();
m
}));
if is_equal(&self.markets, &Value::Null) {
self.load_markets(&[]).await;
}
let mut type_var: Value = Value::Null;
{ let __destr_tmp = self.handle_market_type_and_params(Value::Str("fetchLedgerEntry".to_string()), &[Value::Null, params.clone()]); type_var = get_value(&__destr_tmp, &Value::Int(0)); params = get_value(&__destr_tmp, &Value::Int(1)); }
if !is_equal(&type_var, &Value::Str("option".to_string())) {
panic!("{}", crate::exchange_errors::bad_request(add(&self.id, &Value::Str(" fetchLedgerEntry() can only be used for type option".to_string()))));
}
self.check_required_argument(Value::Str("fetchLedgerEntry".to_string()), code.clone(), Value::Str("code".to_string()), &[]);
let mut currency: Value = self.currency(code.clone());
let mut request: Value = Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("recordId".to_string(), id.clone());
m.insert("currency".to_string(), get_value(¤cy, &Value::Str("id".to_string())));
m
});
let __ws_arg_177 = self.extend(request.clone(), &[params.clone()]);
let mut response: Value = self.eapi_private_get_bill(&[__ws_arg_177]).await;
//
// [
// {
// "id": "1125899906845701870",
// "asset": "USDT",
// "amount": "-0.16518203",
// "type": "FEE",
// "createDate": 1676621042489
// }
// ]
//
let mut first: Value = self.safe_dict(response.clone(), Value::Int(0), &[response.clone()]);
return self.parse_ledger_entry(first.clone(), &[currency.clone()]);
Value::Null
}
/*
* @method
* @name binance#fetchLedger
* @description fetch the history of changes, actions done by the user or operations that altered the balance of the user
* @see https://developers.binance.com/docs/derivatives/option/account/Account-Funding-Flow
* @see https://developers.binance.com/docs/derivatives/usds-margined-futures/account/rest-api/Get-Income-History
* @see https://developers.binance.com/docs/derivatives/coin-margined-futures/account/rest-api/Get-Income-History
* @see https://developers.binance.com/docs/derivatives/portfolio-margin/account/Get-UM-Income-History
* @see https://developers.binance.com/docs/derivatives/portfolio-margin/account/Get-CM-Income-History
* @param {string} [code] unified currency code
* @param {int} [since] timestamp in ms of the earliest ledger entry
* @param {int} [limit] max number of ledger entries to return
* @param {object} [params] extra parameters specific to the exchange API endpoint
* @param {int} [params.until] timestamp in ms of the latest ledger entry
* @param {boolean} [params.paginate] default false, when true will automatically paginate by calling this endpoint multiple times. See in the docs all the [available parameters](https://github.com/ccxt/ccxt/wiki/Manual#pagination-params)
* @param {boolean} [params.portfolioMargin] set to true if you would like to fetch the ledger for a portfolio margin account
* @param {string} [params.subType] "linear" or "inverse"
* @returns {object} a [ledger structure]{@link https://docs.ccxt.com/?id=ledger-entry-structure}
*/
pub async fn fetch_ledger(&mut self, optional_args: &[Value]) -> Value {
let mut code = get_arg(optional_args, 0, Value::Null);
let mut since = get_arg(optional_args, 1, Value::Null);
let mut limit = get_arg(optional_args, 2, Value::Null);
let mut params = get_arg(optional_args, 3, Value::Map({
let mut m = indexmap::IndexMap::new();
m
}));
if is_equal(&self.markets, &Value::Null) {
self.load_markets(&[]).await;
}
let mut paginate: Value = Value::Bool(false);
{ let __destr_tmp = self.handle_option_and_params(params.clone(), Value::Str("fetchLedger".to_string()), Value::Str("paginate".to_string()), &[]); paginate = get_value(&__destr_tmp, &Value::Int(0)); params = get_value(&__destr_tmp, &Value::Int(1)); }
if is_true(&paginate) {
return self.fetch_paginated_call_dynamic(Value::Str("fetchLedger".to_string()), &[code.clone(), since.clone(), limit.clone(), params.clone(), Value::Null, Value::Bool(false)]).await;
}
let mut type_var: Value = Value::Null;
let mut subType: Value = Value::Null;
let mut currency: Value = Value::Null;
if !is_equal(&code, &Value::Null) {
currency = self.currency(code.clone());
}
let mut request: Value = Value::Map({
let mut m = indexmap::IndexMap::new();
m
});
{ let __destr_tmp = self.handle_market_type_and_params(Value::Str("fetchLedger".to_string()), &[Value::Null, params.clone()]); type_var = get_value(&__destr_tmp, &Value::Int(0)); params = get_value(&__destr_tmp, &Value::Int(1)); }
{ let __destr_tmp = self.handle_sub_type_and_params(Value::Str("fetchLedger".to_string()), &[Value::Null, params.clone()]); subType = get_value(&__destr_tmp, &Value::Int(0)); params = get_value(&__destr_tmp, &Value::Int(1)); }
if !is_equal(&since, &Value::Null) {
add_element_to_object(&mut request, &Value::Str("startTime".to_string()), since.clone());
}
if !is_equal(&limit, &Value::Null) {
add_element_to_object(&mut request, &Value::Str("limit".to_string()), limit.clone());
}
let mut until: Value = self.safe_integer_k(params.clone(), "until", &[]);
if !is_equal(&until, &Value::Null) {
params = self.omit(params.clone(), Value::Str("until".to_string()), &[]);
add_element_to_object(&mut request, &Value::Str("endTime".to_string()), until.clone());
}
let mut isPortfolioMargin: Value = Value::Null;
{ let __destr_tmp = self.handle_option_and_params2(params.clone(), Value::Str("fetchLedger".to_string()), Value::Str("papi".to_string()), Value::Str("portfolioMargin".to_string()), &[Value::Bool(false)]); isPortfolioMargin = get_value(&__destr_tmp, &Value::Int(0)); params = get_value(&__destr_tmp, &Value::Int(1)); }
let mut response: Value = Value::Null;
if is_equal(&type_var, &Value::Str("option".to_string())) {
self.check_required_argument(Value::Str("fetchLedger".to_string()), code.clone(), Value::Str("code".to_string()), &[]);
if is_equal(¤cy, &Value::Null) {
panic!("{}", crate::exchange_errors::exchange_error(add(&self.id, &Value::Str(" fetchLedger() could not resolve currency".to_string()))));
}
add_element_to_object(&mut request, &Value::Str("currency".to_string()), get_value(¤cy, &Value::Str("id".to_string())));
let __ws_arg_178 = self.extend(request.clone(), &[params.clone()]);
response = self.eapi_private_get_bill(&[__ws_arg_178]).await;
} else if is_true(&self.is_linear(type_var.clone(), &[subType.clone()])) {
if is_true(&isPortfolioMargin) {
let __ws_arg_179 = self.extend(request.clone(), &[params.clone()]);
response = self.papi_get_um_income(&[__ws_arg_179]).await;
} else {
let __ws_arg_180 = self.extend(request.clone(), &[params.clone()]);
response = self.fapi_private_get_income(&[__ws_arg_180]).await;
}
} else if is_true(&self.is_inverse(type_var.clone(), &[subType.clone()])) {
if is_true(&isPortfolioMargin) {
let __ws_arg_181 = self.extend(request.clone(), &[params.clone()]);
response = self.papi_get_cm_income(&[__ws_arg_181]).await;
} else {
let __ws_arg_182 = self.extend(request.clone(), &[params.clone()]);
response = self.dapi_private_get_income(&[__ws_arg_182]).await;
}
} else {
panic!("{}", crate::exchange_errors::not_supported(add(&self.id, &Value::Str(" fetchLedger() supports contract wallets only".to_string()))));
}
return self.parse_ledger(response.clone(), &[currency.clone(), since.clone(), limit.clone()]);
Value::Null
}
pub fn parse_ledger_entry(&self, mut item: Value, optional_args: &[Value]) -> Value {
let mut currency = get_arg(optional_args, 0, Value::Null);
//
// options (eapi)
//
// {
// "id": "1125899906845701870",
// "asset": "USDT",
// "amount": "-0.16518203",
// "type": "FEE",
// "createDate": 167662104241
// }
//
// futures (fapi, dapi, papi)
//
// {
// "symbol": "",
// "incomeType": "TRANSFER",
// "income": "10.00000000",
// "asset": "USDT",
// "time": 1677645250000,
// "info": "TRANSFER",
// "tranId": 131001573082,
// "tradeId": ""
// }
//
let mut amount: Value = self.safe_string2(item.clone(), Value::Str("amount".to_string()), Value::Str("income".to_string()), &[]);
let mut direction: Value = Value::Null;
if is_true(&crate::precise::Precise::stringLe(&amount, &Value::Str("0".to_string()))) {
direction = Value::Str("out".to_string());
amount = crate::precise::Precise::stringMul(&Value::Str("-1".to_string()), &amount);
} else {
direction = Value::Str("in".to_string());
}
let mut currencyId: Value = self.safe_string_k(item.clone(), "asset", &[]);
let mut code: Value = self.safe_currency_code(currencyId.clone(), &[currency.clone()]);
currency = self.safe_currency(currencyId.clone(), &[currency.clone()]);
let mut timestamp: Value = self.safe_integer2(item.clone(), Value::Str("createDate".to_string()), Value::Str("time".to_string()), &[]);
let mut type_var: Value = self.safe_string2(item.clone(), Value::Str("type".to_string()), Value::Str("incomeType".to_string()), &[]);
return self.safe_ledger_entry(Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("info".to_string(), item.clone());
m.insert("id".to_string(), self.safe_string2(item.clone(), Value::Str("id".to_string()), Value::Str("tranId".to_string()), &[]));
m.insert("direction".to_string(), direction.clone());
m.insert("account".to_string(), Value::Null);
m.insert("referenceAccount".to_string(), Value::Null);
m.insert("referenceId".to_string(), self.safe_string_k(item.clone(), "tradeId", &[]));
m.insert("type".to_string(), self.parse_ledger_entry_type(type_var.clone()));
m.insert("currency".to_string(), code.clone());
m.insert("amount".to_string(), self.parse_number(amount.clone(), &[]));
m.insert("timestamp".to_string(), timestamp.clone());
m.insert("datetime".to_string(), self.iso8601(timestamp.clone()));
m.insert("before".to_string(), Value::Null);
m.insert("after".to_string(), Value::Null);
m.insert("status".to_string(), Value::Null);
m.insert("fee".to_string(), Value::Null);
m
}), &[currency.clone()]);
Value::Null
}
pub fn parse_ledger_entry_type(&self, mut type_var: Value) -> Value {
let mut ledgerType: Value = Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("FEE".to_string(), Value::Str("fee".to_string()));
m.insert("FUNDING_FEE".to_string(), Value::Str("fee".to_string()));
m.insert("OPTIONS_PREMIUM_FEE".to_string(), Value::Str("fee".to_string()));
m.insert("POSITION_LIMIT_INCREASE_FEE".to_string(), Value::Str("fee".to_string()));
m.insert("CONTRACT".to_string(), Value::Str("trade".to_string()));
m.insert("REALIZED_PNL".to_string(), Value::Str("trade".to_string()));
m.insert("TRANSFER".to_string(), Value::Str("transfer".to_string()));
m.insert("CROSS_COLLATERAL_TRANSFER".to_string(), Value::Str("transfer".to_string()));
m.insert("INTERNAL_TRANSFER".to_string(), Value::Str("transfer".to_string()));
m.insert("COIN_SWAP_DEPOSIT".to_string(), Value::Str("deposit".to_string()));
m.insert("COIN_SWAP_WITHDRAW".to_string(), Value::Str("withdrawal".to_string()));
m.insert("OPTIONS_SETTLE_PROFIT".to_string(), Value::Str("settlement".to_string()));
m.insert("DELIVERED_SETTELMENT".to_string(), Value::Str("settlement".to_string()));
m.insert("WELCOME_BONUS".to_string(), Value::Str("cashback".to_string()));
m.insert("CONTEST_REWARD".to_string(), Value::Str("cashback".to_string()));
m.insert("COMMISSION_REBATE".to_string(), Value::Str("rebate".to_string()));
m.insert("API_REBATE".to_string(), Value::Str("rebate".to_string()));
m.insert("REFERRAL_KICKBACK".to_string(), Value::Str("referral".to_string()));
m.insert("COMMISSION".to_string(), Value::Str("commission".to_string()));
m
});
return self.safe_string(ledgerType.clone(), type_var.clone(), &[type_var.clone()]);
Value::Null
}
pub fn get_network_code_by_network_url(&self, mut currencyCode: Value, optional_args: &[Value]) -> Value {
let mut depositUrl = get_arg(optional_args, 0, Value::Null);
// depositUrl is like : https://bscscan.com/address/0xEF238AB229342849..
if is_equal(&depositUrl, &Value::Null) {
return Value::Null;
}
let mut networkCode: Value = Value::Null;
let mut currency: Value = self.currency(currencyCode.clone());
let mut networks: Value = self.safe_dict_k(currency.clone(), "networks", &[Value::Map({
let mut m = indexmap::IndexMap::new();
m
})]);
let mut networkCodes: Value = object_keys(&networks);
{
let mut i: Value = Value::Int(0);
let mut __for_first_284: bool = true;
while { if !__for_first_284 { i = add(&i, &Value::Int(1)); } __for_first_284 = false; is_less_than(&i, &get_array_length(&networkCodes)) } {
let mut currentNetworkCode: Value = get_value(&networkCodes, &i);
let mut currentNetworkCode: Value = get_value(&networkCodes, &i);
let mut info: Value = self.safe_dict_k(get_value(&networks, ¤tNetworkCode), "info", &[Value::Map({
let mut m = indexmap::IndexMap::new();
m
})]);
let mut siteUrl: Value = self.safe_string_k(info.clone(), "contractAddressUrl", &[]);
// check if url matches the field's value
let mut baseDomain: Value = self.get_base_domain_from_url(siteUrl.clone());
if !is_equal(&siteUrl, &Value::Null) && !is_equal(&baseDomain, &Value::Null) && is_true(&Value::Bool(starts_with(&depositUrl, &baseDomain))) {
networkCode = currentNetworkCode.clone();
}
}
}
return networkCode;
Value::Null
}
pub fn get_base_domain_from_url(&self, mut url: Value) -> Value {
if is_equal(&url, &Value::Null) {
return Value::Null;
}
let mut urlParts: Value = split(&url, &Value::Str("/".to_string()));
let mut scheme: Value = self.safe_string(urlParts.clone(), Value::Int(0), &[]);
if is_equal(&scheme, &Value::Null) {
return Value::Null;
}
let mut domain: Value = self.safe_string(urlParts.clone(), Value::Int(2), &[]);
if is_equal(&domain, &Value::Null) {
return Value::Null;
}
return add(&add(&add(&scheme, &Value::Str("//".to_string())), &domain), &Value::Str("/".to_string()));
Value::Null
}
pub fn sign(&self, mut path: Value, optional_args: &[Value]) -> Value {
let mut api = get_arg(optional_args, 0, Value::Str("public".to_string()));
let mut method = get_arg(optional_args, 1, Value::Str("GET".to_string()));
let mut params = get_arg(optional_args, 2, Value::Map({
let mut m = indexmap::IndexMap::new();
m
}));
let mut headers = get_arg(optional_args, 3, Value::Null);
let mut body = get_arg(optional_args, 4, Value::Null);
let mut urls: Value = self.urls.clone();
if !is_true(&(Value::Bool(in_op(&get_value(&urls, &Value::Str("api".to_string())), &api)))) {
panic!("{}", crate::exchange_errors::not_supported(add(&add(&add(&self.id, &Value::Str(" does not have a testnet/sandbox URL for ".to_string())), &api), &Value::Str(" endpoints".to_string()))));
}
let mut url: Value = get_value(&get_value(&self.urls, &Value::Str("api".to_string())), &api);
url = add(&url, &add(&Value::Str("/".to_string()), &path));
if is_equal(&path, &Value::Str("historicalTrades".to_string())) {
if is_true(&(!is_equal(&self.apiKey, &Value::Null))) && is_true(&(!is_equal(&self.apiKey, &Value::Str("".to_string())))) {
headers = Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("X-MBX-APIKEY".to_string(), self.apiKey.clone());
m
});
} else {
panic!("{}", crate::exchange_errors::authentication_error(add(&self.id, &Value::Str(" historicalTrades endpoint requires `apiKey` credential".to_string()))));
}
}
let mut userDataStream: bool = is_true(&(is_equal(&path, &Value::Str("userDataStream".to_string())))) || is_true(&(is_equal(&path, &Value::Str("listenKey".to_string())))) || is_true(&(is_equal(&path, &Value::Str("userListenToken".to_string()))));
if is_true(&userDataStream) {
if is_true(&(!is_equal(&self.apiKey, &Value::Null))) && is_true(&(!is_equal(&self.apiKey, &Value::Str("".to_string())))) {
// v1 special case for userDataStream
headers = Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("X-MBX-APIKEY".to_string(), self.apiKey.clone());
m.insert("Content-Type".to_string(), Value::Str("application/x-www-form-urlencoded".to_string()));
m
});
if !is_equal(&method, &Value::Str("GET".to_string())) {
body = self.urlencode(params.clone(), &[]);
}
} else {
panic!("{}", crate::exchange_errors::authentication_error(add(&self.id, &Value::Str(" userDataStream endpoint requires `apiKey` credential".to_string()))));
}
} else if is_true(&(is_equal(&api, &Value::Str("private".to_string())))) || is_true(&(is_equal(&api, &Value::Str("eapiPrivate".to_string())))) || is_true(&(is_equal(&api, &Value::Str("sapi".to_string())) && !is_equal(&path, &Value::Str("system/status".to_string())))) || is_true(&(is_equal(&api, &Value::Str("sapiV2".to_string())))) || is_true(&(is_equal(&api, &Value::Str("sapiV3".to_string())))) || is_true(&(is_equal(&api, &Value::Str("sapiV4".to_string())))) || is_true(&(is_equal(&api, &Value::Str("dapiPrivate".to_string())))) || is_true(&(is_equal(&api, &Value::Str("dapiPrivateV2".to_string())))) || is_true(&(is_equal(&api, &Value::Str("fapiPrivate".to_string())))) || is_true(&(is_equal(&api, &Value::Str("fapiPrivateV2".to_string())))) || is_true(&(is_equal(&api, &Value::Str("fapiPrivateV3".to_string())))) || is_true(&(is_equal(&api, &Value::Str("papiV2".to_string())) || is_equal(&api, &Value::Str("papi".to_string())) && !is_equal(&path, &Value::Str("ping".to_string())))) {
self.check_required_credentials(&[]);
if is_true(&(is_greater_than(&get_index_of(&url, &Value::Str("testnet.binancefuture.com".to_string())), &negate(&Value::Int(1))))) && is_true(&self.isSandboxModeEnabled) && is_true(&(!is_equal(&self.safe_bool_k(self.options.clone(), "disableFuturesSandboxWarning", &[]), &Value::Bool(true)))) {
panic!("{}", crate::exchange_errors::not_supported(add(&self.id, &Value::Str(" testnet/sandbox mode is not supported for futures anymore, please check the deprecation announcement https://t.me/ccxt_announcements/92 and consider using the demo trading instead.".to_string()))));
}
if is_equal(&method, &Value::Str("POST".to_string())) && is_true(&(is_true(&(is_equal(&path, &Value::Str("order".to_string())))) || is_true(&(is_equal(&path, &Value::Str("sor/order".to_string())))))) {
// inject in implicit API calls
let mut newClientOrderId: Value = self.safe_string_k(params.clone(), "newClientOrderId", &[]);
if is_equal(&newClientOrderId, &Value::Null) {
let mut isSpotOrMargin: bool = is_greater_than(&get_index_of(&api, &Value::Str("sapi".to_string())), &negate(&Value::Int(1))) || is_equal(&api, &Value::Str("private".to_string()));
let mut marketType: Value = ternary(is_true(&isSpotOrMargin), Value::Str("spot".to_string()), Value::Str("future".to_string()));
let mut defaultId: Value = ternary(is_true(&(!is_true(&isSpotOrMargin))), Value::Str("x-xcKtGhcu".to_string()), Value::Str("x-TKT5PX2F".to_string()));
let mut broker: Value = self.safe_dict_k(self.options.clone(), "broker", &[Value::Map({
let mut m = indexmap::IndexMap::new();
m
})]);
let mut brokerId: Value = self.safe_string(broker.clone(), marketType.clone(), &[defaultId.clone()]);
add_element_to_object(&mut params, &Value::Str("newClientOrderId".to_string()), add(&brokerId, &self.uuid22(&[])));
}
}
let mut query: Value = Value::Null;
// handle batchOrders
if is_true(&(is_equal(&path, &Value::Str("batchOrders".to_string())))) && is_true(&(is_true(&(is_equal(&method, &Value::Str("POST".to_string())))) || is_true(&(is_equal(&method, &Value::Str("PUT".to_string())))))) {
let mut batchOrders: Value = self.safe_list_k(params.clone(), "batchOrders", &[Value::List(vec![])]);
let mut checkedBatchOrders: Value = batchOrders.clone();
if is_equal(&method, &Value::Str("POST".to_string())) && is_equal(&api, &Value::Str("fapiPrivate".to_string())) {
// check broker id if batchOrders are called with fapiPrivatePostBatchOrders
checkedBatchOrders = Value::List(vec![]);
{
let mut i: Value = Value::Int(0);
let mut __for_first_285: bool = true;
while { if !__for_first_285 { i = add(&i, &Value::Int(1)); } __for_first_285 = false; is_less_than(&i, &get_array_length(&batchOrders)) } {
let mut batchOrder: Value = get_value(&batchOrders, &i);
let mut batchOrder: Value = get_value(&batchOrders, &i);
let mut newClientOrderId: Value = self.safe_string_k(batchOrder.clone(), "newClientOrderId", &[]);
if is_equal(&newClientOrderId, &Value::Null) {
let mut defaultId: Value = Value::Str("x-xcKtGhcu".to_string()); // batchOrders can not be spot or margin
let mut broker: Value = self.safe_dict_k(self.options.clone(), "broker", &[Value::Map({
let mut m = indexmap::IndexMap::new();
m
})]);
let mut brokerId: Value = self.safe_string_k(broker.clone(), "future", &[defaultId.clone()]);
newClientOrderId = add(&brokerId, &self.uuid22(&[]));
add_element_to_object(&mut batchOrder, &Value::Str("newClientOrderId".to_string()), newClientOrderId.clone());
}
append_to_array(&mut checkedBatchOrders, batchOrder.clone());
}
}
}
let mut queryBatch: Value = (self.json(checkedBatchOrders.clone()));
add_element_to_object(&mut params, &Value::Str("batchOrders".to_string()), queryBatch.clone());
}
let mut defaultRecvWindow: Value = self.safe_integer_k(self.options.clone(), "recvWindow", &[]);
let __ws_arg_183 = self.nonce();
let mut extendedParams: Value = self.extend(Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("timestamp".to_string(), __ws_arg_183);
m
}), &[params.clone()]);
if !is_equal(&defaultRecvWindow, &Value::Null) {
add_element_to_object(&mut extendedParams, &Value::Str("recvWindow".to_string()), defaultRecvWindow.clone());
}
let mut recvWindow: Value = self.safe_integer_k(params.clone(), "recvWindow", &[]);
if !is_equal(&recvWindow, &Value::Null) {
add_element_to_object(&mut extendedParams, &Value::Str("recvWindow".to_string()), recvWindow.clone());
}
if is_true(&(is_equal(&api, &Value::Str("sapi".to_string())))) && is_true(&(is_equal(&path, &Value::Str("asset/dust".to_string())))) {
query = self.urlencode_with_array_repeat(extendedParams.clone());
} else if is_true(&(is_equal(&path, &Value::Str("batchOrders".to_string())))) || is_true(&(is_greater_than_or_equal(&get_index_of(&path, &Value::Str("sub-account".to_string())), &Value::Int(0)))) || is_true(&(is_equal(&path, &Value::Str("capital/withdraw/apply".to_string())))) || is_true(&(is_greater_than_or_equal(&get_index_of(&path, &Value::Str("staking".to_string())), &Value::Int(0)))) || is_true(&(is_greater_than_or_equal(&get_index_of(&path, &Value::Str("simple-earn".to_string())), &Value::Int(0)))) {
if is_true(&(is_equal(&method, &Value::Str("DELETE".to_string())))) && is_true(&(is_equal(&path, &Value::Str("batchOrders".to_string())))) {
let mut orderidlist: Value = self.safe_list_k(extendedParams.clone(), "orderidlist", &[Value::List(vec![])]);
let mut origclientorderidlist: Value = self.safe_list2(extendedParams.clone(), Value::Str("origclientorderidlist".to_string()), Value::Str("origClientOrderIdList".to_string()), &[Value::List(vec![])]);
extendedParams = self.omit(extendedParams.clone(), Value::List(vec![Value::Str("orderidlist".to_string()), Value::Str("origclientorderidlist".to_string()), Value::Str("origClientOrderIdList".to_string())]), &[]);
if is_true(&Value::Bool(in_op(&extendedParams, &Value::Str("symbol".to_string())))) {
{ let __be_tmp = self.encode_uri_component(get_value(&extendedParams, &Value::Str("symbol".to_string()))); add_element_to_object(&mut extendedParams, &Value::Str("symbol".to_string()), __be_tmp); };
}
query = self.rawencode(extendedParams.clone(), &[]);
let mut orderidlistLength: Value = get_array_length(&orderidlist);
let mut origclientorderidlistLength: Value = get_array_length(&origclientorderidlist);
if is_greater_than(&orderidlistLength, &Value::Int(0)) {
query = add(&add(&add(&add(&query, &Value::Str("&".to_string())), &Value::Str("orderidlist=%5B".to_string())), &join(&orderidlist, &Value::Str("%2C".to_string()))), &Value::Str("%5D".to_string()));
}
if is_greater_than(&origclientorderidlistLength, &Value::Int(0)) {
// wrap clientOrderids around ""
let mut newClientOrderIds: Value = Value::List(vec![]);
{
let mut i: Value = Value::Int(0);
let mut __for_first_286: bool = true;
while { if !__for_first_286 { i = add(&i, &Value::Int(1)); } __for_first_286 = false; is_less_than(&i, &origclientorderidlistLength) } {
append_to_array(&mut newClientOrderIds, add(&add(&Value::Str("%22".to_string()), &get_value(&origclientorderidlist, &i)), &Value::Str("%22".to_string())));
}
}
query = add(&add(&add(&add(&query, &Value::Str("&".to_string())), &Value::Str("origclientorderidlist=%5B".to_string())), &join(&newClientOrderIds, &Value::Str("%2C".to_string()))), &Value::Str("%5D".to_string()));
}
} else {
query = self.rawencode(extendedParams.clone(), &[]);
}
} else {
query = self.urlencode(extendedParams.clone(), &[]);
}
let mut signature: Value = Value::Null;
if is_greater_than(&get_index_of(&self.secret, &Value::Str("PRIVATE KEY".to_string())), &negate(&Value::Int(1))) {
if is_greater_than(&get_array_length(&self.secret), &Value::Int(120)) {
signature = self.encode_uri_component(rsa(query.clone(), self.secret.clone(), Value::Str("sha256".to_string())));
} else {
signature = self.encode_uri_component(eddsa(self.encode(query.clone()), self.secret.clone(), Value::Str("ed25519".to_string())));
}
} else {
signature = self.hmac(self.encode(query.clone()), self.encode(self.secret.clone()), Value::Str("sha256".to_string()), &[]);
}
query = add(&query, &add(&add(&Value::Str("&".to_string()), &Value::Str("signature=".to_string())), &signature));
headers = Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("X-MBX-APIKEY".to_string(), self.apiKey.clone());
m
});
if is_true(&(is_equal(&method, &Value::Str("GET".to_string())))) || is_true(&(is_equal(&method, &Value::Str("DELETE".to_string())))) {
url = add(&url, &add(&Value::Str("?".to_string()), &query));
} else {
body = query.clone();
add_element_to_object(&mut headers, &Value::Str("Content-Type".to_string()), Value::Str("application/x-www-form-urlencoded".to_string()));
}
} else {
if is_greater_than(&get_array_length(&object_keys(¶ms)), &Value::Int(0)) {
url = add(&url, &add(&Value::Str("?".to_string()), &self.urlencode(params.clone(), &[])));
}
}
return Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("url".to_string(), url.clone());
m.insert("method".to_string(), method.clone());
m.insert("body".to_string(), body.clone());
m.insert("headers".to_string(), headers.clone());
m
});
Value::Null
}
pub fn get_exceptions_by_url(&self, mut url: Value, mut exactOrBroad: Value) -> Value {
if is_equal(&url, &Value::Null) {
return Value::Map({
let mut m = indexmap::IndexMap::new();
m
});
}
let mut marketType: Value = Value::Null;
let mut hostname: Value = ternary(is_true(&(!is_equal(&self.hostname, &Value::Null))), self.hostname.clone(), Value::Str("binance.com".to_string()));
if is_true(&Value::Bool(starts_with(&url, &add(&add(&Value::Str("https://api.".to_string()), &hostname), &Value::Str("/".to_string()))))) || is_true(&Value::Bool(starts_with(&url, &Value::Str("https://demo-api".to_string())))) || is_true(&Value::Bool(starts_with(&url, &Value::Str("https://testnet.binance.vision".to_string())))) {
marketType = Value::Str("spot".to_string());
} else if is_true(&Value::Bool(starts_with(&url, &add(&add(&Value::Str("https://dapi.".to_string()), &hostname), &Value::Str("/".to_string()))))) || is_true(&Value::Bool(starts_with(&url, &Value::Str("https://demo-dapi".to_string())))) || is_true(&Value::Bool(starts_with(&url, &Value::Str("https://testnet.binancefuture.com/dapi".to_string())))) {
marketType = Value::Str("inverse".to_string());
} else if is_true(&Value::Bool(starts_with(&url, &add(&add(&Value::Str("https://fapi.".to_string()), &hostname), &Value::Str("/".to_string()))))) || is_true(&Value::Bool(starts_with(&url, &Value::Str("https://demo-fapi".to_string())))) || is_true(&Value::Bool(starts_with(&url, &Value::Str("https://testnet.binancefuture.com/fapi".to_string())))) {
marketType = Value::Str("linear".to_string());
} else if is_true(&Value::Bool(starts_with(&url, &add(&add(&Value::Str("https://eapi.".to_string()), &hostname), &Value::Str("/".to_string()))))) {
marketType = Value::Str("option".to_string());
} else if is_true(&Value::Bool(starts_with(&url, &add(&add(&Value::Str("https://papi.".to_string()), &hostname), &Value::Str("/".to_string()))))) {
marketType = Value::Str("portfolioMargin".to_string());
}
if !is_equal(&marketType, &Value::Null) {
let mut exceptionsForMarketType: Value = self.safe_dict(self.exceptions.clone(), marketType.clone(), &[Value::Map({
let mut m = indexmap::IndexMap::new();
m
})]);
return self.safe_dict(exceptionsForMarketType.clone(), exactOrBroad.clone(), &[Value::Map({
let mut m = indexmap::IndexMap::new();
m
})]);
}
return Value::Map({
let mut m = indexmap::IndexMap::new();
m
});
Value::Null
}
pub fn handle_errors(&self, mut code: Value, mut reason: Value, mut url: Value, mut method: Value, mut headers: Value, mut body: Value, mut response: Value, mut requestHeaders: Value, mut requestBody: Value) -> Value {
if is_true(&(is_equal(&code, &Value::Int(418)))) || is_true(&(is_equal(&code, &Value::Int(429)))) {
panic!("{}", crate::exchange_errors::d_do_s_protection(add(&add(&add(&add(&add(&add(&self.id, &Value::Str(" ".to_string())), &to_string_val(&code)), &Value::Str(" ".to_string())), &reason), &Value::Str(" ".to_string())), &body)));
}
// error response in a form: { "code": -1013, "msg": "Invalid quantity." }
// following block contains legacy checks against message patterns in "msg" property
// will switch "code" checks eventually, when we know all of them
if is_true(&(is_greater_than_or_equal(&code, &Value::Int(400)))) && is_true(&(!is_equal(&body, &Value::Null))) {
if is_greater_than_or_equal(&get_index_of(&body, &Value::Str("Price * QTY is zero or less".to_string())), &Value::Int(0)) {
panic!("{}", crate::exchange_errors::invalid_order(add(&add(&self.id, &Value::Str(" order cost = amount * price is zero or less ".to_string())), &body)));
}
if is_greater_than_or_equal(&get_index_of(&body, &Value::Str("LOT_SIZE".to_string())), &Value::Int(0)) {
panic!("{}", crate::exchange_errors::invalid_order(add(&add(&self.id, &Value::Str(" order amount should be evenly divisible by lot size ".to_string())), &body)));
}
if is_greater_than_or_equal(&get_index_of(&body, &Value::Str("PRICE_FILTER".to_string())), &Value::Int(0)) {
panic!("{}", crate::exchange_errors::invalid_order(add(&add(&self.id, &Value::Str(" order price is invalid, i.e. exceeds allowed price precision, exceeds min price or max price limits or is invalid value in general, use this.priceToPrecision (symbol, amount) ".to_string())), &body)));
}
}
if is_equal(&response, &Value::Null) {
return Value::Null;
}
// response in format {'msg': 'The coin does not exist.', 'success': true/false}
let mut success: Value = self.safe_bool_k(response.clone(), "success", &[Value::Bool(true)]);
if !is_equal(&success, &Value::Bool(true)) {
let mut messageNew: Value = self.safe_string_k(response.clone(), "msg", &[]);
let mut parsedMessage: Value = Value::Null;
if !is_equal(&messageNew, &Value::Null) {
let _try_result = std::panic::catch_unwind(std::panic::AssertUnwindSafe(|| {
parsedMessage = json_parse(&messageNew);
#[allow(unreachable_code)] { Value::Null }}));
if let Err(_try_err) = _try_result { let e: Value = panic_to_value(_try_err);
// do nothing
parsedMessage = Value::Null;
}
if !is_equal(&parsedMessage, &Value::Null) {
response = parsedMessage.clone();
}
}
}
let mut message: Value = self.safe_string_k(response.clone(), "msg", &[]);
if !is_equal(&message, &Value::Null) {
self.throw_exactly_matched_exception(self.get_exceptions_by_url(url.clone(), Value::Str("exact".to_string())), message.clone(), add(&add(&self.id, &Value::Str(" ".to_string())), &message));
self.throw_exactly_matched_exception(get_value(&self.exceptions, &Value::Str("exact".to_string())), message.clone(), add(&add(&self.id, &Value::Str(" ".to_string())), &message));
self.throw_broadly_matched_exception(self.get_exceptions_by_url(url.clone(), Value::Str("broad".to_string())), message.clone(), add(&add(&self.id, &Value::Str(" ".to_string())), &message));
self.throw_broadly_matched_exception(get_value(&self.exceptions, &Value::Str("broad".to_string())), message.clone(), add(&add(&self.id, &Value::Str(" ".to_string())), &message));
}
// checks against error codes
let mut error: Value = self.safe_string_k(response.clone(), "code", &[]);
if !is_equal(&error, &Value::Null) {
// https://github.com/ccxt/ccxt/issues/6501
// https://github.com/ccxt/ccxt/issues/7742
if is_true(&(is_equal(&error, &Value::Str("200".to_string())))) || is_true(&crate::precise::Precise::stringEquals(&error, &Value::Str("0".to_string()))) {
return Value::Null;
}
// a workaround for {"code":-2015,"msg":"Invalid API-key, IP, or permissions for action."}
// despite that their message is very confusing, it is raised by Binance
// on a temporary ban, the API key is valid, but disabled for a while
if is_true(&(is_equal(&error, &Value::Str("-2015".to_string())))) && is_true(&(is_equal(&get_value(&self.options, &Value::Str("hasAlreadyAuthenticatedSuccessfully".to_string())), &Value::Bool(true)))) {
panic!("{}", crate::exchange_errors::d_do_s_protection(add(&add(&self.id, &Value::Str(" ".to_string())), &body)));
}
let mut feedback: Value = add(&add(&self.id, &Value::Str(" ".to_string())), &body);
if is_equal(&message, &Value::Str("No need to change margin type.".to_string())) {
panic!("{}", crate::exchange_errors::margin_mode_already_set(feedback));
}
self.throw_exactly_matched_exception(self.get_exceptions_by_url(url.clone(), Value::Str("exact".to_string())), error.clone(), feedback.clone());
self.throw_exactly_matched_exception(get_value(&self.exceptions, &Value::Str("exact".to_string())), error.clone(), feedback.clone());
panic!("{}", crate::exchange_errors::exchange_error(feedback));
}
if !is_equal(&success, &Value::Bool(true)) {
panic!("{}", crate::exchange_errors::exchange_error(add(&add(&self.id, &Value::Str(" ".to_string())), &body)));
}
if is_true(&Value::Bool(is_array(&response))) {
// cancelOrders returns an array like this: [{"code":-2011,"msg":"Unknown order sent."}]
let mut arrayLength: Value = get_array_length(&response);
if is_equal(&arrayLength, &Value::Int(1)) {
let mut element: Value = get_value(&response, &Value::Int(0));
let mut errorCode: Value = self.safe_string_k(element.clone(), "code", &[]);
if !is_equal(&errorCode, &Value::Null) {
self.throw_exactly_matched_exception(self.get_exceptions_by_url(url.clone(), Value::Str("exact".to_string())), errorCode.clone(), add(&add(&self.id, &Value::Str(" ".to_string())), &body));
self.throw_exactly_matched_exception(get_value(&self.exceptions, &Value::Str("exact".to_string())), errorCode.clone(), add(&add(&self.id, &Value::Str(" ".to_string())), &body));
}
}
}
return Value::Null;
Value::Null
}
pub fn calculate_rate_limiter_cost(&self, mut api: Value, mut method: Value, mut path: Value, mut params: Value, optional_args: &[Value]) -> Value {
let mut config = get_arg(optional_args, 0, Value::Map({
let mut m = indexmap::IndexMap::new();
m
}));
if is_true(&(Value::Bool(in_op(&config, &Value::Str("noCoin".to_string()))))) && !is_true(&(Value::Bool(in_op(¶ms, &Value::Str("coin".to_string()))))) {
return get_value(&config, &Value::Str("noCoin".to_string()));
} else if is_true(&(Value::Bool(in_op(&config, &Value::Str("noSymbol".to_string()))))) && !is_true(&(Value::Bool(in_op(¶ms, &Value::Str("symbol".to_string()))))) {
return get_value(&config, &Value::Str("noSymbol".to_string()));
} else if is_true(&(Value::Bool(in_op(&config, &Value::Str("noPoolId".to_string()))))) && !is_true(&(Value::Bool(in_op(¶ms, &Value::Str("poolId".to_string()))))) {
return get_value(&config, &Value::Str("noPoolId".to_string()));
} else if is_true(&(Value::Bool(in_op(&config, &Value::Str("byLimit".to_string()))))) && is_true(&(Value::Bool(in_op(¶ms, &Value::Str("limit".to_string()))))) {
let mut limit: Value = get_value(¶ms, &Value::Str("limit".to_string()));
// safeValue keeps runtime identical to the prior bare index (no empty-array default)
let mut byLimit: Value = self.safe_value_k(config.clone(), "byLimit", &[]);
{
let mut i: Value = Value::Int(0);
let mut __for_first_287: bool = true;
while { if !__for_first_287 { i = add(&i, &Value::Int(1)); } __for_first_287 = false; is_less_than(&i, &get_array_length(&byLimit)) } {
let mut entry: Value = get_value(&byLimit, &i);
let mut entry: Value = get_value(&byLimit, &i);
if is_less_than_or_equal(&limit, &get_value(&entry, &Value::Int(0))) {
return get_value(&entry, &Value::Int(1));
}
}
}
}
return self.safe_value_k(config.clone(), "cost", &[Value::Int(1)]);
Value::Null
}
pub async fn request(&mut self, mut path: Value, optional_args: &[Value]) -> Value {
let mut api = get_arg(optional_args, 0, Value::Str("public".to_string()));
let mut method = get_arg(optional_args, 1, Value::Str("GET".to_string()));
let mut params = get_arg(optional_args, 2, Value::Map({
let mut m = indexmap::IndexMap::new();
m
}));
let mut headers = get_arg(optional_args, 3, Value::Null);
let mut body = get_arg(optional_args, 4, Value::Null);
let mut config = get_arg(optional_args, 5, Value::Map({
let mut m = indexmap::IndexMap::new();
m
}));
let mut response: Value = self.fetch2(path.clone(), &[api.clone(), method.clone(), params.clone(), headers.clone(), body.clone(), config.clone()]).await;
// a workaround for {"code":-2015,"msg":"Invalid API-key, IP, or permissions for action."}
if is_equal(&api, &Value::Str("private".to_string())) {
add_element_to_object(&mut self.options, &Value::Str("hasAlreadyAuthenticatedSuccessfully".to_string()), Value::Bool(true));
}
return response;
Value::Null
}
pub async fn modify_margin_helper(&mut self, mut symbol: Value, mut amount: Value, mut addOrReduce: Value, optional_args: &[Value]) -> Value {
let mut params = get_arg(optional_args, 0, Value::Map({
let mut m = indexmap::IndexMap::new();
m
}));
// used to modify isolated positions
let mut defaultType: Value = self.safe_string_k(self.options.clone(), "defaultType", &[Value::Str("future".to_string())]);
if is_equal(&defaultType, &Value::Str("spot".to_string())) {
defaultType = Value::Str("future".to_string());
}
let mut type_var: Value = self.safe_string_k(params.clone(), "type", &[defaultType.clone()]);
if is_true(&(is_equal(&type_var, &Value::Str("margin".to_string())))) || is_true(&(is_equal(&type_var, &Value::Str("spot".to_string())))) {
panic!("{}", crate::exchange_errors::not_supported(add(&self.id, &Value::Str(" add / reduce margin only supported with type future or delivery".to_string()))));
}
if is_equal(&self.markets, &Value::Null) {
self.load_markets(&[]).await;
}
let mut market: Value = self.market(symbol.clone());
amount = self.amount_to_precision(symbol.clone(), amount.clone());
let mut request: Value = Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("type".to_string(), addOrReduce.clone());
m.insert("symbol".to_string(), get_value(&market, &Value::Str("id".to_string())));
m.insert("amount".to_string(), amount.clone());
m
});
let mut response: Value = Value::Null;
let mut code: Value = Value::Null;
if is_equal(&get_value(&market, &Value::Str("linear".to_string())), &Value::Bool(true)) {
code = get_value(&market, &Value::Str("quote".to_string()));
let __ws_arg_184 = self.extend(request.clone(), &[params.clone()]);
response = self.fapi_private_post_position_margin(&[__ws_arg_184]).await;
} else {
code = get_value(&market, &Value::Str("base".to_string()));
let __ws_arg_185 = self.extend(request.clone(), &[params.clone()]);
response = self.dapi_private_post_position_margin(&[__ws_arg_185]).await;
}
//
// {
// "code": 200,
// "msg": "Successfully modify position margin.",
// "amount": 0.001,
// "type": 1
// }
//
if is_equal(&response, &Value::Null) {
panic!("{}", crate::exchange_errors::null_response(add(&self.id, &Value::Str(" parseMarginModification() returned empty response".to_string()))));
}
let __ws_arg_186 = self.parse_margin_modification(response.clone(), &[market.clone()]);
return self.extend(__ws_arg_186, &[Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("code".to_string(), code.clone());
m
})]);
Value::Null
}
pub fn parse_margin_modification(&self, mut data: Value, optional_args: &[Value]) -> Value {
let mut market = get_arg(optional_args, 0, Value::Null);
//
// add/reduce margin
//
// {
// "code": 200,
// "msg": "Successfully modify position margin.",
// "amount": 0.001,
// "type": 1
// }
//
// fetchMarginAdjustmentHistory
//
// {
// symbol: "XRPUSDT",
// type: "1",
// deltaType: "TRADE",
// amount: "2.57148240",
// asset: "USDT",
// time: "1711046271555",
// positionSide: "BOTH",
// clientTranId: ""
// }
//
let mut rawType: Value = self.safe_integer_k(data.clone(), "type", &[]);
let mut errorCode: Value = self.safe_string_k(data.clone(), "code", &[]);
let mut marketId: Value = self.safe_string_k(data.clone(), "symbol", &[]);
let mut timestamp: Value = self.safe_integer_k(data.clone(), "time", &[]);
market = self.safe_market(&[marketId.clone(), market.clone(), Value::Null, Value::Str("swap".to_string())]);
let mut noErrorCode: bool = is_equal(&errorCode, &Value::Null);
let mut success: bool = is_equal(&errorCode, &Value::Str("200".to_string()));
return Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("info".to_string(), data.clone());
m.insert("symbol".to_string(), get_value(&market, &Value::Str("symbol".to_string())));
m.insert("type".to_string(), ternary(is_true(&(is_equal(&rawType, &Value::Int(1)))), Value::Str("add".to_string()), Value::Str("reduce".to_string())));
m.insert("marginMode".to_string(), Value::Str("isolated".to_string()));
m.insert("amount".to_string(), self.safe_number_k(data.clone(), "amount", &[]));
m.insert("code".to_string(), self.safe_string_k(data.clone(), "asset", &[]));
m.insert("total".to_string(), Value::Null);
m.insert("status".to_string(), ternary(is_true(&(is_true(&success) || is_true(&noErrorCode))), Value::Str("ok".to_string()), Value::Str("failed".to_string())));
m.insert("timestamp".to_string(), timestamp.clone());
m.insert("datetime".to_string(), self.iso8601(timestamp.clone()));
m
});
Value::Null
}
/*
* @method
* @name binance#reduceMargin
* @description remove margin from a position
* @see https://developers.binance.com/docs/derivatives/usds-margined-futures/trade/rest-api/Modify-Isolated-Position-Margin
* @see https://developers.binance.com/docs/derivatives/coin-margined-futures/trade/rest-api/Modify-Isolated-Position-Margin
* @param {string} symbol unified market symbol
* @param {float} amount the amount of margin to remove
* @param {object} [params] extra parameters specific to the exchange API endpoint
* @returns {object} a [margin structure]{@link https://docs.ccxt.com/?id=margin-structure}
*/
pub async fn reduce_margin(&mut self, mut symbol: Value, mut amount: Value, optional_args: &[Value]) -> Value {
let mut params = get_arg(optional_args, 0, Value::Map({
let mut m = indexmap::IndexMap::new();
m
}));
return self.modify_margin_helper(symbol.clone(), amount.clone(), Value::Int(2), &[params.clone()]).await;
Value::Null
}
/*
* @method
* @name binance#addMargin
* @description add margin
* @see https://developers.binance.com/docs/derivatives/usds-margined-futures/trade/rest-api/Modify-Isolated-Position-Margin
* @see https://developers.binance.com/docs/derivatives/coin-margined-futures/trade/rest-api/Modify-Isolated-Position-Margin
* @param {string} symbol unified market symbol
* @param {float} amount amount of margin to add
* @param {object} [params] extra parameters specific to the exchange API endpoint
* @returns {object} a [margin structure]{@link https://docs.ccxt.com/?id=margin-structure}
*/
pub async fn add_margin(&mut self, mut symbol: Value, mut amount: Value, optional_args: &[Value]) -> Value {
let mut params = get_arg(optional_args, 0, Value::Map({
let mut m = indexmap::IndexMap::new();
m
}));
return self.modify_margin_helper(symbol.clone(), amount.clone(), Value::Int(1), &[params.clone()]).await;
Value::Null
}
/*
* @method
* @name binance#fetchCrossBorrowRate
* @description fetch the rate of interest to borrow a currency for margin trading
* @see https://developers.binance.com/docs/margin_trading/borrow-and-repay/Query-Margin-Interest-Rate-History
* @param {string} code unified currency code
* @param {object} [params] extra parameters specific to the exchange API endpoint
* @returns {object} a [borrow rate structure]{@link https://docs.ccxt.com/?id=borrow-rate-structure}
*/
pub async fn fetch_cross_borrow_rate(&mut self, mut code: Value, optional_args: &[Value]) -> Value {
let mut params = get_arg(optional_args, 0, Value::Map({
let mut m = indexmap::IndexMap::new();
m
}));
if is_equal(&self.markets, &Value::Null) {
self.load_markets(&[]).await;
}
let mut currency: Value = self.currency(code.clone());
let mut request: Value = Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("asset".to_string(), get_value(¤cy, &Value::Str("id".to_string())));
m
});
let __ws_arg_187 = self.extend(request.clone(), &[params.clone()]);
let mut response: Value = self.sapi_get_margin_interest_rate_history(&[__ws_arg_187]).await;
//
// [
// {
// "asset": "USDT",
// "timestamp": 1638230400000,
// "dailyInterestRate": "0.0006",
// "vipLevel": 0
// },
// ]
//
let mut rate: Value = self.safe_dict(response.clone(), Value::Int(0), &[]);
return self.parse_borrow_rate(rate.clone(), &[]);
Value::Null
}
/*
* @method
* @name binance#fetchIsolatedBorrowRate
* @description fetch the rate of interest to borrow a currency for margin trading
* @see https://developers.binance.com/docs/margin_trading/account/Query-Isolated-Margin-Fee-Data
* @param {string} symbol unified market symbol
* @param {object} [params] extra parameters specific to the exchange API endpoint
*
* EXCHANGE SPECIFIC PARAMETERS
* @param {object} [params.vipLevel] user's current specific margin data will be returned if viplevel is omitted
* @returns {object} an [isolated borrow rate structure]{@link https://docs.ccxt.com/?id=isolated-borrow-rate-structure}
*/
pub async fn fetch_isolated_borrow_rate(&mut self, mut symbol: Value, optional_args: &[Value]) -> Value {
let mut params = get_arg(optional_args, 0, Value::Map({
let mut m = indexmap::IndexMap::new();
m
}));
let mut request: Value = Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("symbol".to_string(), symbol.clone());
m
});
let __ws_arg_188 = self.extend(request.clone(), &[params.clone()]);
let mut borrowRates: Value = self.fetch_isolated_borrow_rates(&[__ws_arg_188]).await;
return self.safe_dict(borrowRates.clone(), symbol.clone(), &[]);
Value::Null
}
/*
* @method
* @name binance#fetchIsolatedBorrowRates
* @description fetch the borrow interest rates of all currencies
* @see https://developers.binance.com/docs/margin_trading/account/Query-Isolated-Margin-Fee-Data
* @param {object} [params] extra parameters specific to the exchange API endpoint
* @param {object} [params.symbol] unified market symbol
*
* EXCHANGE SPECIFIC PARAMETERS
* @param {object} [params.vipLevel] user's current specific margin data will be returned if viplevel is omitted
* @returns {object} a [borrow rate structure]{@link https://docs.ccxt.com/?id=borrow-rate-structure}
*/
pub async fn fetch_isolated_borrow_rates(&mut self, optional_args: &[Value]) -> Value {
let mut params = get_arg(optional_args, 0, Value::Map({
let mut m = indexmap::IndexMap::new();
m
}));
if is_equal(&self.markets, &Value::Null) {
self.load_markets(&[]).await;
}
let mut request: Value = Value::Map({
let mut m = indexmap::IndexMap::new();
m
});
let mut symbol: Value = self.safe_string_k(params.clone(), "symbol", &[]);
params = self.omit(params.clone(), Value::Str("symbol".to_string()), &[]);
if !is_equal(&symbol, &Value::Null) {
let mut market: Value = self.market(symbol.clone());
add_element_to_object(&mut request, &Value::Str("symbol".to_string()), get_value(&market, &Value::Str("id".to_string())));
}
let __ws_arg_189 = self.extend(request.clone(), &[params.clone()]);
let mut response: Value = self.sapi_get_margin_isolated_margin_data(&[__ws_arg_189]).await;
return self.parse_isolated_borrow_rates(response.clone());
Value::Null
}
/*
* @method
* @name binance#fetchBorrowRateHistory
* @description retrieves a history of a currencies borrow interest rate at specific time slots
* @see https://developers.binance.com/docs/margin_trading/borrow-and-repay/Query-Margin-Interest-Rate-History
* @param {string} code unified currency code
* @param {int} [since] timestamp for the earliest borrow rate
* @param {int} [limit] the maximum number of [borrow rate structures]{@link https://docs.ccxt.com/?id=borrow-rate-structure} to retrieve
* @param {object} [params] extra parameters specific to the exchange API endpoint
* @returns {object[]} an array of [borrow rate structures]{@link https://docs.ccxt.com/?id=borrow-rate-structure}
*/
pub async fn fetch_borrow_rate_history(&mut self, mut code: Value, optional_args: &[Value]) -> Value {
let mut since = get_arg(optional_args, 0, Value::Null);
let mut limit = get_arg(optional_args, 1, Value::Null);
let mut params = get_arg(optional_args, 2, Value::Map({
let mut m = indexmap::IndexMap::new();
m
}));
if is_equal(&self.markets, &Value::Null) {
self.load_markets(&[]).await;
}
if is_equal(&limit, &Value::Null) {
limit = Value::Int(93);
} else if is_greater_than(&limit, &Value::Int(93)) {
panic!("{}", crate::exchange_errors::bad_request(add(&self.id, &Value::Str(" fetchBorrowRateHistory() limit parameter cannot exceed 92".to_string()))));
}
let mut currency: Value = self.currency(code.clone());
let mut request: Value = Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("asset".to_string(), get_value(¤cy, &Value::Str("id".to_string())));
m.insert("limit".to_string(), limit.clone());
m
});
if !is_equal(&since, &Value::Null) {
add_element_to_object(&mut request, &Value::Str("startTime".to_string()), since.clone());
let mut endTime: Value = subtract(&self.sum(&[since.clone(), multiply(&limit, &Value::Int(86400000))]), &Value::Int(1)); // required when startTime is further than 93 days in the past
let mut now: Value = self.milliseconds();
add_element_to_object(&mut request, &Value::Str("endTime".to_string()), crate::runtime::Math::min(&endTime, &now)); // cannot have an endTime later than current time
}
let __ws_arg_190 = self.extend(request.clone(), &[params.clone()]);
let mut response: Value = self.sapi_get_margin_interest_rate_history(&[__ws_arg_190]).await;
return self.parse_borrow_rate_history(response.clone(), code.clone(), since.clone(), limit.clone());
Value::Null
}
pub fn parse_borrow_rate(&self, mut info: Value, optional_args: &[Value]) -> Value {
let mut currency = get_arg(optional_args, 0, Value::Null);
//
// {
// "asset": "USDT",
// "timestamp": 1638230400000,
// "dailyInterestRate": "0.0006",
// "vipLevel": 0
// }
//
let mut timestamp: Value = self.safe_integer_k(info.clone(), "timestamp", &[]);
let mut currencyId: Value = self.safe_string_k(info.clone(), "asset", &[]);
return Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("currency".to_string(), self.safe_currency_code(currencyId.clone(), &[currency.clone()]));
m.insert("rate".to_string(), self.safe_number_k(info.clone(), "dailyInterestRate", &[]));
m.insert("period".to_string(), Value::Int(86400000));
m.insert("timestamp".to_string(), timestamp.clone());
m.insert("datetime".to_string(), self.iso8601(timestamp.clone()));
m.insert("info".to_string(), info.clone());
m
});
Value::Null
}
pub fn parse_isolated_borrow_rate(&self, mut info: Value, optional_args: &[Value]) -> Value {
let mut market = get_arg(optional_args, 0, Value::Null);
//
// {
// "vipLevel": 0,
// "symbol": "BTCUSDT",
// "leverage": "10",
// "data": [
// {
// "coin": "BTC",
// "dailyInterest": "0.00026125",
// "borrowLimit": "270"
// },
// {
// "coin": "USDT",
// "dailyInterest": "0.000475",
// "borrowLimit": "2100000"
// }
// ]
// }
//
let mut marketId: Value = self.safe_string_k(info.clone(), "symbol", &[]);
market = self.safe_market(&[marketId.clone(), market.clone(), Value::Null, Value::Str("spot".to_string())]);
let mut data: Value = self.safe_list_k(info.clone(), "data", &[]);
let mut baseInfo: Value = self.safe_dict(data.clone(), Value::Int(0), &[]);
let mut quoteInfo: Value = self.safe_dict(data.clone(), Value::Int(1), &[]);
return Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("info".to_string(), info.clone());
m.insert("symbol".to_string(), self.safe_string_k(market.clone(), "symbol", &[]));
m.insert("base".to_string(), self.safe_string_k(baseInfo.clone(), "coin", &[]));
m.insert("baseRate".to_string(), self.safe_number_k(baseInfo.clone(), "dailyInterest", &[]));
m.insert("quote".to_string(), self.safe_string_k(quoteInfo.clone(), "coin", &[]));
m.insert("quoteRate".to_string(), self.safe_number_k(quoteInfo.clone(), "dailyInterest", &[]));
m.insert("period".to_string(), Value::Int(86400000));
m.insert("timestamp".to_string(), Value::Null);
m.insert("datetime".to_string(), Value::Null);
m
});
Value::Null
}
/*
* @method
* @name binance#createGiftCode
* @description create gift code
* @see https://developers.binance.com/docs/gift_card/market-data/Create-a-single-token-gift-card
* @param {string} code gift code
* @param {float} amount amount of currency for the gift
* @param {object} [params] extra parameters specific to the exchange API endpoint
* @returns {object} The gift code id, code, currency and amount
*/
pub async fn create_gift_code(&mut self, mut code: Value, mut amount: Value, optional_args: &[Value]) -> Value {
let mut params = get_arg(optional_args, 0, Value::Map({
let mut m = indexmap::IndexMap::new();
m
}));
if is_equal(&self.markets, &Value::Null) {
self.load_markets(&[]).await;
}
let mut currency: Value = self.currency(code.clone());
// ensure you have enough token in your funding account before calling this code
let mut request: Value = Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("token".to_string(), get_value(¤cy, &Value::Str("id".to_string())));
m.insert("amount".to_string(), amount.clone());
m
});
let __ws_arg_191 = self.extend(request.clone(), &[params.clone()]);
let mut response: Value = self.sapi_post_giftcard_create_code(&[__ws_arg_191]).await;
//
// {
// "code": "000000",
// "message": "success",
// "data": { referenceNo: "0033002404219823", code: "AP6EXTLKNHM6CEX7" },
// "success": true
// }
//
let mut data: Value = self.safe_dict_k(response.clone(), "data", &[]);
let mut giftcardCode: Value = self.safe_string_k(data.clone(), "code", &[]);
let mut id: Value = self.safe_string_k(data.clone(), "referenceNo", &[]);
return Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("info".to_string(), response.clone());
m.insert("id".to_string(), id.clone());
m.insert("code".to_string(), giftcardCode.clone());
m.insert("currency".to_string(), code.clone());
m.insert("amount".to_string(), amount.clone());
m
});
Value::Null
}
/*
* @method
* @name binance#redeemGiftCode
* @description redeem gift code
* @see https://developers.binance.com/docs/gift_card/market-data/Redeem-a-Binance-Gift-Card
* @param {string} giftcardCode
* @param {object} [params] extra parameters specific to the exchange API endpoint
* @returns {object} response from the exchange
*/
pub async fn redeem_gift_code(&mut self, mut giftcardCode: Value, optional_args: &[Value]) -> Value {
let mut params = get_arg(optional_args, 0, Value::Map({
let mut m = indexmap::IndexMap::new();
m
}));
let mut request: Value = Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("code".to_string(), giftcardCode.clone());
m
});
let __ws_arg_192 = self.extend(request.clone(), &[params.clone()]);
let mut response: Value = self.sapi_post_giftcard_redeem_code(&[__ws_arg_192]).await;
return response;
Value::Null
}
/*
* @method
* @name binance#verifyGiftCode
* @description verify gift code
* @see https://developers.binance.com/docs/gift_card/market-data/Verify-Binance-Gift-Card-by-Gift-Card-Number
* @param {string} id reference number id
* @param {object} [params] extra parameters specific to the exchange API endpoint
* @returns {object} response from the exchange
*/
pub async fn verify_gift_code(&mut self, mut id: Value, optional_args: &[Value]) -> Value {
let mut params = get_arg(optional_args, 0, Value::Map({
let mut m = indexmap::IndexMap::new();
m
}));
let mut request: Value = Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("referenceNo".to_string(), id.clone());
m
});
let __ws_arg_193 = self.extend(request.clone(), &[params.clone()]);
let mut response: Value = self.sapi_get_giftcard_verify(&[__ws_arg_193]).await;
return response;
Value::Null
}
/*
* @method
* @name binance#fetchBorrowInterest
* @description fetch the interest owed by the user for borrowing currency for margin trading
* @see https://developers.binance.com/docs/margin_trading/borrow-and-repay/Get-Interest-History
* @see https://developers.binance.com/docs/derivatives/portfolio-margin/account/Get-Margin-BorrowLoan-Interest-History
* @param {string} [code] unified currency code
* @param {string} [symbol] unified market symbol when fetch interest in isolated markets
* @param {int} [since] the earliest time in ms to fetch borrrow interest for
* @param {int} [limit] the maximum number of structures to retrieve
* @param {object} [params] extra parameters specific to the exchange API endpoint
* @param {boolean} [params.portfolioMargin] set to true if you would like to fetch the borrow interest in a portfolio margin account
* @returns {object[]} a list of [borrow interest structures]{@link https://docs.ccxt.com/?id=borrow-interest-structure}
*/
pub async fn fetch_borrow_interest(&mut self, optional_args: &[Value]) -> Value {
let mut code = get_arg(optional_args, 0, Value::Null);
let mut symbol = get_arg(optional_args, 1, Value::Null);
let mut since = get_arg(optional_args, 2, Value::Null);
let mut limit = get_arg(optional_args, 3, Value::Null);
let mut params = get_arg(optional_args, 4, Value::Map({
let mut m = indexmap::IndexMap::new();
m
}));
if is_equal(&self.markets, &Value::Null) {
self.load_markets(&[]).await;
}
let mut isPortfolioMargin: Value = Value::Null;
{ let __destr_tmp = self.handle_option_and_params2(params.clone(), Value::Str("fetchBorrowInterest".to_string()), Value::Str("papi".to_string()), Value::Str("portfolioMargin".to_string()), &[Value::Bool(false)]); isPortfolioMargin = get_value(&__destr_tmp, &Value::Int(0)); params = get_value(&__destr_tmp, &Value::Int(1)); }
let mut request: Value = Value::Map({
let mut m = indexmap::IndexMap::new();
m
});
let mut market: Value = Value::Null;
if !is_equal(&code, &Value::Null) {
let mut currency: Value = self.currency(code.clone());
add_element_to_object(&mut request, &Value::Str("asset".to_string()), get_value(¤cy, &Value::Str("id".to_string())));
}
if !is_equal(&since, &Value::Null) {
add_element_to_object(&mut request, &Value::Str("startTime".to_string()), since.clone());
}
if !is_equal(&limit, &Value::Null) {
add_element_to_object(&mut request, &Value::Str("size".to_string()), limit.clone());
}
{ let __destr_tmp = self.handle_until_option(Value::Str("endTime".to_string()), request.clone(), params.clone(), &[]); request = get_value(&__destr_tmp, &Value::Int(0)); params = get_value(&__destr_tmp, &Value::Int(1)); }
let mut response: Value = Value::Null;
if is_true(&isPortfolioMargin) {
let __ws_arg_194 = self.extend(request.clone(), &[params.clone()]);
response = self.papi_get_margin_margin_interest_history(&[__ws_arg_194]).await;
} else {
if !is_equal(&symbol, &Value::Null) {
market = self.market(symbol.clone());
add_element_to_object(&mut request, &Value::Str("isolatedSymbol".to_string()), get_value(&market, &Value::Str("id".to_string())));
}
let __ws_arg_195 = self.extend(request.clone(), &[params.clone()]);
response = self.sapi_get_margin_interest_history(&[__ws_arg_195]).await;
}
//
// spot margin
//
// {
// "rows":[
// {
// "isolatedSymbol": "BNBUSDT", // isolated symbol, will not be returned for crossed margin
// "asset": "BNB",
// "interest": "0.02414667",
// "interestAccuredTime": 1566813600000,
// "interestRate": "0.01600000",
// "principal": "36.22000000",
// "type": "ON_BORROW"
// }
// ],
// "total": 1
// }
//
// spot margin portfolio margin
//
// {
// "total": 49,
// "rows": [
// {
// "txId": 1656187724899910076,
// "interestAccuredTime": 1707541200000,
// "asset": "USDT",
// "rawAsset": "USDT",
// "principal": "0.00011146",
// "interest": "0.00000001",
// "interestRate": "0.00089489",
// "type": "PERIODIC"
// },
// ]
// }
//
let mut rows: Value = self.safe_list_k(response.clone(), "rows", &[]);
let mut interest: Value = self.parse_borrow_interests(rows.clone(), &[market.clone()]);
return self.filter_by_currency_since_limit(interest.clone(), &[code.clone(), since.clone(), limit.clone()]);
Value::Null
}
pub fn parse_borrow_interest(&self, mut info: Value, optional_args: &[Value]) -> Value {
let mut market = get_arg(optional_args, 0, Value::Null);
let mut symbol: Value = self.safe_string_k(info.clone(), "isolatedSymbol", &[]);
let mut timestamp: Value = self.safe_integer_k(info.clone(), "interestAccuredTime", &[]);
let mut marginMode: Value = ternary(is_true(&(is_equal(&symbol, &Value::Null))), Value::Str("cross".to_string()), Value::Str("isolated".to_string()));
return Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("info".to_string(), info.clone());
m.insert("symbol".to_string(), symbol.clone());
m.insert("currency".to_string(), self.safe_currency_code(self.safe_string_k(info.clone(), "asset", &[]), &[]));
m.insert("interest".to_string(), self.safe_number_k(info.clone(), "interest", &[]));
m.insert("interestRate".to_string(), self.safe_number_k(info.clone(), "interestRate", &[]));
m.insert("amountBorrowed".to_string(), self.safe_number_k(info.clone(), "principal", &[]));
m.insert("marginMode".to_string(), marginMode.clone());
m.insert("timestamp".to_string(), timestamp.clone());
m.insert("datetime".to_string(), self.iso8601(timestamp.clone()));
m
});
Value::Null
}
/*
* @method
* @name binance#repayCrossMargin
* @description repay borrowed margin and interest
* @see https://developers.binance.com/docs/derivatives/portfolio-margin/trade/Margin-Account-Repay
* @see https://developers.binance.com/docs/margin_trading/borrow-and-repay/Margin-Account-Borrow-Repay
* @see https://developers.binance.com/docs/derivatives/portfolio-margin/trade/Margin-Account-Repay-Debt
* @param {string} code unified currency code of the currency to repay
* @param {float} amount the amount to repay
* @param {object} [params] extra parameters specific to the exchange API endpoint
* @param {boolean} [params.portfolioMargin] set to true if you would like to repay margin in a portfolio margin account
* @param {string} [params.repayCrossMarginMethod] *portfolio margin only* 'papiPostRepayLoan' (default), 'papiPostMarginRepayDebt' (alternative)
* @param {string} [params.specifyRepayAssets] *portfolio margin papiPostMarginRepayDebt only* specific asset list to repay debt
* @returns {object} a [margin loan structure]{@link https://docs.ccxt.com/?id=margin-loan-structure}
*/
pub async fn repay_cross_margin(&mut self, mut code: Value, mut amount: Value, optional_args: &[Value]) -> Value {
let mut params = get_arg(optional_args, 0, Value::Map({
let mut m = indexmap::IndexMap::new();
m
}));
if is_equal(&self.markets, &Value::Null) {
self.load_markets(&[]).await;
}
let mut currency: Value = self.currency(code.clone());
let mut request: Value = Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("asset".to_string(), get_value(¤cy, &Value::Str("id".to_string())));
m.insert("amount".to_string(), self.currency_to_precision(code.clone(), amount.clone(), &[]));
m
});
let mut response: Value = Value::Null;
let mut isPortfolioMargin: Value = Value::Null;
{ let __destr_tmp = self.handle_option_and_params2(params.clone(), Value::Str("repayCrossMargin".to_string()), Value::Str("papi".to_string()), Value::Str("portfolioMargin".to_string()), &[Value::Bool(false)]); isPortfolioMargin = get_value(&__destr_tmp, &Value::Int(0)); params = get_value(&__destr_tmp, &Value::Int(1)); }
if is_true(&isPortfolioMargin) {
let mut method: Value = Value::Null;
{ let __destr_tmp = self.handle_option_and_params2(params.clone(), Value::Str("repayCrossMargin".to_string()), Value::Str("repayCrossMarginMethod".to_string()), Value::Str("method".to_string()), &[]); method = get_value(&__destr_tmp, &Value::Int(0)); params = get_value(&__destr_tmp, &Value::Int(1)); }
if is_equal(&method, &Value::Str("papiPostMarginRepayDebt".to_string())) {
let __ws_arg_196 = self.extend(request.clone(), &[params.clone()]);
response = self.papi_post_margin_repay_debt(&[__ws_arg_196]).await;
} else {
let __ws_arg_197 = self.extend(request.clone(), &[params.clone()]);
response = self.papi_post_repay_loan(&[__ws_arg_197]).await;
}
} else {
add_element_to_object(&mut request, &Value::Str("isIsolated".to_string()), Value::Str("FALSE".to_string()));
add_element_to_object(&mut request, &Value::Str("type".to_string()), Value::Str("REPAY".to_string()));
let __ws_arg_198 = self.extend(request.clone(), &[params.clone()]);
response = self.sapi_post_margin_borrow_repay(&[__ws_arg_198]).await;
}
return self.parse_margin_loan(response.clone(), &[currency.clone()]);
Value::Null
}
/*
* @method
* @name binance#repayIsolatedMargin
* @description repay borrowed margin and interest
* @see https://developers.binance.com/docs/margin_trading/borrow-and-repay/Margin-Account-Borrow-Repay
* @param {string} symbol unified market symbol, required for isolated margin
* @param {string} code unified currency code of the currency to repay
* @param {float} amount the amount to repay
* @param {object} [params] extra parameters specific to the exchange API endpoint
* @returns {object} a [margin loan structure]{@link https://docs.ccxt.com/?id=margin-loan-structure}
*/
pub async fn repay_isolated_margin(&mut self, mut symbol: Value, mut code: Value, mut amount: Value, optional_args: &[Value]) -> Value {
let mut params = get_arg(optional_args, 0, Value::Map({
let mut m = indexmap::IndexMap::new();
m
}));
if is_equal(&self.markets, &Value::Null) {
self.load_markets(&[]).await;
}
let mut currency: Value = self.currency(code.clone());
let mut market: Value = self.market(symbol.clone());
let mut request: Value = Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("asset".to_string(), get_value(¤cy, &Value::Str("id".to_string())));
m.insert("amount".to_string(), self.currency_to_precision(code.clone(), amount.clone(), &[]));
m.insert("symbol".to_string(), get_value(&market, &Value::Str("id".to_string())));
m.insert("isIsolated".to_string(), Value::Str("TRUE".to_string()));
m.insert("type".to_string(), Value::Str("REPAY".to_string()));
m
});
let __ws_arg_199 = self.extend(request.clone(), &[params.clone()]);
let mut response: Value = self.sapi_post_margin_borrow_repay(&[__ws_arg_199]).await;
return self.parse_margin_loan(response.clone(), &[currency.clone()]);
Value::Null
}
/*
* @method
* @name binance#borrowCrossMargin
* @description create a loan to borrow margin
* @see https://developers.binance.com/docs/margin_trading/borrow-and-repay/Margin-Account-Borrow-Repay
* @see https://developers.binance.com/docs/derivatives/portfolio-margin/trade/Margin-Account-Borrow
* @param {string} code unified currency code of the currency to borrow
* @param {float} amount the amount to borrow
* @param {object} [params] extra parameters specific to the exchange API endpoint
* @param {boolean} [params.portfolioMargin] set to true if you would like to borrow margin in a portfolio margin account
* @returns {object} a [margin loan structure]{@link https://docs.ccxt.com/?id=margin-loan-structure}
*/
pub async fn borrow_cross_margin(&mut self, mut code: Value, mut amount: Value, optional_args: &[Value]) -> Value {
let mut params = get_arg(optional_args, 0, Value::Map({
let mut m = indexmap::IndexMap::new();
m
}));
if is_equal(&self.markets, &Value::Null) {
self.load_markets(&[]).await;
}
let mut currency: Value = self.currency(code.clone());
let mut request: Value = Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("asset".to_string(), get_value(¤cy, &Value::Str("id".to_string())));
m.insert("amount".to_string(), self.currency_to_precision(code.clone(), amount.clone(), &[]));
m
});
let mut response: Value = Value::Null;
let mut isPortfolioMargin: Value = Value::Null;
{ let __destr_tmp = self.handle_option_and_params2(params.clone(), Value::Str("borrowCrossMargin".to_string()), Value::Str("papi".to_string()), Value::Str("portfolioMargin".to_string()), &[Value::Bool(false)]); isPortfolioMargin = get_value(&__destr_tmp, &Value::Int(0)); params = get_value(&__destr_tmp, &Value::Int(1)); }
if is_true(&isPortfolioMargin) {
let __ws_arg_200 = self.extend(request.clone(), &[params.clone()]);
response = self.papi_post_margin_loan(&[__ws_arg_200]).await;
} else {
add_element_to_object(&mut request, &Value::Str("isIsolated".to_string()), Value::Str("FALSE".to_string()));
add_element_to_object(&mut request, &Value::Str("type".to_string()), Value::Str("BORROW".to_string()));
let __ws_arg_201 = self.extend(request.clone(), &[params.clone()]);
response = self.sapi_post_margin_borrow_repay(&[__ws_arg_201]).await;
}
return self.parse_margin_loan(response.clone(), &[currency.clone()]);
Value::Null
}
/*
* @method
* @name binance#borrowIsolatedMargin
* @description create a loan to borrow margin
* @see https://developers.binance.com/docs/margin_trading/borrow-and-repay/Margin-Account-Borrow-Repay
* @param {string} symbol unified market symbol, required for isolated margin
* @param {string} code unified currency code of the currency to borrow
* @param {float} amount the amount to borrow
* @param {object} [params] extra parameters specific to the exchange API endpoint
* @returns {object} a [margin loan structure]{@link https://docs.ccxt.com/?id=margin-loan-structure}
*/
pub async fn borrow_isolated_margin(&mut self, mut symbol: Value, mut code: Value, mut amount: Value, optional_args: &[Value]) -> Value {
let mut params = get_arg(optional_args, 0, Value::Map({
let mut m = indexmap::IndexMap::new();
m
}));
if is_equal(&self.markets, &Value::Null) {
self.load_markets(&[]).await;
}
let mut currency: Value = self.currency(code.clone());
let mut market: Value = self.market(symbol.clone());
let mut request: Value = Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("asset".to_string(), get_value(¤cy, &Value::Str("id".to_string())));
m.insert("amount".to_string(), self.currency_to_precision(code.clone(), amount.clone(), &[]));
m.insert("symbol".to_string(), get_value(&market, &Value::Str("id".to_string())));
m.insert("isIsolated".to_string(), Value::Str("TRUE".to_string()));
m.insert("type".to_string(), Value::Str("BORROW".to_string()));
m
});
let __ws_arg_202 = self.extend(request.clone(), &[params.clone()]);
let mut response: Value = self.sapi_post_margin_borrow_repay(&[__ws_arg_202]).await;
return self.parse_margin_loan(response.clone(), &[currency.clone()]);
Value::Null
}
pub fn parse_margin_loan(&self, mut info: Value, optional_args: &[Value]) -> Value {
let mut currency = get_arg(optional_args, 0, Value::Null);
//
// {
// "tranId": 108988250265,
// "clientTag":""
// }
//
// repayCrossMargin alternative endpoint
//
// {
// "asset": "USDC",
// "amount": 10,
// "specifyRepayAssets": null,
// "updateTime": 1727170761267,
// "success": true
// }
//
let mut currencyId: Value = self.safe_string_k(info.clone(), "asset", &[]);
let mut timestamp: Value = self.safe_integer_k(info.clone(), "updateTime", &[]);
return Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("id".to_string(), self.safe_string_k(info.clone(), "tranId", &[]));
m.insert("currency".to_string(), self.safe_currency_code(currencyId.clone(), &[currency.clone()]));
m.insert("amount".to_string(), self.safe_number_k(info.clone(), "amount", &[]));
m.insert("symbol".to_string(), Value::Null);
m.insert("timestamp".to_string(), timestamp.clone());
m.insert("datetime".to_string(), self.iso8601(timestamp.clone()));
m.insert("info".to_string(), info.clone());
m
});
Value::Null
}
/*
* @method
* @name binance#fetchOpenInterestHistory
* @description Retrieves the open interest history of a currency
* @see https://developers.binance.com/docs/derivatives/usds-margined-futures/market-data/rest-api/Open-Interest-Statistics
* @see https://developers.binance.com/docs/derivatives/coin-margined-futures/market-data/rest-api/Open-Interest-Statistics
* @param {string} symbol Unified CCXT market symbol
* @param {string} timeframe "5m","15m","30m","1h","2h","4h","6h","12h", or "1d"
* @param {int} [since] the time(ms) of the earliest record to retrieve as a unix timestamp
* @param {int} [limit] default 30, max 500
* @param {object} [params] exchange specific parameters
* @param {int} [params.until] the time(ms) of the latest record to retrieve as a unix timestamp
* @param {boolean} [params.paginate] default false, when true will automatically paginate by calling this endpoint multiple times. See in the docs all the [availble parameters](https://github.com/ccxt/ccxt/wiki/Manual#pagination-params)
* @returns {object} an array of [open interest structure]{@link https://docs.ccxt.com/?id=open-interest-structure}
*/
pub async fn fetch_open_interest_history(&mut self, mut symbol: Value, optional_args: &[Value]) -> Value {
let mut timeframe = get_arg(optional_args, 0, Value::Str("5m".to_string()));
let mut since = get_arg(optional_args, 1, Value::Null);
let mut limit = get_arg(optional_args, 2, Value::Null);
let mut params = get_arg(optional_args, 3, Value::Map({
let mut m = indexmap::IndexMap::new();
m
}));
if is_equal(&timeframe, &Value::Str("1m".to_string())) {
panic!("{}", crate::exchange_errors::bad_request(add(&self.id, &Value::Str(" fetchOpenInterestHistory cannot use the 1m timeframe".to_string()))));
}
if is_equal(&self.markets, &Value::Null) {
self.load_markets(&[]).await;
}
let mut paginate: Value = Value::Bool(false);
{ let __destr_tmp = self.handle_option_and_params(params.clone(), Value::Str("fetchOpenInterestHistory".to_string()), Value::Str("paginate".to_string()), &[Value::Bool(false)]); paginate = get_value(&__destr_tmp, &Value::Int(0)); params = get_value(&__destr_tmp, &Value::Int(1)); }
if is_true(&paginate) {
return self.fetch_paginated_call_deterministic(Value::Str("fetchOpenInterestHistory".to_string()), &[symbol.clone(), since.clone(), limit.clone(), timeframe.clone(), params.clone(), Value::Int(500)]).await;
}
let mut market: Value = self.market(symbol.clone());
let mut request: Value = Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("period".to_string(), self.safe_string(self.timeframes.clone(), timeframe.clone(), &[timeframe.clone()]));
m
});
if !is_equal(&limit, &Value::Null) {
add_element_to_object(&mut request, &Value::Str("limit".to_string()), limit.clone());
}
let mut symbolKey: Value = ternary(is_true(&(is_equal(&get_value(&market, &Value::Str("linear".to_string())), &Value::Bool(true)))), Value::Str("symbol".to_string()), Value::Str("pair".to_string()));
add_element_to_object(&mut request, &symbolKey, get_value(&market, &Value::Str("id".to_string())));
if is_equal(&get_value(&market, &Value::Str("inverse".to_string())), &Value::Bool(true)) {
add_element_to_object(&mut request, &Value::Str("contractType".to_string()), self.safe_string_k(params.clone(), "contractType", &[Value::Str("CURRENT_QUARTER".to_string())]));
}
if !is_equal(&since, &Value::Null) {
add_element_to_object(&mut request, &Value::Str("startTime".to_string()), since.clone());
}
let mut until: Value = self.safe_integer_k(params.clone(), "until", &[]); // unified in milliseconds
let mut endTime: Value = self.safe_integer_k(params.clone(), "endTime", &[until.clone()]); // exchange-specific in milliseconds
params = self.omit(params.clone(), Value::List(vec![Value::Str("endTime".to_string()), Value::Str("until".to_string())]), &[]);
if is_true(&(!is_equal(&endTime, &Value::Null))) && is_true(&(!is_equal(&endTime, &Value::Int(0)))) {
add_element_to_object(&mut request, &Value::Str("endTime".to_string()), endTime.clone());
} else if is_true(&(!is_equal(&since, &Value::Null))) && is_true(&(!is_equal(&since, &Value::Int(0)))) {
if is_equal(&limit, &Value::Null) {
limit = Value::Int(30); // Exchange default
}
let mut duration: Value = self.parse_timeframe(timeframe.clone());
add_element_to_object(&mut request, &Value::Str("endTime".to_string()), self.sum(&[since.clone(), multiply(&multiply(&duration, &limit), &Value::Int(1000))]));
}
let mut response: Value = Value::Null;
if is_equal(&get_value(&market, &Value::Str("inverse".to_string())), &Value::Bool(true)) {
let __ws_arg_203 = self.extend(request.clone(), &[params.clone()]);
response = self.dapi_data_get_open_interest_hist(&[__ws_arg_203]).await;
} else {
let __ws_arg_204 = self.extend(request.clone(), &[params.clone()]);
response = self.fapi_data_get_open_interest_hist(&[__ws_arg_204]).await;
}
return self.parse_open_interests_history(response.clone(), &[market.clone(), since.clone(), limit.clone()]);
Value::Null
}
/*
* @method
* @name binance#fetchOpenInterest
* @description retrieves the open interest of a contract trading pair
* @see https://developers.binance.com/docs/derivatives/usds-margined-futures/market-data/rest-api/Open-Interest
* @see https://developers.binance.com/docs/derivatives/coin-margined-futures/market-data/rest-api/Open-Interest
* @see https://developers.binance.com/docs/derivatives/option/market-data/Open-Interest
* @param {string} symbol unified CCXT market symbol
* @param {object} [params] exchange specific parameters
* @returns {object} an open interest structure{@link https://docs.ccxt.com/?id=open-interest-structure}
*/
pub async fn fetch_open_interest(&mut self, mut symbol: Value, optional_args: &[Value]) -> Value {
let mut params = get_arg(optional_args, 0, Value::Map({
let mut m = indexmap::IndexMap::new();
m
}));
if is_equal(&self.markets, &Value::Null) {
self.load_markets(&[]).await;
}
let mut market: Value = self.market(symbol.clone());
let mut request: Value = Value::Map({
let mut m = indexmap::IndexMap::new();
m
});
if is_equal(&get_value(&market, &Value::Str("option".to_string())), &Value::Bool(true)) {
add_element_to_object(&mut request, &Value::Str("underlyingAsset".to_string()), get_value(&market, &Value::Str("baseId".to_string())));
if is_equal(&get_value(&market, &Value::Str("expiry".to_string())), &Value::Null) {
panic!("{}", crate::exchange_errors::not_supported(add(&add(&self.id, &Value::Str(" fetchOpenInterest does not support ".to_string())), &symbol)));
}
add_element_to_object(&mut request, &Value::Str("expiration".to_string()), self.yymmdd(get_value(&market, &Value::Str("expiry".to_string())), &[]));
} else {
add_element_to_object(&mut request, &Value::Str("symbol".to_string()), get_value(&market, &Value::Str("id".to_string())));
}
let mut response: Value = Value::Null;
if is_equal(&get_value(&market, &Value::Str("option".to_string())), &Value::Bool(true)) {
let __ws_arg_205 = self.extend(request.clone(), &[params.clone()]);
response = self.eapi_public_get_open_interest(&[__ws_arg_205]).await;
} else if is_equal(&get_value(&market, &Value::Str("inverse".to_string())), &Value::Bool(true)) {
let __ws_arg_206 = self.extend(request.clone(), &[params.clone()]);
response = self.dapi_public_get_open_interest(&[__ws_arg_206]).await;
} else {
let __ws_arg_207 = self.extend(request.clone(), &[params.clone()]);
response = self.fapi_public_get_open_interest(&[__ws_arg_207]).await;
}
//
// futures (fapi)
//
// {
// "symbol": "ETHUSDT_230331",
// "openInterest": "23581.677",
// "time": 1677356872265
// }
//
// futures (dapi)
//
// {
// "symbol": "ETHUSD_PERP",
// "pair": "ETHUSD",
// "openInterest": "26542436",
// "contractType": "PERPETUAL",
// "time": 1677360272224
// }
//
// options (eapi)
//
// [
// {
// "symbol": "ETH-230225-1625-C",
// "sumOpenInterest": "460.50",
// "sumOpenInterestUsd": "734957.4358092150",
// "timestamp": "1677304860000"
// }
// ]
//
if is_equal(&get_value(&market, &Value::Str("option".to_string())), &Value::Bool(true)) {
symbol = get_value(&market, &Value::Str("symbol".to_string()));
let mut result: Value = self.parse_open_interests_history(response.clone(), &[market.clone()]);
{
let mut i: Value = Value::Int(0);
let mut __for_first_288: bool = true;
while { if !__for_first_288 { i = add(&i, &Value::Int(1)); } __for_first_288 = false; is_less_than(&i, &get_array_length(&result)) } {
let mut item: Value = get_value(&result, &i);
let mut item: Value = get_value(&result, &i);
if is_equal(&get_value(&item, &Value::Str("symbol".to_string())), &symbol) {
return item;
}
}
}
panic!("{}", crate::exchange_errors::null_response(add(&add(&self.id, &Value::Str(" fetchOpenInterest() could not find open interest for ".to_string())), &symbol)));
} else {
return self.parse_open_interest(response.clone(), &[market.clone()]);
}
Value::Null
}
pub fn parse_open_interest(&self, mut interest: Value, optional_args: &[Value]) -> Value {
let mut market = get_arg(optional_args, 0, Value::Null);
let mut timestamp: Value = self.safe_integer2(interest.clone(), Value::Str("timestamp".to_string()), Value::Str("time".to_string()), &[]);
let mut id: Value = self.safe_string_k(interest.clone(), "symbol", &[]);
let mut amount: Value = self.safe_number2(interest.clone(), Value::Str("sumOpenInterest".to_string()), Value::Str("openInterest".to_string()), &[]);
let mut value: Value = self.safe_number2(interest.clone(), Value::Str("sumOpenInterestValue".to_string()), Value::Str("sumOpenInterestUsd".to_string()), &[]);
// Inverse returns the number of contracts different from the base or quote volume in this case
// compared with https://www.binance.com/en/futures/funding-history/quarterly/4
let mut isInverse: bool = is_equal(&self.safe_bool_k(market.clone(), "inverse", &[]), &Value::Bool(true));
let mut baseVolume: Value = ternary(is_true(&isInverse), Value::Null, amount.clone());
return self.safe_open_interest(Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("symbol".to_string(), self.safe_symbol(id.clone(), &[market.clone(), Value::Null, Value::Str("contract".to_string())]));
m.insert("baseVolume".to_string(), baseVolume.clone());
m.insert("quoteVolume".to_string(), value.clone());
m.insert("openInterestAmount".to_string(), amount.clone());
m.insert("openInterestValue".to_string(), value.clone());
m.insert("timestamp".to_string(), timestamp.clone());
m.insert("datetime".to_string(), self.iso8601(timestamp.clone()));
m.insert("info".to_string(), interest.clone());
m
}), &[market.clone()]);
Value::Null
}
/*
* @method
* @name binance#fetchMyLiquidations
* @description retrieves the users liquidated positions
* @see https://developers.binance.com/docs/margin_trading/trade/Get-Force-Liquidation-Record
* @see https://developers.binance.com/docs/derivatives/usds-margined-futures/trade/rest-api/Users-Force-Orders
* @see https://developers.binance.com/docs/derivatives/coin-margined-futures/trade/rest-api/Users-Force-Orders
* @see https://developers.binance.com/docs/derivatives/portfolio-margin/trade/Query-Users-UM-Force-Orders
* @see https://developers.binance.com/docs/derivatives/portfolio-margin/trade/Query-Users-CM-Force-Orders
* @param {string} [symbol] unified CCXT market symbol
* @param {int} [since] the earliest time in ms to fetch liquidations for
* @param {int} [limit] the maximum number of liquidation structures to retrieve
* @param {object} [params] exchange specific parameters for the binance api endpoint
* @param {int} [params.until] timestamp in ms of the latest liquidation
* @param {boolean} [params.paginate] *spot only* default false, when true will automatically paginate by calling this endpoint multiple times. See in the docs all the [available parameters](https://github.com/ccxt/ccxt/wiki/Manual#pagination-params)
* @param {boolean} [params.portfolioMargin] set to true if you would like to fetch liquidations in a portfolio margin account
* @param {string} [params.type] "spot"
* @param {string} [params.subType] "linear" or "inverse"
* @returns {object} an array of [liquidation structures]{@link https://docs.ccxt.com/?id=liquidation-structure}
*/
pub async fn fetch_my_liquidations(&mut self, optional_args: &[Value]) -> Value {
let mut symbol = get_arg(optional_args, 0, Value::Null);
let mut since = get_arg(optional_args, 1, Value::Null);
let mut limit = get_arg(optional_args, 2, Value::Null);
let mut params = get_arg(optional_args, 3, Value::Map({
let mut m = indexmap::IndexMap::new();
m
}));
if is_equal(&self.markets, &Value::Null) {
self.load_markets(&[]).await;
}
let mut paginate: Value = Value::Bool(false);
{ let __destr_tmp = self.handle_option_and_params(params.clone(), Value::Str("fetchMyLiquidations".to_string()), Value::Str("paginate".to_string()), &[]); paginate = get_value(&__destr_tmp, &Value::Int(0)); params = get_value(&__destr_tmp, &Value::Int(1)); }
if is_true(&paginate) {
return self.fetch_paginated_call_incremental(Value::Str("fetchMyLiquidations".to_string()), &[symbol.clone(), since.clone(), limit.clone(), params.clone(), Value::Str("current".to_string()), Value::Int(100)]).await;
}
let mut market: Value = Value::Null;
if !is_equal(&symbol, &Value::Null) {
market = self.market(symbol.clone());
}
let mut type_var: Value = Value::Null;
{ let __destr_tmp = self.handle_market_type_and_params(Value::Str("fetchMyLiquidations".to_string()), &[market.clone(), params.clone()]); type_var = get_value(&__destr_tmp, &Value::Int(0)); params = get_value(&__destr_tmp, &Value::Int(1)); }
let mut subType: Value = Value::Null;
{ let __destr_tmp = self.handle_sub_type_and_params(Value::Str("fetchMyLiquidations".to_string()), &[market.clone(), params.clone(), Value::Str("linear".to_string())]); subType = get_value(&__destr_tmp, &Value::Int(0)); params = get_value(&__destr_tmp, &Value::Int(1)); }
let mut isPortfolioMargin: Value = Value::Null;
{ let __destr_tmp = self.handle_option_and_params2(params.clone(), Value::Str("fetchMyLiquidations".to_string()), Value::Str("papi".to_string()), Value::Str("portfolioMargin".to_string()), &[Value::Bool(false)]); isPortfolioMargin = get_value(&__destr_tmp, &Value::Int(0)); params = get_value(&__destr_tmp, &Value::Int(1)); }
let mut request: Value = Value::Map({
let mut m = indexmap::IndexMap::new();
m
});
if !is_equal(&type_var, &Value::Str("spot".to_string())) {
add_element_to_object(&mut request, &Value::Str("autoCloseType".to_string()), Value::Str("LIQUIDATION".to_string()));
}
if !is_equal(&market, &Value::Null) {
let mut symbolKey: Value = ternary(is_true(&(is_equal(&get_value(&market, &Value::Str("spot".to_string())), &Value::Bool(true)))), Value::Str("isolatedSymbol".to_string()), Value::Str("symbol".to_string()));
if !is_true(&isPortfolioMargin) {
add_element_to_object(&mut request, &symbolKey, get_value(&market, &Value::Str("id".to_string())));
}
}
if !is_equal(&since, &Value::Null) {
add_element_to_object(&mut request, &Value::Str("startTime".to_string()), since.clone());
}
if !is_equal(&limit, &Value::Null) {
if is_equal(&type_var, &Value::Str("spot".to_string())) {
add_element_to_object(&mut request, &Value::Str("size".to_string()), limit.clone());
} else {
add_element_to_object(&mut request, &Value::Str("limit".to_string()), limit.clone());
}
}
{ let __destr_tmp = self.handle_until_option(Value::Str("endTime".to_string()), request.clone(), params.clone(), &[]); request = get_value(&__destr_tmp, &Value::Int(0)); params = get_value(&__destr_tmp, &Value::Int(1)); }
let mut response: Value = Value::Null;
if is_equal(&type_var, &Value::Str("spot".to_string())) {
if is_true(&isPortfolioMargin) {
let __ws_arg_208 = self.extend(request.clone(), &[params.clone()]);
response = self.papi_get_margin_force_orders(&[__ws_arg_208]).await;
} else {
let __ws_arg_209 = self.extend(request.clone(), &[params.clone()]);
response = self.sapi_get_margin_force_liquidation_rec(&[__ws_arg_209]).await;
}
} else if is_equal(&subType, &Value::Str("linear".to_string())) {
if is_true(&isPortfolioMargin) {
let __ws_arg_210 = self.extend(request.clone(), &[params.clone()]);
response = self.papi_get_um_force_orders(&[__ws_arg_210]).await;
} else {
let __ws_arg_211 = self.extend(request.clone(), &[params.clone()]);
response = self.fapi_private_get_force_orders(&[__ws_arg_211]).await;
}
} else if is_equal(&subType, &Value::Str("inverse".to_string())) {
if is_true(&isPortfolioMargin) {
let __ws_arg_212 = self.extend(request.clone(), &[params.clone()]);
response = self.papi_get_cm_force_orders(&[__ws_arg_212]).await;
} else {
let __ws_arg_213 = self.extend(request.clone(), &[params.clone()]);
response = self.dapi_private_get_force_orders(&[__ws_arg_213]).await;
}
} else {
panic!("{}", crate::exchange_errors::not_supported(add(&add(&add(&self.id, &Value::Str(" fetchMyLiquidations() does not support ".to_string())), &self.safe_string_k(market.clone(), "type", &[])), &Value::Str(" markets".to_string()))));
}
//
// margin
//
// {
// "rows": [
// {
// "avgPrice": "0.00388359",
// "executedQty": "31.39000000",
// "orderId": 180015097,
// "price": "0.00388110",
// "qty": "31.39000000",
// "side": "SELL",
// "symbol": "BNBBTC",
// "timeInForce": "GTC",
// "isIsolated": true,
// "updatedTime": 1558941374745
// }
// ],
// "total": 1
// }
//
// linear
//
// [
// {
// "orderId": 6071832819,
// "symbol": "BTCUSDT",
// "status": "FILLED",
// "clientOrderId": "autoclose-1596107620040000020",
// "price": "10871.09",
// "avgPrice": "10913.21000",
// "origQty": "0.001",
// "executedQty": "0.001",
// "cumQuote": "10.91321",
// "timeInForce": "IOC",
// "type": "LIMIT",
// "reduceOnly": false,
// "closePosition": false,
// "side": "SELL",
// "positionSide": "BOTH",
// "stopPrice": "0",
// "workingType": "CONTRACT_PRICE",
// "origType": "LIMIT",
// "time": 1596107620044,
// "updateTime": 1596107620087
// },
// ]
//
// inverse
//
// [
// {
// "orderId": 165123080,
// "symbol": "BTCUSD_200925",
// "pair": "BTCUSD",
// "status": "FILLED",
// "clientOrderId": "autoclose-1596542005017000006",
// "price": "11326.9",
// "avgPrice": "11326.9",
// "origQty": "1",
// "executedQty": "1",
// "cumBase": "0.00882854",
// "timeInForce": "IOC",
// "type": "LIMIT",
// "reduceOnly": false,
// "closePosition": false,
// "side": "SELL",
// "positionSide": "BOTH",
// "stopPrice": "0",
// "workingType": "CONTRACT_PRICE",
// "priceProtect": false,
// "origType": "LIMIT",
// "time": 1596542005019,
// "updateTime": 1596542005050
// },
// ]
//
let mut liquidationsList: Value = Value::List(vec![]);
let mut rows: Value = self.safe_list_k(response.clone(), "rows", &[]);
if !is_equal(&rows, &Value::Null) {
liquidationsList = rows.clone();
} else if is_true(&Value::Bool(is_array(&response))) {
// linear and inverse return the bare array, margin wraps it in 'rows'
liquidationsList = response.clone();
}
return self.parse_liquidations(liquidationsList.clone(), &[market.clone(), since.clone(), limit.clone()]);
Value::Null
}
pub fn parse_liquidation(&self, mut liquidation: Value, optional_args: &[Value]) -> Value {
let mut market = get_arg(optional_args, 0, Value::Null);
//
// margin
//
// {
// "avgPrice": "0.00388359",
// "executedQty": "31.39000000",
// "orderId": 180015097,
// "price": "0.00388110",
// "qty": "31.39000000",
// "side": "SELL",
// "symbol": "BNBBTC",
// "timeInForce": "GTC",
// "isIsolated": true,
// "updatedTime": 1558941374745
// }
//
// linear
//
// {
// "orderId": 6071832819,
// "symbol": "BTCUSDT",
// "status": "FILLED",
// "clientOrderId": "autoclose-1596107620040000020",
// "price": "10871.09",
// "avgPrice": "10913.21000",
// "origQty": "0.001",
// "executedQty": "0.002",
// "cumQuote": "10.91321",
// "timeInForce": "IOC",
// "type": "LIMIT",
// "reduceOnly": false,
// "closePosition": false,
// "side": "SELL",
// "positionSide": "BOTH",
// "stopPrice": "0",
// "workingType": "CONTRACT_PRICE",
// "origType": "LIMIT",
// "time": 1596107620044,
// "updateTime": 1596107620087
// }
//
// inverse
//
// {
// "orderId": 165123080,
// "symbol": "BTCUSD_200925",
// "pair": "BTCUSD",
// "status": "FILLED",
// "clientOrderId": "autoclose-1596542005017000006",
// "price": "11326.9",
// "avgPrice": "11326.9",
// "origQty": "1",
// "executedQty": "1",
// "cumBase": "0.00882854",
// "timeInForce": "IOC",
// "type": "LIMIT",
// "reduceOnly": false,
// "closePosition": false,
// "side": "SELL",
// "positionSide": "BOTH",
// "stopPrice": "0",
// "workingType": "CONTRACT_PRICE",
// "priceProtect": false,
// "origType": "LIMIT",
// "time": 1596542005019,
// "updateTime": 1596542005050
// }
//
let mut marketId: Value = self.safe_string_k(liquidation.clone(), "symbol", &[]);
let mut timestamp: Value = self.safe_integer2(liquidation.clone(), Value::Str("updatedTime".to_string()), Value::Str("updateTime".to_string()), &[]);
return self.safe_liquidation(Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("info".to_string(), liquidation.clone());
m.insert("symbol".to_string(), self.safe_symbol(marketId.clone(), &[market.clone()]));
m.insert("contracts".to_string(), self.safe_number_k(liquidation.clone(), "executedQty", &[]));
m.insert("contractSize".to_string(), self.safe_number_k(market.clone(), "contractSize", &[]));
m.insert("price".to_string(), self.safe_number_k(liquidation.clone(), "avgPrice", &[]));
m.insert("side".to_string(), self.safe_string_lower(liquidation.clone(), Value::Str("side".to_string()), &[]));
m.insert("baseValue".to_string(), self.safe_number_k(liquidation.clone(), "cumBase", &[]));
m.insert("quoteValue".to_string(), self.safe_number_k(liquidation.clone(), "cumQuote", &[]));
m.insert("timestamp".to_string(), timestamp.clone());
m.insert("datetime".to_string(), self.iso8601(timestamp.clone()));
m
}), &[]);
Value::Null
}
/*
* @method
* @name binance#fetchGreeks
* @description fetches an option contracts greeks, financial metrics used to measure the factors that affect the price of an options contract
* @see https://developers.binance.com/docs/derivatives/option/market-data/Option-Mark-Price
* @param {string} symbol unified symbol of the market to fetch greeks for
* @param {object} [params] extra parameters specific to the exchange API endpoint
* @returns {object} a [greeks structure]{@link https://docs.ccxt.com/?id=greeks-structure}
*/
pub async fn fetch_greeks(&mut self, mut symbol: Value, optional_args: &[Value]) -> Value {
let mut params = get_arg(optional_args, 0, Value::Map({
let mut m = indexmap::IndexMap::new();
m
}));
if is_equal(&self.markets, &Value::Null) {
self.load_markets(&[]).await;
}
let mut market: Value = self.market(symbol.clone());
let mut request: Value = Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("symbol".to_string(), get_value(&market, &Value::Str("id".to_string())));
m
});
let __ws_arg_214 = self.extend(request.clone(), &[params.clone()]);
let mut response: Value = self.eapi_public_get_mark(&[__ws_arg_214]).await;
return self.parse_greeks(self.safe_dict(response.clone(), Value::Int(0), &[Value::Map({
let mut m = indexmap::IndexMap::new();
m
})]), &[market.clone()]);
Value::Null
}
/*
* @method
* @name binance#fetchAllGreeks
* @description fetches all option contracts greeks, financial metrics used to measure the factors that affect the price of an options contract
* @see https://developers.binance.com/docs/derivatives/option/market-data/Option-Mark-Price
* @param {string[]} [symbols] unified symbols of the markets to fetch greeks for, all markets are returned if not assigned
* @param {object} [params] extra parameters specific to the exchange API endpoint
* @returns {object} a dictionary of [greeks structures]{@link https://docs.ccxt.com/?id=greeks-structure} indexed by market symbol
*/
pub async fn fetch_all_greeks(&mut self, optional_args: &[Value]) -> Value {
let mut symbols = get_arg(optional_args, 0, Value::Null);
let mut params = get_arg(optional_args, 1, Value::Map({
let mut m = indexmap::IndexMap::new();
m
}));
if is_equal(&self.markets, &Value::Null) {
self.load_markets(&[]).await;
}
symbols = self.market_symbols(&[symbols.clone(), Value::Null, Value::Bool(true), Value::Bool(true), Value::Bool(true)]);
let mut request: Value = Value::Map({
let mut m = indexmap::IndexMap::new();
m
});
let mut market: Value = Value::Null;
if !is_equal(&symbols, &Value::Null) {
let mut symbolsLength: Value = get_array_length(&symbols);
if is_equal(&symbolsLength, &Value::Int(1)) {
market = self.market(get_value(&symbols, &Value::Int(0)));
add_element_to_object(&mut request, &Value::Str("symbol".to_string()), get_value(&market, &Value::Str("id".to_string())));
}
}
let __ws_arg_215 = self.extend(request.clone(), &[params.clone()]);
let mut response: Value = self.eapi_public_get_mark(&[__ws_arg_215]).await;
return self.parse_all_greeks(response.clone(), &[symbols.clone()]);
Value::Null
}
pub fn parse_greeks(&self, mut greeks: Value, optional_args: &[Value]) -> Value {
let mut market = get_arg(optional_args, 0, Value::Null);
//
// {
// "symbol": "BTC-231229-40000-C",
// "markPrice": "2012",
// "bidIV": "0.60236275",
// "askIV": "0.62267244",
// "markIV": "0.6125176",
// "delta": "0.39111646",
// "theta": "-32.13948531",
// "gamma": "0.00004656",
// "vega": "51.70062218",
// "highPriceLimit": "6474",
// "lowPriceLimit": "5"
// }
//
let mut marketId: Value = self.safe_string_k(greeks.clone(), "symbol", &[]);
let mut symbol: Value = self.safe_symbol(marketId.clone(), &[market.clone()]);
return Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("symbol".to_string(), symbol.clone());
m.insert("timestamp".to_string(), Value::Null);
m.insert("datetime".to_string(), Value::Null);
m.insert("delta".to_string(), self.safe_number_k(greeks.clone(), "delta", &[]));
m.insert("gamma".to_string(), self.safe_number_k(greeks.clone(), "gamma", &[]));
m.insert("theta".to_string(), self.safe_number_k(greeks.clone(), "theta", &[]));
m.insert("vega".to_string(), self.safe_number_k(greeks.clone(), "vega", &[]));
m.insert("rho".to_string(), Value::Null);
m.insert("bidSize".to_string(), Value::Null);
m.insert("askSize".to_string(), Value::Null);
m.insert("bidImpliedVolatility".to_string(), self.safe_number_k(greeks.clone(), "bidIV", &[]));
m.insert("askImpliedVolatility".to_string(), self.safe_number_k(greeks.clone(), "askIV", &[]));
m.insert("markImpliedVolatility".to_string(), self.safe_number_k(greeks.clone(), "markIV", &[]));
m.insert("bidPrice".to_string(), Value::Null);
m.insert("askPrice".to_string(), Value::Null);
m.insert("markPrice".to_string(), self.safe_number_k(greeks.clone(), "markPrice", &[]));
m.insert("lastPrice".to_string(), Value::Null);
m.insert("underlyingPrice".to_string(), Value::Null);
m.insert("info".to_string(), greeks.clone());
m
});
Value::Null
}
pub async fn fetch_trading_limits(&mut self, optional_args: &[Value]) -> Value {
let mut symbols = get_arg(optional_args, 0, Value::Null);
let mut params = get_arg(optional_args, 1, Value::Map({
let mut m = indexmap::IndexMap::new();
m
}));
// this method should not be called directly, use loadTradingLimits () instead
let mut markets: Value = self.fetch_markets(&[]).await;
let mut tradingLimits: Value = Value::Map({
let mut m = indexmap::IndexMap::new();
m
});
{
let mut i: Value = Value::Int(0);
let mut __for_first_289: bool = true;
while { if !__for_first_289 { i = add(&i, &Value::Int(1)); } __for_first_289 = false; is_less_than(&i, &get_array_length(&markets)) } {
let mut market: Value = get_value(&markets, &i);
let mut market: Value = get_value(&markets, &i);
let mut symbol: Value = self.safe_string_k(market.clone(), "symbol", &[]);
if is_equal(&market, &Value::Null) {
panic!("{}", crate::exchange_errors::exchange_error(add(&self.id, &Value::Str(" fetchTradingLimits() could not resolve market".to_string()))));
}
if is_true(&(is_equal(&symbols, &Value::Null))) || is_true(&(self.in_array(symbol.clone(), symbols.clone()))) {
if !is_equal(&symbol, &Value::Null) {
add_element_to_object(&mut tradingLimits, &symbol, get_value(&get_value(&market, &Value::Str("limits".to_string())), &Value::Str("amount".to_string())));
}
}
}
}
return tradingLimits;
Value::Null
}
/*
* @method
* @name binance#fetchPositionMode
* @description fetchs the position mode, hedged or one way, hedged for binance is set identically for all linear markets or all inverse markets
* @see https://developers.binance.com/docs/derivatives/usds-margined-futures/account/rest-api/Get-Current-Position-Mode
* @see https://developers.binance.com/docs/derivatives/coin-margined-futures/account/rest-api/Get-Current-Position-Mode
* @param {string} symbol unified symbol of the market to fetch the order book for
* @param {object} [params] extra parameters specific to the exchange API endpoint
* @param {string} [params.subType] "linear" or "inverse"
* @returns {object} an object detailing whether the market is in hedged or one-way mode
*/
pub async fn fetch_position_mode(&mut self, optional_args: &[Value]) -> Value {
let mut symbol = get_arg(optional_args, 0, Value::Null);
let mut params = get_arg(optional_args, 1, Value::Map({
let mut m = indexmap::IndexMap::new();
m
}));
let mut market: Value = Value::Null;
if !is_equal(&symbol, &Value::Null) {
market = self.market(symbol.clone());
}
let mut subType: Value = Value::Null;
{ let __destr_tmp = self.handle_sub_type_and_params(Value::Str("fetchPositionMode".to_string()), &[market.clone(), params.clone()]); subType = get_value(&__destr_tmp, &Value::Int(0)); params = get_value(&__destr_tmp, &Value::Int(1)); }
let mut response: Value = Value::Null;
// we still have two working endpoints but positionMode is common for linear and inverse markets
// thus we do not throw an error if the subType is not specified and default to linear for now
if is_equal(&subType, &Value::Str("inverse".to_string())) {
response = self.dapi_private_get_position_side_dual(&[params.clone()]).await;
} else {
response = self.fapi_private_get_position_side_dual(&[params.clone()]).await;
}
//
// {
// dualSidePosition: false
// }
//
let mut dualSidePosition: Value = self.safe_bool_k(response.clone(), "dualSidePosition", &[]);
return Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("info".to_string(), response.clone());
m.insert("hedged".to_string(), dualSidePosition.clone());
m
});
Value::Null
}
/*
* @method
* @name binance#fetchMarginModes
* @description fetches margin modes ("isolated" or "cross") that the market for the symbol in in, with symbol=undefined all markets for a subType (linear/inverse) are returned
* @see https://developers.binance.com/docs/derivatives/coin-margined-futures/account/rest-api/Account-Information
* @see https://developers.binance.com/docs/derivatives/usds-margined-futures/account/rest-api/Account-Information-V2
* @see https://developers.binance.com/docs/derivatives/usds-margined-futures/account/rest-api/Symbol-Config
* @param {string[]} symbols unified market symbols
* @param {object} [params] extra parameters specific to the exchange API endpoint
* @param {string} [params.subType] "linear" or "inverse"
* @returns {object} a list of [margin mode structures]{@link https://docs.ccxt.com/?id=margin-mode-structure}
*/
pub async fn fetch_margin_modes(&mut self, optional_args: &[Value]) -> Value {
let mut symbols = get_arg(optional_args, 0, Value::Null);
let mut params = get_arg(optional_args, 1, Value::Map({
let mut m = indexmap::IndexMap::new();
m
}));
if is_equal(&self.markets, &Value::Null) {
self.load_markets(&[]).await;
}
let mut market: Value = Value::Null;
if !is_equal(&symbols, &Value::Null) {
symbols = self.market_symbols(&[symbols.clone()]);
market = self.market(get_value(&symbols, &Value::Int(0)));
}
let mut subType: Value = Value::Null;
{ let __destr_tmp = self.handle_sub_type_and_params(Value::Str("fetchMarginMode".to_string()), &[market.clone(), params.clone()]); subType = get_value(&__destr_tmp, &Value::Int(0)); params = get_value(&__destr_tmp, &Value::Int(1)); }
let mut response: Value = Value::Null;
if is_equal(&subType, &Value::Str("linear".to_string())) {
response = self.fapi_private_get_symbol_config(&[params.clone()]).await;
} else if is_equal(&subType, &Value::Str("inverse".to_string())) {
response = self.dapi_private_get_account(&[params.clone()]).await;
} else {
panic!("{}", crate::exchange_errors::bad_request(add(&self.id, &Value::Str(" fetchMarginModes () supports linear and inverse subTypes only".to_string()))));
}
let mut assets: Value = self.safe_list_k(response.clone(), "positions", &[Value::List(vec![])]);
if is_true(&Value::Bool(is_array(&response))) {
assets = response.clone();
}
return self.parse_margin_modes(assets.clone(), &[symbols.clone(), Value::Str("symbol".to_string()), Value::Str("swap".to_string())]);
Value::Null
}
/*
* @method
* @name binance#fetchMarginMode
* @description fetches the margin mode of a specific symbol
* @see https://developers.binance.com/docs/derivatives/usds-margined-futures/account/rest-api/Symbol-Config
* @see https://developers.binance.com/docs/derivatives/coin-margined-futures/account/rest-api/Account-Information
* @param {string} symbol unified symbol of the market the order was made in
* @param {object} [params] extra parameters specific to the exchange API endpoint
* @param {string} [params.subType] "linear" or "inverse"
* @returns {object} a [margin mode structure]{@link https://docs.ccxt.com/?id=margin-mode-structure}
*/
pub async fn fetch_margin_mode(&mut self, mut symbol: Value, optional_args: &[Value]) -> Value {
let mut params = get_arg(optional_args, 0, Value::Map({
let mut m = indexmap::IndexMap::new();
m
}));
if is_equal(&self.markets, &Value::Null) {
self.load_markets(&[]).await;
}
let mut market: Value = self.market(symbol.clone());
let mut subType: Value = Value::Null;
{ let __destr_tmp = self.handle_sub_type_and_params(Value::Str("fetchMarginMode".to_string()), &[market.clone(), params.clone()]); subType = get_value(&__destr_tmp, &Value::Int(0)); params = get_value(&__destr_tmp, &Value::Int(1)); }
let mut response: Value = Value::Null;
if is_equal(&subType, &Value::Str("linear".to_string())) {
let mut request: Value = Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("symbol".to_string(), get_value(&market, &Value::Str("id".to_string())));
m
});
let __ws_arg_216 = self.extend(request.clone(), &[params.clone()]);
response = self.fapi_private_get_symbol_config(&[__ws_arg_216]).await;
} else if is_equal(&subType, &Value::Str("inverse".to_string())) {
let mut fetchMarginModesResponse: Value = self.fetch_margin_modes(&[Value::List(vec![symbol.clone()]), params.clone()]).await;
return get_value(&fetchMarginModesResponse, &symbol);
} else {
panic!("{}", crate::exchange_errors::bad_request(add(&self.id, &Value::Str(" fetchMarginMode () supports linear and inverse subTypes only".to_string()))));
}
if is_equal(&response, &Value::Null) {
panic!("{}", crate::exchange_errors::null_response(add(&self.id, &Value::Str(" fetchMarginMode() returned empty response".to_string()))));
}
return self.parse_margin_mode(get_value(&response, &Value::Int(0)), &[market.clone()]);
Value::Null
}
pub fn parse_margin_mode(&self, mut marginMode: Value, optional_args: &[Value]) -> Value {
let mut market = get_arg(optional_args, 0, Value::Null);
let mut marketId: Value = self.safe_string_k(marginMode.clone(), "symbol", &[]);
market = self.safe_market(&[marketId.clone(), market.clone()]);
let mut marginModeRaw: Value = self.safe_bool_k(marginMode.clone(), "isolated", &[]);
let mut reMarginMode: Value = Value::Null;
if !is_equal(&marginModeRaw, &Value::Null) {
reMarginMode = ternary(is_true(&marginModeRaw), Value::Str("isolated".to_string()), Value::Str("cross".to_string()));
}
let mut marginTypeRaw: Value = self.safe_string_lower(marginMode.clone(), Value::Str("marginType".to_string()), &[]);
if !is_equal(&marginTypeRaw, &Value::Null) {
reMarginMode = ternary(is_true(&(is_equal(&marginTypeRaw, &Value::Str("crossed".to_string())))), Value::Str("cross".to_string()), Value::Str("isolated".to_string()));
}
return Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("info".to_string(), marginMode.clone());
m.insert("symbol".to_string(), self.safe_string_k(market.clone(), "symbol", &[]));
m.insert("marginMode".to_string(), reMarginMode.clone());
m
});
Value::Null
}
/*
* @method
* @name binance#fetchOption
* @description fetches option data that is commonly found in an option chain
* @see https://developers.binance.com/docs/derivatives/option/market-data/24hr-Ticker-Price-Change-Statistics
* @param {string} symbol unified market symbol
* @param {object} [params] extra parameters specific to the exchange API endpoint
* @returns {object} an [option chain structure]{@link https://docs.ccxt.com/?id=option-chain-structure}
*/
pub async fn fetch_option(&mut self, mut symbol: Value, optional_args: &[Value]) -> Value {
let mut params = get_arg(optional_args, 0, Value::Map({
let mut m = indexmap::IndexMap::new();
m
}));
if is_equal(&self.markets, &Value::Null) {
self.load_markets(&[]).await;
}
let mut market: Value = self.market(symbol.clone());
let mut request: Value = Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("symbol".to_string(), get_value(&market, &Value::Str("id".to_string())));
m
});
let __ws_arg_217 = self.extend(request.clone(), &[params.clone()]);
let mut response: Value = self.eapi_public_get_ticker(&[__ws_arg_217]).await;
//
// [
// {
// "symbol": "BTC-241227-80000-C",
// "priceChange": "0",
// "priceChangePercent": "0",
// "lastPrice": "2750",
// "lastQty": "0",
// "open": "2750",
// "high": "2750",
// "low": "2750",
// "volume": "0",
// "amount": "0",
// "bidPrice": "4880",
// "askPrice": "0",
// "openTime": 0,
// "closeTime": 0,
// "firstTradeId": 0,
// "tradeCount": 0,
// "strikePrice": "80000",
// "exercisePrice": "63944.09893617"
// }
// ]
//
let mut chain: Value = self.safe_dict(response.clone(), Value::Int(0), &[Value::Map({
let mut m = indexmap::IndexMap::new();
m
})]);
return self.parse_option(chain.clone(), &[Value::Null, market.clone()]);
Value::Null
}
pub fn parse_option(&self, mut chain: Value, optional_args: &[Value]) -> Value {
let mut currency = get_arg(optional_args, 0, Value::Null);
let mut market = get_arg(optional_args, 1, Value::Null);
//
// {
// "symbol": "BTC-241227-80000-C",
// "priceChange": "0",
// "priceChangePercent": "0",
// "lastPrice": "2750",
// "lastQty": "0",
// "open": "2750",
// "high": "2750",
// "low": "2750",
// "volume": "0",
// "amount": "0",
// "bidPrice": "4880",
// "askPrice": "0",
// "openTime": 0,
// "closeTime": 0,
// "firstTradeId": 0,
// "tradeCount": 0,
// "strikePrice": "80000",
// "exercisePrice": "63944.09893617"
// }
//
let mut marketId: Value = self.safe_string_k(chain.clone(), "symbol", &[]);
market = self.safe_market(&[marketId.clone(), market.clone()]);
return Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("info".to_string(), chain.clone());
m.insert("currency".to_string(), Value::Null);
m.insert("symbol".to_string(), get_value(&market, &Value::Str("symbol".to_string())));
m.insert("timestamp".to_string(), Value::Null);
m.insert("datetime".to_string(), Value::Null);
m.insert("impliedVolatility".to_string(), Value::Null);
m.insert("openInterest".to_string(), Value::Null);
m.insert("bidPrice".to_string(), self.safe_number_k(chain.clone(), "bidPrice", &[]));
m.insert("askPrice".to_string(), self.safe_number_k(chain.clone(), "askPrice", &[]));
m.insert("midPrice".to_string(), Value::Null);
m.insert("markPrice".to_string(), Value::Null);
m.insert("lastPrice".to_string(), self.safe_number_k(chain.clone(), "lastPrice", &[]));
m.insert("underlyingPrice".to_string(), self.safe_number_k(chain.clone(), "exercisePrice", &[]));
m.insert("change".to_string(), self.safe_number_k(chain.clone(), "priceChange", &[]));
m.insert("percentage".to_string(), self.safe_number_k(chain.clone(), "priceChangePercent", &[]));
m.insert("baseVolume".to_string(), self.safe_number_k(chain.clone(), "volume", &[]));
m.insert("quoteVolume".to_string(), Value::Null);
m
});
Value::Null
}
/*
* @method
* @name binance#fetchMarginAdjustmentHistory
* @description fetches the history of margin added or reduced from contract isolated positions
* @see https://developers.binance.com/docs/derivatives/usds-margined-futures/trade/rest-api/Get-Position-Margin-Change-History
* @see https://developers.binance.com/docs/derivatives/coin-margined-futures/trade/rest-api/Get-Position-Margin-Change-History
* @param {string} symbol unified market symbol
* @param {string} [type] "add" or "reduce"
* @param {int} [since] timestamp in ms of the earliest change to fetch
* @param {int} [limit] the maximum amount of changes to fetch
* @param {object} params extra parameters specific to the exchange API endpoint
* @param {int} [params.until] timestamp in ms of the latest change to fetch
* @returns {object[]} a list of [margin structures]{@link https://docs.ccxt.com/?id=margin-loan-structure}
*/
pub async fn fetch_margin_adjustment_history(&mut self, optional_args: &[Value]) -> Value {
let mut symbol = get_arg(optional_args, 0, Value::Null);
let mut type_var = get_arg(optional_args, 1, Value::Null);
let mut since = get_arg(optional_args, 2, Value::Null);
let mut limit = get_arg(optional_args, 3, Value::Null);
let mut params = get_arg(optional_args, 4, Value::Map({
let mut m = indexmap::IndexMap::new();
m
}));
if is_equal(&self.markets, &Value::Null) {
self.load_markets(&[]).await;
}
if is_equal(&symbol, &Value::Null) {
panic!("{}", crate::exchange_errors::arguments_required(add(&self.id, &Value::Str(" fetchMarginAdjustmentHistory () requires a symbol argument".to_string()))));
}
let mut market: Value = self.market(symbol.clone());
let mut until: Value = self.safe_integer_k(params.clone(), "until", &[]);
params = self.omit(params.clone(), Value::Str("until".to_string()), &[]);
let mut request: Value = Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("symbol".to_string(), get_value(&market, &Value::Str("id".to_string())));
m
});
if !is_equal(&type_var, &Value::Null) {
add_element_to_object(&mut request, &Value::Str("type".to_string()), ternary(is_true(&(is_equal(&type_var, &Value::Str("add".to_string())))), Value::Int(1), Value::Int(2)));
}
if !is_equal(&since, &Value::Null) {
add_element_to_object(&mut request, &Value::Str("startTime".to_string()), since.clone());
}
if !is_equal(&limit, &Value::Null) {
add_element_to_object(&mut request, &Value::Str("limit".to_string()), limit.clone());
}
if !is_equal(&until, &Value::Null) {
add_element_to_object(&mut request, &Value::Str("endTime".to_string()), until.clone());
}
let mut response: Value = Value::Null;
if is_equal(&get_value(&market, &Value::Str("linear".to_string())), &Value::Bool(true)) {
let __ws_arg_218 = self.extend(request.clone(), &[params.clone()]);
response = self.fapi_private_get_position_margin_history(&[__ws_arg_218]).await;
} else if is_equal(&get_value(&market, &Value::Str("inverse".to_string())), &Value::Bool(true)) {
let __ws_arg_219 = self.extend(request.clone(), &[params.clone()]);
response = self.dapi_private_get_position_margin_history(&[__ws_arg_219]).await;
} else {
panic!("{}", crate::exchange_errors::bad_request(add(&add(&self.id, &Value::Str(" fetchMarginAdjustmentHistory () is not supported for markets of type ".to_string())), &get_value(&market, &Value::Str("type".to_string())))));
}
//
// [
// {
// symbol: "XRPUSDT",
// type: "1",
// deltaType: "TRADE",
// amount: "2.57148240",
// asset: "USDT",
// time: "1711046271555",
// positionSide: "BOTH",
// clientTranId: ""
// }
// ...
// ]
//
if is_equal(&response, &Value::Null) {
panic!("{}", crate::exchange_errors::null_response(add(&self.id, &Value::Str(" parseMarginModifications() returned empty response".to_string()))));
}
let mut modifications: Value = self.parse_margin_modifications(self.to_array(response.clone()), &[]);
return self.filter_by_symbol_since_limit(modifications.clone(), &[symbol.clone(), since.clone(), limit.clone()]);
Value::Null
}
/*
* @method
* @name binance#fetchConvertCurrencies
* @description fetches all available currencies that can be converted
* @see https://developers.binance.com/docs/convert/market-data/Query-order-quantity-precision-per-asset
* @param {object} [params] extra parameters specific to the exchange API endpoint
* @returns {object} an associative dictionary of currencies
*/
pub async fn fetch_convert_currencies(&mut self, optional_args: &[Value]) -> Value {
let mut params = get_arg(optional_args, 0, Value::Map({
let mut m = indexmap::IndexMap::new();
m
}));
if is_equal(&self.markets, &Value::Null) {
self.load_markets(&[]).await;
}
let mut response: Value = self.sapi_get_convert_asset_info(&[params.clone()]).await;
//
// [
// {
// "asset": "BTC",
// "fraction": 8
// },
// ]
//
let mut result: Value = Value::Map({
let mut m = indexmap::IndexMap::new();
m
});
let mut assets: Value = self.to_array(response.clone());
{
let mut i: Value = Value::Int(0);
let mut __for_first_290: bool = true;
while { if !__for_first_290 { i = add(&i, &Value::Int(1)); } __for_first_290 = false; is_less_than(&i, &get_array_length(&assets)) } {
let mut entry: Value = get_value(&assets, &i);
let mut entry: Value = get_value(&assets, &i);
let mut id: Value = self.safe_string_k(entry.clone(), "asset", &[]);
let mut code: Value = self.safe_currency_code(id.clone(), &[]);
if !is_equal(&code, &Value::Null) {
add_element_to_object(&mut result, &code, Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("info".to_string(), entry.clone());
m.insert("id".to_string(), id.clone());
m.insert("code".to_string(), code.clone());
m.insert("networks".to_string(), Value::Null);
m.insert("type".to_string(), Value::Null);
m.insert("name".to_string(), Value::Null);
m.insert("active".to_string(), Value::Null);
m.insert("deposit".to_string(), Value::Null);
m.insert("withdraw".to_string(), Value::Null);
m.insert("fee".to_string(), Value::Null);
m.insert("precision".to_string(), self.parse_number(self.parse_precision(&[self.safe_string_k(entry.clone(), "fraction", &[])]), &[]));
m.insert("limits".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("amount".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("min".to_string(), Value::Null);
m.insert("max".to_string(), Value::Null);
m
}));
m.insert("withdraw".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("min".to_string(), Value::Null);
m.insert("max".to_string(), Value::Null);
m
}));
m.insert("deposit".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("min".to_string(), Value::Null);
m.insert("max".to_string(), Value::Null);
m
}));
m
}));
m.insert("created".to_string(), Value::Null);
m
}));
}
}
}
return result;
Value::Null
}
/*
* @method
* @name binance#fetchConvertQuote
* @description fetch a quote for converting from one currency to another
* @see https://developers.binance.com/docs/convert/trade/Send-quote-request
* @param {string} fromCode the currency that you want to sell and convert from
* @param {string} toCode the currency that you want to buy and convert into
* @param {float} amount how much you want to trade in units of the from currency
* @param {object} [params] extra parameters specific to the exchange API endpoint
* @param {string} [params.walletType] either 'SPOT' or 'FUNDING', the default is 'SPOT'
* @returns {object} a [conversion structure]{@link https://docs.ccxt.com/?id=conversion-structure}
*/
pub async fn fetch_convert_quote(&mut self, mut fromCode: Value, mut toCode: Value, optional_args: &[Value]) -> Value {
let mut amount = get_arg(optional_args, 0, Value::Null);
let mut params = get_arg(optional_args, 1, Value::Map({
let mut m = indexmap::IndexMap::new();
m
}));
if is_equal(&amount, &Value::Null) {
panic!("{}", crate::exchange_errors::arguments_required(add(&self.id, &Value::Str(" fetchConvertQuote() requires an amount argument".to_string()))));
}
if is_equal(&self.markets, &Value::Null) {
self.load_markets(&[]).await;
}
let mut request: Value = Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("fromAsset".to_string(), fromCode.clone());
m.insert("toAsset".to_string(), toCode.clone());
m.insert("fromAmount".to_string(), amount.clone());
m
});
let __ws_arg_220 = self.extend(request.clone(), &[params.clone()]);
let mut response: Value = self.sapi_post_convert_get_quote(&[__ws_arg_220]).await;
//
// {
// "quoteId":"12415572564",
// "ratio":"38163.7",
// "inverseRatio":"0.0000262",
// "validTimestamp":1623319461670,
// "toAmount":"3816.37",
// "fromAmount":"0.1"
// }
//
let mut fromCurrency: Value = self.currency(fromCode.clone());
let mut toCurrency: Value = self.currency(toCode.clone());
if is_equal(&response, &Value::Null) {
panic!("{}", crate::exchange_errors::null_response(add(&self.id, &Value::Str(" parseConversion() returned empty response".to_string()))));
}
return self.parse_conversion(response.clone(), &[fromCurrency.clone(), toCurrency.clone()]);
Value::Null
}
/*
* @method
* @name binance#createConvertTrade
* @description convert from one currency to another
* @see https://developers.binance.com/docs/convert/trade/Accept-Quote
* @param {string} id the id of the trade that you want to make
* @param {string} fromCode the currency that you want to sell and convert from
* @param {string} toCode the currency that you want to buy and convert into
* @param {float} [amount] how much you want to trade in units of the from currency
* @param {object} [params] extra parameters specific to the exchange API endpoint
* @returns {object} a [conversion structure]{@link https://docs.ccxt.com/?id=conversion-structure}
*/
pub async fn create_convert_trade(&mut self, mut id: Value, mut fromCode: Value, mut toCode: Value, optional_args: &[Value]) -> Value {
let mut amount = get_arg(optional_args, 0, Value::Null);
let mut params = get_arg(optional_args, 1, Value::Map({
let mut m = indexmap::IndexMap::new();
m
}));
if is_equal(&self.markets, &Value::Null) {
self.load_markets(&[]).await;
}
let mut request: Value = Value::Map({
let mut m = indexmap::IndexMap::new();
m
});
let mut response: Value = Value::Null;
if is_true(&(is_equal(&fromCode, &Value::Str("BUSD".to_string())))) || is_true(&(is_equal(&toCode, &Value::Str("BUSD".to_string())))) {
if is_equal(&amount, &Value::Null) {
panic!("{}", crate::exchange_errors::arguments_required(add(&self.id, &Value::Str(" createConvertTrade() requires an amount argument".to_string()))));
}
add_element_to_object(&mut request, &Value::Str("clientTranId".to_string()), id.clone());
add_element_to_object(&mut request, &Value::Str("asset".to_string()), fromCode.clone());
add_element_to_object(&mut request, &Value::Str("targetAsset".to_string()), toCode.clone());
add_element_to_object(&mut request, &Value::Str("amount".to_string()), amount.clone());
let __ws_arg_221 = self.extend(request.clone(), &[params.clone()]);
response = self.sapi_post_asset_convert_transfer(&[__ws_arg_221]).await;
} else {
add_element_to_object(&mut request, &Value::Str("quoteId".to_string()), id.clone());
let __ws_arg_222 = self.extend(request.clone(), &[params.clone()]);
response = self.sapi_post_convert_accept_quote(&[__ws_arg_222]).await;
}
let mut fromCurrency: Value = self.currency(fromCode.clone());
let mut toCurrency: Value = self.currency(toCode.clone());
if is_equal(&response, &Value::Null) {
panic!("{}", crate::exchange_errors::null_response(add(&self.id, &Value::Str(" parseConversion() returned empty response".to_string()))));
}
return self.parse_conversion(response.clone(), &[fromCurrency.clone(), toCurrency.clone()]);
Value::Null
}
/*
* @method
* @name binance#fetchConvertTrade
* @description fetch the data for a conversion trade
* @see https://developers.binance.com/docs/convert/trade/Order-Status
* @param {string} id the id of the trade that you want to fetch
* @param {string} [code] the unified currency code of the conversion trade
* @param {object} [params] extra parameters specific to the exchange API endpoint
* @returns {object} a [conversion structure]{@link https://docs.ccxt.com/?id=conversion-structure}
*/
pub async fn fetch_convert_trade(&mut self, mut id: Value, optional_args: &[Value]) -> Value {
let mut code = get_arg(optional_args, 0, Value::Null);
let mut params = get_arg(optional_args, 1, Value::Map({
let mut m = indexmap::IndexMap::new();
m
}));
if is_equal(&self.markets, &Value::Null) {
self.load_markets(&[]).await;
}
let mut request: Value = Value::Map({
let mut m = indexmap::IndexMap::new();
m
});
let mut response: Value = Value::Null;
if is_equal(&code, &Value::Str("BUSD".to_string())) {
let mut msInDay: Value = Value::Int(86400000);
let mut now: Value = self.milliseconds();
if !is_equal(&code, &Value::Null) {
let mut currency: Value = self.currency(code.clone());
add_element_to_object(&mut request, &Value::Str("asset".to_string()), get_value(¤cy, &Value::Str("id".to_string())));
}
add_element_to_object(&mut request, &Value::Str("tranId".to_string()), id.clone());
add_element_to_object(&mut request, &Value::Str("startTime".to_string()), subtract(&now, &msInDay));
add_element_to_object(&mut request, &Value::Str("endTime".to_string()), now.clone());
let __ws_arg_223 = self.extend(request.clone(), &[params.clone()]);
response = self.sapi_get_asset_convert_transfer_query_by_page(&[__ws_arg_223]).await;
} else {
add_element_to_object(&mut request, &Value::Str("orderId".to_string()), id.clone());
let __ws_arg_224 = self.extend(request.clone(), &[params.clone()]);
response = self.sapi_get_convert_order_status(&[__ws_arg_224]).await;
}
let mut data: Value = response.clone();
if is_equal(&code, &Value::Str("BUSD".to_string())) {
let mut rows: Value = self.safe_list_k(response.clone(), "rows", &[Value::List(vec![])]);
data = self.safe_dict(rows.clone(), Value::Int(0), &[Value::Map({
let mut m = indexmap::IndexMap::new();
m
})]);
}
let mut fromCurrencyId: Value = self.safe_string2(data.clone(), Value::Str("deductedAsset".to_string()), Value::Str("fromAsset".to_string()), &[]);
let mut toCurrencyId: Value = self.safe_string2(data.clone(), Value::Str("targetAsset".to_string()), Value::Str("toAsset".to_string()), &[]);
let mut fromCurrency: Value = Value::Null;
let mut toCurrency: Value = Value::Null;
if !is_equal(&fromCurrencyId, &Value::Null) {
fromCurrency = self.currency(fromCurrencyId.clone());
}
if !is_equal(&toCurrencyId, &Value::Null) {
toCurrency = self.currency(toCurrencyId.clone());
}
if is_equal(&data, &Value::Null) {
panic!("{}", crate::exchange_errors::null_response(add(&self.id, &Value::Str(" parseConversion() returned empty response".to_string()))));
}
return self.parse_conversion(data.clone(), &[fromCurrency.clone(), toCurrency.clone()]);
Value::Null
}
/*
* @method
* @name binance#fetchConvertTradeHistory
* @description fetch the users history of conversion trades
* @see https://developers.binance.com/docs/convert/trade/Get-Convert-Trade-History
* @param {string} [code] the unified currency code
* @param {int} [since] the earliest time in ms to fetch conversions for
* @param {int} [limit] the maximum number of conversion structures to retrieve
* @param {object} [params] extra parameters specific to the exchange API endpoint
* @param {int} [params.until] timestamp in ms of the latest conversion to fetch
* @returns {object[]} a list of [conversion structures]{@link https://docs.ccxt.com/?id=conversion-structure}
*/
pub async fn fetch_convert_trade_history(&mut self, optional_args: &[Value]) -> Value {
let mut code = get_arg(optional_args, 0, Value::Null);
let mut since = get_arg(optional_args, 1, Value::Null);
let mut limit = get_arg(optional_args, 2, Value::Null);
let mut params = get_arg(optional_args, 3, Value::Map({
let mut m = indexmap::IndexMap::new();
m
}));
if is_equal(&self.markets, &Value::Null) {
self.load_markets(&[]).await;
}
let mut request: Value = Value::Map({
let mut m = indexmap::IndexMap::new();
m
});
let mut msInThirtyDays: Value = Value::Int(2592000000);
let mut now: Value = self.milliseconds();
if !is_equal(&since, &Value::Null) {
add_element_to_object(&mut request, &Value::Str("startTime".to_string()), since.clone());
} else {
add_element_to_object(&mut request, &Value::Str("startTime".to_string()), subtract(&now, &msInThirtyDays));
}
let mut endTime: Value = self.safe_integer2(params.clone(), Value::Str("endTime".to_string()), Value::Str("until".to_string()), &[]);
if !is_equal(&endTime, &Value::Null) {
add_element_to_object(&mut request, &Value::Str("endTime".to_string()), endTime.clone());
} else {
add_element_to_object(&mut request, &Value::Str("endTime".to_string()), now.clone());
}
params = self.omit(params.clone(), Value::Str("until".to_string()), &[]);
let mut response: Value = Value::Null;
let mut responseQuery: Value = Value::Null;
let mut fromCurrencyKey: Value = Value::Null;
let mut toCurrencyKey: Value = Value::Null;
if is_equal(&code, &Value::Str("BUSD".to_string())) {
let mut currency: Value = self.currency(code.clone());
add_element_to_object(&mut request, &Value::Str("asset".to_string()), get_value(¤cy, &Value::Str("id".to_string())));
if !is_equal(&limit, &Value::Null) {
add_element_to_object(&mut request, &Value::Str("size".to_string()), limit.clone());
}
fromCurrencyKey = Value::Str("deductedAsset".to_string());
toCurrencyKey = Value::Str("targetAsset".to_string());
responseQuery = Value::Str("rows".to_string());
let __ws_arg_225 = self.extend(request.clone(), &[params.clone()]);
response = self.sapi_get_asset_convert_transfer_query_by_page(&[__ws_arg_225]).await;
} else {
if is_greater_than(&(subtract(&get_value(&request, &Value::Str("endTime".to_string())), &get_value(&request, &Value::Str("startTime".to_string())))), &msInThirtyDays) {
panic!("{}", crate::exchange_errors::bad_request(add(&self.id, &Value::Str(" fetchConvertTradeHistory () the max interval between startTime and endTime is 30 days.".to_string()))));
}
if !is_equal(&limit, &Value::Null) {
add_element_to_object(&mut request, &Value::Str("limit".to_string()), limit.clone());
}
fromCurrencyKey = Value::Str("fromAsset".to_string());
toCurrencyKey = Value::Str("toAsset".to_string());
responseQuery = Value::Str("list".to_string());
let __ws_arg_226 = self.extend(request.clone(), &[params.clone()]);
response = self.sapi_get_convert_trade_flow(&[__ws_arg_226]).await;
}
let mut rows: Value = self.safe_list(response.clone(), responseQuery.clone(), &[Value::List(vec![])]);
return self.parse_conversions(rows.clone(), &[code.clone(), fromCurrencyKey.clone(), toCurrencyKey.clone(), since.clone(), limit.clone()]);
Value::Null
}
pub fn parse_conversion(&self, mut conversion: Value, optional_args: &[Value]) -> Value {
let mut fromCurrency = get_arg(optional_args, 0, Value::Null);
let mut toCurrency = get_arg(optional_args, 1, Value::Null);
//
// fetchConvertQuote
//
// {
// "quoteId":"12415572564",
// "ratio":"38163.7",
// "inverseRatio":"0.0000262",
// "validTimestamp":1623319461670,
// "toAmount":"3816.37",
// "fromAmount":"0.1"
// }
//
// createConvertTrade
//
// {
// "orderId":"933256278426274426",
// "createTime":1623381330472,
// "orderStatus":"PROCESS"
// }
//
// createConvertTrade BUSD
//
// {
// "tranId": 118263407119,
// "status": "S"
// }
//
// fetchConvertTrade, fetchConvertTradeHistory BUSD
//
// {
// "tranId": 118263615991,
// "type": 244,
// "time": 1664442078000,
// "deductedAsset": "BUSD",
// "deductedAmount": "1",
// "targetAsset": "USDC",
// "targetAmount": "1",
// "status": "S",
// "accountType": "MAIN"
// }
//
// fetchConvertTrade
//
// {
// "orderId":933256278426274426,
// "orderStatus":"SUCCESS",
// "fromAsset":"BTC",
// "fromAmount":"0.00054414",
// "toAsset":"USDT",
// "toAmount":"20",
// "ratio":"36755",
// "inverseRatio":"0.00002721",
// "createTime":1623381330472
// }
//
// fetchConvertTradeHistory
//
// {
// "quoteId": "f3b91c525b2644c7bc1e1cd31b6e1aa6",
// "orderId": 940708407462087195,
// "orderStatus": "SUCCESS",
// "fromAsset": "USDT",
// "fromAmount": "20",
// "toAsset": "BNB",
// "toAmount": "0.06154036",
// "ratio": "0.00307702",
// "inverseRatio": "324.99",
// "createTime": 1624248872184
// }
//
let mut timestamp: Value = self.safe_integer_n(conversion.clone(), Value::List(vec![Value::Str("time".to_string()), Value::Str("validTimestamp".to_string()), Value::Str("createTime".to_string())]), &[]);
let mut fromCur: Value = self.safe_string2(conversion.clone(), Value::Str("deductedAsset".to_string()), Value::Str("fromAsset".to_string()), &[]);
let mut fromCode: Value = self.safe_currency_code(fromCur.clone(), &[fromCurrency.clone()]);
let mut to: Value = self.safe_string2(conversion.clone(), Value::Str("targetAsset".to_string()), Value::Str("toAsset".to_string()), &[]);
let mut toCode: Value = self.safe_currency_code(to.clone(), &[toCurrency.clone()]);
return Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("info".to_string(), conversion.clone());
m.insert("timestamp".to_string(), timestamp.clone());
m.insert("datetime".to_string(), self.iso8601(timestamp.clone()));
m.insert("id".to_string(), self.safe_string_n(conversion.clone(), Value::List(vec![Value::Str("tranId".to_string()), Value::Str("orderId".to_string()), Value::Str("quoteId".to_string())]), &[]));
m.insert("fromCurrency".to_string(), fromCode.clone());
m.insert("fromAmount".to_string(), self.safe_number2(conversion.clone(), Value::Str("deductedAmount".to_string()), Value::Str("fromAmount".to_string()), &[]));
m.insert("toCurrency".to_string(), toCode.clone());
m.insert("toAmount".to_string(), self.safe_number2(conversion.clone(), Value::Str("targetAmount".to_string()), Value::Str("toAmount".to_string()), &[]));
m.insert("price".to_string(), Value::Null);
m.insert("fee".to_string(), Value::Null);
m
});
Value::Null
}
/*
* @method
* @name binance#fetchFundingIntervals
* @description fetch the funding rate interval for multiple markets
* @see https://developers.binance.com/docs/derivatives/usds-margined-futures/market-data/rest-api/Get-Funding-Rate-Info
* @see https://developers.binance.com/docs/derivatives/coin-margined-futures/market-data/rest-api/Get-Funding-Info
* @param {string[]} [symbols] list of unified market symbols
* @param {object} [params] extra parameters specific to the exchange API endpoint
* @param {string} [params.subType] "linear" or "inverse"
* @returns {object[]} a list of [funding rate structures]{@link https://docs.ccxt.com/?id=funding-rate-structure}
*/
pub async fn fetch_funding_intervals(&mut self, optional_args: &[Value]) -> Value {
let mut symbols = get_arg(optional_args, 0, Value::Null);
let mut params = get_arg(optional_args, 1, Value::Map({
let mut m = indexmap::IndexMap::new();
m
}));
if is_equal(&self.markets, &Value::Null) {
self.load_markets(&[]).await;
}
let mut market: Value = Value::Null;
if !is_equal(&symbols, &Value::Null) {
symbols = self.market_symbols(&[symbols.clone()]);
market = self.market(get_value(&symbols, &Value::Int(0)));
}
let mut type_var: Value = Value::Str("swap".to_string());
let mut subType: Value = Value::Null;
{ let __destr_tmp = self.handle_sub_type_and_params(Value::Str("fetchFundingIntervals".to_string()), &[market.clone(), params.clone(), Value::Str("linear".to_string())]); subType = get_value(&__destr_tmp, &Value::Int(0)); params = get_value(&__destr_tmp, &Value::Int(1)); }
let mut response: Value = Value::Null;
if is_true(&self.is_linear(type_var.clone(), &[subType.clone()])) {
response = self.fapi_public_get_funding_info(&[params.clone()]).await;
} else if is_true(&self.is_inverse(type_var.clone(), &[subType.clone()])) {
response = self.dapi_public_get_funding_info(&[params.clone()]).await;
} else {
panic!("{}", crate::exchange_errors::not_supported(add(&self.id, &Value::Str(" fetchFundingIntervals() supports linear and inverse swap contracts only".to_string()))));
}
return self.parse_funding_rates(response.clone(), &[symbols.clone()]);
Value::Null
}
/*
* @method
* @name binance#fetchLongShortRatioHistory
* @description fetches the long short ratio history for a unified market symbol
* @see https://developers.binance.com/docs/derivatives/usds-margined-futures/market-data/rest-api/Long-Short-Ratio
* @see https://developers.binance.com/docs/derivatives/coin-margined-futures/market-data/rest-api/Long-Short-Ratio
* @param {string} symbol unified symbol of the market to fetch the long short ratio for
* @param {string} [timeframe] the period for the ratio, default is 24 hours
* @param {int} [since] the earliest time in ms to fetch ratios for
* @param {int} [limit] the maximum number of long short ratio structures to retrieve
* @param {object} [params] extra parameters specific to the exchange API endpoint
* @param {int} [params.until] timestamp in ms of the latest ratio to fetch
* @returns {object[]} an array of [long short ratio structures]{@link https://docs.ccxt.com/?id=long-short-ratio-structure}
*/
pub async fn fetch_long_short_ratio_history(&mut self, optional_args: &[Value]) -> Value {
let mut symbol = get_arg(optional_args, 0, Value::Null);
let mut timeframe = get_arg(optional_args, 1, Value::Null);
let mut since = get_arg(optional_args, 2, Value::Null);
let mut limit = get_arg(optional_args, 3, Value::Null);
let mut params = get_arg(optional_args, 4, Value::Map({
let mut m = indexmap::IndexMap::new();
m
}));
if is_equal(&self.markets, &Value::Null) {
self.load_markets(&[]).await;
}
let mut market: Value = self.market(symbol.clone());
if is_equal(&timeframe, &Value::Null) {
timeframe = Value::Str("1d".to_string());
}
let mut request: Value = Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("period".to_string(), timeframe.clone());
m
});
{ let __destr_tmp = self.handle_until_option(Value::Str("endTime".to_string()), request.clone(), params.clone(), &[]); request = get_value(&__destr_tmp, &Value::Int(0)); params = get_value(&__destr_tmp, &Value::Int(1)); }
if !is_equal(&since, &Value::Null) {
add_element_to_object(&mut request, &Value::Str("startTime".to_string()), since.clone());
}
if !is_equal(&limit, &Value::Null) {
add_element_to_object(&mut request, &Value::Str("limit".to_string()), limit.clone());
}
let mut subType: Value = Value::Null;
{ let __destr_tmp = self.handle_sub_type_and_params(Value::Str("fetchLongShortRatioHistory".to_string()), &[market.clone(), params.clone()]); subType = get_value(&__destr_tmp, &Value::Int(0)); params = get_value(&__destr_tmp, &Value::Int(1)); }
let mut response: Value = Value::Null;
if is_equal(&subType, &Value::Str("linear".to_string())) {
add_element_to_object(&mut request, &Value::Str("symbol".to_string()), get_value(&market, &Value::Str("id".to_string())));
let __ws_arg_227 = self.extend(request.clone(), &[params.clone()]);
response = self.fapi_data_get_global_long_short_account_ratio(&[__ws_arg_227]).await;
} else if is_equal(&subType, &Value::Str("inverse".to_string())) {
add_element_to_object(&mut request, &Value::Str("pair".to_string()), get_value(&get_value(&market, &Value::Str("info".to_string())), &Value::Str("pair".to_string())));
let __ws_arg_228 = self.extend(request.clone(), &[params.clone()]);
response = self.dapi_data_get_global_long_short_account_ratio(&[__ws_arg_228]).await;
} else {
panic!("{}", crate::exchange_errors::bad_request(add(&self.id, &Value::Str(" fetchLongShortRatioHistory() supports linear and inverse subTypes only".to_string()))));
}
return self.parse_long_short_ratio_history(response.clone(), &[market.clone()]);
Value::Null
}
pub fn parse_long_short_ratio(&self, mut info: Value, optional_args: &[Value]) -> Value {
let mut market = get_arg(optional_args, 0, Value::Null);
//
// linear
//
// {
// "symbol": "BTCUSDT",
// "longAccount": "0.4558",
// "longShortRatio": "0.8376",
// "shortAccount": "0.5442",
// "timestamp": 1726790400000
// }
//
// inverse
//
// {
// "longAccount": "0.7262",
// "longShortRatio": "2.6523",
// "shortAccount": "0.2738",
// "pair": "BTCUSD",
// "timestamp": 1726790400000
// }
//
let mut marketId: Value = self.safe_string_k(info.clone(), "symbol", &[]);
let mut timestamp: Value = self.safe_integer_omit_zero(info.clone(), Value::Str("timestamp".to_string()), &[]);
return Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("info".to_string(), info.clone());
m.insert("symbol".to_string(), self.safe_symbol(marketId.clone(), &[market.clone(), Value::Null, Value::Str("contract".to_string())]));
m.insert("timestamp".to_string(), timestamp.clone());
m.insert("datetime".to_string(), self.iso8601(timestamp.clone()));
m.insert("timeframe".to_string(), Value::Null);
m.insert("longShortRatio".to_string(), self.safe_number_k(info.clone(), "longShortRatio", &[]));
m
});
Value::Null
}
/*
* @method
* @name binance#fetchADLRank
* @description fetches the auto deleveraging rank and risk percentage for a symbol
* @see https://developers.binance.com/docs/derivatives/usds-margined-futures/market-data/rest-api/ADL-Risk
* @param {string} symbol unified symbol of the market to fetch the auto deleveraging rank for
* @param {object} [params] extra parameters specific to the exchange API endpoint
* @returns {object} an [auto de leverage structure]{@link https://docs.ccxt.com/?id=auto-de-leverage-structure}
*/
pub async fn fetch_adl_rank(&mut self, mut symbol: Value, optional_args: &[Value]) -> Value {
let mut params = get_arg(optional_args, 0, Value::Map({
let mut m = indexmap::IndexMap::new();
m
}));
if is_equal(&self.markets, &Value::Null) {
self.load_markets(&[]).await;
}
let mut market: Value = self.market(symbol.clone());
let mut request: Value = Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("symbol".to_string(), get_value(&market, &Value::Str("id".to_string())));
m
});
let mut subType: Value = Value::Null;
{ let __destr_tmp = self.handle_sub_type_and_params(Value::Str("fetchADLRank".to_string()), &[market.clone(), params.clone()]); subType = get_value(&__destr_tmp, &Value::Int(0)); params = get_value(&__destr_tmp, &Value::Int(1)); }
let mut response: Value = Value::Null;
if is_equal(&subType, &Value::Str("linear".to_string())) {
let __ws_arg_229 = self.extend(request.clone(), &[params.clone()]);
response = self.fapi_public_get_symbol_adl_risk(&[__ws_arg_229]).await;
} else {
panic!("{}", crate::exchange_errors::bad_request(add(&self.id, &Value::Str(" fetchADLRank() supports linear subTypes only".to_string()))));
}
if is_equal(&response, &Value::Null) {
panic!("{}", crate::exchange_errors::null_response(add(&self.id, &Value::Str(" parseADLRank() returned empty response".to_string()))));
}
return self.parse_adl_rank(response.clone(), &[market.clone()]);
Value::Null
}
/*
* @method
* @name binance#fetchPositionsADLRank
* @description fetches the auto deleveraging rank and risk percentage for a list of symbols that have open positions
* @see https://developers.binance.com/docs/derivatives/usds-margined-futures/trade/rest-api/Position-ADL-Quantile-Estimation
* @see https://developers.binance.com/docs/derivatives/coin-margined-futures/trade/rest-api/Position-ADL-Quantile-Estimation
* @see https://developers.binance.com/docs/derivatives/portfolio-margin/trade/UM-Position-ADL-Quantile-Estimation
* @see https://developers.binance.com/docs/derivatives/portfolio-margin/trade/CM-Position-ADL-Quantile-Estimation
* @param {string[]} [symbols] list of unified market symbols
* @param {object} [params] extra parameters specific to the exchange API endpoint
* @param {boolean} [params.portfolioMargin] set to true for the portfolio margin account
* @returns {object[]} an array of [auto de leverage structure]{@link https://docs.ccxt.com/?id=auto-de-leverage-structure}
*/
pub async fn fetch_positions_adl_rank(&mut self, optional_args: &[Value]) -> Value {
let mut symbols = get_arg(optional_args, 0, Value::Null);
let mut params = get_arg(optional_args, 1, Value::Map({
let mut m = indexmap::IndexMap::new();
m
}));
if is_equal(&self.markets, &Value::Null) {
self.load_markets(&[]).await;
}
symbols = self.market_symbols(&[symbols.clone(), Value::Null, Value::Bool(true), Value::Bool(true), Value::Bool(true)]);
let mut market: Value = self.get_market_from_symbols(&[symbols.clone()]);
let mut subType: Value = Value::Null;
{ let __destr_tmp = self.handle_sub_type_and_params(Value::Str("fetchPositionsADLRank".to_string()), &[market.clone(), params.clone()]); subType = get_value(&__destr_tmp, &Value::Int(0)); params = get_value(&__destr_tmp, &Value::Int(1)); }
let mut isPortfolioMargin: Value = Value::Null;
{ let __destr_tmp = self.handle_option_and_params2(params.clone(), Value::Str("fetchPositionsADLRank".to_string()), Value::Str("papi".to_string()), Value::Str("portfolioMargin".to_string()), &[Value::Bool(false)]); isPortfolioMargin = get_value(&__destr_tmp, &Value::Int(0)); params = get_value(&__destr_tmp, &Value::Int(1)); }
let mut response: Value = Value::Null;
if is_equal(&subType, &Value::Str("linear".to_string())) {
if is_true(&isPortfolioMargin) {
response = self.papi_get_um_adl_quantile(&[params.clone()]).await;
} else {
response = self.fapi_private_get_adl_quantile(&[params.clone()]).await;
}
} else if is_equal(&subType, &Value::Str("inverse".to_string())) {
if is_true(&isPortfolioMargin) {
response = self.papi_get_cm_adl_quantile(&[params.clone()]).await;
} else {
response = self.dapi_private_get_adl_quantile(&[params.clone()]).await;
}
} else {
panic!("{}", crate::exchange_errors::bad_request(add(&self.id, &Value::Str(" fetchPositionsADLRank() supports linear and inverse subTypes only".to_string()))));
}
//
// [
// {
// "symbol": "BTCUSDT",
// "adlQuantile": {
// "LONG": 0,
// "SHORT": 0,
// "BOTH": 1
// }
// }
// ]
//
let mut responseList: Value = Value::List(vec![]);
if !is_equal(&response, &Value::Null) {
responseList = self.to_array(response.clone());
}
return self.parse_adl_ranks(responseList.clone(), &[symbols.clone()]);
Value::Null
}
pub fn parse_adl_rank(&self, mut info: Value, optional_args: &[Value]) -> Value {
let mut market = get_arg(optional_args, 0, Value::Null);
//
// fetchADLRank
//
// {
// "symbol": "BTCUSDT",
// "adlRisk": "LOW",
// "updateTime": 1766827800453
// }
//
// fetchPositionADLRank
//
// {
// "symbol": "BTCUSDT",
// "adlQuantile": {
// "LONG": 0,
// "SHORT": 0,
// "BOTH": 1
// }
// }
//
let mut adlQuantile: Value = self.safe_dict_k(info.clone(), "adlQuantile", &[Value::Map({
let mut m = indexmap::IndexMap::new();
m
})]);
let mut longNum: Value = self.safe_number_k(adlQuantile.clone(), "LONG", &[]);
let mut shortNum: Value = self.safe_number_k(adlQuantile.clone(), "SHORT", &[]);
let mut both: Value = self.safe_number_k(adlQuantile.clone(), "BOTH", &[]);
let mut rank: Value = Value::Null;
if !is_equal(&both, &Value::Null) {
rank = both.clone();
} else {
if !is_equal(&longNum, &Value::Null) && !is_equal(&shortNum, &Value::Null) {
if is_greater_than(&longNum, &shortNum) {
rank = longNum.clone();
} else {
rank = shortNum.clone();
}
}
}
let mut marketId: Value = self.safe_string_k(info.clone(), "symbol", &[]);
let mut timestamp: Value = self.safe_integer2(info.clone(), Value::Str("timestamp".to_string()), Value::Str("updateTime".to_string()), &[]);
return Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("info".to_string(), info.clone());
m.insert("symbol".to_string(), self.safe_symbol(marketId.clone(), &[market.clone(), Value::Null, Value::Str("contract".to_string())]));
m.insert("rank".to_string(), rank.clone());
m.insert("rating".to_string(), self.safe_string_lower(info.clone(), Value::Str("adlRisk".to_string()), &[]));
m.insert("percentage".to_string(), Value::Null);
m.insert("timestamp".to_string(), timestamp.clone());
m.insert("datetime".to_string(), self.iso8601(timestamp.clone()));
m
});
Value::Null
}
}