// 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 WhitebitCore {
pub exchange: crate::exchange::Exchange,
}
impl WhitebitCore {
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 = WhitebitCore::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 WhitebitCore {
fn nonce(&self, ) -> crate::Value {
// Forward to the inherent method on WhitebitCore.
WhitebitCore::nonce(self, )
}
fn parse_ticker(&self, ticker: crate::Value, market: crate::Value) -> crate::Value {
// Forward to the inherent method on WhitebitCore.
WhitebitCore::parse_ticker(self, ticker, &[market.clone()])
}
fn parse_trade(&self, trade: crate::Value, market: crate::Value) -> crate::Value {
// Forward to the inherent method on WhitebitCore.
WhitebitCore::parse_trade(self, trade, &[market.clone()])
}
fn parse_order(&self, order: crate::Value, market: crate::Value) -> crate::Value {
// Forward to the inherent method on WhitebitCore.
WhitebitCore::parse_order(self, order, &[market.clone()])
}
fn parse_market(&self, market: crate::Value) -> crate::Value {
// Forward to the inherent method on WhitebitCore.
WhitebitCore::parse_market(self, market)
}
fn parse_ohlcv(&self, ohlcv: crate::Value, market: crate::Value) -> crate::Value {
// Forward to the inherent method on WhitebitCore.
WhitebitCore::parse_ohlcv(self, ohlcv, &[market.clone()])
}
fn parse_balance(&self, response: crate::Value) -> crate::Value {
// Forward to the inherent method on WhitebitCore.
WhitebitCore::parse_balance(self, response)
}
fn parse_position(&self, position: crate::Value, market: crate::Value) -> crate::Value {
// Forward to the inherent method on WhitebitCore.
WhitebitCore::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 WhitebitCore.
WhitebitCore::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 WhitebitCore.
WhitebitCore::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 WhitebitCore.
WhitebitCore::parse_transfer(self, transfer, &[currency.clone()])
}
fn parse_currency(&self, currency: crate::Value) -> crate::Value {
// Forward to the inherent method on WhitebitCore.
WhitebitCore::parse_currency(self, currency)
}
fn parse_funding_rate_history(&self, entry: crate::Value, market: crate::Value) -> crate::Value {
// Forward to the inherent method on WhitebitCore.
WhitebitCore::parse_funding_rate_history(self, entry, &[market.clone()])
}
fn parse_transaction(&self, transaction: crate::Value, currency: crate::Value) -> crate::Value {
// Forward to the inherent method on WhitebitCore.
WhitebitCore::parse_transaction(self, transaction, &[currency.clone()])
}
fn parse_borrow_interest(&self, info: crate::Value, market: crate::Value) -> crate::Value {
// Forward to the inherent method on WhitebitCore.
WhitebitCore::parse_borrow_interest(self, info, &[market.clone()])
}
fn parse_conversion(&self, conversion: crate::Value, from_currency: crate::Value, to_currency: crate::Value) -> crate::Value {
// Forward to the inherent method on WhitebitCore.
WhitebitCore::parse_conversion(self, conversion, &[from_currency.clone(), to_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 WhitebitCore.
WhitebitCore::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 WhitebitCore.
WhitebitCore::handle_errors(self, code, reason, url, method, headers, body, response, request_headers, request_body)
}
}
impl crate::exchange_generated::ExchangeBase for WhitebitCore {
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 {
"cancel_all_orders" => self.cancel_all_orders(&args.get(0..).unwrap_or(&[]).to_vec()[..]).await,
"cancel_all_orders_after" => self.cancel_all_orders_after(args.get(0).cloned().unwrap_or(crate::Value::Null), &args.get(1..).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,
"create_convert_trade" => self.create_convert_trade(args.get(0).cloned().unwrap_or(crate::Value::Null), args.get(1).cloned().unwrap_or(crate::Value::Null), args.get(2).cloned().unwrap_or(crate::Value::Null), &args.get(3..).unwrap_or(&[]).to_vec()[..]).await,
"create_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_order_with_cost" => self.create_market_order_with_cost(args.get(0).cloned().unwrap_or(crate::Value::Null), args.get(1).cloned().unwrap_or(crate::Value::Null), args.get(2).cloned().unwrap_or(crate::Value::Null), &args.get(3..).unwrap_or(&[]).to_vec()[..]).await,
"create_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,
"edit_order" => self.edit_order(args.get(0).cloned().unwrap_or(crate::Value::Null), args.get(1).cloned().unwrap_or(crate::Value::Null), args.get(2).cloned().unwrap_or(crate::Value::Null), args.get(3).cloned().unwrap_or(crate::Value::Null), &args.get(4..).unwrap_or(&[]).to_vec()[..]).await,
"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_borrow_interest" => self.fetch_borrow_interest(&args.get(0..).unwrap_or(&[]).to_vec()[..]).await,
"fetch_closed_orders" => self.fetch_closed_orders(&args.get(0..).unwrap_or(&[]).to_vec()[..]).await,
"fetch_convert_quote" => self.fetch_convert_quote(args.get(0).cloned().unwrap_or(crate::Value::Null), args.get(1).cloned().unwrap_or(crate::Value::Null), &args.get(2..).unwrap_or(&[]).to_vec()[..]).await,
"fetch_convert_trade_history" => self.fetch_convert_trade_history(&args.get(0..).unwrap_or(&[]).to_vec()[..]).await,
"fetch_currencies" => self.fetch_currencies(&args.get(0..).unwrap_or(&[]).to_vec()[..]).await,
"fetch_deposit" => self.fetch_deposit(args.get(0).cloned().unwrap_or(crate::Value::Null), &args.get(1..).unwrap_or(&[]).to_vec()[..]).await,
"fetch_deposit_address" => self.fetch_deposit_address(args.get(0).cloned().unwrap_or(crate::Value::Null), &args.get(1..).unwrap_or(&[]).to_vec()[..]).await,
"fetch_deposit_withdraw_fees" => self.fetch_deposit_withdraw_fees(&args.get(0..).unwrap_or(&[]).to_vec()[..]).await,
"fetch_deposits" => self.fetch_deposits(&args.get(0..).unwrap_or(&[]).to_vec()[..]).await,
"fetch_deposits_withdrawals" => self.fetch_deposits_withdrawals(&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_limits" => self.fetch_funding_limits(&args.get(0..).unwrap_or(&[]).to_vec()[..]).await,
"fetch_funding_rate" => self.fetch_funding_rate(args.get(0).cloned().unwrap_or(crate::Value::Null), &args.get(1..).unwrap_or(&[]).to_vec()[..]).await,
"fetch_funding_rate_history" => self.fetch_funding_rate_history(&args.get(0..).unwrap_or(&[]).to_vec()[..]).await,
"fetch_funding_rates" => self.fetch_funding_rates(&args.get(0..).unwrap_or(&[]).to_vec()[..]).await,
"fetch_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_position" => self.fetch_position(args.get(0).cloned().unwrap_or(crate::Value::Null), &args.get(1..).unwrap_or(&[]).to_vec()[..]).await,
"fetch_position_history" => self.fetch_position_history(args.get(0).cloned().unwrap_or(crate::Value::Null), &args.get(1..).unwrap_or(&[]).to_vec()[..]).await,
"fetch_positions" => self.fetch_positions(&args.get(0..).unwrap_or(&[]).to_vec()[..]).await,
"fetch_status" => self.fetch_status(&args.get(0..).unwrap_or(&[]).to_vec()[..]).await,
"fetch_ticker" => self.fetch_ticker(args.get(0).cloned().unwrap_or(crate::Value::Null), &args.get(1..).unwrap_or(&[]).to_vec()[..]).await,
"fetch_tickers" => self.fetch_tickers(&args.get(0..).unwrap_or(&[]).to_vec()[..]).await,
"fetch_time" => self.fetch_time(&args.get(0..).unwrap_or(&[]).to_vec()[..]).await,
"fetch_trades" => self.fetch_trades(args.get(0).cloned().unwrap_or(crate::Value::Null), &args.get(1..).unwrap_or(&[]).to_vec()[..]).await,
"fetch_trading_fees" => self.fetch_trading_fees(&args.get(0..).unwrap_or(&[]).to_vec()[..]).await,
"fetch_trading_limits" => self.fetch_trading_limits(&args.get(0..).unwrap_or(&[]).to_vec()[..]).await,
"fetch_transaction_fees" => self.fetch_transaction_fees(&args.get(0..).unwrap_or(&[]).to_vec()[..]).await,
"fetch_transactions" => self.fetch_transactions(&args.get(0..).unwrap_or(&[]).to_vec()[..]).await,
"fetch_withdrawals" => self.fetch_withdrawals(&args.get(0..).unwrap_or(&[]).to_vec()[..]).await,
"handle_errors" => self.handle_errors(args.get(0).cloned().unwrap_or(crate::Value::Null), args.get(1).cloned().unwrap_or(crate::Value::Null), args.get(2).cloned().unwrap_or(crate::Value::Null), args.get(3).cloned().unwrap_or(crate::Value::Null), args.get(4).cloned().unwrap_or(crate::Value::Null), args.get(5).cloned().unwrap_or(crate::Value::Null), args.get(6).cloned().unwrap_or(crate::Value::Null), args.get(7).cloned().unwrap_or(crate::Value::Null), args.get(8).cloned().unwrap_or(crate::Value::Null)),
"is_fiat" => self.is_fiat(args.get(0).cloned().unwrap_or(crate::Value::Null)),
"nonce" => self.nonce(),
"parse_balance" => self.parse_balance(args.get(0).cloned().unwrap_or(crate::Value::Null)),
"parse_borrow_interest" => self.parse_borrow_interest(args.get(0).cloned().unwrap_or(crate::Value::Null), &args.get(1..).unwrap_or(&[]).to_vec()[..]),
"parse_conversion" => self.parse_conversion(args.get(0).cloned().unwrap_or(crate::Value::Null), &args.get(1..).unwrap_or(&[]).to_vec()[..]),
"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_fees" => self.parse_deposit_withdraw_fees(args.get(0).cloned().unwrap_or(crate::Value::Null), &args.get(1..).unwrap_or(&[]).to_vec()[..]),
"parse_funding_histories" => self.parse_funding_histories(args.get(0).cloned().unwrap_or(crate::Value::Null), &args.get(1..).unwrap_or(&[]).to_vec()[..]),
"parse_funding_history" => self.parse_funding_history(args.get(0).cloned().unwrap_or(crate::Value::Null), &args.get(1..).unwrap_or(&[]).to_vec()[..]),
"parse_funding_rate" => self.parse_funding_rate(args.get(0).cloned().unwrap_or(crate::Value::Null), &args.get(1..).unwrap_or(&[]).to_vec()[..]),
"parse_funding_rate_history" => self.parse_funding_rate_history(args.get(0).cloned().unwrap_or(crate::Value::Null), &args.get(1..).unwrap_or(&[]).to_vec()[..]),
"parse_market" => self.parse_market(args.get(0).cloned().unwrap_or(crate::Value::Null)),
"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_status" => self.parse_order_status(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_status" => self.parse_transaction_status(args.get(0).cloned().unwrap_or(crate::Value::Null)),
"parse_transfer" => self.parse_transfer(args.get(0).cloned().unwrap_or(crate::Value::Null), &args.get(1..).unwrap_or(&[]).to_vec()[..]),
"set_leverage" => self.set_leverage(args.get(0).cloned().unwrap_or(crate::Value::Null), &args.get(1..).unwrap_or(&[]).to_vec()[..]).await,
"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 WhitebitCore {
type Target = crate::exchange::Exchange;
fn deref(&self) -> &crate::exchange::Exchange { &self.exchange }
}
impl std::ops::DerefMut for WhitebitCore {
fn deref_mut(&mut self) -> &mut crate::exchange::Exchange { &mut self.exchange }
}
impl WhitebitCore {
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("whitebit".to_string()));
m.insert("name".to_string(), Value::Str("WhiteBit".to_string()));
m.insert("version".to_string(), Value::Str("v4".to_string()));
m.insert("countries".to_string(), Value::List(vec![Value::Str("EE".to_string())]));
m.insert("rateLimit".to_string(), Value::Int(20));
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("cancelAllOrders".to_string(), Value::Bool(true));
m.insert("cancelAllOrdersAfter".to_string(), Value::Bool(true));
m.insert("cancelOrder".to_string(), Value::Bool(true));
m.insert("cancelOrders".to_string(), Value::Bool(false));
m.insert("createConvertTrade".to_string(), Value::Bool(true));
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(false));
m.insert("createOrder".to_string(), Value::Bool(true));
m.insert("createPostOnlyOrder".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("editOrder".to_string(), Value::Bool(true));
m.insert("fetchAccounts".to_string(), Value::Bool(true));
m.insert("fetchBalance".to_string(), Value::Bool(true));
m.insert("fetchBorrowInterest".to_string(), Value::Bool(true));
m.insert("fetchBorrowRateHistories".to_string(), Value::Bool(false));
m.insert("fetchBorrowRateHistory".to_string(), Value::Bool(false));
m.insert("fetchClosedOrders".to_string(), Value::Bool(true));
m.insert("fetchConvertQuote".to_string(), Value::Bool(true));
m.insert("fetchConvertTrade".to_string(), Value::Bool(false));
m.insert("fetchConvertTradeHistory".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::Bool(true));
m.insert("fetchDepositAddress".to_string(), Value::Bool(true));
m.insert("fetchDepositAddresses".to_string(), Value::Bool(false));
m.insert("fetchDepositAddressesByNetwork".to_string(), Value::Bool(false));
m.insert("fetchDeposits".to_string(), Value::Bool(true));
m.insert("fetchDepositsWithdrawals".to_string(), Value::Bool(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("fetchFundingLimits".to_string(), Value::Bool(true));
m.insert("fetchFundingRate".to_string(), Value::Bool(true));
m.insert("fetchFundingRateHistory".to_string(), Value::Bool(true));
m.insert("fetchFundingRates".to_string(), Value::Bool(true));
m.insert("fetchIndexOHLCV".to_string(), Value::Bool(false));
m.insert("fetchIsolatedBorrowRate".to_string(), Value::Bool(false));
m.insert("fetchIsolatedBorrowRates".to_string(), Value::Bool(false));
m.insert("fetchLedger".to_string(), Value::Bool(false));
m.insert("fetchMarginMode".to_string(), Value::Bool(false));
m.insert("fetchMarkets".to_string(), Value::Bool(true));
m.insert("fetchMarkOHLCV".to_string(), Value::Bool(false));
m.insert("fetchMyTrades".to_string(), Value::Bool(true));
m.insert("fetchOHLCV".to_string(), Value::Bool(true));
m.insert("fetchOpenInterestHistory".to_string(), Value::Bool(false));
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("fetchOrders".to_string(), Value::Bool(true));
m.insert("fetchOrderTrades".to_string(), Value::Bool(true));
m.insert("fetchPosition".to_string(), Value::Bool(true));
m.insert("fetchPositionHistory".to_string(), Value::Bool(true));
m.insert("fetchPositionMode".to_string(), Value::Bool(false));
m.insert("fetchPositions".to_string(), Value::Bool(true));
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(false));
m.insert("fetchTradingFees".to_string(), Value::Bool(true));
m.insert("fetchTradingLimits".to_string(), Value::Bool(true));
m.insert("fetchTransactionFees".to_string(), Value::Bool(true));
m.insert("fetchTransactions".to_string(), Value::Bool(true));
m.insert("fetchWithdrawals".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("transfer".to_string(), Value::Bool(true));
m.insert("withdraw".to_string(), Value::Bool(true));
m
}));
m.insert("timeframes".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("1m".to_string(), Value::Str("1m".to_string()));
m.insert("3m".to_string(), Value::Str("3m".to_string()));
m.insert("5m".to_string(), Value::Str("5m".to_string()));
m.insert("15m".to_string(), Value::Str("15m".to_string()));
m.insert("30m".to_string(), Value::Str("30m".to_string()));
m.insert("1h".to_string(), Value::Str("1h".to_string()));
m.insert("2h".to_string(), Value::Str("2h".to_string()));
m.insert("4h".to_string(), Value::Str("4h".to_string()));
m.insert("6h".to_string(), Value::Str("6h".to_string()));
m.insert("8h".to_string(), Value::Str("8h".to_string()));
m.insert("12h".to_string(), Value::Str("12h".to_string()));
m.insert("1d".to_string(), Value::Str("1d".to_string()));
m.insert("3d".to_string(), Value::Str("3d".to_string()));
m.insert("1w".to_string(), Value::Str("1w".to_string()));
m.insert("1M".to_string(), Value::Str("1M".to_string()));
m
}));
m.insert("urls".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("logo".to_string(), Value::Str("https://user-images.githubusercontent.com/1294454/66732963-8eb7dd00-ee66-11e9-849b-10d9282bb9e0.jpg".to_string()));
m.insert("api".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("v1".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("public".to_string(), Value::Str("https://whitebit.com/api/v1/public".to_string()));
m.insert("private".to_string(), Value::Str("https://whitebit.com/api/v1".to_string()));
m
}));
m.insert("v2".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("public".to_string(), Value::Str("https://whitebit.com/api/v2/public".to_string()));
m
}));
m.insert("v4".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("public".to_string(), Value::Str("https://whitebit.com/api/v4/public".to_string()));
m.insert("private".to_string(), Value::Str("https://whitebit.com/api/v4".to_string()));
m
}));
m
}));
m.insert("www".to_string(), Value::Str("https://www.whitebit.com".to_string()));
m.insert("doc".to_string(), Value::Str("https://github.com/whitebit-exchange/api-docs".to_string()));
m.insert("fees".to_string(), Value::Str("https://whitebit.com/fee-schedule".to_string()));
m.insert("referral".to_string(), Value::Str("https://whitebit.com/referral/d9bdf40e-28f2-4b52-b2f9-cd1415d82963".to_string()));
m
}));
m.insert("api".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("web".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("v1/healthcheck".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(1));
m
}));
m
}));
m
}));
m.insert("v1".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("markets".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(1));
m
}));
m.insert("tickers".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(1));
m
}));
m.insert("ticker".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(1));
m
}));
m.insert("symbols".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(1));
m
}));
m.insert("depth/result".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(1));
m
}));
m.insert("history".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(1));
m
}));
m.insert("kline".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("post".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("account/balance".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(1));
m
}));
m.insert("order/new".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(1));
m
}));
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("orders".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(1));
m
}));
m.insert("account/order_history".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(1));
m
}));
m.insert("account/executed_history".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(1));
m
}));
m.insert("account/executed_history/all".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(1));
m
}));
m.insert("account/order".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(1));
m
}));
m
}));
m
}));
m
}));
m.insert("v2".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("markets".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(1));
m
}));
m.insert("ticker".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(1));
m
}));
m.insert("assets".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(1));
m
}));
m.insert("fee".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(1));
m
}));
m.insert("depth/{market}".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(1));
m
}));
m.insert("trades/{market}".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(1));
m
}));
m
}));
m
}));
m
}));
m.insert("v4".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("assets".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(1));
m
}));
m.insert("collateral/markets".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(1));
m
}));
m.insert("fee".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(1));
m
}));
m.insert("funding-history/{market}".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(1));
m
}));
m.insert("orderbook/depth/{market}".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(1));
m
}));
m.insert("orderbook/{market}".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(1));
m
}));
m.insert("ticker".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(1));
m
}));
m.insert("trades/{market}".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("ping".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(1));
m
}));
m.insert("markets".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(1));
m
}));
m.insert("futures".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(1));
m
}));
m.insert("platform/status".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(1));
m
}));
m.insert("mining-pool".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("post".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("collateral-account/balance".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(1));
m
}));
m.insert("collateral-account/balance-summary".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(1));
m
}));
m.insert("collateral-account/positions/history".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(1));
m
}));
m.insert("collateral-account/leverage".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(1));
m
}));
m.insert("collateral-account/positions/open".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(1));
m
}));
m.insert("collateral-account/summary".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(1));
m
}));
m.insert("collateral-account/funding-history".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(1));
m
}));
m.insert("main-account/address".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(1));
m
}));
m.insert("main-account/balance".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(1));
m
}));
m.insert("main-account/create-new-address".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(1));
m
}));
m.insert("main-account/codes".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(1));
m
}));
m.insert("main-account/codes/apply".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(1));
m
}));
m.insert("main-account/codes/my".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(1));
m
}));
m.insert("main-account/codes/history".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(1));
m
}));
m.insert("main-account/fiat-deposit-url".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(1));
m
}));
m.insert("main-account/history".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(1));
m
}));
m.insert("main-account/withdraw".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(1));
m
}));
m.insert("main-account/withdraw-pay".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(1));
m
}));
m.insert("main-account/transfer".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(1));
m
}));
m.insert("main-account/smart/plans".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(1));
m
}));
m.insert("main-account/smart/investment".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(1));
m
}));
m.insert("main-account/smart/investment/close".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(1));
m
}));
m.insert("main-account/smart/investments".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(1));
m
}));
m.insert("main-account/fee".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(1));
m
}));
m.insert("main-account/smart/interest-payment-history".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(1));
m
}));
m.insert("trade-account/balance".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(1));
m
}));
m.insert("trade-account/executed-history".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(1));
m
}));
m.insert("trade-account/order/history".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(1));
m
}));
m.insert("trade-account/order".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(1));
m
}));
m.insert("order/collateral/limit".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(1));
m
}));
m.insert("order/collateral/market".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(1));
m
}));
m.insert("order/collateral/stop-limit".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(1));
m
}));
m.insert("order/collateral/trigger-market".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(1));
m
}));
m.insert("order/collateral/bulk".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(1));
m
}));
m.insert("order/new".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(1));
m
}));
m.insert("order/market".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(1));
m
}));
m.insert("order/stock_market".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(1));
m
}));
m.insert("order/stop_limit".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(1));
m
}));
m.insert("order/stop_market".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(1));
m
}));
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/all".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(1));
m
}));
m.insert("order/kill-switch".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(1));
m
}));
m.insert("order/kill-switch/status".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(1));
m
}));
m.insert("order/bulk".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(1));
m
}));
m.insert("order/modify".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(1));
m
}));
m.insert("order/conditional-cancel".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(1));
m
}));
m.insert("orders".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(1));
m
}));
m.insert("oco-orders".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(1));
m
}));
m.insert("order/collateral/oco".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(1));
m
}));
m.insert("order/oco-cancel".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(1));
m
}));
m.insert("order/oto-cancel".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(1));
m
}));
m.insert("profile/websocket_token".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(1));
m
}));
m.insert("convert/estimate".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(1));
m
}));
m.insert("convert/confirm".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(1));
m
}));
m.insert("convert/history".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(1));
m
}));
m.insert("sub-account/create".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(1));
m
}));
m.insert("sub-account/delete".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(1));
m
}));
m.insert("sub-account/edit".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/transfer".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(1));
m
}));
m.insert("sub-account/block".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(1));
m
}));
m.insert("sub-account/unblock".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(1));
m
}));
m.insert("sub-account/balances".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(1));
m
}));
m.insert("sub-account/transfer/history".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(1));
m
}));
m.insert("sub-account/api-key/create".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(1));
m
}));
m.insert("sub-account/api-key/edit".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(1));
m
}));
m.insert("sub-account/api-key/delete".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(1));
m
}));
m.insert("sub-account/api-key/list".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(1));
m
}));
m.insert("sub-account/api-key/reset".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(1));
m
}));
m.insert("sub-account/api-key/ip-address/list".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(1));
m
}));
m.insert("sub-account/api-key/ip-address/create".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(1));
m
}));
m.insert("sub-account/api-key/ip-address/delete".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(1));
m
}));
m.insert("mining/rewards".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(1));
m
}));
m.insert("market/fee".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(1));
m
}));
m.insert("conditional-orders".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("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("taker".to_string(), self.parse_number(Value::Str("0.001".to_string()), &[]));
m.insert("maker".to_string(), self.parse_number(Value::Str("0.001".to_string()), &[]));
m
}));
m
}));
m.insert("options".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("timeDifference".to_string(), Value::Int(0));
m.insert("adjustForTimeDifference".to_string(), Value::Bool(false));
m.insert("fiatCurrencies".to_string(), Value::List(vec![Value::Str("EUR".to_string()), Value::Str("USD".to_string()), Value::Str("RUB".to_string()), Value::Str("UAH".to_string())]));
m.insert("nonceWindow".to_string(), Value::Bool(false));
m.insert("fetchBalance".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("account".to_string(), Value::Str("spot".to_string()));
m
}));
m.insert("accountsByType".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("funding".to_string(), Value::Str("main".to_string()));
m.insert("main".to_string(), Value::Str("main".to_string()));
m.insert("spot".to_string(), Value::Str("spot".to_string()));
m.insert("margin".to_string(), Value::Str("collateral".to_string()));
m.insert("trade".to_string(), Value::Str("spot".to_string()));
m
}));
m.insert("networksById".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m
}));
m.insert("defaultType".to_string(), Value::Str("spot".to_string()));
m.insert("brokerId".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(true));
m.insert("triggerDirection".to_string(), Value::Bool(false));
m.insert("triggerPriceType".to_string(), Value::Null);
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(false));
m.insert("PO".to_string(), Value::Bool(true));
m.insert("GTD".to_string(), Value::Bool(false));
m
}));
m.insert("hedged".to_string(), Value::Bool(false));
m.insert("trailing".to_string(), Value::Bool(false));
m.insert("leverage".to_string(), Value::Bool(false));
m.insert("marketBuyByCost".to_string(), Value::Bool(true));
m.insert("marketBuyRequiresPrice".to_string(), Value::Bool(false));
m.insert("selfTradePrevention".to_string(), Value::Bool(false));
m.insert("iceberg".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::Null);
m.insert("untilDays".to_string(), Value::Null);
m.insert("symbolRequired".to_string(), Value::Bool(false));
m
}));
m.insert("fetchOrder".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("checkActive".to_string(), Value::Bool(true));
m.insert("checkExecuted".to_string(), Value::Bool(true));
m.insert("symbolRequired".to_string(), Value::Bool(false));
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
}));
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(false));
m.insert("trailing".to_string(), Value::Bool(false));
m.insert("symbolRequired".to_string(), Value::Bool(false));
m
}));
m.insert("fetchOrders".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("marginMode".to_string(), Value::Bool(false));
m.insert("limit".to_string(), Value::Int(100));
m.insert("daysBack".to_string(), Value::Null);
m.insert("untilDays".to_string(), Value::Null);
m.insert("trigger".to_string(), Value::Bool(false));
m.insert("trailing".to_string(), Value::Bool(false));
m.insert("symbolRequired".to_string(), Value::Bool(false));
m
}));
m.insert("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::Null);
m.insert("daysBackCanceled".to_string(), Value::Null);
m.insert("untilDays".to_string(), Value::Null);
m.insert("trigger".to_string(), Value::Bool(false));
m.insert("trailing".to_string(), Value::Bool(false));
m.insert("symbolRequired".to_string(), Value::Bool(false));
m
}));
m.insert("fetchOHLCV".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("limit".to_string(), Value::Int(1440));
m
}));
m.insert("fetchWithdrawals".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::Null);
m.insert("untilDays".to_string(), Value::Null);
m.insert("symbolRequired".to_string(), Value::Bool(false));
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
}));
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("default".to_string()));
m
}));
m.insert("inverse".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("extends".to_string(), Value::Str("default".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("precisionMode".to_string(), Value::Int(crate::runtime::TICK_SIZE));
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("Unauthorized request.".to_string(), Value::Str("AuthenticationError".to_string()).clone());
m.insert("The market format is invalid.".to_string(), Value::Str("BadSymbol".to_string()).clone());
m.insert("Market is not available".to_string(), Value::Str("BadSymbol".to_string()).clone());
m.insert("Invalid payload.".to_string(), Value::Str("BadRequest".to_string()).clone());
m.insert("Amount must be greater than 0".to_string(), Value::Str("InvalidOrder".to_string()).clone());
m.insert("Not enough balance.".to_string(), Value::Str("InsufficientFunds".to_string()).clone());
m.insert("The order id field is required.".to_string(), Value::Str("InvalidOrder".to_string()).clone());
m.insert("Not enough balance".to_string(), Value::Str("InsufficientFunds".to_string()).clone());
m.insert("This action is unauthorized.".to_string(), Value::Str("PermissionDenied".to_string()).clone());
m.insert("This API Key is not authorized to perform this action.".to_string(), Value::Str("PermissionDenied".to_string()).clone());
m.insert("Unexecuted order was not found.".to_string(), Value::Str("OrderNotFound".to_string()).clone());
m.insert("The selected from is invalid.".to_string(), Value::Str("BadRequest".to_string()).clone());
m.insert("503".to_string(), Value::Str("ExchangeNotAvailable".to_string()).clone());
m.insert("422".to_string(), Value::Str("OrderNotFound".to_string()).clone());
m
}));
m.insert("broad".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("limit must be less than or equal to".to_string(), Value::Str("BadRequest".to_string()).clone());
m.insert("The Price should be less than or equal to".to_string(), Value::Str("InvalidOrder".to_string()).clone());
m.insert("The Price should be greater than or equal to".to_string(), Value::Str("InvalidOrder".to_string()).clone());
m.insert("This action is unauthorized".to_string(), Value::Str("PermissionDenied".to_string()).clone());
m.insert("Given amount is less than min amount".to_string(), Value::Str("InvalidOrder".to_string()).clone());
m.insert("Min amount step".to_string(), Value::Str("InvalidOrder".to_string()).clone());
m.insert("Total is less than".to_string(), Value::Str("InvalidOrder".to_string()).clone());
m.insert("fee must be no less than".to_string(), Value::Str("InvalidOrder".to_string()).clone());
m.insert("Enable your key in API settings".to_string(), Value::Str("PermissionDenied".to_string()).clone());
m.insert("You don't have such amount for transfer".to_string(), Value::Str("InsufficientFunds".to_string()).clone());
m
}));
m
}));
m
})]);
Value::Null
}
/*
* @method
* @name whitebit#fetchMarkets
* @description retrieves data on all markets for whitebit
* @see https://docs.whitebit.com/public/http-v4/#market-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_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 markets: Value = self.v4_public_get_markets(&[]).await;
return self.parse_markets(markets.clone());
Value::Null
}
pub fn parse_market(&self, mut market: Value) -> Value {
let mut id: Value = self.safe_string_k(market.clone(), "name", &[]);
let mut baseId: Value = self.safe_string_k(market.clone(), "stock", &[]);
let mut quoteId: Value = self.safe_string_k(market.clone(), "money", &[]);
quoteId = ternary(is_true(&(is_equal("eId, &Value::Str("PERP".to_string())))), Value::Str("USDT".to_string()), quoteId.clone());
let mut base: Value = self.safe_currency_code(baseId.clone(), &[]);
let mut quote: Value = self.safe_currency_code(quoteId.clone(), &[]);
let mut active: Value = self.safe_value_k(market.clone(), "tradesEnabled", &[]);
let mut isCollateral: Value = self.safe_value_k(market.clone(), "isCollateral", &[]);
let mut typeId: Value = self.safe_string_k(market.clone(), "type", &[]);
let mut type_var: Value = Value::Null;
let mut settle: Value = Value::Null;
let mut settleId: Value = Value::Null;
let mut symbol: Value = add(&add(&base, &Value::Str("/".to_string())), "e);
let mut swap: Value = Value::Bool(is_true(&(is_equal(&typeId, &Value::Str("futures".to_string())))) || is_true(&(is_equal(&typeId, &Value::Str("tradfiFutures".to_string())))));
let mut margin: Value = Value::Bool(is_true(&(is_equal(&isCollateral, &Value::Bool(true)))) && !is_true(&swap));
let mut contract: Value = Value::Bool(false);
let mut amountPrecision: Value = self.parse_number(self.parse_precision(&[self.safe_string_k(market.clone(), "stockPrec", &[])]), &[]);
let mut linear: Value = Value::Null;
let mut inverse: Value = Value::Null;
if is_true(&swap) {
settleId = quoteId.clone();
settle = self.safe_currency_code(settleId.clone(), &[]);
symbol = add(&add(&symbol, &Value::Str(":".to_string())), &settle);
type_var = Value::Str("swap".to_string());
contract = Value::Bool(true);
linear = Value::Bool(true);
inverse = Value::Bool(false);
} else {
type_var = Value::Str("spot".to_string());
}
let mut takerFeeRate: Value = self.safe_string_k(market.clone(), "takerFee", &[]);
let mut taker: Value = crate::precise::Precise::stringDiv(&takerFeeRate, &Value::Str("100".to_string()));
let mut makerFeeRate: Value = self.safe_string_k(market.clone(), "makerFee", &[]);
let mut maker: Value = crate::precise::Precise::stringDiv(&makerFeeRate, &Value::Str("100".to_string()));
let mut isSpot: Value = Value::Bool(!is_true(&swap));
return self.safe_market_structure(&[Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("id".to_string(), id.clone());
m.insert("symbol".to_string(), symbol.clone());
m.insert("base".to_string(), base.clone());
m.insert("quote".to_string(), quote.clone());
m.insert("settle".to_string(), settle.clone());
m.insert("baseId".to_string(), baseId.clone());
m.insert("quoteId".to_string(), quoteId.clone());
m.insert("settleId".to_string(), settleId.clone());
m.insert("type".to_string(), type_var.clone());
m.insert("spot".to_string(), isSpot.clone());
m.insert("margin".to_string(), margin.clone());
m.insert("swap".to_string(), swap.clone());
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(), contract.clone());
m.insert("linear".to_string(), linear.clone());
m.insert("inverse".to_string(), inverse.clone());
m.insert("taker".to_string(), self.parse_number(taker.clone(), &[]));
m.insert("maker".to_string(), self.parse_number(maker.clone(), &[]));
m.insert("contractSize".to_string(), ternary(is_true(&isSpot), Value::Null, self.parse_number(Value::Str("1".to_string()), &[])));
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(), amountPrecision.clone());
m.insert("price".to_string(), self.parse_number(self.parse_precision(&[self.safe_string_k(market.clone(), "moneyPrec", &[])]), &[]));
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(), "minAmount", &[]));
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(), "minTotal", &[]));
m.insert("max".to_string(), self.safe_number_k(market.clone(), "maxTotal", &[]));
m
}));
m
}));
m.insert("created".to_string(), Value::Null);
m.insert("info".to_string(), market.clone());
m
})]);
Value::Null
}
/*
* @method
* @name whitebit#fetchCurrencies
* @description fetches all available currencies on an exchange
* @see https://docs.whitebit.com/public/http-v4/#asset-status-list
* @param {object} [params] extra parameters specific to the exchange API endpoint
* @returns {object} an associative dictionary of currencies
*/
pub async fn fetch_currencies(&mut self, optional_args: &[Value]) -> Value {
let mut params = get_arg(optional_args, 0, Value::Map({
let mut m = indexmap::IndexMap::new();
m
}));
let mut response: Value = self.v4_public_get_assets(&[params.clone()]).await;
//
// {
// BTC: {
// name: "Bitcoin",
// unified_cryptoasset_id: "1",
// can_withdraw: true,
// can_deposit: true,
// min_withdraw: "0.0003",
// max_withdraw: "0",
// maker_fee: "0.1",
// taker_fee: "0.1",
// min_deposit: "0.0001",
// max_deposit: "0",
// networks: {
// deposits: [ "BTC", ],
// withdraws: [ "BTC", ],
// default: "BTC",
// },
// confirmations: {
// BTC: "2",
// },
// limits: {
// deposit: {
// BTC: { min: "0.0001", },
// },
// withdraw: {
// BTC: { min: "0.0003", },
// },
// },
// currency_precision: "8",
// is_memo: false,
// },
// USD: {
// name: "United States Dollar",
// unified_cryptoasset_id: "6955",
// can_withdraw: true,
// can_deposit: true,
// min_withdraw: "10",
// max_withdraw: "10000",
// maker_fee: "0.1",
// taker_fee: "0.1",
// min_deposit: "10",
// max_deposit: "10000",
// networks: {
// deposits: [ "USD", ],
// withdraws: [ "USD", ],
// default: "USD",
// },
// providers: {
// deposits: [ "ADVCASH", ],
// withdraws: [ "ADVCASH", ],
// },
// limits: {
// deposit: {
// USD: { max: "10000", min: "10", },
// },
// withdraw: {
// USD: { max: "10000", min: "10", },
// },
// },
// currency_precision: "2",
// is_memo: false,
// }
// }
//
let mut enhancedArray: Value = self.add_key_in_array_items(response.clone(), Value::Str("_coin_id".to_string()));
return self.parse_currencies(enhancedArray.clone());
Value::Null
}
pub fn parse_currency(&self, mut rawCurrency: Value) -> Value {
// const name = this.safeString (currency, 'name'); // breaks down in Python due to utf8 encoding issues on the exchange side
let mut id: Value = self.safe_string_k(rawCurrency.clone(), "_coin_id", &[]);
let mut code: Value = self.safe_currency_code(id.clone(), &[]);
let mut hasProvider: Value = (Value::Bool(in_op(&rawCurrency, &Value::Str("providers".to_string()))));
let mut networks: Value = Value::Map({
let mut m = indexmap::IndexMap::new();
m
});
let mut rawNetworks: Value = self.safe_dict_k(rawCurrency.clone(), "networks", &[Value::Map({
let mut m = indexmap::IndexMap::new();
m
})]);
let mut depositsNetworks: Value = self.safe_list_k(rawNetworks.clone(), "deposits", &[Value::List(vec![])]);
let mut withdrawsNetworks: Value = self.safe_list_k(rawNetworks.clone(), "withdraws", &[Value::List(vec![])]);
let mut networkLimits: Value = self.safe_dict_k(rawCurrency.clone(), "limits", &[Value::Map({
let mut m = indexmap::IndexMap::new();
m
})]);
let mut depositLimits: Value = self.safe_dict_k(networkLimits.clone(), "deposit", &[Value::Map({
let mut m = indexmap::IndexMap::new();
m
})]);
let mut withdrawLimits: Value = self.safe_dict_k(networkLimits.clone(), "withdraw", &[Value::Map({
let mut m = indexmap::IndexMap::new();
m
})]);
let mut allNetworks: Value = self.array_concat(depositsNetworks.clone(), withdrawsNetworks.clone());
{
let mut j: Value = Value::Int(0);
let mut __for_first_1097: bool = true;
while { if !__for_first_1097 { j = add(&j, &Value::Int(1)); } __for_first_1097 = false; is_less_than(&j, &get_array_length(&allNetworks)) } {
let mut networkId: Value = get_value(&allNetworks, &j);
let mut networkId: Value = get_value(&allNetworks, &j);
let mut networkCode: Value = self.network_id_to_code(&[networkId.clone(), code.clone()]);
let mut networkDepositLimits: Value = self.safe_dict(depositLimits.clone(), networkId.clone(), &[Value::Map({
let mut m = indexmap::IndexMap::new();
m
})]);
let mut networkWithdrawLimits: Value = self.safe_dict(withdrawLimits.clone(), networkId.clone(), &[Value::Map({
let mut m = indexmap::IndexMap::new();
m
})]);
if !is_equal(&networkCode, &Value::Null) {
add_element_to_object(&mut networks, &networkCode, Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("id".to_string(), networkId.clone());
m.insert("network".to_string(), networkCode.clone());
m.insert("active".to_string(), Value::Null);
m.insert("deposit".to_string(), self.in_array(networkId.clone(), depositsNetworks.clone()));
m.insert("withdraw".to_string(), self.in_array(networkId.clone(), withdrawsNetworks.clone()));
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("deposit".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("min".to_string(), self.safe_number_k(networkDepositLimits.clone(), "min", &[]));
m.insert("max".to_string(), self.safe_number_k(networkDepositLimits.clone(), "max", &[]));
m
}));
m.insert("withdraw".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("min".to_string(), self.safe_number_k(networkWithdrawLimits.clone(), "min", &[]));
m.insert("max".to_string(), self.safe_number_k(networkWithdrawLimits.clone(), "max", &[]));
m
}));
m
}));
m
}));
}
}
}
return self.safe_currency_structure(Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("id".to_string(), id.clone());
m.insert("code".to_string(), code.clone());
m.insert("info".to_string(), rawCurrency.clone());
m.insert("name".to_string(), Value::Null);
m.insert("active".to_string(), Value::Null);
m.insert("deposit".to_string(), self.safe_bool_k(rawCurrency.clone(), "can_deposit", &[]));
m.insert("withdraw".to_string(), self.safe_bool_k(rawCurrency.clone(), "can_withdraw", &[]));
m.insert("fee".to_string(), Value::Null);
m.insert("networks".to_string(), networks.clone());
m.insert("type".to_string(), ternary(is_true(&hasProvider), Value::Str("fiat".to_string()), Value::Str("crypto".to_string())));
m.insert("precision".to_string(), self.parse_number(self.parse_precision(&[self.safe_string_k(rawCurrency.clone(), "currency_precision", &[])]), &[]));
m.insert("limits".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("amount".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("min".to_string(), Value::Null);
m.insert("max".to_string(), Value::Null);
m
}));
m.insert("withdraw".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("min".to_string(), self.safe_number_k(rawCurrency.clone(), "min_withdraw", &[]));
m.insert("max".to_string(), self.safe_number_k(rawCurrency.clone(), "max_withdraw", &[]));
m
}));
m.insert("deposit".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("min".to_string(), self.safe_number_k(rawCurrency.clone(), "min_deposit", &[]));
m.insert("max".to_string(), self.safe_number_k(rawCurrency.clone(), "max_deposit", &[]));
m
}));
m
}));
m
}));
Value::Null
}
/*
* @method
* @name whitebit#fetchTransactionFees
* @deprecated
* @description please use fetchDepositWithdrawFees instead
* @see https://docs.whitebit.com/public/http-v4/#fee
* @param {string[]|undefined} codes not used by fetchTransactionFees ()
* @param {object} [params] extra parameters specific to the exchange API endpoint
* @returns {object} a list of [fee structures]{@link https://docs.ccxt.com/?id=fee-structure}
*/
pub async fn fetch_transaction_fees(&mut self, optional_args: &[Value]) -> Value {
let mut codes = get_arg(optional_args, 0, Value::Null);
let mut params = get_arg(optional_args, 1, Value::Map({
let mut m = indexmap::IndexMap::new();
m
}));
if is_equal(&self.markets, &Value::Null) {
self.load_markets(&[]).await;
}
let mut response: Value = self.v4_public_get_fee(&[params.clone()]).await;
//
// {
// "1INCH":{
// "is_depositable":true,
// "is_withdrawal":true,
// "ticker":"1INCH",
// "name":"1inch",
// "providers":[
// ],
// "withdraw":{
// "max_amount":"0",
// "min_amount":"21.5",
// "fixed":"17.5",
// "flex":null
// },
// "deposit":{
// "max_amount":"0",
// "min_amount":"19.5",
// "fixed":null,
// "flex":null
// }
// },
// {...}
// }
//
let mut currenciesIds: Value = object_keys(&response);
let mut withdrawFees: Value = Value::Map({
let mut m = indexmap::IndexMap::new();
m
});
let mut depositFees: Value = Value::Map({
let mut m = indexmap::IndexMap::new();
m
});
{
let mut i: Value = Value::Int(0);
let mut __for_first_1098: bool = true;
while { if !__for_first_1098 { i = add(&i, &Value::Int(1)); } __for_first_1098 = false; is_less_than(&i, &get_array_length(¤ciesIds)) } {
let mut currency: Value = get_value(¤ciesIds, &i);
let mut currency: Value = get_value(¤ciesIds, &i);
let mut data: Value = self.safe_dict(response.clone(), currency.clone(), &[Value::Map({
let mut m = indexmap::IndexMap::new();
m
})]);
let mut code: Value = self.safe_currency_code(currency.clone(), &[]);
let mut withdraw: Value = self.safe_value_k(data.clone(), "withdraw", &[Value::Map({
let mut m = indexmap::IndexMap::new();
m
})]);
if !is_equal(&code, &Value::Null) {
add_element_to_object(&mut withdrawFees, &code, self.safe_string_k(withdraw.clone(), "fixed", &[]));
}
let mut deposit: Value = self.safe_value_k(data.clone(), "deposit", &[Value::Map({
let mut m = indexmap::IndexMap::new();
m
})]);
if !is_equal(&code, &Value::Null) {
add_element_to_object(&mut depositFees, &code, self.safe_string_k(deposit.clone(), "fixed", &[]));
}
}
}
return Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("withdraw".to_string(), withdrawFees.clone());
m.insert("deposit".to_string(), depositFees.clone());
m.insert("info".to_string(), response.clone());
m
});
Value::Null
}
/*
* @method
* @name whitebit#fetchDepositWithdrawFees
* @description fetch deposit and withdraw fees
* @see https://docs.whitebit.com/public/http-v4/#fee
* @param {string[]|undefined} codes not used by fetchDepositWithdrawFees ()
* @param {object} [params] extra parameters specific to the exchange API endpoint
* @returns {object} a list of [fee structures]{@link https://docs.ccxt.com/?id=fee-structure}
*/
pub async fn fetch_deposit_withdraw_fees(&mut self, optional_args: &[Value]) -> Value {
let mut codes = get_arg(optional_args, 0, Value::Null);
let mut params = get_arg(optional_args, 1, Value::Map({
let mut m = indexmap::IndexMap::new();
m
}));
if is_equal(&self.markets, &Value::Null) {
self.load_markets(&[]).await;
}
let mut response: Value = self.v4_public_get_fee(&[params.clone()]).await;
return self.parse_deposit_withdraw_fees(response.clone(), &[codes.clone()]);
Value::Null
}
pub fn parse_deposit_withdraw_fees(&self, mut response: Value, optional_args: &[Value]) -> Value {
let mut codes = get_arg(optional_args, 0, Value::Null);
let mut currencyIdKey = get_arg(optional_args, 1, Value::Null);
//
// {
// "1INCH": {
// "is_depositable": true,
// "is_withdrawal": true,
// "ticker": "1INCH",
// "name": "1inch",
// "providers": [],
// "withdraw": {
// "max_amount": "0",
// "min_amount": "21.5",
// "fixed": "17.5",
// "flex": null
// },
// "deposit": {
// "max_amount": "0",
// "min_amount": "19.5",
// "fixed": null,
// "flex": null
// }
// },
// "WBT (ERC20)": {
// "is_depositable": true,
// "is_withdrawal": true,
// "ticker": "WBT",
// "name": "WhiteBIT Token",
// "providers": [],
// "withdraw": { max_amount: "0", min_amount: "0.7", fixed: "0.253", flex: null },
// "deposit": { max_amount: "0", min_amount: "0.35", fixed: null, flex: null }
// },
// "WBT (TRC20)": {
// "is_depositable": true,
// "is_withdrawal": true,
// "ticker": "WBT",
// "name": "WhiteBIT Token",
// "providers": [],
// "withdraw": { max_amount: "0", min_amount: "1.5", fixed: "0.075", flex: null },
// "deposit": { max_amount: "0", min_amount: "0.75", fixed: null, flex: null }
// },
// ...
// }
//
let mut depositWithdrawFees: Value = Value::Map({
let mut m = indexmap::IndexMap::new();
m
});
codes = self.market_codes(&[codes.clone()]);
let mut currencyIds: Value = object_keys(&response);
{
let mut i: Value = Value::Int(0);
let mut __for_first_1099: bool = true;
while { if !__for_first_1099 { i = add(&i, &Value::Int(1)); } __for_first_1099 = false; is_less_than(&i, &get_array_length(¤cyIds)) } {
let mut entry: Value = get_value(¤cyIds, &i);
let mut entry: Value = get_value(¤cyIds, &i);
let mut splitEntry: Value = split(&entry, &Value::Str(" ".to_string()));
let mut currencyId: Value = get_value(&splitEntry, &Value::Int(0));
let mut feeInfo: Value = get_value(&response, &entry);
let mut feeInfo: Value = get_value(&response, &entry);
let mut code: Value = self.safe_currency_code(currencyId.clone(), &[]);
if is_true(&(!is_equal(&code, &Value::Null))) && is_true(&(is_true(&(is_equal(&codes, &Value::Null))) || is_true(&(self.in_array(code.clone(), codes.clone()))))) {
let mut depositWithdrawFee: Value = self.safe_value(depositWithdrawFees.clone(), code.clone(), &[]);
if is_equal(&depositWithdrawFee, &Value::Null) {
add_element_to_object(&mut depositWithdrawFees, &code, self.deposit_withdraw_fee(Value::Map({
let mut m = indexmap::IndexMap::new();
m
})));
}
add_element_to_object(get_value_mut(get_value_mut(&mut depositWithdrawFees, &code), &Value::Str("info".to_string())), &entry, feeInfo.clone());
let mut networkId: Value = self.safe_string(splitEntry.clone(), Value::Int(1), &[]);
let mut withdraw: Value = self.safe_value_k(feeInfo.clone(), "withdraw", &[]);
let mut deposit: Value = self.safe_value_k(feeInfo.clone(), "deposit", &[]);
let mut withdrawFee: Value = self.safe_number_k(withdraw.clone(), "fixed", &[]);
let mut depositFee: Value = self.safe_number_k(deposit.clone(), "fixed", &[]);
let mut withdrawResult: Value = Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("fee".to_string(), withdrawFee.clone());
m.insert("percentage".to_string(), ternary(is_true(&(!is_equal(&withdrawFee, &Value::Null))), Value::Bool(false), Value::Null));
m
});
let mut depositResult: Value = Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("fee".to_string(), depositFee.clone());
m.insert("percentage".to_string(), ternary(is_true(&(!is_equal(&depositFee, &Value::Null))), Value::Bool(false), Value::Null));
m
});
if !is_equal(&networkId, &Value::Null) {
let mut networkLength: Value = get_array_length(&networkId);
networkId = slice(&networkId, &Value::Int(1), &subtract(&networkLength, &Value::Int(1)));
let mut networkCode: Value = self.network_id_to_code(&[networkId.clone(), code.clone()]);
if !is_equal(&networkCode, &Value::Null) {
add_element_to_object(get_value_mut(get_value_mut(&mut depositWithdrawFees, &code), &Value::Str("networks".to_string())), &networkCode, Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("withdraw".to_string(), withdrawResult.clone());
m.insert("deposit".to_string(), depositResult.clone());
m
}));
}
} else {
add_element_to_object(get_value_mut(&mut depositWithdrawFees, &code), &Value::Str("withdraw".to_string()), withdrawResult.clone());
add_element_to_object(get_value_mut(&mut depositWithdrawFees, &code), &Value::Str("deposit".to_string()), depositResult.clone());
}
}
}
}
let mut depositWithdrawCodes: Value = object_keys(&depositWithdrawFees);
{
let mut i: Value = Value::Int(0);
let mut __for_first_1100: bool = true;
while { if !__for_first_1100 { i = add(&i, &Value::Int(1)); } __for_first_1100 = false; is_less_than(&i, &get_array_length(&depositWithdrawCodes)) } {
let mut code: Value = get_value(&depositWithdrawCodes, &i);
let mut code: Value = get_value(&depositWithdrawCodes, &i);
let mut currency: Value = self.currency(code.clone());
{ let __be_tmp = self.assign_default_deposit_withdraw_fees(get_value(&depositWithdrawFees, &code), &[currency.clone()]); add_element_to_object(&mut depositWithdrawFees, &code, __be_tmp); };
}
}
return depositWithdrawFees;
Value::Null
}
/*
* @method
* @name whitebit#fetchTradingFees
* @description fetch the trading fees for multiple markets
* @see https://docs.whitebit.com/public/http-v4/#asset-status-list
* @param {object} [params] extra parameters specific to the exchange API endpoint
* @returns {object} a dictionary of [fee structures]{@link https://docs.ccxt.com/?id=fee-structure} indexed by market symbols
*/
pub async fn fetch_trading_fees(&mut self, optional_args: &[Value]) -> Value {
let mut params = get_arg(optional_args, 0, Value::Map({
let mut m = indexmap::IndexMap::new();
m
}));
if is_equal(&self.markets, &Value::Null) {
self.load_markets(&[]).await;
}
let mut response: Value = self.v4_public_get_assets(&[params.clone()]).await;
//
// {
// "1INCH": {
// "name": "1inch",
// "unified_cryptoasset_id": "8104",
// "can_withdraw": true,
// "can_deposit": true,
// "min_withdraw": "33",
// "max_withdraw": "0",
// "maker_fee": "0.1",
// "taker_fee": "0.1",
// "min_deposit": "30",
// "max_deposit": "0"
// },
// ...
// }
//
let mut result: Value = Value::Map({
let mut m = indexmap::IndexMap::new();
m
});
let mut symbols: Value = self.symbols.clone();
{
let mut i: Value = Value::Int(0);
let mut __for_first_1101: bool = true;
while { if !__for_first_1101 { i = add(&i, &Value::Int(1)); } __for_first_1101 = false; is_less_than(&i, &get_array_length(&symbols)) } {
let mut symbol: Value = get_value(&symbols, &i);
let mut symbol: Value = get_value(&symbols, &i);
let mut market: Value = self.market(symbol.clone());
let mut fee: Value = self.safe_value(response.clone(), get_value(&market, &Value::Str("baseId".to_string())), &[Value::Map({
let mut m = indexmap::IndexMap::new();
m
})]);
let mut makerFee: Value = self.safe_string_k(fee.clone(), "maker_fee", &[]);
let mut takerFee: Value = self.safe_string_k(fee.clone(), "taker_fee", &[]);
makerFee = crate::precise::Precise::stringDiv(&makerFee, &Value::Str("100".to_string()));
takerFee = crate::precise::Precise::stringDiv(&takerFee, &Value::Str("100".to_string()));
add_element_to_object(&mut result, &symbol, Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("info".to_string(), fee.clone());
m.insert("symbol".to_string(), get_value(&market, &Value::Str("symbol".to_string())));
m.insert("percentage".to_string(), Value::Bool(true));
m.insert("tierBased".to_string(), Value::Bool(false));
m.insert("maker".to_string(), self.parse_number(makerFee.clone(), &[]));
m.insert("taker".to_string(), self.parse_number(takerFee.clone(), &[]));
m
}));
}
}
return result;
Value::Null
}
/*
* @method
* @name whitebit#fetchTradingLimits
* @description fetch the trading limits for a market
* @see https://docs.whitebit.com/public/http-v4/#market-info
* @param {string[]|undefined} symbols unified market symbol
* @param {object} [params] extra parameters specific to the exchange API endpoint
* @returns {object} a [trading limits structure]{@link https://docs.ccxt.com/?id=trading-limits-structure}
*/
pub async fn fetch_trading_limits(&mut self, optional_args: &[Value]) -> Value {
let mut symbols = get_arg(optional_args, 0, Value::Null);
let mut params = get_arg(optional_args, 1, Value::Map({
let mut m = indexmap::IndexMap::new();
m
}));
if is_equal(&self.markets, &Value::Null) {
self.load_markets(&[]).await;
}
//
// Trading limits are derived from market information already loaded by loadMarkets()
// Market structure includes:
// {
// "id": "BTC_USDT", // Market ID
// "symbol": "BTC/USDT", // Unified symbol
// "base": "BTC", // Base currency
// "quote": "USDT", // Quote currency
// "active": true, // Market active status
// "type": "spot", // Market type
// "spot": true, // Spot trading enabled
// "margin": false, // Margin trading enabled
// "future": false, // Futures trading enabled
// "option": false, // Options trading enabled
// "contract": false, // Contract trading enabled
// "settle": undefined, // Settlement currency
// "settleId": undefined, // Settlement currency ID
// "contractSize": undefined, // Contract size
// "linear": undefined, // Linear contract
// "inverse": undefined, // Inverse contract
// "limits": { // Trading limits
// "amount": { // Amount limits
// "min": 0.00001, // Minimum amount
// "max": 1000000 // Maximum amount
// },
// "price": { // Price limits
// "min": 0.01, // Minimum price
// "max": 1000000 // Maximum price
// },
// "cost": { // Cost limits
// "min": 5.0, // Minimum cost
// "max": 10000000 // Maximum cost
// }
// },
// "precision": { // Precision settings
// "amount": 5, // Amount precision
// "price": 2 // Price precision
// },
// "taker": 0.001, // Taker fee
// "maker": 0.001, // Maker fee
// "percentage": true, // Fee percentage
// "tierBased": false // Tier-based fees
// }
//
let mut result: Value = Value::Map({
let mut m = indexmap::IndexMap::new();
m
});
// Process all markets from the loaded markets cache
let mut markets: Value = self.markets.clone();
if is_equal(&markets, &Value::Null) {
panic!("{}", crate::exchange_errors::exchange_error(add(&self.id, &Value::Str(" markets not loaded".to_string()))));
}
let mut marketIds: Value = object_keys(&markets);
{
let mut i: Value = Value::Int(0);
let mut __for_first_1103: bool = true;
while { if !__for_first_1103 { i = add(&i, &Value::Int(1)); } __for_first_1103 = false; is_less_than(&i, &get_array_length(&marketIds)) } {
let mut marketId: Value = get_value(&marketIds, &i);
let mut marketId: Value = get_value(&marketIds, &i);
let mut market: Value = get_value(&markets, &marketId);
let mut market: Value = get_value(&markets, &marketId);
let mut marketSymbol: Value = self.safe_string_k(market.clone(), "symbol", &[]);
if is_true(&(is_equal(&market, &Value::Null))) || is_true(&(is_equal(&market, &Value::Null))) || is_true(&(is_equal(&marketSymbol, &Value::Null))) || is_true(&(is_equal(&marketSymbol, &Value::Str("".to_string())))) {
continue;
}
let mut symbol: Value = get_value(&market, &Value::Str("symbol".to_string()));
// Filter by symbols if specified
if !is_equal(&symbols, &Value::Null) {
let mut symbolFound: bool = false;
{
let mut j: Value = Value::Int(0);
let mut __for_first_1102: bool = true;
while { if !__for_first_1102 { j = add(&j, &Value::Int(1)); } __for_first_1102 = false; is_less_than(&j, &get_array_length(&symbols)) } {
if is_equal(&get_value(&symbols, &j), &symbol) {
symbolFound = true;
break;
}
}
}
if !is_true(&symbolFound) {
continue;
}
}
// Extract trading limits
let mut limits: Value = self.safe_dict_k(market.clone(), "limits", &[]);
let mut amountLimits: Value = self.safe_dict_k(limits.clone(), "amount", &[]);
let mut priceLimits: Value = self.safe_dict_k(limits.clone(), "price", &[]);
let mut costLimits: Value = self.safe_dict_k(limits.clone(), "cost", &[]);
// Validate that all required limits exist and are valid numbers
let mut hasAmountLimits: Value = Value::Bool(is_true(&(!is_equal(&amountLimits, &Value::Null))) && is_true(&(!is_equal(&amountLimits, &Value::Null))) && !is_equal(&self.safe_number_k(amountLimits.clone(), "min", &[]), &Value::Null) && !is_equal(&self.safe_number_k(amountLimits.clone(), "max", &[]), &Value::Null));
let mut hasPriceLimits: Value = Value::Bool(is_true(&(!is_equal(&priceLimits, &Value::Null))) && is_true(&(!is_equal(&priceLimits, &Value::Null))) && !is_equal(&self.safe_number_k(priceLimits.clone(), "min", &[]), &Value::Null) && !is_equal(&self.safe_number_k(priceLimits.clone(), "max", &[]), &Value::Null));
let mut hasCostLimits: Value = Value::Bool(is_true(&(!is_equal(&costLimits, &Value::Null))) && is_true(&(!is_equal(&costLimits, &Value::Null))) && !is_equal(&self.safe_number_k(costLimits.clone(), "min", &[]), &Value::Null) && !is_equal(&self.safe_number_k(costLimits.clone(), "max", &[]), &Value::Null));
if is_true(&(is_equal(&hasAmountLimits, &Value::Bool(true)))) && is_true(&(is_equal(&hasPriceLimits, &Value::Bool(true)))) && is_true(&(is_equal(&hasCostLimits, &Value::Bool(true)))) {
add_element_to_object(&mut result, &symbol, Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("info".to_string(), market.clone());
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(), self.safe_number_k(amountLimits.clone(), "min", &[]));
m.insert("max".to_string(), self.safe_number_k(amountLimits.clone(), "max", &[]));
m
}));
m.insert("price".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("min".to_string(), self.safe_number_k(priceLimits.clone(), "min", &[]));
m.insert("max".to_string(), self.safe_number_k(priceLimits.clone(), "max", &[]));
m
}));
m.insert("cost".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("min".to_string(), self.safe_number_k(costLimits.clone(), "min", &[]));
m.insert("max".to_string(), self.safe_number_k(costLimits.clone(), "max", &[]));
m
}));
m
}));
m
}));
}
}
}
return result;
Value::Null
}
/*
* @method
* @name whitebit#fetchFundingLimits
* @description fetch the deposit and withdrawal limits for a currency
* @see https://docs.whitebit.com/public/http-v4/#asset-status-list
* @see https://docs.whitebit.com/public/http-v4/#fee
* @param {string[]|undefined} codes unified currency codes
* @param {object} [params] extra parameters specific to the exchange API endpoint
* @returns {object} a [funding limits structure]{@link https://docs.ccxt.com/?id=funding-limits-structure}
*/
pub async fn fetch_funding_limits(&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;
}
// Fetch both currencies and fees data for comprehensive funding limits
let mut currenciesDatafeesDataVariable = promise_all(&Value::List(vec![self.fetch_currencies(&[]).await, self.v4_public_get_fee(&[params.clone()]).await])).await;
let mut currenciesData: Value = get_value(¤ciesDatafeesDataVariable, &Value::Int(0));
let mut feesData: Value = get_value(¤ciesDatafeesDataVariable, &Value::Int(1));
//
// Currencies response structure (from fetchCurrencies):
// {
// "BTC": {
// "id": "BTC", // Currency ID
// "code": "BTC", // Currency code
// "name": "Bitcoin", // Currency name
// "active": true, // Currency active status
// "type": "crypto", // Currency type
// "precision": 8, // Currency precision
// "limits": { // Currency limits
// "deposit": { // Deposit limits
// "min": 0.00001, // Minimum deposit
// "max": 1000000 // Maximum deposit
// },
// "withdraw": { // Withdrawal limits
// "min": 0.00001, // Minimum withdrawal
// "max": 1000000 // Maximum withdrawal
// }
// },
// "networks": { // Network-specific limits
// "BTC": {
// "limits": {
// "deposit": { "min": "0.001" },
// "withdraw": { "min": "0.002" }
// }
// }
// },
// "info": { ... } // Original API response
// }
// }
//
// Fees response structure (from /api/v4/public/fee):
// {
// "USDT (ERC20)": {
// "ticker": "USDT",
// "name": "Tether US",
// "deposit": {
// "min_amount": "0.0005",
// "max_amount": "0.1",
// "fixed": "0.0005",
// "flex": {
// "min_fee": "100",
// "max_fee": "1000",
// "percent": "10"
// }
// },
// "withdraw": {
// "min_amount": "0.001",
// "max_amount": "0",
// "fixed": null,
// "flex": null
// }
// }
// }
//
let mut result: Value = Value::Map({
let mut m = indexmap::IndexMap::new();
m
});
let mut currencyKeys: Value = object_keys(¤ciesData);
{
let mut i: Value = Value::Int(0);
let mut __for_first_1105: bool = true;
while { if !__for_first_1105 { i = add(&i, &Value::Int(1)); } __for_first_1105 = false; is_less_than(&i, &get_array_length(¤cyKeys)) } {
let mut code: Value = get_value(¤cyKeys, &i);
let mut code: Value = get_value(¤cyKeys, &i);
let mut currency: Value = get_value(¤ciesData, &code);
let mut currency: Value = get_value(¤ciesData, &code);
if is_equal(¤cy, &Value::Null) {
continue;
}
if !is_equal(&codes, &Value::Null) && !is_true(&self.in_array(code.clone(), codes.clone())) {
continue;
}
// Find corresponding fee data for this currency
let mut feeData: Value = Value::Null;
let mut feeKeys: Value = object_keys(&feesData);
{
let mut j: Value = Value::Int(0);
let mut __for_first_1104: bool = true;
while { if !__for_first_1104 { j = add(&j, &Value::Int(1)); } __for_first_1104 = false; is_less_than(&j, &get_array_length(&feeKeys)) } {
let mut feeKey: Value = get_value(&feeKeys, &j);
let mut feeKey: Value = get_value(&feeKeys, &j);
let mut fee: Value = self.safe_dict(feesData.clone(), feeKey.clone(), &[]);
if is_true(&(!is_equal(&fee, &Value::Null) && !is_equal(&fee, &Value::Null))) && is_equal(&get_value(&fee, &Value::Str("ticker".to_string())), &code) {
feeData = fee.clone();
break;
}
}
}
// Build comprehensive funding limits
let mut currencyLimits: Value = self.safe_dict_k(currency.clone(), "limits", &[Value::Map({
let mut m = indexmap::IndexMap::new();
m
})]);
let mut limits: Value = Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("deposit".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("min".to_string(), get_value(&get_value(¤cyLimits, &Value::Str("deposit".to_string())), &Value::Str("min".to_string())));
m.insert("max".to_string(), get_value(&get_value(¤cyLimits, &Value::Str("deposit".to_string())), &Value::Str("max".to_string())));
m
}));
m.insert("withdraw".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("min".to_string(), get_value(&get_value(¤cyLimits, &Value::Str("withdraw".to_string())), &Value::Str("min".to_string())));
m.insert("max".to_string(), get_value(&get_value(¤cyLimits, &Value::Str("withdraw".to_string())), &Value::Str("max".to_string())));
m
}));
m
});
// Add fee information if available
if !is_equal(&feeData, &Value::Null) {
let mut depositFee: Value = get_value(&feeData, &Value::Str("deposit".to_string()));
let mut withdrawFee: Value = get_value(&feeData, &Value::Str("withdraw".to_string()));
if is_true(&(!is_equal(&depositFee, &Value::Null))) && is_true(&(!is_equal(&depositFee, &Value::Null))) {
let mut depositFeeData: Value = Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("fixed".to_string(), self.safe_number_k(depositFee.clone(), "fixed", &[]));
m
});
if is_true(&(!is_equal(&get_value(&depositFee, &Value::Str("flex".to_string())), &Value::Null))) && is_true(&(!is_equal(&get_value(&depositFee, &Value::Str("flex".to_string())), &Value::Null))) {
add_element_to_object(&mut depositFeeData, &Value::Str("flex".to_string()), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("min".to_string(), self.safe_number(get_value(&depositFee, &Value::Str("flex".to_string())), Value::Str("min_fee".to_string()), &[]));
m.insert("max".to_string(), self.safe_number(get_value(&depositFee, &Value::Str("flex".to_string())), Value::Str("max_fee".to_string()), &[]));
m.insert("percent".to_string(), self.safe_number(get_value(&depositFee, &Value::Str("flex".to_string())), Value::Str("percent".to_string()), &[]));
m
}));
}
add_element_to_object(get_value_mut(&mut limits, &Value::Str("deposit".to_string())), &Value::Str("fee".to_string()), depositFeeData.clone());
}
if is_true(&(!is_equal(&withdrawFee, &Value::Null))) && is_true(&(!is_equal(&withdrawFee, &Value::Null))) {
let mut withdrawFeeData: Value = Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("fixed".to_string(), self.safe_number_k(withdrawFee.clone(), "fixed", &[]));
m
});
if is_true(&(!is_equal(&get_value(&withdrawFee, &Value::Str("flex".to_string())), &Value::Null))) && is_true(&(!is_equal(&get_value(&withdrawFee, &Value::Str("flex".to_string())), &Value::Null))) {
add_element_to_object(&mut withdrawFeeData, &Value::Str("flex".to_string()), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("min".to_string(), self.safe_number(get_value(&withdrawFee, &Value::Str("flex".to_string())), Value::Str("min_fee".to_string()), &[]));
m.insert("max".to_string(), self.safe_number(get_value(&withdrawFee, &Value::Str("flex".to_string())), Value::Str("max_fee".to_string()), &[]));
m.insert("percent".to_string(), self.safe_number(get_value(&withdrawFee, &Value::Str("flex".to_string())), Value::Str("percent".to_string()), &[]));
m
}));
}
add_element_to_object(get_value_mut(&mut limits, &Value::Str("withdraw".to_string())), &Value::Str("fee".to_string()), withdrawFeeData.clone());
}
}
// Add network-specific limits if available
if !is_equal(&get_value(¤cy, &Value::Str("networks".to_string())), &Value::Null) {
add_element_to_object(&mut limits, &Value::Str("networks".to_string()), get_value(¤cy, &Value::Str("networks".to_string())));
}
add_element_to_object(&mut result, &code, Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("info".to_string(), currency.clone());
m.insert("limits".to_string(), limits.clone());
m
}));
}
}
return result;
Value::Null
}
/*
* @method
* @name whitebit#fetchTicker
* @description fetches a price ticker, a statistical calculation with the information calculated over the past 24 hours for a specific market
* @see https://docs.whitebit.com/public/http-v4/#market-activity
* @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 request: Value = Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("market".to_string(), get_value(&market, &Value::Str("id".to_string())));
m
});
let __ws_arg_0 = self.extend(request.clone(), &[params.clone()]);
let mut response: Value = self.v1_public_get_ticker(&[__ws_arg_0]).await;
//
// {
// "success":true,
// "message":"",
// "result": {
// "bid":"0.021979",
// "ask":"0.021996",
// "open":"0.02182",
// "high":"0.022039",
// "low":"0.02161",
// "last":"0.021987",
// "volume":"2810.267",
// "deal":"61.383565474",
// "change":"0.76",
// },
// }
//
let mut ticker: Value = self.safe_dict_k(response.clone(), "result", &[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);
//
// FetchTicker (v1)
//
// {
// "bid": "0.021979",
// "ask": "0.021996",
// "open": "0.02182",
// "high": "0.022039",
// "low": "0.02161",
// "last": "0.021987",
// "volume": "2810.267",
// "deal": "61.383565474",
// "change": "0.76",
// }
//
// FetchTickers (v4)
//
// "BCH_RUB": {
// "base_id": 1831,
// "quote_id": 0,
// "last_price": "32830.21",
// "quote_volume": "1494659.8024096",
// "base_volume": "46.1083",
// "isFrozen": false,
// "change": "2.12" // in percent
// }
//
// WS market_update
//
// {
// "open": "52853.04",
// "close": "55913.88",
// "high": "56272",
// "low": "49549.67",
// "volume": "57331.067185",
// "deal": "3063860382.42985338",
// "last": "55913.88",
// "period": 86400
// }
// v2
// {
// lastUpdateTimestamp: '2025-01-02T09:16:36.000Z',
// tradingPairs: 'ARB_USDC',
// lastPrice: '0.7727',
// lowestAsk: '0.7735',
// highestBid: '0.7732',
// baseVolume24h: '1555793.74',
// quoteVolume24h: '1157602.622406',
// tradesEnabled: true
// }
//
// v4PublicGetFutures
// {
// "ticker_id": "0G_PERP",
// "stock_currency": "0G",
// "money_currency": "USDT",
// "last_price": "0.6065",
// "stock_volume": "2563218",
// "money_volume": "1587952.6137",
// "bid": "0.6065",
// "ask": "0.6077",
// "high": "0.6472",
// "low": "0.6045",
// "product_type": "Perpetual",
// "open_interest": "3721488",
// "index_price": "0.61",
// "index_name": "0G future contract",
// "index_currency": "0G",
// "funding_rate": "-0.00000778",
// "next_funding_rate_timestamp": "1772467200000",
// "brackets": {
// "1": 0,
// "10": 0,
// "100": 0,
// "2": 0,
// "20": 4000,
// "3": 0,
// "5": 0,
// "50": 800
// },
// "max_leverage": 50,
// "funding_interval_minutes": 240
// }
//
let mut marketId: Value = self.safe_string2(ticker.clone(), Value::Str("tradingPairs".to_string()), Value::Str("ticker_id".to_string()), &[]);
market = self.safe_market(&[marketId.clone(), market.clone()]);
// last price is provided as "last" or "last_price"
let mut last: Value = self.safe_string_n(ticker.clone(), Value::List(vec![Value::Str("last".to_string()), Value::Str("last_price".to_string()), Value::Str("lastPrice".to_string())]), &[]);
// if "close" is provided, use it, otherwise use <last>
let mut close: Value = self.safe_string_k(ticker.clone(), "close", &[last.clone()]);
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(), Value::Null);
m.insert("datetime".to_string(), Value::Null);
m.insert("high".to_string(), self.safe_string_k(ticker.clone(), "high", &[]));
m.insert("low".to_string(), self.safe_string_k(ticker.clone(), "low", &[]));
m.insert("bid".to_string(), self.safe_string2(ticker.clone(), Value::Str("bid".to_string()), Value::Str("highestBid".to_string()), &[]));
m.insert("bidVolume".to_string(), Value::Null);
m.insert("ask".to_string(), self.safe_string2(ticker.clone(), Value::Str("ask".to_string()), Value::Str("lowestAsk".to_string()), &[]));
m.insert("askVolume".to_string(), Value::Null);
m.insert("vwap".to_string(), Value::Null);
m.insert("open".to_string(), self.safe_string_k(ticker.clone(), "open", &[]));
m.insert("close".to_string(), close.clone());
m.insert("last".to_string(), last.clone());
m.insert("previousClose".to_string(), Value::Null);
m.insert("change".to_string(), Value::Null);
m.insert("percentage".to_string(), self.safe_string_k(ticker.clone(), "change", &[]));
m.insert("average".to_string(), Value::Null);
m.insert("baseVolume".to_string(), self.safe_string_n(ticker.clone(), Value::List(vec![Value::Str("base_volume".to_string()), Value::Str("volume".to_string()), Value::Str("baseVolume24h".to_string()), Value::Str("stock_volume".to_string())]), &[]));
m.insert("quoteVolume".to_string(), self.safe_string_n(ticker.clone(), Value::List(vec![Value::Str("quote_volume".to_string()), Value::Str("deal".to_string()), Value::Str("quoteVolume24h".to_string()), Value::Str("money_volume".to_string())]), &[]));
m.insert("indexPrice".to_string(), self.safe_string_k(ticker.clone(), "index_price", &[]));
m.insert("info".to_string(), ticker.clone());
m
}), &[market.clone()]);
Value::Null
}
/*
* @method
* @name whitebit#fetchOrder
* @description fetches information on an order by the id
* @see https://docs.whitebit.com/private/http-trade-v4/#query-unexecutedactive-orders
* @see https://docs.whitebit.com/private/http-trade-v4/#query-executed-orders
* @param {string} id order id
* @param {string} symbol unified symbol of the market the order was made in
* @param {object} [params] extra parameters specific to the exchange API endpoint
* @param {boolean} [params.checkActive] whether to check active orders (default: true)
* @param {boolean} [params.checkExecuted] whether to check executed orders (default: true)
* @returns {object} an [order structure]{@link https://docs.ccxt.com/?id=order-structure}
*/
pub async fn fetch_order(&mut self, mut id: Value, optional_args: &[Value]) -> Value {
let mut symbol = get_arg(optional_args, 0, Value::Null);
let mut params = get_arg(optional_args, 1, Value::Map({
let mut m = indexmap::IndexMap::new();
m
}));
if is_equal(&self.markets, &Value::Null) {
self.load_markets(&[]).await;
}
// Extract control parameters from params
let mut checkActive: Value = self.safe_bool_k(params.clone(), "checkActive", &[Value::Bool(true)]);
let mut checkExecuted: Value = self.safe_bool_k(params.clone(), "checkExecuted", &[Value::Bool(true)]);
params = self.omit(params.clone(), Value::List(vec![Value::Str("checkActive".to_string()), Value::Str("checkExecuted".to_string())]), &[]);
let mut request: Value = Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("orderId".to_string(), id.clone());
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("market".to_string()), get_value(&market, &Value::Str("id".to_string())));
}
// Try active orders first (if enabled)
if is_equal(&checkActive, &Value::Bool(true)) {
let _try_result = futures::FutureExt::catch_unwind(std::panic::AssertUnwindSafe(async {
let __ws_arg_1 = self.extend(request.clone(), &[params.clone()]);
let mut response: Value = self.v4_private_post_orders(&[__ws_arg_1]).await;
// Search for order in active orders response (array format)
let mut orders: Value = self.to_array(response.clone());
{
let mut i: Value = Value::Int(0);
let mut __for_first_1106: bool = true;
while { if !__for_first_1106 { i = add(&i, &Value::Int(1)); } __for_first_1106 = false; is_less_than(&i, &get_array_length(&orders)) } {
let mut order: Value = get_value(&orders, &i);
let mut order: Value = get_value(&orders, &i);
let mut orderId: Value = self.safe_string_k(order.clone(), "orderId", &[]);
if is_equal(&orderId, &id) {
let mut marketId: Value = self.safe_string_k(order.clone(), "market", &[]);
let mut marketNew: Value = self.safe_market(&[marketId.clone(), Value::Null, Value::Str("_".to_string())]);
return self.parse_order(order.clone(), &[marketNew.clone()]);
}
}
}
#[allow(unreachable_code)] { Value::Null }})).await;
match _try_result { Ok(__try_ok) => { if !matches!(__try_ok, Value::Null) { return __try_ok; } return Value::Null; } Err(_try_err) => { let error: Value = panic_to_value(_try_err);
if !is_true(&(is_instance(&error, &Value::Str("OrderNotFound".to_string())))) {
panic!("{}", error);
}
} }
}
// Try executed orders (if enabled)
if is_equal(&checkExecuted, &Value::Bool(true)) {
let _try_result = futures::FutureExt::catch_unwind(std::panic::AssertUnwindSafe(async {
let __ws_arg_2 = self.extend(request.clone(), &[params.clone()]);
let mut response: Value = self.v4_private_post_trade_account_order_history(&[__ws_arg_2]).await;
// Search for order in executed orders response (object format)
let mut marketIds: Value = object_keys(&response);
{
let mut i: Value = Value::Int(0);
let mut __for_first_1108: bool = true;
while { if !__for_first_1108 { i = add(&i, &Value::Int(1)); } __for_first_1108 = false; is_less_than(&i, &get_array_length(&marketIds)) } {
let mut marketId: Value = get_value(&marketIds, &i);
let mut marketId: Value = get_value(&marketIds, &i);
let mut marketNew: Value = self.safe_market(&[marketId.clone(), Value::Null, Value::Str("_".to_string())]);
let mut marketOrders: Value = self.safe_list(response.clone(), marketId.clone(), &[Value::List(vec![])]);
{
let mut j: Value = Value::Int(0);
let mut __for_first_1107: bool = true;
while { if !__for_first_1107 { j = add(&j, &Value::Int(1)); } __for_first_1107 = false; is_less_than(&j, &get_array_length(&marketOrders)) } {
let mut order: Value = get_value(&marketOrders, &j);
let mut order: Value = get_value(&marketOrders, &j);
let mut orderId: Value = self.safe_string_k(order.clone(), "id", &[]);
if is_equal(&orderId, &id) {
return self.parse_order(order.clone(), &[marketNew.clone()]);
}
}
}
}
}
#[allow(unreachable_code)] { Value::Null }})).await;
match _try_result { Ok(__try_ok) => { if !matches!(__try_ok, Value::Null) { return __try_ok; } return Value::Null; } Err(_try_err) => { let error: Value = panic_to_value(_try_err);
if !is_true(&(is_instance(&error, &Value::Str("OrderNotFound".to_string())))) {
panic!("{}", error);
}
} }
}
panic!("{}", crate::exchange_errors::order_not_found(add(&add(&self.id, &Value::Str(" fetchOrder() order not found: ".to_string())), &id)));
Value::Null
}
/*
* @method
* @name whitebit#fetchTickers
* @description fetches price tickers for multiple markets, statistical information calculated over the past 24 hours for each market
* @see https://docs.whitebit.com/public/http-v4/#market-activity
* @param {string[]} [symbols] unified symbols of the markets to fetch the ticker for, all market tickers are returned if not assigned
* @param {object} [params] extra parameters specific to the exchange API endpoint
* @param {string} [params.type] 'spot' or 'swap' - default is 'spot'. If type is 'swap', it will call v4PublicGetFutures
* @param {string} [params.method] either v2PublicGetTicker or v4PublicGetTicker or v4PublicGetFutures - default is v4PublicGetTicker for spot and mixed markets, and v4PublicGetFutures for swap
* @returns {object} a dictionary of [ticker structures]{@link https://docs.ccxt.com/?id=ticker-structure}
*/
pub async fn fetch_tickers(&mut self, optional_args: &[Value]) -> Value {
let mut symbols = get_arg(optional_args, 0, Value::Null);
let mut params = get_arg(optional_args, 1, Value::Map({
let mut m = indexmap::IndexMap::new();
m
}));
if is_equal(&self.markets, &Value::Null) {
self.load_markets(&[]).await;
}
symbols = self.market_symbols(&[symbols.clone()]);
let mut onlyContractSymbols: bool = true;
if !is_equal(&symbols, &Value::Null) {
{
let mut i: Value = Value::Int(0);
let mut __for_first_1109: bool = true;
while { if !__for_first_1109 { i = add(&i, &Value::Int(1)); } __for_first_1109 = false; is_less_than(&i, &get_array_length(&symbols)) } {
let mut symbol: Value = get_value(&symbols, &i);
let mut symbol: Value = get_value(&symbols, &i);
let mut market: Value = self.market(symbol.clone());
if !is_equal(&get_value(&market, &Value::Str("contract".to_string())), &Value::Bool(true)) {
onlyContractSymbols = false;
break;
}
}
}
} else {
onlyContractSymbols = false;
}
let mut marketType: Value = Value::Null;
{ let __destr_tmp = self.handle_market_type_and_params(Value::Str("fetchTickers".to_string()), &[Value::Null, params.clone()]); marketType = get_value(&__destr_tmp, &Value::Int(0)); params = get_value(&__destr_tmp, &Value::Int(1)); }
let mut method: Value = Value::Null;
{ let __destr_tmp = self.handle_option_and_params(params.clone(), Value::Str("fetchTickers".to_string()), Value::Str("method".to_string()), &[method.clone()]); method = get_value(&__destr_tmp, &Value::Int(0)); params = get_value(&__destr_tmp, &Value::Int(1)); }
if is_equal(&method, &Value::Null) {
// if the user did not specify a method, choose it based on market type and symbols
if is_true(&onlyContractSymbols) || is_true(&(is_equal(&marketType, &Value::Str("swap".to_string())))) {
method = Value::Str("v4PublicGetFutures".to_string());
} else {
method = Value::Str("v4PublicGetTicker".to_string());
}
}
let mut response: Value = Value::Null;
if is_equal(&method, &Value::Str("v4PublicGetTicker".to_string())) {
//
// "BCH_RUB": {
// "base_id":1831,
// "quote_id":0,
// "last_price":"32830.21",
// "quote_volume":"1494659.8024096",
// "base_volume":"46.1083",
// "isFrozen":false,
// "change":"2.12"
// },
//
response = self.v4_public_get_ticker(&[params.clone()]).await;
} else if is_equal(&method, &Value::Str("v4PublicGetFutures".to_string())) {
//
// {
// "success": true,
// "message": null,
// "result": [
// {
// "ticker_id": "0G_PERP",
// "stock_currency": "0G",
// "money_currency": "USDT",
// "last_price": "0.6065",
// "stock_volume": "2563218",
// "money_volume": "1587952.6137",
// "bid": "0.6065",
// "ask": "0.6077",
// "high": "0.6472",
// "low": "0.6045",
// "product_type": "Perpetual",
// "open_interest": "3721488",
// "index_price": "0.61",
// "index_name": "0G future contract",
// "index_currency": "0G",
// "funding_rate": "-0.00000778",
// "next_funding_rate_timestamp": "1772467200000",
// "brackets": {
// "1": 0,
// "10": 0,
// "100": 0,
// "2": 0,
// "20": 4000,
// "3": 0,
// "5": 0,
// "50": 800
// },
// "max_leverage": 50,
// "funding_interval_minutes": 240
// }
// ]
// }
//
response = self.v4_public_get_futures(&[params.clone()]).await;
} else {
response = self.v2_public_get_ticker(&[params.clone()]).await;
}
let mut resultList: Value = self.safe_list_k(response.clone(), "result", &[]);
if !is_equal(&resultList, &Value::Null) {
return self.parse_tickers(resultList.clone(), &[symbols.clone()]);
}
let mut marketIds: Value = object_keys(&response);
let mut result: Value = Value::Map({
let mut m = indexmap::IndexMap::new();
m
});
{
let mut i: Value = Value::Int(0);
let mut __for_first_1110: bool = true;
while { if !__for_first_1110 { i = add(&i, &Value::Int(1)); } __for_first_1110 = false; is_less_than(&i, &get_array_length(&marketIds)) } {
let mut marketId: Value = get_value(&marketIds, &i);
let mut marketId: Value = get_value(&marketIds, &i);
let mut market: Value = self.safe_market(&[marketId.clone()]);
let mut ticker: Value = self.parse_ticker(get_value(&response, &marketId), &[market.clone()]);
let mut symbol: Value = get_value(&ticker, &Value::Str("symbol".to_string()));
add_element_to_object(&mut result, &symbol, ticker.clone());
}
}
return self.filter_by_array_tickers(result.clone(), Value::Str("symbol".to_string()), &[symbols.clone()]);
Value::Null
}
/*
* @method
* @name whitebit#fetchOrderBook
* @description fetches information on open orders with bid (buy) and ask (sell) prices, volumes and other data
* @see https://docs.whitebit.com/public/http-v4/#orderbook
* @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("market".to_string(), get_value(&market, &Value::Str("id".to_string())));
m
});
if !is_equal(&limit, &Value::Null) {
add_element_to_object(&mut request, &Value::Str("limit".to_string()), limit.clone()); // default = 100, maximum = 100
}
let __ws_arg_3 = self.extend(request.clone(), &[params.clone()]);
let mut response: Value = self.v4_public_get_orderbook_market(&[__ws_arg_3]).await;
//
// {
// "timestamp": 1594391413,
// "asks": [
// [
// "9184.41",
// "0.773162"
// ],
// [ ... ]
// ],
// "bids": [
// [
// "9181.19",
// "0.010873"
// ],
// [ ... ]
// ]
// }
//
let mut timestamp: Value = self.safe_timestamp(response.clone(), Value::Str("timestamp".to_string()), &[]);
return self.parse_order_book(response.clone(), symbol.clone(), &[timestamp.clone()]);
Value::Null
}
/*
* @method
* @name whitebit#fetchTrades
* @description get the list of most recent trades for a particular symbol
* @see https://docs.whitebit.com/public/http-v4/#recent-trades
* @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
* @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("market".to_string(), get_value(&market, &Value::Str("id".to_string())));
m
});
let __ws_arg_4 = self.extend(request.clone(), &[params.clone()]);
let mut response: Value = self.v4_public_get_trades_market(&[__ws_arg_4]).await;
return self.parse_trades(response.clone(), &[market.clone(), since.clone(), limit.clone()]);
Value::Null
}
/*
* @method
* @name whitebit#fetchMyTrades
* @description fetch all trades made by the user
* @see https://docs.whitebit.com/private/http-trade-v4/#query-executed-order-history
* @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
* @returns {Trade[]} a list of [trade structures]{@link https://docs.ccxt.com/?id=public-trades}
*/
pub async fn fetch_my_trades(&mut self, optional_args: &[Value]) -> Value {
let mut symbol = get_arg(optional_args, 0, Value::Null);
let mut since = get_arg(optional_args, 1, Value::Null);
let mut limit = get_arg(optional_args, 2, Value::Null);
let mut params = get_arg(optional_args, 3, Value::Map({
let mut m = indexmap::IndexMap::new();
m
}));
if is_equal(&self.markets, &Value::Null) {
self.load_markets(&[]).await;
}
let mut 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("market".to_string()), get_value(&market, &Value::Str("id".to_string())));
}
let __ws_arg_5 = self.extend(request.clone(), &[params.clone()]);
let mut response: Value = self.v4_private_post_trade_account_executed_history(&[__ws_arg_5]).await;
//
// when no symbol is provided
//
// {
// "USDC_USDT":[
// {
// "id":"1343815269",
// "clientOrderId":"",
// "time":"1641051917.532965",
// "side":"sell",
// "role":"2",
// "amount":"9.986",
// "price":"0.9995",
// "deal":"9.981007",
// "fee":"0.009981007",
// "orderId":"58166729555"
// },
// ]
// }
//
// when a symbol is provided
//
// [
// {
// "id": 1343815269,
// "clientOrderId": '',
// "time": 1641051917.532965,
// "side": "sell",
// "role": 2,
// "amount": "9.986",
// "price": "0.9995",
// "deal": "9.981007",
// "fee": "0.009981007",
// "orderId": 58166729555,
// },
// ]
//
if is_true(&Value::Bool(is_array(&response))) {
return self.parse_trades(response.clone(), &[market.clone(), since.clone(), limit.clone()]);
} else {
let mut results: Value = Value::List(vec![]);
let mut keys: Value = object_keys(&response);
{
let mut i: Value = Value::Int(0);
let mut __for_first_1111: bool = true;
while { if !__for_first_1111 { i = add(&i, &Value::Int(1)); } __for_first_1111 = false; is_less_than(&i, &get_array_length(&keys)) } {
let mut marketId: Value = get_value(&keys, &i);
let mut marketId: Value = get_value(&keys, &i);
let mut marketNew: Value = self.safe_market(&[marketId.clone(), Value::Null, Value::Str("_".to_string())]);
let mut rawTrades: Value = self.safe_value(response.clone(), marketId.clone(), &[Value::List(vec![])]);
let mut parsed: Value = self.parse_trades(rawTrades.clone(), &[marketNew.clone(), since.clone(), limit.clone()]);
results = self.array_concat(results.clone(), parsed.clone());
}
}
results = self.sort_by2(results.clone(), Value::Str("timestamp".to_string()), Value::Str("id".to_string()), &[]);
return self.filter_by_since_limit(results.clone(), &[since.clone(), limit.clone(), Value::Str("timestamp".to_string())]);
}
Value::Null
}
pub fn parse_trade(&self, mut trade: Value, optional_args: &[Value]) -> Value {
let mut market = get_arg(optional_args, 0, Value::Null);
//
// fetchTradesV4
//
// {
// "tradeID": 158056419,
// "price": "9186.13",
// "quote_volume": "0.0021",
// "base_volume": "9186.13",
// "trade_timestamp": 1594391747,
// "type": "sell"
// }
//
// orderTrades (v4Private)
//
// {
// "time": 1593342324.613711,
// "fee": "0.00000419198",
// "price": "0.00000701",
// "amount": "598",
// "id": 149156519, // trade id
// "dealOrderId": 3134995325, // orderId
// "clientOrderId": "customId11",
// "role": 2, // 1 = maker, 2 = taker
// "deal": "0.00419198" // amount in money
// "feeAsset": "USDT"
// }
//
// fetchMyTrades
//
// {
// "id": 1343815269,
// "clientOrderId": '',
// "time": 1641051917.532965,
// "side": "sell",
// "role": 2,
// "amount": "9.986",
// "price": "0.9995",
// "deal": "9.981007",
// "fee": "0.009981007",
// "orderId": 58166729555,
// "feeAsset": "USDT"
// }
//
market = self.safe_market(&[Value::Null, market.clone()]);
let mut timestamp: Value = self.safe_timestamp2(trade.clone(), Value::Str("time".to_string()), Value::Str("trade_timestamp".to_string()), &[]);
let mut orderId: Value = self.safe_string2(trade.clone(), Value::Str("dealOrderId".to_string()), Value::Str("orderId".to_string()), &[]);
let mut cost: Value = self.safe_string_k(trade.clone(), "deal", &[]);
let mut price: Value = self.safe_string_k(trade.clone(), "price", &[]);
let mut amount: Value = self.safe_string2(trade.clone(), Value::Str("amount".to_string()), Value::Str("quote_volume".to_string()), &[]);
let mut id: Value = self.safe_string2(trade.clone(), Value::Str("id".to_string()), Value::Str("tradeID".to_string()), &[]);
let mut side: Value = self.safe_string2(trade.clone(), Value::Str("type".to_string()), Value::Str("side".to_string()), &[]);
let mut symbol: Value = get_value(&market, &Value::Str("symbol".to_string()));
let mut role: Value = self.safe_integer_k(trade.clone(), "role", &[]);
let mut takerOrMaker: Value = Value::Null;
if !is_equal(&role, &Value::Null) {
takerOrMaker = ternary(is_true(&(is_equal(&role, &Value::Int(1)))), Value::Str("maker".to_string()), Value::Str("taker".to_string()));
}
let mut fee: Value = Value::Null;
let mut feeCost: Value = self.safe_string_k(trade.clone(), "fee", &[]);
if !is_equal(&feeCost, &Value::Null) {
fee = Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), feeCost.clone());
m.insert("currency".to_string(), self.safe_currency_code(self.safe_string_k(trade.clone(), "feeAsset", &[]), &[]));
m
});
}
return self.safe_trade(Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("info".to_string(), trade.clone());
m.insert("timestamp".to_string(), timestamp.clone());
m.insert("datetime".to_string(), self.iso8601(timestamp.clone()));
m.insert("symbol".to_string(), symbol.clone());
m.insert("id".to_string(), id.clone());
m.insert("order".to_string(), orderId.clone());
m.insert("type".to_string(), Value::Null);
m.insert("takerOrMaker".to_string(), takerOrMaker.clone());
m.insert("side".to_string(), side.clone());
m.insert("price".to_string(), price.clone());
m.insert("amount".to_string(), amount.clone());
m.insert("cost".to_string(), cost.clone());
m.insert("fee".to_string(), fee.clone());
m
}), &[market.clone()]);
Value::Null
}
/*
* @method
* @name whitebit#fetchOHLCV
* @description fetches historical candlestick data containing the open, high, low, and close price, and the volume of a market
* @see https://docs.whitebit.com/public/http-v1/#kline
* @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
* @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 request: Value = Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("market".to_string(), get_value(&market, &Value::Str("id".to_string())));
m.insert("interval".to_string(), self.safe_string(self.timeframes.clone(), timeframe.clone(), &[timeframe.clone()]));
m
});
if !is_equal(&since, &Value::Null) {
let mut maxLimit: Value = Value::Int(1440);
if is_equal(&limit, &Value::Null) {
limit = maxLimit.clone();
}
limit = crate::runtime::Math::min(&limit, &maxLimit);
let mut start: Value = self.parse_to_int(divide(&since, &Value::Int(1000)));
add_element_to_object(&mut request, &Value::Str("start".to_string()), start.clone());
}
if !is_equal(&limit, &Value::Null) {
add_element_to_object(&mut request, &Value::Str("limit".to_string()), crate::runtime::Math::min(&limit, &Value::Int(1440)));
}
let __ws_arg_6 = self.extend(request.clone(), &[params.clone()]);
let mut response: Value = self.v1_public_get_kline(&[__ws_arg_6]).await;
//
// {
// "success":true,
// "message":"",
// "result":[
// [1591488000,"0.025025","0.025025","0.025029","0.025023","6.181","0.154686629"],
// [1591488060,"0.025028","0.025033","0.025035","0.025026","8.067","0.201921167"],
// [1591488120,"0.025034","0.02505","0.02505","0.025034","20.089","0.503114696"],
// ]
// }
//
let mut result: Value = self.safe_list_k(response.clone(), "result", &[Value::List(vec![])]);
return self.parse_ohlc_vs(result.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_timestamp(ohlcv.clone(), Value::Int(0), &[]), self.safe_number(ohlcv.clone(), Value::Int(1), &[]), self.safe_number(ohlcv.clone(), Value::Int(3), &[]), self.safe_number(ohlcv.clone(), Value::Int(4), &[]), self.safe_number(ohlcv.clone(), Value::Int(2), &[]), self.safe_number(ohlcv.clone(), Value::Int(5), &[])]);
Value::Null
}
/*
* @method
* @name whitebit#fetchStatus
* @description the latest known information on the availability of the exchange API
* @see https://docs.whitebit.com/public/http-v4/#server-status
* @param {object} [params] extra parameters specific to the exchange API endpoint
* @returns {object} a [status structure]{@link https://docs.ccxt.com/?id=exchange-status-structure}
*/
pub async fn fetch_status(&mut self, optional_args: &[Value]) -> Value {
let mut params = get_arg(optional_args, 0, Value::Map({
let mut m = indexmap::IndexMap::new();
m
}));
let mut response: Value = self.v4_public_get_ping(&[params.clone()]).await;
//
// [
// "pong"
// ]
//
let mut status: Value = self.safe_string(response.clone(), Value::Int(0), &[]);
return Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("status".to_string(), ternary(is_true(&(is_equal(&status, &Value::Str("pong".to_string())))), Value::Str("ok".to_string()), status.clone()));
m.insert("updated".to_string(), Value::Null);
m.insert("eta".to_string(), Value::Null);
m.insert("url".to_string(), Value::Null);
m.insert("info".to_string(), response.clone());
m
});
Value::Null
}
/*
* @method
* @name whitebit#fetchTime
* @description fetches the current integer timestamp in milliseconds from the exchange server
* @see https://docs.whitebit.com/public/http-v4/#server-time
* @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 response: Value = self.v4_public_get_time(&[params.clone()]).await;
return self.safe_integer_product(response.clone(), Value::Str("time".to_string()), Value::Int(1000), &[]);
Value::Null
}
/*
* @method
* @name whitebit#createMarketOrderWithCost
* @description create a market order by providing the symbol, side and cost
* @param {string} symbol unified symbol of the market to create an order in
* @param {string} side 'buy' or 'sell'
* @param {float} cost how much you want to trade in units of the quote currency
* @param {object} [params] extra parameters specific to the exchange API endpoint
* @returns {object} an [order structure]{@link https://docs.ccxt.com/?id=order-structure}
*/
pub async fn create_market_order_with_cost(&mut self, mut symbol: Value, mut side: Value, mut cost: Value, optional_args: &[Value]) -> Value {
let mut params = get_arg(optional_args, 0, Value::Map({
let mut m = indexmap::IndexMap::new();
m
}));
let mut req: Value = Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), cost.clone());
m
});
let __ws_arg_7 = self.extend(req.clone(), &[params.clone()]);
return self.create_order(symbol.clone(), Value::Str("market".to_string()), side.clone(), Value::Int(0), &[Value::Null, __ws_arg_7]).await;
Value::Null
}
/*
* @method
* @name whitebit#createMarketBuyOrderWithCost
* @description create a market buy order by providing the symbol and cost
* @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
}));
return self.create_market_order_with_cost(symbol.clone(), Value::Str("buy".to_string()), cost.clone(), &[params.clone()]).await;
Value::Null
}
/*
* @method
* @name whitebit#createOrder
* @description create a trade order
* @see https://docs.whitebit.com/private/http-trade-v4/#create-limit-order
* @see https://docs.whitebit.com/private/http-trade-v4/#create-market-order
* @see https://docs.whitebit.com/private/http-trade-v4/#create-buy-stock-market-order
* @see https://docs.whitebit.com/private/http-trade-v4/#create-stop-limit-order
* @see https://docs.whitebit.com/private/http-trade-v4/#create-stop-market-order
* @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 {float} [params.cost] *market orders only* the cost of the order in units of the base currency
* @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 to the order book and not executed immediately
* @param {string} [params.timeInForce] "GTC", "IOC" or "PO"; IOC and PO are limit-order only, not supported for stop orders
* @param {string} [params.clientOrderId] a unique id for the order
* @param {string} [params.marginMode] 'cross' or 'isolated', for margin trading, uses this.options.defaultMarginMode if not passed, defaults to undefined/None/null
* @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 request: Value = Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("market".to_string(), get_value(&market, &Value::Str("id".to_string())));
m.insert("side".to_string(), side.clone());
m
});
let mut cost: Value = Value::Null;
{ let __destr_tmp = self.handle_param_string(params.clone(), Value::Str("cost".to_string()), &[]); cost = get_value(&__destr_tmp, &Value::Int(0)); params = get_value(&__destr_tmp, &Value::Int(1)); }
if !is_equal(&cost, &Value::Null) {
if is_true(&(!is_equal(&side, &Value::Str("buy".to_string())))) || is_true(&(!is_equal(&type_var, &Value::Str("market".to_string())))) {
panic!("{}", crate::exchange_errors::invalid_order(add(&self.id, &Value::Str(" createOrder() cost is only supported for market buy orders".to_string()))));
}
add_element_to_object(&mut request, &Value::Str("amount".to_string()), self.cost_to_precision(symbol.clone(), cost.clone()));
} else {
add_element_to_object(&mut request, &Value::Str("amount".to_string()), self.amount_to_precision(symbol.clone(), amount.clone()));
}
let mut clientOrderId: Value = self.safe_string2(params.clone(), Value::Str("clOrdId".to_string()), Value::Str("clientOrderId".to_string()), &[]);
if is_equal(&clientOrderId, &Value::Null) {
let mut brokerId: Value = self.safe_string_k(self.options.clone(), "brokerId", &[]);
if !is_equal(&brokerId, &Value::Null) {
add_element_to_object(&mut request, &Value::Str("clientOrderId".to_string()), add(&brokerId, &self.uuid16(&[])));
}
} else {
add_element_to_object(&mut request, &Value::Str("clientOrderId".to_string()), clientOrderId.clone());
params = self.omit(params.clone(), Value::List(vec![Value::Str("clientOrderId".to_string())]), &[]);
}
let mut marketType: Value = self.safe_string_k(market.clone(), "type", &[]);
let mut isLimitOrder: bool = is_equal(&type_var, &Value::Str("limit".to_string()));
let mut isMarketOrder: Value = Value::Bool(is_equal(&type_var, &Value::Str("market".to_string())));
let mut triggerPrice: Value = self.safe_number_n(params.clone(), Value::List(vec![Value::Str("triggerPrice".to_string()), Value::Str("stopPrice".to_string()), Value::Str("activation_price".to_string())]), &[]);
let mut isStopOrder: bool = !is_equal(&triggerPrice, &Value::Null);
let mut timeInForce: Value = self.safe_string_upper(params.clone(), Value::Str("timeInForce".to_string()), &[]);
if is_true(&(!is_equal(&timeInForce, &Value::Null))) && is_true(&(!is_equal(&timeInForce, &Value::Str("GTC".to_string())))) && is_true(&(!is_equal(&timeInForce, &Value::Str("IOC".to_string())))) && is_true(&(!is_equal(&timeInForce, &Value::Str("PO".to_string())))) {
panic!("{}", crate::exchange_errors::not_supported(add(&add(&add(&self.id, &Value::Str(" createOrder() does not support timeInForce ".to_string())), &timeInForce), &Value::Str(", only GTC, IOC and PO are allowed".to_string()))));
}
let mut postOnly: Value = self.is_post_only(isMarketOrder.clone(), Value::Bool(false), &[params.clone()]);
let mut ioc: bool = is_equal(&timeInForce, &Value::Str("IOC".to_string()));
if is_true(&isStopOrder) && is_true(&(is_true(&postOnly) || is_true(&ioc))) {
panic!("{}", crate::exchange_errors::not_supported(add(&self.id, &Value::Str(" createOrder() does not support postOnly or timeInForce IOC for stop orders".to_string()))));
}
if is_true(&ioc) && !is_true(&isLimitOrder) {
panic!("{}", crate::exchange_errors::not_supported(add(&self.id, &Value::Str(" createOrder() timeInForce IOC is only supported for limit orders".to_string()))));
}
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_true(&postOnly) {
add_element_to_object(&mut request, &Value::Str("postOnly".to_string()), Value::Bool(true));
}
if is_true(&ioc) {
add_element_to_object(&mut request, &Value::Str("ioc".to_string()), Value::Bool(true));
}
if !is_equal(&marginMode, &Value::Null) && !is_equal(&marginMode, &Value::Str("cross".to_string())) {
panic!("{}", crate::exchange_errors::not_supported(add(&self.id, &Value::Str(" createOrder() is only available for cross margin".to_string()))));
}
params = self.omit(query.clone(), Value::List(vec![Value::Str("postOnly".to_string()), Value::Str("triggerPrice".to_string()), Value::Str("stopPrice".to_string()), Value::Str("timeInForce".to_string())]), &[]);
let mut useCollateralEndpoint: bool = !is_equal(&marginMode, &Value::Null) || is_equal(&marketType, &Value::Str("swap".to_string()));
let mut response: Value = Value::Null;
if is_true(&isStopOrder) {
add_element_to_object(&mut request, &Value::Str("activation_price".to_string()), self.price_to_precision(symbol.clone(), triggerPrice.clone()));
if is_true(&isLimitOrder) {
// stop limit order
add_element_to_object(&mut request, &Value::Str("price".to_string()), self.price_to_precision(symbol.clone(), price.clone()));
let __ws_arg_8 = self.extend(request.clone(), &[params.clone()]);
response = self.v4_private_post_order_stop_limit(&[__ws_arg_8]).await;
} else {
// stop market order
if is_true(&useCollateralEndpoint) {
let __ws_arg_9 = self.extend(request.clone(), &[params.clone()]);
response = self.v4_private_post_order_collateral_trigger_market(&[__ws_arg_9]).await;
} else {
let __ws_arg_10 = self.extend(request.clone(), &[params.clone()]);
response = self.v4_private_post_order_stop_market(&[__ws_arg_10]).await;
}
}
} else {
if is_true(&isLimitOrder) {
// limit order
add_element_to_object(&mut request, &Value::Str("price".to_string()), self.price_to_precision(symbol.clone(), price.clone()));
if is_true(&useCollateralEndpoint) {
let __ws_arg_11 = self.extend(request.clone(), &[params.clone()]);
response = self.v4_private_post_order_collateral_limit(&[__ws_arg_11]).await;
} else {
let __ws_arg_12 = self.extend(request.clone(), &[params.clone()]);
response = self.v4_private_post_order_new(&[__ws_arg_12]).await;
}
} else {
// market order
if is_true(&useCollateralEndpoint) {
let __ws_arg_13 = self.extend(request.clone(), &[params.clone()]);
response = self.v4_private_post_order_collateral_market(&[__ws_arg_13]).await;
} else {
if !is_equal(&cost, &Value::Null) {
let __ws_arg_14 = self.extend(request.clone(), &[params.clone()]);
response = self.v4_private_post_order_market(&[__ws_arg_14]).await;
} else {
let __ws_arg_15 = self.extend(request.clone(), &[params.clone()]);
response = self.v4_private_post_order_stock_market(&[__ws_arg_15]).await;
}
}
}
}
return self.parse_order(response.clone(), &[]);
Value::Null
}
/*
* @method
* @name whitebit#editOrder
* @description edit a trade order
* @see https://docs.whitebit.com/private/http-trade-v4/#modify-order
* @param {string} id cancel order id
* @param {string} symbol unified symbol of the market to create an order in
* @param {string} type 'market' or 'limit'
* @param {string} side 'buy' or 'sell'
* @param {float} amount how much of currency you want to trade in units of base currency
* @param {float} price the price at which the order is to be fulfilled, in units of the quote currency, ignored in market orders
* @param {object} [params] extra parameters specific to the exchange API endpoint
* @returns {object} an [order structure]{@link https://docs.ccxt.com/?id=order-structure}
*/
pub async fn edit_order(&mut self, mut id: Value, mut symbol: Value, mut type_var: Value, mut side: Value, optional_args: &[Value]) -> Value {
let mut amount = get_arg(optional_args, 0, Value::Null);
let mut price = get_arg(optional_args, 1, Value::Null);
let mut params = get_arg(optional_args, 2, Value::Map({
let mut m = indexmap::IndexMap::new();
m
}));
if is_equal(&self.markets, &Value::Null) {
self.load_markets(&[]).await;
}
let mut market: Value = self.market(symbol.clone());
let mut request: Value = Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("market".to_string(), get_value(&market, &Value::Str("id".to_string())));
m
});
// Handle clientOrderId vs orderId (clientOrderId takes priority)
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("clientOrderId".to_string()), clientOrderId.clone());
} else {
add_element_to_object(&mut request, &Value::Str("orderId".to_string()), id.clone());
}
// Handle amount vs total parameter based on order type and side
let mut triggerPrice: Value = self.safe_number_n(params.clone(), Value::List(vec![Value::Str("triggerPrice".to_string()), Value::Str("stopPrice".to_string()), Value::Str("activationPrice".to_string())]), &[]);
let mut isStopOrder: bool = !is_equal(&triggerPrice, &Value::Null);
// Handle activation price for stop orders
if is_true(&isStopOrder) {
add_element_to_object(&mut request, &Value::Str("activation_price".to_string()), self.price_to_precision(symbol.clone(), triggerPrice.clone()));
}
let mut isLimitOrder: bool = is_equal(&type_var, &Value::Str("limit".to_string()));
let mut total: Value = self.safe_number_k(params.clone(), "total", &[]);
if !is_equal(&total, &Value::Null) {
add_element_to_object(&mut request, &Value::Str("total".to_string()), self.amount_to_precision(symbol.clone(), total.clone()));
} else if !is_equal(&amount, &Value::Null) {
if is_true(&isLimitOrder) {
// Limit orders always use amount parameter
add_element_to_object(&mut request, &Value::Str("amount".to_string()), self.amount_to_precision(symbol.clone(), amount.clone()));
} else if is_equal(&type_var, &Value::Str("market".to_string())) && is_equal(&side, &Value::Str("buy".to_string())) {
// Market buy orders use total parameter
add_element_to_object(&mut request, &Value::Str("total".to_string()), self.amount_to_precision(symbol.clone(), amount.clone()));
} else {
// Market sell orders use amount parameter
add_element_to_object(&mut request, &Value::Str("amount".to_string()), self.amount_to_precision(symbol.clone(), amount.clone()));
}
}
// Handle price parameter for limit orders
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()));
}
// Ensure at least one modifiable parameter is provided
let mut hasModifiableParam: bool = is_true(&(!is_equal(&amount, &Value::Null))) || is_true(&(!is_equal(&price, &Value::Null))) || is_true(&(!is_equal(&triggerPrice, &Value::Null))) || is_true(&(!is_equal(&total, &Value::Null)));
if !is_true(&hasModifiableParam) {
panic!("{}", crate::exchange_errors::arguments_required(add(&self.id, &Value::Str(" editOrder() requires at least one of: amount, price, activationPrice, or total parameters".to_string()))));
}
params = self.omit(params.clone(), Value::List(vec![Value::Str("clientOrderId".to_string()), Value::Str("triggerPrice".to_string()), Value::Str("stopPrice".to_string()), Value::Str("activationPrice".to_string()), Value::Str("total".to_string())]), &[]);
let __ws_arg_16 = self.extend(request.clone(), &[params.clone()]);
let mut response: Value = self.v4_private_post_order_modify(&[__ws_arg_16]).await;
return self.parse_order(response.clone(), &[]);
Value::Null
}
/*
* @method
* @name whitebit#cancelOrder
* @description cancels an open order
* @see https://docs.whitebit.com/private/http-trade-v4/#cancel-order
* @param {string} id order id
* @param {string} symbol unified symbol of the market the order was made in
* @param {object} [params] extra parameters specific to the exchange API endpoint
* @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(&symbol, &Value::Null) {
panic!("{}", crate::exchange_errors::arguments_required(add(&self.id, &Value::Str(" cancelOrder() 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("market".to_string(), get_value(&market, &Value::Str("id".to_string())));
m.insert("orderId".to_string(), crate::runtime::parse_int(&id));
m
});
let __ws_arg_17 = self.extend(request.clone(), &[params.clone()]);
let mut response: Value = self.v4_private_post_order_cancel(&[__ws_arg_17]).await;
return self.parse_order(response.clone(), &[]);
Value::Null
}
/*
* @method
* @name whitebit#cancelAllOrders
* @description cancel all open orders
* @see https://docs.whitebit.com/private/http-trade-v4/#cancel-all-orders
* @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
* @param {string} [params.type] market type, ['swap', 'spot']
* @param {boolean} [params.isMargin] cancel all margin orders
* @returns {object[]} a list of [order structures]{@link https://docs.ccxt.com/?id=order-structure}
*/
pub async fn cancel_all_orders(&mut self, optional_args: &[Value]) -> Value {
let mut symbol = get_arg(optional_args, 0, Value::Null);
let mut params = get_arg(optional_args, 1, Value::Map({
let mut m = indexmap::IndexMap::new();
m
}));
if is_equal(&self.markets, &Value::Null) {
self.load_markets(&[]).await;
}
let mut 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("market".to_string()), get_value(&market, &Value::Str("id".to_string())));
}
let mut type_var: Value = Value::Null;
{ let __destr_tmp = self.handle_market_type_and_params(Value::Str("cancelAllOrders".to_string()), &[market.clone(), params.clone()]); type_var = get_value(&__destr_tmp, &Value::Int(0)); params = get_value(&__destr_tmp, &Value::Int(1)); }
let mut requestType: Value = Value::List(vec![]);
if is_equal(&type_var, &Value::Str("spot".to_string())) {
let mut isMargin: Value = Value::Null;
{ let __destr_tmp = self.handle_option_and_params(params.clone(), Value::Str("cancelAllOrders".to_string()), Value::Str("isMargin".to_string()), &[Value::Bool(false)]); isMargin = get_value(&__destr_tmp, &Value::Int(0)); params = get_value(&__destr_tmp, &Value::Int(1)); }
if is_true(&isMargin) {
append_to_array(&mut requestType, Value::Str("margin".to_string()));
} else {
append_to_array(&mut requestType, Value::Str("spot".to_string()));
}
} else if is_equal(&type_var, &Value::Str("swap".to_string())) {
append_to_array(&mut requestType, Value::Str("futures".to_string()));
} else {
panic!("{}", crate::exchange_errors::not_supported(add(&add(&add(&self.id, &Value::Str(" cancelAllOrders() does not support ".to_string())), &type_var), &Value::Str(" type".to_string()))));
}
add_element_to_object(&mut request, &Value::Str("type".to_string()), requestType.clone());
let __ws_arg_18 = self.extend(request.clone(), &[params.clone()]);
let mut response: Value = self.v4_private_post_order_cancel_all(&[__ws_arg_18]).await;
return self.parse_orders(response.clone(), &[market.clone()]);
Value::Null
}
/*
* @method
* @name whitebit#fetchOrders
* @description fetches information on multiple orders made by the user (combines open and closed orders)
* @see https://docs.whitebit.com/private/http-trade-v4/#query-unexecutedactive-orders
* @see https://docs.whitebit.com/private/http-trade-v4/#query-executed-orders
* @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_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;
}
// Fetch both open and closed orders in parallel
let mut openOrdersclosedOrdersVariable = promise_all(&Value::List(vec![self.fetch_open_orders(&[symbol.clone(), since.clone(), limit.clone(), params.clone()]).await, self.fetch_closed_orders(&[symbol.clone(), since.clone(), limit.clone(), params.clone()]).await])).await;
let mut openOrders: Value = get_value(&openOrdersclosedOrdersVariable, &Value::Int(0));
let mut closedOrders: Value = get_value(&openOrdersclosedOrdersVariable, &Value::Int(1));
let mut allOrders: Value = self.array_concat(openOrders.clone(), closedOrders.clone());
// Sort by timestamp (most recent first)
let mut sortedOrders: Value = self.sort_by(allOrders.clone(), Value::Str("timestamp".to_string()), &[Value::Bool(true)]);
// Apply limit if specified (since and symbol filtering already handled by individual methods)
if !is_equal(&limit, &Value::Null) && is_greater_than(&get_array_length(&sortedOrders), &limit) {
return slice(&sortedOrders, &Value::Int(0), &limit);
}
return sortedOrders;
Value::Null
}
/*
* @method
* @name whitebit#cancelAllOrdersAfter
* @description dead man's switch, cancel all orders after the given timeout
* @see https://docs.whitebit.com/private/http-trade-v4/#sync-kill-switch-timer
* @param {number} timeout time in milliseconds, 0 represents cancel the timer
* @param {object} [params] extra parameters specific to the exchange API endpoint
* @param {string} [params.types] Order types value. Example: "spot", "margin", "futures" or null
* @param {string} [params.symbol] symbol unified symbol of the market the order was made in
* @returns {object} the api result
*/
pub async fn cancel_all_orders_after(&mut self, mut timeout: 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 symbol: Value = self.safe_string_k(params.clone(), "symbol", &[]);
if is_equal(&symbol, &Value::Null) {
panic!("{}", crate::exchange_errors::arguments_required(add(&self.id, &Value::Str(" cancelAllOrdersAfter() requires a symbol argument in params".to_string()))));
}
let mut market: Value = self.market(symbol.clone());
params = self.omit(params.clone(), Value::Str("symbol".to_string()), &[]);
if is_equal(&timeout, &Value::Null) {
panic!("{}", crate::exchange_errors::exchange_error(add(&self.id, &Value::Str(" cancelAllOrdersAfter() missing timeout".to_string()))));
}
let mut isBiggerThanZero: bool = is_greater_than(&timeout, &Value::Int(0));
let mut request: Value = Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("market".to_string(), get_value(&market, &Value::Str("id".to_string())));
m
});
if is_true(&isBiggerThanZero) {
add_element_to_object(&mut request, &Value::Str("timeout".to_string()), self.number_to_string(divide(&timeout, &Value::Int(1000))));
} else {
add_element_to_object(&mut request, &Value::Str("timeout".to_string()), Value::Str("null".to_string()));
}
let __ws_arg_19 = self.extend(request.clone(), &[params.clone()]);
let mut response: Value = self.v4_private_post_order_kill_switch(&[__ws_arg_19]).await;
return response;
Value::Null
}
pub fn parse_balance(&self, mut response: Value) -> Value {
let mut balanceKeys: Value = object_keys(&response);
let mut result: Value = Value::Map({
let mut m = indexmap::IndexMap::new();
m
});
{
let mut i: Value = Value::Int(0);
let mut __for_first_1112: bool = true;
while { if !__for_first_1112 { i = add(&i, &Value::Int(1)); } __for_first_1112 = false; is_less_than(&i, &get_array_length(&balanceKeys)) } {
let mut id: Value = get_value(&balanceKeys, &i);
let mut id: Value = get_value(&balanceKeys, &i);
let mut code: Value = self.safe_currency_code(id.clone(), &[]);
let mut balance: Value = get_value(&response, &id);
let mut balance: Value = get_value(&response, &id);
if !is_equal(&balance, &Value::Null) && is_true(&self.is_dictionary(balance.clone())) {
let mut account: Value = self.account();
add_element_to_object(&mut account, &Value::Str("free".to_string()), self.safe_string2(balance.clone(), Value::Str("available".to_string()), Value::Str("main_balance".to_string()), &[]));
add_element_to_object(&mut account, &Value::Str("used".to_string()), self.safe_string_k(balance.clone(), "freeze", &[]));
add_element_to_object(&mut account, &Value::Str("total".to_string()), self.safe_string_k(balance.clone(), "main_balance", &[]));
if !is_equal(&code, &Value::Null) {
add_element_to_object(&mut result, &code, account.clone());
}
} else {
let mut account: Value = self.account();
add_element_to_object(&mut account, &Value::Str("total".to_string()), balance.clone());
if !is_equal(&code, &Value::Null) {
add_element_to_object(&mut result, &code, account.clone());
}
}
}
}
return self.safe_balance(result.clone());
Value::Null
}
/*
* @method
* @name whitebit#fetchBalance
* @description query for balance and get the amount of funds available for trading or funds locked in orders
* @see https://docs.whitebit.com/private/http-main-v4/#main-balance
* @see https://docs.whitebit.com/private/http-trade-v4/#trading-balance
* @param {object} [params] extra parameters specific to the exchange API endpoint
* @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 __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 response: Value = Value::Null;
if is_equal(&marketType, &Value::Str("swap".to_string())) {
response = self.v4_private_post_collateral_account_balance(&[params.clone()]).await;
} else {
let mut options: Value = self.safe_value_k(self.options.clone(), "fetchBalance", &[Value::Map({
let mut m = indexmap::IndexMap::new();
m
})]);
let mut defaultAccount: Value = self.safe_string_k(options.clone(), "account", &[]);
let mut account: Value = self.safe_string2(params.clone(), Value::Str("account".to_string()), Value::Str("type".to_string()), &[defaultAccount.clone()]);
params = self.omit(params.clone(), Value::List(vec![Value::Str("account".to_string()), Value::Str("type".to_string())]), &[]);
if is_equal(&account, &Value::Str("main".to_string())) || is_equal(&account, &Value::Str("funding".to_string())) {
response = self.v4_private_post_main_account_balance(&[params.clone()]).await;
} else {
response = self.v4_private_post_trade_account_balance(&[params.clone()]).await;
}
}
return self.parse_balance(response.clone());
Value::Null
}
/*
* @method
* @name whitebit#fetchOpenOrders
* @description fetch all unfilled currently open orders
* @see https://docs.whitebit.com/private/http-trade-v4/#query-unexecutedactive-orders
* @param {string} [symbol] unified market symbol
* @param {int} [since] the earliest time in ms to fetch open orders for
* @param {int} [limit] the maximum number of open 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_open_orders(&mut self, optional_args: &[Value]) -> Value {
let mut symbol = get_arg(optional_args, 0, Value::Null);
let mut since = get_arg(optional_args, 1, Value::Null);
let mut limit = get_arg(optional_args, 2, Value::Null);
let mut params = get_arg(optional_args, 3, Value::Map({
let mut m = indexmap::IndexMap::new();
m
}));
if is_equal(&self.markets, &Value::Null) {
self.load_markets(&[]).await;
}
let mut market: Value = Value::Null;
let mut 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("market".to_string()), get_value(&market, &Value::Str("id".to_string())));
}
if !is_equal(&limit, &Value::Null) {
add_element_to_object(&mut request, &Value::Str("limit".to_string()), crate::runtime::Math::min(&limit, &Value::Int(100)));
}
let __ws_arg_20 = self.extend(request.clone(), &[params.clone()]);
let mut response: Value = self.v4_private_post_orders(&[__ws_arg_20]).await;
return self.parse_orders(response.clone(), &[market.clone(), since.clone(), limit.clone(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("status".to_string(), Value::Str("open".to_string()));
m
})]);
Value::Null
}
/*
* @method
* @name whitebit#fetchClosedOrders
* @description fetches information on multiple closed orders made by the user
* @see https://docs.whitebit.com/private/http-trade-v4/#query-executed-orders
* @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
}));
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());
symbol = get_value(&market, &Value::Str("symbol".to_string()));
add_element_to_object(&mut request, &Value::Str("market".to_string()), get_value(&market, &Value::Str("id".to_string())));
}
if !is_equal(&limit, &Value::Null) {
add_element_to_object(&mut request, &Value::Str("limit".to_string()), crate::runtime::Math::min(&limit, &Value::Int(100))); // default 50 max 100
}
let __ws_arg_21 = self.extend(request.clone(), &[params.clone()]);
let mut response: Value = self.v4_private_post_trade_account_order_history(&[__ws_arg_21]).await;
//
// {
// "BTC_USDT": [
// {
// "id": 160305483,
// "clientOrderId": "customId11",
// "time": 1594667731.724403,
// "side": "sell",
// "role": 2, // 1 = maker, 2 = taker
// "amount": "0.000076",
// "price": "9264.21",
// "deal": "0.70407996",
// "fee": "0.00070407996"
// },
// ],
// }
//
let mut marketIds: Value = object_keys(&response);
let mut results: Value = Value::List(vec![]);
{
let mut i: Value = Value::Int(0);
let mut __for_first_1114: bool = true;
while { if !__for_first_1114 { i = add(&i, &Value::Int(1)); } __for_first_1114 = false; is_less_than(&i, &get_array_length(&marketIds)) } {
let mut marketId: Value = get_value(&marketIds, &i);
let mut marketId: Value = get_value(&marketIds, &i);
let mut marketNew: Value = self.safe_market(&[marketId.clone(), Value::Null, Value::Str("_".to_string())]);
let mut orders: Value = self.safe_list(response.clone(), marketId.clone(), &[Value::List(vec![])]);
{
let mut j: Value = Value::Int(0);
let mut __for_first_1113: bool = true;
while { if !__for_first_1113 { j = add(&j, &Value::Int(1)); } __for_first_1113 = false; is_less_than(&j, &get_array_length(&orders)) } {
let mut order: Value = self.parse_order(get_value(&orders, &j), &[marketNew.clone()]);
append_to_array(&mut results, self.extend(order.clone(), &[Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("status".to_string(), Value::Str("closed".to_string()));
m
})]));
}
}
}
}
results = self.sort_by(results.clone(), Value::Str("timestamp".to_string()), &[]);
results = self.filter_by_symbol_since_limit(results.clone(), &[symbol.clone(), since.clone(), limit.clone()]);
return results;
Value::Null
}
pub fn parse_order_type(&self, mut type_var: Value) -> Value {
let mut types: Value = Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("limit".to_string(), Value::Str("limit".to_string()));
m.insert("market".to_string(), Value::Str("market".to_string()));
m.insert("stop market".to_string(), Value::Str("market".to_string()));
m.insert("stop limit".to_string(), Value::Str("limit".to_string()));
m.insert("stock market".to_string(), Value::Str("market".to_string()));
m.insert("margin limit".to_string(), Value::Str("limit".to_string()));
m.insert("margin market".to_string(), Value::Str("market".to_string()));
m
});
return self.safe_string(types.clone(), type_var.clone(), &[type_var.clone()]);
Value::Null
}
pub fn parse_order(&self, mut order: Value, optional_args: &[Value]) -> Value {
let mut market = get_arg(optional_args, 0, Value::Null);
//
// createOrder, fetchOpenOrders, cancelOrder
//
// {
// "orderId":105687928629,
// "clientOrderId":"",
// "market":"DOGE_USDT",
// "side":"sell",
// "type":"stop market",
// "timestamp":1659091079.729576,
// "dealMoney":"0", // executed amount in quote
// "dealStock":"0", // base filled amount
// "amount":"100",
// "takerFee":"0.001",
// "makerFee":"0",
// "left":"100",
// "price": "40000", // price if price isset
// "dealFee":"0",
// "activation_price":"0.065" // stop price (if stop limit or stop market)
// }
//
// fetchClosedOrders
//
// {
// "id":105531094719,
// "clientOrderId":"",
// "ctime":1659045334.550127,
// "ftime":1659045334.550127,
// "side":"buy",
// "amount":"5.9940059", // cost in terms of quote for regular market orders, amount in terms or base for all other order types
// "price":"0",
// "type":"market",
// "takerFee":"0.001",
// "makerFee":"0",
// "dealFee":"0.0059375815",
// "dealStock":"85", // base filled amount
// "dealMoney":"5.9375815", // executed amount in quote
// }
//
let mut marketId: Value = self.safe_string_k(order.clone(), "market", &[]);
market = self.safe_market(&[marketId.clone(), market.clone(), Value::Str("_".to_string())]);
let mut symbol: Value = get_value(&market, &Value::Str("symbol".to_string()));
let mut side: Value = self.safe_string_k(order.clone(), "side", &[]);
let mut filled: Value = self.safe_string_k(order.clone(), "dealStock", &[]);
let mut remaining: Value = self.safe_string_k(order.clone(), "left", &[]);
let mut clientOrderId: Value = self.safe_string_k(order.clone(), "clientOrderId", &[]);
if is_equal(&clientOrderId, &Value::Str("".to_string())) {
clientOrderId = Value::Null;
}
let mut price: Value = self.safe_string_k(order.clone(), "price", &[]);
let mut triggerPrice: Value = self.safe_number_k(order.clone(), "activation_price", &[]);
let mut orderId: Value = self.safe_string2(order.clone(), Value::Str("orderId".to_string()), Value::Str("id".to_string()), &[]);
let mut type_var: Value = self.safe_string_k(order.clone(), "type", &[]);
let mut orderType: Value = self.parse_order_type(type_var.clone());
if is_equal(&orderType, &Value::Str("market".to_string())) {
remaining = Value::Null;
}
let mut amount: Value = self.safe_string_k(order.clone(), "amount", &[]);
let mut cost: Value = self.safe_string_k(order.clone(), "dealMoney", &[]);
if is_true(&(is_equal(&side, &Value::Str("buy".to_string())))) && is_true(&(is_true(&(is_equal(&type_var, &Value::Str("market".to_string())))) || is_true(&(is_equal(&type_var, &Value::Str("stop market".to_string())))))) {
amount = filled.clone();
}
let mut dealFee: Value = self.safe_string_k(order.clone(), "dealFee", &[]);
let mut fee: Value = Value::Null;
if !is_equal(&dealFee, &Value::Null) {
fee = Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), self.parse_number(dealFee.clone(), &[]));
m.insert("currency".to_string(), get_value(&market, &Value::Str("quote".to_string())));
m
});
}
let mut timestamp: Value = self.safe_timestamp2(order.clone(), Value::Str("ctime".to_string()), Value::Str("timestamp".to_string()), &[]);
let mut lastTradeTimestamp: Value = self.safe_timestamp(order.clone(), Value::Str("ftime".to_string()), &[]);
let mut postOnly: Value = self.safe_bool_k(order.clone(), "postOnly", &[]);
let mut ioc: Value = self.safe_bool_k(order.clone(), "ioc", &[]);
let mut timeInForce: Value = Value::Null;
if is_equal(&ioc, &Value::Bool(true)) {
timeInForce = Value::Str("IOC".to_string());
} else if is_equal(&postOnly, &Value::Bool(true)) {
timeInForce = Value::Str("PO".to_string());
}
return self.safe_order(Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("info".to_string(), order.clone());
m.insert("id".to_string(), orderId.clone());
m.insert("symbol".to_string(), symbol.clone());
m.insert("clientOrderId".to_string(), clientOrderId.clone());
m.insert("timestamp".to_string(), timestamp.clone());
m.insert("datetime".to_string(), self.iso8601(timestamp.clone()));
m.insert("lastTradeTimestamp".to_string(), lastTradeTimestamp.clone());
m.insert("timeInForce".to_string(), timeInForce.clone());
m.insert("postOnly".to_string(), postOnly.clone());
m.insert("status".to_string(), self.parse_order_status(self.safe_string_k(order.clone(), "status", &[])));
m.insert("side".to_string(), side.clone());
m.insert("price".to_string(), price.clone());
m.insert("type".to_string(), orderType.clone());
m.insert("triggerPrice".to_string(), triggerPrice.clone());
m.insert("amount".to_string(), amount.clone());
m.insert("filled".to_string(), filled.clone());
m.insert("remaining".to_string(), remaining.clone());
m.insert("average".to_string(), Value::Null);
m.insert("cost".to_string(), cost.clone());
m.insert("fee".to_string(), fee.clone());
m.insert("trades".to_string(), Value::Null);
m
}), &[market.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("CANCELED".to_string(), Value::Str("canceled".to_string()));
m.insert("OPEN".to_string(), Value::Str("open".to_string()));
m.insert("PARTIALLY_FILLED".to_string(), Value::Str("open".to_string()));
m.insert("FILLED".to_string(), Value::Str("closed".to_string()));
m
});
return self.safe_string_lower(statuses.clone(), status.clone(), &[status.clone()]);
Value::Null
}
/*
* @method
* @name whitebit#fetchOrderTrades
* @description fetch all the trades made from a single order
* @see https://docs.whitebit.com/private/http-trade-v4/#query-executed-order-deals
* @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.insert("orderId".to_string(), crate::runtime::parse_int(&id));
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("market".to_string()), get_value(&market, &Value::Str("id".to_string())));
}
if !is_equal(&limit, &Value::Null) {
add_element_to_object(&mut request, &Value::Str("limit".to_string()), crate::runtime::Math::min(&limit, &Value::Int(100)));
}
let __ws_arg_22 = self.extend(request.clone(), &[params.clone()]);
let mut response: Value = self.v4_private_post_trade_account_order(&[__ws_arg_22]).await;
//
// {
// "records": [
// {
// "time": 1593342324.613711,
// "fee": "0.00000419198",
// "price": "0.00000701",
// "amount": "598",
// "id": 149156519, // trade id
// "dealOrderId": 3134995325, // orderId
// "clientOrderId": "customId11", // empty string if not specified
// "role": 2, // 1 = maker, 2 = taker
// "deal": "0.00419198"
// }
// ],
// "offset": 0,
// "limit": 100
// }
//
let mut data: Value = self.safe_list_k(response.clone(), "records", &[Value::List(vec![])]);
return self.parse_trades(data.clone(), &[market.clone()]);
Value::Null
}
/*
* @method
* @name whitebit#fetchWithdrawals
* @description fetch all withdrawals made from an account
* @see https://docs.whitebit.com/private/http-main-v4/#get-depositwithdraw-history
* @param {string} code unified currency code
* @param {int} [since] the earliest time in ms to fetch withdrawals for
* @param {int} [limit] the maximum number of withdrawals structures to retrieve
* @param {object} [params] extra parameters specific to the exchange API endpoint
* @param {string} [params.transactionMethod] transaction method (1=deposit, 2=withdrawal) - automatically set to '2' for withdrawals
* @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 currency: Value = Value::Null;
let mut request: Value = Value::Map({
let mut m = indexmap::IndexMap::new();
m
});
if !is_equal(&code, &Value::Null) {
currency = self.currency(code.clone());
add_element_to_object(&mut request, &Value::Str("ticker".to_string()), get_value(¤cy, &Value::Str("id".to_string())));
}
if !is_equal(&since, &Value::Null) {
add_element_to_object(&mut request, &Value::Str("startDate".to_string()), self.parse_to_int(divide(&since, &Value::Int(1000))));
}
if is_equal(&limit, &Value::Null) || is_greater_than(&limit, &Value::Int(100)) {
limit = Value::Int(100);
}
if !is_equal(&limit, &Value::Null) {
add_element_to_object(&mut request, &Value::Str("limit".to_string()), limit.clone());
}
// Use transactionMethod parameter to filter withdrawals server-side (method = 2)
add_element_to_object(&mut request, &Value::Str("transactionMethod".to_string()), Value::Str("2".to_string()));
let __ws_arg_23 = self.extend(request.clone(), &[params.clone()]);
let mut response: Value = self.v4_private_post_main_account_history(&[__ws_arg_23]).await;
return self.parse_transactions(self.safe_list_k(response.clone(), "records", &[Value::List(vec![])]), &[currency.clone(), since.clone(), limit.clone()]);
Value::Null
}
/*
* @method
* @name whitebit#fetchTransactions
* @description fetch history of deposits and withdrawals
* @see https://docs.whitebit.com/private/http-main-v4/#get-depositwithdraw-history
* @param {string} [code] unified currency code
* @param {int} [since] the earliest time in ms to fetch transactions for
* @param {int} [limit] the maximum number of transactions structures to retrieve
* @param {object} [params] extra parameters specific to the exchange API endpoint
* @param {string} [params.transactionMethod] transaction method (1=deposit, 2=withdrawal) - automatically set to '1' for deposits
* @returns {object[]} a list of [transaction structures]{@link https://docs.ccxt.com/?id=transaction-structure}
*/
pub async fn fetch_transactions(&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 currency: Value = Value::Null;
let mut request: Value = Value::Map({
let mut m = indexmap::IndexMap::new();
m
});
if !is_equal(&code, &Value::Null) {
currency = self.currency(code.clone());
add_element_to_object(&mut request, &Value::Str("ticker".to_string()), get_value(¤cy, &Value::Str("id".to_string())));
}
if !is_equal(&since, &Value::Null) {
add_element_to_object(&mut request, &Value::Str("startDate".to_string()), self.parse_to_int(divide(&since, &Value::Int(1000))));
}
if is_equal(&limit, &Value::Null) || is_greater_than(&limit, &Value::Int(100)) {
limit = Value::Int(100);
}
if !is_equal(&limit, &Value::Null) {
add_element_to_object(&mut request, &Value::Str("limit".to_string()), limit.clone());
}
// Do not filter by transactionMethod to get all transactions (deposits and withdrawals)
let __ws_arg_24 = self.extend(request.clone(), &[params.clone()]);
let mut response: Value = self.v4_private_post_main_account_history(&[__ws_arg_24]).await;
//
// {
// "records": [
// {
// "address": "TDepositAddressExample1111111111111",
// "uniqueId": null,
// "transactionId": "11111111-2222-3333-4444-555555555555",
// "createdAt": 1786182572,
// "currency": "Tether US",
// "ticker": "USDT",
// "method": 1, // 1 = deposit, 2 = withdraw
// "amount": "20.723117",
// "description": null,
// "memo": null,
// "fee": "0",
// "status": 3,
// "network": "TRC20",
// "transactionHash": "a1b2c3d4e5f6a7b8c9d0e1f2a3b4c5d6e7f8a9b0c1d2e3f4a5b6c7d8e9f0a1b2",
// "details": { "partial": null },
// "centralized": false
// }
// ],
// "total": 1,
// "limit": 100,
// "offset": 0
// }
//
let mut records: Value = self.safe_list_k(response.clone(), "records", &[Value::List(vec![])]);
return self.parse_transactions(records.clone(), &[currency.clone(), since.clone(), limit.clone()]);
Value::Null
}
/*
* @method
* @name whitebit#fetchDepositAddress
* @description fetch the deposit address for a currency associated with this account
* @see https://docs.whitebit.com/private/http-main-v4/#get-fiat-deposit-address
* @see https://docs.whitebit.com/private/http-main-v4/#get-cryptocurrency-deposit-address
* @param {string} code unified currency code
* @param {object} [params] extra parameters specific to the exchange API endpoint
* @returns {object} an [address structure]{@link https://docs.ccxt.com/?id=address-structure}
*/
pub async fn fetch_deposit_address(&mut self, mut code: Value, optional_args: &[Value]) -> Value {
let mut params = get_arg(optional_args, 0, Value::Map({
let mut m = indexmap::IndexMap::new();
m
}));
if is_equal(&self.markets, &Value::Null) {
self.load_markets(&[]).await;
}
let mut currency: Value = self.currency(code.clone());
let mut request: Value = Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("ticker".to_string(), get_value(¤cy, &Value::Str("id".to_string())));
m
});
let mut response: Value = Value::Null;
if is_true(&self.is_fiat(code.clone())) {
let mut provider: Value = self.safe_string_k(params.clone(), "provider", &[]);
if is_equal(&provider, &Value::Null) {
panic!("{}", crate::exchange_errors::arguments_required(add(&self.id, &Value::Str(" fetchDepositAddress() requires a provider when the ticker is fiat".to_string()))));
}
add_element_to_object(&mut request, &Value::Str("provider".to_string()), provider.clone());
let mut amount: Value = self.safe_number_k(params.clone(), "amount", &[]);
if is_equal(&amount, &Value::Null) {
panic!("{}", crate::exchange_errors::arguments_required(add(&self.id, &Value::Str(" fetchDepositAddress() requires an amount when the ticker is fiat".to_string()))));
}
add_element_to_object(&mut request, &Value::Str("amount".to_string()), amount.clone());
let mut uniqueId: Value = self.safe_value_k(params.clone(), "uniqueId", &[]);
if is_equal(&uniqueId, &Value::Null) {
panic!("{}", crate::exchange_errors::arguments_required(add(&self.id, &Value::Str(" fetchDepositAddress() requires an uniqueId when the ticker is fiat".to_string()))));
}
let __ws_arg_25 = self.extend(request.clone(), &[params.clone()]);
response = self.v4_private_post_main_account_fiat_deposit_url(&[__ws_arg_25]).await;
} else {
let __ws_arg_26 = self.extend(request.clone(), &[params.clone()]);
response = self.v4_private_post_main_account_address(&[__ws_arg_26]).await;
}
//
// fiat
//
// {
// "url": "https://someaddress.com"
// }
//
// crypto
//
// {
// "account": {
// "address": "GDTSOI56XNVAKJNJBLJGRNZIVOCIZJRBIDKTWSCYEYNFAZEMBLN75RMN",
// "memo": "48565488244493"
// },
// "required": {
// "fixedFee": "0",
// "flexFee": {
// "maxFee": "0",
// "minFee": "0",
// "percent": "0"
// },
// "maxAmount": "0",
// "minAmount": "1"
// }
// }
//
let mut url: Value = self.safe_string_k(response.clone(), "url", &[]);
let mut account: Value = self.safe_value_k(response.clone(), "account", &[Value::Map({
let mut m = indexmap::IndexMap::new();
m
})]);
let mut address: Value = self.safe_string_k(account.clone(), "address", &[url.clone()]);
let mut tag: Value = self.safe_string_k(account.clone(), "memo", &[]);
self.check_address(&[address.clone()]);
return Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("info".to_string(), response.clone());
m.insert("currency".to_string(), code.clone());
m.insert("network".to_string(), Value::Null);
m.insert("address".to_string(), address.clone());
m.insert("tag".to_string(), tag.clone());
m
});
Value::Null
}
/*
* @method
* @name whitebit#createDepositAddress
* @description create a currency deposit address
* @see https://docs.whitebit.com/private/http-main-v4/#create-new-address-for-deposit
* @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 to create a deposit address on
* @param {string} [params.type] address type, available for specific currencies
* @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("ticker".to_string(), get_value(¤cy, &Value::Str("id".to_string())));
m
});
let __ws_arg_27 = self.extend(request.clone(), &[params.clone()]);
let mut response: Value = self.v4_private_post_main_account_create_new_address(&[__ws_arg_27]).await;
//
// {
// "account": {
// "address": "GDTSOI56XNVAKJNJBLJGRNZIVOCIZJRBIDKTWSCYEYNFAZEMBLN75RMN",
// "memo": "48565488244493"
// },
// "required": {
// "maxAmount": "0",
// "minAmount": "1",
// "fixedFee": "0",
// "flexFee": {
// "maxFee": "0",
// "minFee": "0",
// "percent": "0"
// }
// }
// }
//
let mut data: Value = self.safe_dict_k(response.clone(), "account", &[Value::Map({
let mut m = indexmap::IndexMap::new();
m
})]);
return self.parse_deposit_address(data.clone(), &[currency.clone()]);
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);
return Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("info".to_string(), depositAddress.clone());
m.insert("currency".to_string(), self.safe_currency_code(Value::Null, &[currency.clone()]));
m.insert("network".to_string(), Value::Null);
m.insert("address".to_string(), self.safe_string_k(depositAddress.clone(), "address", &[]));
m.insert("tag".to_string(), self.safe_string_k(depositAddress.clone(), "memo", &[]));
m
});
Value::Null
}
/*
* @method
* @name whitebit#fetchAccounts
* @description fetch all the accounts associated with a profile
* @see https://docs.whitebit.com/private/http-main-v4/#sub-account-list
* @param {object} [params] extra parameters specific to the exchange API endpoint
* @returns {object[]} a list of [account structures]{@link https://docs.ccxt.com/?id=account-structure}
*/
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
}));
if is_equal(&self.markets, &Value::Null) {
self.load_markets(&[]).await;
}
let mut accounts: Value = Value::List(vec![]);
let mut response: Value = self.v4_private_post_sub_account_list(&[params.clone()]).await;
//
// {
// "offset": 0,
// "limit": 100,
// "data": [
// {
// "id": "8e667b4a-0b71-4988-8af5-9474dbfaeb51",
// "alias": "trading_bot",
// "userId": "u-12345",
// "email": "s***@example.com",
// "status": "active",
// "color": "#FF5733",
// "kyc": { "shareKyc": false, "kycStatus": "verified" },
// "permissions": { "spotEnabled": true, "collateralEnabled": false }
// }
// ]
// }
//
let mut subAccounts: Value = self.safe_list_k(response.clone(), "data", &[Value::List(vec![])]);
{
let mut i: Value = Value::Int(0);
let mut __for_first_1115: bool = true;
while { if !__for_first_1115 { i = add(&i, &Value::Int(1)); } __for_first_1115 = false; is_less_than(&i, &get_array_length(&subAccounts)) } {
let mut subAccount: Value = self.safe_dict(subAccounts.clone(), i.clone(), &[Value::Map({
let mut m = indexmap::IndexMap::new();
m
})]);
let mut accountId: Value = self.safe_string_k(subAccount.clone(), "id", &[]);
let mut accountName: Value = self.safe_string_k(subAccount.clone(), "alias", &[]);
append_to_array(&mut accounts, Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("id".to_string(), accountId.clone());
m.insert("type".to_string(), Value::Str("subaccount".to_string()));
m.insert("name".to_string(), accountName.clone());
m.insert("code".to_string(), Value::Null);
m.insert("info".to_string(), subAccount.clone());
m
}));
}
}
return accounts;
Value::Null
}
/*
* @method
* @name whitebit#setLeverage
* @description set the level of leverage for a market
* @see https://docs.whitebit.com/private/http-trade-v4/#change-collateral-account-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;
}
if !is_equal(&symbol, &Value::Null) {
panic!("{}", crate::exchange_errors::not_supported(add(&self.id, &Value::Str(" setLeverage() does not allow to set per symbol".to_string()))));
}
if is_true(&(is_less_than(&leverage, &Value::Int(1)))) || is_true(&(is_greater_than(&leverage, &Value::Int(20)))) {
panic!("{}", crate::exchange_errors::bad_request(add(&self.id, &Value::Str(" setLeverage() leverage should be between 1 and 20".to_string()))));
}
let mut request: Value = Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("leverage".to_string(), leverage.clone());
m
});
let __ws_arg_28 = self.extend(request.clone(), &[params.clone()]);
return self.v4_private_post_collateral_account_leverage(&[__ws_arg_28]).await;
Value::Null
}
/*
* @method
* @name whitebit#transfer
* @description transfer currency internally between wallets on the same account
* @see https://docs.whitebit.com/private/http-main-v4/#transfer-between-main-and-trade-balances
* @param {string} code unified currency code
* @param {float} amount amount to transfer
* @param {string} fromAccount account to transfer from - main, spot, collateral
* @param {string} toAccount account to transfer to - main, spot, collateral
* @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 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 accountsByType: Value = self.safe_value_k(self.options.clone(), "accountsByType", &[]);
let mut fromAccountId: Value = self.safe_string(accountsByType.clone(), fromAccount.clone(), &[fromAccount.clone()]);
let mut toAccountId: Value = self.safe_string(accountsByType.clone(), toAccount.clone(), &[toAccount.clone()]);
let mut amountString: Value = self.currency_to_precision(code.clone(), amount.clone(), &[]);
let mut request: Value = Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("ticker".to_string(), get_value(¤cy, &Value::Str("id".to_string())));
m.insert("amount".to_string(), amountString.clone());
m.insert("from".to_string(), fromAccountId.clone());
m.insert("to".to_string(), toAccountId.clone());
m
});
let __ws_arg_29 = self.extend(request.clone(), &[params.clone()]);
let mut response: Value = self.v4_private_post_main_account_transfer(&[__ws_arg_29]).await;
return self.parse_transfer(response.clone(), &[currency.clone()]);
Value::Null
}
pub fn parse_transfer(&self, mut transfer: Value, optional_args: &[Value]) -> Value {
let mut currency = get_arg(optional_args, 0, Value::Null);
return Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("info".to_string(), transfer.clone());
m.insert("id".to_string(), Value::Null);
m.insert("timestamp".to_string(), Value::Null);
m.insert("datetime".to_string(), Value::Null);
m.insert("currency".to_string(), self.safe_currency_code(Value::Null, &[currency.clone()]));
m.insert("amount".to_string(), Value::Null);
m.insert("fromAccount".to_string(), Value::Null);
m.insert("toAccount".to_string(), Value::Null);
m.insert("status".to_string(), Value::Null);
m
});
Value::Null
}
/*
* @method
* @name whitebit#withdraw
* @description make a withdrawal
* @see https://docs.whitebit.com/private/http-main-v4/#create-withdraw-request
* @param {string} code unified currency code
* @param {float} amount the amount to withdraw
* @param {string} address the address to withdraw to
* @param {string} tag
* @param {object} [params] extra parameters specific to the exchange API endpoint
* @returns {object} a [transaction structure]{@link https://docs.ccxt.com/?id=transaction-structure}
*/
pub async fn withdraw(&mut self, mut code: Value, mut amount: Value, mut address: Value, optional_args: &[Value]) -> Value {
let mut tag = get_arg(optional_args, 0, Value::Null);
let mut params = get_arg(optional_args, 1, Value::Map({
let mut m = indexmap::IndexMap::new();
m
}));
if is_equal(&self.markets, &Value::Null) {
self.load_markets(&[]).await;
}
let mut currency: Value = self.currency(code.clone()); // check if it has canDeposit
let mut request: Value = Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("ticker".to_string(), get_value(¤cy, &Value::Str("id".to_string())));
m.insert("amount".to_string(), self.currency_to_precision(code.clone(), amount.clone(), &[]));
m.insert("address".to_string(), address.clone());
m
});
let mut uniqueId: Value = self.safe_value_k(params.clone(), "uniqueId", &[]);
if is_equal(&uniqueId, &Value::Null) {
uniqueId = self.uuid22(&[]);
}
add_element_to_object(&mut request, &Value::Str("uniqueId".to_string()), uniqueId.clone());
if !is_equal(&tag, &Value::Null) {
add_element_to_object(&mut request, &Value::Str("memo".to_string()), tag.clone());
}
if is_true(&self.is_fiat(code.clone())) {
let mut provider: Value = self.safe_value_k(params.clone(), "provider", &[]);
if is_equal(&provider, &Value::Null) {
panic!("{}", crate::exchange_errors::arguments_required(add(&self.id, &Value::Str(" withdraw() requires a provider when the ticker is fiat".to_string()))));
}
add_element_to_object(&mut request, &Value::Str("provider".to_string()), provider.clone());
}
let __ws_arg_30 = self.extend(request.clone(), &[params.clone()]);
let mut response: Value = self.v4_private_post_main_account_withdraw(&[__ws_arg_30]).await;
let __ws_arg_31 = self.parse_transaction(response.clone(), &[currency.clone()]);
return self.extend(__ws_arg_31, &[Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("id".to_string(), uniqueId.clone());
m
})]);
Value::Null
}
pub fn parse_transaction(&self, mut transaction: Value, optional_args: &[Value]) -> Value {
let mut currency = get_arg(optional_args, 0, Value::Null);
//
// {
// "address": "3ApEASLcrQtZpg1TsssFgYF5V5YQJAKvuE", // deposit address
// "uniqueId": null, // unique Id of deposit
// "transactionId": "a6d71d69-2b17-4ad8-8b15-2d686c54a1a5",
// "createdAt": 1593437922, // timestamp of deposit
// "currency": "Bitcoin", // deposit currency
// "ticker": "BTC", // deposit currency ticker
// "method": 1, // called method 1 - deposit, 2 - withdraw
// "amount": "0.0006", // amount of deposit
// "description": "", // deposit description
// "memo": "", // deposit memo
// "fee": "0", // deposit fee
// "status": 15, // transactions status
// "network": null, // if currency is multinetwork
// "transactionHash": "a275a514013e4e0f927fd0d1bed215e7f6f2c4c6ce762836fe135ec22529d886", // deposit transaction hash
// "details": {
// "partial": { // details about partially successful withdrawals
// "requestAmount": "50000", // requested withdrawal amount
// "processedAmount": "39000", // processed withdrawal amount
// "processedFee": "273", // fee for processed withdrawal amount
// "normalizeTransaction": "" // deposit id
// }
// },
// "confirmations": { // if transaction status == 15 you can see this object
// "actual": 1, // current block confirmations
// "required": 2 // required block confirmation for successful deposit
// }
// "centralized": false,
// }
//
currency = self.safe_currency(Value::Null, &[currency.clone()]);
let mut address: Value = self.safe_string_k(transaction.clone(), "address", &[]);
let mut timestamp: Value = self.safe_timestamp(transaction.clone(), Value::Str("createdAt".to_string()), &[]);
let mut currencyId: Value = self.safe_string_k(transaction.clone(), "ticker", &[]);
let mut status: Value = self.safe_string_k(transaction.clone(), "status", &[]);
let mut method: Value = self.safe_string_k(transaction.clone(), "method", &[]);
return Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("id".to_string(), self.safe_string_k(transaction.clone(), "uniqueId", &[]));
m.insert("txid".to_string(), self.safe_string_k(transaction.clone(), "transactionId", &[]));
m.insert("timestamp".to_string(), timestamp.clone());
m.insert("datetime".to_string(), self.iso8601(timestamp.clone()));
m.insert("network".to_string(), self.safe_string_k(transaction.clone(), "network", &[]));
m.insert("addressFrom".to_string(), ternary(is_true(&(is_equal(&method, &Value::Str("1".to_string())))), address.clone(), Value::Null));
m.insert("address".to_string(), address.clone());
m.insert("addressTo".to_string(), ternary(is_true(&(is_equal(&method, &Value::Str("2".to_string())))), address.clone(), Value::Null));
m.insert("amount".to_string(), self.safe_number_k(transaction.clone(), "amount", &[]));
m.insert("type".to_string(), ternary(is_true(&(is_equal(&method, &Value::Str("1".to_string())))), Value::Str("deposit".to_string()), Value::Str("withdrawal".to_string())));
m.insert("currency".to_string(), self.safe_currency_code(currencyId.clone(), &[currency.clone()]));
m.insert("status".to_string(), self.parse_transaction_status(status.clone()));
m.insert("updated".to_string(), Value::Null);
m.insert("tagFrom".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("comment".to_string(), self.safe_string_k(transaction.clone(), "description", &[]));
m.insert("internal".to_string(), Value::Null);
m.insert("fee".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), self.safe_number_k(transaction.clone(), "fee", &[]));
m.insert("currency".to_string(), self.safe_currency_code(currencyId.clone(), &[currency.clone()]));
m
}));
m.insert("info".to_string(), transaction.clone());
m
});
Value::Null
}
pub fn parse_transaction_status(&self, mut status: Value) -> Value {
let mut statuses: Value = 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("ok".to_string()));
m.insert("4".to_string(), Value::Str("canceled".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("9".to_string(), Value::Str("canceled".to_string()));
m.insert("10".to_string(), Value::Str("pending".to_string()));
m.insert("11".to_string(), Value::Str("pending".to_string()));
m.insert("12".to_string(), Value::Str("pending".to_string()));
m.insert("13".to_string(), Value::Str("pending".to_string()));
m.insert("14".to_string(), Value::Str("pending".to_string()));
m.insert("15".to_string(), Value::Str("pending".to_string()));
m.insert("16".to_string(), Value::Str("pending".to_string()));
m.insert("17".to_string(), Value::Str("pending".to_string()));
m
});
return self.safe_string(statuses.clone(), status.clone(), &[status.clone()]);
Value::Null
}
/*
* @method
* @name whitebit#fetchDeposit
* @description fetch information on a deposit
* @see https://docs.whitebit.com/private/http-main-v4/#get-depositwithdraw-history
* @param {string} id deposit id
* @param {string} code not used by fetchDeposit ()
* @param {object} [params] extra parameters specific to the exchange API endpoint
* @returns {object} a [transaction structure]{@link https://docs.ccxt.com/?id=transaction-structure}
*/
pub async fn fetch_deposit(&mut self, mut id: Value, optional_args: &[Value]) -> Value {
let mut code = get_arg(optional_args, 0, Value::Null);
let mut params = get_arg(optional_args, 1, Value::Map({
let mut m = indexmap::IndexMap::new();
m
}));
if is_equal(&self.markets, &Value::Null) {
self.load_markets(&[]).await;
}
let mut currency: Value = Value::Null;
let mut request: Value = Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("transactionMethod".to_string(), Value::Int(1));
m.insert("uniqueId".to_string(), id.clone());
m.insert("limit".to_string(), Value::Int(1));
m.insert("offset".to_string(), Value::Int(0));
m
});
if !is_equal(&code, &Value::Null) {
currency = self.currency(code.clone());
add_element_to_object(&mut request, &Value::Str("ticker".to_string()), get_value(¤cy, &Value::Str("id".to_string())));
}
let __ws_arg_32 = self.extend(request.clone(), &[params.clone()]);
let mut response: Value = self.v4_private_post_main_account_history(&[__ws_arg_32]).await;
//
// {
// "limit": 100,
// "offset": 0,
// "records": [
// {
// "address": "3ApEASLcrQtZpg1TsssFgYF5V5YQJAKvuE", // deposit address
// "uniqueId": null, // unique Id of deposit
// "createdAt": 1593437922, // timestamp of deposit
// "currency": "Bitcoin", // deposit currency
// "ticker": "BTC", // deposit currency ticker
// "method": 1, // called method 1 - deposit, 2 - withdraw
// "amount": "0.0006", // amount of deposit
// "description": "", // deposit description
// "memo": "", // deposit memo
// "fee": "0", // deposit fee
// "status": 15, // transactions status
// "network": null, // if currency is multinetwork
// "transactionHash": "a275a514013e4e0f927fd0d1bed215e7f6f2c4c6ce762836fe135ec22529d886", // deposit transaction hash
// "details": {
// "partial": { // details about partially successful withdrawals
// "requestAmount": "50000", // requested withdrawal amount
// "processedAmount": "39000", // processed withdrawal amount
// "processedFee": "273", // fee for processed withdrawal amount
// "normalizeTransaction": "" // deposit id
// }
// },
// "confirmations": { // if transaction status == 15 you can see this object
// "actual": 1, // current block confirmations
// "required": 2 // required block confirmation for successful deposit
// }
// },
// {...},
// ],
// "total": 300 // total number of transactions, use this for calculating ‘limit’ and ‘offset'
// }
//
let mut records: Value = self.safe_value_k(response.clone(), "records", &[Value::List(vec![])]);
let mut first: Value = self.safe_dict(records.clone(), Value::Int(0), &[Value::Map({
let mut m = indexmap::IndexMap::new();
m
})]);
return self.parse_transaction(first.clone(), &[currency.clone()]);
Value::Null
}
/*
* @method
* @name whitebit#fetchDeposits
* @description fetch all deposits made to an account
* @see https://docs.whitebit.com/private/http-main-v4/#get-depositwithdraw-history
* @param {string} code unified currency code
* @param {int} [since] the earliest time in ms to fetch deposits for
* @param {int} [limit] the maximum number of deposits structures to retrieve
* @param {object} [params] extra parameters specific to the exchange API endpoint
* @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 currency: Value = Value::Null;
let mut request: Value = Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("transactionMethod".to_string(), Value::Int(1));
m.insert("limit".to_string(), Value::Int(100));
m.insert("offset".to_string(), Value::Int(0));
m
});
if !is_equal(&code, &Value::Null) {
currency = self.currency(code.clone());
add_element_to_object(&mut request, &Value::Str("ticker".to_string()), get_value(¤cy, &Value::Str("id".to_string())));
}
if !is_equal(&limit, &Value::Null) {
add_element_to_object(&mut request, &Value::Str("limit".to_string()), crate::runtime::Math::min(&limit, &Value::Int(100)));
}
let __ws_arg_33 = self.extend(request.clone(), &[params.clone()]);
let mut response: Value = self.v4_private_post_main_account_history(&[__ws_arg_33]).await;
//
// {
// "limit": 100,
// "offset": 0,
// "records": [
// {
// "address": "3ApEASLcrQtZpg1TsssFgYF5V5YQJAKvuE", // deposit address
// "uniqueId": null, // unique Id of deposit
// "createdAt": 1593437922, // timestamp of deposit
// "currency": "Bitcoin", // deposit currency
// "ticker": "BTC", // deposit currency ticker
// "method": 1, // called method 1 - deposit, 2 - withdraw
// "amount": "0.0006", // amount of deposit
// "description": "", // deposit description
// "memo": "", // deposit memo
// "fee": "0", // deposit fee
// "status": 15, // transactions status
// "network": null, // if currency is multinetwork
// "transactionHash": "a275a514013e4e0f927fd0d1bed215e7f6f2c4c6ce762836fe135ec22529d886", // deposit transaction hash
// "details": {
// "partial": { // details about partially successful withdrawals
// "requestAmount": "50000", // requested withdrawal amount
// "processedAmount": "39000", // processed withdrawal amount
// "processedFee": "273", // fee for processed withdrawal amount
// "normalizeTransaction": "" // deposit id
// }
// },
// "confirmations": { // if transaction status == 15 you can see this object
// "actual": 1, // current block confirmations
// "required": 2 // required block confirmation for successful deposit
// }
// },
// {...},
// ],
// "total": 300 // total number of transactions, use this for calculating ‘limit’ and ‘offset'
// }
//
let mut records: Value = self.safe_list_k(response.clone(), "records", &[Value::List(vec![])]);
let mut recordsList: Value = Value::List(vec![]);
if !is_equal(&records, &Value::Null) {
recordsList = records.clone();
}
return self.parse_transactions(recordsList.clone(), &[currency.clone(), since.clone(), limit.clone()]);
Value::Null
}
/*
* @method
* @name whitebit#fetchBorrowInterest
* @description fetch the interest owed by the user for borrowing currency for margin trading
* @see https://docs.whitebit.com/private/http-trade-v4/#open-positions
* @param {string} code unified currency code
* @param {string} symbol unified market symbol
* @param {int} [since] the earliest time in ms to fetch borrrow interest for
* @param {int} [limit] the maximum number of structures to retrieve
* @param {object} [params] extra parameters specific to the exchange API endpoint
* @returns {object[]} a list of [borrow interest structures]{@link https://docs.ccxt.com/?id=borrow-interest-structure}
*/
pub async fn fetch_borrow_interest(&mut self, optional_args: &[Value]) -> Value {
let mut code = get_arg(optional_args, 0, Value::Null);
let mut symbol = get_arg(optional_args, 1, Value::Null);
let mut since = get_arg(optional_args, 2, Value::Null);
let mut limit = get_arg(optional_args, 3, Value::Null);
let mut params = get_arg(optional_args, 4, Value::Map({
let mut m = indexmap::IndexMap::new();
m
}));
if is_equal(&self.markets, &Value::Null) {
self.load_markets(&[]).await;
}
let mut 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("market".to_string()), get_value(&market, &Value::Str("id".to_string())));
}
let __ws_arg_34 = self.extend(request.clone(), &[params.clone()]);
let mut response: Value = self.v4_private_post_collateral_account_positions_open(&[__ws_arg_34]).await;
//
// [
// {
// "positionId": 191823,
// "market": "BTC_USDT",
// "openDate": 1660340344.027163,
// "modifyDate": 1660340344.027163,
// "amount": "0.003075",
// "basePrice": "24149.24512",
// "liquidationPrice": "7059.02",
// "leverage": "5",
// "pnl": "-0.15",
// "pnlPercent": "-0.20",
// "margin": "14.86",
// "freeMargin": "44.99",
// "funding": "0",
// "unrealizedFunding": "0.0000307828284903",
// "liquidationState": null
// }
// ]
//
let mut interest: Value = self.parse_borrow_interests(response.clone(), &[market.clone()]);
return self.filter_by_currency_since_limit(interest.clone(), &[code.clone(), since.clone(), limit.clone()]);
Value::Null
}
pub fn parse_borrow_interest(&self, mut info: Value, optional_args: &[Value]) -> Value {
let mut market = get_arg(optional_args, 0, Value::Null);
//
// {
// "positionId": 191823,
// "market": "BTC_USDT",
// "openDate": 1660340344.027163,
// "modifyDate": 1660340344.027163,
// "amount": "0.003075",
// "basePrice": "24149.24512",
// "liquidationPrice": "7059.02",
// "leverage": "5",
// "pnl": "-0.15",
// "pnlPercent": "-0.20",
// "margin": "14.86",
// "freeMargin": "44.99",
// "funding": "0",
// "unrealizedFunding": "0.0000307828284903",
// "liquidationState": null
// }
//
let mut marketId: Value = self.safe_string_k(info.clone(), "market", &[]);
let mut symbol: Value = self.safe_symbol(marketId.clone(), &[market.clone(), Value::Str("_".to_string())]);
let mut timestamp: Value = self.safe_timestamp(info.clone(), Value::Str("modifyDate".to_string()), &[]);
return Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("info".to_string(), info.clone());
m.insert("symbol".to_string(), symbol.clone());
m.insert("currency".to_string(), Value::Str("USDT".to_string()));
m.insert("interest".to_string(), self.safe_number_k(info.clone(), "unrealizedFunding", &[]));
m.insert("interestRate".to_string(), Value::Float(0.00098));
m.insert("amountBorrowed".to_string(), self.safe_number_k(info.clone(), "amount", &[]));
m.insert("marginMode".to_string(), Value::Str("cross".to_string()));
m.insert("timestamp".to_string(), timestamp.clone());
m.insert("datetime".to_string(), self.iso8601(timestamp.clone()));
m
});
Value::Null
}
/*
* @method
* @name whitebit#fetchFundingRate
* @description fetch the current funding rate
* @see https://docs.whitebit.com/public/http-v4/#available-futures-markets-list
* @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;
}
symbol = self.symbol(symbol.clone());
let mut response: Value = self.fetch_funding_rates(&[Value::List(vec![symbol.clone()]), params.clone()]).await;
return self.safe_value(response.clone(), symbol.clone(), &[]);
Value::Null
}
/*
* @method
* @name whitebit#fetchFundingRates
* @description fetch the funding rate for multiple markets
* @see https://docs.whitebit.com/public/http-v4/#available-futures-markets-list
* @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 [funding rate structures]{@link https://docs.ccxt.com/?id=funding-rates-structure}, indexed by market symbols
*/
pub async fn fetch_funding_rates(&mut self, optional_args: &[Value]) -> Value {
let mut symbols = get_arg(optional_args, 0, Value::Null);
let mut params = get_arg(optional_args, 1, Value::Map({
let mut m = indexmap::IndexMap::new();
m
}));
if is_equal(&self.markets, &Value::Null) {
self.load_markets(&[]).await;
}
symbols = self.market_symbols(&[symbols.clone()]);
let mut response: Value = self.v4_public_get_futures(&[params.clone()]).await;
//
// [
// {
// "name": "BTC_USDT",
// "type": "direct",
// "quanto_multiplier": "0.0001",
// "ref_discount_rate": "0",
// "order_price_deviate": "0.5",
// "maintenance_rate": "0.005",
// "mark_type": "index",
// "last_price": "38026",
// "mark_price": "37985.6",
// "index_price": "37954.92",
// "funding_rate_indicative": "0.000219",
// "mark_price_round": "0.01",
// "funding_offset": 0,
// "in_delisting": false,
// "risk_limit_base": "1000000",
// "interest_rate": "0.0003",
// "order_price_round": "0.1",
// "order_size_min": 1,
// "ref_rebate_rate": "0.2",
// "funding_interval": 28800,
// "risk_limit_step": "1000000",
// "leverage_min": "1",
// "leverage_max": "100",
// "risk_limit_max": "8000000",
// "maker_fee_rate": "-0.00025",
// "taker_fee_rate": "0.00075",
// "funding_rate": "0.002053",
// "order_size_max": 1000000,
// "funding_next_apply": 1610035200,
// "short_users": 977,
// "config_change_time": 1609899548,
// "trade_size": 28530850594,
// "position_size": 5223816,
// "long_users": 455,
// "funding_impact_value": "60000",
// "orders_limit": 50,
// "trade_id": 10851092,
// "orderbook_id": 2129638396
// }
// ]
//
let mut data: Value = self.safe_list_k(response.clone(), "result", &[Value::List(vec![])]);
return self.parse_funding_rates(data.clone(), &[symbols.clone()]);
Value::Null
}
pub fn parse_funding_rate(&self, mut contract: Value, optional_args: &[Value]) -> Value {
let mut market = get_arg(optional_args, 0, Value::Null);
//
// {
// "ticker_id":"ADA_PERP",
// "stock_currency":"ADA",
// "money_currency":"USDT",
// "last_price":"0.296708",
// "stock_volume":"7982130",
// "money_volume":"2345758.29189",
// "bid":"0.296608",
// "ask":"0.296758",
// "high":"0.298338",
// "low":"0.290171",
// "product_type":"Perpetual",
// "open_interest":"46533000",
// "index_price":"0.29659",
// "index_name":"Cardano",
// "index_currency":"ADA",
// "funding_rate":"0.0001",
// "next_funding_rate_timestamp":"1691193600000",
// "brackets":{
// "1":"0",
// "2":"0",
// "3":"0",
// "5":"0",
// "10":"0",
// "20":"0",
// "50":"-10000",
// "100":"-5000"
// },
// "max_leverage":"100"
// }
//
let mut marketId: Value = self.safe_string_k(contract.clone(), "ticker_id", &[]);
let mut symbol: Value = self.safe_symbol(marketId.clone(), &[market.clone()]);
let mut markPrice: Value = self.safe_number_k(contract.clone(), "markPrice", &[]);
let mut indexPrice: Value = self.safe_number_k(contract.clone(), "indexPrice", &[]);
let mut interestRate: Value = self.safe_number_k(contract.clone(), "interestRate", &[]);
let mut fundingRate: Value = self.safe_number_k(contract.clone(), "funding_rate", &[]);
let mut fundingTime: Value = self.safe_integer_k(contract.clone(), "next_funding_rate_timestamp", &[]);
return Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("info".to_string(), contract.clone());
m.insert("symbol".to_string(), symbol.clone());
m.insert("markPrice".to_string(), markPrice.clone());
m.insert("indexPrice".to_string(), indexPrice.clone());
m.insert("interestRate".to_string(), interestRate.clone());
m.insert("timestamp".to_string(), Value::Null);
m.insert("datetime".to_string(), Value::Null);
m.insert("fundingRate".to_string(), fundingRate.clone());
m.insert("fundingTimestamp".to_string(), fundingTime.clone());
m.insert("fundingDatetime".to_string(), self.iso8601(fundingTime.clone()));
m.insert("nextFundingRate".to_string(), Value::Null);
m.insert("nextFundingTimestamp".to_string(), Value::Null);
m.insert("nextFundingDatetime".to_string(), Value::Null);
m.insert("previousFundingRate".to_string(), Value::Null);
m.insert("previousFundingTimestamp".to_string(), Value::Null);
m.insert("previousFundingDatetime".to_string(), Value::Null);
m.insert("interval".to_string(), Value::Null);
m
});
Value::Null
}
/*
* @method
* @name whitebit#fetchFundingHistory
* @description fetch the history of funding payments paid and received on this account
* @see https://docs.whitebit.com/private/http-trade-v4/#funding-history
* @param {string} [symbol] unified market symbol
* @param {int} [since] the starting timestamp in milliseconds
* @param {int} [limit] the number of entries to return
* @param {object} [params] extra parameters specific to the exchange API endpoint
* @param {int} [params.until] the latest time in ms to fetch funding history for
* @returns {object[]} a list of [funding history structures]{@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;
}
if is_equal(&symbol, &Value::Null) {
panic!("{}", crate::exchange_errors::arguments_required(add(&self.id, &Value::Str(" fetchFundingHistory() requires a symbol argument".to_string()))));
}
let mut market: Value = self.market(symbol.clone());
let mut request: Value = Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("market".to_string(), get_value(&market, &Value::Str("id".to_string())));
m
});
if !is_equal(&since, &Value::Null) {
add_element_to_object(&mut request, &Value::Str("startDate".to_string()), since.clone());
}
if !is_equal(&limit, &Value::Null) {
add_element_to_object(&mut request, &Value::Str("limit".to_string()), limit.clone());
}
{ let __destr_tmp = self.handle_until_option(Value::Str("endDate".to_string()), request.clone(), params.clone(), &[]); request = get_value(&__destr_tmp, &Value::Int(0)); params = get_value(&__destr_tmp, &Value::Int(1)); }
let __ws_arg_35 = self.extend(request.clone(), &[params.clone()]);
let mut response: Value = self.v4_private_post_collateral_account_funding_history(&[__ws_arg_35]).await;
//
// {
// "records": [
// {
// "market": "BTC_PERP",
// "fundingTime": "1708704000000",
// "fundingRate": "0.00017674",
// "fundingAmount": "-0.171053531892",
// "positionAmount": "0.019",
// "settlementPrice": "50938.2",
// "rateCalculatedTime": "1708675200000"
// },
// ],
// "limit": 100,
// "offset": 0
// }
//
let mut data: Value = self.safe_list_k(response.clone(), "records", &[Value::List(vec![])]);
return self.parse_funding_histories(data.clone(), &[market.clone(), since.clone(), limit.clone()]);
Value::Null
}
pub fn parse_funding_history(&self, mut contract: Value, optional_args: &[Value]) -> Value {
let mut market = get_arg(optional_args, 0, Value::Null);
//
// {
// "market": "BTC_PERP",
// "fundingTime": "1708704000000",
// "fundingRate": "0.00017674",
// "fundingAmount": "-0.171053531892",
// "positionAmount": "0.019",
// "settlementPrice": "50938.2",
// "rateCalculatedTime": "1708675200000"
// }
//
let mut marketId: Value = self.safe_string_k(contract.clone(), "market", &[]);
let mut timestamp: Value = self.safe_integer_k(contract.clone(), "fundingTime", &[]);
return Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("info".to_string(), contract.clone());
m.insert("symbol".to_string(), self.safe_symbol(marketId.clone(), &[market.clone(), Value::Null, Value::Str("swap".to_string())]));
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(), Value::Null);
m.insert("amount".to_string(), self.safe_number_k(contract.clone(), "fundingAmount", &[]));
m
});
Value::Null
}
pub fn parse_funding_histories(&self, mut contracts: Value, optional_args: &[Value]) -> Value {
let mut market = 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 result: Value = Value::List(vec![]);
{
let mut i: Value = Value::Int(0);
let mut __for_first_1116: bool = true;
while { if !__for_first_1116 { i = add(&i, &Value::Int(1)); } __for_first_1116 = false; is_less_than(&i, &get_array_length(&contracts)) } {
let mut contract: Value = get_value(&contracts, &i);
let mut contract: Value = get_value(&contracts, &i);
append_to_array(&mut result, self.parse_funding_history(contract.clone(), &[market.clone()]));
}
}
let mut sorted: Value = self.sort_by(result.clone(), Value::Str("timestamp".to_string()), &[]);
return self.filter_by_since_limit(sorted.clone(), &[since.clone(), limit.clone()]);
Value::Null
}
/*
* @method
* @name whitebit#fetchDepositsWithdrawals
* @description fetch history of deposits and withdrawals
* @see https://github.com/whitebit-exchange/api-docs/blob/main/pages/private/http-main-v4.md#get-depositwithdraw-history
* @param {string} [code] unified currency code for the currency of the deposit/withdrawals, default is undefined
* @param {int} [since] timestamp in ms of the earliest deposit/withdrawal, default is undefined
* @param {int} [limit] max number of deposit/withdrawals to return, default = 50, Min: 1, Max: 100
* @param {object} [params] extra parameters specific to the exchange API endpoint
*
* EXCHANGE SPECIFIC PARAMETERS
* @param {number} [params.transactionMethod] Method. Example: 1 to display deposits / 2 to display withdraws. Do not send this parameter in order to receive both deposits and withdraws.
* @param {string} [params.address] Can be used for filtering transactions by specific address or memo.
* @param {string[]} [params.addresses] Can be used for filtering transactions by specific addresses or memos (max: 20).
* @param {string} [params.uniqueId] Can be used for filtering transactions by specific unique id
* @param {int} [params.offset] If you want the request to return entries starting from a particular line, you can use OFFSET clause to tell it where it should start. Default: 0, Min: 0, Max: 10000
* @param {string[]} [params.status] Can be used for filtering transactions by status codes. Caution: You must use this parameter with appropriate transactionMethod and use valid status codes for this method. You can find them below. Example: "status": [3,7]
* @returns {object} a list of [transaction structure]{@link https://docs.ccxt.com/?id=transaction-structure}
*/
pub async fn fetch_deposits_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("ticker".to_string()), get_value(¤cy, &Value::Str("id".to_string())));
}
if !is_equal(&limit, &Value::Null) {
add_element_to_object(&mut request, &Value::Str("limit".to_string()), limit.clone()); // default 1000
}
let __ws_arg_36 = self.extend(request.clone(), &[params.clone()]);
let mut response: Value = self.v4_private_post_main_account_history(&[__ws_arg_36]).await;
//
// {
// "limit": 100,
// "offset": 0,
// "records": [
// {
// "address": "3ApEASLcrQtZpg1TsssFgYF5V5YQJAKvuE", // deposit address
// "uniqueId": null, // unique Id of deposit
// "createdAt": 1593437922, // timestamp of deposit
// "currency": "Bitcoin", // deposit currency
// "ticker": "BTC", // deposit currency ticker
// "method": 1, // called method 1 - deposit, 2 - withdraw
// "amount": "0.0006", // amount of deposit
// "description": "", // deposit description
// "memo": "", // deposit memo
// "fee": "0", // deposit fee
// "status": 15, // transactions status
// "network": null, // if currency is multinetwork
// "transactionHash": "a275a514013e4e0f927fd0d1bed215e7f6f2c4c6ce762836fe135ec22529d886", // deposit transaction hash
// "transactionId": "5e112b38-9652-11ed-a1eb-0242ac120002", // transaction id
// "details": {
// "partial": { // details about partially successful withdrawals
// "requestAmount": "50000", // requested withdrawal amount
// "processedAmount": "39000", // processed withdrawal amount
// "processedFee": "273", // fee for processed withdrawal amount
// "normalizeTransaction": "" // deposit id
// }
// },
// "confirmations": { // if transaction status == 15 (Pending) you can see this object
// "actual": 1, // current block confirmations
// "required": 2 // required block confirmation for successful deposit
// }
// },
// {...},
// ],
// "total": 300 // total number of transactions, use this for calculating ‘limit’ and ‘offset'
// }
//
let mut records: Value = self.safe_list_k(response.clone(), "records", &[]);
let mut recordsList: Value = Value::List(vec![]);
if !is_equal(&records, &Value::Null) {
recordsList = records.clone();
}
return self.parse_transactions(recordsList.clone(), &[currency.clone(), since.clone(), limit.clone()]);
Value::Null
}
/*
* @method
* @name whitebit#fetchConvertQuote
* @description fetch a quote for converting from one currency to another
* @see https://docs.whitebit.com/private/http-trade-v4/#convert-estimate
* @param {string} fromCode the currency that you want to sell and convert from
* @param {string} toCode the currency that you want to buy and convert into
* @param {float} amount how much you want to trade in units of the from currency
* @param {object} [params] extra parameters specific to the exchange API endpoint
* @returns {object} a [conversion structure]{@link https://docs.ccxt.com/?id=conversion-structure}
*/
pub async fn fetch_convert_quote(&mut self, mut fromCode: Value, mut toCode: Value, optional_args: &[Value]) -> Value {
let mut amount = get_arg(optional_args, 0, Value::Null);
let mut params = get_arg(optional_args, 1, Value::Map({
let mut m = indexmap::IndexMap::new();
m
}));
if is_equal(&self.markets, &Value::Null) {
self.load_markets(&[]).await;
}
let mut fromCurrency: Value = self.currency(fromCode.clone());
let mut toCurrency: Value = self.currency(toCode.clone());
let mut request: Value = Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("from".to_string(), fromCode.clone());
m.insert("to".to_string(), toCode.clone());
m.insert("amount".to_string(), self.number_to_string(amount.clone()));
m.insert("direction".to_string(), Value::Str("from".to_string()));
m
});
let __ws_arg_37 = self.extend(request.clone(), &[params.clone()]);
let mut response: Value = self.v4_private_post_convert_estimate(&[__ws_arg_37]).await;
return self.parse_conversion(response.clone(), &[fromCurrency.clone(), toCurrency.clone()]);
Value::Null
}
/*
* @method
* @name whitebit#createConvertTrade
* @description convert from one currency to another
* @see https://docs.whitebit.com/private/http-trade-v4/#convert-confirm
* @param {string} id the id of the trade that you want to make
* @param {string} fromCode the currency that you want to sell and convert from
* @param {string} toCode the currency that you want to buy and convert into
* @param {float} [amount] how much you want to trade in units of the from currency
* @param {object} [params] extra parameters specific to the exchange API endpoint
* @returns {object} a [conversion structure]{@link https://docs.ccxt.com/?id=conversion-structure}
*/
pub async fn create_convert_trade(&mut self, mut id: Value, mut fromCode: Value, mut toCode: Value, optional_args: &[Value]) -> Value {
let mut amount = get_arg(optional_args, 0, Value::Null);
let mut params = get_arg(optional_args, 1, Value::Map({
let mut m = indexmap::IndexMap::new();
m
}));
if is_equal(&self.markets, &Value::Null) {
self.load_markets(&[]).await;
}
let mut fromCurrency: Value = self.currency(fromCode.clone());
let mut toCurrency: Value = self.currency(toCode.clone());
let mut request: Value = Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("quoteId".to_string(), id.clone());
m
});
let __ws_arg_38 = self.extend(request.clone(), &[params.clone()]);
let mut response: Value = self.v4_private_post_convert_confirm(&[__ws_arg_38]).await;
return self.parse_conversion(response.clone(), &[fromCurrency.clone(), toCurrency.clone()]);
Value::Null
}
/*
* @method
* @name whitebit#fetchConvertTradeHistory
* @description fetch the users history of conversion trades
* @see https://docs.whitebit.com/private/http-trade-v4/#convert-history
* @param {string} [code] the unified currency code
* @param {int} [since] the earliest time in ms to fetch conversions for
* @param {int} [limit] the maximum number of conversion structures to retrieve, default 20, max 200
* @param {object} [params] extra parameters specific to the exchange API endpoint
* @param {string} [params.until] the end time in ms
* @param {string} [params.fromTicker] the currency that you sold and converted from
* @param {string} [params.toTicker] the currency that you bought and converted into
* @param {string} [params.quoteId] the quote id of the conversion
* @returns {object[]} a list of [conversion structures]{@link https://docs.ccxt.com/?id=conversion-structure}
*/
pub async fn fetch_convert_trade_history(&mut self, optional_args: &[Value]) -> Value {
let mut code = get_arg(optional_args, 0, Value::Null);
let mut since = get_arg(optional_args, 1, Value::Null);
let mut limit = get_arg(optional_args, 2, Value::Null);
let mut params = get_arg(optional_args, 3, Value::Map({
let mut m = indexmap::IndexMap::new();
m
}));
if is_equal(&self.markets, &Value::Null) {
self.load_markets(&[]).await;
}
let mut request: Value = Value::Map({
let mut m = indexmap::IndexMap::new();
m
});
if !is_equal(&code, &Value::Null) {
add_element_to_object(&mut request, &Value::Str("fromTicker".to_string()), code.clone());
}
if !is_equal(&since, &Value::Null) {
let mut start: Value = self.parse_to_int(divide(&since, &Value::Int(1000)));
add_element_to_object(&mut request, &Value::Str("from".to_string()), self.number_to_string(start.clone()));
}
if !is_equal(&limit, &Value::Null) {
add_element_to_object(&mut request, &Value::Str("limit".to_string()), limit.clone());
}
{ let __destr_tmp = self.handle_until_option(Value::Str("to".to_string()), request.clone(), params.clone(), &[Value::Float(0.001)]); request = get_value(&__destr_tmp, &Value::Int(0)); params = get_value(&__destr_tmp, &Value::Int(1)); }
let __ws_arg_39 = self.extend(request.clone(), &[params.clone()]);
let mut response: Value = self.v4_private_post_convert_history(&[__ws_arg_39]).await;
//
// {
// "records": [
// {
// "id": "1741105",
// "path": [
// {
// "from": "USDT",
// "to": "BTC",
// "rate": "0.00001193"
// }
// ],
// "date": 1741090757,
// "give": "4",
// "receive": "0.00004772",
// "rate": "0.00001193"
// }
// ],
// "total": 1,
// "limit": 100,
// "offset": 0
// }
//
let mut rows: Value = self.safe_list_k(response.clone(), "records", &[Value::List(vec![])]);
return self.parse_conversions(rows.clone(), &[code.clone(), Value::Str("fromCurrency".to_string()), Value::Str("toCurrency".to_string()), since.clone(), limit.clone()]);
Value::Null
}
pub fn parse_conversion(&self, mut conversion: Value, optional_args: &[Value]) -> Value {
let mut fromCurrency = get_arg(optional_args, 0, Value::Null);
let mut toCurrency = get_arg(optional_args, 1, Value::Null);
//
// fetchConvertQuote
//
// {
// "give": "4",
// "receive": "0.00004762",
// "rate": "0.0000119",
// "id": "1740889",
// "expireAt": 1741090147,
// "from": "USDT",
// "to": "BTC"
// }
//
// createConvertTrade
//
// {
// "finalGive": "4",
// "finalReceive": "0.00004772"
// }
//
// fetchConvertTradeHistory
//
// {
// "id": "1741105",
// "path": [
// {
// "from": "USDT",
// "to": "BTC",
// "rate": "0.00001193"
// }
// ],
// "date": 1741090757,
// "give": "4",
// "receive": "0.00004772",
// "rate": "0.00001193"
// }
//
let mut path: Value = self.safe_list_k(conversion.clone(), "path", &[Value::List(vec![])]);
let mut first: Value = self.safe_dict(path.clone(), Value::Int(0), &[Value::Map({
let mut m = indexmap::IndexMap::new();
m
})]);
let mut fromPath: Value = self.safe_string_k(first.clone(), "from", &[]);
let mut toPath: Value = self.safe_string_k(first.clone(), "to", &[]);
let mut timestamp: Value = self.safe_timestamp2(conversion.clone(), Value::Str("date".to_string()), Value::Str("expireAt".to_string()), &[]);
let mut fromCoin: Value = self.safe_string_k(conversion.clone(), "from", &[fromPath.clone()]);
let mut fromCode: Value = self.safe_currency_code(fromCoin.clone(), &[fromCurrency.clone()]);
let mut toCoin: Value = self.safe_string_k(conversion.clone(), "to", &[toPath.clone()]);
let mut toCode: Value = self.safe_currency_code(toCoin.clone(), &[toCurrency.clone()]);
return Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("info".to_string(), conversion.clone());
m.insert("timestamp".to_string(), timestamp.clone());
m.insert("datetime".to_string(), self.iso8601(timestamp.clone()));
m.insert("id".to_string(), self.safe_string_k(conversion.clone(), "id", &[]));
m.insert("fromCurrency".to_string(), fromCode.clone());
m.insert("fromAmount".to_string(), self.safe_number2(conversion.clone(), Value::Str("give".to_string()), Value::Str("finalGive".to_string()), &[]));
m.insert("toCurrency".to_string(), toCode.clone());
m.insert("toAmount".to_string(), self.safe_number2(conversion.clone(), Value::Str("receive".to_string()), Value::Str("finalReceive".to_string()), &[]));
m.insert("price".to_string(), self.safe_number_k(conversion.clone(), "rate", &[]));
m.insert("fee".to_string(), Value::Null);
m
});
Value::Null
}
/*
* @method
* @name whitebit#fetchPositionHistory
* @description fetches historical positions
* @see https://docs.whitebit.com/private/http-trade-v4/#positions-history
* @param {string} symbol unified contract symbol
* @param {int} [since] the earliest time in ms to fetch positions for
* @param {int} [limit] the maximum amount of records to fetch
* @param {object} [params] extra parameters specific to the exchange API endpoint
* @param {int} [params.positionId] the id of the requested position
* @returns {object[]} a list of [position structures]{@link https://docs.ccxt.com/?id=position-structure}
*/
pub async fn fetch_position_history(&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("market".to_string(), get_value(&market, &Value::Str("id".to_string())));
m
});
if !is_equal(&since, &Value::Null) {
add_element_to_object(&mut request, &Value::Str("startDate".to_string()), since.clone());
}
if !is_equal(&limit, &Value::Null) {
add_element_to_object(&mut request, &Value::Str("limit".to_string()), since.clone());
}
{ let __destr_tmp = self.handle_until_option(Value::Str("endDate".to_string()), request.clone(), params.clone(), &[]); request = get_value(&__destr_tmp, &Value::Int(0)); params = get_value(&__destr_tmp, &Value::Int(1)); }
let __ws_arg_40 = self.extend(request.clone(), &[params.clone()]);
let mut response: Value = self.v4_private_post_collateral_account_positions_history(&[__ws_arg_40]).await;
//
// [
// {
// "positionId": 479975679,
// "market": "BTC_PERP",
// "openDate": 1741941025.309887,
// "modifyDate": 1741941025.309887,
// "amount": "0.001",
// "basePrice": "82498.7",
// "realizedFunding": "0",
// "liquidationPrice": "0",
// "liquidationState": null,
// "orderDetail": {
// "id": 1224727949521,
// "tradeAmount": "0.001",
// "price": "82498.7",
// "tradeFee": "0.028874545",
// "fundingFee": "0",
// "realizedPnl": "-0.028874545"
// }
// }
// ]
//
let mut positions: Value = self.parse_positions(response.clone(), &[]);
return self.filter_by_symbol_since_limit(positions.clone(), &[symbol.clone(), since.clone(), limit.clone()]);
Value::Null
}
/*
* @method
* @name whitebit#fetchPositions
* @description fetch all open positions
* @see https://docs.whitebit.com/private/http-trade-v4/#open-positions
* @param {string[]} [symbols] list of unified market symbols
* @param {object} [params] extra parameters specific to the exchange API endpoint
* @returns {object[]} a list of [position structures]{@link https://docs.ccxt.com/?id=position-structure}
*/
pub async fn fetch_positions(&mut self, optional_args: &[Value]) -> Value {
let mut symbols = get_arg(optional_args, 0, Value::Null);
let mut params = get_arg(optional_args, 1, Value::Map({
let mut m = indexmap::IndexMap::new();
m
}));
if is_equal(&self.markets, &Value::Null) {
self.load_markets(&[]).await;
}
symbols = self.market_symbols(&[symbols.clone()]);
let mut response: Value = self.v4_private_post_collateral_account_positions_open(&[params.clone()]).await;
return self.parse_positions(response.clone(), &[symbols.clone()]);
Value::Null
}
/*
* @method
* @name whitebit#fetchPosition
* @description fetch data on a single open contract trade position
* @see https://docs.whitebit.com/private/http-trade-v4/#open-positions
* @param {string} symbol unified market symbol of the market the position is held in
* @param {object} [params] extra parameters specific to the exchange API endpoint
* @returns {object} a [position structure]{@link https://docs.ccxt.com/?id=position-structure}
*/
pub async fn fetch_position(&mut self, mut symbol: Value, optional_args: &[Value]) -> Value {
let mut params = get_arg(optional_args, 0, Value::Map({
let mut m = indexmap::IndexMap::new();
m
}));
if is_equal(&self.markets, &Value::Null) {
self.load_markets(&[]).await;
}
let mut market: Value = self.market(symbol.clone());
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_41 = self.extend(request.clone(), &[params.clone()]);
let mut response: Value = self.v4_private_post_collateral_account_positions_open(&[__ws_arg_41]).await;
//
// [
// {
// "positionId": 479975679,
// "market": "BTC_PERP",
// "openDate": 1741941025.3098869,
// "modifyDate": 1741941025.3098869,
// "amount": "0.001",
// "basePrice": "82498.7",
// "liquidationPrice": "70177.2",
// "pnl": "0",
// "pnlPercent": "0.00",
// "margin": "4.2",
// "freeMargin": "9.9",
// "funding": "0",
// "unrealizedFunding": "0",
// "liquidationState": null,
// "tpsl": null
// }
// ]
//
let mut data: Value = self.safe_dict(response.clone(), Value::Int(0), &[Value::Map({
let mut m = indexmap::IndexMap::new();
m
})]);
return self.parse_position(data.clone(), &[market.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);
//
// fetchPosition, fetchPositions
//
// {
// "positionId": 479975679,
// "market": "BTC_PERP",
// "openDate": 1741941025.3098869,
// "modifyDate": 1741941025.3098869,
// "amount": "0.001",
// "basePrice": "82498.7",
// "liquidationPrice": "70177.2",
// "pnl": "0",
// "pnlPercent": "0.00",
// "margin": "4.2",
// "freeMargin": "9.9",
// "funding": "0",
// "unrealizedFunding": "0",
// "liquidationState": null,
// "tpsl": null
// }
//
// fetchPositionHistory
//
// {
// "positionId": 479975679,
// "market": "BTC_PERP",
// "openDate": 1741941025.309887,
// "modifyDate": 1741941025.309887,
// "amount": "0.001",
// "basePrice": "82498.7",
// "realizedFunding": "0",
// "liquidationPrice": "0",
// "liquidationState": null,
// "orderDetail": {
// "id": 1224727949521,
// "tradeAmount": "0.001",
// "price": "82498.7",
// "tradeFee": "0.028874545",
// "fundingFee": "0",
// "realizedPnl": "-0.028874545"
// }
// }
//
let mut marketId: Value = self.safe_string_k(position.clone(), "market", &[]);
let mut timestamp: Value = self.safe_timestamp(position.clone(), Value::Str("openDate".to_string()), &[]);
let mut tpsl: Value = self.safe_dict_k(position.clone(), "tpsl", &[Value::Map({
let mut m = indexmap::IndexMap::new();
m
})]);
let mut orderDetail: Value = self.safe_dict_k(position.clone(), "orderDetail", &[Value::Map({
let mut m = indexmap::IndexMap::new();
m
})]);
return self.safe_position(Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("info".to_string(), position.clone());
m.insert("id".to_string(), self.safe_string_k(position.clone(), "positionId", &[]));
m.insert("symbol".to_string(), self.safe_symbol(marketId.clone(), &[market.clone()]));
m.insert("notional".to_string(), Value::Null);
m.insert("marginMode".to_string(), Value::Null);
m.insert("liquidationPrice".to_string(), self.safe_number_k(position.clone(), "liquidationPrice", &[]));
m.insert("entryPrice".to_string(), self.safe_number_k(position.clone(), "basePrice", &[]));
m.insert("unrealizedPnl".to_string(), self.safe_number_k(position.clone(), "pnl", &[]));
m.insert("realizedPnl".to_string(), self.safe_number_k(orderDetail.clone(), "realizedPnl", &[]));
m.insert("percentage".to_string(), self.safe_number_k(position.clone(), "pnlPercent", &[]));
m.insert("contracts".to_string(), Value::Null);
m.insert("contractSize".to_string(), Value::Null);
m.insert("markPrice".to_string(), Value::Null);
m.insert("lastPrice".to_string(), Value::Null);
m.insert("side".to_string(), Value::Null);
m.insert("hedged".to_string(), Value::Null);
m.insert("timestamp".to_string(), timestamp.clone());
m.insert("datetime".to_string(), self.iso8601(timestamp.clone()));
m.insert("lastUpdateTimestamp".to_string(), self.safe_timestamp(position.clone(), Value::Str("modifyDate".to_string()), &[]));
m.insert("maintenanceMargin".to_string(), Value::Null);
m.insert("maintenanceMarginPercentage".to_string(), Value::Null);
m.insert("collateral".to_string(), self.safe_number_k(position.clone(), "margin", &[]));
m.insert("initialMargin".to_string(), Value::Null);
m.insert("initialMarginPercentage".to_string(), Value::Null);
m.insert("leverage".to_string(), Value::Null);
m.insert("marginRatio".to_string(), Value::Null);
m.insert("stopLossPrice".to_string(), self.safe_number_k(tpsl.clone(), "stopLoss", &[]));
m.insert("takeProfitPrice".to_string(), self.safe_number_k(tpsl.clone(), "takeProfit", &[]));
m
}));
Value::Null
}
pub fn is_fiat(&self, mut currency: Value) -> Value {
let mut fiatCurrencies: Value = self.safe_value_k(self.options.clone(), "fiatCurrencies", &[Value::List(vec![])]);
return self.in_array(currency.clone(), fiatCurrencies.clone());
Value::Null
}
/*
* @method
* @name whitebit#fetchFundingRateHistory
* @description fetches historical funding rate prices
* @see https://docs.whitebit.com/api-reference/market-data/funding-history
* @param {string} symbol unified symbol of the market to fetch the funding rate history for
* @param {int} [since] timestamp in ms of the earliest funding rate to fetch
* @param {int} [limit] the maximum amount of [funding rate structures]{@link https://docs.ccxt.com/?id=funding-rate-history-structure} to fetch (default 100, max 100)
* @param {object} [params] extra parameters specific to the exchange API endpoint
* @param {int} [params.until] timestamp in ms of the latest funding rate
* @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()))));
}
let mut maxLimit: Value = Value::Int(100);
let mut paginate: Value = Value::Bool(false);
{ let __destr_tmp = self.handle_option_and_params(params.clone(), Value::Str("fetchFundingRateHistory".to_string()), Value::Str("paginate".to_string()), &[]); paginate = get_value(&__destr_tmp, &Value::Int(0)); params = get_value(&__destr_tmp, &Value::Int(1)); }
if is_true(&paginate) {
return self.fetch_paginated_call_deterministic(Value::Str("fetchFundingRateHistory".to_string()), &[symbol.clone(), since.clone(), limit.clone(), Value::Str("8h".to_string()), params.clone(), maxLimit.clone()]).await;
}
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("market".to_string(), get_value(&market, &Value::Str("id".to_string())));
m
});
if !is_equal(&since, &Value::Null) {
add_element_to_object(&mut request, &Value::Str("startDate".to_string()), math_round(÷(&since, &Value::Int(1000))));
}
{ let __destr_tmp = self.handle_until_option(Value::Str("until_timestamp".to_string()), request.clone(), params.clone(), &[Value::Float(0.001)]); request = get_value(&__destr_tmp, &Value::Int(0)); params = get_value(&__destr_tmp, &Value::Int(1)); }
if !is_equal(&limit, &Value::Null) {
add_element_to_object(&mut request, &Value::Str("limit".to_string()), limit.clone());
}
let __ws_arg_42 = self.extend(request.clone(), &[params.clone()]);
let mut response: Value = self.v4_public_get_funding_history_market(&[__ws_arg_42]).await;
return self.parse_funding_rate_histories(response.clone(), &[market.clone(), since.clone(), limit.clone()]);
Value::Null
}
pub fn parse_funding_rate_history(&self, mut info: Value, optional_args: &[Value]) -> Value {
let mut market = get_arg(optional_args, 0, Value::Null);
let mut marketId: Value = self.safe_string_k(info.clone(), "market", &[]);
market = self.safe_market(&[marketId.clone(), market.clone()]);
let mut timestamp: Value = self.safe_timestamp(info.clone(), Value::Str("fundingTime".to_string()), &[]);
return Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("info".to_string(), info.clone());
m.insert("symbol".to_string(), get_value(&market, &Value::Str("symbol".to_string())));
m.insert("fundingRate".to_string(), self.safe_number_k(info.clone(), "fundingRate", &[]));
m.insert("timestamp".to_string(), timestamp.clone());
m.insert("datetime".to_string(), self.iso8601(timestamp.clone()));
m
});
Value::Null
}
pub fn nonce(&self) -> Value {
return subtract(&self.milliseconds(), &get_value(&self.options, &Value::Str("timeDifference".to_string())));
Value::Null
}
pub fn sign(&self, mut path: Value, optional_args: &[Value]) -> Value {
let mut api = get_arg(optional_args, 0, Value::Str("public".to_string()));
let mut method = get_arg(optional_args, 1, Value::Str("GET".to_string()));
let mut params = get_arg(optional_args, 2, Value::Map({
let mut m = indexmap::IndexMap::new();
m
}));
let mut headers = get_arg(optional_args, 3, Value::Null);
let mut body = get_arg(optional_args, 4, Value::Null);
let mut query: Value = self.omit(params.clone(), self.extract_params(path.clone()), &[]);
let mut version: Value = self.safe_value(api.clone(), Value::Int(0), &[]);
let mut accessibility: Value = self.safe_value(api.clone(), Value::Int(1), &[]);
if is_equal(&headers, &Value::Null) {
headers = Value::Map({
let mut m = indexmap::IndexMap::new();
m
});
}
add_element_to_object(&mut headers, &Value::Str("User-Agent".to_string()), add(&add(&add(&Value::Str("ccxt/".to_string()), &self.id), &Value::Str("-".to_string())), &self.version));
let mut pathWithParams: Value = add(&Value::Str("/".to_string()), &self.implode_params(path.clone(), params.clone()));
let mut url: Value = add(&get_value(&get_value(&get_value(&self.urls, &Value::Str("api".to_string())), &version), &accessibility), &pathWithParams);
if is_equal(&accessibility, &Value::Str("public".to_string())) {
if is_greater_than(&get_array_length(&object_keys(&query)), &Value::Int(0)) {
url = add(&url, &add(&Value::Str("?".to_string()), &self.urlencode(query.clone(), &[])));
}
}
if is_equal(&accessibility, &Value::Str("private".to_string())) {
self.check_required_credentials(&[]);
let mut nonce: Value = to_string_val(&self.nonce());
let mut secret: Value = self.encode(self.secret.clone());
let mut request: Value = add(&add(&add(&add(&Value::Str("/".to_string()), &Value::Str("api".to_string())), &Value::Str("/".to_string())), &version), &pathWithParams);
let mut nonceWindowrequestParamsVariable = self.handle_option_and_params(params.clone(), Value::Str("sign".to_string()), Value::Str("nonceWindow".to_string()), &[Value::Bool(false)]);
let mut nonceWindow: Value = get_value(&nonceWindowrequestParamsVariable, &Value::Int(0));
let mut requestParams: Value = get_value(&nonceWindowrequestParamsVariable, &Value::Int(1));
let __ws_arg_43 = self.extend(Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("request".to_string(), request.clone());
m.insert("nonce".to_string(), nonce.clone());
m.insert("nonceWindow".to_string(), nonceWindow.clone());
m
}), &[requestParams.clone()]);
body = self.json(__ws_arg_43);
let mut payload: Value = self.string_to_base64(body.clone(), &[]);
let mut signature: Value = self.hmac(self.encode(payload.clone()), secret.clone(), Value::Str("sha512".to_string()), &[]);
headers = Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("Content-Type".to_string(), Value::Str("application/json".to_string()));
m.insert("X-TXC-APIKEY".to_string(), self.apiKey.clone());
m.insert("X-TXC-PAYLOAD".to_string(), payload.clone());
m.insert("X-TXC-SIGNATURE".to_string(), signature.clone());
m
});
}
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_true(&(is_equal(&code, &Value::Int(418)))) || is_true(&(is_equal(&code, &Value::Int(429)))) {
panic!("{}", crate::exchange_errors::d_do_s_protection(add(&add(&add(&add(&add(&add(&self.id, &Value::Str(" ".to_string())), &to_string_val(&code)), &Value::Str(" ".to_string())), &reason), &Value::Str(" ".to_string())), &body)));
}
if is_equal(&code, &Value::Int(404)) {
panic!("{}", crate::exchange_errors::exchange_error(add(&add(&add(&self.id, &Value::Str(" ".to_string())), &to_string_val(&code)), &Value::Str(" endpoint not found".to_string()))));
}
if !is_equal(&response, &Value::Null) {
// For cases where we have a meaningful status
// {"response":null,"status":422,"errors":{"orderId":["Finished order id 435453454535 not found on your account"]},"notification":null,"warning":"Finished order id 435453454535 not found on your account","_token":null}
let mut status: Value = self.safe_string_k(response.clone(), "status", &[]);
let mut errors: Value = self.safe_value_k(response.clone(), "errors", &[]);
// {"code":10,"message":"Unauthorized request."}
let mut message: Value = self.safe_string_k(response.clone(), "message", &[]);
// For these cases where we have a generic code variable error key
// {"code":0,"message":"Validation failed","errors":{"amount":["Amount must be greater than 0"]}}
let mut codeNew: Value = self.safe_integer_k(response.clone(), "code", &[]);
let mut hasErrorStatus: bool = !is_equal(&status, &Value::Null) && !is_equal(&status, &Value::Str("200".to_string())) && !is_equal(&errors, &Value::Null);
if is_true(&hasErrorStatus) || !is_equal(&codeNew, &Value::Null) {
let mut feedback: Value = add(&add(&self.id, &Value::Str(" ".to_string())), &body);
let mut errorInfo: Value = message.clone();
if is_true(&hasErrorStatus) {
errorInfo = status.clone();
} else {
let mut errorObject: Value = self.safe_dict_k(response.clone(), "errors", &[Value::Map({
let mut m = indexmap::IndexMap::new();
m
})]);
let mut errorKeys: Value = object_keys(&errorObject);
let mut errorsLength: Value = get_array_length(&errorKeys);
if is_greater_than(&errorsLength, &Value::Int(0)) {
let mut errorKey: Value = get_value(&errorKeys, &Value::Int(0));
let mut errorMessageArray: Value = self.safe_value(errorObject.clone(), errorKey.clone(), &[Value::List(vec![])]);
let mut errorMessageLength: Value = get_array_length(&errorMessageArray);
errorInfo = ternary(is_true(&(is_greater_than(&errorMessageLength, &Value::Int(0)))), get_value(&errorMessageArray, &Value::Int(0)), body.clone());
}
}
self.throw_exactly_matched_exception(get_value(&self.exceptions, &Value::Str("exact".to_string())), errorInfo.clone(), feedback.clone());
self.throw_broadly_matched_exception(get_value(&self.exceptions, &Value::Str("broad".to_string())), body.clone(), feedback.clone());
panic!("{}", crate::exchange_errors::exchange_error(feedback));
}
// {"success":false,"message":{"limit":["limit must be less than or equal to 100"]},"result":null}
let mut success: Value = self.safe_bool_k(response.clone(), "success", &[Value::Bool(true)]);
if !is_equal(&success, &Value::Bool(true)) {
let mut errMsg: Value = self.safe_dict_k(response.clone(), "message", &[Value::Map({
let mut m = indexmap::IndexMap::new();
m
})]);
let mut errKeys: Value = object_keys(&errMsg);
let mut errKeysLength: Value = get_array_length(&errKeys);
let mut errorInfo: Value = body.clone();
if is_greater_than(&errKeysLength, &Value::Int(0)) {
let mut errorKey: Value = get_value(&errKeys, &Value::Int(0));
let mut errorMessageArray: Value = self.safe_list(errMsg.clone(), errorKey.clone(), &[Value::List(vec![])]);
let mut errorMessageLength: Value = get_array_length(&errorMessageArray);
errorInfo = ternary(is_true(&(is_greater_than(&errorMessageLength, &Value::Int(0)))), get_value(&errorMessageArray, &Value::Int(0)), body.clone());
}
let mut feedback: Value = add(&add(&self.id, &Value::Str(" ".to_string())), &body);
self.throw_exactly_matched_exception(get_value(&self.exceptions, &Value::Str("exact".to_string())), errorInfo.clone(), feedback.clone());
self.throw_broadly_matched_exception(get_value(&self.exceptions, &Value::Str("broad".to_string())), body.clone(), feedback.clone());
panic!("{}", crate::exchange_errors::exchange_error(feedback));
}
}
return Value::Null;
Value::Null
}
}