// 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;
// Dynamic `this[method](...)` re-entries are emitted as
// `self.call_dynamic_checked(...)` (blanket-impl'd on every Core) so an
// unresolvable name raises NotSupported instead of yielding a silent Null.
use crate::exchange::CallDynamicChecked;
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])
}
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])
}
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])
}
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])
}
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])
}
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])
}
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])
}
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])
}
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])
}
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])
}
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])
}
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, to_currency])
}
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, method, params, headers, body])
}
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[..]).await,
"cancel_all_orders_after" => self.cancel_all_orders_after(args.get(0).cloned().unwrap_or(crate::Value::Null), &args[1.min(args.len())..]).await,
"cancel_order" => self.cancel_order(args.get(0).cloned().unwrap_or(crate::Value::Null), &args[1.min(args.len())..]).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[3.min(args.len())..]).await,
"create_deposit_address" => self.create_deposit_address(args.get(0).cloned().unwrap_or(crate::Value::Null), &args[1.min(args.len())..]).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[2.min(args.len())..]).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[3.min(args.len())..]).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[4.min(args.len())..]).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[4.min(args.len())..]).await,
"fetch_accounts" => self.fetch_accounts(&args[..]).await,
"fetch_balance" => self.fetch_balance(&args[..]).await,
"fetch_borrow_interest" => self.fetch_borrow_interest(&args[..]).await,
"fetch_closed_orders" => self.fetch_closed_orders(&args[..]).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[2.min(args.len())..]).await,
"fetch_convert_trade_history" => self.fetch_convert_trade_history(&args[..]).await,
"fetch_currencies" => self.fetch_currencies(&args[..]).await,
"fetch_deposit" => self.fetch_deposit(args.get(0).cloned().unwrap_or(crate::Value::Null), &args[1.min(args.len())..]).await,
"fetch_deposit_address" => self.fetch_deposit_address(args.get(0).cloned().unwrap_or(crate::Value::Null), &args[1.min(args.len())..]).await,
"fetch_deposit_withdraw_fees" => self.fetch_deposit_withdraw_fees(&args[..]).await,
"fetch_deposits" => self.fetch_deposits(&args[..]).await,
"fetch_deposits_withdrawals" => self.fetch_deposits_withdrawals(&args[..]).await,
"fetch_funding_history" => self.fetch_funding_history(&args[..]).await,
"fetch_funding_limits" => self.fetch_funding_limits(&args[..]).await,
"fetch_funding_rate" => self.fetch_funding_rate(args.get(0).cloned().unwrap_or(crate::Value::Null), &args[1.min(args.len())..]).await,
"fetch_funding_rate_history" => self.fetch_funding_rate_history(&args[..]).await,
"fetch_funding_rates" => self.fetch_funding_rates(&args[..]).await,
"fetch_markets" => self.fetch_markets(&args[..]).await,
"fetch_my_trades" => self.fetch_my_trades(&args[..]).await,
"fetch_ohlcv" => self.fetch_ohlcv(args.get(0).cloned().unwrap_or(crate::Value::Null), &args[1.min(args.len())..]).await,
"fetch_open_orders" => self.fetch_open_orders(&args[..]).await,
"fetch_order" => self.fetch_order(args.get(0).cloned().unwrap_or(crate::Value::Null), &args[1.min(args.len())..]).await,
"fetch_order_book" => self.fetch_order_book(args.get(0).cloned().unwrap_or(crate::Value::Null), &args[1.min(args.len())..]).await,
"fetch_order_trades" => self.fetch_order_trades(args.get(0).cloned().unwrap_or(crate::Value::Null), &args[1.min(args.len())..]).await,
"fetch_orders" => self.fetch_orders(&args[..]).await,
"fetch_position" => self.fetch_position(args.get(0).cloned().unwrap_or(crate::Value::Null), &args[1.min(args.len())..]).await,
"fetch_position_history" => self.fetch_position_history(args.get(0).cloned().unwrap_or(crate::Value::Null), &args[1.min(args.len())..]).await,
"fetch_positions" => self.fetch_positions(&args[..]).await,
"fetch_status" => self.fetch_status(&args[..]).await,
"fetch_ticker" => self.fetch_ticker(args.get(0).cloned().unwrap_or(crate::Value::Null), &args[1.min(args.len())..]).await,
"fetch_tickers" => self.fetch_tickers(&args[..]).await,
"fetch_time" => self.fetch_time(&args[..]).await,
"fetch_trades" => self.fetch_trades(args.get(0).cloned().unwrap_or(crate::Value::Null), &args[1.min(args.len())..]).await,
"fetch_trading_fees" => self.fetch_trading_fees(&args[..]).await,
"fetch_trading_limits" => self.fetch_trading_limits(&args[..]).await,
"fetch_transaction_fees" => self.fetch_transaction_fees(&args[..]).await,
"fetch_transactions" => self.fetch_transactions(&args[..]).await,
"fetch_withdrawals" => self.fetch_withdrawals(&args[..]).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[1.min(args.len())..]),
"parse_conversion" => self.parse_conversion(args.get(0).cloned().unwrap_or(crate::Value::Null), &args[1.min(args.len())..]),
"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[1.min(args.len())..]),
"parse_deposit_withdraw_fees" => self.parse_deposit_withdraw_fees(args.get(0).cloned().unwrap_or(crate::Value::Null), &args[1.min(args.len())..]),
"parse_funding_histories" => self.parse_funding_histories(args.get(0).cloned().unwrap_or(crate::Value::Null), &args[1.min(args.len())..]),
"parse_funding_history" => self.parse_funding_history(args.get(0).cloned().unwrap_or(crate::Value::Null), &args[1.min(args.len())..]),
"parse_funding_rate" => self.parse_funding_rate(args.get(0).cloned().unwrap_or(crate::Value::Null), &args[1.min(args.len())..]),
"parse_funding_rate_history" => self.parse_funding_rate_history(args.get(0).cloned().unwrap_or(crate::Value::Null), &args[1.min(args.len())..]),
"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[1.min(args.len())..]),
"parse_order" => self.parse_order(args.get(0).cloned().unwrap_or(crate::Value::Null), &args[1.min(args.len())..]),
"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[1.min(args.len())..]),
"parse_ticker" => self.parse_ticker(args.get(0).cloned().unwrap_or(crate::Value::Null), &args[1.min(args.len())..]),
"parse_trade" => self.parse_trade(args.get(0).cloned().unwrap_or(crate::Value::Null), &args[1.min(args.len())..]),
"parse_transaction" => self.parse_transaction(args.get(0).cloned().unwrap_or(crate::Value::Null), &args[1.min(args.len())..]),
"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[1.min(args.len())..]),
"set_leverage" => self.set_leverage(args.get(0).cloned().unwrap_or(crate::Value::Null), &args[1.min(args.len())..]).await,
"sign" => self.sign(args.get(0).cloned().unwrap_or(crate::Value::Null), &args[1.min(args.len())..]),
"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[4.min(args.len())..]).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[3.min(args.len())..]).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".into()));
m.insert("name".to_string(), Value::Str("WhiteBit".into()));
m.insert("version".to_string(), Value::Str("v4".into()));
m.insert("countries".to_string(), Value::from(vec![Value::Str("EE".into())]));
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".into()));
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".into()));
m.insert("3m".to_string(), Value::Str("3m".into()));
m.insert("5m".to_string(), Value::Str("5m".into()));
m.insert("15m".to_string(), Value::Str("15m".into()));
m.insert("30m".to_string(), Value::Str("30m".into()));
m.insert("1h".to_string(), Value::Str("1h".into()));
m.insert("2h".to_string(), Value::Str("2h".into()));
m.insert("4h".to_string(), Value::Str("4h".into()));
m.insert("6h".to_string(), Value::Str("6h".into()));
m.insert("8h".to_string(), Value::Str("8h".into()));
m.insert("12h".to_string(), Value::Str("12h".into()));
m.insert("1d".to_string(), Value::Str("1d".into()));
m.insert("3d".to_string(), Value::Str("3d".into()));
m.insert("1w".to_string(), Value::Str("1w".into()));
m.insert("1M".to_string(), Value::Str("1M".into()));
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".into()));
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".into()));
m.insert("private".to_string(), Value::Str("https://whitebit.com/api/v1".into()));
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".into()));
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".into()));
m.insert("private".to_string(), Value::Str("https://whitebit.com/api/v4".into()));
m
}));
m
}));
m.insert("www".to_string(), Value::Str("https://www.whitebit.com".into()));
m.insert("doc".to_string(), Value::Str("https://github.com/whitebit-exchange/api-docs".into()));
m.insert("fees".to_string(), Value::Str("https://whitebit.com/fee-schedule".into()));
m.insert("referral".to_string(), Value::Str("https://whitebit.com/referral/d9bdf40e-28f2-4b52-b2f9-cd1415d82963".into()));
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/positions/closed-pnl".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/express-withdraw/token".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("main-account/smart-flex/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-flex/investments".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(1));
m
}));
m.insert("main-account/smart-flex/investments/history".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(1));
m
}));
m.insert("main-account/smart-flex/investments/payment-history".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(1));
m
}));
m.insert("main-account/smart-flex/investments/invest".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(1));
m
}));
m.insert("main-account/smart-flex/investments/withdraw".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(1));
m
}));
m.insert("main-account/smart-flex/investments/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-flex/investments/auto-invest".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/history/query".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/cancel/bulk".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("mining/hashrate".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(1));
m
}));
m.insert("mining/payout-destination".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(1));
m
}));
m.insert("mining/payout-destination/edit".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(1));
m
}));
m.insert("mining/miners/info".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(1));
m
}));
m.insert("mining/workers/names".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(1));
m
}));
m.insert("mining/workers/hashrate".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(1));
m
}));
m.insert("mining/watcher-links/create".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(1));
m
}));
m.insert("mining/watcher-links/list".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(1));
m
}));
m.insert("mining/accounts/create".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(1));
m
}));
m.insert("mining/accounts".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("market/fee/single".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.insert("travel-rule/vasps".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(1));
m
}));
m.insert("travel-rule/deposit/verification".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(1));
m
}));
m.insert("jwt".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".into()), &[]));
m.insert("maker".to_string(), self.parse_number(Value::Str("0.001".into()), &[]));
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::from(vec![Value::Str("EUR".into()), Value::Str("USD".into()), Value::Str("RUB".into()), Value::Str("UAH".into())]));
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".into()));
m
}));
m.insert("accountsByType".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("funding".to_string(), Value::Str("main".into()));
m.insert("main".to_string(), Value::Str("main".into()));
m.insert("spot".to_string(), Value::Str("spot".into()));
m.insert("margin".to_string(), Value::Str("collateral".into()));
m.insert("trade".to_string(), Value::Str("spot".into()));
m
}));
m.insert("networksById".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m
}));
m.insert("defaultType".to_string(), Value::Str("spot".into()));
m.insert("brokerId".to_string(), Value::Str("ccxt".into()));
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".into()));
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".into()));
m
}));
m.insert("inverse".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("extends".to_string(), Value::Str("default".into()));
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".into()).clone());
m.insert("The market format is invalid.".to_string(), Value::Str("BadSymbol".into()).clone());
m.insert("Market is not available".to_string(), Value::Str("BadSymbol".into()).clone());
m.insert("Invalid payload.".to_string(), Value::Str("BadRequest".into()).clone());
m.insert("Amount must be greater than 0".to_string(), Value::Str("InvalidOrder".into()).clone());
m.insert("Not enough balance.".to_string(), Value::Str("InsufficientFunds".into()).clone());
m.insert("The order id field is required.".to_string(), Value::Str("InvalidOrder".into()).clone());
m.insert("Not enough balance".to_string(), Value::Str("InsufficientFunds".into()).clone());
m.insert("This action is unauthorized.".to_string(), Value::Str("PermissionDenied".into()).clone());
m.insert("This API Key is not authorized to perform this action.".to_string(), Value::Str("PermissionDenied".into()).clone());
m.insert("Unexecuted order was not found.".to_string(), Value::Str("OrderNotFound".into()).clone());
m.insert("The selected from is invalid.".to_string(), Value::Str("BadRequest".into()).clone());
m.insert("503".to_string(), Value::Str("ExchangeNotAvailable".into()).clone());
m.insert("422".to_string(), Value::Str("OrderNotFound".into()).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".into()).clone());
m.insert("The Price should be less than or equal to".to_string(), Value::Str("InvalidOrder".into()).clone());
m.insert("The Price should be greater than or equal to".to_string(), Value::Str("InvalidOrder".into()).clone());
m.insert("This action is unauthorized".to_string(), Value::Str("PermissionDenied".into()).clone());
m.insert("Given amount is less than min amount".to_string(), Value::Str("InvalidOrder".into()).clone());
m.insert("Min amount step".to_string(), Value::Str("InvalidOrder".into()).clone());
m.insert("Total is less than".to_string(), Value::Str("InvalidOrder".into()).clone());
m.insert("fee must be no less than".to_string(), Value::Str("InvalidOrder".into()).clone());
m.insert("Enable your key in API settings".to_string(), Value::Str("PermissionDenied".into()).clone());
m.insert("You don't have such amount for transfer".to_string(), Value::Str("InsufficientFunds".into()).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(&self.options.as_map().and_then(|__m| __m.get("adjustForTimeDifference")).cloned().unwrap_or(Value::Null), &Value::Bool(true)) {
self.load_time_difference(&[]).await;
}
let mut markets: Value = self.v4_public_get_markets(&[]).await;
return self.parse_markets(markets);
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 = (if (quoteId.as_str() == Some("PERP")) { Value::Str("USDT".into()) } else { 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_bool_k(market.clone(), "tradesEnabled", &[]);
let mut isCollateral: Value = self.safe_bool_k(market.clone(), "isCollateral", &[]);
let mut typeId: Option<String> = self.safe_string_k(market.clone(), "type", &[]).as_str().map(str::to_owned);
let mut type_var: Value = Value::Null;
let mut settle: Value = Value::Null;
let mut settleId: Value = Value::Null;
let mut symbol: Value = Value::Str(format!("{}{}", Value::Str(format!("{}{}", base, Value::Str("/".into())).into()), quote).into());
let mut swap: Value = Value::Bool((typeId.as_deref() == Some("futures")) || (typeId.as_deref() == Some("tradfiFutures")));
let mut margin: Value = Value::Bool((isCollateral.as_bool() == Some(true)) && !(matches!(&swap, Value::Bool(true))));
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 matches!(&swap, Value::Bool(true)) {
settleId = quoteId.clone();
settle = self.safe_currency_code(settleId.clone(), &[]);
symbol = Value::Str(format!("{}{}", Value::Str(format!("{}{}", symbol, Value::Str(":".into())).into()), settle).into());
type_var = Value::Str("swap".into());
contract = Value::Bool(true);
linear = Value::Bool(true);
inverse = Value::Bool(false);
} else {
type_var = Value::Str("spot".into());
}
let mut takerFeeRate: Value = self.safe_string_k(market.clone(), "takerFee", &[]);
let mut taker: Value = crate::precise::Precise::stringDiv(&takerFeeRate, &Value::Str("100".into()));
let mut makerFeeRate: Value = self.safe_string_k(market.clone(), "makerFee", &[]);
let mut maker: Value = crate::precise::Precise::stringDiv(&makerFeeRate, &Value::Str("100".into()));
let mut isSpot: Value = Value::Bool(!(matches!(&swap, Value::Bool(true))));
return self.safe_market_structure(&[Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("id".to_string(), id);
m.insert("symbol".to_string(), symbol);
m.insert("base".to_string(), base);
m.insert("quote".to_string(), quote);
m.insert("settle".to_string(), settle);
m.insert("baseId".to_string(), baseId);
m.insert("quoteId".to_string(), quoteId);
m.insert("settleId".to_string(), settleId);
m.insert("type".to_string(), type_var);
m.insert("spot".to_string(), isSpot.clone());
m.insert("margin".to_string(), margin);
m.insert("swap".to_string(), swap);
m.insert("future".to_string(), Value::Bool(false));
m.insert("option".to_string(), Value::Bool(false));
m.insert("active".to_string(), active);
m.insert("contract".to_string(), contract);
m.insert("linear".to_string(), linear);
m.insert("inverse".to_string(), inverse);
m.insert("taker".to_string(), self.parse_number(taker, &[]));
m.insert("maker".to_string(), self.parse_number(maker, &[]));
m.insert("contractSize".to_string(), (if matches!(&isSpot, Value::Bool(true)) { Value::Null } else { self.parse_number(Value::Str("1".into()), &[]) }));
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);
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);
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]).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, Value::Str("_coin_id".into()));
return self.parse_currencies(enhancedArray);
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: bool = matches!(&rawCurrency, Value::Dict(__d) if __d.contains_key("providers"));
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::from(vec![])]);
let mut withdrawsNetworks: Value = self.safe_list_k(rawNetworks, "withdraws", &[Value::from(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, "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_1098: bool = true;
while { if !__for_first_1098 { j = (match (&(j), &(Value::Int(1))) { (Value::Int(x), Value::Int(y)) => Value::Int(x + y), (Value::Int(x), Value::Float(y)) => Value::Float(*x as f64 + *y), (Value::Float(x), Value::Int(y)) => Value::Float(*x + *y as f64), (Value::Float(x), Value::Float(y)) => Value::Float(x + y), _ => Value::Null }); } __for_first_1098 = false; j.as_f64().unwrap_or(f64::NAN) < ((allNetworks.len() as i64) as f64) } {
let mut networkId: Value = allNetworks.as_array().and_then(|__arr| match &j { Value::Int(__n) => __arr.get(*__n as usize), Value::Str(__s) => __s.parse::<usize>().ok().and_then(|__n| __arr.get(__n)), _ => None }).cloned().unwrap_or(Value::Null);
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 (networkCode != Value::Null) {
if let Value::Dict(__d) = &mut networks { std::sync::Arc::make_mut(__d).insert(crate::runtime::stringify_param(&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, 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, "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, "max", &[]));
m
}));
m
}));
m
})); }
}
}
}
return self.safe_currency_structure(Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("id".to_string(), id);
m.insert("code".to_string(), code);
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);
m.insert("type".to_string(), (if hasProvider { Value::Str("fiat".into()) } else { Value::Str("crypto".into()) }));
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, "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 (self.markets.clone() == Value::Null) {
self.load_markets(&[]).await;
}
let mut response: Value = self.v4_public_get_fee(&[params]).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_1099: bool = true;
while { if !__for_first_1099 { i = (match (&(i), &(Value::Int(1))) { (Value::Int(x), Value::Int(y)) => Value::Int(x + y), (Value::Int(x), Value::Float(y)) => Value::Float(*x as f64 + *y), (Value::Float(x), Value::Int(y)) => Value::Float(*x + *y as f64), (Value::Float(x), Value::Float(y)) => Value::Float(x + y), _ => Value::Null }); } __for_first_1099 = false; i.as_f64().unwrap_or(f64::NAN) < ((currenciesIds.len() as i64) as f64) } {
let mut currency: Value = currenciesIds.as_array().and_then(|__arr| match &i { Value::Int(__n) => __arr.get(*__n as usize), Value::Str(__s) => __s.parse::<usize>().ok().and_then(|__n| __arr.get(__n)), _ => None }).cloned().unwrap_or(Value::Null);
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, &[]);
let mut withdraw: Value = self.safe_dict_k(data.clone(), "withdraw", &[Value::Map({
let mut m = indexmap::IndexMap::new();
m
})]);
if (code != Value::Null) {
if let Value::Dict(__d) = &mut withdrawFees { std::sync::Arc::make_mut(__d).insert(crate::runtime::stringify_param(&code), self.safe_string_k(withdraw, "fixed", &[])); }
}
let mut deposit: Value = self.safe_dict_k(data, "deposit", &[Value::Map({
let mut m = indexmap::IndexMap::new();
m
})]);
if (code != Value::Null) {
if let Value::Dict(__d) = &mut depositFees { std::sync::Arc::make_mut(__d).insert(crate::runtime::stringify_param(&code), self.safe_string_k(deposit, "fixed", &[])); }
}
}
}
return Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("withdraw".to_string(), withdrawFees);
m.insert("deposit".to_string(), depositFees);
m.insert("info".to_string(), response);
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 (self.markets.clone() == Value::Null) {
self.load_markets(&[]).await;
}
let mut response: Value = self.v4_public_get_fee(&[params]).await;
return self.parse_deposit_withdraw_fees(response, &[codes]);
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_1100: bool = true;
while { if !__for_first_1100 { i = (match (&(i), &(Value::Int(1))) { (Value::Int(x), Value::Int(y)) => Value::Int(x + y), (Value::Int(x), Value::Float(y)) => Value::Float(*x as f64 + *y), (Value::Float(x), Value::Int(y)) => Value::Float(*x + *y as f64), (Value::Float(x), Value::Float(y)) => Value::Float(x + y), _ => Value::Null }); } __for_first_1100 = false; i.as_f64().unwrap_or(f64::NAN) < ((currencyIds.len() as i64) as f64) } {
let mut entry: Value = currencyIds.as_array().and_then(|__arr| match &i { Value::Int(__n) => __arr.get(*__n as usize), Value::Str(__s) => __s.parse::<usize>().ok().and_then(|__n| __arr.get(__n)), _ => None }).cloned().unwrap_or(Value::Null);
let mut splitEntry: Value = split(&entry, &Value::Str(" ".into()));
let mut currencyId: Value = splitEntry.as_array().and_then(|__arr| __arr.get(0)).cloned().unwrap_or(Value::Null);
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, &[]);
if (code != Value::Null) && ((codes == Value::Null) || self.in_array(code.clone(), codes.clone()).as_bool() == Some(true)) {
let mut depositWithdrawFee: Value = self.safe_dict(depositWithdrawFees.clone(), code.clone(), &[]);
if (depositWithdrawFee == Value::Null) {
if let Value::Dict(__d) = &mut depositWithdrawFees { std::sync::Arc::make_mut(__d).insert(crate::runtime::stringify_param(&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".into())), &entry, feeInfo.clone());
let mut networkId: Value = self.safe_string(splitEntry, Value::Int(1), &[]);
let mut withdraw: Value = self.safe_dict_k(feeInfo.clone(), "withdraw", &[]);
let mut deposit: Value = self.safe_dict_k(feeInfo, "deposit", &[]);
let mut withdrawFee: Value = self.safe_number_k(withdraw, "fixed", &[]);
let mut depositFee: Value = self.safe_number_k(deposit, "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(), (if (withdrawFee != Value::Null) { Value::Bool(false) } else { 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(), (if (depositFee != Value::Null) { Value::Bool(false) } else { Value::Null }));
m
});
if (networkId != Value::Null) {
let mut networkLength: Value = Value::Int(networkId.len() as i64);
networkId = slice(&networkId, &Value::Int(1), &(match (&(networkLength), &(Value::Int(1))) { (Value::Int(x), Value::Int(y)) => Value::Int(x - y), (Value::Int(x), Value::Float(y)) => Value::Float(*x as f64 - *y), (Value::Float(x), Value::Int(y)) => Value::Float(*x - *y as f64), (Value::Float(x), Value::Float(y)) => Value::Float(x - y), _ => Value::Null }));
let mut networkCode: Value = self.network_id_to_code(&[networkId, code.clone()]);
if (networkCode != Value::Null) {
add_element_to_object(get_value_mut(get_value_mut(&mut depositWithdrawFees, &code), &Value::Str("networks".into())), &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".into()), withdrawResult);
add_element_to_object(get_value_mut(&mut depositWithdrawFees, &code), &Value::Str("deposit".into()), depositResult);
}
}
}
}
let mut depositWithdrawCodes: Value = object_keys(&depositWithdrawFees);
{
let mut i: Value = Value::Int(0);
let mut __for_first_1101: bool = true;
while { if !__for_first_1101 { i = (match (&(i), &(Value::Int(1))) { (Value::Int(x), Value::Int(y)) => Value::Int(x + y), (Value::Int(x), Value::Float(y)) => Value::Float(*x as f64 + *y), (Value::Float(x), Value::Int(y)) => Value::Float(*x + *y as f64), (Value::Float(x), Value::Float(y)) => Value::Float(x + y), _ => Value::Null }); } __for_first_1101 = false; i.as_f64().unwrap_or(f64::NAN) < ((depositWithdrawCodes.len() as i64) as f64) } {
let mut code: Value = depositWithdrawCodes.as_array().and_then(|__arr| match &i { Value::Int(__n) => __arr.get(*__n as usize), Value::Str(__s) => __s.parse::<usize>().ok().and_then(|__n| __arr.get(__n)), _ => None }).cloned().unwrap_or(Value::Null);
let mut currency: Value = self.currency(code.clone());
{ let __be_tmp = self.assign_default_deposit_withdraw_fees(get_value(&depositWithdrawFees, &code), &[currency]); if let Value::Dict(__d) = &mut depositWithdrawFees { std::sync::Arc::make_mut(__d).insert(crate::runtime::stringify_param(&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 (self.markets.clone() == Value::Null) {
self.load_markets(&[]).await;
}
let mut response: Value = self.v4_public_get_assets(&[params]).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_1102: bool = true;
while { if !__for_first_1102 { i = (match (&(i), &(Value::Int(1))) { (Value::Int(x), Value::Int(y)) => Value::Int(x + y), (Value::Int(x), Value::Float(y)) => Value::Float(*x as f64 + *y), (Value::Float(x), Value::Int(y)) => Value::Float(*x + *y as f64), (Value::Float(x), Value::Float(y)) => Value::Float(x + y), _ => Value::Null }); } __for_first_1102 = false; i.as_f64().unwrap_or(f64::NAN) < ((symbols.len() as i64) as f64) } {
let mut symbol: Value = symbols.as_array().and_then(|__arr| match &i { Value::Int(__n) => __arr.get(*__n as usize), Value::Str(__s) => __s.parse::<usize>().ok().and_then(|__n| __arr.get(__n)), _ => None }).cloned().unwrap_or(Value::Null);
let mut market: Value = self.market(symbol.clone());
let mut fee: Value = self.safe_dict(response.clone(), market.as_map().and_then(|__m| __m.get("baseId")).cloned().unwrap_or(Value::Null), &[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".into()));
takerFee = crate::precise::Precise::stringDiv(&takerFee, &Value::Str("100".into()));
if let Value::Dict(__d) = &mut result { std::sync::Arc::make_mut(__d).insert(crate::runtime::stringify_param(&symbol), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("info".to_string(), fee);
m.insert("symbol".to_string(), market.as_map().and_then(|__m| __m.get("symbol")).cloned().unwrap_or(Value::Null));
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, &[]));
m.insert("taker".to_string(), self.parse_number(takerFee, &[]));
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 (self.markets.clone() == 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 (markets == Value::Null) {
panic!("{}", crate::exchange_errors::exchange_error(format!("{}{}", self.id.clone(), Value::Str(" markets not loaded".into()))));
}
let mut marketIds: Value = object_keys(&markets);
{
let mut i: Value = Value::Int(0);
let mut __for_first_1104: bool = true;
while { if !__for_first_1104 { i = (match (&(i), &(Value::Int(1))) { (Value::Int(x), Value::Int(y)) => Value::Int(x + y), (Value::Int(x), Value::Float(y)) => Value::Float(*x as f64 + *y), (Value::Float(x), Value::Int(y)) => Value::Float(*x + *y as f64), (Value::Float(x), Value::Float(y)) => Value::Float(x + y), _ => Value::Null }); } __for_first_1104 = false; i.as_f64().unwrap_or(f64::NAN) < ((marketIds.len() as i64) as f64) } {
let mut marketId: Value = marketIds.as_array().and_then(|__arr| match &i { Value::Int(__n) => __arr.get(*__n as usize), Value::Str(__s) => __s.parse::<usize>().ok().and_then(|__n| __arr.get(__n)), _ => None }).cloned().unwrap_or(Value::Null);
let mut market: Value = markets.as_map().and_then(|__m| marketId.as_str().and_then(|__k| __m.get(__k))).cloned().unwrap_or(Value::Null);
let mut marketSymbol: Option<String> = self.safe_string_k(market.clone(), "symbol", &[]).as_str().map(str::to_owned);
if (market == Value::Null) || (market == Value::Null) || (marketSymbol.is_none()) || (marketSymbol.as_deref() == Some("")) {
continue;
}
let mut symbol: Value = crate::value::get_value_k(&market, "symbol");
// Filter by symbols if specified
if (symbols != Value::Null) {
let mut symbolFound: bool = false;
{
let mut j: Value = Value::Int(0);
let mut __for_first_1103: bool = true;
while { if !__for_first_1103 { j = (match (&(j), &(Value::Int(1))) { (Value::Int(x), Value::Int(y)) => Value::Int(x + y), (Value::Int(x), Value::Float(y)) => Value::Float(*x as f64 + *y), (Value::Float(x), Value::Int(y)) => Value::Float(*x + *y as f64), (Value::Float(x), Value::Float(y)) => Value::Float(x + y), _ => Value::Null }); } __for_first_1103 = false; j.as_f64().unwrap_or(f64::NAN) < ((symbols.len() as i64) as f64) } {
if is_equal(&symbols.as_array().and_then(|__arr| match &j { Value::Int(__n) => __arr.get(*__n as usize), Value::Str(__s) => __s.parse::<usize>().ok().and_then(|__n| __arr.get(__n)), _ => None }).cloned().unwrap_or(Value::Null), &symbol) {
symbolFound = true;
break;
}
}
}
if !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, "cost", &[]);
// Validate that all required limits exist and are valid numbers
let mut hasAmountLimits: bool = (amountLimits != Value::Null) && (amountLimits != Value::Null) && (self.safe_number_k(amountLimits.clone(), "min", &[]) != Value::Null) && (self.safe_number_k(amountLimits.clone(), "max", &[]) != Value::Null);
let mut hasPriceLimits: bool = (priceLimits != Value::Null) && (priceLimits != Value::Null) && (self.safe_number_k(priceLimits.clone(), "min", &[]) != Value::Null) && (self.safe_number_k(priceLimits.clone(), "max", &[]) != Value::Null);
let mut hasCostLimits: bool = (costLimits != Value::Null) && (costLimits != Value::Null) && (self.safe_number_k(costLimits.clone(), "min", &[]) != Value::Null) && (self.safe_number_k(costLimits.clone(), "max", &[]) != Value::Null);
if (hasAmountLimits) && (hasPriceLimits) && (hasCostLimits) {
if let Value::Dict(__d) = &mut result { std::sync::Arc::make_mut(__d).insert(crate::runtime::stringify_param(&symbol), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("info".to_string(), market);
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, "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, "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, "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 (self.markets.clone() == Value::Null) {
self.load_markets(&[]).await;
}
// Fetch both currencies and fees data for comprehensive funding limits
let mut currenciesDatafeesDataVariable = promise_all(&Value::from(vec![self.fetch_currencies(&[]).await, self.v4_public_get_fee(&[params]).await])).await;
let mut currenciesData: Value = currenciesDatafeesDataVariable.as_array().and_then(|__arr| __arr.get(0)).cloned().unwrap_or(Value::Null);
let mut feesData: Value = currenciesDatafeesDataVariable.as_array().and_then(|__arr| __arr.get(1)).cloned().unwrap_or(Value::Null);
//
// 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_1106: bool = true;
while { if !__for_first_1106 { i = (match (&(i), &(Value::Int(1))) { (Value::Int(x), Value::Int(y)) => Value::Int(x + y), (Value::Int(x), Value::Float(y)) => Value::Float(*x as f64 + *y), (Value::Float(x), Value::Int(y)) => Value::Float(*x + *y as f64), (Value::Float(x), Value::Float(y)) => Value::Float(x + y), _ => Value::Null }); } __for_first_1106 = false; i.as_f64().unwrap_or(f64::NAN) < ((currencyKeys.len() as i64) as f64) } {
let mut code: Value = currencyKeys.as_array().and_then(|__arr| match &i { Value::Int(__n) => __arr.get(*__n as usize), Value::Str(__s) => __s.parse::<usize>().ok().and_then(|__n| __arr.get(__n)), _ => None }).cloned().unwrap_or(Value::Null);
let mut currency: Value = get_value(¤ciesData, &code);
let mut currency: Value = get_value(¤ciesData, &code);
if (currency == Value::Null) {
continue;
}
if (codes != Value::Null) && !(self.in_array(code.clone(), codes.clone()).as_bool() == Some(true)) {
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_1105: bool = true;
while { if !__for_first_1105 { j = (match (&(j), &(Value::Int(1))) { (Value::Int(x), Value::Int(y)) => Value::Int(x + y), (Value::Int(x), Value::Float(y)) => Value::Float(*x as f64 + *y), (Value::Float(x), Value::Int(y)) => Value::Float(*x + *y as f64), (Value::Float(x), Value::Float(y)) => Value::Float(x + y), _ => Value::Null }); } __for_first_1105 = false; j.as_f64().unwrap_or(f64::NAN) < ((feeKeys.len() as i64) as f64) } {
let mut feeKey: Value = feeKeys.as_array().and_then(|__arr| match &j { Value::Int(__n) => __arr.get(*__n as usize), Value::Str(__s) => __s.parse::<usize>().ok().and_then(|__n| __arr.get(__n)), _ => None }).cloned().unwrap_or(Value::Null);
let mut fee: Value = self.safe_dict(feesData.clone(), feeKey, &[]);
if ((fee != Value::Null) && (fee != Value::Null)) && is_equal(&fee.as_map().and_then(|__m| __m.get("ticker")).cloned().unwrap_or(Value::Null), &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(), crate::value::get_value_k(¤cyLimits.as_map().and_then(|__m| __m.get("deposit")).cloned().unwrap_or(Value::Null), "min"));
m.insert("max".to_string(), crate::value::get_value_k(¤cyLimits.as_map().and_then(|__m| __m.get("deposit")).cloned().unwrap_or(Value::Null), "max"));
m
}));
m.insert("withdraw".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("min".to_string(), crate::value::get_value_k(¤cyLimits.as_map().and_then(|__m| __m.get("withdraw")).cloned().unwrap_or(Value::Null), "min"));
m.insert("max".to_string(), crate::value::get_value_k(¤cyLimits.as_map().and_then(|__m| __m.get("withdraw")).cloned().unwrap_or(Value::Null), "max"));
m
}));
m
});
// Add fee information if available
if (feeData != Value::Null) {
let mut depositFee: Value = feeData.as_map().and_then(|__m| __m.get("deposit")).cloned().unwrap_or(Value::Null);
let mut withdrawFee: Value = feeData.as_map().and_then(|__m| __m.get("withdraw")).cloned().unwrap_or(Value::Null);
if (depositFee != Value::Null) && (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 (crate::value::get_value_k(&depositFee, "flex") != Value::Null) && (crate::value::get_value_k(&depositFee, "flex") != Value::Null) {
if let Value::Dict(__d) = &mut depositFeeData { std::sync::Arc::make_mut(__d).insert("flex".into(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("min".to_string(), self.safe_number_k(crate::value::get_value_k(&depositFee, "flex"), "min_fee", &[]));
m.insert("max".to_string(), self.safe_number_k(crate::value::get_value_k(&depositFee, "flex"), "max_fee", &[]));
m.insert("percent".to_string(), self.safe_number_k(crate::value::get_value_k(&depositFee, "flex"), "percent", &[]));
m
})); }
}
add_element_to_object(get_value_mut(&mut limits, &Value::Str("deposit".into())), &Value::Str("fee".into()), depositFeeData);
}
if (withdrawFee != Value::Null) && (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 (crate::value::get_value_k(&withdrawFee, "flex") != Value::Null) && (crate::value::get_value_k(&withdrawFee, "flex") != Value::Null) {
if let Value::Dict(__d) = &mut withdrawFeeData { std::sync::Arc::make_mut(__d).insert("flex".into(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("min".to_string(), self.safe_number_k(crate::value::get_value_k(&withdrawFee, "flex"), "min_fee", &[]));
m.insert("max".to_string(), self.safe_number_k(crate::value::get_value_k(&withdrawFee, "flex"), "max_fee", &[]));
m.insert("percent".to_string(), self.safe_number_k(crate::value::get_value_k(&withdrawFee, "flex"), "percent", &[]));
m
})); }
}
add_element_to_object(get_value_mut(&mut limits, &Value::Str("withdraw".into())), &Value::Str("fee".into()), withdrawFeeData);
}
}
// Add network-specific limits if available
if (currency.as_map().and_then(|__m| __m.get("networks")).cloned().unwrap_or(Value::Null) != Value::Null) {
if let Value::Dict(__d) = &mut limits { std::sync::Arc::make_mut(__d).insert("networks".into(), currency.as_map().and_then(|__m| __m.get("networks")).cloned().unwrap_or(Value::Null)); }
}
if let Value::Dict(__d) = &mut result { std::sync::Arc::make_mut(__d).insert(crate::runtime::stringify_param(&code), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("info".to_string(), currency);
m.insert("limits".to_string(), limits);
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 (self.markets.clone() == Value::Null) {
self.load_markets(&[]).await;
}
let mut market: Value = self.market(symbol);
let mut request: Value = Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("market".to_string(), market.as_map().and_then(|__m| __m.get("id")).cloned().unwrap_or(Value::Null));
m
});
let __ws_arg_0 = self.extend(request, &[params]);
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, "result", &[Value::Map({
let mut m = indexmap::IndexMap::new();
m
})]);
return self.parse_ticker(ticker, &[market]);
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".into()), Value::Str("ticker_id".into()), &[]);
market = self.safe_market(&[marketId, market.clone()]);
// last price is provided as "last" or "last_price"
let mut last: Value = self.safe_string_n(ticker.clone(), Value::from(vec![Value::Str("last".into()), Value::Str("last_price".into()), Value::Str("lastPrice".into())]), &[]);
// 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(), market.as_map().and_then(|__m| __m.get("symbol")).cloned().unwrap_or(Value::Null));
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".into()), Value::Str("highestBid".into()), &[]));
m.insert("bidVolume".to_string(), Value::Null);
m.insert("ask".to_string(), self.safe_string2(ticker.clone(), Value::Str("ask".into()), Value::Str("lowestAsk".into()), &[]));
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);
m.insert("last".to_string(), last);
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::from(vec![Value::Str("base_volume".into()), Value::Str("volume".into()), Value::Str("baseVolume24h".into()), Value::Str("stock_volume".into())]), &[]));
m.insert("quoteVolume".to_string(), self.safe_string_n(ticker.clone(), Value::from(vec![Value::Str("quote_volume".into()), Value::Str("deal".into()), Value::Str("quoteVolume24h".into()), Value::Str("money_volume".into())]), &[]));
m.insert("indexPrice".to_string(), self.safe_string_k(ticker.clone(), "index_price", &[]));
m.insert("info".to_string(), ticker);
m
}), &[market]);
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 (self.markets.clone() == 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::from(vec![Value::Str("checkActive".into()), Value::Str("checkExecuted".into())]), &[]);
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 (symbol != Value::Null) {
market = self.market(symbol);
if let Value::Dict(__d) = &mut request { std::sync::Arc::make_mut(__d).insert("market".into(), market.as_map().and_then(|__m| __m.get("id")).cloned().unwrap_or(Value::Null)); }
}
// Try active orders first (if enabled)
if (checkActive.as_bool() == Some(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_1107: bool = true;
while { if !__for_first_1107 { i = (match (&(i), &(Value::Int(1))) { (Value::Int(x), Value::Int(y)) => Value::Int(x + y), (Value::Int(x), Value::Float(y)) => Value::Float(*x as f64 + *y), (Value::Float(x), Value::Int(y)) => Value::Float(*x + *y as f64), (Value::Float(x), Value::Float(y)) => Value::Float(x + y), _ => Value::Null }); } __for_first_1107 = false; i.as_f64().unwrap_or(f64::NAN) < ((orders.len() as i64) as f64) } {
let mut order: Value = orders.as_array().and_then(|__arr| match &i { Value::Int(__n) => __arr.get(*__n as usize), Value::Str(__s) => __s.parse::<usize>().ok().and_then(|__n| __arr.get(__n)), _ => None }).cloned().unwrap_or(Value::Null);
let mut orderId: Value = self.safe_string_k(order.clone(), "orderId", &[]);
if (orderId.as_str() == id.as_str()) {
let mut marketId: Value = self.safe_string_k(order.clone(), "market", &[]);
let mut marketNew: Value = self.safe_market(&[marketId.clone(), Value::Null, Value::Str("_".into())]);
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 !(matches!(&error, Value::Str(__s) if __s.contains("[OrderNotFound]"))) {
panic!("{}", error);
}
} }
}
// Try executed orders (if enabled)
if (checkExecuted.as_bool() == Some(true)) {
let _try_result = futures::FutureExt::catch_unwind(std::panic::AssertUnwindSafe(async {
let __ws_arg_2 = self.extend(request, &[params]);
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_1109: bool = true;
while { if !__for_first_1109 { i = (match (&(i), &(Value::Int(1))) { (Value::Int(x), Value::Int(y)) => Value::Int(x + y), (Value::Int(x), Value::Float(y)) => Value::Float(*x as f64 + *y), (Value::Float(x), Value::Int(y)) => Value::Float(*x + *y as f64), (Value::Float(x), Value::Float(y)) => Value::Float(x + y), _ => Value::Null }); } __for_first_1109 = false; i.as_f64().unwrap_or(f64::NAN) < ((marketIds.len() as i64) as f64) } {
let mut marketId: Value = marketIds.as_array().and_then(|__arr| match &i { Value::Int(__n) => __arr.get(*__n as usize), Value::Str(__s) => __s.parse::<usize>().ok().and_then(|__n| __arr.get(__n)), _ => None }).cloned().unwrap_or(Value::Null);
let mut marketNew: Value = self.safe_market(&[marketId.clone(), Value::Null, Value::Str("_".into())]);
let mut marketOrders: Value = self.safe_list(response.clone(), marketId, &[Value::from(vec![])]);
{
let mut j: Value = Value::Int(0);
let mut __for_first_1108: bool = true;
while { if !__for_first_1108 { j = (match (&(j), &(Value::Int(1))) { (Value::Int(x), Value::Int(y)) => Value::Int(x + y), (Value::Int(x), Value::Float(y)) => Value::Float(*x as f64 + *y), (Value::Float(x), Value::Int(y)) => Value::Float(*x + *y as f64), (Value::Float(x), Value::Float(y)) => Value::Float(x + y), _ => Value::Null }); } __for_first_1108 = false; j.as_f64().unwrap_or(f64::NAN) < ((marketOrders.len() as i64) as f64) } {
let mut order: Value = marketOrders.as_array().and_then(|__arr| match &j { Value::Int(__n) => __arr.get(*__n as usize), Value::Str(__s) => __s.parse::<usize>().ok().and_then(|__n| __arr.get(__n)), _ => None }).cloned().unwrap_or(Value::Null);
let mut orderId: Value = self.safe_string_k(order.clone(), "id", &[]);
if (orderId.as_str() == id.as_str()) {
return self.parse_order(order, &[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 !(matches!(&error, Value::Str(__s) if __s.contains("[OrderNotFound]"))) {
panic!("{}", error);
}
} }
}
panic!("{}", crate::exchange_errors::order_not_found(format!("{}{}", Value::Str(format!("{}{}", self.id.clone(), Value::Str(" fetchOrder() order not found: ".into())).into()), 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 (self.markets.clone() == Value::Null) {
self.load_markets(&[]).await;
}
symbols = self.market_symbols(&[symbols.clone()]);
let mut onlyContractSymbols: bool = true;
if (symbols != Value::Null) {
{
let mut i: Value = Value::Int(0);
let mut __for_first_1110: bool = true;
while { if !__for_first_1110 { i = (match (&(i), &(Value::Int(1))) { (Value::Int(x), Value::Int(y)) => Value::Int(x + y), (Value::Int(x), Value::Float(y)) => Value::Float(*x as f64 + *y), (Value::Float(x), Value::Int(y)) => Value::Float(*x + *y as f64), (Value::Float(x), Value::Float(y)) => Value::Float(x + y), _ => Value::Null }); } __for_first_1110 = false; i.as_f64().unwrap_or(f64::NAN) < ((symbols.len() as i64) as f64) } {
let mut symbol: Value = symbols.as_array().and_then(|__arr| match &i { Value::Int(__n) => __arr.get(*__n as usize), Value::Str(__s) => __s.parse::<usize>().ok().and_then(|__n| __arr.get(__n)), _ => None }).cloned().unwrap_or(Value::Null);
let mut market: Value = self.market(symbol.clone());
if (market.as_map().and_then(|__m| __m.get("contract")).cloned().unwrap_or(Value::Null).as_bool() != Some(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".into()), &[Value::Null, params.clone()]); marketType = __destr_tmp.as_array().and_then(|__arr| __arr.get(0)).cloned().unwrap_or(Value::Null); params = __destr_tmp.as_array().and_then(|__arr| __arr.get(1)).cloned().unwrap_or(Value::Null); }
let mut method: Value = Value::Null;
{ let __destr_tmp = self.handle_option_and_params(params.clone(), Value::Str("fetchTickers".into()), Value::Str("method".into()), &[method.clone()]); method = __destr_tmp.as_array().and_then(|__arr| __arr.get(0)).cloned().unwrap_or(Value::Null); params = __destr_tmp.as_array().and_then(|__arr| __arr.get(1)).cloned().unwrap_or(Value::Null); }
if (method == Value::Null) {
// if the user did not specify a method, choose it based on market type and symbols
if onlyContractSymbols || (marketType.as_str() == Some("swap")) {
method = Value::Str("v4PublicGetFutures".into());
} else {
method = Value::Str("v4PublicGetTicker".into());
}
}
let mut response: Value = Value::Null;
if (method.as_str() == Some("v4PublicGetTicker")) {
//
// "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 (method.as_str() == Some("v4PublicGetFutures")) {
//
// {
// "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]).await;
}
let mut resultList: Value = self.safe_list_k(response.clone(), "result", &[]);
if (resultList != Value::Null) {
return self.parse_tickers(resultList, &[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_1111: bool = true;
while { if !__for_first_1111 { i = (match (&(i), &(Value::Int(1))) { (Value::Int(x), Value::Int(y)) => Value::Int(x + y), (Value::Int(x), Value::Float(y)) => Value::Float(*x as f64 + *y), (Value::Float(x), Value::Int(y)) => Value::Float(*x + *y as f64), (Value::Float(x), Value::Float(y)) => Value::Float(x + y), _ => Value::Null }); } __for_first_1111 = false; i.as_f64().unwrap_or(f64::NAN) < ((marketIds.len() as i64) as f64) } {
let mut marketId: Value = marketIds.as_array().and_then(|__arr| match &i { Value::Int(__n) => __arr.get(*__n as usize), Value::Str(__s) => __s.parse::<usize>().ok().and_then(|__n| __arr.get(__n)), _ => None }).cloned().unwrap_or(Value::Null);
let mut market: Value = self.safe_market(&[marketId.clone()]);
let mut ticker: Value = self.parse_ticker(get_value(&response, &marketId), &[market]);
let mut symbol: Value = ticker.as_map().and_then(|__m| __m.get("symbol")).cloned().unwrap_or(Value::Null);
if let Value::Dict(__d) = &mut result { std::sync::Arc::make_mut(__d).insert(crate::runtime::stringify_param(&symbol), ticker); }
}
}
return self.filter_by_array_tickers(result, Value::Str("symbol".into()), &[symbols]);
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 (self.markets.clone() == 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(), market.as_map().and_then(|__m| __m.get("id")).cloned().unwrap_or(Value::Null));
m
});
if (limit != Value::Null) {
if let Value::Dict(__d) = &mut request { std::sync::Arc::make_mut(__d).insert("limit".into(), limit); }; // default = 100, maximum = 100
}
let __ws_arg_3 = self.extend(request, &[params]);
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_k(response.clone(), "timestamp", &[]);
return self.parse_order_book(response, symbol, &[timestamp]);
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 (self.markets.clone() == Value::Null) {
self.load_markets(&[]).await;
}
let mut market: Value = self.market(symbol);
let mut request: Value = Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("market".to_string(), market.as_map().and_then(|__m| __m.get("id")).cloned().unwrap_or(Value::Null));
m
});
let __ws_arg_4 = self.extend(request, &[params]);
let mut response: Value = self.v4_public_get_trades_market(&[__ws_arg_4]).await;
return self.parse_trades(response, &[market, since, limit]);
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 (self.markets.clone() == 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 (symbol != Value::Null) {
market = self.market(symbol);
if let Value::Dict(__d) = &mut request { std::sync::Arc::make_mut(__d).insert("market".into(), market.as_map().and_then(|__m| __m.get("id")).cloned().unwrap_or(Value::Null)); }
}
let __ws_arg_5 = self.extend(request, &[params]);
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 (matches!(&response, Value::Arr(_))) {
return self.parse_trades(response.clone(), &[market, since.clone(), limit.clone()]);
} else {
let mut results: Value = Value::from(vec![]);
let mut keys: Value = object_keys(&response);
{
let mut i: Value = Value::Int(0);
let mut __for_first_1112: bool = true;
while { if !__for_first_1112 { i = (match (&(i), &(Value::Int(1))) { (Value::Int(x), Value::Int(y)) => Value::Int(x + y), (Value::Int(x), Value::Float(y)) => Value::Float(*x as f64 + *y), (Value::Float(x), Value::Int(y)) => Value::Float(*x + *y as f64), (Value::Float(x), Value::Float(y)) => Value::Float(x + y), _ => Value::Null }); } __for_first_1112 = false; i.as_f64().unwrap_or(f64::NAN) < ((keys.len() as i64) as f64) } {
let mut marketId: Value = keys.as_array().and_then(|__arr| match &i { Value::Int(__n) => __arr.get(*__n as usize), Value::Str(__s) => __s.parse::<usize>().ok().and_then(|__n| __arr.get(__n)), _ => None }).cloned().unwrap_or(Value::Null);
let mut marketNew: Value = self.safe_market(&[marketId.clone(), Value::Null, Value::Str("_".into())]);
let mut rawTrades: Value = self.safe_list(response.clone(), marketId, &[Value::from(vec![])]);
let mut parsed: Value = self.parse_trades(rawTrades, &[marketNew, since.clone(), limit.clone()]);
results = self.array_concat(results.clone(), parsed);
}
}
results = self.sort_by2(results.clone(), Value::Str("timestamp".into()), Value::Str("id".into()), &[]);
return self.filter_by_since_limit(results, &[since, limit, Value::Str("timestamp".into())]);
}
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".into()), Value::Str("trade_timestamp".into()), &[]);
let mut orderId: Value = self.safe_string2(trade.clone(), Value::Str("dealOrderId".into()), Value::Str("orderId".into()), &[]);
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".into()), Value::Str("quote_volume".into()), &[]);
let mut id: Value = self.safe_string2(trade.clone(), Value::Str("id".into()), Value::Str("tradeID".into()), &[]);
let mut side: Value = self.safe_string2(trade.clone(), Value::Str("type".into()), Value::Str("side".into()), &[]);
let mut symbol: Value = market.as_map().and_then(|__m| __m.get("symbol")).cloned().unwrap_or(Value::Null);
let mut role: Option<i64> = self.safe_integer_k(trade.clone(), "role", &[]).as_i64();
let mut takerOrMaker: Value = Value::Null;
if (role.is_some()) {
takerOrMaker = (if (role == Some(1)) { Value::Str("maker".into()) } else { Value::Str("taker".into()) });
}
let mut fee: Value = Value::Null;
let mut feeCost: Value = self.safe_string_k(trade.clone(), "fee", &[]);
if (feeCost != Value::Null) {
fee = Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), feeCost);
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);
m.insert("timestamp".to_string(), timestamp.clone());
m.insert("datetime".to_string(), self.iso8601(timestamp));
m.insert("symbol".to_string(), symbol);
m.insert("id".to_string(), id);
m.insert("order".to_string(), orderId);
m.insert("type".to_string(), Value::Null);
m.insert("takerOrMaker".to_string(), takerOrMaker);
m.insert("side".to_string(), side);
m.insert("price".to_string(), price);
m.insert("amount".to_string(), amount);
m.insert("cost".to_string(), cost);
m.insert("fee".to_string(), fee);
m
}), &[market]);
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".into()));
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 (self.markets.clone() == Value::Null) {
self.load_markets(&[]).await;
}
let mut market: Value = self.market(symbol);
let mut request: Value = Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("market".to_string(), market.as_map().and_then(|__m| __m.get("id")).cloned().unwrap_or(Value::Null));
m.insert("interval".to_string(), self.safe_string(self.timeframes.clone(), timeframe.clone(), &[timeframe.clone()]));
m
});
if (since != Value::Null) {
let mut maxLimit: Value = Value::Int(1440);
if (limit == Value::Null) {
limit = maxLimit.clone();
}
limit = crate::runtime::Math::min(&limit, &maxLimit);
let mut start: Value = self.parse_to_int((match ((since).as_f64(), (Value::Int(1000)).as_f64()) { (Some(x), Some(y)) if y != 0.0 => Value::Float(x / y), _ => Value::Null }));
if let Value::Dict(__d) = &mut request { std::sync::Arc::make_mut(__d).insert("start".into(), start); }
}
if (limit != Value::Null) {
if let Value::Dict(__d) = &mut request { std::sync::Arc::make_mut(__d).insert("limit".into(), crate::runtime::Math::min(&limit, &Value::Int(1440))); }
}
let __ws_arg_6 = self.extend(request, &[params]);
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, "result", &[Value::from(vec![])]);
return self.parse_ohlc_vs(result, &[market, timeframe, since, limit]);
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::from(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, 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]).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(), (if (status.as_str() == Some("pong")) { Value::Str("ok".into()) } else { status }));
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);
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]).await;
return self.safe_integer_product_k(response, "time", 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);
m
});
let __ws_arg_7 = self.extend(req, &[params]);
return self.create_order(symbol, Value::Str("market".into()), side, 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, Value::Str("buy".into()), cost, &[params]).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 (self.markets.clone() == 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(), market.as_map().and_then(|__m| __m.get("id")).cloned().unwrap_or(Value::Null));
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".into()), &[]); cost = __destr_tmp.as_array().and_then(|__arr| __arr.get(0)).cloned().unwrap_or(Value::Null); params = __destr_tmp.as_array().and_then(|__arr| __arr.get(1)).cloned().unwrap_or(Value::Null); }
if (cost != Value::Null) {
if (side.as_str() != Some("buy")) || (type_var.as_str() != Some("market")) {
panic!("{}", crate::exchange_errors::invalid_order(format!("{}{}", self.id.clone(), Value::Str(" createOrder() cost is only supported for market buy orders".into()))));
}
if let Value::Dict(__d) = &mut request { std::sync::Arc::make_mut(__d).insert("amount".into(), self.cost_to_precision(symbol.clone(), cost.clone())); }
} else {
if let Value::Dict(__d) = &mut request { std::sync::Arc::make_mut(__d).insert("amount".into(), self.amount_to_precision(symbol.clone(), amount)); }
}
let mut clientOrderId: Value = self.safe_string2(params.clone(), Value::Str("clOrdId".into()), Value::Str("clientOrderId".into()), &[]);
if (clientOrderId == Value::Null) {
let mut brokerId: Value = self.safe_string_k(self.options.clone(), "brokerId", &[]);
if (brokerId != Value::Null) {
if let Value::Dict(__d) = &mut request { std::sync::Arc::make_mut(__d).insert("clientOrderId".into(), Value::Str(format!("{}{}", brokerId, self.uuid16(&[])).into())); }
}
} else {
if let Value::Dict(__d) = &mut request { std::sync::Arc::make_mut(__d).insert("clientOrderId".into(), clientOrderId); }
params = self.omit(params.clone(), Value::from(vec![Value::Str("clientOrderId".into())]), &[]);
}
let mut marketType: Option<String> = self.safe_string_k(market, "type", &[]).as_str().map(str::to_owned);
let mut isLimitOrder: bool = type_var.as_str() == Some("limit");
let mut isMarketOrder: Value = Value::Bool(type_var.as_str() == Some("market"));
let mut triggerPrice: Value = self.safe_number_n(params.clone(), Value::from(vec![Value::Str("triggerPrice".into()), Value::Str("stopPrice".into()), Value::Str("activation_price".into())]), &[]);
let mut isStopOrder: bool = triggerPrice != Value::Null;
let mut timeInForce: Value = self.safe_string_upper_k(params.clone(), "timeInForce", &[]);
if (timeInForce != Value::Null) && (timeInForce.as_str() != Some("GTC")) && (timeInForce.as_str() != Some("IOC")) && (timeInForce.as_str() != Some("PO")) {
panic!("{}", crate::exchange_errors::not_supported(format!("{}{}", Value::Str(format!("{}{}", Value::Str(format!("{}{}", self.id.clone(), Value::Str(" createOrder() does not support timeInForce ".into())).into()), timeInForce).into()), Value::Str(", only GTC, IOC and PO are allowed".into()))));
}
let mut postOnly: Value = self.is_post_only(isMarketOrder, Value::Bool(false), &[params.clone()]);
let mut ioc: bool = timeInForce.as_str() == Some("IOC");
if isStopOrder && (is_true(&postOnly) || ioc) {
panic!("{}", crate::exchange_errors::not_supported(format!("{}{}", self.id.clone(), Value::Str(" createOrder() does not support postOnly or timeInForce IOC for stop orders".into()))));
}
if ioc && !isLimitOrder {
panic!("{}", crate::exchange_errors::not_supported(format!("{}{}", self.id.clone(), Value::Str(" createOrder() timeInForce IOC is only supported for limit orders".into()))));
}
let mut marginModequeryVariable = self.handle_margin_mode_and_params(Value::Str("createOrder".into()), &[params.clone()]);
let mut marginMode: Value = marginModequeryVariable.as_array().and_then(|__arr| __arr.get(0)).cloned().unwrap_or(Value::Null);
let mut query: Value = marginModequeryVariable.as_array().and_then(|__arr| __arr.get(1)).cloned().unwrap_or(Value::Null);
if is_true(&postOnly) {
if let Value::Dict(__d) = &mut request { std::sync::Arc::make_mut(__d).insert("postOnly".into(), Value::Bool(true)); }
}
if ioc {
if let Value::Dict(__d) = &mut request { std::sync::Arc::make_mut(__d).insert("ioc".into(), Value::Bool(true)); }
}
if (marginMode != Value::Null) && (marginMode.as_str() != Some("cross")) {
panic!("{}", crate::exchange_errors::not_supported(format!("{}{}", self.id.clone(), Value::Str(" createOrder() is only available for cross margin".into()))));
}
params = self.omit(query, Value::from(vec![Value::Str("postOnly".into()), Value::Str("triggerPrice".into()), Value::Str("stopPrice".into()), Value::Str("timeInForce".into())]), &[]);
let mut useCollateralEndpoint: bool = (marginMode != Value::Null) || (marketType.as_deref() == Some("swap"));
let mut response: Value = Value::Null;
if isStopOrder {
if let Value::Dict(__d) = &mut request { std::sync::Arc::make_mut(__d).insert("activation_price".into(), self.price_to_precision(symbol.clone(), triggerPrice)); }
if isLimitOrder {
// stop limit order
if let Value::Dict(__d) = &mut request { std::sync::Arc::make_mut(__d).insert("price".into(), 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 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 isLimitOrder {
// limit order
if let Value::Dict(__d) = &mut request { std::sync::Arc::make_mut(__d).insert("price".into(), self.price_to_precision(symbol, price)); }
if 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 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 (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, &[params]);
response = self.v4_private_post_order_stock_market(&[__ws_arg_15]).await;
}
}
}
}
return self.parse_order(response, &[]);
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 (self.markets.clone() == 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(), market.as_map().and_then(|__m| __m.get("id")).cloned().unwrap_or(Value::Null));
m
});
// Handle clientOrderId vs orderId (clientOrderId takes priority)
let mut clientOrderId: Value = self.safe_string_k(params.clone(), "clientOrderId", &[]);
if (clientOrderId != Value::Null) {
if let Value::Dict(__d) = &mut request { std::sync::Arc::make_mut(__d).insert("clientOrderId".into(), clientOrderId); }
} else {
if let Value::Dict(__d) = &mut request { std::sync::Arc::make_mut(__d).insert("orderId".into(), id.clone()); }
}
// Handle amount vs total parameter based on order type and side
let mut triggerPrice: Value = self.safe_number_n(params.clone(), Value::from(vec![Value::Str("triggerPrice".into()), Value::Str("stopPrice".into()), Value::Str("activationPrice".into())]), &[]);
let mut isStopOrder: bool = triggerPrice != Value::Null;
// Handle activation price for stop orders
if isStopOrder {
if let Value::Dict(__d) = &mut request { std::sync::Arc::make_mut(__d).insert("activation_price".into(), self.price_to_precision(symbol.clone(), triggerPrice.clone())); }
}
let mut isLimitOrder: bool = type_var.as_str() == Some("limit");
let mut total: Value = self.safe_number_k(params.clone(), "total", &[]);
if (total != Value::Null) {
if let Value::Dict(__d) = &mut request { std::sync::Arc::make_mut(__d).insert("total".into(), self.amount_to_precision(symbol.clone(), total.clone())); }
} else if (amount != Value::Null) {
if isLimitOrder {
// Limit orders always use amount parameter
if let Value::Dict(__d) = &mut request { std::sync::Arc::make_mut(__d).insert("amount".into(), self.amount_to_precision(symbol.clone(), amount.clone())); }
} else if (type_var.as_str() == Some("market")) && (side.as_str() == Some("buy")) {
// Market buy orders use total parameter
if let Value::Dict(__d) = &mut request { std::sync::Arc::make_mut(__d).insert("total".into(), self.amount_to_precision(symbol.clone(), amount.clone())); }
} else {
// Market sell orders use amount parameter
if let Value::Dict(__d) = &mut request { std::sync::Arc::make_mut(__d).insert("amount".into(), self.amount_to_precision(symbol.clone(), amount.clone())); }
}
}
// Handle price parameter for limit orders
if (price != Value::Null) {
if let Value::Dict(__d) = &mut request { std::sync::Arc::make_mut(__d).insert("price".into(), self.price_to_precision(symbol, price.clone())); }
}
// Ensure at least one modifiable parameter is provided
let mut hasModifiableParam: bool = (amount != Value::Null) || (price != Value::Null) || (triggerPrice != Value::Null) || (total != Value::Null);
if !hasModifiableParam {
panic!("{}", crate::exchange_errors::arguments_required(format!("{}{}", self.id.clone(), Value::Str(" editOrder() requires at least one of: amount, price, activationPrice, or total parameters".into()))));
}
params = self.omit(params.clone(), Value::from(vec![Value::Str("clientOrderId".into()), Value::Str("triggerPrice".into()), Value::Str("stopPrice".into()), Value::Str("activationPrice".into()), Value::Str("total".into())]), &[]);
let __ws_arg_16 = self.extend(request, &[params]);
let mut response: Value = self.v4_private_post_order_modify(&[__ws_arg_16]).await;
return self.parse_order(response, &[]);
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 (symbol == Value::Null) {
panic!("{}", crate::exchange_errors::arguments_required(format!("{}{}", self.id.clone(), Value::Str(" cancelOrder() requires a symbol argument".into()))));
}
if (self.markets.clone() == Value::Null) {
self.load_markets(&[]).await;
}
let mut market: Value = self.market(symbol);
let mut request: Value = Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("market".to_string(), market.as_map().and_then(|__m| __m.get("id")).cloned().unwrap_or(Value::Null));
m.insert("orderId".to_string(), (match &id { Value::Str(__parse_s) => __parse_s.trim().parse::<i64>().map(Value::Int).unwrap_or(Value::Null), Value::Int(__parse_n) => Value::Int(*__parse_n), Value::Float(__parse_f) => Value::Int(*__parse_f as i64), _ => Value::Null }));
m
});
let __ws_arg_17 = self.extend(request, &[params]);
let mut response: Value = self.v4_private_post_order_cancel(&[__ws_arg_17]).await;
return self.parse_order(response, &[]);
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 (self.markets.clone() == 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 (symbol != Value::Null) {
market = self.market(symbol);
if let Value::Dict(__d) = &mut request { std::sync::Arc::make_mut(__d).insert("market".into(), market.as_map().and_then(|__m| __m.get("id")).cloned().unwrap_or(Value::Null)); }
}
let mut type_var: Value = Value::Null;
{ let __destr_tmp = self.handle_market_type_and_params(Value::Str("cancelAllOrders".into()), &[market.clone(), params.clone()]); type_var = __destr_tmp.as_array().and_then(|__arr| __arr.get(0)).cloned().unwrap_or(Value::Null); params = __destr_tmp.as_array().and_then(|__arr| __arr.get(1)).cloned().unwrap_or(Value::Null); }
let mut requestType: Value = Value::from(vec![]);
if (type_var.as_str() == Some("spot")) {
let mut isMargin: Value = Value::Null;
{ let __destr_tmp = self.handle_option_and_params(params.clone(), Value::Str("cancelAllOrders".into()), Value::Str("isMargin".into()), &[Value::Bool(false)]); isMargin = __destr_tmp.as_array().and_then(|__arr| __arr.get(0)).cloned().unwrap_or(Value::Null); params = __destr_tmp.as_array().and_then(|__arr| __arr.get(1)).cloned().unwrap_or(Value::Null); }
if is_true(&isMargin) {
append_to_array(&mut requestType, Value::Str("margin".into()));
} else {
append_to_array(&mut requestType, Value::Str("spot".into()));
}
} else if (type_var.as_str() == Some("swap")) {
append_to_array(&mut requestType, Value::Str("futures".into()));
} else {
panic!("{}", crate::exchange_errors::not_supported(format!("{}{}", Value::Str(format!("{}{}", Value::Str(format!("{}{}", self.id.clone(), Value::Str(" cancelAllOrders() does not support ".into())).into()), type_var).into()), Value::Str(" type".into()))));
}
if let Value::Dict(__d) = &mut request { std::sync::Arc::make_mut(__d).insert("type".into(), requestType); }
let __ws_arg_18 = self.extend(request, &[params]);
let mut response: Value = self.v4_private_post_order_cancel_all(&[__ws_arg_18]).await;
return self.parse_orders(response, &[market]);
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 (self.markets.clone() == Value::Null) {
self.load_markets(&[]).await;
}
// Fetch both open and closed orders in parallel
let mut openOrdersclosedOrdersVariable = promise_all(&Value::from(vec![self.fetch_open_orders(&[symbol.clone(), since.clone(), limit.clone(), params.clone()]).await, self.fetch_closed_orders(&[symbol, since, limit.clone(), params]).await])).await;
let mut openOrders: Value = openOrdersclosedOrdersVariable.as_array().and_then(|__arr| __arr.get(0)).cloned().unwrap_or(Value::Null);
let mut closedOrders: Value = openOrdersclosedOrdersVariable.as_array().and_then(|__arr| __arr.get(1)).cloned().unwrap_or(Value::Null);
let mut allOrders: Value = self.array_concat(openOrders, closedOrders);
// Sort by timestamp (most recent first)
let mut sortedOrders: Value = self.sort_by(allOrders, Value::Str("timestamp".into()), &[Value::Bool(true)]);
// Apply limit if specified (since and symbol filtering already handled by individual methods)
if (limit != Value::Null) && ((sortedOrders.len() as i64) as f64) > limit.as_f64().unwrap_or(f64::NAN) {
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 (self.markets.clone() == Value::Null) {
self.load_markets(&[]).await;
}
let mut symbol: Value = self.safe_string_k(params.clone(), "symbol", &[]);
if (symbol == Value::Null) {
panic!("{}", crate::exchange_errors::arguments_required(format!("{}{}", self.id.clone(), Value::Str(" cancelAllOrdersAfter() requires a symbol argument in params".into()))));
}
let mut market: Value = self.market(symbol);
params = self.omit(params.clone(), Value::Str("symbol".into()), &[]);
if (timeout == Value::Null) {
panic!("{}", crate::exchange_errors::exchange_error(format!("{}{}", self.id.clone(), Value::Str(" cancelAllOrdersAfter() missing timeout".into()))));
}
let mut isBiggerThanZero: bool = timeout.as_f64().unwrap_or(f64::NAN) > ((0i64) as f64);
let mut request: Value = Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("market".to_string(), market.as_map().and_then(|__m| __m.get("id")).cloned().unwrap_or(Value::Null));
m
});
if isBiggerThanZero {
if let Value::Dict(__d) = &mut request { std::sync::Arc::make_mut(__d).insert("timeout".into(), self.number_to_string((match ((timeout).as_f64(), (Value::Int(1000)).as_f64()) { (Some(x), Some(y)) if y != 0.0 => Value::Float(x / y), _ => Value::Null }))); }
} else {
if let Value::Dict(__d) = &mut request { std::sync::Arc::make_mut(__d).insert("timeout".into(), Value::Str("null".into())); }
}
let __ws_arg_19 = self.extend(request, &[params]);
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_1113: bool = true;
while { if !__for_first_1113 { i = (match (&(i), &(Value::Int(1))) { (Value::Int(x), Value::Int(y)) => Value::Int(x + y), (Value::Int(x), Value::Float(y)) => Value::Float(*x as f64 + *y), (Value::Float(x), Value::Int(y)) => Value::Float(*x + *y as f64), (Value::Float(x), Value::Float(y)) => Value::Float(x + y), _ => Value::Null }); } __for_first_1113 = false; i.as_f64().unwrap_or(f64::NAN) < ((balanceKeys.len() as i64) as f64) } {
let mut id: Value = balanceKeys.as_array().and_then(|__arr| match &i { Value::Int(__n) => __arr.get(*__n as usize), Value::Str(__s) => __s.parse::<usize>().ok().and_then(|__n| __arr.get(__n)), _ => None }).cloned().unwrap_or(Value::Null);
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 (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".into()), self.safe_string2(balance.clone(), Value::Str("available".into()), Value::Str("main_balance".into()), &[]));
add_element_to_object(&mut account, &Value::Str("used".into()), self.safe_string_k(balance.clone(), "freeze", &[]));
add_element_to_object(&mut account, &Value::Str("total".into()), self.safe_string_k(balance.clone(), "main_balance", &[]));
if (code != Value::Null) {
if let Value::Dict(__d) = &mut result { std::sync::Arc::make_mut(__d).insert(crate::runtime::stringify_param(&code), account.clone()); }
}
} else {
let mut account: Value = self.account();
add_element_to_object(&mut account, &Value::Str("total".into()), balance);
if (code != Value::Null) {
if let Value::Dict(__d) = &mut result { std::sync::Arc::make_mut(__d).insert(crate::runtime::stringify_param(&code), account); }
}
}
}
}
return self.safe_balance(result);
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 (self.markets.clone() == Value::Null) {
self.load_markets(&[]).await;
}
let mut marketType: Value = Value::Null;
{ let __destr_tmp = self.handle_market_type_and_params(Value::Str("fetchBalance".into()), &[Value::Null, params.clone()]); marketType = __destr_tmp.as_array().and_then(|__arr| __arr.get(0)).cloned().unwrap_or(Value::Null); params = __destr_tmp.as_array().and_then(|__arr| __arr.get(1)).cloned().unwrap_or(Value::Null); }
let mut response: Value = Value::Null;
if (marketType.as_str() == Some("swap")) {
response = self.v4_private_post_collateral_account_balance(&[params.clone()]).await;
} else {
let mut options: Value = self.safe_dict_k(self.options.clone(), "fetchBalance", &[Value::Map({
let mut m = indexmap::IndexMap::new();
m
})]);
let mut defaultAccount: Value = self.safe_string_k(options, "account", &[]);
let mut account: Option<String> = self.safe_string2(params.clone(), Value::Str("account".into()), Value::Str("type".into()), &[defaultAccount]).as_str().map(str::to_owned);
params = self.omit(params.clone(), Value::from(vec![Value::Str("account".into()), Value::Str("type".into())]), &[]);
if (account.as_deref() == Some("main")) || (account.as_deref() == Some("funding")) {
response = self.v4_private_post_main_account_balance(&[params.clone()]).await;
} else {
response = self.v4_private_post_trade_account_balance(&[params]).await;
}
}
return self.parse_balance(response);
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 (self.markets.clone() == 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 (symbol != Value::Null) {
market = self.market(symbol);
if let Value::Dict(__d) = &mut request { std::sync::Arc::make_mut(__d).insert("market".into(), market.as_map().and_then(|__m| __m.get("id")).cloned().unwrap_or(Value::Null)); }
}
if (limit != Value::Null) {
if let Value::Dict(__d) = &mut request { std::sync::Arc::make_mut(__d).insert("limit".into(), crate::runtime::Math::min(&limit, &Value::Int(100))); }
}
let __ws_arg_20 = self.extend(request, &[params]);
let mut response: Value = self.v4_private_post_orders(&[__ws_arg_20]).await;
return self.parse_orders(response, &[market, since, limit, Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("status".to_string(), Value::Str("open".into()));
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 (self.markets.clone() == 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 (symbol != Value::Null) {
market = self.market(symbol.clone());
symbol = market.as_map().and_then(|__m| __m.get("symbol")).cloned().unwrap_or(Value::Null);
if let Value::Dict(__d) = &mut request { std::sync::Arc::make_mut(__d).insert("market".into(), market.as_map().and_then(|__m| __m.get("id")).cloned().unwrap_or(Value::Null)); }
}
if (limit != Value::Null) {
if let Value::Dict(__d) = &mut request { std::sync::Arc::make_mut(__d).insert("limit".into(), crate::runtime::Math::min(&limit, &Value::Int(100))); }; // default 50 max 100
}
let __ws_arg_21 = self.extend(request, &[params]);
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::from(vec![]);
{
let mut i: Value = Value::Int(0);
let mut __for_first_1115: bool = true;
while { if !__for_first_1115 { i = (match (&(i), &(Value::Int(1))) { (Value::Int(x), Value::Int(y)) => Value::Int(x + y), (Value::Int(x), Value::Float(y)) => Value::Float(*x as f64 + *y), (Value::Float(x), Value::Int(y)) => Value::Float(*x + *y as f64), (Value::Float(x), Value::Float(y)) => Value::Float(x + y), _ => Value::Null }); } __for_first_1115 = false; i.as_f64().unwrap_or(f64::NAN) < ((marketIds.len() as i64) as f64) } {
let mut marketId: Value = marketIds.as_array().and_then(|__arr| match &i { Value::Int(__n) => __arr.get(*__n as usize), Value::Str(__s) => __s.parse::<usize>().ok().and_then(|__n| __arr.get(__n)), _ => None }).cloned().unwrap_or(Value::Null);
let mut marketNew: Value = self.safe_market(&[marketId.clone(), Value::Null, Value::Str("_".into())]);
let mut orders: Value = self.safe_list(response.clone(), marketId, &[Value::from(vec![])]);
{
let mut j: Value = Value::Int(0);
let mut __for_first_1114: bool = true;
while { if !__for_first_1114 { j = (match (&(j), &(Value::Int(1))) { (Value::Int(x), Value::Int(y)) => Value::Int(x + y), (Value::Int(x), Value::Float(y)) => Value::Float(*x as f64 + *y), (Value::Float(x), Value::Int(y)) => Value::Float(*x + *y as f64), (Value::Float(x), Value::Float(y)) => Value::Float(x + y), _ => Value::Null }); } __for_first_1114 = false; j.as_f64().unwrap_or(f64::NAN) < ((orders.len() as i64) as f64) } {
let mut order: Value = self.parse_order(orders.as_array().and_then(|__arr| match &j { Value::Int(__n) => __arr.get(*__n as usize), Value::Str(__s) => __s.parse::<usize>().ok().and_then(|__n| __arr.get(__n)), _ => None }).cloned().unwrap_or(Value::Null), &[marketNew.clone()]);
append_to_array(&mut results, self.extend(order, &[Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("status".to_string(), Value::Str("closed".into()));
m
})]));
}
}
}
}
results = self.sort_by(results.clone(), Value::Str("timestamp".into()), &[]);
results = self.filter_by_symbol_since_limit(results.clone(), &[symbol, since, limit]);
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".into()));
m.insert("market".to_string(), Value::Str("market".into()));
m.insert("stop market".to_string(), Value::Str("market".into()));
m.insert("stop limit".to_string(), Value::Str("limit".into()));
m.insert("stock market".to_string(), Value::Str("market".into()));
m.insert("margin limit".to_string(), Value::Str("limit".into()));
m.insert("margin market".to_string(), Value::Str("market".into()));
m
});
return self.safe_string(types, 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, market.clone(), Value::Str("_".into())]);
let mut symbol: Value = market.as_map().and_then(|__m| __m.get("symbol")).cloned().unwrap_or(Value::Null);
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 (clientOrderId.as_str() == Some("")) {
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".into()), Value::Str("id".into()), &[]);
let mut type_var: Value = self.safe_string_k(order.clone(), "type", &[]);
let mut orderType: Value = self.parse_order_type(type_var.clone());
if (orderType.as_str() == Some("market")) {
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 (side.as_str() == Some("buy")) && ((type_var.as_str() == Some("market")) || (type_var.as_str() == Some("stop market"))) {
amount = filled.clone();
}
let mut dealFee: Value = self.safe_string_k(order.clone(), "dealFee", &[]);
let mut fee: Value = Value::Null;
if (dealFee != Value::Null) {
fee = Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), self.parse_number(dealFee, &[]));
m.insert("currency".to_string(), market.as_map().and_then(|__m| __m.get("quote")).cloned().unwrap_or(Value::Null));
m
});
}
let mut timestamp: Value = self.safe_timestamp2(order.clone(), Value::Str("ctime".into()), Value::Str("timestamp".into()), &[]);
let mut lastTradeTimestamp: Value = self.safe_timestamp_k(order.clone(), "ftime", &[]);
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 (ioc.as_bool() == Some(true)) {
timeInForce = Value::Str("IOC".into());
} else if (postOnly.as_bool() == Some(true)) {
timeInForce = Value::Str("PO".into());
}
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);
m.insert("symbol".to_string(), symbol);
m.insert("clientOrderId".to_string(), clientOrderId);
m.insert("timestamp".to_string(), timestamp.clone());
m.insert("datetime".to_string(), self.iso8601(timestamp));
m.insert("lastTradeTimestamp".to_string(), lastTradeTimestamp);
m.insert("timeInForce".to_string(), timeInForce);
m.insert("postOnly".to_string(), postOnly);
m.insert("status".to_string(), self.parse_order_status(self.safe_string_k(order, "status", &[])));
m.insert("side".to_string(), side);
m.insert("price".to_string(), price);
m.insert("type".to_string(), orderType);
m.insert("triggerPrice".to_string(), triggerPrice);
m.insert("amount".to_string(), amount);
m.insert("filled".to_string(), filled);
m.insert("remaining".to_string(), remaining);
m.insert("average".to_string(), Value::Null);
m.insert("cost".to_string(), cost);
m.insert("fee".to_string(), fee);
m.insert("trades".to_string(), Value::Null);
m
}), &[market]);
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".into()));
m.insert("OPEN".to_string(), Value::Str("open".into()));
m.insert("PARTIALLY_FILLED".to_string(), Value::Str("open".into()));
m.insert("FILLED".to_string(), Value::Str("closed".into()));
m
});
return self.safe_string_lower(statuses, 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 (self.markets.clone() == Value::Null) {
self.load_markets(&[]).await;
}
let mut request: Value = Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("orderId".to_string(), (match &id { Value::Str(__parse_s) => __parse_s.trim().parse::<i64>().map(Value::Int).unwrap_or(Value::Null), Value::Int(__parse_n) => Value::Int(*__parse_n), Value::Float(__parse_f) => Value::Int(*__parse_f as i64), _ => Value::Null }));
m
});
let mut market: Value = Value::Null;
if (symbol != Value::Null) {
market = self.market(symbol);
if let Value::Dict(__d) = &mut request { std::sync::Arc::make_mut(__d).insert("market".into(), market.as_map().and_then(|__m| __m.get("id")).cloned().unwrap_or(Value::Null)); }
}
if (limit != Value::Null) {
if let Value::Dict(__d) = &mut request { std::sync::Arc::make_mut(__d).insert("limit".into(), crate::runtime::Math::min(&limit, &Value::Int(100))); }
}
let __ws_arg_22 = self.extend(request, &[params]);
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, "records", &[Value::from(vec![])]);
return self.parse_trades(data, &[market]);
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 (self.markets.clone() == 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 (code != Value::Null) {
currency = self.currency(code);
if let Value::Dict(__d) = &mut request { std::sync::Arc::make_mut(__d).insert("ticker".into(), currency.as_map().and_then(|__m| __m.get("id")).cloned().unwrap_or(Value::Null)); }
}
if (since != Value::Null) {
if let Value::Dict(__d) = &mut request { std::sync::Arc::make_mut(__d).insert("startDate".into(), self.parse_to_int((match ((since).as_f64(), (Value::Int(1000)).as_f64()) { (Some(x), Some(y)) if y != 0.0 => Value::Float(x / y), _ => Value::Null }))); }
}
if (limit == Value::Null) || limit.as_f64().unwrap_or(f64::NAN) > ((100i64) as f64) {
limit = Value::Int(100);
}
if (limit != Value::Null) {
if let Value::Dict(__d) = &mut request { std::sync::Arc::make_mut(__d).insert("limit".into(), limit.clone()); }
}
// Use transactionMethod parameter to filter withdrawals server-side (method = 2)
if let Value::Dict(__d) = &mut request { std::sync::Arc::make_mut(__d).insert("transactionMethod".into(), Value::Str("2".into())); }
let __ws_arg_23 = self.extend(request, &[params]);
let mut response: Value = self.v4_private_post_main_account_history(&[__ws_arg_23]).await;
return self.parse_transactions(self.safe_list_k(response, "records", &[Value::from(vec![])]), &[currency, since, limit]);
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 (self.markets.clone() == 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 (code != Value::Null) {
currency = self.currency(code);
if let Value::Dict(__d) = &mut request { std::sync::Arc::make_mut(__d).insert("ticker".into(), currency.as_map().and_then(|__m| __m.get("id")).cloned().unwrap_or(Value::Null)); }
}
if (since != Value::Null) {
if let Value::Dict(__d) = &mut request { std::sync::Arc::make_mut(__d).insert("startDate".into(), self.parse_to_int((match ((since).as_f64(), (Value::Int(1000)).as_f64()) { (Some(x), Some(y)) if y != 0.0 => Value::Float(x / y), _ => Value::Null }))); }
}
if (limit == Value::Null) || limit.as_f64().unwrap_or(f64::NAN) > ((100i64) as f64) {
limit = Value::Int(100);
}
if (limit != Value::Null) {
if let Value::Dict(__d) = &mut request { std::sync::Arc::make_mut(__d).insert("limit".into(), limit.clone()); }
}
// Do not filter by transactionMethod to get all transactions (deposits and withdrawals)
let __ws_arg_24 = self.extend(request, &[params]);
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, "records", &[Value::from(vec![])]);
return self.parse_transactions(records, &[currency, since, limit]);
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 (self.markets.clone() == 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(), currency.as_map().and_then(|__m| __m.get("id")).cloned().unwrap_or(Value::Null));
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 (provider == Value::Null) {
panic!("{}", crate::exchange_errors::arguments_required(format!("{}{}", self.id.clone(), Value::Str(" fetchDepositAddress() requires a provider when the ticker is fiat".into()))));
}
if let Value::Dict(__d) = &mut request { std::sync::Arc::make_mut(__d).insert("provider".into(), provider); }
let mut amount: Value = self.safe_number_k(params.clone(), "amount", &[]);
if (amount == Value::Null) {
panic!("{}", crate::exchange_errors::arguments_required(format!("{}{}", self.id.clone(), Value::Str(" fetchDepositAddress() requires an amount when the ticker is fiat".into()))));
}
if let Value::Dict(__d) = &mut request { std::sync::Arc::make_mut(__d).insert("amount".into(), amount); }
let mut uniqueId: Value = self.safe_value_k(params.clone(), "uniqueId", &[]);
if (uniqueId == Value::Null) {
panic!("{}", crate::exchange_errors::arguments_required(format!("{}{}", self.id.clone(), Value::Str(" fetchDepositAddress() requires an uniqueId when the ticker is fiat".into()))));
}
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, &[params]);
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_dict_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]);
let mut tag: Value = self.safe_string_k(account, "memo", &[]);
self.check_address(&[address.clone()]);
return Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("info".to_string(), response);
m.insert("currency".to_string(), code);
m.insert("network".to_string(), Value::Null);
m.insert("address".to_string(), address);
m.insert("tag".to_string(), tag);
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 (self.markets.clone() == Value::Null) {
self.load_markets(&[]).await;
}
let mut currency: Value = self.currency(code);
let mut request: Value = Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("ticker".to_string(), currency.as_map().and_then(|__m| __m.get("id")).cloned().unwrap_or(Value::Null));
m
});
let __ws_arg_27 = self.extend(request, &[params]);
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, "account", &[Value::Map({
let mut m = indexmap::IndexMap::new();
m
})]);
return self.parse_deposit_address(data, &[currency]);
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]));
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, "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 (self.markets.clone() == Value::Null) {
self.load_markets(&[]).await;
}
let mut accounts: Value = Value::from(vec![]);
let mut response: Value = self.v4_private_post_sub_account_list(&[params]).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, "data", &[Value::from(vec![])]);
{
let mut i: Value = Value::Int(0);
let mut __for_first_1116: bool = true;
while { if !__for_first_1116 { i = (match (&(i), &(Value::Int(1))) { (Value::Int(x), Value::Int(y)) => Value::Int(x + y), (Value::Int(x), Value::Float(y)) => Value::Float(*x as f64 + *y), (Value::Float(x), Value::Int(y)) => Value::Float(*x + *y as f64), (Value::Float(x), Value::Float(y)) => Value::Float(x + y), _ => Value::Null }); } __for_first_1116 = false; i.as_f64().unwrap_or(f64::NAN) < ((subAccounts.len() as i64) as f64) } {
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);
m.insert("type".to_string(), Value::Str("subaccount".into()));
m.insert("name".to_string(), accountName);
m.insert("code".to_string(), Value::Null);
m.insert("info".to_string(), subAccount);
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 (self.markets.clone() == Value::Null) {
self.load_markets(&[]).await;
}
if (symbol != Value::Null) {
panic!("{}", crate::exchange_errors::not_supported(format!("{}{}", self.id.clone(), Value::Str(" setLeverage() does not allow to set per symbol".into()))));
}
if (leverage.as_f64().unwrap_or(f64::NAN) < ((1i64) as f64)) || (leverage.as_f64().unwrap_or(f64::NAN) > ((20i64) as f64)) {
panic!("{}", crate::exchange_errors::bad_request(format!("{}{}", self.id.clone(), Value::Str(" setLeverage() leverage should be between 1 and 20".into()))));
}
let mut request: Value = Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("leverage".to_string(), leverage);
m
});
let __ws_arg_28 = self.extend(request, &[params]);
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 (self.markets.clone() == Value::Null) {
self.load_markets(&[]).await;
}
let mut currency: Value = self.currency(code.clone());
let mut accountsByType: Value = self.safe_dict_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, toAccount.clone(), &[toAccount.clone()]);
let mut amountString: Value = self.currency_to_precision(code, amount, &[]);
let mut request: Value = Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("ticker".to_string(), currency.as_map().and_then(|__m| __m.get("id")).cloned().unwrap_or(Value::Null));
m.insert("amount".to_string(), amountString);
m.insert("from".to_string(), fromAccountId);
m.insert("to".to_string(), toAccountId);
m
});
let __ws_arg_29 = self.extend(request, &[params]);
let mut response: Value = self.v4_private_post_main_account_transfer(&[__ws_arg_29]).await;
return self.parse_transfer(response, &[currency]);
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);
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]));
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 (self.markets.clone() == 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(), currency.as_map().and_then(|__m| __m.get("id")).cloned().unwrap_or(Value::Null));
m.insert("amount".to_string(), self.currency_to_precision(code.clone(), amount, &[]));
m.insert("address".to_string(), address);
m
});
let mut uniqueId: Value = self.safe_value_k(params.clone(), "uniqueId", &[]);
if (uniqueId == Value::Null) {
uniqueId = self.uuid22(&[]);
}
if let Value::Dict(__d) = &mut request { std::sync::Arc::make_mut(__d).insert("uniqueId".into(), uniqueId.clone()); }
if (tag != Value::Null) {
if let Value::Dict(__d) = &mut request { std::sync::Arc::make_mut(__d).insert("memo".into(), tag); }
}
if is_true(&self.is_fiat(code)) {
let mut provider: Value = self.safe_value_k(params.clone(), "provider", &[]);
if (provider == Value::Null) {
panic!("{}", crate::exchange_errors::arguments_required(format!("{}{}", self.id.clone(), Value::Str(" withdraw() requires a provider when the ticker is fiat".into()))));
}
if let Value::Dict(__d) = &mut request { std::sync::Arc::make_mut(__d).insert("provider".into(), provider); }
}
let __ws_arg_30 = self.extend(request, &[params]);
let mut response: Value = self.v4_private_post_main_account_withdraw(&[__ws_arg_30]).await;
let __ws_arg_31 = self.parse_transaction(response, &[currency]);
return self.extend(__ws_arg_31, &[Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("id".to_string(), uniqueId);
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_k(transaction.clone(), "createdAt", &[]);
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: Option<String> = self.safe_string_k(transaction.clone(), "method", &[]).as_str().map(str::to_owned);
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));
m.insert("network".to_string(), self.safe_string_k(transaction.clone(), "network", &[]));
m.insert("addressFrom".to_string(), (if (method.as_deref() == Some("1")) { address.clone() } else { Value::Null }));
m.insert("address".to_string(), address.clone());
m.insert("addressTo".to_string(), (if (method.as_deref() == Some("2")) { address } else { Value::Null }));
m.insert("amount".to_string(), self.safe_number_k(transaction.clone(), "amount", &[]));
m.insert("type".to_string(), (if (method.as_deref() == Some("1")) { Value::Str("deposit".into()) } else { Value::Str("withdrawal".into()) }));
m.insert("currency".to_string(), self.safe_currency_code(currencyId.clone(), &[currency.clone()]));
m.insert("status".to_string(), self.parse_transaction_status(status));
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, &[currency]));
m
}));
m.insert("info".to_string(), transaction);
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".into()));
m.insert("2".to_string(), Value::Str("pending".into()));
m.insert("3".to_string(), Value::Str("ok".into()));
m.insert("4".to_string(), Value::Str("canceled".into()));
m.insert("5".to_string(), Value::Str("pending".into()));
m.insert("6".to_string(), Value::Str("pending".into()));
m.insert("7".to_string(), Value::Str("ok".into()));
m.insert("9".to_string(), Value::Str("canceled".into()));
m.insert("10".to_string(), Value::Str("pending".into()));
m.insert("11".to_string(), Value::Str("pending".into()));
m.insert("12".to_string(), Value::Str("pending".into()));
m.insert("13".to_string(), Value::Str("pending".into()));
m.insert("14".to_string(), Value::Str("pending".into()));
m.insert("15".to_string(), Value::Str("pending".into()));
m.insert("16".to_string(), Value::Str("pending".into()));
m.insert("17".to_string(), Value::Str("pending".into()));
m
});
return self.safe_string(statuses, 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 (self.markets.clone() == 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);
m.insert("limit".to_string(), Value::Int(1));
m.insert("offset".to_string(), Value::Int(0));
m
});
if (code != Value::Null) {
currency = self.currency(code);
if let Value::Dict(__d) = &mut request { std::sync::Arc::make_mut(__d).insert("ticker".into(), currency.as_map().and_then(|__m| __m.get("id")).cloned().unwrap_or(Value::Null)); }
}
let __ws_arg_32 = self.extend(request, &[params]);
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_list_k(response, "records", &[Value::from(vec![])]);
let mut first: Value = self.safe_dict(records, Value::Int(0), &[Value::Map({
let mut m = indexmap::IndexMap::new();
m
})]);
return self.parse_transaction(first, &[currency]);
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 (self.markets.clone() == 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 (code != Value::Null) {
currency = self.currency(code);
if let Value::Dict(__d) = &mut request { std::sync::Arc::make_mut(__d).insert("ticker".into(), currency.as_map().and_then(|__m| __m.get("id")).cloned().unwrap_or(Value::Null)); }
}
if (limit != Value::Null) {
if let Value::Dict(__d) = &mut request { std::sync::Arc::make_mut(__d).insert("limit".into(), crate::runtime::Math::min(&limit, &Value::Int(100))); }
}
let __ws_arg_33 = self.extend(request, &[params]);
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, "records", &[Value::from(vec![])]);
let mut recordsList: Value = Value::from(vec![]);
if (records != Value::Null) {
recordsList = records;
}
return self.parse_transactions(recordsList, &[currency, since, limit]);
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 (self.markets.clone() == 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 (symbol != Value::Null) {
market = self.market(symbol);
if let Value::Dict(__d) = &mut request { std::sync::Arc::make_mut(__d).insert("market".into(), market.as_map().and_then(|__m| __m.get("id")).cloned().unwrap_or(Value::Null)); }
}
let __ws_arg_34 = self.extend(request, &[params]);
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, &[market]);
return self.filter_by_currency_since_limit(interest, &[code, since, limit]);
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, &[market, Value::Str("_".into())]);
let mut timestamp: Value = self.safe_timestamp_k(info.clone(), "modifyDate", &[]);
return Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("info".to_string(), info.clone());
m.insert("symbol".to_string(), symbol);
m.insert("currency".to_string(), Value::Str("USDT".into()));
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, "amount", &[]));
m.insert("marginMode".to_string(), Value::Str("cross".into()));
m.insert("timestamp".to_string(), timestamp.clone());
m.insert("datetime".to_string(), self.iso8601(timestamp));
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 (self.markets.clone() == Value::Null) {
self.load_markets(&[]).await;
}
symbol = self.symbol(symbol.clone());
let mut response: Value = self.fetch_funding_rates(&[Value::from(vec![symbol.clone()]), params]).await;
return self.safe_value(response, symbol, &[]);
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 (self.markets.clone() == Value::Null) {
self.load_markets(&[]).await;
}
symbols = self.market_symbols(&[symbols.clone()]);
let mut response: Value = self.v4_public_get_futures(&[params]).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, "result", &[Value::from(vec![])]);
return self.parse_funding_rates(data, &[symbols]);
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, &[market]);
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);
m.insert("symbol".to_string(), symbol);
m.insert("markPrice".to_string(), markPrice);
m.insert("indexPrice".to_string(), indexPrice);
m.insert("interestRate".to_string(), interestRate);
m.insert("timestamp".to_string(), Value::Null);
m.insert("datetime".to_string(), Value::Null);
m.insert("fundingRate".to_string(), fundingRate);
m.insert("fundingTimestamp".to_string(), fundingTime.clone());
m.insert("fundingDatetime".to_string(), self.iso8601(fundingTime));
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 (self.markets.clone() == Value::Null) {
self.load_markets(&[]).await;
}
if (symbol == Value::Null) {
panic!("{}", crate::exchange_errors::arguments_required(format!("{}{}", self.id.clone(), Value::Str(" fetchFundingHistory() requires a symbol argument".into()))));
}
let mut market: Value = self.market(symbol);
let mut request: Value = Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("market".to_string(), market.as_map().and_then(|__m| __m.get("id")).cloned().unwrap_or(Value::Null));
m
});
if (since != Value::Null) {
if let Value::Dict(__d) = &mut request { std::sync::Arc::make_mut(__d).insert("startDate".into(), since.clone()); }
}
if (limit != Value::Null) {
if let Value::Dict(__d) = &mut request { std::sync::Arc::make_mut(__d).insert("limit".into(), limit.clone()); }
}
{ let __destr_tmp = self.handle_until_option(Value::Str("endDate".into()), request.clone(), params.clone(), &[]); request = __destr_tmp.as_array().and_then(|__arr| __arr.get(0)).cloned().unwrap_or(Value::Null); params = __destr_tmp.as_array().and_then(|__arr| __arr.get(1)).cloned().unwrap_or(Value::Null); }
let __ws_arg_35 = self.extend(request, &[params]);
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, "records", &[Value::from(vec![])]);
return self.parse_funding_histories(data, &[market, since, limit]);
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, &[market, Value::Null, Value::Str("swap".into())]));
m.insert("code".to_string(), Value::Null);
m.insert("timestamp".to_string(), timestamp.clone());
m.insert("datetime".to_string(), self.iso8601(timestamp));
m.insert("id".to_string(), Value::Null);
m.insert("amount".to_string(), self.safe_number_k(contract, "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::from(vec![]);
{
let mut i: Value = Value::Int(0);
let mut __for_first_1117: bool = true;
while { if !__for_first_1117 { i = (match (&(i), &(Value::Int(1))) { (Value::Int(x), Value::Int(y)) => Value::Int(x + y), (Value::Int(x), Value::Float(y)) => Value::Float(*x as f64 + *y), (Value::Float(x), Value::Int(y)) => Value::Float(*x + *y as f64), (Value::Float(x), Value::Float(y)) => Value::Float(x + y), _ => Value::Null }); } __for_first_1117 = false; i.as_f64().unwrap_or(f64::NAN) < get_array_length(&contracts).as_f64().unwrap_or(f64::NAN) } {
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, &[market.clone()]));
}
}
let mut sorted: Value = self.sort_by(result, Value::Str("timestamp".into()), &[]);
return self.filter_by_since_limit(sorted, &[since, limit]);
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 (self.markets.clone() == 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 (code != Value::Null) {
currency = self.currency(code);
if let Value::Dict(__d) = &mut request { std::sync::Arc::make_mut(__d).insert("ticker".into(), currency.as_map().and_then(|__m| __m.get("id")).cloned().unwrap_or(Value::Null)); }
}
if (limit != Value::Null) {
if let Value::Dict(__d) = &mut request { std::sync::Arc::make_mut(__d).insert("limit".into(), limit.clone()); }; // default 1000
}
let __ws_arg_36 = self.extend(request, &[params]);
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, "records", &[]);
let mut recordsList: Value = Value::from(vec![]);
if (records != Value::Null) {
recordsList = records;
}
return self.parse_transactions(recordsList, &[currency, since, limit]);
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 (self.markets.clone() == 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);
m.insert("to".to_string(), toCode);
m.insert("amount".to_string(), self.number_to_string(amount));
m.insert("direction".to_string(), Value::Str("from".into()));
m
});
let __ws_arg_37 = self.extend(request, &[params]);
let mut response: Value = self.v4_private_post_convert_estimate(&[__ws_arg_37]).await;
return self.parse_conversion(response, &[fromCurrency, toCurrency]);
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 (self.markets.clone() == Value::Null) {
self.load_markets(&[]).await;
}
let mut fromCurrency: Value = self.currency(fromCode);
let mut toCurrency: Value = self.currency(toCode);
let mut request: Value = Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("quoteId".to_string(), id);
m
});
let __ws_arg_38 = self.extend(request, &[params]);
let mut response: Value = self.v4_private_post_convert_confirm(&[__ws_arg_38]).await;
return self.parse_conversion(response, &[fromCurrency, toCurrency]);
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 (self.markets.clone() == Value::Null) {
self.load_markets(&[]).await;
}
let mut request: Value = Value::Map({
let mut m = indexmap::IndexMap::new();
m
});
if (code != Value::Null) {
if let Value::Dict(__d) = &mut request { std::sync::Arc::make_mut(__d).insert("fromTicker".into(), code.clone()); }
}
if (since != Value::Null) {
let mut start: Value = self.parse_to_int((match ((since).as_f64(), (Value::Int(1000)).as_f64()) { (Some(x), Some(y)) if y != 0.0 => Value::Float(x / y), _ => Value::Null }));
if let Value::Dict(__d) = &mut request { std::sync::Arc::make_mut(__d).insert("from".into(), self.number_to_string(start)); }
}
if (limit != Value::Null) {
if let Value::Dict(__d) = &mut request { std::sync::Arc::make_mut(__d).insert("limit".into(), limit.clone()); }
}
{ let __destr_tmp = self.handle_until_option(Value::Str("to".into()), request.clone(), params.clone(), &[Value::Float(0.001)]); request = __destr_tmp.as_array().and_then(|__arr| __arr.get(0)).cloned().unwrap_or(Value::Null); params = __destr_tmp.as_array().and_then(|__arr| __arr.get(1)).cloned().unwrap_or(Value::Null); }
let __ws_arg_39 = self.extend(request, &[params]);
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, "records", &[Value::from(vec![])]);
return self.parse_conversions(rows, &[code, Value::Str("fromCurrency".into()), Value::Str("toCurrency".into()), since, limit]);
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::from(vec![])]);
let mut first: Value = self.safe_dict(path, 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, "to", &[]);
let mut timestamp: Value = self.safe_timestamp2(conversion.clone(), Value::Str("date".into()), Value::Str("expireAt".into()), &[]);
let mut fromCoin: Value = self.safe_string_k(conversion.clone(), "from", &[fromPath]);
let mut fromCode: Value = self.safe_currency_code(fromCoin, &[fromCurrency]);
let mut toCoin: Value = self.safe_string_k(conversion.clone(), "to", &[toPath]);
let mut toCode: Value = self.safe_currency_code(toCoin, &[toCurrency]);
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));
m.insert("id".to_string(), self.safe_string_k(conversion.clone(), "id", &[]));
m.insert("fromCurrency".to_string(), fromCode);
m.insert("fromAmount".to_string(), self.safe_number2(conversion.clone(), Value::Str("give".into()), Value::Str("finalGive".into()), &[]));
m.insert("toCurrency".to_string(), toCode);
m.insert("toAmount".to_string(), self.safe_number2(conversion.clone(), Value::Str("receive".into()), Value::Str("finalReceive".into()), &[]));
m.insert("price".to_string(), self.safe_number_k(conversion, "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 (self.markets.clone() == 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(), market.as_map().and_then(|__m| __m.get("id")).cloned().unwrap_or(Value::Null));
m
});
if (since != Value::Null) {
if let Value::Dict(__d) = &mut request { std::sync::Arc::make_mut(__d).insert("startDate".into(), since.clone()); }
}
if (limit != Value::Null) {
if let Value::Dict(__d) = &mut request { std::sync::Arc::make_mut(__d).insert("limit".into(), since.clone()); }
}
{ let __destr_tmp = self.handle_until_option(Value::Str("endDate".into()), request.clone(), params.clone(), &[]); request = __destr_tmp.as_array().and_then(|__arr| __arr.get(0)).cloned().unwrap_or(Value::Null); params = __destr_tmp.as_array().and_then(|__arr| __arr.get(1)).cloned().unwrap_or(Value::Null); }
let __ws_arg_40 = self.extend(request, &[params]);
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, &[]);
return self.filter_by_symbol_since_limit(positions, &[symbol, since, limit]);
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 (self.markets.clone() == 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]).await;
return self.parse_positions(response, &[symbols]);
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 (self.markets.clone() == Value::Null) {
self.load_markets(&[]).await;
}
let mut market: Value = self.market(symbol);
let mut request: Value = Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("symbol".to_string(), market.as_map().and_then(|__m| __m.get("id")).cloned().unwrap_or(Value::Null));
m
});
let __ws_arg_41 = self.extend(request, &[params]);
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, Value::Int(0), &[Value::Map({
let mut m = indexmap::IndexMap::new();
m
})]);
return self.parse_position(data, &[market]);
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_k(position.clone(), "openDate", &[]);
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, &[market]));
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, "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));
m.insert("lastUpdateTimestamp".to_string(), self.safe_timestamp_k(position.clone(), "modifyDate", &[]));
m.insert("maintenanceMargin".to_string(), Value::Null);
m.insert("maintenanceMarginPercentage".to_string(), Value::Null);
m.insert("collateral".to_string(), self.safe_number_k(position, "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, "takeProfit", &[]));
m
}));
Value::Null
}
pub fn is_fiat(&self, mut currency: Value) -> Value {
let mut fiatCurrencies: Value = self.safe_list_k(self.options.clone(), "fiatCurrencies", &[Value::from(vec![])]);
return self.in_array(currency, fiatCurrencies);
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 (symbol == Value::Null) {
panic!("{}", crate::exchange_errors::arguments_required(format!("{}{}", self.id.clone(), Value::Str(" fetchFundingRateHistory() requires a symbol argument".into()))));
}
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".into()), Value::Str("paginate".into()), &[]); paginate = __destr_tmp.as_array().and_then(|__arr| __arr.get(0)).cloned().unwrap_or(Value::Null); params = __destr_tmp.as_array().and_then(|__arr| __arr.get(1)).cloned().unwrap_or(Value::Null); }
if is_true(&paginate) {
return self.fetch_paginated_call_deterministic(Value::Str("fetchFundingRateHistory".into()), &[symbol.clone(), since.clone(), limit.clone(), Value::Str("8h".into()), params.clone(), maxLimit]).await;
}
if (self.markets.clone() == Value::Null) {
self.load_markets(&[]).await;
}
let mut market: Value = self.market(symbol);
let mut request: Value = Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("market".to_string(), market.as_map().and_then(|__m| __m.get("id")).cloned().unwrap_or(Value::Null));
m
});
if (since != Value::Null) {
if let Value::Dict(__d) = &mut request { std::sync::Arc::make_mut(__d).insert("startDate".into(), math_round(&(match ((since).as_f64(), (Value::Int(1000)).as_f64()) { (Some(x), Some(y)) if y != 0.0 => Value::Float(x / y), _ => Value::Null }))); }
}
{ let __destr_tmp = self.handle_until_option(Value::Str("until_timestamp".into()), request.clone(), params.clone(), &[Value::Float(0.001)]); request = __destr_tmp.as_array().and_then(|__arr| __arr.get(0)).cloned().unwrap_or(Value::Null); params = __destr_tmp.as_array().and_then(|__arr| __arr.get(1)).cloned().unwrap_or(Value::Null); }
if (limit != Value::Null) {
if let Value::Dict(__d) = &mut request { std::sync::Arc::make_mut(__d).insert("limit".into(), limit.clone()); }
}
let __ws_arg_42 = self.extend(request, &[params]);
let mut response: Value = self.v4_public_get_funding_history_market(&[__ws_arg_42]).await;
return self.parse_funding_rate_histories(response, &[market, since, limit]);
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, market.clone()]);
let mut timestamp: Value = self.safe_timestamp_k(info.clone(), "fundingTime", &[]);
return Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("info".to_string(), info.clone());
m.insert("symbol".to_string(), market.as_map().and_then(|__m| __m.get("symbol")).cloned().unwrap_or(Value::Null));
m.insert("fundingRate".to_string(), self.safe_number_k(info, "fundingRate", &[]));
m.insert("timestamp".to_string(), timestamp.clone());
m.insert("datetime".to_string(), self.iso8601(timestamp));
m
});
Value::Null
}
pub fn nonce(&self) -> Value {
return subtract(&self.milliseconds(), &self.options.as_map().and_then(|__m| __m.get("timeDifference")).cloned().unwrap_or(Value::Null));
Value::Null
}
pub fn sign(&self, mut path: Value, optional_args: &[Value]) -> Value {
let mut api = get_arg(optional_args, 0, Value::Str("public".into()));
let mut method = get_arg(optional_args, 1, Value::Str("GET".into()));
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, Value::Int(1), &[]);
if (headers == Value::Null) {
headers = Value::Map({
let mut m = indexmap::IndexMap::new();
m
});
}
if let Value::Dict(__d) = &mut headers { std::sync::Arc::make_mut(__d).insert("User-Agent".into(), Value::Str(format!("{}{}", Value::Str(format!("{}{}", Value::Str(format!("{}{}", Value::Str("ccxt/".into()), self.id.clone()).into()), Value::Str("-".into())).into()), self.version.clone()).into())); }
let mut pathWithParams: Value = Value::Str(format!("{}{}", Value::Str("/".into()), self.implode_params(path, params.clone())).into());
let mut url: Value = add(&get_value(&get_value(&self.urls.as_map().and_then(|__m| __m.get("api")).cloned().unwrap_or(Value::Null), &version), &accessibility), &pathWithParams);
if (accessibility.as_str() == Some("public")) {
if ((object_keys(&query).len() as i64) as f64) > ((0i64) as f64) {
url = Value::Str(format!("{}{}", url, Value::Str(format!("{}{}", Value::Str("?".into()), self.urlencode(query.clone(), &[])).into())).into());
}
}
if (accessibility.as_str() == Some("private")) {
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 = Value::Str(format!("{}{}", add(&Value::Str(format!("{}{}", Value::Str(format!("{}{}", Value::Str("/".into()), Value::Str("api".into())).into()), Value::Str("/".into())).into()), &version), pathWithParams).into());
let mut nonceWindowrequestParamsVariable = self.handle_option_and_params(params, Value::Str("sign".into()), Value::Str("nonceWindow".into()), &[Value::Bool(false)]);
let mut nonceWindow: Value = nonceWindowrequestParamsVariable.as_array().and_then(|__arr| __arr.get(0)).cloned().unwrap_or(Value::Null);
let mut requestParams: Value = nonceWindowrequestParamsVariable.as_array().and_then(|__arr| __arr.get(1)).cloned().unwrap_or(Value::Null);
let __ws_arg_43 = self.extend(Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("request".to_string(), request);
m.insert("nonce".to_string(), nonce);
m.insert("nonceWindow".to_string(), nonceWindow);
m
}), &[requestParams]);
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, Value::Str("sha512".into()), &[]);
headers = Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("Content-Type".to_string(), Value::Str("application/json".into()));
m.insert("X-TXC-APIKEY".to_string(), self.apiKey.clone());
m.insert("X-TXC-PAYLOAD".to_string(), payload);
m.insert("X-TXC-SIGNATURE".to_string(), signature);
m
});
}
return Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("url".to_string(), url);
m.insert("method".to_string(), method);
m.insert("body".to_string(), body);
m.insert("headers".to_string(), headers);
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 (code.as_f64() == Some(418.0)) || (code.as_f64() == Some(429.0)) {
panic!("{}", crate::exchange_errors::d_do_s_protection(format!("{}{}", Value::Str(format!("{}{}", Value::Str(format!("{}{}", Value::Str(format!("{}{}", Value::Str(format!("{}{}", Value::Str(format!("{}{}", self.id.clone(), Value::Str(" ".into())).into()), to_string_val(&code)).into()), Value::Str(" ".into())).into()), reason).into()), Value::Str(" ".into())).into()), body)));
}
if (code.as_f64() == Some(404.0)) {
panic!("{}", crate::exchange_errors::exchange_error(format!("{}{}", Value::Str(format!("{}{}", Value::Str(format!("{}{}", self.id.clone(), Value::Str(" ".into())).into()), to_string_val(&code)).into()), Value::Str(" endpoint not found".into()))));
}
if (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_dict_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: Option<i64> = self.safe_integer_k(response.clone(), "code", &[]).as_i64();
let mut hasErrorStatus: bool = (status != Value::Null) && (status.as_str() != Some("200")) && (errors != Value::Null);
if hasErrorStatus || (codeNew.is_some()) {
let mut feedback: Value = Value::Str(format!("{}{}", Value::Str(format!("{}{}", self.id.clone(), Value::Str(" ".into())).into()), body).into());
let mut errorInfo: Value = message;
if hasErrorStatus {
errorInfo = status;
} 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: f64 = ((errorKeys.len() as i64) as f64);
if errorsLength > ((0i64) as f64) {
let mut errorKey: Value = errorKeys.as_array().and_then(|__arr| __arr.get(0)).cloned().unwrap_or(Value::Null);
let mut errorMessageArray: Value = self.safe_list(errorObject, errorKey.clone(), &[Value::from(vec![])]);
let mut errorMessageLength: f64 = ((errorMessageArray.len() as i64) as f64);
errorInfo = (if (errorMessageLength > ((0i64) as f64)) { errorMessageArray.as_array().and_then(|__arr| __arr.get(0)).cloned().unwrap_or(Value::Null) } else { body.clone() });
}
}
self.throw_exactly_matched_exception(self.exceptions.as_map().and_then(|__m| __m.get("exact")).cloned().unwrap_or(Value::Null), errorInfo.clone(), feedback.clone());
self.throw_broadly_matched_exception(self.exceptions.as_map().and_then(|__m| __m.get("broad")).cloned().unwrap_or(Value::Null), 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 (success.as_bool() != Some(true)) {
let mut errMsg: Value = self.safe_dict_k(response, "message", &[Value::Map({
let mut m = indexmap::IndexMap::new();
m
})]);
let mut errKeys: Value = object_keys(&errMsg);
let mut errKeysLength: f64 = ((errKeys.len() as i64) as f64);
let mut errorInfo: Value = body.clone();
if errKeysLength > ((0i64) as f64) {
let mut errorKey: Value = errKeys.as_array().and_then(|__arr| __arr.get(0)).cloned().unwrap_or(Value::Null);
let mut errorMessageArray: Value = self.safe_list(errMsg, errorKey, &[Value::from(vec![])]);
let mut errorMessageLength: f64 = ((errorMessageArray.len() as i64) as f64);
errorInfo = (if (errorMessageLength > ((0i64) as f64)) { errorMessageArray.as_array().and_then(|__arr| __arr.get(0)).cloned().unwrap_or(Value::Null) } else { body.clone() });
}
let mut feedback: Value = Value::Str(format!("{}{}", Value::Str(format!("{}{}", self.id.clone(), Value::Str(" ".into())).into()), body).into());
self.throw_exactly_matched_exception(self.exceptions.as_map().and_then(|__m| __m.get("exact")).cloned().unwrap_or(Value::Null), errorInfo, feedback.clone());
self.throw_broadly_matched_exception(self.exceptions.as_map().and_then(|__m| __m.get("broad")).cloned().unwrap_or(Value::Null), body, feedback.clone());
panic!("{}", crate::exchange_errors::exchange_error(feedback));
}
}
return Value::Null;
Value::Null
}
}