// 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 MexcCore {
pub exchange: crate::exchange::Exchange,
}
impl MexcCore {
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 = MexcCore::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 MexcCore {
fn nonce(&self, ) -> crate::Value {
// Forward to the inherent method on MexcCore.
MexcCore::nonce(self, )
}
fn parse_ticker(&self, ticker: crate::Value, market: crate::Value) -> crate::Value {
// Forward to the inherent method on MexcCore.
MexcCore::parse_ticker(self, ticker, &[market.clone()])
}
fn parse_trade(&self, trade: crate::Value, market: crate::Value) -> crate::Value {
// Forward to the inherent method on MexcCore.
MexcCore::parse_trade(self, trade, &[market.clone()])
}
fn parse_order(&self, order: crate::Value, market: crate::Value) -> crate::Value {
// Forward to the inherent method on MexcCore.
MexcCore::parse_order(self, order, &[market.clone()])
}
fn parse_ohlcv(&self, ohlcv: crate::Value, market: crate::Value) -> crate::Value {
// Forward to the inherent method on MexcCore.
MexcCore::parse_ohlcv(self, ohlcv, &[market.clone()])
}
fn parse_position(&self, position: crate::Value, market: crate::Value) -> crate::Value {
// Forward to the inherent method on MexcCore.
MexcCore::parse_position(self, position, &[market.clone()])
}
fn parse_funding_rate(&self, rate: crate::Value, market: crate::Value) -> crate::Value {
// Forward to the inherent method on MexcCore.
MexcCore::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 MexcCore.
MexcCore::parse_deposit_address(self, depositAddress, &[currency.clone()])
}
fn parse_transfer(&self, transfer: crate::Value, currency: crate::Value) -> crate::Value {
// Forward to the inherent method on MexcCore.
MexcCore::parse_transfer(self, transfer, &[currency.clone()])
}
fn parse_currency(&self, currency: crate::Value) -> crate::Value {
// Forward to the inherent method on MexcCore.
MexcCore::parse_currency(self, currency)
}
fn parse_transaction(&self, transaction: crate::Value, currency: crate::Value) -> crate::Value {
// Forward to the inherent method on MexcCore.
MexcCore::parse_transaction(self, transaction, &[currency.clone()])
}
fn parse_leverage(&self, leverage: crate::Value, market: crate::Value) -> crate::Value {
// Forward to the inherent method on MexcCore.
MexcCore::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 MexcCore.
MexcCore::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 MexcCore.
MexcCore::parse_deposit_withdraw_fee(self, fee, &[currency.clone()])
}
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 MexcCore.
MexcCore::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 MexcCore.
MexcCore::handle_errors(self, code, reason, url, method, headers, body, response, request_headers, request_body)
}
}
impl crate::exchange_generated::ExchangeBase for MexcCore {
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,
"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,
"close_all_positions" => self.close_all_positions(&args.get(0..).unwrap_or(&[]).to_vec()[..]).await,
"create_deposit_address" => self.create_deposit_address(args.get(0).cloned().unwrap_or(crate::Value::Null), &args.get(1..).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_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_orders" => self.create_orders(args.get(0).cloned().unwrap_or(crate::Value::Null), &args.get(1..).unwrap_or(&[]).to_vec()[..]).await,
"create_spot_order" => self.create_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..).unwrap_or(&[]).to_vec()[..]).await,
"create_spot_order_request" => self.create_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..).unwrap_or(&[]).to_vec()[..]),
"create_swap_order" => self.create_swap_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,
"custom_parse_balance" => self.custom_parse_balance(args.get(0).cloned().unwrap_or(crate::Value::Null), args.get(1).cloned().unwrap_or(crate::Value::Null)),
"fetch_account_helper" => self.fetch_account_helper(args.get(0).cloned().unwrap_or(crate::Value::Null), args.get(1).cloned().unwrap_or(crate::Value::Null)).await,
"fetch_accounts" => self.fetch_accounts(&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_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_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_addresses_by_network" => self.fetch_deposit_addresses_by_network(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_interval" => self.fetch_funding_interval(args.get(0).cloned().unwrap_or(crate::Value::Null), &args.get(1..).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_leverage" => self.fetch_leverage(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_markets" => self.fetch_markets(&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_orders" => self.fetch_open_orders(&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_orders_by_ids" => self.fetch_orders_by_ids(args.get(0).cloned().unwrap_or(crate::Value::Null), &args.get(1..).unwrap_or(&[]).to_vec()[..]).await,
"fetch_orders_by_state" => self.fetch_orders_by_state(args.get(0).cloned().unwrap_or(crate::Value::Null), &args.get(1..).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_history" => self.fetch_positions_history(&args.get(0..).unwrap_or(&[]).to_vec()[..]).await,
"fetch_spot_markets" => self.fetch_spot_markets(&args.get(0..).unwrap_or(&[]).to_vec()[..]).await,
"fetch_status" => self.fetch_status(&args.get(0..).unwrap_or(&[]).to_vec()[..]).await,
"fetch_swap_markets" => self.fetch_swap_markets(&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_transaction_fees" => self.fetch_transaction_fees(&args.get(0..).unwrap_or(&[]).to_vec()[..]).await,
"fetch_transfer" => self.fetch_transfer(args.get(0).cloned().unwrap_or(crate::Value::Null), &args.get(1..).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,
"get_tif_from_raw_order_type" => self.get_tif_from_raw_order_type(&args.get(0..).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)),
"handle_margin_mode_and_params" => self.handle_margin_mode_and_params(args.get(0).cloned().unwrap_or(crate::Value::Null), &args.get(1..).unwrap_or(&[]).to_vec()[..]),
"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_id" => self.parse_account_id(args.get(0).cloned().unwrap_or(crate::Value::Null)),
"parse_balance_helper" => self.parse_balance_helper(args.get(0).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_funding_rate" => self.parse_funding_rate(args.get(0).cloned().unwrap_or(crate::Value::Null), &args.get(1..).unwrap_or(&[]).to_vec()[..]),
"parse_leverage" => self.parse_leverage(args.get(0).cloned().unwrap_or(crate::Value::Null), &args.get(1..).unwrap_or(&[]).to_vec()[..]),
"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_order" => self.parse_order(args.get(0).cloned().unwrap_or(crate::Value::Null), &args.get(1..).unwrap_or(&[]).to_vec()[..]),
"parse_order_book_bid_ask" => self.parse_order_book_bid_ask(args.get(0).cloned().unwrap_or(crate::Value::Null), &args.get(1..).unwrap_or(&[]).to_vec()[..]),
"parse_order_side" => self.parse_order_side(args.get(0).cloned().unwrap_or(crate::Value::Null)),
"parse_order_status" => self.parse_order_status(args.get(0).cloned().unwrap_or(crate::Value::Null)),
"parse_order_time_in_force" => self.parse_order_time_in_force(args.get(0).cloned().unwrap_or(crate::Value::Null)),
"parse_order_type" => self.parse_order_type(args.get(0).cloned().unwrap_or(crate::Value::Null)),
"parse_position" => self.parse_position(args.get(0).cloned().unwrap_or(crate::Value::Null), &args.get(1..).unwrap_or(&[]).to_vec()[..]),
"parse_ticker" => self.parse_ticker(args.get(0).cloned().unwrap_or(crate::Value::Null), &args.get(1..).unwrap_or(&[]).to_vec()[..]),
"parse_trade" => self.parse_trade(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_fee" => self.parse_transaction_fee(args.get(0).cloned().unwrap_or(crate::Value::Null), &args.get(1..).unwrap_or(&[]).to_vec()[..]),
"parse_transaction_fees" => self.parse_transaction_fees(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)),
"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,
"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()[..]),
"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,
"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 MexcCore {
type Target = crate::exchange::Exchange;
fn deref(&self) -> &crate::exchange::Exchange { &self.exchange }
}
impl std::ops::DerefMut for MexcCore {
fn deref_mut(&mut self) -> &mut crate::exchange::Exchange { &mut self.exchange }
}
impl MexcCore {
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("mexc".to_string()));
m.insert("name".to_string(), Value::Str("MEXC Global".to_string()));
m.insert("countries".to_string(), Value::List(vec![Value::Str("SC".to_string())]));
m.insert("rateLimit".to_string(), Value::Int(50));
m.insert("version".to_string(), Value::Str("v3".to_string()));
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(false));
m.insert("option".to_string(), Value::Bool(false));
m.insert("addMargin".to_string(), Value::Bool(true));
m.insert("borrowCrossMargin".to_string(), Value::Bool(false));
m.insert("borrowIsolatedMargin".to_string(), Value::Bool(false));
m.insert("borrowMargin".to_string(), Value::Bool(false));
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(true));
m.insert("closePosition".to_string(), Value::Bool(false));
m.insert("createDepositAddress".to_string(), Value::Bool(true));
m.insert("createMarketBuyOrderWithCost".to_string(), Value::Bool(true));
m.insert("createMarketOrderWithCost".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("createPostOnlyOrder".to_string(), Value::Bool(true));
m.insert("createReduceOnlyOrder".to_string(), Value::Bool(true));
m.insert("createStopLimitOrder".to_string(), Value::Bool(true));
m.insert("createStopMarketOrder".to_string(), Value::Bool(true));
m.insert("createStopOrder".to_string(), Value::Bool(true));
m.insert("createTriggerOrder".to_string(), Value::Bool(true));
m.insert("deposit".to_string(), Value::Null);
m.insert("editOrder".to_string(), Value::Null);
m.insert("fetchAccounts".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(false));
m.insert("fetchBorrowRate".to_string(), Value::Bool(false));
m.insert("fetchBorrowRateHistories".to_string(), Value::Bool(false));
m.insert("fetchBorrowRateHistory".to_string(), Value::Bool(false));
m.insert("fetchBorrowRates".to_string(), Value::Bool(false));
m.insert("fetchBorrowRatesPerSymbol".to_string(), Value::Bool(false));
m.insert("fetchCanceledOrders".to_string(), Value::Bool(true));
m.insert("fetchClosedOrder".to_string(), Value::Null);
m.insert("fetchClosedOrders".to_string(), Value::Bool(true));
m.insert("fetchCrossBorrowRate".to_string(), Value::Bool(false));
m.insert("fetchCrossBorrowRates".to_string(), Value::Bool(false));
m.insert("fetchCurrencies".to_string(), Value::Bool(true));
m.insert("fetchDeposit".to_string(), Value::Null);
m.insert("fetchDepositAddress".to_string(), Value::Bool(true));
m.insert("fetchDepositAddresses".to_string(), Value::Null);
m.insert("fetchDepositAddressesByNetwork".to_string(), Value::Bool(true));
m.insert("fetchDeposits".to_string(), Value::Bool(true));
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::Bool(true));
m.insert("fetchFundingIntervals".to_string(), Value::Bool(false));
m.insert("fetchFundingRate".to_string(), Value::Bool(true));
m.insert("fetchFundingRateHistory".to_string(), Value::Bool(true));
m.insert("fetchFundingRates".to_string(), Value::Bool(false));
m.insert("fetchIndexOHLCV".to_string(), Value::Bool(true));
m.insert("fetchIsolatedBorrowRate".to_string(), Value::Bool(false));
m.insert("fetchIsolatedBorrowRates".to_string(), Value::Bool(false));
m.insert("fetchIsolatedPositions".to_string(), Value::Bool(false));
m.insert("fetchL2OrderBook".to_string(), Value::Bool(true));
m.insert("fetchLedger".to_string(), Value::Null);
m.insert("fetchLedgerEntry".to_string(), Value::Null);
m.insert("fetchLeverage".to_string(), Value::Bool(true));
m.insert("fetchLeverages".to_string(), Value::Bool(false));
m.insert("fetchLeverageTiers".to_string(), Value::Bool(true));
m.insert("fetchMarginAdjustmentHistory".to_string(), Value::Bool(false));
m.insert("fetchMarginMode".to_string(), Value::Bool(false));
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("fetchMyTrades".to_string(), Value::Bool(true));
m.insert("fetchOHLCV".to_string(), Value::Bool(true));
m.insert("fetchOpenInterest".to_string(), Value::Bool(false));
m.insert("fetchOpenInterestHistory".to_string(), Value::Bool(false));
m.insert("fetchOpenOrder".to_string(), Value::Null);
m.insert("fetchOpenOrders".to_string(), Value::Bool(true));
m.insert("fetchOrder".to_string(), Value::Bool(true));
m.insert("fetchOrderBook".to_string(), Value::Bool(true));
m.insert("fetchOrderBooks".to_string(), Value::Null);
m.insert("fetchOrders".to_string(), Value::Bool(true));
m.insert("fetchOrderTrades".to_string(), Value::Bool(true));
m.insert("fetchPosition".to_string(), Value::Str("emulated".to_string()));
m.insert("fetchPositionHistory".to_string(), Value::Str("emulated".to_string()));
m.insert("fetchPositionMode".to_string(), Value::Bool(true));
m.insert("fetchPositions".to_string(), Value::Bool(true));
m.insert("fetchPositionsHistory".to_string(), Value::Bool(true));
m.insert("fetchPositionsRisk".to_string(), Value::Null);
m.insert("fetchPremiumIndexOHLCV".to_string(), Value::Bool(false));
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(false));
m.insert("fetchTradingLimits".to_string(), Value::Null);
m.insert("fetchTransactionFee".to_string(), Value::Str("emulated".to_string()));
m.insert("fetchTransactionFees".to_string(), Value::Bool(true));
m.insert("fetchTransactions".to_string(), Value::Null);
m.insert("fetchTransfer".to_string(), Value::Bool(true));
m.insert("fetchTransfers".to_string(), Value::Bool(true));
m.insert("fetchWithdrawal".to_string(), Value::Null);
m.insert("fetchWithdrawals".to_string(), Value::Bool(true));
m.insert("reduceMargin".to_string(), Value::Bool(true));
m.insert("repayCrossMargin".to_string(), Value::Bool(false));
m.insert("repayIsolatedMargin".to_string(), Value::Bool(false));
m.insert("setLeverage".to_string(), Value::Bool(true));
m.insert("setMarginMode".to_string(), Value::Bool(true));
m.insert("setPositionMode".to_string(), Value::Bool(true));
m.insert("signIn".to_string(), Value::Null);
m.insert("transfer".to_string(), Value::Bool(true));
m.insert("withdraw".to_string(), Value::Bool(true));
m
}));
m.insert("urls".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("logo".to_string(), Value::Str("https://user-images.githubusercontent.com/1294454/137283979-8b2a818d-8633-461b-bfca-de89e8c446b2.jpg".to_string()));
m.insert("api".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("public".to_string(), Value::Str("https://api.mexc.com".to_string()));
m.insert("private".to_string(), Value::Str("https://api.mexc.com".to_string()));
m
}));
m.insert("spot2".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("public".to_string(), Value::Str("https://www.mexc.com/open/api/v2".to_string()));
m.insert("private".to_string(), Value::Str("https://www.mexc.com/open/api/v2".to_string()));
m
}));
m.insert("contract".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("public".to_string(), Value::Str("https://api.mexc.com/api/v1/contract".to_string()));
m.insert("private".to_string(), Value::Str("https://api.mexc.com/api/v1/private".to_string()));
m
}));
m.insert("broker".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("private".to_string(), Value::Str("https://api.mexc.com/api/v3/broker".to_string()));
m
}));
m
}));
m.insert("www".to_string(), Value::Str("https://www.mexc.com/".to_string()));
m.insert("doc".to_string(), Value::List(vec![Value::Str("https://www.mexc.com/api-docs/spot-v3/introduction".to_string()), Value::Str("https://www.mexc.com/api-docs/futures/integration-guide".to_string())]));
m.insert("fees".to_string(), Value::List(vec![Value::Str("https://www.mexc.com/fee".to_string())]));
m.insert("referral".to_string(), Value::Str("https://www.mexc.com/register?inviteCode=mexc-1FQ1GNu1".to_string()));
m
}));
m.insert("api".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("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("announcements".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(8));
m
}));
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("defaultSymbols".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(1));
m
}));
m.insert("symbol/offline".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(10));
m
}));
m.insert("exchangeInfo".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(25));
m
}));
m.insert("depth".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(3));
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(1));
m
}));
m.insert("aggTrades".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("avgPrice".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(25));
m
}));
m.insert("ticker/price".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(10));
m
}));
m.insert("ticker/bookTicker".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(10));
m
}));
m.insert("etf/info".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(1));
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("kyc/status".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(1));
m
}));
m.insert("uid".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(2));
m
}));
m.insert("openOrders".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(3));
m
}));
m.insert("allOrders".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(10));
m
}));
m.insert("account".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(10));
m
}));
m.insert("myTrades".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(10));
m
}));
m.insert("strategy/group".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(20));
m
}));
m.insert("strategy/group/uid".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(20));
m
}));
m.insert("tradeFee".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(20));
m
}));
m.insert("sub-account/list".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(1));
m
}));
m.insert("sub-account/apiKey".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(1));
m
}));
m.insert("sub-account/asset".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(1));
m
}));
m.insert("capital/config/getall".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(10));
m
}));
m.insert("capital/deposit/hisrec".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(10));
m
}));
m.insert("capital/withdraw/history".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(1));
m
}));
m.insert("capital/withdraw/address".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(10));
m
}));
m.insert("capital/deposit/address".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(10));
m
}));
m.insert("capital/transfer".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(1));
m
}));
m.insert("capital/transfer/tranId".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(1));
m
}));
m.insert("capital/transfer/internal".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(1));
m
}));
m.insert("capital/sub-account/universalTransfer".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(1));
m
}));
m.insert("capital/convert".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(1));
m
}));
m.insert("capital/convert/list".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/allOrders".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(1));
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/openOrders".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(1));
m
}));
m.insert("margin/maxTransferable".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(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("margin/order".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(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/maxBorrowable".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/isolated/pair".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(1));
m
}));
m.insert("margin/forceLiquidationRec".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(1));
m
}));
m.insert("margin/isolatedMarginData".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".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::Int(1));
m
}));
m.insert("rebate/taxQuery".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(1));
m
}));
m.insert("rebate/detail".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(1));
m
}));
m.insert("rebate/detail/kickback".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(1));
m
}));
m.insert("rebate/referCode".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(1));
m
}));
m.insert("rebate/affiliate/commission".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(1));
m
}));
m.insert("rebate/affiliate/withdraw".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(1));
m
}));
m.insert("rebate/affiliate/commission/detail".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(1));
m
}));
m.insert("rebate/affiliate/campaign".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(1));
m
}));
m.insert("rebate/affiliate/referral".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(1));
m
}));
m.insert("rebate/affiliate/subaffiliates".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(1));
m
}));
m.insert("rebate/affiliate/list".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(1));
m
}));
m.insert("mxDeduct/enable".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(1));
m
}));
m.insert("userDataStream".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(1));
m
}));
m.insert("selfSymbols".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(1));
m
}));
m.insert("asset/internal/transfer/record".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(10));
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("order/test".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(1));
m
}));
m.insert("apiKeyInfo".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(1));
m
}));
m.insert("sub-account/virtualSubAccount".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(1));
m
}));
m.insert("sub-account/apiKey".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(1));
m
}));
m.insert("sub-account/futures".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(1));
m
}));
m.insert("sub-account/margin".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(10));
m
}));
m.insert("strategy/group".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(20));
m
}));
m.insert("capital/withdraw/apply".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(1));
m
}));
m.insert("capital/withdraw".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(1));
m
}));
m.insert("capital/transfer".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(50));
m
}));
m.insert("capital/transfer/internal".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/sub-account/universalTransfer".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(1));
m
}));
m.insert("capital/convert".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(10));
m
}));
m.insert("mxDeduct/enable".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(1));
m
}));
m.insert("userDataStream".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("userDataStream".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("order".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
}));
m.insert("order/all".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(1));
m
}));
m.insert("sub-account/apiKey".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(1));
m
}));
m.insert("strategy/group".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(1));
m
}));
m.insert("strategy/group/uid".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("margin/openOrders".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(1));
m
}));
m.insert("userDataStream".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(1));
m
}));
m.insert("capital/withdraw".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(1));
m
}));
m
}));
m
}));
m
}));
m.insert("contract".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
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::Int(2));
m
}));
m.insert("detail".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(100));
m
}));
m.insert("support_currencies".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(2));
m
}));
m.insert("depth/{symbol}".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(2));
m
}));
m.insert("depth_commits/{symbol}/{limit}".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(2));
m
}));
m.insert("index_price/{symbol}".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(2));
m
}));
m.insert("fair_price/{symbol}".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(2));
m
}));
m.insert("funding_rate/{symbol}".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(2));
m
}));
m.insert("kline/{symbol}".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(2));
m
}));
m.insert("kline/index_price/{symbol}".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(2));
m
}));
m.insert("kline/fair_price/{symbol}".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(2));
m
}));
m.insert("deals/{symbol}".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(2));
m
}));
m.insert("ticker".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(2));
m
}));
m.insert("risk_reverse".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(2));
m
}));
m.insert("risk_reverse/history".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(2));
m
}));
m.insert("funding_rate/history".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(2));
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("account/assets".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(2));
m
}));
m.insert("account/asset/{currency}".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(2));
m
}));
m.insert("account/transfer_record".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(2));
m
}));
m.insert("account/profit_rate/{type}".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(2));
m
}));
m.insert("account/asset/analysis/{type}".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(2));
m
}));
m.insert("account/feeDeductConfigs".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(2));
m
}));
m.insert("account/asset/analysis/yesterday_pnl".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(2));
m
}));
m.insert("account/asset/analysis/today_pnl".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(2));
m
}));
m.insert("account/config/contractFeeDiscountConfig".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(2));
m
}));
m.insert("order/fee_details".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(2));
m
}));
m.insert("account/discountType".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(2));
m
}));
m.insert("account/asset/analysis/export".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(2));
m
}));
m.insert("account/asset_book/order_deal_fee/total".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(2));
m
}));
m.insert("account/contract/fee_rate".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(2));
m
}));
m.insert("account/contract/zero_fee_rate".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(2));
m
}));
m.insert("position/list/history_positions".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(2));
m
}));
m.insert("position/open_positions".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(2));
m
}));
m.insert("position/funding_records".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(2));
m
}));
m.insert("position/position_mode".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(2));
m
}));
m.insert("order/list/open_orders/{symbol}".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(2));
m
}));
m.insert("order/list/open_orders".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(2));
m
}));
m.insert("order/list/history_orders".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(2));
m
}));
m.insert("order/list/order_deals/v3".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(2));
m
}));
m.insert("order/external/{symbol}/{external_oid}".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(2));
m
}));
m.insert("order/get/{order_id}".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(2));
m
}));
m.insert("order/batch_query".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(8));
m
}));
m.insert("order/deal_details/{order_id}".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(2));
m
}));
m.insert("order/list/order_deals".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(2));
m
}));
m.insert("order/list/close_orders".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(2));
m
}));
m.insert("planorder/list/orders".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(2));
m
}));
m.insert("stoporder/list/orders".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(2));
m
}));
m.insert("stoporder/open_orders".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(2));
m
}));
m.insert("stoporder/order_details/{stop_order_id}".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(2));
m
}));
m.insert("account/risk_limit".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(2));
m
}));
m.insert("account/tiered_fee_rate".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(2));
m
}));
m.insert("position/leverage".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(2));
m
}));
m.insert("account/tiered_fee_rate/v2".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(2));
m
}));
m.insert("trackorder/list/orders".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(2));
m
}));
m.insert("market_maker/self_trade/blacklist".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(2));
m
}));
m.insert("market_maker/self_trade/blacklist/search".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("account/asset/analysis/v3".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(2));
m
}));
m.insert("account/asset/analysis/calendar/daily/v3".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(2));
m
}));
m.insert("account/asset/analysis/calendar/monthly/v3".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(2));
m
}));
m.insert("account/asset/analysis/recent/v3".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(2));
m
}));
m.insert("position/change_margin".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(2));
m
}));
m.insert("position/change_auto_add_im".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(2));
m
}));
m.insert("position/change_leverage".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(2));
m
}));
m.insert("position/change_position_mode".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(2));
m
}));
m.insert("position/reverse".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(2));
m
}));
m.insert("position/close_all".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(10));
m
}));
m.insert("order/create".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(2));
m
}));
m.insert("order/submit".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(2));
m
}));
m.insert("order/submit_batch".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(40));
m
}));
m.insert("order/chase_limit_order".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(40));
m
}));
m.insert("order/change_limit_order".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(40));
m
}));
m.insert("order/cancel".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(2));
m
}));
m.insert("order/batch_cancel_with_external".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(2));
m
}));
m.insert("order/cancel_with_external".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(2));
m
}));
m.insert("order/cancel_all".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(2));
m
}));
m.insert("order/open_order_total_count".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(2));
m
}));
m.insert("order/batch_query_with_external".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(2));
m
}));
m.insert("account/change_risk_level".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(2));
m
}));
m.insert("planorder/place".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(2));
m
}));
m.insert("planorder/place/v2".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(2));
m
}));
m.insert("planorder/cancel".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(2));
m
}));
m.insert("planorder/cancel_all".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(2));
m
}));
m.insert("planorder/change_stop_order".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(2));
m
}));
m.insert("stoporder/place".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(2));
m
}));
m.insert("stoporder/cancel".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(2));
m
}));
m.insert("stoporder/cancel_all".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(2));
m
}));
m.insert("stoporder/change_price".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(2));
m
}));
m.insert("stoporder/change_plan_price".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(2));
m
}));
m.insert("trackorder/place".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(2));
m
}));
m.insert("trackorder/cancel".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(2));
m
}));
m.insert("trackorder/change_order".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(2));
m
}));
m.insert("market_maker/self_trade/blacklist/create".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(2));
m
}));
m.insert("market_maker/self_trade/blacklist/update".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(2));
m
}));
m.insert("market_maker/self_trade/blacklist/delete".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(2));
m
}));
m
}));
m
}));
m
}));
m.insert("spot2".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
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("market/symbols".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(1));
m
}));
m.insert("market/coin/list".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(2));
m
}));
m.insert("common/timestamp".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(1));
m
}));
m.insert("common/ping".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(2));
m
}));
m.insert("market/ticker".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(1));
m
}));
m.insert("market/depth".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(1));
m
}));
m.insert("market/deals".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(1));
m
}));
m.insert("market/kline".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(1));
m
}));
m.insert("market/api_default_symbols".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(2));
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("account/info".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(1));
m
}));
m.insert("order/open_orders".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(1));
m
}));
m.insert("order/list".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(1));
m
}));
m.insert("order/query".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(1));
m
}));
m.insert("order/deals".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(1));
m
}));
m.insert("order/deal_detail".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(1));
m
}));
m.insert("asset/deposit/address/list".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(2));
m
}));
m.insert("asset/deposit/list".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(2));
m
}));
m.insert("asset/address/list".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(2));
m
}));
m.insert("asset/withdraw/list".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(2));
m
}));
m.insert("asset/internal/transfer/record".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(10));
m
}));
m.insert("account/balance".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(10));
m
}));
m.insert("asset/internal/transfer/info".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(10));
m
}));
m.insert("market/api_symbols".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("order/place".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(1));
m
}));
m.insert("order/place_batch".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(1));
m
}));
m.insert("order/advanced/place_batch".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(1));
m
}));
m.insert("asset/withdraw".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(2));
m
}));
m.insert("asset/internal/transfer".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(10));
m
}));
m
}));
m.insert("delete".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("order/cancel".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(1));
m
}));
m.insert("order/cancel_by_symbol".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(1));
m
}));
m.insert("asset/withdraw".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(2));
m
}));
m
}));
m
}));
m
}));
m.insert("broker".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
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("sub-account/universalTransfer".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(1));
m
}));
m.insert("sub-account/list".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(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/apiKey".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(1));
m
}));
m.insert("capital/deposit/subAddress".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(1));
m
}));
m.insert("capital/deposit/subHisrec".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(1));
m
}));
m.insert("capital/deposit/subHisrec/getall".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(1));
m
}));
m.insert("rebate/taxQuery".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("sub-account/virtualSubAccount".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(1));
m
}));
m.insert("sub-account/apiKey".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(1));
m
}));
m.insert("capital/deposit/subAddress".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(1));
m
}));
m.insert("capital/withdraw/apply".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(1));
m
}));
m.insert("sub-account/universalTransfer".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(1));
m
}));
m.insert("sub-account/futures".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("sub-account/apiKey".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(1));
m
}));
m
}));
m
}));
m
}));
m
}));
m.insert("precisionMode".to_string(), Value::Int(crate::runtime::TICK_SIZE));
m.insert("timeframes".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("1m".to_string(), Value::Str("1m".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("4h".to_string(), Value::Str("4h".to_string()));
m.insert("8h".to_string(), Value::Str("8h".to_string()));
m.insert("1d".to_string(), Value::Str("1d".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("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("tierBased".to_string(), Value::Bool(false));
m.insert("percentage".to_string(), Value::Bool(true));
m.insert("maker".to_string(), self.parse_number(Value::Str("0.002".to_string()), &[]));
m.insert("taker".to_string(), self.parse_number(Value::Str("0.002".to_string()), &[]));
m
}));
m
}));
m.insert("options".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("adjustForTimeDifference".to_string(), Value::Bool(false));
m.insert("timeDifference".to_string(), Value::Int(0));
m.insert("fetchMarkets".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("types".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("spot".to_string(), Value::Bool(true));
m.insert("swap".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("linear".to_string(), Value::Bool(true));
m.insert("inverse".to_string(), Value::Bool(false));
m
}));
m
}));
m
}));
m.insert("useCcxtTradeId".to_string(), Value::Bool(true));
m.insert("timeframes".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("1m".to_string(), Value::Str("1m".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("60m".to_string()));
m.insert("4h".to_string(), Value::Str("4h".to_string()));
m.insert("1d".to_string(), Value::Str("1d".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("swap".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("1m".to_string(), Value::Str("Min1".to_string()));
m.insert("5m".to_string(), Value::Str("Min5".to_string()));
m.insert("15m".to_string(), Value::Str("Min15".to_string()));
m.insert("30m".to_string(), Value::Str("Min30".to_string()));
m.insert("1h".to_string(), Value::Str("Min60".to_string()));
m.insert("4h".to_string(), Value::Str("Hour4".to_string()));
m.insert("8h".to_string(), Value::Str("Hour8".to_string()));
m.insert("1d".to_string(), Value::Str("Day1".to_string()));
m.insert("1w".to_string(), Value::Str("Week1".to_string()));
m.insert("1M".to_string(), Value::Str("Month1".to_string()));
m
}));
m
}));
m.insert("defaultType".to_string(), Value::Str("spot".to_string()));
m.insert("defaultNetwork".to_string(), Value::Str("ETH".to_string()));
m.insert("defaultNetworks".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("ETH".to_string(), Value::Str("ETH".to_string()));
m.insert("USDT".to_string(), Value::Str("ERC20".to_string()));
m.insert("USDC".to_string(), Value::Str("ERC20".to_string()));
m.insert("BTC".to_string(), Value::Str("BTC".to_string()));
m.insert("LTC".to_string(), Value::Str("LTC".to_string()));
m
}));
m.insert("networks".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("ZKSYNC".to_string(), Value::Str("ZKSYNCERA".to_string()));
m.insert("TRC20".to_string(), Value::Str("TRX".to_string()));
m.insert("TON".to_string(), Value::Str("TONCOIN".to_string()));
m.insert("ARBITRUM".to_string(), Value::Str("ARB".to_string()));
m.insert("STX".to_string(), Value::Str("STACKS".to_string()));
m.insert("LUNC".to_string(), Value::Str("LUNA".to_string()));
m.insert("STARK".to_string(), Value::Str("STARKNET".to_string()));
m.insert("APT".to_string(), Value::Str("APTOS".to_string()));
m.insert("PEAQ".to_string(), Value::Str("PEAQEVM".to_string()));
m.insert("AVAXC".to_string(), Value::Str("AVAX_CCHAIN".to_string()));
m.insert("ERC20".to_string(), Value::Str("ETH".to_string()));
m.insert("ACA".to_string(), Value::Str("ACALA".to_string()));
m.insert("BEP20".to_string(), Value::Str("BSC".to_string()));
m.insert("OPTIMISM".to_string(), Value::Str("OP".to_string()));
m.insert("ASTR".to_string(), Value::Str("ASTAR".to_string()));
m.insert("BTM".to_string(), Value::Str("BTM2".to_string()));
m.insert("CRC20".to_string(), Value::Str("CRONOS".to_string()));
m.insert("DOT".to_string(), Value::Str("DOTASSETHUB".to_string()));
m.insert("ETHF".to_string(), Value::Str("ETF".to_string()));
m.insert("HRC20".to_string(), Value::Str("HECO".to_string()));
m.insert("OASIS".to_string(), Value::Str("ROSE".to_string()));
m.insert("OKC".to_string(), Value::Str("OKT".to_string()));
m.insert("RSK".to_string(), Value::Str("RBTC".to_string()));
m
}));
m.insert("networksById".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("BNB Smart Chain(BEP20-RACAV1)".to_string(), Value::Str("BSC".to_string()));
m.insert("BNB Smart Chain(BEP20-RACAV2)".to_string(), Value::Str("BSC".to_string()));
m.insert("BNB Smart Chain(BEP20)".to_string(), Value::Str("BSC".to_string()));
m.insert("Ethereum(ERC20)".to_string(), Value::Str("ERC20".to_string()));
m
}));
m.insert("recvWindow".to_string(), multiply(&Value::Int(5), &Value::Int(1000)));
m.insert("maxTimeTillEnd".to_string(), subtract(&multiply(&multiply(&Value::Int(90), &Value::Int(86400)), &Value::Int(1000)), &Value::Int(1)));
m.insert("broker".to_string(), Value::Str("CCXT".to_string()));
m
}));
m.insert("features".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("default".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("sandbox".to_string(), Value::Bool(false));
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(false));
m.insert("triggerDirection".to_string(), Value::Bool(false));
m.insert("triggerPriceType".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("last".to_string(), Value::Bool(false));
m.insert("mark".to_string(), Value::Bool(false));
m.insert("index".to_string(), Value::Bool(false));
m
}));
m.insert("stopLossPrice".to_string(), Value::Bool(false));
m.insert("takeProfitPrice".to_string(), Value::Bool(false));
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("trailing".to_string(), Value::Bool(false));
m.insert("leverage".to_string(), Value::Bool(true));
m.insert("marketBuyByCost".to_string(), Value::Bool(true));
m.insert("marketBuyRequiresPrice".to_string(), Value::Bool(false));
m.insert("selfTradePrevention".to_string(), Value::Bool(false));
m.insert("iceberg".to_string(), Value::Bool(false));
m
}));
m.insert("createOrders".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("max".to_string(), Value::Int(20));
m
}));
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(100));
m.insert("daysBack".to_string(), Value::Int(30));
m.insert("untilDays".to_string(), Value::Null);
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::Null);
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("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(7));
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(7));
m.insert("daysBackCanceled".to_string(), Value::Int(7));
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(1000));
m
}));
m
}));
m.insert("spot".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("extends".to_string(), Value::Str("default".to_string()));
m.insert("fetchCurrencies".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("private".to_string(), Value::Bool(true));
m
}));
m
}));
m.insert("forDerivs".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("extends".to_string(), Value::Str("default".to_string()));
m.insert("createOrder".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("triggerPrice".to_string(), Value::Bool(true));
m.insert("triggerPriceType".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("last".to_string(), Value::Bool(true));
m.insert("mark".to_string(), Value::Bool(true));
m.insert("index".to_string(), Value::Bool(true));
m
}));
m.insert("triggerDirection".to_string(), Value::Bool(true));
m.insert("stopLossPrice".to_string(), Value::Bool(false));
m.insert("takeProfitPrice".to_string(), Value::Bool(false));
m.insert("hedged".to_string(), Value::Bool(true));
m.insert("leverage".to_string(), Value::Bool(true));
m.insert("marketBuyByCost".to_string(), Value::Bool(false));
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(100));
m.insert("daysBack".to_string(), Value::Int(90));
m.insert("untilDays".to_string(), Value::Int(90));
m
}));
m.insert("fetchOrder".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("marginMode".to_string(), Value::Bool(false));
m
}));
m.insert("fetchOpenOrders".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(100));
m.insert("trigger".to_string(), Value::Bool(true));
m.insert("trailing".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(false));
m.insert("limit".to_string(), Value::Int(100));
m.insert("daysBack".to_string(), Value::Int(90));
m.insert("untilDays".to_string(), Value::Int(90));
m.insert("trigger".to_string(), Value::Bool(true));
m.insert("trailing".to_string(), Value::Bool(false));
m
}));
m.insert("fetchClosedOrders".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(100));
m.insert("daysBack".to_string(), Value::Int(90));
m.insert("daysBackCanceled".to_string(), Value::Null);
m.insert("untilDays".to_string(), Value::Int(90));
m.insert("trigger".to_string(), Value::Bool(true));
m.insert("trailing".to_string(), Value::Bool(false));
m
}));
m.insert("fetchOHLCV".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("limit".to_string(), Value::Int(2000));
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("forDerivs".to_string()));
m
}));
m.insert("inverse".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("extends".to_string(), Value::Str("forDerivs".to_string()));
m
}));
m
}));
m.insert("future".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("linear".to_string(), Value::Null);
m.insert("inverse".to_string(), Value::Null);
m
}));
m
}));
m.insert("commonCurrencies".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("BEYONDPROTOCOL".to_string(), Value::Str("BEYOND".to_string()));
m.insert("BIFI".to_string(), Value::Str("BIFIF".to_string()));
m.insert("BYN".to_string(), Value::Str("BEYONDFI".to_string()));
m.insert("COFI".to_string(), Value::Str("COFIX".to_string()));
m.insert("DFI".to_string(), Value::Str("DFISTARTER".to_string()));
m.insert("DFT".to_string(), Value::Str("DFUTURE".to_string()));
m.insert("DRK".to_string(), Value::Str("DRK".to_string()));
m.insert("EGC".to_string(), Value::Str("EGORASCREDIT".to_string()));
m.insert("FLUX1".to_string(), Value::Str("FLUX".to_string()));
m.insert("FLUX".to_string(), Value::Str("FLUX1".to_string()));
m.insert("FREE".to_string(), Value::Str("FREEROSSDAO".to_string()));
m.insert("GAS".to_string(), Value::Str("GASDAO".to_string()));
m.insert("GASNEO".to_string(), Value::Str("GAS".to_string()));
m.insert("GMT".to_string(), Value::Str("GMTTOKEN".to_string()));
m.insert("STEPN".to_string(), Value::Str("GMT".to_string()));
m.insert("HERO".to_string(), Value::Str("STEPHERO".to_string()));
m.insert("MIMO".to_string(), Value::Str("MIMOSA".to_string()));
m.insert("PROS".to_string(), Value::Str("PROSFINANCE".to_string()));
m.insert("SIN".to_string(), Value::Str("SINCITYTOKEN".to_string()));
m.insert("SOUL".to_string(), Value::Str("SOULSWAP".to_string()));
m.insert("XBT".to_string(), Value::Str("XBT".to_string()));
m
}));
m.insert("exceptions".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("-1128".to_string(), Value::Str("BadRequest".to_string()).clone());
m.insert("-2011".to_string(), Value::Str("BadRequest".to_string()).clone());
m.insert("-1121".to_string(), Value::Str("BadSymbol".to_string()).clone());
m.insert("401".to_string(), Value::Str("AuthenticationError".to_string()).clone());
m.insert("402".to_string(), Value::Str("AuthenticationError".to_string()).clone());
m.insert("403".to_string(), Value::Str("PermissionDenied".to_string()).clone());
m.insert("406".to_string(), Value::Str("PermissionDenied".to_string()).clone());
m.insert("429".to_string(), Value::Str("RateLimitExceeded".to_string()).clone());
m.insert("500".to_string(), Value::Str("ExchangeError".to_string()).clone());
m.insert("501".to_string(), Value::Str("ExchangeNotAvailable".to_string()).clone());
m.insert("503".to_string(), Value::Str("ExchangeNotAvailable".to_string()).clone());
m.insert("504".to_string(), Value::Str("RequestTimeout".to_string()).clone());
m.insert("510".to_string(), Value::Str("RateLimitExceeded".to_string()).clone());
m.insert("511".to_string(), Value::Str("PermissionDenied".to_string()).clone());
m.insert("513".to_string(), Value::Str("BadRequest".to_string()).clone());
m.insert("601".to_string(), Value::Str("BadRequest".to_string()).clone());
m.insert("603".to_string(), Value::Str("BadRequest".to_string()).clone());
m.insert("604".to_string(), Value::Str("OnMaintenance".to_string()).clone());
m.insert("701".to_string(), Value::Str("PermissionDenied".to_string()).clone());
m.insert("702".to_string(), Value::Str("PermissionDenied".to_string()).clone());
m.insert("703".to_string(), Value::Str("PermissionDenied".to_string()).clone());
m.insert("704".to_string(), Value::Str("PermissionDenied".to_string()).clone());
m.insert("801".to_string(), Value::Str("OnMaintenance".to_string()).clone());
m.insert("1000".to_string(), Value::Str("AuthenticationError".to_string()).clone());
m.insert("1001".to_string(), Value::Str("BadSymbol".to_string()).clone());
m.insert("10101".to_string(), Value::Str("InsufficientFunds".to_string()).clone());
m.insert("2009".to_string(), Value::Str("InvalidOrder".to_string()).clone());
m.insert("2011".to_string(), Value::Str("BadRequest".to_string()).clone());
m.insert("30004".to_string(), Value::Str("InsufficientFunds".to_string()).clone());
m.insert("33333".to_string(), Value::Str("BadRequest".to_string()).clone());
m.insert("44444".to_string(), Value::Str("BadRequest".to_string()).clone());
m.insert("1002".to_string(), Value::Str("InvalidOrder".to_string()).clone());
m.insert("30019".to_string(), Value::Str("BadRequest".to_string()).clone());
m.insert("30005".to_string(), Value::Str("InvalidOrder".to_string()).clone());
m.insert("2003".to_string(), Value::Str("InvalidOrder".to_string()).clone());
m.insert("2005".to_string(), Value::Str("InsufficientFunds".to_string()).clone());
m.insert("400".to_string(), Value::Str("BadRequest".to_string()).clone());
m.insert("600".to_string(), Value::Str("BadRequest".to_string()).clone());
m.insert("70011".to_string(), Value::Str("PermissionDenied".to_string()).clone());
m.insert("88004".to_string(), Value::Str("InsufficientFunds".to_string()).clone());
m.insert("88009".to_string(), Value::Str("ExchangeError".to_string()).clone());
m.insert("88013".to_string(), Value::Str("InvalidOrder".to_string()).clone());
m.insert("88015".to_string(), Value::Str("InsufficientFunds".to_string()).clone());
m.insert("700003".to_string(), Value::Str("InvalidNonce".to_string()).clone());
m.insert("26".to_string(), Value::Str("ExchangeError".to_string()).clone());
m.insert("602".to_string(), Value::Str("AuthenticationError".to_string()).clone());
m.insert("10001".to_string(), Value::Str("AuthenticationError".to_string()).clone());
m.insert("10007".to_string(), Value::Str("BadSymbol".to_string()).clone());
m.insert("10015".to_string(), Value::Str("BadRequest".to_string()).clone());
m.insert("10072".to_string(), Value::Str("BadRequest".to_string()).clone());
m.insert("10073".to_string(), Value::Str("BadRequest".to_string()).clone());
m.insert("10095".to_string(), Value::Str("InvalidOrder".to_string()).clone());
m.insert("10096".to_string(), Value::Str("InvalidOrder".to_string()).clone());
m.insert("10097".to_string(), Value::Str("InvalidOrder".to_string()).clone());
m.insert("10098".to_string(), Value::Str("InvalidOrder".to_string()).clone());
m.insert("10099".to_string(), Value::Str("BadRequest".to_string()).clone());
m.insert("10100".to_string(), Value::Str("BadRequest".to_string()).clone());
m.insert("10102".to_string(), Value::Str("InvalidOrder".to_string()).clone());
m.insert("10103".to_string(), Value::Str("ExchangeError".to_string()).clone());
m.insert("10200".to_string(), Value::Str("BadRequest".to_string()).clone());
m.insert("10201".to_string(), Value::Str("BadRequest".to_string()).clone());
m.insert("10202".to_string(), Value::Str("BadRequest".to_string()).clone());
m.insert("10206".to_string(), Value::Str("BadRequest".to_string()).clone());
m.insert("10211".to_string(), Value::Str("BadRequest".to_string()).clone());
m.insert("10212".to_string(), Value::Str("BadRequest".to_string()).clone());
m.insert("10216".to_string(), Value::Str("ExchangeError".to_string()).clone());
m.insert("10219".to_string(), Value::Str("ExchangeError".to_string()).clone());
m.insert("10222".to_string(), Value::Str("BadRequest".to_string()).clone());
m.insert("10232".to_string(), Value::Str("BadRequest".to_string()).clone());
m.insert("10259".to_string(), Value::Str("ExchangeError".to_string()).clone());
m.insert("10265".to_string(), Value::Str("ExchangeError".to_string()).clone());
m.insert("10268".to_string(), Value::Str("BadRequest".to_string()).clone());
m.insert("11444".to_string(), Value::Str("OnMaintenance".to_string()).clone());
m.insert("20001".to_string(), Value::Str("ExchangeError".to_string()).clone());
m.insert("20002".to_string(), Value::Str("ExchangeError".to_string()).clone());
m.insert("22222".to_string(), Value::Str("BadRequest".to_string()).clone());
m.insert("30000".to_string(), Value::Str("ExchangeError".to_string()).clone());
m.insert("30001".to_string(), Value::Str("InvalidOrder".to_string()).clone());
m.insert("30002".to_string(), Value::Str("InvalidOrder".to_string()).clone());
m.insert("30003".to_string(), Value::Str("InvalidOrder".to_string()).clone());
m.insert("30010".to_string(), Value::Str("InvalidOrder".to_string()).clone());
m.insert("30014".to_string(), Value::Str("InvalidOrder".to_string()).clone());
m.insert("30016".to_string(), Value::Str("InvalidOrder".to_string()).clone());
m.insert("30018".to_string(), Value::Str("AccountSuspended".to_string()).clone());
m.insert("30020".to_string(), Value::Str("AuthenticationError".to_string()).clone());
m.insert("30021".to_string(), Value::Str("BadRequest".to_string()).clone());
m.insert("30025".to_string(), Value::Str("InvalidOrder".to_string()).clone());
m.insert("30026".to_string(), Value::Str("BadRequest".to_string()).clone());
m.insert("30027".to_string(), Value::Str("InvalidOrder".to_string()).clone());
m.insert("30028".to_string(), Value::Str("InvalidOrder".to_string()).clone());
m.insert("30029".to_string(), Value::Str("InvalidOrder".to_string()).clone());
m.insert("30032".to_string(), Value::Str("InvalidOrder".to_string()).clone());
m.insert("30041".to_string(), Value::Str("InvalidOrder".to_string()).clone());
m.insert("30087".to_string(), Value::Str("InvalidOrder".to_string()).clone());
m.insert("60005".to_string(), Value::Str("ExchangeError".to_string()).clone());
m.insert("700001".to_string(), Value::Str("AuthenticationError".to_string()).clone());
m.insert("700002".to_string(), Value::Str("AuthenticationError".to_string()).clone());
m.insert("700004".to_string(), Value::Str("BadRequest".to_string()).clone());
m.insert("700005".to_string(), Value::Str("InvalidNonce".to_string()).clone());
m.insert("700006".to_string(), Value::Str("BadRequest".to_string()).clone());
m.insert("700007".to_string(), Value::Str("AuthenticationError".to_string()).clone());
m.insert("700008".to_string(), Value::Str("BadRequest".to_string()).clone());
m.insert("700013".to_string(), Value::Str("AuthenticationError".to_string()).clone());
m.insert("730001".to_string(), Value::Str("BadRequest".to_string()).clone());
m.insert("730002".to_string(), Value::Str("BadRequest".to_string()).clone());
m.insert("730000".to_string(), Value::Str("ExchangeError".to_string()).clone());
m.insert("730003".to_string(), Value::Str("ExchangeError".to_string()).clone());
m.insert("730100".to_string(), Value::Str("ExchangeError".to_string()).clone());
m.insert("730600".to_string(), Value::Str("BadRequest".to_string()).clone());
m.insert("730601".to_string(), Value::Str("BadRequest".to_string()).clone());
m.insert("730602".to_string(), Value::Str("BadRequest".to_string()).clone());
m.insert("730700".to_string(), Value::Str("BadRequest".to_string()).clone());
m.insert("730701".to_string(), Value::Str("BadRequest".to_string()).clone());
m.insert("730702".to_string(), Value::Str("BadRequest".to_string()).clone());
m.insert("730703".to_string(), Value::Str("BadRequest".to_string()).clone());
m.insert("730704".to_string(), Value::Str("BadRequest".to_string()).clone());
m.insert("730705".to_string(), Value::Str("BadRequest".to_string()).clone());
m.insert("730706".to_string(), Value::Str("BadRequest".to_string()).clone());
m.insert("730707".to_string(), Value::Str("BadRequest".to_string()).clone());
m.insert("730101".to_string(), Value::Str("BadRequest".to_string()).clone());
m.insert("140001".to_string(), Value::Str("BadRequest".to_string()).clone());
m.insert("140002".to_string(), Value::Str("AuthenticationError".to_string()).clone());
m
}));
m.insert("broad".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("Order quantity error, please try to modify.".to_string(), Value::Str("BadRequest".to_string()));
m.insert("Combination of optional parameters invalid".to_string(), Value::Str("BadRequest".to_string()).clone());
m.insert("api market order is disabled".to_string(), Value::Str("BadRequest".to_string()).clone());
m.insert("Contract not allow place order!".to_string(), Value::Str("InvalidOrder".to_string()).clone());
m.insert("Oversold".to_string(), Value::Str("InsufficientFunds".to_string()).clone());
m.insert("Insufficient position".to_string(), Value::Str("InsufficientFunds".to_string()).clone());
m.insert("Insufficient balance!".to_string(), Value::Str("InsufficientFunds".to_string()).clone());
m.insert("Bid price is great than max allow price".to_string(), Value::Str("InvalidOrder".to_string()).clone());
m.insert("Invalid symbol.".to_string(), Value::Str("BadSymbol".to_string()).clone());
m.insert("Param error!".to_string(), Value::Str("BadRequest".to_string()).clone());
m.insert("maintenance".to_string(), Value::Str("OnMaintenance".to_string()).clone());
m
}));
m
}));
m
})]);
Value::Null
}
/*
* @method
* @name mexc#fetchStatus
* @description the latest known information on the availability of the exchange API
* @see https://www.mexc.com/api-docs/spot-v3/market-data-endpoints/test-connectivity // spot
* @see https://www.mexc.com/api-docs/futures/market-endpoints/get-server-time // swap
* @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 marketTypequeryVariable = self.handle_market_type_and_params(Value::Str("fetchStatus".to_string()), &[Value::Null, params.clone()]);
let mut marketType: Value = get_value(&marketTypequeryVariable, &Value::Int(0));
let mut query: Value = get_value(&marketTypequeryVariable, &Value::Int(1));
let mut response: Value = Value::Map({
let mut m = indexmap::IndexMap::new();
m
});
let mut status: Value = Value::Null;
let mut updated: Value = Value::Null;
if is_equal(&marketType, &Value::Str("spot".to_string())) {
response = self.spot_public_get_ping(&[query.clone()]).await;
//
// {}
//
let mut keys: Value = object_keys(&response);
let mut length: Value = get_array_length(&keys);
status = ternary(is_true(&(is_greater_than(&length, &Value::Int(0)))), self.json(response.clone()), Value::Str("ok".to_string()));
} else if is_equal(&marketType, &Value::Str("swap".to_string())) {
response = self.contract_public_get_ping(&[query.clone()]).await;
//
// {"success":true,"code":"0","data":"1648124374985"}
//
let mut success: bool = is_equal(&self.safe_bool_k(response.clone(), "success", &[]), &Value::Bool(true));
status = ternary(is_true(&success), Value::Str("ok".to_string()), self.json(response.clone()));
updated = self.safe_integer_k(response.clone(), "data", &[]);
}
return Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("status".to_string(), status.clone());
m.insert("updated".to_string(), updated.clone());
m.insert("url".to_string(), Value::Null);
m.insert("eta".to_string(), Value::Null);
m.insert("info".to_string(), response.clone());
m
});
Value::Null
}
/*
* @method
* @name mexc#fetchTime
* @description fetches the current integer timestamp in milliseconds from the exchange server
* @see https://www.mexc.com/api-docs/spot-v3/market-data-endpoints/check-server-time // spot
* @see https://www.mexc.com/api-docs/futures/market-endpoints/get-server-time // swap
* @param {object} [params] extra parameters specific to the exchange API endpoint
* @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 marketTypequeryVariable = self.handle_market_type_and_params(Value::Str("fetchTime".to_string()), &[Value::Null, params.clone()]);
let mut marketType: Value = get_value(&marketTypequeryVariable, &Value::Int(0));
let mut query: Value = get_value(&marketTypequeryVariable, &Value::Int(1));
let mut response: Value = Value::Null;
if is_equal(&marketType, &Value::Str("spot".to_string())) {
response = self.spot_public_get_time(&[query.clone()]).await;
return self.safe_integer_k(response.clone(), "serverTime", &[]);
} else if is_equal(&marketType, &Value::Str("swap".to_string())) {
response = self.contract_public_get_ping(&[query.clone()]).await;
return self.safe_integer_k(response.clone(), "data", &[]);
}
return Value::Null;
Value::Null
}
/*
* @method
* @name mexc#fetchCurrencies
* @description fetches all available currencies on an exchange
* @see https://www.mexc.com/api-docs/spot-v3/wallet-endpoints/query-the-currency-information
* @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
}));
// 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
});
}
let mut response: Value = self.spot_private_get_capital_config_getall(&[params.clone()]).await;
return self.parse_currencies(response.clone());
Value::Null
}
pub fn parse_currency(&self, mut rawCurrency: Value) -> Value {
let mut id: Value = self.safe_string_k(rawCurrency.clone(), "coin", &[]);
let mut code: Value = self.safe_currency_code(id.clone(), &[]);
let mut networks: Value = Value::Map({
let mut m = indexmap::IndexMap::new();
m
});
let mut chains: Value = self.safe_value_k(rawCurrency.clone(), "networkList", &[Value::List(vec![])]);
{
let mut j: Value = Value::Int(0);
let mut __for_first_934: bool = true;
while { if !__for_first_934 { j = add(&j, &Value::Int(1)); } __for_first_934 = false; is_less_than(&j, &get_array_length(&chains)) } {
let mut chain: Value = get_value(&chains, &j);
let mut chain: Value = get_value(&chains, &j);
let mut networkId: Value = self.safe_string2(chain.clone(), Value::Str("netWork".to_string()), Value::Str("network".to_string()), &[]);
let mut network: Value = self.network_id_to_code(&[networkId.clone(), code.clone()]);
if !is_equal(&network, &Value::Null) {
add_element_to_object(&mut networks, &network, Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("info".to_string(), chain.clone());
m.insert("id".to_string(), networkId.clone());
m.insert("network".to_string(), network.clone());
m.insert("active".to_string(), Value::Null);
m.insert("deposit".to_string(), self.safe_bool_k(chain.clone(), "depositEnable", &[Value::Bool(false)]));
m.insert("withdraw".to_string(), self.safe_bool_k(chain.clone(), "withdrawEnable", &[Value::Bool(false)]));
m.insert("fee".to_string(), self.safe_number_k(chain.clone(), "withdrawFee", &[]));
m.insert("precision".to_string(), Value::Null);
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_string_k(chain.clone(), "withdrawMin", &[]));
m.insert("max".to_string(), self.safe_string_k(chain.clone(), "withdrawMax", &[]));
m
}));
m
}));
m.insert("contract".to_string(), self.safe_string_k(chain.clone(), "contract", &[]));
m
}));
}
}
}
return self.safe_currency_structure(Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("info".to_string(), rawCurrency.clone());
m.insert("id".to_string(), id.clone());
m.insert("code".to_string(), code.clone());
m.insert("name".to_string(), self.safe_string_k(rawCurrency.clone(), "name", &[]));
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(), Value::Null);
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
}));
m.insert("type".to_string(), Value::Str("crypto".to_string()));
m.insert("networks".to_string(), networks.clone());
m
}));
Value::Null
}
/*
* @method
* @name mexc#fetchMarkets
* @description retrieves data on all markets for mexc
* @see https://www.mexc.com/api-docs/spot-v3/market-data-endpoints/exchange-information // spot
* @see https://www.mexc.com/api-docs/futures/market-endpoints/get-contract-info // swap
* @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
}));
if is_equal(&get_value(&self.options, &Value::Str("adjustForTimeDifference".to_string())), &Value::Bool(true)) {
self.load_time_difference(&[]).await;
}
let mut spotMarketPromise: Value = self.fetch_spot_markets(&[params.clone()]).await;
let mut swapMarketPromise: Value = self.fetch_swap_markets(&[params.clone()]).await;
let mut spotMarketswapMarketVariable = promise_all(&Value::List(vec![spotMarketPromise.clone(), swapMarketPromise.clone()])).await;
let mut spotMarket: Value = get_value(&spotMarketswapMarketVariable, &Value::Int(0));
let mut swapMarket: Value = get_value(&spotMarketswapMarketVariable, &Value::Int(1));
return self.array_concat(spotMarket.clone(), swapMarket.clone());
Value::Null
}
/*
* @ignore
* @method
* @name mexc#fetchMarkets
* @description retrieves data on all spot markets for mexc
* @see https://www.mexc.com/api-docs/spot-v3/market-data-endpoints/exchange-information
* @param {object} [params] extra parameters specific to the exchange API endpoint
* @returns {object[]} an array of objects representing market data
*/
pub async fn fetch_spot_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 response: Value = self.spot_public_get_exchange_info(&[params.clone()]).await;
//
// {
// "timezone": "CST",
// "serverTime": 1647521860402,
// "rateLimits": [],
// "exchangeFilters": [],
// "symbols": [
// {
// "symbol": "OGNUSDT",
// "status": "1",
// "baseAsset": "OGN",
// "baseAssetPrecision": "2",
// "quoteAsset": "USDT",
// "quoteAssetPrecision": "4",
// "orderTypes": [
// "LIMIT",
// "LIMIT_MAKER"
// ],
// "baseCommissionPrecision": "2",
// "quoteCommissionPrecision": "4",
// "quoteOrderQtyMarketAllowed": false,
// "isSpotTradingAllowed": true,
// "isMarginTradingAllowed": true,
// "permissions": [
// "SPOT",
// "MARGIN"
// ],
// "filters": [],
// "baseSizePrecision": "0.01", // this turned out to be a minimum base amount for order
// "maxQuoteAmount": "5000000",
// "makerCommission": "0.002",
// "takerCommission": "0.002"
// "quoteAmountPrecision": "5", // this turned out to be a minimum cost amount for order
// "quotePrecision": "4", // deprecated in favor of 'quoteAssetPrecision' ( https://dev.binance.vision/t/what-is-the-difference-between-quoteprecision-and-quoteassetprecision/4333 )
// // note, "icebergAllowed" & "ocoAllowed" fields were recently removed
// },
// ]
// }
//
// Notes:
// - 'quoteAssetPrecision' & 'baseAssetPrecision' are not currency's real blockchain precision (to view currency's actual individual precision, refer to fetchCurrencies() method).
//
let mut data: Value = self.safe_value_k(response.clone(), "symbols", &[Value::List(vec![])]);
let mut result: Value = Value::List(vec![]);
{
let mut i: Value = Value::Int(0);
let mut __for_first_935: bool = true;
while { if !__for_first_935 { i = add(&i, &Value::Int(1)); } __for_first_935 = false; is_less_than(&i, &get_array_length(&data)) } {
let mut market: Value = get_value(&data, &i);
let mut market: Value = get_value(&data, &i);
let mut id: Value = self.safe_string_k(market.clone(), "symbol", &[]);
let mut baseId: Value = self.safe_string_k(market.clone(), "baseAsset", &[]);
let mut quoteId: Value = self.safe_string_k(market.clone(), "quoteAsset", &[]);
let mut base: Value = self.safe_currency_code(baseId.clone(), &[]);
let mut quote: Value = self.safe_currency_code(quoteId.clone(), &[]);
let mut status: Value = self.safe_string_k(market.clone(), "status", &[]);
let mut isSpotTradingAllowed: Value = self.safe_value_k(market.clone(), "isSpotTradingAllowed", &[]);
let mut active: Value = Value::Bool(false);
if is_true(&(is_equal(&status, &Value::Str("1".to_string())))) && is_true(&(is_equal(&isSpotTradingAllowed, &Value::Bool(true)))) {
active = Value::Bool(true);
}
let mut isMarginTradingAllowed: Value = self.safe_value_k(market.clone(), "isMarginTradingAllowed", &[]);
let mut makerCommission: Value = self.safe_number_k(market.clone(), "makerCommission", &[]);
let mut takerCommission: Value = self.safe_number_k(market.clone(), "takerCommission", &[]);
let mut maxQuoteAmount: Value = self.safe_number_k(market.clone(), "maxQuoteAmount", &[]);
append_to_array(&mut result, Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("id".to_string(), id.clone());
m.insert("symbol".to_string(), add(&add(&base, &Value::Str("/".to_string())), "e));
m.insert("base".to_string(), base.clone());
m.insert("quote".to_string(), quote.clone());
m.insert("settle".to_string(), Value::Null);
m.insert("baseId".to_string(), baseId.clone());
m.insert("quoteId".to_string(), quoteId.clone());
m.insert("settleId".to_string(), Value::Null);
m.insert("type".to_string(), Value::Str("spot".to_string()));
m.insert("spot".to_string(), Value::Bool(true));
m.insert("margin".to_string(), isMarginTradingAllowed.clone());
m.insert("swap".to_string(), Value::Bool(false));
m.insert("future".to_string(), Value::Bool(false));
m.insert("option".to_string(), Value::Bool(false));
m.insert("active".to_string(), active.clone());
m.insert("contract".to_string(), Value::Bool(false));
m.insert("linear".to_string(), Value::Null);
m.insert("inverse".to_string(), Value::Null);
m.insert("taker".to_string(), takerCommission.clone());
m.insert("maker".to_string(), makerCommission.clone());
m.insert("contractSize".to_string(), Value::Null);
m.insert("expiry".to_string(), Value::Null);
m.insert("expiryDatetime".to_string(), Value::Null);
m.insert("strike".to_string(), Value::Null);
m.insert("optionType".to_string(), Value::Null);
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_string_k(market.clone(), "baseAssetPrecision", &[])]), &[]));
m.insert("price".to_string(), self.parse_number(self.parse_precision(&[self.safe_string_k(market.clone(), "quoteAssetPrecision", &[])]), &[]));
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(), "baseSizePrecision", &[]));
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(), self.safe_number_k(market.clone(), "quoteAmountPrecision", &[]));
m.insert("max".to_string(), maxQuoteAmount.clone());
m
}));
m
}));
m.insert("created".to_string(), Value::Null);
m.insert("info".to_string(), market.clone());
m
}));
}
}
return result;
Value::Null
}
/*
* @ignore
* @method
* @name mexc#fetchMarkets
* @description retrieves data on all swap markets for mexc
* @see https://www.mexc.com/api-docs/futures/market-endpoints/get-contract-info
* @param {object} [params] extra parameters specific to the exchange API endpoint
* @returns {object[]} an array of objects representing market data
*/
pub async fn fetch_swap_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 currentRl: Value = self.rateLimit.clone();
self.set_property(Value::Str("rateLimit".to_string()), &[Value::Int(10)]); // see comment: https://github.com/ccxt/ccxt/pull/23698
let mut response: Value = self.contract_public_get_detail(&[params.clone()]).await;
self.set_property(Value::Str("rateLimit".to_string()), &[currentRl.clone()]);
//
// {
// "success":true,
// "code":0,
// "data":[
// {
// "symbol":"BTC_USDT",
// "displayName":"BTC_USDT永续",
// "displayNameEn":"BTC_USDT SWAP",
// "positionOpenType":3,
// "baseCoin":"BTC",
// "quoteCoin":"USDT",
// "settleCoin":"USDT",
// "contractSize":0.0001,
// "minLeverage":1,
// "maxLeverage":125,
// "priceScale":2, // seems useless atm, as it's just how UI shows the price, i.e. 29583.50 for BTC/USDT:USDT, while price ticksize is 0.5
// "volScale":0, // probably: contract amount precision
// "amountScale":4, // probably: quote currency precision
// "priceUnit":0.5, // price tick size
// "volUnit":1, // probably: contract tick size
// "minVol":1,
// "maxVol":1000000,
// "bidLimitPriceRate":0.1,
// "askLimitPriceRate":0.1,
// "takerFeeRate":0.0006,
// "makerFeeRate":0.0002,
// "maintenanceMarginRate":0.004,
// "initialMarginRate":0.008,
// "riskBaseVol":10000,
// "riskIncrVol":200000,
// "riskIncrMmr":0.004,
// "riskIncrImr":0.004,
// "riskLevelLimit":5,
// "priceCoefficientVariation":0.1,
// "indexOrigin":["BINANCE","GATEIO","HUOBI","MXC"],
// "state":0, // 0 enabled, 1 delivery, 2 completed, 3 offline, 4 pause
// "isNew":false,
// "isHot":true,
// "isHidden":false
// },
// ]
// }
//
let mut data: Value = self.safe_value_k(response.clone(), "data", &[Value::List(vec![])]);
let mut result: Value = Value::List(vec![]);
{
let mut i: Value = Value::Int(0);
let mut __for_first_936: bool = true;
while { if !__for_first_936 { i = add(&i, &Value::Int(1)); } __for_first_936 = false; is_less_than(&i, &get_array_length(&data)) } {
let mut market: Value = get_value(&data, &i);
let mut market: Value = get_value(&data, &i);
let mut id: Value = self.safe_string_k(market.clone(), "symbol", &[]);
let mut baseId: Value = self.safe_string_k(market.clone(), "baseCoin", &[]);
let mut quoteId: Value = self.safe_string_k(market.clone(), "quoteCoin", &[]);
let mut settleId: Value = self.safe_string_k(market.clone(), "settleCoin", &[]);
let mut base: Value = self.safe_currency_code(baseId.clone(), &[]);
let mut quote: Value = self.safe_currency_code(quoteId.clone(), &[]);
let mut settle: Value = self.safe_currency_code(settleId.clone(), &[]);
let mut state: Value = self.safe_string_k(market.clone(), "state", &[]);
let mut isLinear: Value = Value::Bool(is_equal("e, &settle));
append_to_array(&mut result, Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("id".to_string(), id.clone());
m.insert("symbol".to_string(), add(&add(&add(&add(&base, &Value::Str("/".to_string())), "e), &Value::Str(":".to_string())), &settle));
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(), Value::Str("swap".to_string()));
m.insert("spot".to_string(), Value::Bool(false));
m.insert("margin".to_string(), Value::Bool(false));
m.insert("swap".to_string(), Value::Bool(true));
m.insert("future".to_string(), Value::Bool(false));
m.insert("option".to_string(), Value::Bool(false));
m.insert("active".to_string(), Value::Bool((is_equal(&state, &Value::Str("0".to_string())))));
m.insert("contract".to_string(), Value::Bool(true));
m.insert("linear".to_string(), isLinear.clone());
m.insert("inverse".to_string(), Value::Bool(!is_true(&isLinear)));
m.insert("taker".to_string(), self.safe_number_k(market.clone(), "takerFeeRate", &[]));
m.insert("maker".to_string(), self.safe_number_k(market.clone(), "makerFeeRate", &[]));
m.insert("contractSize".to_string(), self.safe_number_k(market.clone(), "contractSize", &[]));
m.insert("expiry".to_string(), Value::Null);
m.insert("expiryDatetime".to_string(), Value::Null);
m.insert("strike".to_string(), Value::Null);
m.insert("optionType".to_string(), Value::Null);
m.insert("precision".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("amount".to_string(), self.safe_number_k(market.clone(), "volUnit", &[]));
m.insert("price".to_string(), self.safe_number_k(market.clone(), "priceUnit", &[]));
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(), self.safe_number_k(market.clone(), "minLeverage", &[]));
m.insert("max".to_string(), self.safe_number_k(market.clone(), "maxLeverage", &[]));
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(), "minVol", &[]));
m.insert("max".to_string(), self.safe_number_k(market.clone(), "maxVol", &[]));
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("created".to_string(), Value::Null);
m.insert("info".to_string(), market.clone());
m
}));
}
}
return result;
Value::Null
}
/*
* @method
* @name mexc#fetchOrderBook
* @see https://www.mexc.com/api-docs/spot-v3/market-data-endpoints/order-book // spot
* @see https://www.mexc.com/api-docs/futures/market-endpoints/get-contract-order-book-depth // swap
* @description fetches information on open orders with bid (buy) and ask (sell) prices, volumes and other data
* @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
* @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());
}
let mut orderbook: Value = Value::Null;
if is_equal(&get_value(&market, &Value::Str("spot".to_string())), &Value::Bool(true)) {
let __ws_arg_0 = self.extend(request.clone(), &[params.clone()]);
let mut response: Value = self.spot_public_get_depth(&[__ws_arg_0]).await;
//
// {
// "lastUpdateId": "744267132",
// "bids": [
// ["40838.50","0.387864"],
// ["40837.95","0.008400"],
// ],
// "asks": [
// ["40838.61","6.544908"],
// ["40838.88","0.498000"],
// ]
// }
//
let mut spotTimestamp: Value = self.safe_integer_k(response.clone(), "timestamp", &[]);
orderbook = self.parse_order_book(response.clone(), symbol.clone(), &[spotTimestamp.clone()]);
add_element_to_object(&mut orderbook, &Value::Str("nonce".to_string()), self.safe_integer_k(response.clone(), "lastUpdateId", &[]));
} else if is_equal(&get_value(&market, &Value::Str("swap".to_string())), &Value::Bool(true)) {
let __ws_arg_1 = self.extend(request.clone(), &[params.clone()]);
let mut response: Value = self.contract_public_get_depth_symbol(&[__ws_arg_1]).await;
//
// {
// "success":true,
// "code":0,
// "data":{
// "asks":[
// [3445.72,48379,1],
// [3445.75,34994,1],
// ],
// "bids":[
// [3445.55,44081,1],
// [3445.51,24857,1],
// ],
// "version":2827730444,
// "timestamp":1634117846232
// }
// }
//
let mut data: Value = self.safe_value_k(response.clone(), "data", &[]);
let mut timestamp: Value = self.safe_integer_k(data.clone(), "timestamp", &[]);
orderbook = self.parse_order_book(data.clone(), symbol.clone(), &[timestamp.clone()]);
add_element_to_object(&mut orderbook, &Value::Str("nonce".to_string()), self.safe_integer_k(data.clone(), "version", &[]));
}
return orderbook;
Value::Null
}
pub fn parse_order_book_bid_ask(&self, mut bidask: Value, optional_args: &[Value]) -> Value {
let mut priceKey = get_arg(optional_args, 0, Value::Int(0));
let mut amountKey = get_arg(optional_args, 1, Value::Int(1));
let mut countOrIdKey = get_arg(optional_args, 2, Value::Int(2));
let mut countKey: Value = Value::Int(2);
let mut price: Value = self.safe_number(bidask.clone(), priceKey.clone(), &[]);
let mut amount: Value = self.safe_number(bidask.clone(), amountKey.clone(), &[]);
let mut count: Value = self.safe_number(bidask.clone(), countKey.clone(), &[]);
if !is_equal(&count, &Value::Null) {
return Value::List(vec![price.clone(), amount.clone(), count.clone()]);
}
return Value::List(vec![price.clone(), amount.clone()]);
Value::Null
}
/*
* @method
* @name mexc#fetchTrades
* @see https://www.mexc.com/api-docs/spot-v3/market-data-endpoints/recent-trades-list // spot
* @see https://www.mexc.com/api-docs/spot-v3/market-data-endpoints/compressedaggregate-trades-list // spot aggregated
* @see https://www.mexc.com/api-docs/futures/market-endpoints/get-recent-trades // swap
* @description get the list of most recent trades for a particular symbol
* @param {string} symbol unified symbol of the market to fetch trades for
* @param {int} [since] timestamp in ms of the earliest trade to fetch
* @param {int} [limit] the maximum amount of trades to fetch
* @param {object} [params] extra parameters specific to the exchange API endpoint
* @param {int} [params.until] *spot only* *since must be defined* the latest time in ms to fetch entries for
* @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 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());
}
let mut trades: Value = Value::List(vec![]);
if is_equal(&get_value(&market, &Value::Str("spot".to_string())), &Value::Bool(true)) {
let mut until: Value = self.safe_integer2(params.clone(), Value::Str("endTime".to_string()), Value::Str("until".to_string()), &[]);
if !is_equal(&since, &Value::Null) {
add_element_to_object(&mut request, &Value::Str("startTime".to_string()), since.clone());
if is_equal(&until, &Value::Null) {
panic!("{}", crate::exchange_errors::arguments_required(add(&self.id, &Value::Str(" fetchTrades() requires an until parameter when since is provided".to_string()))));
}
}
if !is_equal(&until, &Value::Null) {
if is_equal(&since, &Value::Null) {
panic!("{}", crate::exchange_errors::arguments_required(add(&self.id, &Value::Str(" fetchTrades() requires a since parameter when until is provided".to_string()))));
}
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", &[Value::Str("spotPublicGetAggTrades".to_string())]);
method = self.safe_string_k(params.clone(), "method", &[method.clone()]); // AggTrades, HistoricalTrades, Trades
params = self.omit(params.clone(), Value::List(vec![Value::Str("method".to_string())]), &[]);
if is_equal(&method, &Value::Str("spotPublicGetAggTrades".to_string())) {
let __ws_arg_2 = self.extend(request.clone(), &[params.clone()]);
trades = self.spot_public_get_agg_trades(&[__ws_arg_2]).await;
} else if is_equal(&method, &Value::Str("spotPublicGetHistoricalTrades".to_string())) {
let __ws_arg_3 = self.extend(request.clone(), &[params.clone()]);
trades = self.spot_public_get_historical_trades(&[__ws_arg_3]).await;
} else if is_equal(&method, &Value::Str("spotPublicGetTrades".to_string())) {
let __ws_arg_4 = self.extend(request.clone(), &[params.clone()]);
trades = self.spot_public_get_trades(&[__ws_arg_4]).await;
} else {
panic!("{}", crate::exchange_errors::not_supported(add(&self.id, &Value::Str(" fetchTrades() not support this method".to_string()))));
}
} else if is_equal(&get_value(&market, &Value::Str("swap".to_string())), &Value::Bool(true)) {
let __ws_arg_5 = self.extend(request.clone(), &[params.clone()]);
let mut response: Value = self.contract_public_get_deals_symbol(&[__ws_arg_5]).await;
//
// {
// "success": true,
// "code": 0,
// "data": [
// {
// "p": 31199,
// "v": 18,
// "T": 1,
// "O": 3,
// "M": 2,
// "t": 1609831235985
// },
// ]
// }
//
trades = self.safe_list_k(response.clone(), "data", &[Value::List(vec![])]);
}
return self.parse_trades(trades.clone(), &[market.clone(), since.clone(), limit.clone()]);
Value::Null
}
pub fn parse_trade(&self, mut trade: Value, optional_args: &[Value]) -> Value {
let mut market = get_arg(optional_args, 0, Value::Null);
let mut id: Value = Value::Null;
let mut timestamp: Value = Value::Null;
let mut orderId: Value = Value::Null;
let mut symbol: Value = Value::Null;
let mut fee: Value = Value::Null;
let mut type_var: Value = Value::Null;
let mut side: Value = Value::Null;
let mut takerOrMaker: Value = Value::Null;
let mut priceString: Value = Value::Null;
let mut amountString: Value = Value::Null;
let mut costString: Value = Value::Null;
// if swap
if is_true(&Value::Bool(in_op(&trade, &Value::Str("v".to_string())))) {
//
// swap: fetchTrades
//
// {
// "p": 31199,
// "v": 18,
// "T": 1,
// "O": 3,
// "M": 2,
// "t": 1609831235985
// }
//
timestamp = self.safe_integer_k(trade.clone(), "t", &[]);
market = self.safe_market(&[Value::Null, market.clone()]);
symbol = get_value(&market, &Value::Str("symbol".to_string()));
priceString = self.safe_string_k(trade.clone(), "p", &[]);
amountString = self.safe_string_k(trade.clone(), "v", &[]);
side = self.parse_order_side(self.safe_string_k(trade.clone(), "T", &[]));
takerOrMaker = Value::Str("taker".to_string());
} else {
//
// spot: fetchTrades (for aggTrades)
//
// {
// "a": null,
// "f": null,
// "l": null,
// "p": "40679",
// "q": "0.001309",
// "T": 1647551328000,
// "m": true,
// "M": true
// }
//
// spot: fetchMyTrades, fetchOrderTrades
//
// {
// "symbol": "BTCUSDT",
// "id": "133948532984922113",
// "orderId": "133948532531949568",
// "orderListId": "-1",
// "price": "41995.51",
// "qty": "0.0002",
// "quoteQty": "8.399102",
// "commission": "0.016798204",
// "commissionAsset": "USDT",
// "time": "1647718055000",
// "isBuyer": true,
// "isMaker": false,
// "isBestMatch": true
// }
//
// swap: fetchMyTrades, fetchOrderTrades
//
// {
// "id": "299444585",
// "symbol": "STEPN_USDT",
// "side": "1",
// "vol": "1",
// "price": "2.45455",
// "feeCurrency": "USDT",
// "fee": "0.00147273",
// "timestamp": "1648924557000",
// "profit": "0",
// "category": "1",
// "orderId": "265307163526610432",
// "positionMode": "1",
// "taker": true
// }
//
let mut marketId: Value = self.safe_string_k(trade.clone(), "symbol", &[]);
market = self.safe_market(&[marketId.clone(), market.clone()]);
symbol = get_value(&market, &Value::Str("symbol".to_string()));
id = self.safe_string2(trade.clone(), Value::Str("id".to_string()), Value::Str("a".to_string()), &[]);
priceString = self.safe_string2(trade.clone(), Value::Str("price".to_string()), Value::Str("p".to_string()), &[]);
orderId = self.safe_string_k(trade.clone(), "orderId", &[]);
// if swap
if is_true(&Value::Bool(in_op(&trade, &Value::Str("positionMode".to_string())))) {
timestamp = self.safe_integer_k(trade.clone(), "timestamp", &[]);
amountString = self.safe_string_k(trade.clone(), "vol", &[]);
side = self.parse_order_side(self.safe_string_k(trade.clone(), "side", &[]));
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(), self.safe_currency_code(self.safe_string_k(trade.clone(), "feeCurrency", &[]), &[]));
m
});
let mut isTaker: bool = is_equal(&self.safe_bool_k(trade.clone(), "taker", &[]), &Value::Bool(true));
takerOrMaker = ternary(is_true(&isTaker), Value::Str("taker".to_string()), Value::Str("maker".to_string()));
} else {
timestamp = self.safe_integer2(trade.clone(), Value::Str("time".to_string()), Value::Str("T".to_string()), &[]);
amountString = self.safe_string2(trade.clone(), Value::Str("qty".to_string()), Value::Str("q".to_string()), &[]);
costString = self.safe_string_k(trade.clone(), "quoteQty", &[]);
let mut isBuyer: Value = self.safe_value_k(trade.clone(), "isBuyer", &[]);
let mut isMaker: Value = self.safe_value_k(trade.clone(), "isMaker", &[]);
let mut buyerMaker: Value = self.safe_value2(trade.clone(), Value::Str("isBuyerMaker".to_string()), Value::Str("m".to_string()), &[]);
if !is_equal(&isMaker, &Value::Null) {
takerOrMaker = ternary(is_true(&(is_equal(&isMaker, &Value::Bool(true)))), Value::Str("maker".to_string()), Value::Str("taker".to_string()));
}
if !is_equal(&isBuyer, &Value::Null) {
side = ternary(is_true(&(is_equal(&isBuyer, &Value::Bool(true)))), Value::Str("buy".to_string()), Value::Str("sell".to_string()));
}
if !is_equal(&buyerMaker, &Value::Null) {
side = ternary(is_true(&(is_equal(&buyerMaker, &Value::Bool(true)))), Value::Str("sell".to_string()), Value::Str("buy".to_string()));
takerOrMaker = Value::Str("taker".to_string());
}
let mut feeAsset: Value = self.safe_string_k(trade.clone(), "commissionAsset", &[]);
if !is_equal(&feeAsset, &Value::Null) {
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(feeAsset.clone(), &[]));
m
});
}
}
}
if is_equal(&id, &Value::Null) && is_true(&self.safe_bool_k(self.options.clone(), "useCcxtTradeId", &[Value::Bool(true)])) {
id = self.create_ccxt_trade_id(&[timestamp.clone(), side.clone(), amountString.clone(), priceString.clone(), takerOrMaker.clone()]);
}
return self.safe_trade(Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("id".to_string(), id.clone());
m.insert("order".to_string(), orderId.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("type".to_string(), type_var.clone());
m.insert("side".to_string(), side.clone());
m.insert("takerOrMaker".to_string(), takerOrMaker.clone());
m.insert("price".to_string(), priceString.clone());
m.insert("amount".to_string(), amountString.clone());
m.insert("cost".to_string(), costString.clone());
m.insert("fee".to_string(), fee.clone());
m.insert("info".to_string(), trade.clone());
m
}), &[market.clone()]);
Value::Null
}
/*
* @method
* @name mexc#fetchOHLCV
* @see https://www.mexc.com/api-docs/spot-v3/market-data-endpoints/klinecandlestick-data // spot
* @see https://www.mexc.com/api-docs/futures/market-endpoints/get-candlestick-data // swap
* @see https://www.mexc.com/api-docs/futures/market-endpoints/get-index-price-candles // index
* @see https://www.mexc.com/api-docs/futures/market-endpoints/get-fair-price-candles // mark
* @description fetches historical candlestick data containing the open, high, low, and close price, and the volume of a market
* @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 {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 [availble 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 market: Value = self.market(symbol.clone());
let mut maxLimit: Value = ternary(is_true(&(is_equal(&get_value(&market, &Value::Str("spot".to_string())), &Value::Bool(true)))), Value::Int(500), Value::Int(2000)); // docs say 1000 for spot, but in practice it's 500
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(), maxLimit.clone()]).await;
}
let mut options: Value = self.safe_value_k(self.options.clone(), "timeframes", &[Value::Map({
let mut m = indexmap::IndexMap::new();
m
})]);
let mut timeframes: Value = self.safe_value(options.clone(), get_value(&market, &Value::Str("type".to_string())), &[Value::Map({
let mut m = indexmap::IndexMap::new();
m
})]);
let mut timeframeValue: Value = self.safe_string(timeframes.clone(), timeframe.clone(), &[]);
let mut duration: Value = multiply(&self.parse_timeframe(timeframe.clone()), &Value::Int(1000));
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("interval".to_string(), timeframeValue.clone());
m
});
let mut candles: Value = Value::List(vec![]);
let mut until: Value = self.safe_integer2(params.clone(), Value::Str("until".to_string()), Value::Str("endTime".to_string()), &[]);
let mut start: Value = since.clone();
if is_true(&(!is_equal(&until, &Value::Null))) && is_true(&(is_equal(&since, &Value::Null))) {
params = self.omit(params.clone(), Value::List(vec![Value::Str("until".to_string())]), &[]);
let mut usedLimit: Value = ternary(is_true(&(!is_equal(&limit, &Value::Null) && !is_equal(&limit, &Value::Null) && !is_equal(&limit, &Value::Int(0)))), limit.clone(), maxLimit.clone());
start = subtract(&until, &(multiply(&usedLimit, &duration)));
}
if is_equal(&get_value(&market, &Value::Str("spot".to_string())), &Value::Bool(true)) {
if !is_equal(&start, &Value::Null) {
add_element_to_object(&mut request, &Value::Str("startTime".to_string()), start.clone());
if is_equal(&until, &Value::Null) {
// we have to calculate it assuming we can get at most 2000 entries per request
let mut end: Value = self.sum(&[since.clone(), multiply(&maxLimit, &duration)]);
let mut now: Value = self.milliseconds();
add_element_to_object(&mut request, &Value::Str("endTime".to_string()), crate::runtime::Math::min(&end, &now));
}
}
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()), add(&until, &Value::Int(1))); // mexc's endTime is not inclusive, so we add 1 ms to avoid missing the last candle in the results
}
let __ws_arg_6 = self.extend(request.clone(), &[params.clone()]);
let mut response: Value = self.spot_public_get_klines(&[__ws_arg_6]).await;
//
// [
// [
// 1640804880000,
// "47482.36",
// "47482.36",
// "47416.57",
// "47436.1",
// "3.550717",
// 1640804940000,
// "168387.3"
// ],
// ]
//
candles = self.to_array(response.clone());
} else if is_equal(&get_value(&market, &Value::Str("swap".to_string())), &Value::Bool(true)) {
if !is_equal(&since, &Value::Null) {
add_element_to_object(&mut request, &Value::Str("start".to_string()), self.parse_to_int(divide(&since, &Value::Int(1000))));
}
if !is_equal(&until, &Value::Null) {
add_element_to_object(&mut request, &Value::Str("end".to_string()), self.parse_to_int(divide(&until, &Value::Int(1000))));
if is_equal(&since, &Value::Null) {
add_element_to_object(&mut request, &Value::Str("start".to_string()), self.parse_to_int(divide(&start, &Value::Int(1000))));
}
}
let mut priceType: Value = self.safe_string_k(params.clone(), "price", &[Value::Str("default".to_string())]);
params = self.omit(params.clone(), Value::Str("price".to_string()), &[]);
let mut response: Value = Value::Null;
if is_equal(&priceType, &Value::Str("default".to_string())) {
let __ws_arg_7 = self.extend(request.clone(), &[params.clone()]);
response = self.contract_public_get_kline_symbol(&[__ws_arg_7]).await;
} else if is_equal(&priceType, &Value::Str("index".to_string())) {
let __ws_arg_8 = self.extend(request.clone(), &[params.clone()]);
response = self.contract_public_get_kline_index_price_symbol(&[__ws_arg_8]).await;
} else if is_equal(&priceType, &Value::Str("mark".to_string())) {
let __ws_arg_9 = self.extend(request.clone(), &[params.clone()]);
response = self.contract_public_get_kline_fair_price_symbol(&[__ws_arg_9]).await;
} else {
panic!("{}", crate::exchange_errors::not_supported(add(&self.id, &Value::Str(" fetchOHLCV() not support this price type, [default, index, mark]".to_string()))));
}
//
// {
// "success":true,
// "code":0,
// "data":{
// "time":[1634052300,1634052360,1634052420],
// "open":[3492.2,3491.3,3495.65],
// "close":[3491.3,3495.65,3495.2],
// "high":[3495.85,3496.55,3499.4],
// "low":[3491.15,3490.9,3494.2],
// "vol":[1740.0,351.0,314.0],
// "amount":[60793.623,12260.4885,10983.1375],
// }
// }
//
let mut data: Value = self.safe_value_k(response.clone(), "data", &[]);
candles = self.convert_trading_view_to_ohlcv(data.clone(), &[Value::Str("time".to_string()), Value::Str("open".to_string()), Value::Str("high".to_string()), Value::Str("low".to_string()), Value::Str("close".to_string()), Value::Str("vol".to_string())]);
}
return self.parse_ohlc_vs(candles.clone(), &[market.clone(), timeframe.clone(), since.clone(), limit.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);
return Value::List(vec![self.safe_integer(ohlcv.clone(), Value::Int(0), &[]), self.safe_number(ohlcv.clone(), Value::Int(1), &[]), self.safe_number(ohlcv.clone(), Value::Int(2), &[]), self.safe_number(ohlcv.clone(), Value::Int(3), &[]), self.safe_number(ohlcv.clone(), Value::Int(4), &[]), self.safe_number(ohlcv.clone(), Value::Int(5), &[])]);
Value::Null
}
/*
* @method
* @name mexc#fetchTickers
* @description fetches price tickers for multiple markets, statistical information calculated over the past 24 hours for each market
* @see https://www.mexc.com/api-docs/spot-v3/market-data-endpoints/api-24hr-ticker-price-change-statistics // spot
* @see https://www.mexc.com/api-docs/futures/market-endpoints/get-ticker-contract-market-data // swap
* @param {string[]|undefined} 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
* @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;
}
let mut request: Value = Value::Map({
let mut m = indexmap::IndexMap::new();
m
});
let mut market: Value = Value::Null;
let mut isSingularMarket: bool = false;
if !is_equal(&symbols, &Value::Null) {
let mut length: Value = get_array_length(&symbols);
isSingularMarket = is_equal(&length, &Value::Int(1));
let mut firstSymbol: Value = self.safe_string(symbols.clone(), Value::Int(0), &[]);
market = self.market(firstSymbol.clone());
}
let mut marketTypequeryVariable = self.handle_market_type_and_params(Value::Str("fetchTickers".to_string()), &[market.clone(), params.clone()]);
let mut marketType: Value = get_value(&marketTypequeryVariable, &Value::Int(0));
let mut query: Value = get_value(&marketTypequeryVariable, &Value::Int(1));
let mut tickers: Value = Value::Null;
if is_true(&isSingularMarket) {
add_element_to_object(&mut request, &Value::Str("symbol".to_string()), self.safe_string_k(market.clone(), "id", &[]));
}
if is_equal(&marketType, &Value::Str("spot".to_string())) {
let __ws_arg_10 = self.extend(request.clone(), &[query.clone()]);
tickers = self.spot_public_get_ticker24hr(&[__ws_arg_10]).await;
} else if is_equal(&marketType, &Value::Str("swap".to_string())) {
let __ws_arg_11 = self.extend(request.clone(), &[query.clone()]);
let mut response: Value = self.contract_public_get_ticker(&[__ws_arg_11]).await;
//
// {
// "success":true,
// "code":0,
// "data":[
// {
// "symbol":"ETH_USDT",
// "lastPrice":3581.3,
// "bid1":3581.25,
// "ask1":3581.5,
// "volume24":4045530,
// "amount24":141331823.5755,
// "holdVol":5832946,
// "lower24Price":3413.4,
// "high24Price":3588.7,
// "riseFallRate":0.0275,
// "riseFallValue":95.95,
// "indexPrice":3580.7852,
// "fairPrice":3581.08,
// "fundingRate":0.000063,
// "maxBidPrice":3938.85,
// "minAskPrice":3222.7,
// "timestamp":1634162885016
// },
// ]
// }
//
tickers = self.safe_value_k(response.clone(), "data", &[Value::List(vec![])]);
}
// when it's single symbol request, the returned structure is different (singular object) for both spot & swap, thus we need to wrap inside array
if is_true(&isSingularMarket) {
tickers = Value::List(vec![tickers.clone()]);
}
return self.parse_tickers(tickers.clone(), &[symbols.clone()]);
Value::Null
}
/*
* @method
* @name mexc#fetchTicker
* @description fetches a price ticker, a statistical calculation with the information calculated over the past 24 hours for a specific market
* @see https://www.mexc.com/api-docs/spot-v3/market-data-endpoints/api-24hr-ticker-price-change-statistics // spot
* @see https://www.mexc.com/api-docs/futures/market-endpoints/get-ticker-contract-market-data // swap
* @param {string} symbol unified symbol of the market to fetch the ticker for
* @param {object} [params] extra parameters specific to the exchange API endpoint
* @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 marketTypequeryVariable = self.handle_market_type_and_params(Value::Str("fetchTicker".to_string()), &[market.clone(), params.clone()]);
let mut marketType: Value = get_value(&marketTypequeryVariable, &Value::Int(0));
let mut query: Value = get_value(&marketTypequeryVariable, &Value::Int(1));
let mut ticker: Value = Value::Null;
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(&marketType, &Value::Str("spot".to_string())) {
let __ws_arg_12 = self.extend(request.clone(), &[query.clone()]);
ticker = self.spot_public_get_ticker24hr(&[__ws_arg_12]).await;
} else if is_equal(&marketType, &Value::Str("swap".to_string())) {
let __ws_arg_13 = self.extend(request.clone(), &[query.clone()]);
let mut response: Value = self.contract_public_get_ticker(&[__ws_arg_13]).await;
//
// {
// "success":true,
// "code":0,
// "data":{
// "symbol":"ETH_USDT",
// "lastPrice":3581.3,
// "bid1":3581.25,
// "ask1":3581.5,
// "volume24":4045530,
// "amount24":141331823.5755,
// "holdVol":5832946,
// "lower24Price":3413.4,
// "high24Price":3588.7,
// "riseFallRate":0.0275,
// "riseFallValue":95.95,
// "indexPrice":3580.7852,
// "fairPrice":3581.08,
// "fundingRate":0.000063,
// "maxBidPrice":3938.85,
// "minAskPrice":3222.7,
// "timestamp":1634162885016
// }
// }
//
ticker = self.safe_value_k(response.clone(), "data", &[Value::Map({
let mut m = indexmap::IndexMap::new();
m
})]);
}
return self.parse_ticker(ticker.clone(), &[market.clone()]);
Value::Null
}
pub fn parse_ticker(&self, mut ticker: Value, optional_args: &[Value]) -> Value {
let mut market = get_arg(optional_args, 0, Value::Null);
let mut marketId: Value = self.safe_string_k(ticker.clone(), "symbol", &[]);
market = self.safe_market(&[marketId.clone(), market.clone()]);
let mut timestamp: Value = Value::Null;
let mut bid: Value = Value::Null;
let mut ask: Value = Value::Null;
let mut bidVolume: Value = Value::Null;
let mut askVolume: Value = Value::Null;
let mut baseVolume: Value = Value::Null;
let mut quoteVolume: Value = Value::Null;
let mut open: Value = Value::Null;
let mut high: Value = Value::Null;
let mut low: Value = Value::Null;
let mut changePcnt: Value = Value::Null;
let mut changeValue: Value = Value::Null;
let mut prevClose: Value = Value::Null;
let mut isSwap: Value = self.safe_value_k(market.clone(), "swap", &[]);
// if swap
if is_true(&(is_equal(&isSwap, &Value::Bool(true)))) || is_true(&(Value::Bool(in_op(&ticker, &Value::Str("timestamp".to_string()))))) {
//
// {
// "symbol": "ETH_USDT",
// "lastPrice": 3581.3,
// "bid1": 3581.25,
// "ask1": 3581.5,
// "volume24": 4045530,
// "amount24": 141331823.5755,
// "holdVol": 5832946,
// "lower24Price": 3413.4,
// "high24Price": 3588.7,
// "riseFallRate": 0.0275,
// "riseFallValue": 95.95,
// "indexPrice": 3580.7852,
// "fairPrice": 3581.08,
// "fundingRate": 0.000063,
// "maxBidPrice": 3938.85,
// "minAskPrice": 3222.7,
// "timestamp": 1634162885016
// }
//
timestamp = self.safe_integer_k(ticker.clone(), "timestamp", &[]);
bid = self.safe_string_k(ticker.clone(), "bid1", &[]);
ask = self.safe_string_k(ticker.clone(), "ask1", &[]);
baseVolume = self.safe_string_k(ticker.clone(), "volume24", &[]);
quoteVolume = self.safe_string_k(ticker.clone(), "amount24", &[]);
high = self.safe_string_k(ticker.clone(), "high24Price", &[]);
low = self.safe_string_k(ticker.clone(), "lower24Price", &[]);
changeValue = self.safe_string_k(ticker.clone(), "riseFallValue", &[]);
changePcnt = self.safe_string_k(ticker.clone(), "riseFallRate", &[]);
changePcnt = crate::precise::Precise::stringMul(&changePcnt, &Value::Str("100".to_string()));
} else {
//
// {
// "symbol": "BTCUSDT",
// "priceChange": "184.34",
// "priceChangePercent": "0.00400048",
// "prevClosePrice": "46079.37",
// "lastPrice": "46263.71",
// "lastQty": "",
// "bidPrice": "46260.38",
// "bidQty": "",
// "askPrice": "46260.41",
// "askQty": "",
// "openPrice": "46079.37",
// "highPrice": "47550.01",
// "lowPrice": "45555.5",
// "volume": "1732.461487",
// "quoteVolume": null,
// "openTime": 1641349500000,
// "closeTime": 1641349582808,
// "count": null
// }
//
timestamp = self.safe_integer_k(ticker.clone(), "closeTime", &[]);
bid = self.safe_string_k(ticker.clone(), "bidPrice", &[]);
ask = self.safe_string_k(ticker.clone(), "askPrice", &[]);
bidVolume = self.safe_string_k(ticker.clone(), "bidQty", &[]);
askVolume = self.safe_string_k(ticker.clone(), "askQty", &[]);
if is_true(&crate::precise::Precise::stringEq(&bidVolume, &Value::Str("0".to_string()))) {
bidVolume = Value::Null;
}
if is_true(&crate::precise::Precise::stringEq(&askVolume, &Value::Str("0".to_string()))) {
askVolume = Value::Null;
}
baseVolume = self.safe_string_k(ticker.clone(), "volume", &[]);
quoteVolume = self.safe_string_k(ticker.clone(), "quoteVolume", &[]);
open = self.safe_string_k(ticker.clone(), "openPrice", &[]);
high = self.safe_string_k(ticker.clone(), "highPrice", &[]);
low = self.safe_string_k(ticker.clone(), "lowPrice", &[]);
prevClose = self.safe_string_k(ticker.clone(), "prevClosePrice", &[]);
changeValue = self.safe_string_k(ticker.clone(), "priceChange", &[]);
changePcnt = self.safe_string_k(ticker.clone(), "priceChangePercent", &[]);
changePcnt = crate::precise::Precise::stringMul(&changePcnt, &Value::Str("100".to_string()));
}
return self.safe_ticker(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("open".to_string(), open.clone());
m.insert("high".to_string(), high.clone());
m.insert("low".to_string(), low.clone());
m.insert("close".to_string(), self.safe_string_k(ticker.clone(), "lastPrice", &[]));
m.insert("bid".to_string(), bid.clone());
m.insert("bidVolume".to_string(), bidVolume.clone());
m.insert("ask".to_string(), ask.clone());
m.insert("askVolume".to_string(), askVolume.clone());
m.insert("vwap".to_string(), Value::Null);
m.insert("previousClose".to_string(), prevClose.clone());
m.insert("change".to_string(), changeValue.clone());
m.insert("percentage".to_string(), changePcnt.clone());
m.insert("average".to_string(), Value::Null);
m.insert("baseVolume".to_string(), baseVolume.clone());
m.insert("quoteVolume".to_string(), quoteVolume.clone());
m.insert("info".to_string(), ticker.clone());
m
}), &[market.clone()]);
Value::Null
}
/*
* @method
* @name mexc#fetchBidsAsks
* @description fetches the bid and ask price and volume for multiple markets
* @see https://www.mexc.com/api-docs/spot-v3/market-data-endpoints/symbol-order-book-ticker
* @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
* @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;
}
let mut market: Value = Value::Null;
let mut isSingularMarket: bool = false;
if !is_equal(&symbols, &Value::Null) {
let mut length: Value = get_array_length(&symbols);
isSingularMarket = is_equal(&length, &Value::Int(1));
market = self.market(get_value(&symbols, &Value::Int(0)));
}
let mut marketTypequeryVariable = self.handle_market_type_and_params(Value::Str("fetchBidsAsks".to_string()), &[market.clone(), params.clone()]);
let mut marketType: Value = get_value(&marketTypequeryVariable, &Value::Int(0));
let mut query: Value = get_value(&marketTypequeryVariable, &Value::Int(1));
let mut tickers: Value = Value::Null;
if is_equal(&marketType, &Value::Str("spot".to_string())) {
tickers = self.spot_public_get_ticker_book_ticker(&[query.clone()]).await;
} else if is_equal(&marketType, &Value::Str("swap".to_string())) {
panic!("{}", crate::exchange_errors::not_supported(add(&add(&add(&self.id, &Value::Str(" fetchBidsAsks() is not available for ".to_string())), &marketType), &Value::Str(" markets".to_string()))));
}
// when it's single symbol request, the returned structure is different (singular object) for both spot & swap, thus we need to wrap inside array
if is_true(&isSingularMarket) {
tickers = Value::List(vec![tickers.clone()]);
}
return self.parse_tickers(tickers.clone(), &[symbols.clone()]);
Value::Null
}
/*
* @method
* @name mexc#createMarketBuyOrderWithCost
* @description create a market buy order by providing the symbol and cost
* @see https://www.mexc.com/api-docs/spot-v3/spot-account-trade/new-order
* @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_14 = self.extend(req.clone(), &[params.clone()]);
return self.create_order(symbol.clone(), Value::Str("market".to_string()), Value::Str("buy".to_string()), Value::Int(0), &[Value::Null, __ws_arg_14]).await;
Value::Null
}
/*
* @method
* @name mexc#createMarketSellOrderWithCost
* @description create a market sell order by providing the symbol and cost
* @see https://www.mexc.com/api-docs/spot-v3/spot-account-trade/new-order
* @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(" 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_15 = self.extend(req.clone(), &[params.clone()]);
return self.create_order(symbol.clone(), Value::Str("market".to_string()), Value::Str("sell".to_string()), Value::Int(0), &[Value::Null, __ws_arg_15]).await;
Value::Null
}
/*
* @method
* @name mexc#createOrder
* @description create a trade order
* @see https://www.mexc.com/api-docs/spot-v3/spot-account-trade/new-order // spot
* @see https://www.mexc.com/api-docs/futures/account-and-trading-endpoints/place-order // swap
* @see https://www.mexc.com/api-docs/futures/account-and-trading-endpoints/place-plan-order // swap trigger
* @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 {string} [params.marginMode] only 'isolated' is supported for spot-margin trading
* @param {float} [params.triggerPrice] The price at which a trigger order is triggered at
* @param {bool} [params.postOnly] if true, the order will only be posted if it will be a maker order
* @param {bool} [params.reduceOnly] *contract only* indicates if this order is to reduce the size of a position
* @param {bool} [params.hedged] *swap only* true for hedged mode, false for one way mode, default is false
* @param {string} [params.timeInForce] 'IOC' or 'FOK', default is 'GTC'
* EXCHANGE SPECIFIC PARAMETERS
* @param {int} [params.leverage] *contract only* leverage is necessary on isolated margin
* @param {long} [params.positionId] *contract only* it is recommended to fill in this parameter when closing a position
* @param {string} [params.externalOid] *contract only* external order ID
* @param {int} [params.positionMode] *contract only* 1:hedge, 2:one-way, default: the user's current config
* @param {boolean} [params.test] *spot only* whether to use the test endpoint or not, default is false
* @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());
let mut marginModequeryVariable = self.handle_margin_mode_and_params(Value::Str("createOrder".to_string()), &[params.clone()]);
let mut marginMode: Value = get_value(&marginModequeryVariable, &Value::Int(0));
let mut query: Value = get_value(&marginModequeryVariable, &Value::Int(1));
if is_equal(&get_value(&market, &Value::Str("spot".to_string())), &Value::Bool(true)) {
return self.create_spot_order(market.clone(), type_var.clone(), side.clone(), amount.clone(), &[price.clone(), marginMode.clone(), query.clone()]).await;
} else {
return self.create_swap_order(market.clone(), type_var.clone(), side.clone(), amount.clone(), &[price.clone(), marginMode.clone(), query.clone()]).await;
}
Value::Null
}
pub fn create_spot_order_request(&self, mut market: 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 marginMode = 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 symbol: Value = get_value(&market, &Value::Str("symbol".to_string()));
let mut orderSide: 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(), orderSide.clone());
m.insert("type".to_string(), to_upper(&type_var));
m
});
if is_equal(&type_var, &Value::Str("market".to_string())) {
let mut cost: Value = self.safe_number2(params.clone(), Value::Str("cost".to_string()), Value::Str("quoteOrderQty".to_string()), &[]);
params = self.omit(params.clone(), Value::Str("cost".to_string()), &[]);
if !is_equal(&cost, &Value::Null) {
amount = cost.clone();
add_element_to_object(&mut request, &Value::Str("quoteOrderQty".to_string()), self.cost_to_precision(symbol.clone(), amount.clone()));
} else {
if is_equal(&price, &Value::Null) {
add_element_to_object(&mut request, &Value::Str("quantity".to_string()), self.amount_to_precision(symbol.clone(), amount.clone()));
} else {
let mut amountString: Value = self.number_to_string(amount.clone());
let mut priceString: Value = self.number_to_string(price.clone());
let mut quoteAmount: Value = crate::precise::Precise::stringMul(&amountString, &priceString);
amount = quoteAmount.clone();
add_element_to_object(&mut request, &Value::Str("quoteOrderQty".to_string()), self.cost_to_precision(symbol.clone(), amount.clone()));
}
}
} else {
add_element_to_object(&mut request, &Value::Str("quantity".to_string()), self.amount_to_precision(symbol.clone(), amount.clone()));
}
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()));
}
let mut clientOrderId: Value = self.safe_string_k(params.clone(), "clientOrderId", &[]);
if !is_equal(&clientOrderId, &Value::Null) {
add_element_to_object(&mut request, &Value::Str("newClientOrderId".to_string()), clientOrderId.clone());
params = self.omit(params.clone(), Value::List(vec![Value::Str("type".to_string()), Value::Str("clientOrderId".to_string())]), &[]);
}
if !is_equal(&marginMode, &Value::Null) {
if !is_equal(&marginMode, &Value::Str("isolated".to_string())) {
panic!("{}", crate::exchange_errors::bad_request(add(&add(&add(&self.id, &Value::Str(" createOrder() does not support marginMode ".to_string())), &marginMode), &Value::Str(" for spot-margin trading".to_string()))));
}
}
let mut postOnly: Value = Value::Null;
{ let __destr_tmp = self.handle_post_only(Value::Bool(is_equal(&type_var, &Value::Str("market".to_string()))), Value::Bool(is_equal(&type_var, &Value::Str("LIMIT_MAKER".to_string()))), &[params.clone()]); postOnly = get_value(&__destr_tmp, &Value::Int(0)); params = get_value(&__destr_tmp, &Value::Int(1)); }
if is_equal(&postOnly, &Value::Bool(true)) {
add_element_to_object(&mut request, &Value::Str("type".to_string()), Value::Str("LIMIT_MAKER".to_string()));
}
let mut tif: Value = self.safe_string_k(params.clone(), "timeInForce", &[]);
if !is_equal(&tif, &Value::Null) {
params = self.omit(params.clone(), Value::Str("timeInForce".to_string()), &[]);
if is_equal(&tif, &Value::Str("IOC".to_string())) {
add_element_to_object(&mut request, &Value::Str("type".to_string()), Value::Str("IMMEDIATE_OR_CANCEL".to_string()));
} else if is_equal(&tif, &Value::Str("FOK".to_string())) {
add_element_to_object(&mut request, &Value::Str("type".to_string()), Value::Str("FILL_OR_KILL".to_string()));
}
}
return self.extend(request.clone(), &[params.clone()]);
Value::Null
}
/*
* @ignore
* @method
* @name mexc#createSpotOrder
* @description create a trade order
* @see https://www.mexc.com/api-docs/spot-v3/spot-account-trade/new-order
* @param {string} market 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 {string} [marginMode] only 'isolated' is supported for spot-margin trading
* @param {object} [params] extra parameters specific to the exchange API endpoint
* @param {bool} [params.postOnly] if true, the order will only be posted if it will be a maker order
* @returns {object} an [order structure]{@link https://docs.ccxt.com/?id=order-structure}
*/
pub async fn create_spot_order(&mut self, mut market: 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 marginMode = 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 test: Value = self.safe_bool_k(params.clone(), "test", &[Value::Bool(false)]);
params = self.omit(params.clone(), Value::Str("test".to_string()), &[]);
let mut request: Value = self.create_spot_order_request(market.clone(), type_var.clone(), side.clone(), amount.clone(), &[price.clone(), marginMode.clone(), params.clone()]);
let mut response: Value = Value::Null;
if is_equal(&test, &Value::Bool(true)) {
response = self.spot_private_post_order_test(&[request.clone()]).await;
} else {
response = self.spot_private_post_order(&[request.clone()]).await;
}
//
// spot
//
// {
// "symbol": "BTCUSDT",
// "orderId": "123738410679123456",
// "orderListId": -1
// }
//
// margin
//
// {
// "symbol": "BTCUSDT",
// "orderId": "762634301354414080",
// "clientOrderId": null,
// "isIsolated": true,
// "transactTime": 1661992652132
// }
//
let mut order: Value = self.parse_order(response.clone(), &[market.clone()]);
add_element_to_object(&mut order, &Value::Str("side".to_string()), side.clone());
add_element_to_object(&mut order, &Value::Str("type".to_string()), type_var.clone());
if is_equal(&self.safe_string_k(order.clone(), "price", &[]), &Value::Null) {
add_element_to_object(&mut order, &Value::Str("price".to_string()), price.clone());
}
if is_equal(&self.safe_string_k(order.clone(), "amount", &[]), &Value::Null) {
add_element_to_object(&mut order, &Value::Str("amount".to_string()), amount.clone());
}
return order;
Value::Null
}
/*
* @ignore
* @method
* @name mexc#createSwapOrder
* @description create a trade order
* @see https://www.mexc.com/api-docs/futures/account-and-trading-endpoints/place-order
* @see https://www.mexc.com/api-docs/futures/account-and-trading-endpoints/place-plan-order
* @param {string} market 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 {string} [marginMode] only 'isolated' is supported for spot-margin trading
* @param {object} [params] extra parameters specific to the exchange API endpoint
* @param {float} [params.triggerPrice] The price at which a trigger order is triggered at
* @param {bool} [params.postOnly] if true, the order will only be posted if it will be a maker order
* @param {bool} [params.reduceOnly] indicates if this order is to reduce the size of a position
* @param {bool} [params.hedged] *swap only* true for hedged mode, false for one way mode, default is false
*
* EXCHANGE SPECIFIC PARAMETERS
* @param {int} [params.leverage] leverage is necessary on isolated margin
* @param {long} [params.positionId] it is recommended to fill in this parameter when closing a position
* @param {string} [params.externalOid] external order ID
* @param {int} [params.positionMode] 1:hedge, 2:one-way, default: the user's current config
* @returns {object} an [order structure]{@link https://docs.ccxt.com/?id=order-structure}
*/
pub async fn create_swap_order(&mut self, mut market: 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 marginMode = 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 symbol: Value = get_value(&market, &Value::Str("symbol".to_string()));
let mut openType: Value = Value::Null;
if !is_equal(&marginMode, &Value::Null) {
if is_equal(&marginMode, &Value::Str("cross".to_string())) {
openType = Value::Int(2);
} else if is_equal(&marginMode, &Value::Str("isolated".to_string())) {
openType = Value::Int(1);
} else {
panic!("{}", crate::exchange_errors::arguments_required(add(&self.id, &Value::Str(" createSwapOrder() marginMode parameter should be either \"cross\" or \"isolated\"".to_string()))));
}
} else {
openType = self.safe_integer_k(params.clone(), "openType", &[Value::Int(2)]); // defaulting to cross margin
}
if is_true(&(!is_equal(&type_var, &Value::Str("limit".to_string())))) && is_true(&(!is_equal(&type_var, &Value::Str("market".to_string())))) && is_true(&(!is_equal(&type_var, &Value::Int(1)))) && is_true(&(!is_equal(&type_var, &Value::Int(2)))) && is_true(&(!is_equal(&type_var, &Value::Int(3)))) && is_true(&(!is_equal(&type_var, &Value::Int(4)))) && is_true(&(!is_equal(&type_var, &Value::Int(5)))) && is_true(&(!is_equal(&type_var, &Value::Int(6)))) {
panic!("{}", crate::exchange_errors::invalid_order(add(&self.id, &Value::Str(" createSwapOrder() order type must either limit, market, or 1 for limit orders, 2 for post-only orders, 3 for IOC orders, 4 for FOK orders, 5 for market orders or 6 to convert market price to current price".to_string()))));
}
let mut postOnly: Value = Value::Null;
{ let __destr_tmp = self.handle_post_only(Value::Bool(is_equal(&type_var, &Value::Str("market".to_string()))), Value::Bool(is_equal(&type_var, &Value::Int(2))), &[params.clone()]); postOnly = get_value(&__destr_tmp, &Value::Int(0)); params = get_value(&__destr_tmp, &Value::Int(1)); }
if is_equal(&postOnly, &Value::Bool(true)) {
type_var = Value::Int(2);
} else if is_equal(&type_var, &Value::Str("limit".to_string())) {
type_var = Value::Int(1);
} else if is_equal(&type_var, &Value::Str("market".to_string())) {
type_var = Value::Int(6);
}
let mut volString: Value = self.amount_to_precision(symbol.clone(), amount.clone());
if is_equal(&volString, &Value::Null) {
volString = Value::Str("0".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("vol".to_string(), crate::runtime::parse_float(&volString));
m.insert("type".to_string(), type_var.clone());
m.insert("openType".to_string(), openType.clone());
m
});
if is_true(&(!is_equal(&type_var, &Value::Int(5)))) && is_true(&(!is_equal(&type_var, &Value::Int(6)))) && is_true(&(!is_equal(&type_var, &Value::Str("market".to_string())))) {
let mut priceString: Value = self.price_to_precision(symbol.clone(), price.clone());
if is_equal(&priceString, &Value::Null) {
priceString = Value::Str("0".to_string());
}
add_element_to_object(&mut request, &Value::Str("price".to_string()), crate::runtime::parse_float(&priceString));
}
if is_equal(&openType, &Value::Int(1)) {
let mut leverage: Value = self.safe_integer_k(params.clone(), "leverage", &[]);
if is_equal(&leverage, &Value::Null) {
panic!("{}", crate::exchange_errors::arguments_required(add(&self.id, &Value::Str(" createSwapOrder() requires a leverage parameter for isolated margin orders".to_string()))));
}
}
let mut reduceOnly: Value = self.safe_bool_k(params.clone(), "reduceOnly", &[Value::Bool(false)]);
let mut hedged: Value = self.safe_bool_k(params.clone(), "hedged", &[Value::Bool(false)]);
let mut sideInteger: Value = Value::Null;
if is_equal(&hedged, &Value::Bool(true)) {
if is_equal(&reduceOnly, &Value::Bool(true)) {
params = self.omit(params.clone(), Value::Str("reduceOnly".to_string()), &[]); // hedged mode does not accept this parameter
sideInteger = ternary(is_true(&(is_equal(&side, &Value::Str("buy".to_string())))), Value::Int(4), Value::Int(2)); // close short, close long
} else {
sideInteger = ternary(is_true(&(is_equal(&side, &Value::Str("buy".to_string())))), Value::Int(1), Value::Int(3));
}
add_element_to_object(&mut request, &Value::Str("positionMode".to_string()), Value::Int(1));
} else {
if is_equal(&reduceOnly, &Value::Bool(true)) {
sideInteger = ternary(is_true(&(is_equal(&side, &Value::Str("buy".to_string())))), Value::Int(2), Value::Int(4));
params = self.omit(params.clone(), Value::Str("reduceOnly".to_string()), &[]);
} else {
sideInteger = ternary(is_true(&(is_equal(&side, &Value::Str("buy".to_string())))), Value::Int(1), Value::Int(3));
}
}
add_element_to_object(&mut request, &Value::Str("side".to_string()), sideInteger.clone());
let mut clientOrderId: Value = self.safe_string2(params.clone(), Value::Str("clientOrderId".to_string()), Value::Str("externalOid".to_string()), &[]);
if !is_equal(&clientOrderId, &Value::Null) {
add_element_to_object(&mut request, &Value::Str("externalOid".to_string()), clientOrderId.clone());
}
let mut triggerPrice: Value = self.safe_number2(params.clone(), Value::Str("triggerPrice".to_string()), Value::Str("stopPrice".to_string()), &[]);
params = self.omit(params.clone(), Value::List(vec![Value::Str("clientOrderId".to_string()), Value::Str("externalOid".to_string()), Value::Str("postOnly".to_string()), Value::Str("stopPrice".to_string()), Value::Str("triggerPrice".to_string()), Value::Str("hedged".to_string())]), &[]);
let mut response: Value = Value::Null;
if is_true(&(!is_equal(&triggerPrice, &Value::Null))) && is_true(&(!is_equal(&triggerPrice, &Value::Int(0)))) {
add_element_to_object(&mut request, &Value::Str("triggerPrice".to_string()), self.price_to_precision(symbol.clone(), triggerPrice.clone()));
add_element_to_object(&mut request, &Value::Str("triggerType".to_string()), self.safe_integer_k(params.clone(), "triggerType", &[Value::Int(1)]));
add_element_to_object(&mut request, &Value::Str("executeCycle".to_string()), self.safe_integer_k(params.clone(), "executeCycle", &[Value::Int(1)]));
add_element_to_object(&mut request, &Value::Str("trend".to_string()), self.safe_integer_k(params.clone(), "trend", &[Value::Int(1)]));
add_element_to_object(&mut request, &Value::Str("orderType".to_string()), self.safe_integer_k(params.clone(), "orderType", &[Value::Int(1)]));
let __ws_arg_16 = self.extend(request.clone(), &[params.clone()]);
response = self.contract_private_post_planorder_place(&[__ws_arg_16]).await;
} else {
let __ws_arg_17 = self.extend(request.clone(), &[params.clone()]);
response = self.contract_private_post_order_create(&[__ws_arg_17]).await;
}
//
// Swap
// {"code":200,"data":"2ff3163e8617443cb9c6fc19d42b1ca4"}
//
// Trigger
// {"success":true,"code":0,"data":259208506303929856}
//
// {"success":true,"code":0,"data":{"orderId":"814218083416790528","ts":1779795118533}}
//
let mut data: Value = self.safe_dict_k(response.clone(), "data", &[]);
return self.safe_order(Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("id".to_string(), self.safe_string_k(data.clone(), "orderId", &[]));
m.insert("timestamp".to_string(), self.safe_integer_k(data.clone(), "ts", &[]));
m
}), &[market.clone()]);
Value::Null
}
/*
* @method
* @name mexc#createOrders
* @description *spot only* *all orders must have the same symbol* create a list of trade orders
* @see https://www.mexc.com/api-docs/spot-v3/spot-account-trade/batch-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 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 symbol: Value = Value::Null;
{
let mut i: Value = Value::Int(0);
let mut __for_first_937: bool = true;
while { if !__for_first_937 { i = add(&i, &Value::Int(1)); } __for_first_937 = 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", &[]);
let mut market: Value = self.market(marketId.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(" createOrders() is only supported for spot markets".to_string()))));
}
if is_equal(&symbol, &Value::Null) {
symbol = marketId.clone();
} else {
if !is_equal(&symbol, &marketId) {
panic!("{}", crate::exchange_errors::bad_request(add(&self.id, &Value::Str(" createOrders() requires all orders to have the same symbol".to_string()))));
}
}
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_value_k(rawOrder.clone(), "params", &[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("createOrder".to_string()), &[params.clone()]); marginMode = get_value(&__destr_tmp, &Value::Int(0)); params = get_value(&__destr_tmp, &Value::Int(1)); }
let mut orderRequest: Value = self.create_spot_order_request(market.clone(), type_var.clone(), side.clone(), amount.clone(), &[price.clone(), marginMode.clone(), orderParams.clone()]);
append_to_array(&mut ordersRequests, orderRequest.clone());
}
}
let mut request: Value = Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("batchOrders".to_string(), self.json(ordersRequests.clone()));
m
});
let mut response: Value = self.spot_private_post_batch_orders(&[request.clone()]).await;
return self.parse_orders(response.clone(), &[]);
Value::Null
}
/*
* @method
* @name mexc#fetchOrder
* @description fetches information on an order made by the user
* @see https://www.mexc.com/api-docs/spot-v3/spot-account-trade/query-order // spot
* @see https://www.mexc.com/api-docs/futures/account-and-trading-endpoints/get-order-information-by-order-id // swap
* @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 {string} [params.marginMode] only 'isolated' is supported, for spot-margin trading
* @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(&symbol, &Value::Null) {
panic!("{}", crate::exchange_errors::arguments_required(add(&self.id, &Value::Str(" fetchOrder() 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 data: Value = Value::Map({
let mut m = indexmap::IndexMap::new();
m
});
if is_equal(&get_value(&market, &Value::Str("spot".to_string())), &Value::Bool(true)) {
let mut clientOrderId: Value = self.safe_string_k(params.clone(), "clientOrderId", &[]);
if !is_equal(&clientOrderId, &Value::Null) {
params = self.omit(params.clone(), Value::Str("clientOrderId".to_string()), &[]);
add_element_to_object(&mut request, &Value::Str("origClientOrderId".to_string()), clientOrderId.clone());
} else {
add_element_to_object(&mut request, &Value::Str("orderId".to_string()), id.clone());
}
let mut marginModequeryVariable = self.handle_margin_mode_and_params(Value::Str("fetchOrder".to_string()), &[params.clone()]);
let mut marginMode: Value = get_value(&marginModequeryVariable, &Value::Int(0));
let mut query: Value = get_value(&marginModequeryVariable, &Value::Int(1));
if !is_equal(&marginMode, &Value::Null) {
if !is_equal(&marginMode, &Value::Str("isolated".to_string())) {
panic!("{}", crate::exchange_errors::bad_request(add(&add(&add(&self.id, &Value::Str(" fetchOrder() does not support marginMode ".to_string())), &marginMode), &Value::Str(" for spot-margin trading".to_string()))));
}
let __ws_arg_18 = self.extend(request.clone(), &[query.clone()]);
data = self.spot_private_get_margin_order(&[__ws_arg_18]).await;
} else {
let __ws_arg_19 = self.extend(request.clone(), &[query.clone()]);
data = self.spot_private_get_order(&[__ws_arg_19]).await;
}
} else if is_equal(&get_value(&market, &Value::Str("swap".to_string())), &Value::Bool(true)) {
add_element_to_object(&mut request, &Value::Str("order_id".to_string()), id.clone());
let __ws_arg_20 = self.extend(request.clone(), &[params.clone()]);
let mut response: Value = self.contract_private_get_order_get_order_id(&[__ws_arg_20]).await;
//
// {
// "success": true,
// "code": "0",
// "data": {
// "orderId": "264995729269765120",
// "symbol": "STEPN_USDT",
// "positionId": "0",
// "price": "2.2",
// "vol": "15",
// "leverage": "20",
// "side": "1",
// "category": "1",
// "orderType": "1",
// "dealAvgPrice": "0",
// "dealVol": "0",
// "orderMargin": "2.2528",
// "takerFee": "0",
// "makerFee": "0",
// "profit": "0",
// "feeCurrency": "USDT",
// "openType": "1",
// "state": "2",
// "externalOid": "_m_0e9520c256744d64b942985189026d20",
// "errorCode": "0",
// "usedMargin": "0",
// "createTime": "1648850305236",
// "updateTime": "1648850305245",
// "positionMode": "1"
// }
// }
//
data = self.safe_value_k(response.clone(), "data", &[]);
}
return self.parse_order(data.clone(), &[market.clone()]);
Value::Null
}
/*
* @method
* @name mexc#fetchOrders
* @description fetches information on multiple orders made by the user
* @see https://www.mexc.com/api-docs/spot-v3/spot-account-trade/all-orders // spot
* @see https://www.mexc.com/api-docs/futures/account-and-trading-endpoints/get-all-historical-orders // swap
* @see https://www.mexc.com/api-docs/futures/account-and-trading-endpoints/get-plan-order-list // swap trigger
* @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 {int} [params.until] the latest time in ms to fetch orders for
* @param {string} [params.marginMode] only 'isolated' is supported, for spot-margin trading
* @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 request: Value = 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());
add_element_to_object(&mut request, &Value::Str("symbol".to_string()), get_value(&market, &Value::Str("id".to_string())));
}
let mut until: Value = self.safe_integer_k(params.clone(), "until", &[]);
params = self.omit(params.clone(), Value::Str("until".to_string()), &[]);
let mut marketTypequeryVariable = self.handle_market_type_and_params(Value::Str("fetchOrders".to_string()), &[market.clone(), params.clone()]);
let mut marketType: Value = get_value(&marketTypequeryVariable, &Value::Int(0));
let mut query: Value = get_value(&marketTypequeryVariable, &Value::Int(1));
if is_equal(&marketType, &Value::Str("spot".to_string())) {
if is_equal(&symbol, &Value::Null) {
panic!("{}", crate::exchange_errors::arguments_required(add(&self.id, &Value::Str(" fetchOrders() requires a symbol argument for spot market".to_string()))));
}
let mut marginModequeryInnerVariable = self.handle_margin_mode_and_params(Value::Str("fetchOrders".to_string()), &[params.clone()]);
let mut marginMode: Value = get_value(&marginModequeryInnerVariable, &Value::Int(0));
let mut queryInner: Value = get_value(&marginModequeryInnerVariable, &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(&until, &Value::Null) {
add_element_to_object(&mut request, &Value::Str("endTime".to_string()), until.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_equal(&marginMode, &Value::Null) {
if !is_equal(&marginMode, &Value::Str("isolated".to_string())) {
panic!("{}", crate::exchange_errors::bad_request(add(&add(&add(&self.id, &Value::Str(" fetchOrders() does not support marginMode ".to_string())), &marginMode), &Value::Str(" for spot-margin trading".to_string()))));
}
let __ws_arg_21 = self.extend(request.clone(), &[queryInner.clone()]);
response = self.spot_private_get_margin_all_orders(&[__ws_arg_21]).await;
} else {
let __ws_arg_22 = self.extend(request.clone(), &[queryInner.clone()]);
response = self.spot_private_get_all_orders(&[__ws_arg_22]).await;
}
return self.parse_orders(response.clone(), &[market.clone(), since.clone(), limit.clone()]);
} else {
if !is_equal(&since, &Value::Null) {
add_element_to_object(&mut request, &Value::Str("start_time".to_string()), since.clone());
let mut end: Value = self.safe_integer_k(params.clone(), "end_time", &[until.clone()]);
if is_equal(&end, &Value::Null) {
add_element_to_object(&mut request, &Value::Str("end_time".to_string()), self.sum(&[since.clone(), get_value(&self.options, &Value::Str("maxTimeTillEnd".to_string()))]));
} else {
if is_greater_than(&(subtract(&end, &since)), &get_value(&self.options, &Value::Str("maxTimeTillEnd".to_string()))) {
panic!("{}", crate::exchange_errors::bad_request(add(&self.id, &Value::Str(" end is invalid, i.e. exceeds allowed 90 days.".to_string()))));
} else {
add_element_to_object(&mut request, &Value::Str("end_time".to_string()), until.clone());
}
}
} else if !is_equal(&until, &Value::Null) {
add_element_to_object(&mut request, &Value::Str("start_time".to_string()), self.sum(&[until.clone(), multiply(&get_value(&self.options, &Value::Str("maxTimeTillEnd".to_string())), &negate(&Value::Int(1)))]));
add_element_to_object(&mut request, &Value::Str("end_time".to_string()), until.clone());
}
if !is_equal(&limit, &Value::Null) {
add_element_to_object(&mut request, &Value::Str("page_size".to_string()), limit.clone());
}
let mut method: Value = self.safe_string_k(self.options.clone(), "fetchOrders", &[Value::Str("contractPrivateGetOrderListHistoryOrders".to_string())]);
method = self.safe_string_k(query.clone(), "method", &[method.clone()]);
let mut ordersOfRegular: Value = Value::List(vec![]);
let mut ordersOfTrigger: Value = Value::List(vec![]);
if is_equal(&method, &Value::Str("contractPrivateGetOrderListHistoryOrders".to_string())) {
let __ws_arg_23 = self.extend(request.clone(), &[query.clone()]);
let mut response: Value = self.contract_private_get_order_list_history_orders(&[__ws_arg_23]).await;
//
// {
// "success": true,
// "code": "0",
// "data": [
// {
// "orderId": "265230764677709315",
// "symbol": "STEPN_USDT",
// "positionId": "0",
// "price": "2.1",
// "vol": "102",
// "leverage": "20",
// "side": "1",
// "category": "1",
// "orderType": "1",
// "dealAvgPrice": "0",
// "dealVol": "0",
// "orderMargin": "10.96704",
// "takerFee": "0",
// "makerFee": "0",
// "profit": "0",
// "feeCurrency": "USDT",
// "openType": "1",
// "state": "2",
// "externalOid": "_m_7e42f8df6b324c869e4e200397e2b00f",
// "errorCode": "0",
// "usedMargin": "0",
// "createTime": "1648906342000",
// "updateTime": "1648906342000",
// "positionMode": "1"
// },
// ]
// }
//
ordersOfRegular = self.safe_value_k(response.clone(), "data", &[]);
} else {
// the Planorder endpoints work not only for stop-market orders, but also for stop-limit orders that were supposed to have a separate endpoint
let __ws_arg_24 = self.extend(request.clone(), &[query.clone()]);
let mut response: Value = self.contract_private_get_planorder_list_orders(&[__ws_arg_24]).await;
//
// {
// "success": true,
// "code": "0",
// "data": [
// {
// "symbol": "STEPN_USDT",
// "leverage": "20",
// "side": "1",
// "vol": "13",
// "openType": "1",
// "state": "1",
// "orderType": "1",
// "errorCode": "0",
// "createTime": "1648984276000",
// "updateTime": "1648984276000",
// "id": "265557643326564352",
// "triggerType": "1",
// "triggerPrice": "3",
// "price": "2.9", // not present in stop-market, but in stop-limit order
// "executeCycle": "87600",
// "trend": "1",
// },
// ]
// }
//
ordersOfTrigger = self.safe_value_k(response.clone(), "data", &[]);
}
let mut merged: Value = self.array_concat(ordersOfTrigger.clone(), ordersOfRegular.clone());
return self.parse_orders(merged.clone(), &[market.clone(), since.clone(), limit.clone(), params.clone()]);
}
Value::Null
}
pub async fn fetch_orders_by_ids(&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(&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;
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())));
}
let mut marketTypequeryVariable = self.handle_market_type_and_params(Value::Str("fetchOrdersByIds".to_string()), &[market.clone(), params.clone()]);
let mut marketType: Value = get_value(&marketTypequeryVariable, &Value::Int(0));
let mut query: Value = get_value(&marketTypequeryVariable, &Value::Int(1));
if is_equal(&marketType, &Value::Str("spot".to_string())) {
panic!("{}", crate::exchange_errors::bad_request(add(&add(&self.id, &Value::Str(" fetchOrdersByIds() is not supported for ".to_string())), &marketType)));
} else {
add_element_to_object(&mut request, &Value::Str("order_ids".to_string()), join(&ids, &Value::Str(",".to_string())));
let __ws_arg_25 = self.extend(request.clone(), &[query.clone()]);
let mut response: Value = self.contract_private_get_order_batch_query(&[__ws_arg_25]).await;
//
// {
// "success": true,
// "code": "0",
// "data": [
// {
// "orderId": "265230764677709315",
// "symbol": "STEPN_USDT",
// "positionId": "0",
// "price": "2.1",
// "vol": "102",
// "leverage": "20",
// "side": "1",
// "category": "1",
// "orderType": "1",
// "dealAvgPrice": "0",
// "dealVol": "0",
// "orderMargin": "10.96704",
// "takerFee": "0",
// "makerFee": "0",
// "profit": "0",
// "feeCurrency": "USDT",
// "openType": "1",
// "state": "2",
// "externalOid": "_m_7e42f8df6b324c869e4e200397e2b00f",
// "errorCode": "0",
// "usedMargin": "0",
// "createTime": "1648906342000",
// "updateTime": "1648906342000",
// "positionMode": "1"
// }
// ]
// }
//
let mut data: Value = self.safe_list_k(response.clone(), "data", &[]);
return self.parse_orders(data.clone(), &[market.clone()]);
}
Value::Null
}
/*
* @method
* @name mexc#fetchOpenOrders
* @description fetch all unfilled currently open orders
* @see https://www.mexc.com/api-docs/spot-v3/spot-account-trade/current-open-orders // spot
* @see https://www.mexc.com/api-docs/futures/account-and-trading-endpoints/get-current-orders // swap
* @see https://www.mexc.com/api-docs/futures/account-and-trading-endpoints/get-plan-order-list // swap trigger
* @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] only 'isolated' is supported, for spot-margin trading
* @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 request: Value = Value::Map({
let mut m = indexmap::IndexMap::new();
m
});
let mut market: Value = Value::Null;
let mut marketType: Value = Value::Null;
if !is_equal(&symbol, &Value::Null) {
market = self.market(symbol.clone());
}
{ let __destr_tmp = self.handle_market_type_and_params(Value::Str("fetchOpenOrders".to_string()), &[market.clone(), params.clone()]); marketType = get_value(&__destr_tmp, &Value::Int(0)); params = get_value(&__destr_tmp, &Value::Int(1)); }
if is_equal(&marketType, &Value::Str("spot".to_string())) {
if !is_equal(&symbol, &Value::Null) {
add_element_to_object(&mut request, &Value::Str("symbol".to_string()), self.safe_string_k(market.clone(), "id", &[]));
}
let mut marginModequeryVariable = self.handle_margin_mode_and_params(Value::Str("fetchOpenOrders".to_string()), &[params.clone()]);
let mut marginMode: Value = get_value(&marginModequeryVariable, &Value::Int(0));
let mut query: Value = get_value(&marginModequeryVariable, &Value::Int(1));
let mut response: Value = Value::Null;
if !is_equal(&marginMode, &Value::Null) {
if !is_equal(&marginMode, &Value::Str("isolated".to_string())) {
panic!("{}", crate::exchange_errors::bad_request(add(&add(&add(&self.id, &Value::Str(" fetchOpenOrders() does not support marginMode ".to_string())), &marginMode), &Value::Str(" for spot-margin trading".to_string()))));
}
let __ws_arg_26 = self.extend(request.clone(), &[query.clone()]);
response = self.spot_private_get_margin_open_orders(&[__ws_arg_26]).await;
} else {
let __ws_arg_27 = self.extend(request.clone(), &[query.clone()]);
response = self.spot_private_get_open_orders(&[__ws_arg_27]).await;
}
return self.parse_orders(response.clone(), &[market.clone(), since.clone(), limit.clone()]);
} else {
if is_equal(&limit, &Value::Null) {
add_element_to_object(&mut request, &Value::Str("page_size".to_string()), Value::Int(100)); // max
}
let __ws_arg_28 = self.extend(request.clone(), &[params.clone()]);
let mut swapResponse: Value = self.contract_private_get_order_list_open_orders(&[__ws_arg_28]).await;
let mut data: Value = self.safe_list_k(swapResponse.clone(), "data", &[Value::List(vec![])]);
return self.parse_orders(data.clone(), &[market.clone(), since.clone(), limit.clone(), params.clone()]);
}
Value::Null
}
/*
* @method
* @name mexc#fetchClosedOrders
* @description fetches information on multiple closed orders made by the user
* @see https://www.mexc.com/api-docs/spot-v3/spot-account-trade/all-orders // spot
* @see https://www.mexc.com/api-docs/futures/account-and-trading-endpoints/get-all-historical-orders // swap
* @see https://www.mexc.com/api-docs/futures/account-and-trading-endpoints/get-plan-order-list // swap trigger
* @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
* @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
}));
return self.fetch_orders_by_state(Value::Int(3), &[symbol.clone(), since.clone(), limit.clone(), params.clone()]).await;
Value::Null
}
/*
* @method
* @name mexc#fetchCanceledOrders
* @description fetches information on multiple canceled orders made by the user
* @see https://www.mexc.com/api-docs/spot-v3/spot-account-trade/all-orders // spot
* @see https://www.mexc.com/api-docs/futures/account-and-trading-endpoints/get-all-historical-orders // swap
* @see https://www.mexc.com/api-docs/futures/account-and-trading-endpoints/get-plan-order-list // swap trigger
* @param {string} symbol unified market symbol of the market orders were made in
* @param {int} [since] timestamp in ms of the earliest order, default is undefined
* @param {int} [limit] max number of orders to return, default is undefined
* @param {object} [params] extra parameters specific to the exchange API endpoint
* @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
}));
return self.fetch_orders_by_state(Value::Int(4), &[symbol.clone(), since.clone(), limit.clone(), params.clone()]).await;
Value::Null
}
pub async fn fetch_orders_by_state(&mut self, mut state: 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(&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;
if !is_equal(&symbol, &Value::Null) {
market = self.market(symbol.clone());
}
let mut marketTypeVariable = self.handle_market_type_and_params(Value::Str("fetchOrdersByState".to_string()), &[market.clone(), params.clone()]);
let mut marketType: Value = get_value(&marketTypeVariable, &Value::Int(0));
if is_equal(&marketType, &Value::Str("spot".to_string())) {
panic!("{}", crate::exchange_errors::not_supported(add(&add(&self.id, &Value::Str(" fetchOrdersByState() is not supported for ".to_string())), &marketType)));
} else {
add_element_to_object(&mut request, &Value::Str("states".to_string()), state.clone());
let __ws_arg_29 = self.extend(request.clone(), &[params.clone()]);
return self.fetch_orders(&[symbol.clone(), since.clone(), limit.clone(), __ws_arg_29]).await;
}
Value::Null
}
/*
* @method
* @name mexc#cancelOrder
* @description cancels an open order
* @see https://www.mexc.com/api-docs/spot-v3/spot-account-trade/cancel-order // spot
* @see https://www.mexc.com/api-docs/futures/account-and-trading-endpoints/cancel-orders // swap
* @see https://www.mexc.com/api-docs/futures/account-and-trading-endpoints/cancel-planned-orders // swap trigger
* @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 {string} [params.marginMode] only 'isolated' is supported for spot-margin trading
* @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;
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())));
}
let mut marketType: Value = Value::Null;
{ let __destr_tmp = self.handle_market_type_and_params(Value::Str("cancelOrder".to_string()), &[market.clone(), params.clone()]); marketType = get_value(&__destr_tmp, &Value::Int(0)); params = get_value(&__destr_tmp, &Value::Int(1)); }
let mut marginModequeryVariable = self.handle_margin_mode_and_params(Value::Str("cancelOrder".to_string()), &[params.clone()]);
let mut marginMode: Value = get_value(&marginModequeryVariable, &Value::Int(0));
let mut query: Value = get_value(&marginModequeryVariable, &Value::Int(1));
let mut data: Value = Value::Null;
if is_equal(&marketType, &Value::Str("spot".to_string())) {
if is_equal(&symbol, &Value::Null) {
panic!("{}", crate::exchange_errors::arguments_required(add(&self.id, &Value::Str(" cancelOrder() requires a symbol argument".to_string()))));
}
let mut requestInner: Value = Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("symbol".to_string(), self.safe_string_k(market.clone(), "id", &[]));
m
});
let mut clientOrderId: Value = self.safe_string_k(params.clone(), "clientOrderId", &[]);
if !is_equal(&clientOrderId, &Value::Null) {
params = self.omit(query.clone(), Value::Str("clientOrderId".to_string()), &[]);
add_element_to_object(&mut requestInner, &Value::Str("origClientOrderId".to_string()), clientOrderId.clone());
} else {
add_element_to_object(&mut requestInner, &Value::Str("orderId".to_string()), id.clone());
}
if !is_equal(&marginMode, &Value::Null) {
if !is_equal(&marginMode, &Value::Str("isolated".to_string())) {
panic!("{}", crate::exchange_errors::bad_request(add(&add(&add(&self.id, &Value::Str(" cancelOrder() does not support marginMode ".to_string())), &marginMode), &Value::Str(" for spot-margin trading".to_string()))));
}
let __ws_arg_30 = self.extend(requestInner.clone(), &[query.clone()]);
data = self.spot_private_delete_margin_order(&[__ws_arg_30]).await;
} else {
let __ws_arg_31 = self.extend(requestInner.clone(), &[query.clone()]);
data = self.spot_private_delete_order(&[__ws_arg_31]).await;
}
} else {
// TODO: PlanorderCancel endpoint has bug atm. waiting for fix.
let mut method: Value = self.safe_string_k(self.options.clone(), "cancelOrder", &[Value::Str("contractPrivatePostOrderCancel".to_string())]); // contractPrivatePostOrderCancel, contractPrivatePostPlanorderCancel
method = self.safe_string_k(query.clone(), "method", &[method.clone()]);
let mut response: Value = Value::Null;
if is_equal(&method, &Value::Str("contractPrivatePostOrderCancel".to_string())) {
response = self.contract_private_post_order_cancel(&[Value::List(vec![id.clone()])]).await; // the request cannot be changed or extended. This is the only way to send.
} else if is_equal(&method, &Value::Str("contractPrivatePostPlanorderCancel".to_string())) {
response = self.contract_private_post_planorder_cancel(&[Value::List(vec![id.clone()])]).await; // the request cannot be changed or extended. This is the only way to send.
} else {
panic!("{}", crate::exchange_errors::not_supported(add(&self.id, &Value::Str(" cancelOrder() not support this method".to_string()))));
}
//
// {
// "success": true,
// "code": "0",
// "data": [
// {
// "orderId": "264995729269765120",
// "errorCode": "0", // if already canceled: "2041"; if doesn't exist: "2040"
// "errorMsg": "success", // if already canceled: "order state cannot be cancelled"; if doesn't exist: "order not exist"
// }
// ]
// }
//
data = self.safe_value_k(response.clone(), "data", &[]);
let mut order: Value = self.safe_value(data.clone(), Value::Int(0), &[]);
let mut errorMsg: Value = self.safe_value_k(order.clone(), "errorMsg", &[Value::Str("".to_string())]);
if !is_equal(&errorMsg, &Value::Str("success".to_string())) {
panic!("{}", crate::exchange_errors::invalid_order(add(&add(&add(&add(&self.id, &Value::Str(" cancelOrder() the order with id ".to_string())), &id), &Value::Str(" cannot be cancelled: ".to_string())), &errorMsg)));
}
}
return self.parse_order(data.clone(), &[market.clone()]);
Value::Null
}
/*
* @method
* @name mexc#cancelOrders
* @description cancel multiple orders
* @see https://www.mexc.com/api-docs/futures/account-and-trading-endpoints/cancel-orders
* @param {string[]} ids order ids
* @param {string} symbol unified market symbol, default is undefined
* @param {object} [params] extra parameters specific to the exchange API endpoint
* @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(&self.markets, &Value::Null) {
self.load_markets(&[]).await;
}
let mut market: Value = ternary(is_true(&(!is_equal(&symbol, &Value::Null))), self.market(symbol.clone()), Value::Null);
let mut marketTypeVariable = self.handle_market_type_and_params(Value::Str("cancelOrders".to_string()), &[market.clone(), params.clone()]);
let mut marketType: Value = get_value(&marketTypeVariable, &Value::Int(0));
if is_equal(&marketType, &Value::Str("spot".to_string())) {
panic!("{}", crate::exchange_errors::bad_request(add(&add(&self.id, &Value::Str(" cancelOrders() is not supported for ".to_string())), &marketType)));
} else {
let mut response: Value = self.contract_private_post_order_cancel(&[ids.clone()]).await; // the request cannot be changed or extended. The only way to send.
//
// {
// "success": true,
// "code": "0",
// "data": [
// {
// "orderId": "264995729269765120",
// "errorCode": "0", // if already canceled: "2041"
// "errorMsg": "success", // if already canceled: "order state cannot be cancelled"
// },
// ]
// }
//
let mut data: Value = self.safe_list_k(response.clone(), "data", &[]);
return self.parse_orders(data.clone(), &[market.clone()]);
}
Value::Null
}
/*
* @method
* @name mexc#cancelAllOrders
* @description cancel all open orders
* @see https://www.mexc.com/api-docs/spot-v3/spot-account-trade/cancel-all-open-orders-on-a-symbol // spot
* @see https://www.mexc.com/api-docs/spot-v3/spot-account-trade/cancel-all-orders // spot all symbols
* @see https://www.mexc.com/api-docs/futures/account-and-trading-endpoints/cancel-all-orders-under-a-contract // swap
* @see https://www.mexc.com/api-docs/futures/account-and-trading-endpoints/cancel-all-planned-orders // swap trigger
* @param {string} [symbol] unified market symbol, only orders in the market of this symbol are cancelled when symbol is not undefined
* @param {object} [params] extra parameters specific to the exchange API endpoint
* @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 market: Value = Value::Null;
if !is_equal(&symbol, &Value::Null) {
market = self.market(symbol.clone());
}
let mut request: Value = Value::Map({
let mut m = indexmap::IndexMap::new();
m
});
let mut marketType: Value = Value::Null;
{ let __destr_tmp = self.handle_market_type_and_params(Value::Str("cancelAllOrders".to_string()), &[market.clone(), params.clone()]); marketType = get_value(&__destr_tmp, &Value::Int(0)); params = get_value(&__destr_tmp, &Value::Int(1)); }
if is_equal(&marketType, &Value::Str("spot".to_string())) {
if is_equal(&symbol, &Value::Null) {
self.spot_private_delete_order_all(&[params.clone()]).await;
return Value::List(vec![]);
}
add_element_to_object(&mut request, &Value::Str("symbol".to_string()), self.safe_string_k(market.clone(), "id", &[]));
let __ws_arg_32 = self.extend(request.clone(), &[params.clone()]);
let mut response: Value = self.spot_private_delete_open_orders(&[__ws_arg_32]).await;
return self.parse_orders(response.clone(), &[market.clone()]);
} else {
if !is_equal(&symbol, &Value::Null) {
add_element_to_object(&mut request, &Value::Str("symbol".to_string()), self.safe_string_k(market.clone(), "id", &[]));
}
// method can be either: contractPrivatePostOrderCancelAll or contractPrivatePostPlanorderCancelAll
// the Planorder endpoints work not only for stop-market orders but also for stop-limit orders that are supposed to have separate endpoint
let mut method: Value = self.safe_string_k(self.options.clone(), "cancelAllOrders", &[Value::Str("contractPrivatePostOrderCancelAll".to_string())]);
method = self.safe_string_k(params.clone(), "method", &[method.clone()]);
let mut response: Value = Value::Map({
let mut m = indexmap::IndexMap::new();
m
});
if is_equal(&method, &Value::Str("contractPrivatePostOrderCancelAll".to_string())) {
let __ws_arg_33 = self.extend(request.clone(), &[params.clone()]);
response = self.contract_private_post_order_cancel_all(&[__ws_arg_33]).await;
} else if is_equal(&method, &Value::Str("contractPrivatePostPlanorderCancelAll".to_string())) {
let __ws_arg_34 = self.extend(request.clone(), &[params.clone()]);
response = self.contract_private_post_planorder_cancel_all(&[__ws_arg_34]).await;
}
//
// {
// "success": true,
// "code": "0"
// }
//
let mut data: Value = self.safe_list_k(response.clone(), "data", &[Value::List(vec![])]);
return self.parse_orders(data.clone(), &[market.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
// createOrder
//
// {
// "symbol": "FARTCOINUSDT",
// "orderId": "C02__342252993005723644225",
// "orderListId": "-1",
// "price": "1.1",
// "origQty": "6.3",
// "type": "IMMEDIATE_OR_CANCEL",
// "side": "SELL",
// "transactTime": "1745852205223"
// }
//
// unknown endpoint on spot
//
// {
// "symbol": "BTCUSDT",
// "orderId": "123738410679123456",
// "orderListId": -1
// }
//
// margin: createOrder
//
// {
// "symbol": "BTCUSDT",
// "orderId": "762634301354414080",
// "clientOrderId": null,
// "isIsolated": true,
// "transactTime": 1661992652132
// }
//
// spot: cancelOrder, cancelAllOrders
//
// {
// "symbol": "BTCUSDT",
// "orderId": "133926441921286144",
// "price": "30000",
// "origQty": "0.0002",
// "type": "LIMIT",
// "side": "BUY"
// }
//
// margin: cancelOrder, cancelAllOrders
//
// {
// "symbol": "BTCUSDT",
// "orderId": "762640232574226432",
// "orderListId": "-1",
// "clientOrderId": null,
// "price": "18000",
// "origQty": "0.00147",
// "executedQty": "0",
// "cummulativeQuoteQty": "0",
// "status": "NEW",
// "type": "LIMIT",
// "side": "BUY",
// "isIsolated": true,
// "isWorking": true,
// "time": 1661994066000,
// "updateTime": 1661994066000
// }
//
// spot: fetchOrder, fetchOpenOrders, fetchOrders
//
// {
// "symbol": "BTCUSDT",
// "orderId": "133734823834147272",
// "orderListId": "-1",
// "clientOrderId": null,
// "price": "30000",
// "origQty": "0.0002",
// "executedQty": "0",
// "cummulativeQuoteQty": "0",
// "status": "CANCELED",
// "timeInForce": null,
// "type": "LIMIT",
// "side": "BUY",
// "stopPrice": null,
// "icebergQty": null,
// "time": "1647667102000",
// "updateTime": "1647708567000",
// "isWorking": true,
// "origQuoteOrderQty": "6"
// }
//
// margin: fetchOrder, fetchOrders
//
// {
// "symbol": "BTCUSDT",
// "orderId": "763307297891028992",
// "orderListId": "-1",
// "clientOrderId": null,
// "price": "18000",
// "origQty": "0.0014",
// "executedQty": "0",
// "cummulativeQuoteQty": "0",
// "status": "NEW",
// "type": "LIMIT",
// "side": "BUY",
// "isIsolated": true,
// "isWorking": true,
// "time": 1662153107000,
// "updateTime": 1662153107000
// }
//
// swap: createOrder
//
// 2ff3163e8617443cb9c6fc19d42b1ca4
//
// swap: fetchOrder, fetchOrders
//
// regular
// {
// "orderId": "264995729269765120",
// "symbol": "STEPN_USDT",
// "positionId": "0",
// "price": "2.2",
// "vol": "15",
// "leverage": "20",
// "side": "1", // TODO: not unified
// "category": "1",
// "orderType": "1", // TODO: not unified
// "dealAvgPrice": "0",
// "dealVol": "0",
// "orderMargin": "2.2528",
// "takerFee": "0",
// "makerFee": "0",
// "profit": "0",
// "feeCurrency": "USDT",
// "openType": "1",
// "state": "2", // TODO
// "externalOid": "_m_0e9520c256744d64b942985189026d20",
// "errorCode": "0",
// "usedMargin": "0",
// "createTime": "1648850305236",
// "updateTime": "1648850305245",
// "positionMode": "1"
// }
//
// stop
// {
// "id": "265557643326564352",
// "triggerType": "1",
// "triggerPrice": "3",
// "price": "2.9", // not present in stop-market, but in stop-limit order
// "executeCycle": "87600",
// "trend": "1",
// // below keys are same as in regular order structure
// "symbol": "STEPN_USDT",
// "leverage": "20",
// "side": "1",
// "vol": "13",
// "openType": "1",
// "state": "1",
// "orderType": "1",
// "errorCode": "0",
// "createTime": "1648984276000",
// "updateTime": "1648984276000",
// }
//
// createOrders error
//
// {
// "newClientOrderId": "123456",
// "msg": "The minimum transaction volume cannot be less than:0.5USDT",
// "code": 30002
// }
//
let mut code: Value = self.safe_integer_k(order.clone(), "code", &[]);
if !is_equal(&code, &Value::Null) {
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.insert("clientOrderId".to_string(), self.safe_string_k(order.clone(), "newClientOrderId", &[]));
m
}), &[]);
}
let mut id: Value = Value::Null;
if is_string(&order) {
id = order.clone();
} else {
id = self.safe_string2(order.clone(), Value::Str("orderId".to_string()), Value::Str("id".to_string()), &[]);
}
let mut timeInForce: Value = self.parse_order_time_in_force(self.safe_string_k(order.clone(), "timeInForce", &[]));
let mut typeRaw: Value = self.safe_string_k(order.clone(), "type", &[]);
if is_equal(&timeInForce, &Value::Null) {
timeInForce = self.get_tif_from_raw_order_type(&[typeRaw.clone()]);
}
let mut marketId: Value = self.safe_string_k(order.clone(), "symbol", &[]);
market = self.safe_market(&[marketId.clone(), market.clone()]);
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("transactTime".to_string())]), &[]);
let mut fee: Value = Value::Null;
let mut feeCurrency: Value = self.safe_string_k(order.clone(), "feeCurrency", &[]);
if !is_equal(&feeCurrency, &Value::Null) {
let mut takerFee: Value = self.safe_string_k(order.clone(), "takerFee", &[]);
let mut makerFee: Value = self.safe_string_k(order.clone(), "makerFee", &[]);
let mut feeSum: Value = crate::precise::Precise::stringAdd(&takerFee, &makerFee);
fee = Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("currency".to_string(), feeCurrency.clone());
m.insert("cost".to_string(), self.parse_number(feeSum.clone(), &[]));
m
});
}
return self.safe_order(Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("id".to_string(), id.clone());
m.insert("clientOrderId".to_string(), self.safe_string_k(order.clone(), "clientOrderId", &[]));
m.insert("timestamp".to_string(), timestamp.clone());
m.insert("datetime".to_string(), self.iso8601(timestamp.clone()));
m.insert("lastTradeTimestamp".to_string(), Value::Null);
m.insert("lastUpdateTimestamp".to_string(), self.safe_integer_k(order.clone(), "updateTime", &[]));
m.insert("status".to_string(), self.parse_order_status(self.safe_string2(order.clone(), Value::Str("status".to_string()), Value::Str("state".to_string()), &[])));
m.insert("symbol".to_string(), get_value(&market, &Value::Str("symbol".to_string())));
m.insert("type".to_string(), self.parse_order_type(typeRaw.clone()));
m.insert("timeInForce".to_string(), timeInForce.clone());
m.insert("side".to_string(), self.parse_order_side(self.safe_string_k(order.clone(), "side", &[])));
m.insert("price".to_string(), self.safe_number_k(order.clone(), "price", &[]));
m.insert("triggerPrice".to_string(), self.safe_number2(order.clone(), Value::Str("stopPrice".to_string()), Value::Str("triggerPrice".to_string()), &[]));
m.insert("average".to_string(), self.safe_number_k(order.clone(), "dealAvgPrice", &[]));
m.insert("amount".to_string(), self.safe_number2(order.clone(), Value::Str("origQty".to_string()), Value::Str("vol".to_string()), &[]));
m.insert("cost".to_string(), self.safe_number_k(order.clone(), "cummulativeQuoteQty", &[]));
m.insert("filled".to_string(), self.safe_number2(order.clone(), Value::Str("executedQty".to_string()), Value::Str("dealVol".to_string()), &[]));
m.insert("remaining".to_string(), Value::Null);
m.insert("fee".to_string(), fee.clone());
m.insert("trades".to_string(), Value::Null);
m.insert("info".to_string(), order.clone());
m
}), &[market.clone()]);
Value::Null
}
pub fn parse_order_side(&self, mut status: Value) -> Value {
let mut statuses: Value = Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("BUY".to_string(), Value::Str("buy".to_string()));
m.insert("SELL".to_string(), Value::Str("sell".to_string()));
m.insert("1".to_string(), Value::Str("buy".to_string()));
m.insert("2".to_string(), Value::Str("sell".to_string()));
m
});
return self.safe_string(statuses.clone(), status.clone(), &[status.clone()]);
Value::Null
}
pub fn parse_order_type(&self, mut status: Value) -> Value {
let mut statuses: Value = Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("MARKET".to_string(), Value::Str("market".to_string()));
m.insert("LIMIT".to_string(), Value::Str("limit".to_string()));
m.insert("LIMIT_MAKER".to_string(), Value::Str("limit".to_string()));
m.insert("IMMEDIATE_OR_CANCEL".to_string(), Value::Str("limit".to_string()));
m.insert("FILL_OR_KILL".to_string(), Value::Str("limit".to_string()));
m
});
return self.safe_string(statuses.clone(), status.clone(), &[status.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("FILLED".to_string(), Value::Str("closed".to_string()));
m.insert("CANCELED".to_string(), Value::Str("canceled".to_string()));
m.insert("PARTIALLY_FILLED".to_string(), Value::Str("open".to_string()));
m.insert("PARTIALLY_CANCELED".to_string(), Value::Str("canceled".to_string()));
m.insert("2".to_string(), Value::Str("open".to_string()));
m.insert("3".to_string(), Value::Str("closed".to_string()));
m.insert("4".to_string(), Value::Str("canceled".to_string()));
m
});
return self.safe_string(statuses.clone(), status.clone(), &[status.clone()]);
Value::Null
}
pub fn parse_order_time_in_force(&self, mut status: Value) -> Value {
let mut statuses: Value = Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("GTC".to_string(), Value::Str("GTC".to_string()));
m.insert("FOK".to_string(), Value::Str("FOK".to_string()));
m.insert("IOC".to_string(), Value::Str("IOC".to_string()));
m
});
return self.safe_string(statuses.clone(), status.clone(), &[status.clone()]);
Value::Null
}
pub fn get_tif_from_raw_order_type(&self, optional_args: &[Value]) -> Value {
let mut orderType = get_arg(optional_args, 0, Value::Null);
let mut statuses: Value = Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("LIMIT".to_string(), Value::Str("GTC".to_string()));
m.insert("LIMIT_MAKER".to_string(), Value::Str("POST_ONLY".to_string()));
m.insert("IMMEDIATE_OR_CANCEL".to_string(), Value::Str("IOC".to_string()));
m.insert("FILL_OR_KILL".to_string(), Value::Str("FOK".to_string()));
m.insert("MARKET".to_string(), Value::Str("IOC".to_string()));
m
});
return self.safe_string(statuses.clone(), orderType.clone(), &[orderType.clone()]);
Value::Null
}
pub async fn fetch_account_helper(&mut self, mut type_var: Value, mut params: Value) -> Value {
if is_equal(&type_var, &Value::Str("spot".to_string())) {
return self.spot_private_get_account(&[params.clone()]).await;
} else if is_equal(&type_var, &Value::Str("swap".to_string())) {
let mut response: Value = self.contract_private_get_account_assets(&[params.clone()]).await;
return Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("balances".to_string(), self.safe_value_k(response.clone(), "data", &[Value::List(vec![])]));
m
});
}
return Value::Null;
Value::Null
}
/*
* @method
* @name mexc#fetchAccounts
* @description fetch all the accounts associated with a profile
* @see https://www.mexc.com/api-docs/spot-v3/spot-account-trade/account-information // spot
* @see https://www.mexc.com/api-docs/futures/account-and-trading-endpoints/get-all-account-assets // swap
* @param {object} [params] extra parameters specific to the exchange API endpoint
* @returns {object} a dictionary of [account structures]{@link https://docs.ccxt.com/?id=account-structure} indexed by the account type
*/
pub async fn fetch_accounts(&mut self, optional_args: &[Value]) -> Value {
let mut params = get_arg(optional_args, 0, Value::Map({
let mut m = indexmap::IndexMap::new();
m
}));
// TODO: is the below endpoints suitable for fetchAccounts?
let mut marketTypequeryVariable = self.handle_market_type_and_params(Value::Str("fetchAccounts".to_string()), &[Value::Null, params.clone()]);
let mut marketType: Value = get_value(&marketTypequeryVariable, &Value::Int(0));
let mut query: Value = get_value(&marketTypequeryVariable, &Value::Int(1));
if is_equal(&self.markets, &Value::Null) {
self.load_markets(&[]).await;
}
let mut response: Value = self.fetch_account_helper(marketType.clone(), query.clone()).await;
let mut data: Value = self.safe_value_k(response.clone(), "balances", &[Value::List(vec![])]);
let mut result: Value = Value::List(vec![]);
{
let mut i: Value = Value::Int(0);
let mut __for_first_938: bool = true;
while { if !__for_first_938 { i = add(&i, &Value::Int(1)); } __for_first_938 = false; is_less_than(&i, &get_array_length(&data)) } {
let mut account: Value = get_value(&data, &i);
let mut account: Value = get_value(&data, &i);
let mut currencyId: Value = self.safe_string2(account.clone(), Value::Str("asset".to_string()), Value::Str("currency".to_string()), &[]);
let mut code: Value = self.safe_currency_code(currencyId.clone(), &[]);
append_to_array(&mut result, Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("id".to_string(), self.safe_string_k(account.clone(), "id", &[]));
m.insert("type".to_string(), self.safe_string_k(account.clone(), "type", &[]));
m.insert("code".to_string(), code.clone());
m.insert("info".to_string(), account.clone());
m
}));
}
}
return result;
Value::Null
}
/*
* @method
* @name mexc#fetchTradingFee
* @description fetch the trading fees for a market
* @see https://www.mexc.com/api-docs/spot-v3/spot-account-trade/query-symbol-commission
* @param {string} symbol unified market symbol
* @param {object} [params] extra parameters specific to the exchange API endpoint
* @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());
if !is_equal(&get_value(&market, &Value::Str("spot".to_string())), &Value::Bool(true)) {
panic!("{}", crate::exchange_errors::bad_request(add(&self.id, &Value::Str(" fetchTradingFee() supports spot 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_35 = self.extend(request.clone(), &[params.clone()]);
let mut response: Value = self.spot_private_get_trade_fee(&[__ws_arg_35]).await;
//
// {
// "data":{
// "makerCommission":0.003000000000000000,
// "takerCommission":0.003000000000000000
// },
// "code":0,
// "msg":"success",
// "timestamp":1669109672717
// }
//
let mut data: Value = self.safe_dict_k(response.clone(), "data", &[Value::Map({
let mut m = indexmap::IndexMap::new();
m
})]);
return Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("info".to_string(), data.clone());
m.insert("symbol".to_string(), symbol.clone());
m.insert("maker".to_string(), self.safe_number_k(data.clone(), "makerCommission", &[]));
m.insert("taker".to_string(), self.safe_number_k(data.clone(), "takerCommission", &[]));
m.insert("percentage".to_string(), Value::Null);
m.insert("tierBased".to_string(), Value::Null);
m
});
Value::Null
}
pub fn custom_parse_balance(&self, mut response: Value, mut marketType: Value) -> Value {
//
// spot
//
// {
// "asset": "USDT",
// "free": "0.000000000674",
// "locked": "0"
// }
//
// swap
//
// {
// "currency": "BSV",
// "positionMargin": 0,
// "availableBalance": 0,
// "cashBalance": 0,
// "frozenBalance": 0,
// "equity": 0,
// "unrealized": 0,
// "bonus": 0
// }
//
// margin
//
// {
// "baseAsset": {
// "asset": "BTC",
// "borrowEnabled": true,
// "borrowed": "0",
// "free": "0",
// "interest": "0",
// "locked": "0",
// "netAsset": "0",
// "netAssetOfBtc": "0",
// "repayEnabled": true,
// "totalAsset": "0"
// }
// "quoteAsset": {
// "asset": "USDT",
// "borrowEnabled": true,
// "borrowed": "0",
// "free": "10",
// "interest": "0",
// "locked": "0",
// "netAsset": "10",
// "netAssetOfBtc": "0",
// "repayEnabled": true,
// "totalAsset": "10"
// }
// "symbol": "BTCUSDT",
// "isolatedCreated": true,
// "enabled": true,
// "marginLevel": "999",
// "marginRatio": "9",
// "indexPrice": "16741.137068965517241379",
// "liquidatePrice": "--",
// "liquidateRate": "--",
// "tradeEnabled": true
// }
//
let mut wallet: Value = Value::Null;
if is_equal(&marketType, &Value::Str("margin".to_string())) {
wallet = self.safe_value_k(response.clone(), "assets", &[Value::List(vec![])]);
} else if is_equal(&marketType, &Value::Str("swap".to_string())) {
wallet = self.safe_value_k(response.clone(), "data", &[Value::List(vec![])]);
} else {
wallet = self.safe_value_k(response.clone(), "balances", &[Value::List(vec![])]);
}
let mut result: Value = Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("info".to_string(), response.clone());
m
});
if is_equal(&marketType, &Value::Str("margin".to_string())) {
{
let mut i: Value = Value::Int(0);
let mut __for_first_939: bool = true;
while { if !__for_first_939 { i = add(&i, &Value::Int(1)); } __for_first_939 = false; is_less_than(&i, &get_array_length(&wallet)) } {
let mut entry: Value = get_value(&wallet, &i);
let mut entry: Value = get_value(&wallet, &i);
let mut base: Value = self.safe_value_k(entry.clone(), "baseAsset", &[Value::Map({
let mut m = indexmap::IndexMap::new();
m
})]);
let mut quote: Value = self.safe_value_k(entry.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()));
}
}
}
return self.safe_balance(result.clone());
} else if is_equal(&marketType, &Value::Str("swap".to_string())) {
{
let mut i: Value = Value::Int(0);
let mut __for_first_940: bool = true;
while { if !__for_first_940 { i = add(&i, &Value::Int(1)); } __for_first_940 = false; is_less_than(&i, &get_array_length(&wallet)) } {
let mut entry: Value = get_value(&wallet, &i);
let mut entry: Value = get_value(&wallet, &i);
let mut currencyId: Value = self.safe_string_k(entry.clone(), "currency", &[]);
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(entry.clone(), "availableBalance", &[]));
add_element_to_object(&mut account, &Value::Str("used".to_string()), self.safe_string_k(entry.clone(), "frozenBalance", &[]));
if !is_equal(&code, &Value::Null) {
add_element_to_object(&mut result, &code, account.clone());
}
}
}
return self.safe_balance(result.clone());
} else {
{
let mut i: Value = Value::Int(0);
let mut __for_first_941: bool = true;
while { if !__for_first_941 { i = add(&i, &Value::Int(1)); } __for_first_941 = false; is_less_than(&i, &get_array_length(&wallet)) } {
let mut entry: Value = get_value(&wallet, &i);
let mut entry: Value = get_value(&wallet, &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();
add_element_to_object(&mut account, &Value::Str("free".to_string()), self.safe_string_k(entry.clone(), "free", &[]));
add_element_to_object(&mut account, &Value::Str("used".to_string()), self.safe_string_k(entry.clone(), "locked", &[]));
if !is_equal(&code, &Value::Null) {
add_element_to_object(&mut result, &code, account.clone());
}
}
}
return self.safe_balance(result.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", &[]));
add_element_to_object(&mut account, &Value::Str("total".to_string()), self.safe_string_k(entry.clone(), "totalAsset", &[]));
let mut debt: Value = self.safe_string_k(entry.clone(), "borrowed", &[]);
let mut interest: Value = self.safe_string_k(entry.clone(), "interest", &[]);
add_element_to_object(&mut account, &Value::Str("debt".to_string()), crate::precise::Precise::stringAdd(&debt, &interest));
return account;
Value::Null
}
/*
* @method
* @name mexc#fetchBalance
* @description query for balance and get the amount of funds available for trading or funds locked in orders
* @see https://www.mexc.com/api-docs/spot-v3/spot-account-trade/account-information // spot
* @see https://www.mexc.com/api-docs/futures/account-and-trading-endpoints/get-all-account-assets // swap
* @see https://mexcdevelop.github.io/apidocs/spot_v3_en/#isolated-account
* @param {object} [params] extra parameters specific to the exchange API endpoint
* @param {string} [params.symbols] // required for margin, market id's separated by commas
* @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 marketType: Value = Value::Null;
let mut request: Value = Value::Map({
let mut m = indexmap::IndexMap::new();
m
});
{ let __destr_tmp = self.handle_market_type_and_params(Value::Str("fetchBalance".to_string()), &[Value::Null, params.clone()]); marketType = get_value(&__destr_tmp, &Value::Int(0)); params = get_value(&__destr_tmp, &Value::Int(1)); }
let mut marginMode: Value = self.safe_string_k(params.clone(), "marginMode", &[]);
let mut isMargin: Value = self.safe_bool_k(params.clone(), "margin", &[Value::Bool(false)]);
params = self.omit(params.clone(), Value::List(vec![Value::Str("margin".to_string()), Value::Str("marginMode".to_string())]), &[]);
let mut response: Value = Value::Null;
if is_true(&(!is_equal(&marginMode, &Value::Null))) || is_true(&(is_equal(&isMargin, &Value::Bool(true)))) || is_true(&(is_equal(&marketType, &Value::Str("margin".to_string())))) {
let mut parsedSymbols: Value = Value::Null;
let mut symbol: Value = self.safe_string_k(params.clone(), "symbol", &[]);
if is_equal(&symbol, &Value::Null) {
let mut symbols: Value = self.safe_value_k(params.clone(), "symbols", &[]);
if !is_equal(&symbols, &Value::Null) {
let mut symbolIds: Value = self.market_ids(&[symbols.clone()]);
if !is_equal(&symbolIds, &Value::Null) {
parsedSymbols = join(&symbolIds, &Value::Str(",".to_string()));
}
}
} else {
let mut market: Value = self.market(symbol.clone());
parsedSymbols = get_value(&market, &Value::Str("id".to_string()));
}
self.check_required_argument(Value::Str("fetchBalance".to_string()), parsedSymbols.clone(), Value::Str("symbol or symbols".to_string()), &[]);
marketType = Value::Str("margin".to_string());
add_element_to_object(&mut request, &Value::Str("symbols".to_string()), parsedSymbols.clone());
params = self.omit(params.clone(), Value::List(vec![Value::Str("symbol".to_string()), Value::Str("symbols".to_string())]), &[]);
let __ws_arg_36 = self.extend(request.clone(), &[params.clone()]);
response = self.spot_private_get_margin_isolated_account(&[__ws_arg_36]).await;
} else if is_equal(&marketType, &Value::Str("spot".to_string())) {
let __ws_arg_37 = self.extend(request.clone(), &[params.clone()]);
response = self.spot_private_get_account(&[__ws_arg_37]).await;
} else if is_equal(&marketType, &Value::Str("swap".to_string())) {
let __ws_arg_38 = self.extend(request.clone(), &[params.clone()]);
response = self.contract_private_get_account_assets(&[__ws_arg_38]).await;
} else {
panic!("{}", crate::exchange_errors::not_supported(add(&self.id, &Value::Str(" fetchBalance() not support this method".to_string()))));
}
return self.custom_parse_balance(response.clone(), marketType.clone());
Value::Null
}
/*
* @method
* @name mexc#fetchMyTrades
* @description fetch all trades made by the user
* @see https://www.mexc.com/api-docs/spot-v3/spot-account-trade/account-trade-list // spot
* @see https://mexcdevelop.github.io/apidocs/contract_v1_en/#get-all-transaction-details-of-the-user-s-order // swap legacy endpoint
* @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 {int} [params.until] the latest time in ms to fetch trades for
* @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(&symbol, &Value::Null) {
panic!("{}", crate::exchange_errors::arguments_required(add(&self.id, &Value::Str(" fetchMyTrades() 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 marketType: Value = Value::Null;
{ let __destr_tmp = self.handle_market_type_and_params(Value::Str("fetchMyTrades".to_string()), &[market.clone(), params.clone()]); marketType = 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 trades: Value = Value::List(vec![]);
if is_equal(&marketType, &Value::Str("spot".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 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 __ws_arg_39 = self.extend(request.clone(), &[params.clone()]);
trades = self.spot_private_get_my_trades(&[__ws_arg_39]).await;
} else {
if !is_equal(&since, &Value::Null) {
add_element_to_object(&mut request, &Value::Str("start_time".to_string()), since.clone());
let mut end: Value = self.safe_integer_k(params.clone(), "end_time", &[]);
if is_equal(&end, &Value::Null) {
add_element_to_object(&mut request, &Value::Str("end_time".to_string()), self.sum(&[since.clone(), get_value(&self.options, &Value::Str("maxTimeTillEnd".to_string()))]));
}
}
if !is_equal(&limit, &Value::Null) {
add_element_to_object(&mut request, &Value::Str("page_size".to_string()), limit.clone());
}
let __ws_arg_40 = self.extend(request.clone(), &[params.clone()]);
let mut response: Value = self.contract_private_get_order_list_order_deals(&[__ws_arg_40]).await;
//
// {
// "success": true,
// "code": "0",
// "data": [
// {
// "id": "299444585",
// "symbol": "STEPN_USDT",
// "side": "1",
// "vol": "1",
// "price": "2.45455",
// "feeCurrency": "USDT",
// "fee": "0.00147273",
// "timestamp": "1648924557000",
// "profit": "0",
// "category": "1",
// "orderId": "265307163526610432",
// "positionMode": "1",
// "taker": true
// }
// ]
// }
//
trades = self.safe_list_k(response.clone(), "data", &[Value::List(vec![])]);
}
return self.parse_trades(trades.clone(), &[market.clone(), since.clone(), limit.clone()]);
Value::Null
}
/*
* @method
* @name mexc#fetchOrderTrades
* @description fetch all the trades made from a single order
* @see https://www.mexc.com/api-docs/spot-v3/spot-account-trade/account-trade-list // spot
* @see https://www.mexc.com/api-docs/futures/account-and-trading-endpoints/get-trade-records-by-order-id // swap
* @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(&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;
if !is_equal(&symbol, &Value::Null) {
market = self.market(symbol.clone());
}
let mut marketTypequeryVariable = self.handle_market_type_and_params(Value::Str("fetchOrderTrades".to_string()), &[market.clone(), params.clone()]);
let mut marketType: Value = get_value(&marketTypequeryVariable, &Value::Int(0));
let mut query: Value = get_value(&marketTypequeryVariable, &Value::Int(1));
let mut trades: Value = Value::List(vec![]);
if is_equal(&marketType, &Value::Str("spot".to_string())) {
if is_equal(&symbol, &Value::Null) {
panic!("{}", crate::exchange_errors::arguments_required(add(&self.id, &Value::Str(" fetchOrderTrades() requires a symbol argument".to_string()))));
}
add_element_to_object(&mut request, &Value::Str("symbol".to_string()), self.safe_string_k(market.clone(), "id", &[]));
add_element_to_object(&mut request, &Value::Str("orderId".to_string()), id.clone());
let __ws_arg_41 = self.extend(request.clone(), &[query.clone()]);
trades = self.spot_private_get_my_trades(&[__ws_arg_41]).await;
} else {
add_element_to_object(&mut request, &Value::Str("order_id".to_string()), id.clone());
let __ws_arg_42 = self.extend(request.clone(), &[query.clone()]);
let mut response: Value = self.contract_private_get_order_deal_details_order_id(&[__ws_arg_42]).await;
//
// {
// "success": true,
// "code": "0",
// "data": [
// {
// "id": "299444585",
// "symbol": "STEPN_USDT",
// "side": "1",
// "vol": "1",
// "price": "2.45455",
// "feeCurrency": "USDT",
// "fee": "0.00147273",
// "timestamp": "1648924557000",
// "profit": "0",
// "category": "1",
// "orderId": "265307163526610432",
// "positionMode": "1",
// "taker": true
// }
// ]
// }
//
trades = self.safe_list_k(response.clone(), "data", &[Value::List(vec![])]);
}
return self.parse_trades(trades.clone(), &[market.clone(), since.clone(), limit.clone(), query.clone()]);
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
}));
let mut positionId: Value = self.safe_integer_k(params.clone(), "positionId", &[]);
if is_equal(&positionId, &Value::Null) {
panic!("{}", crate::exchange_errors::arguments_required(add(&self.id, &Value::Str(" modifyMarginHelper() requires a positionId parameter".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("positionId".to_string(), positionId.clone());
m.insert("amount".to_string(), amount.clone());
m.insert("type".to_string(), addOrReduce.clone());
m
});
let __ws_arg_43 = self.extend(request.clone(), &[params.clone()]);
let mut response: Value = self.contract_private_post_position_change_margin(&[__ws_arg_43]).await;
return response;
Value::Null
}
/*
* @method
* @name mexc#reduceMargin
* @description remove margin from a position
* @see https://www.mexc.com/api-docs/futures/account-and-trading-endpoints/modify-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::Str("SUB".to_string()), &[params.clone()]).await;
Value::Null
}
/*
* @method
* @name mexc#addMargin
* @description add margin
* @see https://www.mexc.com/api-docs/futures/account-and-trading-endpoints/modify-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::Str("ADD".to_string()), &[params.clone()]).await;
Value::Null
}
/*
* @method
* @name mexc#setLeverage
* @description set the level of leverage for a market
* @see https://www.mexc.com/api-docs/futures/account-and-trading-endpoints/modify-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
* @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(&self.markets, &Value::Null) {
self.load_markets(&[]).await;
}
let mut request: Value = Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("leverage".to_string(), leverage.clone());
m
});
let mut positionId: Value = self.safe_integer_k(params.clone(), "positionId", &[]);
if is_equal(&positionId, &Value::Null) {
let mut openType: Value = self.safe_number_k(params.clone(), "openType", &[]); // 1 or 2
let mut positionType: Value = self.safe_number_k(params.clone(), "positionType", &[]); // 1 or 2
let mut market: Value = ternary(is_true(&(!is_equal(&symbol, &Value::Null))), self.market(symbol.clone()), Value::Null);
if is_true(&(is_equal(&openType, &Value::Null))) || is_true(&(is_equal(&positionType, &Value::Null))) || is_true(&(is_equal(&market, &Value::Null))) {
panic!("{}", crate::exchange_errors::arguments_required(add(&self.id, &Value::Str(" setLeverage() requires a positionId parameter or a symbol argument with openType and positionType parameters, use openType 1 or 2 for isolated or cross margin respectively, use positionType 1 or 2 for long or short positions".to_string()))));
} else {
add_element_to_object(&mut request, &Value::Str("openType".to_string()), openType.clone());
add_element_to_object(&mut request, &Value::Str("symbol".to_string()), get_value(&market, &Value::Str("id".to_string())));
add_element_to_object(&mut request, &Value::Str("positionType".to_string()), positionType.clone());
}
} else {
add_element_to_object(&mut request, &Value::Str("positionId".to_string()), positionId.clone());
}
let __ws_arg_44 = self.extend(request.clone(), &[params.clone()]);
return self.contract_private_post_position_change_leverage(&[__ws_arg_44]).await;
Value::Null
}
/*
* @method
* @name mexc#fetchFundingHistory
* @description fetch the history of funding payments paid and received on this account
* @see https://www.mexc.com/api-docs/futures/account-and-trading-endpoints/get-funding-fee-details
* @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
* @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
});
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(&limit, &Value::Null) {
add_element_to_object(&mut request, &Value::Str("page_size".to_string()), limit.clone());
}
let __ws_arg_45 = self.extend(request.clone(), &[params.clone()]);
let mut response: Value = self.contract_private_get_position_funding_records(&[__ws_arg_45]).await;
//
// {
// "success": true,
// "code": 0,
// "data": {
// "pageSize": 20,
// "totalCount": 2,
// "totalPage": 1,
// "currentPage": 1,
// "resultList": [
// {
// "id": 7423910,
// "symbol": "BTC_USDT",
// "positionType": 1,
// "positionValue": 29.30024,
// "funding": 0.00076180624,
// "rate": -0.000026,
// "settleTime": 1643299200000
// },
// {
// "id": 7416473,
// "symbol": "BTC_USDT",
// "positionType": 1,
// "positionValue": 28.9188,
// "funding": 0.0014748588,
// "rate": -0.000051,
// "settleTime": 1643270400000
// }
// ]
// }
// }
//
let mut data: Value = self.safe_value_k(response.clone(), "data", &[Value::Map({
let mut m = indexmap::IndexMap::new();
m
})]);
let mut resultList: Value = self.safe_value_k(data.clone(), "resultList", &[Value::List(vec![])]);
let mut result: Value = Value::List(vec![]);
{
let mut i: Value = Value::Int(0);
let mut __for_first_942: bool = true;
while { if !__for_first_942 { i = add(&i, &Value::Int(1)); } __for_first_942 = false; is_less_than(&i, &get_array_length(&resultList)) } {
let mut entry: Value = get_value(&resultList, &i);
let mut entry: Value = get_value(&resultList, &i);
let mut timestamp: Value = self.safe_integer_k(entry.clone(), "settleTime", &[]);
append_to_array(&mut result, Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("info".to_string(), entry.clone());
m.insert("symbol".to_string(), symbol.clone());
m.insert("code".to_string(), Value::Null);
m.insert("timestamp".to_string(), timestamp.clone());
m.insert("datetime".to_string(), self.iso8601(timestamp.clone()));
m.insert("id".to_string(), self.safe_number_k(entry.clone(), "id", &[]));
m.insert("amount".to_string(), self.safe_number_k(entry.clone(), "funding", &[]));
m
}));
}
}
return result;
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);
//
// {
// "symbol": "BTC_USDT",
// "fundingRate": 0.000014,
// "maxFundingRate": 0.003,
// "minFundingRate": -0.003,
// "collectCycle": 8,
// "nextSettleTime": 1643241600000,
// "timestamp": 1643240373359
// }
//
// watchFundingRate
//
// {
// "symbol": "BTC_USDT",
// "rate": -0.000021,
// "nextSettleTime": 1771084800000
// }
//
let mut nextFundingRate: Value = self.safe_number2(contract.clone(), Value::Str("fundingRate".to_string()), Value::Str("rate".to_string()), &[]);
let mut nextFundingTimestamp: Value = self.safe_integer_k(contract.clone(), "nextSettleTime", &[]);
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 timestamp: Value = self.safe_integer_k(contract.clone(), "timestamp", &[]);
let mut interval: Value = self.safe_string_k(contract.clone(), "collectCycle", &[]);
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(), Value::Null);
m.insert("indexPrice".to_string(), Value::Null);
m.insert("interestRate".to_string(), Value::Null);
m.insert("estimatedSettlePrice".to_string(), Value::Null);
m.insert("timestamp".to_string(), timestamp.clone());
m.insert("datetime".to_string(), self.iso8601(timestamp.clone()));
m.insert("fundingRate".to_string(), nextFundingRate.clone());
m.insert("fundingTimestamp".to_string(), nextFundingTimestamp.clone());
m.insert("fundingDatetime".to_string(), self.iso8601(nextFundingTimestamp.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
}
/*
* @method
* @name mexc#fetchFundingInterval
* @description fetch the current funding rate interval
* @see https://www.mexc.com/api-docs/futures/market-endpoints/get-funding-rate
* @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_interval(&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
}));
return self.fetch_funding_rate(symbol.clone(), &[params.clone()]).await;
Value::Null
}
/*
* @method
* @name mexc#fetchFundingRate
* @description fetch the current funding rate
* @see https://www.mexc.com/api-docs/futures/market-endpoints/get-funding-rate
* @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 __ws_arg_46 = self.extend(request.clone(), &[params.clone()]);
let mut response: Value = self.contract_public_get_funding_rate_symbol(&[__ws_arg_46]).await;
//
// {
// "success": true,
// "code": 0,
// "data": {
// "symbol": "BTC_USDT",
// "fundingRate": 0.000014,
// "maxFundingRate": 0.003,
// "minFundingRate": -0.003,
// "collectCycle": 8,
// "nextSettleTime": 1643241600000,
// "timestamp": 1643240373359
// }
// }
//
let mut result: Value = self.safe_value_k(response.clone(), "data", &[Value::Map({
let mut m = indexmap::IndexMap::new();
m
})]);
return self.parse_funding_rate(result.clone(), &[market.clone()]);
Value::Null
}
/*
* @method
* @name mexc#fetchFundingRateHistory
* @description fetches historical funding rate prices
* @see https://www.mexc.com/api-docs/futures/market-endpoints/get-funding-rate-history
* @param {string} symbol unified symbol of the market to fetch the funding rate history for
* @param {int} [since] not used by mexc, but filtered internally by ccxt
* @param {int} [limit] mexc limit is page_size default 20, maximum is 100
* @param {object} [params] extra parameters specific to the exchange API endpoint
* @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(&symbol, &Value::Null) {
panic!("{}", crate::exchange_errors::arguments_required(add(&self.id, &Value::Str(" fetchFundingRateHistory() 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
});
if !is_equal(&limit, &Value::Null) {
add_element_to_object(&mut request, &Value::Str("page_size".to_string()), limit.clone());
}
let __ws_arg_47 = self.extend(request.clone(), &[params.clone()]);
let mut response: Value = self.contract_public_get_funding_rate_history(&[__ws_arg_47]).await;
//
// {
// "success": true,
// "code": 0,
// "data": {
// "pageSize": 2,
// "totalCount": 21,
// "totalPage": 11,
// "currentPage": 1,
// "resultList": [
// {
// "symbol": "BTC_USDT",
// "fundingRate": 0.000266,
// "settleTime": 1609804800000
// },
// {
// "symbol": "BTC_USDT",
// "fundingRate": 0.00029,
// "settleTime": 1609776000000
// }
// ]
// }
// }
//
let mut data: Value = self.safe_value_k(response.clone(), "data", &[]);
let mut result: Value = self.safe_value_k(data.clone(), "resultList", &[Value::List(vec![])]);
let mut rates: Value = Value::List(vec![]);
{
let mut i: Value = Value::Int(0);
let mut __for_first_943: bool = true;
while { if !__for_first_943 { i = add(&i, &Value::Int(1)); } __for_first_943 = false; is_less_than(&i, &get_array_length(&result)) } {
let mut entry: Value = get_value(&result, &i);
let mut entry: Value = get_value(&result, &i);
let mut marketId: Value = self.safe_string_k(entry.clone(), "symbol", &[]);
let mut symbolInner: Value = self.safe_symbol(marketId.clone(), &[]);
let mut timestamp: Value = self.safe_integer_k(entry.clone(), "settleTime", &[]);
append_to_array(&mut rates, Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("info".to_string(), entry.clone());
m.insert("symbol".to_string(), symbolInner.clone());
m.insert("fundingRate".to_string(), self.safe_number_k(entry.clone(), "fundingRate", &[]));
m.insert("timestamp".to_string(), timestamp.clone());
m.insert("datetime".to_string(), self.iso8601(timestamp.clone()));
m
}));
}
}
let mut sorted: Value = self.sort_by(rates.clone(), Value::Str("timestamp".to_string()), &[]);
return self.filter_by_symbol_since_limit(sorted.clone(), &[get_value(&market, &Value::Str("symbol".to_string())), since.clone(), limit.clone()]);
Value::Null
}
/*
* @method
* @name mexc#fetchLeverageTiers
* @description retrieve information on the maximum leverage, and maintenance margin for trades of varying trade sizes, if a market has a leverage tier of 0, then the leverage tiers cannot be obtained for this market
* @see https://www.mexc.com/api-docs/futures/market-endpoints/get-contract-info
* @param {string[]} [symbols] list of unified market symbols
* @param {object} [params] extra parameters specific to the exchange API endpoint
* @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;
}
symbols = self.market_symbols(&[symbols.clone(), Value::Str("swap".to_string()), Value::Bool(true), Value::Bool(true)]);
let mut response: Value = self.contract_public_get_detail(&[params.clone()]).await;
//
// {
// "success":true,
// "code":0,
// "data":[
// {
// "symbol": "BTC_USDT",
// "displayName": "BTC_USDT永续",
// "displayNameEn": "BTC_USDT SWAP",
// "positionOpenType": 3,
// "baseCoin": "BTC",
// "quoteCoin": "USDT",
// "settleCoin": "USDT",
// "contractSize": 0.0001,
// "minLeverage": 1,
// "maxLeverage": 125,
// "priceScale": 2,
// "volScale": 0,
// "amountScale": 4,
// "priceUnit": 0.5,
// "volUnit": 1,
// "minVol": 1,
// "maxVol": 1000000,
// "bidLimitPriceRate": 0.1,
// "askLimitPriceRate": 0.1,
// "takerFeeRate": 0.0006,
// "makerFeeRate": 0.0002,
// "maintenanceMarginRate": 0.004,
// "initialMarginRate": 0.008,
// "riskBaseVol": 10000,
// "riskIncrVol": 200000,
// "riskIncrMmr": 0.004,
// "riskIncrImr": 0.004,
// "riskLevelLimit": 5,
// "priceCoefficientVariation": 0.1,
// "indexOrigin": ["BINANCE","GATEIO","HUOBI","MXC"],
// "state": 0, // 0 enabled, 1 delivery, 2 completed, 3 offline, 4 pause
// "isNew": false,
// "isHot": true,
// "isHidden": false
// },
// ...
// ]
// }
//
let mut data: Value = self.safe_list_k(response.clone(), "data", &[]);
return self.parse_leverage_tiers(data.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);
//
// {
// "symbol": "BTC_USDT",
// "displayName": "BTC_USDT永续",
// "displayNameEn": "BTC_USDT SWAP",
// "positionOpenType": 3,
// "baseCoin": "BTC",
// "quoteCoin": "USDT",
// "settleCoin": "USDT",
// "contractSize": 0.0001,
// "minLeverage": 1,
// "maxLeverage": 125,
// "priceScale": 2,
// "volScale": 0,
// "amountScale": 4,
// "priceUnit": 0.5,
// "volUnit": 1,
// "minVol": 1,
// "maxVol": 1000000,
// "bidLimitPriceRate": 0.1,
// "askLimitPriceRate": 0.1,
// "takerFeeRate": 0.0006,
// "makerFeeRate": 0.0002,
// "maintenanceMarginRate": 0.004,
// "initialMarginRate": 0.008,
// "riskBaseVol": 10000,
// "riskIncrVol": 200000,
// "riskIncrMmr": 0.004,
// "riskIncrImr": 0.004,
// "riskLevelLimit": 5,
// "priceCoefficientVariation": 0.1,
// "indexOrigin": ["BINANCE","GATEIO","HUOBI","MXC"],
// "state": 0, // 0 enabled, 1 delivery, 2 completed, 3 offline, 4 pause
// "isNew": false,
// "isHot": true,
// "isHidden": false
// }
//
let mut marketId: Value = self.safe_string_k(info.clone(), "symbol", &[]);
let mut maintenanceMarginRate: Value = self.safe_string_k(info.clone(), "maintenanceMarginRate", &[]);
let mut initialMarginRate: Value = self.safe_string_k(info.clone(), "initialMarginRate", &[]);
let mut maxVol: Value = self.safe_string_k(info.clone(), "maxVol", &[]);
let mut riskIncrVol: Value = self.safe_string_k(info.clone(), "riskIncrVol", &[]);
let mut riskIncrMmr: Value = self.safe_string_k(info.clone(), "riskIncrMmr", &[]);
let mut riskIncrImr: Value = self.safe_string_k(info.clone(), "riskIncrImr", &[]);
let mut floor: Value = Value::Str("0".to_string());
let mut tiers: Value = Value::List(vec![]);
let mut quoteId: Value = self.safe_string_k(info.clone(), "quoteCoin", &[]);
if is_equal(&riskIncrVol, &Value::Str("0".to_string())) {
return Value::List(vec![Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("tier".to_string(), Value::Int(0));
m.insert("symbol".to_string(), self.safe_symbol(marketId.clone(), &[market.clone(), Value::Null, Value::Str("contract".to_string())]));
m.insert("currency".to_string(), self.safe_currency_code(quoteId.clone(), &[]));
m.insert("minNotional".to_string(), Value::Null);
m.insert("maxNotional".to_string(), Value::Null);
m.insert("maintenanceMarginRate".to_string(), Value::Null);
m.insert("maxLeverage".to_string(), self.safe_number_k(info.clone(), "maxLeverage", &[]));
m.insert("info".to_string(), info.clone());
m
})]);
}
while is_true(&crate::precise::Precise::stringLt(&floor, &maxVol)) {
let mut cap: Value = crate::precise::Precise::stringAdd(&floor, &riskIncrVol);
let mut minNotional: Value = self.parse_number(floor.clone(), &[]);
let mut mainMarginRate: Value = self.parse_number(maintenanceMarginRate.clone(), &[]);
let mut maxLev: Value = self.parse_number(crate::precise::Precise::stringDiv(&Value::Str("1".to_string()), &initialMarginRate), &[]);
append_to_array(&mut tiers, Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("tier".to_string(), self.parse_number(crate::precise::Precise::stringDiv(&cap, &riskIncrVol), &[]));
m.insert("symbol".to_string(), self.safe_symbol(marketId.clone(), &[market.clone(), Value::Null, Value::Str("contract".to_string())]));
m.insert("currency".to_string(), self.safe_currency_code(quoteId.clone(), &[]));
m.insert("minNotional".to_string(), minNotional.clone());
m.insert("maxNotional".to_string(), self.parse_number(cap.clone(), &[]));
m.insert("maintenanceMarginRate".to_string(), mainMarginRate.clone());
m.insert("maxLeverage".to_string(), maxLev.clone());
m.insert("info".to_string(), info.clone());
m
}));
initialMarginRate = crate::precise::Precise::stringAdd(&initialMarginRate, &riskIncrImr);
maintenanceMarginRate = crate::precise::Precise::stringAdd(&maintenanceMarginRate, &riskIncrMmr);
floor = cap.clone();
}
return tiers;
Value::Null
}
pub fn parse_deposit_address(&self, mut depositAddress: Value, optional_args: &[Value]) -> Value {
let mut currency = get_arg(optional_args, 0, Value::Null);
//
// {
// coin: "USDT",
// network: "BNB Smart Chain(BEP20)",
// address: "0x0d48003e0c27c5de62b97c9b4cdb31fdd29da619",
// memo: null
// }
//
let mut address: Value = self.safe_string_k(depositAddress.clone(), "address", &[]);
let mut currencyId: Value = self.safe_string_k(depositAddress.clone(), "coin", &[]);
let mut code: Value = self.safe_currency_code(currencyId.clone(), &[currency.clone()]);
let mut networkId: Value = self.safe_string_k(depositAddress.clone(), "netWork", &[]);
return Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("info".to_string(), depositAddress.clone());
m.insert("currency".to_string(), code.clone());
m.insert("network".to_string(), self.network_id_to_code(&[networkId.clone(), code.clone()]));
m.insert("address".to_string(), address.clone());
m.insert("tag".to_string(), self.safe_string_k(depositAddress.clone(), "memo", &[]));
m
});
Value::Null
}
/*
* @method
* @name mexc#fetchDepositAddressesByNetwork
* @description fetch a dictionary of addresses for a currency, indexed by network
* @see https://www.mexc.com/api-docs/spot-v3/wallet-endpoints/deposit-address-supporting-network
* @param {string} code unified currency code of the currency for the deposit address
* @param {object} [params] extra parameters specific to the exchange API endpoint
* @returns {object} a dictionary of [address structures]{@link https://docs.ccxt.com/?id=address-structure} indexed by the network
*/
pub async fn fetch_deposit_addresses_by_network(&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 = self.safe_string_k(params.clone(), "network", &[]);
let mut networkId: Value = Value::Null;
if !is_equal(&networkCode, &Value::Null) {
// createDepositAddress and fetchDepositAddress use a different network-id compared to withdraw
let mut networkUnified: Value = self.network_id_to_code(&[networkCode.clone(), code.clone()]);
let mut networks: Value = self.safe_dict_k(currency.clone(), "networks", &[Value::Map({
let mut m = indexmap::IndexMap::new();
m
})]);
if is_true(&(!is_equal(&networkUnified, &Value::Null))) && is_true(&(Value::Bool(in_op(&networks, &networkUnified)))) {
let mut network: Value = ternary(is_true(&(is_equal(&networkUnified, &Value::Null))), Value::Map({
let mut m = indexmap::IndexMap::new();
m
}), self.safe_dict(networks.clone(), networkUnified.clone(), &[Value::Map({
let mut m = indexmap::IndexMap::new();
m
})]));
let mut networkInfo: Value = self.safe_value_k(network.clone(), "info", &[Value::Map({
let mut m = indexmap::IndexMap::new();
m
})]);
networkId = self.safe_string_k(networkInfo.clone(), "network", &[]);
} else {
networkId = self.network_code_to_id(networkCode.clone(), &[code.clone()]);
}
}
if !is_equal(&networkId, &Value::Null) {
add_element_to_object(&mut request, &Value::Str("network".to_string()), networkId.clone());
}
params = self.omit(params.clone(), Value::Str("network".to_string()), &[]);
let __ws_arg_48 = self.extend(request.clone(), &[params.clone()]);
let mut response: Value = self.spot_private_get_capital_deposit_address(&[__ws_arg_48]).await;
//
// [
// {
// coin: "USDT",
// network: "BNB Smart Chain(BEP20)",
// address: "0x0d48003e0c27c5de62b97c9b4cdb31fdd29da619",
// memo: null
// }
// ...
// ]
//
let mut addressStructures: Value = self.parse_deposit_addresses(response.clone(), &[Value::Null, Value::Bool(false)]);
return self.index_by(addressStructures.clone(), Value::Str("network".to_string()));
Value::Null
}
/*
* @method
* @name mexc#createDepositAddress
* @description create a currency deposit address
* @see https://www.mexc.com/api-docs/spot-v3/wallet-endpoints/generate-deposit-address-supporting-network
* @param {string} code unified currency code of the currency for the deposit address
* @param {object} [params] extra parameters specific to the exchange API endpoint
* @param {string} [params.network] the blockchain network name
* @returns {object} an [address structure]{@link https://docs.ccxt.com/?id=address-structure}
*/
pub async fn create_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 = self.safe_string_k(params.clone(), "network", &[]);
if is_equal(&networkCode, &Value::Null) {
panic!("{}", crate::exchange_errors::arguments_required(add(&self.id, &Value::Str(" createDepositAddress requires a `network` parameter".to_string()))));
}
// createDepositAddress and fetchDepositAddress use a different network-id compared to withdraw
let mut networkId: Value = Value::Null;
let mut networkUnified: Value = self.network_id_to_code(&[networkCode.clone(), code.clone()]);
let mut networks: Value = self.safe_dict_k(currency.clone(), "networks", &[Value::Map({
let mut m = indexmap::IndexMap::new();
m
})]);
if is_true(&(!is_equal(&networkUnified, &Value::Null))) && is_true(&(Value::Bool(in_op(&networks, &networkUnified)))) {
let mut network: Value = ternary(is_true(&(is_equal(&networkUnified, &Value::Null))), Value::Map({
let mut m = indexmap::IndexMap::new();
m
}), self.safe_dict(networks.clone(), networkUnified.clone(), &[Value::Map({
let mut m = indexmap::IndexMap::new();
m
})]));
let mut networkInfo: Value = self.safe_value_k(network.clone(), "info", &[Value::Map({
let mut m = indexmap::IndexMap::new();
m
})]);
networkId = self.safe_string_k(networkInfo.clone(), "network", &[]);
} else {
networkId = self.network_code_to_id(networkCode.clone(), &[code.clone()]);
}
if !is_equal(&networkId, &Value::Null) {
add_element_to_object(&mut request, &Value::Str("network".to_string()), networkId.clone());
}
params = self.omit(params.clone(), Value::Str("network".to_string()), &[]);
let __ws_arg_49 = self.extend(request.clone(), &[params.clone()]);
let mut response: Value = self.spot_private_post_capital_deposit_address(&[__ws_arg_49]).await;
return self.parse_deposit_address(response.clone(), &[currency.clone()]);
Value::Null
}
/*
* @method
* @name mexc#fetchDepositAddress
* @description fetch the deposit address for a currency associated with this account
* @see https://www.mexc.com/api-docs/spot-v3/wallet-endpoints/deposit-address-supporting-network
* @param {string} code unified currency code
* @param {object} [params] extra parameters specific to the exchange API endpoint
* @param {string} [params.network] the chain of currency, this only apply for multi-chain currency, and there is no need for single chain currency
* @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
}));
let mut network: Value = self.safe_string_k(params.clone(), "network", &[]);
let mut addressStructures: Value = self.fetch_deposit_addresses_by_network(code.clone(), &[params.clone()]).await;
let mut result: Value = Value::Null;
if !is_equal(&network, &Value::Null) {
let mut netCode: Value = self.network_id_to_code(&[network.clone(), code.clone()]);
result = ternary(is_true(&(is_equal(&netCode, &Value::Null))), Value::Null, self.safe_dict(addressStructures.clone(), netCode.clone(), &[]));
} else {
let mut options: Value = self.safe_dict_k(self.options.clone(), "defaultNetworks", &[]);
let mut defaultNetworkForCurrency: Value = self.safe_string(options.clone(), code.clone(), &[]);
if !is_equal(&defaultNetworkForCurrency, &Value::Null) {
result = self.safe_dict(addressStructures.clone(), defaultNetworkForCurrency.clone(), &[]);
} else {
let mut keys: Value = object_keys(&addressStructures);
let mut key: Value = self.safe_string(keys.clone(), Value::Int(0), &[]);
result = self.safe_dict(addressStructures.clone(), key.clone(), &[]);
}
}
if is_equal(&result, &Value::Null) {
panic!("{}", crate::exchange_errors::invalid_address(add(&add(&add(&add(&add(&self.id, &Value::Str(" fetchDepositAddress() cannot find a deposit address for ".to_string())), &code), &Value::Str(", and network".to_string())), &network), &Value::Str("consider creating one using .createDepositAddress() method or in MEXC website".to_string()))));
}
return result;
Value::Null
}
/*
* @method
* @name mexc#fetchDeposits
* @description fetch all deposits made to an account
* @see https://www.mexc.com/api-docs/spot-v3/wallet-endpoints/deposit-historysupporting-network
* @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
* @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 request: Value = Value::Map({
let mut m = indexmap::IndexMap::new();
m
});
let mut currency: Value = Value::Null;
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())));
// currently mexc does not have network names unified so for certain things we might need TRX or TRC-20
// due to that I'm applying the network parameter directly so the user can control it on its side
let mut rawNetwork: Value = self.safe_string_k(params.clone(), "network", &[]);
if !is_equal(&rawNetwork, &Value::Null) {
params = self.omit(params.clone(), Value::Str("network".to_string()), &[]);
{ let __be_tmp = add(&add(&get_value(&request, &Value::Str("coin".to_string())), &Value::Str("-".to_string())), &rawNetwork); add_element_to_object(&mut request, &Value::Str("coin".to_string()), __be_tmp); };
}
}
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_greater_than(&limit, &Value::Int(1000)) {
panic!("{}", crate::exchange_errors::exchange_error(Value::Str("This exchange supports a maximum limit of 1000".to_string())));
}
add_element_to_object(&mut request, &Value::Str("limit".to_string()), limit.clone());
}
let __ws_arg_50 = self.extend(request.clone(), &[params.clone()]);
let mut response: Value = self.spot_private_get_capital_deposit_hisrec(&[__ws_arg_50]).await;
return self.parse_transactions(response.clone(), &[currency.clone(), since.clone(), limit.clone()]);
Value::Null
}
/*
* @method
* @name mexc#fetchWithdrawals
* @description fetch all withdrawals made from an account
* @see https://www.mexc.com/api-docs/spot-v3/wallet-endpoints/withdraw-history-supporting-network
* @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
* @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 request: Value = Value::Map({
let mut m = indexmap::IndexMap::new();
m
});
let mut currency: Value = Value::Null;
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());
}
if !is_equal(&limit, &Value::Null) {
if is_greater_than(&limit, &Value::Int(1000)) {
panic!("{}", crate::exchange_errors::exchange_error(Value::Str("This exchange supports a maximum limit of 1000".to_string())));
}
add_element_to_object(&mut request, &Value::Str("limit".to_string()), limit.clone());
}
let __ws_arg_51 = self.extend(request.clone(), &[params.clone()]);
let mut response: Value = self.spot_private_get_capital_withdraw_history(&[__ws_arg_51]).await;
return self.parse_transactions(response.clone(), &[currency.clone(), since.clone(), limit.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": "10",
// "coin": "USDC-TRX",
// "network": "TRX",
// "status": "5",
// "address": "TSMcEDDvkqY9dz8RkFnrS86U59GwEZjfvh",
// "txId": "51a8f49e6f03f2c056e71fe3291aa65e1032880be855b65cecd0595a1b8af95b:0",
// "insertTime": "1664805021000",
// "unlockConfirm": "200",
// "confirmTimes": "203",
// "memo": "xxyy1122",
// "transHash": "51a8f49e6f03f2c056e71fe3291aa65e1032880be855b65cecd0595a1b8af95b",
// "updateTime": "1664805621000",
// "netWork: "TRX"
// }
//
// fetchWithdrawals
//
// {
// "id": "adcd1c8322154de691b815eedcd10c42",
// "txId": "0xc8c918cd69b2246db493ef6225a72ffdc664f15b08da3e25c6879b271d05e9d0:0",
// "coin": "USDC-MATIC",
// "network": "MATIC",
// "address": "0xeE6C7a415995312ED52c53a0f8f03e165e0A5D62",
// "amount": "2",
// "transferType": "0",
// "status": "7",
// "transactionFee": "1",
// "confirmNo": null,
// "applyTime": "1664882739000",
// "remark": "",
// "memo": null,
// "explorerUrl": "https://etherscan.io/tx/0xc8c918cd69b2246db493ef6225a72ffdc664f15b08da3e25c6879b271d05e9d0",
// "transHash": "0xc8c918cd69b2246db493ef6225a72ffdc664f15b08da3e25c6879b271d05e9d0",
// "updateTime": "1664882799000",
// "netWork: "MATIC"
// }
//
// withdraw
//
// {
// "id":"25fb2831fb6d4fc7aa4094612a26c81d"
// }
//
// internal withdraw (aka internal-transfer)
//
// {
// "tranId":"ad36f0e9c9a24ae794b36fa4f152e471"
// }
//
let mut id: Value = self.safe_string2(transaction.clone(), Value::Str("id".to_string()), Value::Str("tranId".to_string()), &[]);
let mut type_var: Value = ternary(is_true(&(is_equal(&id, &Value::Null))), Value::Str("deposit".to_string()), Value::Str("withdrawal".to_string()));
let mut timestamp: Value = self.safe_integer2(transaction.clone(), Value::Str("insertTime".to_string()), Value::Str("applyTime".to_string()), &[]);
let mut updated: Value = self.safe_integer_k(transaction.clone(), "updateTime", &[]);
let mut currencyId: Value = Value::Null;
let mut currencyWithNetwork: Value = self.safe_string_k(transaction.clone(), "coin", &[]);
if !is_equal(¤cyWithNetwork, &Value::Null) {
currencyId = get_value(&split(¤cyWithNetwork, &Value::Str("-".to_string())), &Value::Int(0));
}
let mut code: Value = self.safe_currency_code(currencyId.clone(), &[currency.clone()]);
let mut network: Value = Value::Null;
let mut rawNetwork: Value = self.safe_string_k(transaction.clone(), "network", &[]);
if !is_equal(&rawNetwork, &Value::Null) {
network = self.network_id_to_code(&[rawNetwork.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 amountString: Value = self.safe_string_k(transaction.clone(), "amount", &[]);
let mut address: Value = self.safe_string_k(transaction.clone(), "address", &[]);
let mut txid: Value = self.safe_string2(transaction.clone(), Value::Str("transHash".to_string()), Value::Str("txId".to_string()), &[]);
let mut fee: Value = Value::Null;
let mut feeCostString: Value = self.safe_string_k(transaction.clone(), "transactionFee", &[]);
if !is_equal(&feeCostString, &Value::Null) {
fee = Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), self.parse_number(feeCostString.clone(), &[]));
m.insert("currency".to_string(), code.clone());
m
});
}
if is_equal(&type_var, &Value::Str("withdrawal".to_string())) {
// mexc withdrawal amount includes the fee
amountString = crate::precise::Precise::stringSub(&amountString, &feeCostString);
}
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(), self.safe_string_k(transaction.clone(), "memo", &[]));
m.insert("tagTo".to_string(), Value::Null);
m.insert("tagFrom".to_string(), Value::Null);
m.insert("type".to_string(), type_var.clone());
m.insert("amount".to_string(), self.parse_number(amountString.clone(), &[]));
m.insert("currency".to_string(), code.clone());
m.insert("status".to_string(), status.clone());
m.insert("updated".to_string(), updated.clone());
m.insert("comment".to_string(), self.safe_string_k(transaction.clone(), "remark", &[]));
m.insert("internal".to_string(), Value::Null);
m.insert("fee".to_string(), fee.clone());
m
});
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);
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("1".to_string(), Value::Str("failed".to_string()));
m.insert("2".to_string(), Value::Str("pending".to_string()));
m.insert("3".to_string(), Value::Str("pending".to_string()));
m.insert("4".to_string(), Value::Str("pending".to_string()));
m.insert("5".to_string(), Value::Str("ok".to_string()));
m.insert("6".to_string(), Value::Str("pending".to_string()));
m.insert("7".to_string(), Value::Str("failed".to_string()));
m
}));
m.insert("withdrawal".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("1".to_string(), Value::Str("pending".to_string()));
m.insert("2".to_string(), Value::Str("pending".to_string()));
m.insert("3".to_string(), Value::Str("pending".to_string()));
m.insert("4".to_string(), Value::Str("pending".to_string()));
m.insert("5".to_string(), Value::Str("pending".to_string()));
m.insert("6".to_string(), Value::Str("pending".to_string()));
m.insert("7".to_string(), Value::Str("ok".to_string()));
m.insert("8".to_string(), Value::Str("failed".to_string()));
m.insert("9".to_string(), Value::Str("canceled".to_string()));
m.insert("10".to_string(), Value::Str("pending".to_string()));
m
}));
m
});
let mut statuses: Value = self.safe_value(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
}
/*
* @method
* @name mexc#closeAllPositions
* @description closes all open swap positions
* @see https://www.mexc.com/api-docs/futures/account-and-trading-endpoints/close-all
* @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 close_all_positions(&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.contract_private_post_position_close_all(&[params.clone()]).await;
//
// {
// "success": true,
// "code": 0,
// "data": []
// }
//
let mut data: Value = self.safe_list_k(response.clone(), "data", &[Value::List(vec![])]);
return self.parse_positions(data.clone(), &[]);
Value::Null
}
/*
* @method
* @name mexc#fetchPosition
* @description fetch data on a single open contract trade position
* @see https://www.mexc.com/api-docs/futures/account-and-trading-endpoints/get-open-positions
* @param {string} symbol unified market symbol of the market the position is held in, default is undefined
* @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());
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_52 = self.extend(request.clone(), &[params.clone()]);
let mut response: Value = self.fetch_positions(&[Value::Null, __ws_arg_52]).await;
return self.safe_value(response.clone(), Value::Int(0), &[]);
Value::Null
}
/*
* @method
* @name mexc#fetchPositions
* @description fetch all open positions
* @see https://www.mexc.com/api-docs/futures/account-and-trading-endpoints/get-open-positions
* @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 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
}));
if is_equal(&self.markets, &Value::Null) {
self.load_markets(&[]).await;
}
let mut response: Value = self.contract_private_get_position_open_positions(&[params.clone()]).await;
//
// {
// "success": true,
// "code": 0,
// "data": [
// {
// "positionId": 1394650,
// "symbol": "ETH_USDT",
// "positionType": 1,
// "openType": 1,
// "state": 1,
// "holdVol": 1,
// "frozenVol": 0,
// "closeVol": 0,
// "holdAvgPrice": 1217.3,
// "openAvgPrice": 1217.3,
// "closeAvgPrice": 0,
// "liquidatePrice": 1211.2,
// "oim": 0.1290338,
// "im": 0.1290338,
// "holdFee": 0,
// "realised": -0.0073,
// "leverage": 100,
// "createTime": 1609991676000,
// "updateTime": 1609991676000,
// "autoAddIm": false
// }
// ]
// }
//
let mut data: Value = self.safe_list_k(response.clone(), "data", &[Value::List(vec![])]);
return self.parse_positions(data.clone(), &[symbols.clone()]);
Value::Null
}
pub fn parse_position(&self, mut position: Value, optional_args: &[Value]) -> Value {
let mut market = get_arg(optional_args, 0, Value::Null);
//
// fetchPositions
//
// {
// "positionId": 1394650,
// "symbol": "ETH_USDT",
// "positionType": 1,
// "openType": 1,
// "state": 1,
// "holdVol": 1,
// "frozenVol": 0,
// "closeVol": 0,
// "holdAvgPrice": 1217.3,
// "openAvgPrice": 1217.3,
// "closeAvgPrice": 0,
// "liquidatePrice": 1211.2,
// "oim": 0.1290338,
// "im": 0.1290338,
// "holdFee": 0,
// "realised": -0.0073,
// "leverage": 100,
// "createTime": 1609991676000,
// "updateTime": 1609991676000,
// "autoAddIm": false
// }
//
// fetchPositionsHistory
//
// {
// positionId: '390281084',
// symbol: 'RVN_USDT',
// positionType: '1',
// openType: '2',
// state: '3',
// holdVol: '0',
// frozenVol: '0',
// closeVol: '1141',
// holdAvgPrice: '0.03491',
// holdAvgPriceFullyScale: '0.03491',
// openAvgPrice: '0.03491',
// openAvgPriceFullyScale: '0.03491',
// closeAvgPrice: '0.03494',
// liquidatePrice: '0.03433',
// oim: '0',
// im: '0',
// holdFee: '0',
// realised: '0.1829',
// leverage: '50',
// createTime: '1711512408000',
// updateTime: '1711512553000',
// autoAddIm: false,
// version: '4',
// profitRatio: '0.0227',
// newOpenAvgPrice: '0.03491',
// newCloseAvgPrice: '0.03494',
// closeProfitLoss: '0.3423',
// fee: '0.1593977',
// positionShowStatus: 'CLOSED'
// }
//
market = self.safe_market(&[self.safe_string_k(position.clone(), "symbol", &[]), market.clone(), Value::Null, Value::Str("swap".to_string())]);
let mut symbol: Value = get_value(&market, &Value::Str("symbol".to_string()));
let mut contracts: Value = self.safe_string_k(position.clone(), "holdVol", &[]);
let mut entryPrice: Value = self.safe_number_k(position.clone(), "openAvgPrice", &[]);
let mut initialMargin: Value = self.safe_string_k(position.clone(), "im", &[]);
let mut rawSide: Value = self.safe_string_k(position.clone(), "positionType", &[]);
let mut side: Value = ternary(is_true(&(is_equal(&rawSide, &Value::Str("1".to_string())))), Value::Str("long".to_string()), Value::Str("short".to_string()));
let mut openType: Value = self.safe_string_k(position.clone(), "margin_mode", &[]);
let mut marginType: Value = ternary(is_true(&(is_equal(&openType, &Value::Str("1".to_string())))), Value::Str("isolated".to_string()), Value::Str("cross".to_string()));
let mut leverage: Value = self.safe_number_k(position.clone(), "leverage", &[]);
let mut liquidationPrice: Value = self.safe_number_k(position.clone(), "liquidatePrice", &[]);
let mut timestamp: Value = self.safe_integer_k(position.clone(), "updateTime", &[]);
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(), self.parse_number(contracts.clone(), &[]));
m.insert("contractSize".to_string(), Value::Null);
m.insert("entryPrice".to_string(), entryPrice.clone());
m.insert("collateral".to_string(), Value::Null);
m.insert("side".to_string(), side.clone());
m.insert("unrealizedPnl".to_string(), Value::Null);
m.insert("leverage".to_string(), self.parse_number(leverage.clone(), &[]));
m.insert("percentage".to_string(), Value::Null);
m.insert("marginMode".to_string(), marginType.clone());
m.insert("notional".to_string(), Value::Null);
m.insert("markPrice".to_string(), Value::Null);
m.insert("lastPrice".to_string(), Value::Null);
m.insert("liquidationPrice".to_string(), liquidationPrice.clone());
m.insert("initialMargin".to_string(), self.parse_number(initialMargin.clone(), &[]));
m.insert("initialMarginPercentage".to_string(), Value::Null);
m.insert("maintenanceMargin".to_string(), Value::Null);
m.insert("maintenanceMarginPercentage".to_string(), Value::Null);
m.insert("marginRatio".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("stopLossPrice".to_string(), Value::Null);
m.insert("takeProfitPrice".to_string(), Value::Null);
m.insert("lastUpdateTimestamp".to_string(), Value::Null);
m
}));
Value::Null
}
/*
* @method
* @name mexc#fetchTransfer
* @description fetches a transfer
* @see https://mexcdevelop.github.io/apidocs/spot_v2_en/#internal-assets-transfer-order-inquiry
* @param {string} id transfer id
* @param {string} [code] not used by mexc fetchTransfer
* @param {object} params extra parameters specific to the exchange API endpoint
* @returns {object} a [transfer structure]{@link https://docs.ccxt.com/?id=transfer-structure}
*/
pub async fn fetch_transfer(&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
}));
let mut marketTypequeryVariable = self.handle_market_type_and_params(Value::Str("fetchTransfer".to_string()), &[Value::Null, params.clone()]);
let mut marketType: Value = get_value(&marketTypequeryVariable, &Value::Int(0));
let mut query: Value = get_value(&marketTypequeryVariable, &Value::Int(1));
if is_equal(&self.markets, &Value::Null) {
self.load_markets(&[]).await;
}
if is_equal(&marketType, &Value::Str("spot".to_string())) {
let mut request: Value = Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("transact_id".to_string(), id.clone());
m
});
let __ws_arg_53 = self.extend(request.clone(), &[query.clone()]);
let mut response: Value = self.spot_private_get_asset_internal_transfer_record(&[__ws_arg_53]).await;
//
// {
// "code": "200",
// "data": {
// "currency": "USDT",
// "amount": "1",
// "transact_id": "954877a2ef54499db9b28a7cf9ebcf41",
// "from": "MAIN",
// "to": "CONTRACT",
// "transact_state": "SUCCESS"
// }
// }
//
let mut data: Value = self.safe_dict_k(response.clone(), "data", &[Value::Map({
let mut m = indexmap::IndexMap::new();
m
})]);
return self.parse_transfer(data.clone(), &[]);
} else if is_equal(&marketType, &Value::Str("swap".to_string())) {
panic!("{}", crate::exchange_errors::bad_request(add(&add(&self.id, &Value::Str(" fetchTransfer() is not supported for ".to_string())), &marketType)));
}
panic!("{}", crate::exchange_errors::bad_request(add(&add(&self.id, &Value::Str(" fetchTransfer() is not supported for ".to_string())), &marketType)));
Value::Null
}
/*
* @method
* @name mexc#fetchTransfers
* @description fetch a history of internal transfers made on an account
* @see https://www.mexc.com/api-docs/spot-v3/wallet-endpoints/query-user-universal-transfer-history // spot universal transfer
* @see https://www.mexc.com/api-docs/futures/account-and-trading-endpoints/get-asset-transfer-records // swap
* @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 {string} [params.fromAccountType] 'SPOT' for spot wallet, 'FUTURES' for contract wallet
* @param {string} [params.toAccountType] 'SPOT' for spot wallet, 'FUTURES' for contract wallet
* @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
}));
let mut marketType: Value = Value::Null;
{ let __destr_tmp = self.handle_market_type_and_params(Value::Str("fetchTransfers".to_string()), &[Value::Null, params.clone()]); marketType = get_value(&__destr_tmp, &Value::Int(0)); params = get_value(&__destr_tmp, &Value::Int(1)); }
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 currency: Value = Value::Null;
if !is_equal(&code, &Value::Null) {
currency = self.currency(code.clone());
}
let mut fromAccountType: Value = Value::Null;
{ let __destr_tmp = self.handle_option_and_params(params.clone(), Value::Str("fetchTransfers".to_string()), Value::Str("fromAccountType".to_string()), &[]); fromAccountType = get_value(&__destr_tmp, &Value::Int(0)); params = get_value(&__destr_tmp, &Value::Int(1)); }
let mut accountTypes: Value = Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("spot".to_string(), Value::Str("SPOT".to_string()));
m.insert("swap".to_string(), Value::Str("FUTURES".to_string()));
m.insert("futures".to_string(), Value::Str("FUTURES".to_string()));
m.insert("future".to_string(), Value::Str("FUTURES".to_string()));
m.insert("margin".to_string(), Value::Str("SPOT".to_string()));
m
});
if !is_equal(&fromAccountType, &Value::Null) {
add_element_to_object(&mut request, &Value::Str("fromAccountType".to_string()), self.safe_string(accountTypes.clone(), fromAccountType.clone(), &[fromAccountType.clone()]));
} else {
panic!("{}", crate::exchange_errors::arguments_required(add(&self.id, &Value::Str(" fetchTransfers() requires a fromAccountType parameter, one of \"SPOT\", \"FUTURES\"".to_string()))));
}
let mut toAccountType: Value = Value::Null;
{ let __destr_tmp = self.handle_option_and_params(params.clone(), Value::Str("fetchTransfers".to_string()), Value::Str("toAccountType".to_string()), &[]); toAccountType = get_value(&__destr_tmp, &Value::Int(0)); params = get_value(&__destr_tmp, &Value::Int(1)); }
if !is_equal(&toAccountType, &Value::Null) {
add_element_to_object(&mut request, &Value::Str("toAccountType".to_string()), self.safe_string(accountTypes.clone(), toAccountType.clone(), &[toAccountType.clone()]));
} else {
panic!("{}", crate::exchange_errors::arguments_required(add(&self.id, &Value::Str(" fetchTransfers() requires a toAccountType parameter, one of \"SPOT\", \"FUTURES\"".to_string()))));
}
let mut resultList: Value = Value::List(vec![]);
if is_equal(&marketType, &Value::Str("spot".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_greater_than(&limit, &Value::Int(100)) {
panic!("{}", crate::exchange_errors::exchange_error(Value::Str("This exchange supports a maximum limit of 50".to_string())));
}
add_element_to_object(&mut request, &Value::Str("size".to_string()), limit.clone());
}
let __ws_arg_54 = self.extend(request.clone(), &[params.clone()]);
let mut response: Value = self.spot_private_get_capital_transfer(&[__ws_arg_54]).await;
//
//
// {
// "rows": [
// {
// "tranId": "cdf0d2a618b5458c965baefe6b1d0859",
// "clientTranId": null,
// "asset": "USDT",
// "amount": "1",
// "fromAccountType": "FUTURES",
// "toAccountType": "SPOT",
// "symbol": null,
// "status": "SUCCESS",
// "timestamp": 1759328309000
// }
// ],
// "total": 1
// }
resultList = self.safe_list_k(response.clone(), "rows", &[Value::List(vec![])]);
} else if is_equal(&marketType, &Value::Str("swap".to_string())) {
if !is_equal(&limit, &Value::Null) {
add_element_to_object(&mut request, &Value::Str("page_size".to_string()), limit.clone());
}
let __ws_arg_55 = self.extend(request.clone(), &[params.clone()]);
let mut response: Value = self.contract_private_get_account_transfer_record(&[__ws_arg_55]).await;
let mut data: Value = self.safe_value_k(response.clone(), "data", &[]);
resultList = self.safe_value_k(data.clone(), "resultList", &[]);
}
return self.parse_transfers(resultList.clone(), &[currency.clone(), since.clone(), limit.clone()]);
Value::Null
}
/*
* @method
* @name mexc#transfer
* @description transfer currency internally between wallets on the same account
* @see https://www.mexc.com/api-docs/spot-v3/wallet-endpoints/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.symbol] market symbol required for margin account transfers eg:BTCUSDT
* @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 accounts: Value = Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("spot".to_string(), Value::Str("SPOT".to_string()));
m.insert("swap".to_string(), Value::Str("FUTURES".to_string()));
m.insert("future".to_string(), Value::Str("FUTURES".to_string()));
m
});
let mut fromId: Value = self.safe_string(accounts.clone(), fromAccount.clone(), &[fromAccount.clone()]);
let mut toId: Value = self.safe_string(accounts.clone(), toAccount.clone(), &[toAccount.clone()]);
if is_equal(&fromId, &Value::Null) {
let mut keys: Value = object_keys(&accounts);
panic!("{}", crate::exchange_errors::exchange_error(add(&add(&self.id, &Value::Str(" fromAccount must be one of ".to_string())), &join(&keys, &Value::Str(", ".to_string())))));
}
if is_equal(&toId, &Value::Null) {
let mut keys: Value = object_keys(&accounts);
panic!("{}", crate::exchange_errors::exchange_error(add(&add(&self.id, &Value::Str(" toAccount must be one of ".to_string())), &join(&keys, &Value::Str(", ".to_string())))));
}
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("fromAccountType".to_string(), fromId.clone());
m.insert("toAccountType".to_string(), toId.clone());
m
});
if is_true(&(is_equal(&fromId, &Value::Str("ISOLATED_MARGIN".to_string())))) || is_true(&(is_equal(&toId, &Value::Str("ISOLATED_MARGIN".to_string())))) {
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) {
panic!("{}", crate::exchange_errors::arguments_required(add(&self.id, &Value::Str(" transfer() requires a symbol argument for isolated margin".to_string()))));
}
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_56 = self.extend(request.clone(), &[params.clone()]);
let mut response: Value = self.spot_private_post_capital_transfer(&[__ws_arg_56]).await;
//
// {
// "tranId": "ebb06123e6a64f4ab234b396c548d57e"
// }
//
let mut transaction: Value = self.parse_transfer(response.clone(), &[currency.clone()]);
return self.extend(transaction.clone(), &[Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("amount".to_string(), amount.clone());
m.insert("fromAccount".to_string(), fromAccount.clone());
m.insert("toAccount".to_string(), toAccount.clone());
m
})]);
Value::Null
}
pub fn parse_transfer(&self, mut transfer: Value, optional_args: &[Value]) -> Value {
let mut currency = get_arg(optional_args, 0, Value::Null);
//
// spot: fetchTransfer
//
// {
// "currency": "USDT",
// "amount": "1",
// "transact_id": "b60c1df8e7b24b268858003f374ecb75",
// "from": "MAIN",
// "to": "CONTRACT",
// "transact_state": "WAIT"
// }
//
// swap: fetchTransfer
//
// {
// "currency": "USDT",
// "amount": "22.90213135",
// "txid": "fa8a1e7bf05940a3b7025856dc48d025",
// "id": "2980812",
// "type": "IN",
// "state": "SUCCESS",
// "createTime": "1648849076000",
// "updateTime": "1648849076000"
// }
// {
// "tranId": "cdf0d2a618b5458c965baefe6b1d0859",
// "clientTranId": null,
// "asset": "USDT",
// "amount": "1",
// "fromAccountType": "FUTURES",
// "toAccountType": "SPOT",
// "symbol": null,
// "status": "SUCCESS",
// "timestamp": 1759328309000
// }
//
// transfer
//
// {
// "tranId": "ebb06123e6a64f4ab234b396c548d57e"
// }
//
let mut currencyId: Value = self.safe_string2(transfer.clone(), Value::Str("currency".to_string()), Value::Str("asset".to_string()), &[]);
let mut id: Value = self.safe_string_n(transfer.clone(), Value::List(vec![Value::Str("transact_id".to_string()), Value::Str("txid".to_string()), Value::Str("tranId".to_string())]), &[]);
let mut timestamp: Value = self.safe_integer2(transfer.clone(), Value::Str("createTime".to_string()), Value::Str("timestamp".to_string()), &[]);
let mut datetime: Value = ternary(is_true(&(!is_equal(×tamp, &Value::Null))), self.iso8601(timestamp.clone()), Value::Null);
let mut direction: Value = self.safe_string_k(transfer.clone(), "type", &[]);
let mut accountFrom: Value = Value::Null;
let mut accountTo: Value = Value::Null;
let mut fromAccountType: Value = self.safe_string_k(transfer.clone(), "fromAccountType", &[]);
let mut toAccountType: Value = self.safe_string_k(transfer.clone(), "toAccountType", &[]);
if is_true(&(!is_equal(&fromAccountType, &Value::Null))) && is_true(&(!is_equal(&toAccountType, &Value::Null))) {
accountFrom = fromAccountType.clone();
accountTo = toAccountType.clone();
} else if !is_equal(&direction, &Value::Null) {
accountFrom = ternary(is_true(&(is_equal(&direction, &Value::Str("IN".to_string())))), Value::Str("MAIN".to_string()), Value::Str("CONTRACT".to_string()));
accountTo = ternary(is_true(&(is_equal(&direction, &Value::Str("IN".to_string())))), Value::Str("CONTRACT".to_string()), Value::Str("MAIN".to_string()));
} else {
accountFrom = self.safe_string_k(transfer.clone(), "from", &[]);
accountTo = self.safe_string_k(transfer.clone(), "to", &[]);
}
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(), datetime.clone());
m.insert("currency".to_string(), self.safe_currency_code(currencyId.clone(), &[currency.clone()]));
m.insert("amount".to_string(), self.safe_number_k(transfer.clone(), "amount", &[]));
m.insert("fromAccount".to_string(), self.parse_account_id(accountFrom.clone()));
m.insert("toAccount".to_string(), self.parse_account_id(accountTo.clone()));
m.insert("status".to_string(), self.parse_transfer_status(self.safe_string_n(transfer.clone(), Value::List(vec![Value::Str("transact_state".to_string()), Value::Str("state".to_string()), Value::Str("status".to_string())]), &[])));
m
});
Value::Null
}
pub fn parse_account_id(&self, mut status: Value) -> Value {
let mut statuses: Value = Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("SPOT".to_string(), Value::Str("spot".to_string()));
m.insert("FUTURES".to_string(), Value::Str("swap".to_string()));
m.insert("MAIN".to_string(), Value::Str("spot".to_string()));
m.insert("CONTRACT".to_string(), Value::Str("swap".to_string()));
m
});
return self.safe_string(statuses.clone(), status.clone(), &[status.clone()]);
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("SUCCESS".to_string(), Value::Str("ok".to_string()));
m.insert("FAILED".to_string(), Value::Str("failed".to_string()));
m.insert("WAIT".to_string(), Value::Str("pending".to_string()));
m
});
return self.safe_string(statuses.clone(), status.clone(), &[status.clone()]);
Value::Null
}
/*
* @method
* @name mexc#withdraw
* @description make a withdrawal
* @see https://www.mexc.com/api-docs/spot-v3/wallet-endpoints/withdrawnew // on-chain withdrawal
* @see https://www.mexc.com/api-docs/spot-v3/wallet-endpoints/internal-transfer // internal transfer
* @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
* @param {object} [params.internal] false by default, set to true for an "internal transfer"
* @param {object} [params.toAccountType] skipped by default, set to 'EMAIL|UID|MOBILE' when making an "internal transfer"
* @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
}));
if is_equal(&self.markets, &Value::Null) {
self.load_markets(&[]).await;
}
let mut currency: Value = self.currency(code.clone());
{ 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)); }
let mut internal: Value = self.safe_bool_k(params.clone(), "internal", &[Value::Bool(false)]);
if is_equal(&internal, &Value::Bool(true)) {
params = self.omit(params.clone(), Value::Str("internal".to_string()), &[]);
let mut requestForInternal: 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("toAccount".to_string(), address.clone());
m
});
let mut toAccountType: Value = self.safe_string_k(params.clone(), "toAccountType", &[]);
if is_equal(&toAccountType, &Value::Null) {
panic!("{}", crate::exchange_errors::arguments_required(add(&self.id, &Value::Str(" withdraw() requires a toAccountType parameter for internal transfer to be of: EMAIL | UID | MOBILE".to_string()))));
}
let __ws_arg_57 = self.extend(requestForInternal.clone(), &[params.clone()]);
let mut responseForInternal: Value = self.spot_private_post_capital_transfer_internal(&[__ws_arg_57]).await;
return self.parse_transaction(responseForInternal.clone(), &[currency.clone()]);
}
let mut networks: Value = self.safe_dict_k(self.options.clone(), "networks", &[Value::Map({
let mut m = indexmap::IndexMap::new();
m
})]);
let mut network: Value = self.safe_string2(params.clone(), Value::Str("network".to_string()), Value::Str("netWork".to_string()), &[]); // this line allows the user to specify either ERC20 or ETH
network = self.safe_string(networks.clone(), network.clone(), &[network.clone()]); // handle ETH > ERC-20 alias
network = self.network_code_to_id(network.clone(), &[get_value(¤cy, &Value::Str("code".to_string()))]);
self.check_address(&[address.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.insert("amount".to_string(), amount.clone());
m
});
if !is_equal(&tag, &Value::Null) {
add_element_to_object(&mut request, &Value::Str("memo".to_string()), tag.clone());
}
if !is_equal(&network, &Value::Null) {
add_element_to_object(&mut request, &Value::Str("netWork".to_string()), network.clone());
params = self.omit(params.clone(), Value::List(vec![Value::Str("network".to_string()), Value::Str("netWork".to_string())]), &[]);
}
let __ws_arg_58 = self.extend(request.clone(), &[params.clone()]);
let mut response: Value = self.spot_private_post_capital_withdraw(&[__ws_arg_58]).await;
return self.parse_transaction(response.clone(), &[currency.clone()]);
Value::Null
}
/*
* @method
* @name mexc#setPositionMode
* @description set hedged to true or false for a market
* @see https://www.mexc.com/api-docs/futures/account-and-trading-endpoints/modify-user-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
* @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 request: Value = Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("positionMode".to_string(), ternary(is_true(&hedged), Value::Int(1), Value::Int(2)));
m
});
let __ws_arg_59 = self.extend(request.clone(), &[params.clone()]);
let mut response: Value = self.contract_private_post_position_change_position_mode(&[__ws_arg_59]).await;
return response;
Value::Null
}
/*
* @method
* @name mexc#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://www.mexc.com/api-docs/futures/account-and-trading-endpoints/get-user-position-mode
* @param {string} symbol not used by mexc fetchPositionMode
* @param {object} [params] extra parameters specific to the exchange API endpoint
* @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 response: Value = self.contract_private_get_position_position_mode(&[params.clone()]).await;
//
// {
// "success":true,
// "code":0,
// "data":2
// }
//
let mut positionMode: Value = self.safe_integer_k(response.clone(), "data", &[]);
return Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("info".to_string(), response.clone());
m.insert("hedged".to_string(), Value::Bool((is_equal(&positionMode, &Value::Int(1)))));
m
});
Value::Null
}
/*
* @method
* @name mexc#fetchTransactionFees
* @description fetch deposit and withdrawal fees
* @see https://www.mexc.com/api-docs/spot-v3/wallet-endpoints/query-the-currency-information
* @param {string[]|undefined} codes returns fees for all currencies if undefined
* @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.spot_private_get_capital_config_getall(&[params.clone()]).await;
return self.parse_transaction_fees(response.clone(), &[codes.clone()]);
Value::Null
}
pub fn parse_transaction_fees(&self, mut response: Value, optional_args: &[Value]) -> Value {
let mut codes = get_arg(optional_args, 0, Value::Null);
let mut withdrawFees: Value = Value::Map({
let mut m = indexmap::IndexMap::new();
m
});
{
let mut i: Value = Value::Int(0);
let mut __for_first_944: bool = true;
while { if !__for_first_944 { i = add(&i, &Value::Int(1)); } __for_first_944 = 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 currencyId: Value = self.safe_string_k(entry.clone(), "coin", &[]);
let mut currency: Value = self.safe_currency(currencyId.clone(), &[]);
let mut code: Value = self.safe_string_k(currency.clone(), "code", &[]);
if is_true(&(is_equal(&codes, &Value::Null))) || is_true(&(self.in_array(code.clone(), codes.clone()))) {
add_element_to_object(&mut withdrawFees, &code, self.parse_transaction_fee(entry.clone(), &[currency.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
}
pub fn parse_transaction_fee(&self, mut transaction: Value, optional_args: &[Value]) -> Value {
let mut currency = get_arg(optional_args, 0, Value::Null);
//
// {
// "coin": "AGLD",
// "name": "Adventure Gold",
// "networkList": [
// {
// "coin": "AGLD",
// "depositDesc": null,
// "depositEnable": true,
// "minConfirm": "0",
// "name": "Adventure Gold",
// "network": "ERC20",
// "withdrawEnable": true,
// "withdrawFee": "10.000000000000000000",
// "withdrawIntegerMultiple": null,
// "withdrawMax": "1200000.000000000000000000",
// "withdrawMin": "20.000000000000000000",
// "sameAddress": false,
// "contract": "0x32353a6c91143bfd6c7d363b546e62a9a2489a20",
// "withdrawTips": null,
// "depositTips": null
// }
// ...
// ]
// }
//
let mut networkList: Value = self.safe_value_k(transaction.clone(), "networkList", &[Value::List(vec![])]);
let mut result: Value = Value::Map({
let mut m = indexmap::IndexMap::new();
m
});
{
let mut j: Value = Value::Int(0);
let mut __for_first_945: bool = true;
while { if !__for_first_945 { j = add(&j, &Value::Int(1)); } __for_first_945 = 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_string(get_value(&self.options, &Value::Str("networks".to_string())), networkId.clone(), &[networkId.clone()]);
let mut fee: Value = self.safe_number_k(networkEntry.clone(), "withdrawFee", &[]);
add_element_to_object(&mut result, &networkCode, fee.clone());
}
}
return result;
Value::Null
}
/*
* @method
* @name mexc#fetchDepositWithdrawFees
* @description fetch deposit and withdrawal fees
* @see https://www.mexc.com/api-docs/spot-v3/wallet-endpoints/query-the-currency-information
* @param {string[]|undefined} codes returns fees for all currencies if undefined
* @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.spot_private_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": "AGLD",
// "name": "Adventure Gold",
// "networkList": [
// {
// "coin": "AGLD",
// "depositDesc": null,
// "depositEnable": true,
// "minConfirm": "0",
// "name": "Adventure Gold",
// "network": "ERC20",
// "withdrawEnable": true,
// "withdrawFee": "10.000000000000000000",
// "withdrawIntegerMultiple": null,
// "withdrawMax": "1200000.000000000000000000",
// "withdrawMin": "20.000000000000000000",
// "sameAddress": false,
// "contract": "0x32353a6c91143bfd6c7d363b546e62a9a2489a20",
// "withdrawTips": null,
// "depositTips": null
// }
// ...
// ]
// }
//
let mut networkList: Value = self.safe_value_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_946: bool = true;
while { if !__for_first_946 { j = add(&j, &Value::Int(1)); } __for_first_946 = 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(), self.safe_string_k(currency.clone(), "code", &[])]);
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(), self.safe_number_k(networkEntry.clone(), "withdrawFee", &[]));
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 self.assign_default_deposit_withdraw_fees(result.clone(), &[]);
Value::Null
}
/*
* @method
* @name mexc#fetchLeverage
* @description fetch the set leverage for a market
* @see https://www.mexc.com/api-docs/futures/account-and-trading-endpoints/get-position-leverage-multipliers
* @param {string} symbol unified market symbol
* @param {object} [params] extra parameters specific to the exchange API endpoint
* @returns {object} a [leverage structure]{@link https://docs.ccxt.com/?id=leverage-structure}
*/
pub async fn fetch_leverage(&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_60 = self.extend(request.clone(), &[params.clone()]);
let mut response: Value = self.contract_private_get_position_leverage(&[__ws_arg_60]).await;
//
// {
// "success": true,
// "code": 0,
// "data": [
// {
// "level": 1,
// "maxVol": 463300,
// "mmr": 0.004,
// "imr": 0.005,
// "positionType": 1,
// "openType": 1,
// "leverage": 20,
// "limitBySys": false,
// "currentMmr": 0.004
// },
// {
// "level": 1,
// "maxVol": 463300,
// "mmr": 0.004,
// "imr": 0.005,
// "positionType": 2,
// "openType": 1,
// "leverage": 20,
// "limitBySys": false,
// "currentMmr": 0.004
// }
// ]
// }
//
let mut data: Value = self.safe_list_k(response.clone(), "data", &[Value::List(vec![])]);
return self.parse_leverage(data.clone(), &[market.clone()]);
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 marginMode: Value = Value::Null;
let mut longLeverage: Value = Value::Null;
let mut shortLeverage: Value = Value::Null;
{
let mut i: Value = Value::Int(0);
let mut __for_first_947: bool = true;
while { if !__for_first_947 { i = add(&i, &Value::Int(1)); } __for_first_947 = false; is_less_than(&i, &get_array_length(&leverage)) } {
let mut entry: Value = get_value(&leverage, &i);
let mut entry: Value = get_value(&leverage, &i);
let mut openType: Value = self.safe_integer_k(entry.clone(), "openType", &[]);
let mut positionType: Value = self.safe_integer_k(entry.clone(), "positionType", &[]);
if is_equal(&positionType, &Value::Int(1)) {
longLeverage = self.safe_integer_k(entry.clone(), "leverage", &[]);
} else if is_equal(&positionType, &Value::Int(2)) {
shortLeverage = self.safe_integer_k(entry.clone(), "leverage", &[]);
}
marginMode = ternary(is_true(&(is_equal(&openType, &Value::Int(1)))), Value::Str("isolated".to_string()), Value::Str("cross".to_string()));
}
}
return Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("info".to_string(), leverage.clone());
m.insert("symbol".to_string(), self.safe_string_k(market.clone(), "symbol", &[]));
m.insert("marginMode".to_string(), marginMode.clone());
m.insert("longLeverage".to_string(), longLeverage.clone());
m.insert("shortLeverage".to_string(), shortLeverage.clone());
m
});
Value::Null
}
pub fn handle_margin_mode_and_params(&self, mut methodName: Value, optional_args: &[Value]) -> Value {
let mut params = get_arg(optional_args, 0, Value::Map({
let mut m = indexmap::IndexMap::new();
m
}));
let mut defaultValue = get_arg(optional_args, 1, Value::Null);
/*
* @ignore
* @method
* @description marginMode specified by params["marginMode"], this.options["marginMode"], this.options["defaultMarginMode"], params["margin"] = true or this.options["defaultType"] = 'margin'
* @param {object} [params] extra parameters specific to the exchange API endpoint
* @param {bool} [params.margin] true for trading spot-margin
* @returns {Array} the marginMode in lowercase
*/
let mut defaultType: Value = self.safe_string_k(self.options.clone(), "defaultType", &[]);
let mut isMargin: Value = self.safe_bool_k(params.clone(), "margin", &[Value::Bool(false)]);
let mut marginMode: Value = Value::Null;
{ let __destr_tmp = self.super_handle_margin_mode_and_params(methodName.clone(), params.clone(), defaultValue.clone()); marginMode = get_value(&__destr_tmp, &Value::Int(0)); params = get_value(&__destr_tmp, &Value::Int(1)); }
if is_true(&(is_equal(&defaultType, &Value::Str("margin".to_string())))) || is_true(&(is_equal(&isMargin, &Value::Bool(true)))) {
marginMode = Value::Str("isolated".to_string());
}
return Value::List(vec![marginMode.clone(), params.clone()]);
Value::Null
}
/*
* @method
* @name mexc#fetchPositionsHistory
* @description fetches historical positions
* @see https://www.mexc.com/api-docs/futures/account-and-trading-endpoints/get-historical-positions
* @param {string[]} [symbols] unified contract symbols
* @param {int} [since] not used by mexc fetchPositionsHistory
* @param {int} [limit] the maximum amount of candles to fetch, default=1000
* @param {object} [params] extra parameters specific to the exchange API endpoint
*
* EXCHANGE SPECIFIC PARAMETERS
* @param {int} [params.type] position type,1: long, 2: short
* @param {int} [params.page_num] current page number, default is 1
* @returns {object[]} a list of [position structures]{@link https://docs.ccxt.com/?id=position-structure}
*/
pub async fn fetch_positions_history(&mut self, optional_args: &[Value]) -> Value {
let mut symbols = 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
});
if !is_equal(&symbols, &Value::Null) {
let mut symbolsLength: Value = get_array_length(&symbols);
if is_equal(&symbolsLength, &Value::Int(1)) {
let mut market: Value = 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())));
}
}
if !is_equal(&limit, &Value::Null) {
add_element_to_object(&mut request, &Value::Str("page_size".to_string()), limit.clone());
}
let __ws_arg_61 = self.extend(request.clone(), &[params.clone()]);
let mut response: Value = self.contract_private_get_position_list_history_positions(&[__ws_arg_61]).await;
//
// {
// success: true,
// code: '0',
// data: [
// {
// positionId: '390281084',
// symbol: 'RVN_USDT',
// positionType: '1',
// openType: '2',
// state: '3',
// holdVol: '0',
// frozenVol: '0',
// closeVol: '1141',
// holdAvgPrice: '0.03491',
// holdAvgPriceFullyScale: '0.03491',
// openAvgPrice: '0.03491',
// openAvgPriceFullyScale: '0.03491',
// closeAvgPrice: '0.03494',
// liquidatePrice: '0.03433',
// oim: '0',
// im: '0',
// holdFee: '0',
// realised: '0.1829',
// leverage: '50',
// createTime: '1711512408000',
// updateTime: '1711512553000',
// autoAddIm: false,
// version: '4',
// profitRatio: '0.0227',
// newOpenAvgPrice: '0.03491',
// newCloseAvgPrice: '0.03494',
// closeProfitLoss: '0.3423',
// fee: '0.1593977',
// positionShowStatus: 'CLOSED'
// },
// ...
// ]
// }
//
let mut data: Value = self.safe_list_k(response.clone(), "data", &[Value::List(vec![])]);
let mut positions: Value = self.parse_positions(data.clone(), &[symbols.clone(), params.clone()]);
return self.filter_by_since_limit(positions.clone(), &[since.clone(), limit.clone()]);
Value::Null
}
/*
* @method
* @name mexc#setMarginMode
* @description set margin mode to 'cross' or 'isolated'
* @see https://www.mexc.com/api-docs/futures/account-and-trading-endpoints/modify-leverage
* @param {string} marginMode 'cross' or 'isolated'
* @param {string} [symbol] required when there is no position, else provide params["positionId"]
* @param {object} [params] extra parameters specific to the exchange API endpoint
* @param {string} [params.positionId] required when a position is set
* @param {string} [params.direction] "long" or "short" required when there is no position
* @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(&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::bad_symbol(add(&self.id, &Value::Str(" setMarginMode() supports contract markets only".to_string()))));
}
let mut marginModeLower: Value = to_lower(&marginMode);
if !is_equal(&marginModeLower, &Value::Str("isolated".to_string())) && !is_equal(&marginModeLower, &Value::Str("cross".to_string())) {
panic!("{}", crate::exchange_errors::bad_request(add(&self.id, &Value::Str(" setMarginMode() marginMode argument should be isolated or cross".to_string()))));
}
let mut leverage: Value = self.safe_integer_k(params.clone(), "leverage", &[]);
if is_equal(&leverage, &Value::Null) {
panic!("{}", crate::exchange_errors::arguments_required(add(&self.id, &Value::Str(" setMarginMode() requires a leverage parameter".to_string()))));
}
let mut direction: Value = self.safe_string_lower2(params.clone(), Value::Str("direction".to_string()), Value::Str("positionId".to_string()), &[]);
let mut request: Value = Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("leverage".to_string(), leverage.clone());
m.insert("openType".to_string(), ternary(is_true(&(is_equal(&marginModeLower, &Value::Str("isolated".to_string())))), Value::Int(1), Value::Int(2)));
m
});
if !is_equal(&symbol, &Value::Null) {
add_element_to_object(&mut request, &Value::Str("symbol".to_string()), get_value(&market, &Value::Str("id".to_string())));
}
if !is_equal(&direction, &Value::Null) {
add_element_to_object(&mut request, &Value::Str("positionType".to_string()), ternary(is_true(&(is_equal(&direction, &Value::Str("short".to_string())))), Value::Int(2), Value::Int(1)));
}
params = self.omit(params.clone(), Value::Str("direction".to_string()), &[]);
let __ws_arg_62 = self.extend(request.clone(), &[params.clone()]);
let mut response: Value = self.contract_private_post_position_change_leverage(&[__ws_arg_62]).await;
return self.parse_leverage(response.clone(), &[market.clone()]);
Value::Null
}
pub fn nonce(&self) -> Value {
return subtract(&self.milliseconds(), &self.safe_integer_k(self.options.clone(), "timeDifference", &[Value::Int(0)]));
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 section: Value = self.safe_string(api.clone(), Value::Int(0), &[]);
let mut access: Value = self.safe_string(api.clone(), Value::Int(1), &[]);
{ let __destr_tmp = self.resolve_path(path.clone(), params.clone()); path = get_value(&__destr_tmp, &Value::Int(0)); params = get_value(&__destr_tmp, &Value::Int(1)); }
let mut url: Value = Value::Null;
if is_equal(§ion, &Value::Str("spot".to_string())) || is_equal(§ion, &Value::Str("broker".to_string())) {
if is_equal(§ion, &Value::Str("broker".to_string())) {
url = add(&add(&get_value(&get_value(&get_value(&self.urls, &Value::Str("api".to_string())), §ion), &access), &Value::Str("/".to_string())), &path);
} else {
url = add(&add(&add(&add(&get_value(&get_value(&get_value(&self.urls, &Value::Str("api".to_string())), §ion), &access), &Value::Str("/api/".to_string())), &self.version), &Value::Str("/".to_string())), &path);
}
let mut urlParams: Value = params.clone();
if is_equal(&access, &Value::Str("private".to_string())) {
if is_equal(§ion, &Value::Str("broker".to_string())) && is_true(&(is_true(&(is_equal(&method, &Value::Str("POST".to_string())))) || is_true(&(is_equal(&method, &Value::Str("PUT".to_string())))) || is_true(&(is_equal(&method, &Value::Str("DELETE".to_string())))))) {
urlParams = Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("timestamp".to_string(), self.nonce());
m.insert("recvWindow".to_string(), self.safe_integer_k(self.options.clone(), "recvWindow", &[Value::Int(5000)]));
m
});
body = self.json(params.clone());
} else {
add_element_to_object(&mut urlParams, &Value::Str("timestamp".to_string()), self.nonce());
add_element_to_object(&mut urlParams, &Value::Str("recvWindow".to_string()), self.safe_integer_k(self.options.clone(), "recvWindow", &[Value::Int(5000)]));
}
}
let mut paramsEncoded: Value = Value::Str("".to_string());
if is_greater_than(&get_array_length(&object_keys(&urlParams)), &Value::Int(0)) {
paramsEncoded = self.urlencode(urlParams.clone(), &[]);
url = add(&url, &add(&Value::Str("?".to_string()), ¶msEncoded));
}
if is_equal(&access, &Value::Str("private".to_string())) {
self.check_required_credentials(&[]);
let mut signature: Value = self.hmac(self.encode(paramsEncoded.clone()), self.encode(self.secret.clone()), Value::Str("sha256".to_string()), &[]);
url = add(&url, &add(&add(&Value::Str("&".to_string()), &Value::Str("signature=".to_string())), &signature));
headers = Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("X-MEXC-APIKEY".to_string(), self.apiKey.clone());
m.insert("source".to_string(), self.safe_string_k(self.options.clone(), "broker", &[Value::Str("CCXT".to_string())]));
m
});
}
if is_true(&(is_equal(&method, &Value::Str("POST".to_string())))) || is_true(&(is_equal(&method, &Value::Str("PUT".to_string())))) || is_true(&(is_equal(&method, &Value::Str("DELETE".to_string())))) {
headers = ternary(is_true(&(is_equal(&headers, &Value::Null))), Value::Map({
let mut m = indexmap::IndexMap::new();
m
}), headers.clone());
add_element_to_object(&mut headers, &Value::Str("Content-Type".to_string()), Value::Str("application/json".to_string()));
}
} else if is_equal(§ion, &Value::Str("contract".to_string())) || is_equal(§ion, &Value::Str("spot2".to_string())) {
url = add(&add(&get_value(&get_value(&get_value(&self.urls, &Value::Str("api".to_string())), §ion), &access), &Value::Str("/".to_string())), &self.implode_params(path.clone(), params.clone()));
params = self.omit(params.clone(), self.extract_params(path.clone()), &[]);
if is_equal(&access, &Value::Str("public".to_string())) {
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(), &[])));
}
} else {
self.check_required_credentials(&[]);
let mut timestamp: Value = to_string_val(&self.nonce());
let mut auth: Value = Value::Str("".to_string());
headers = Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("ApiKey".to_string(), self.apiKey.clone());
m.insert("Request-Time".to_string(), timestamp.clone());
m.insert("Content-Type".to_string(), Value::Str("application/json".to_string()));
m.insert("source".to_string(), self.safe_string_k(self.options.clone(), "broker", &[Value::Str("CCXT".to_string())]));
m
});
if is_equal(&method, &Value::Str("POST".to_string())) {
auth = self.json(params.clone());
body = auth.clone();
} else {
params = self.keysort(params.clone(), &[]);
if is_greater_than(&get_array_length(&object_keys(¶ms)), &Value::Int(0)) {
auth = add(&auth, &self.urlencode(params.clone(), &[]));
url = add(&url, &add(&Value::Str("?".to_string()), &auth));
}
}
auth = add(&add(&self.apiKey, ×tamp), &auth);
let mut signature: Value = self.hmac(self.encode(auth.clone()), self.encode(self.secret.clone()), Value::Str("sha256".to_string()), &[]);
add_element_to_object(&mut headers, &Value::Str("Signature".to_string()), signature.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 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_equal(&response, &Value::Null) {
return Value::Null;
}
// spot
// {"code":-1128,"msg":"Combination of optional parameters invalid.","_extend":null}
// {"success":false,"code":123456,"message":"Order quantity error...."}
//
// contract
//
// {"code":10232,"msg":"The currency not exist"}
// {"code":10216,"msg":"No available deposit address"}
// {"success":true, "code":0, "data":1634095541710}
//
let mut success: Value = self.safe_bool_k(response.clone(), "success", &[Value::Bool(false)]); // v1
if is_equal(&success, &Value::Bool(true)) {
return Value::Null;
}
let mut responseCode: Value = self.safe_string_k(response.clone(), "code", &[]);
if is_true(&(!is_equal(&responseCode, &Value::Null))) && is_true(&(!is_equal(&responseCode, &Value::Str("200".to_string())))) && is_true(&(!is_equal(&responseCode, &Value::Str("0".to_string())))) {
let mut feedback: Value = add(&add(&self.id, &Value::Str(" ".to_string())), &body);
self.throw_broadly_matched_exception(get_value(&self.exceptions, &Value::Str("broad".to_string())), body.clone(), feedback.clone());
self.throw_exactly_matched_exception(get_value(&self.exceptions, &Value::Str("exact".to_string())), responseCode.clone(), feedback.clone());
panic!("{}", crate::exchange_errors::exchange_error(feedback));
}
return Value::Null;
Value::Null
}
}