// 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
// Generated from `ts/src/base/Exchange.ts` — methods below the
// "METHODS BELOW THIS LINE ARE TRANSPILED" marker. Everything
// above the marker is hand-written (src/exchange.rs / src/prediction_exchange.rs).
#![allow(unused, non_snake_case, clippy::all)]
use crate::Value;
use crate::ExchangeError;
use crate::exchange::Exchange;
use crate::exchange::ExchangeRuntime;
use crate::runtime::*;
pub trait ExchangeBase:
crate::exchange::DerivedExchange
+ std::ops::DerefMut<Target = Exchange>
+ Send
+ Sized
{
/// Dispatch a snake_case method name to this core's inherent async
/// methods, falling through to `call_dynamic_base` for base-only methods.
/// The single required method — every override reaches the core statically.
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>>;
/// Route `method(args)` to the derived override by name, with a per-method
/// re-entry guard (so a base method calling its own name falls through to
/// the base body instead of looping). Replaces `Exchange::dispatch_to_derived`
/// — no stored pointer; `call_dynamic` is a static trait call.
fn dispatch_to_derived<'a>(&'a mut self, method: &'a str, args: Vec<crate::Value>)
-> std::pin::Pin<Box<dyn std::future::Future<Output = Option<crate::Value>> + Send + 'a>>
{
Box::pin(async move {
if !self.dispatch_guard_enter(method) { return None; }
let out = futures::FutureExt::catch_unwind(
std::panic::AssertUnwindSafe(self.call_dynamic(method, args))
).await;
self.dispatch_guard_exit();
match out {
Ok(v) => Some(v),
Err(p) => std::panic::resume_unwind(p),
}
})
}
/// `isDictionary(value)` — hand-provided base method. The ast-transpiler
/// drops `Exchange.ts`'s `typeof value === 'object'` body, so supply it here
/// as a trait default reachable by every Core (used across the base +
/// derived exchanges).
fn is_dictionary(&self, value: crate::Value) -> crate::Value {
crate::Value::Bool(
!crate::runtime::is_equal(&value, &crate::Value::Null)
&& crate::runtime::is_object(&value)
&& !crate::runtime::is_array(&value)
)
}
fn describe(&self) -> Value {
return Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("id".to_string(), self.id.clone());
m.insert("name".to_string(), self.name.clone());
m.insert("countries".to_string(), self.countries.clone());
m.insert("enableRateLimit".to_string(), self.enableRateLimit.clone());
m.insert("rateLimit".to_string(), self.rateLimit.clone());
m.insert("rateLimiterAlgorithm".to_string(), self.rateLimiterAlgorithm.clone());
m.insert("timeout".to_string(), self.timeout.clone());
m.insert("certified".to_string(), self.certified.clone());
m.insert("pro".to_string(), self.pro.clone());
m.insert("alias".to_string(), self.alias.clone());
m.insert("dex".to_string(), Value::Bool(false));
m.insert("has".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("publicAPI".to_string(), Value::Bool(true));
m.insert("privateAPI".to_string(), Value::Bool(true));
m.insert("CORS".to_string(), Value::Null);
m.insert("sandbox".to_string(), Value::Null);
m.insert("spot".to_string(), Value::Null);
m.insert("margin".to_string(), Value::Null);
m.insert("swap".to_string(), Value::Null);
m.insert("future".to_string(), Value::Null);
m.insert("option".to_string(), Value::Null);
m.insert("index".to_string(), Value::Null);
m.insert("addMargin".to_string(), Value::Null);
m.insert("borrowCrossMargin".to_string(), Value::Null);
m.insert("borrowIsolatedMargin".to_string(), Value::Null);
m.insert("borrowMargin".to_string(), Value::Null);
m.insert("cancelAllOrders".to_string(), Value::Null);
m.insert("cancelAllOrdersWs".to_string(), Value::Null);
m.insert("cancelOrder".to_string(), Value::Bool(true));
m.insert("cancelOrderWithClientOrderId".to_string(), Value::Null);
m.insert("cancelOrderWs".to_string(), Value::Null);
m.insert("cancelOrders".to_string(), Value::Null);
m.insert("cancelOrdersWithClientOrderId".to_string(), Value::Null);
m.insert("cancelOrdersWs".to_string(), Value::Null);
m.insert("closeAllPositions".to_string(), Value::Null);
m.insert("closePosition".to_string(), Value::Null);
m.insert("createDepositAddress".to_string(), Value::Null);
m.insert("createLimitBuyOrder".to_string(), Value::Null);
m.insert("createLimitBuyOrderWs".to_string(), Value::Null);
m.insert("createLimitOrder".to_string(), Value::Bool(true));
m.insert("createLimitOrderWs".to_string(), Value::Null);
m.insert("createLimitSellOrder".to_string(), Value::Null);
m.insert("createLimitSellOrderWs".to_string(), Value::Null);
m.insert("createMarketBuyOrder".to_string(), Value::Null);
m.insert("createMarketBuyOrderWs".to_string(), Value::Null);
m.insert("createMarketBuyOrderWithCost".to_string(), Value::Null);
m.insert("createMarketBuyOrderWithCostWs".to_string(), Value::Null);
m.insert("createMarketOrder".to_string(), Value::Bool(true));
m.insert("createMarketOrderWs".to_string(), Value::Bool(true));
m.insert("createMarketOrderWithCost".to_string(), Value::Null);
m.insert("createMarketOrderWithCostWs".to_string(), Value::Null);
m.insert("createMarketSellOrder".to_string(), Value::Null);
m.insert("createMarketSellOrderWs".to_string(), Value::Null);
m.insert("createMarketSellOrderWithCost".to_string(), Value::Null);
m.insert("createMarketSellOrderWithCostWs".to_string(), Value::Null);
m.insert("createOrder".to_string(), Value::Bool(true));
m.insert("createOrderWs".to_string(), Value::Null);
m.insert("createOrders".to_string(), Value::Null);
m.insert("createOrderWithTakeProfitAndStopLoss".to_string(), Value::Null);
m.insert("createOrderWithTakeProfitAndStopLossWs".to_string(), Value::Null);
m.insert("createPostOnlyOrder".to_string(), Value::Null);
m.insert("createPostOnlyOrderWs".to_string(), Value::Null);
m.insert("createReduceOnlyOrder".to_string(), Value::Null);
m.insert("createReduceOnlyOrderWs".to_string(), Value::Null);
m.insert("createStopLimitOrder".to_string(), Value::Null);
m.insert("createStopLimitOrderWs".to_string(), Value::Null);
m.insert("createStopLossOrder".to_string(), Value::Null);
m.insert("createStopLossOrderWs".to_string(), Value::Null);
m.insert("createStopMarketOrder".to_string(), Value::Null);
m.insert("createStopMarketOrderWs".to_string(), Value::Null);
m.insert("createStopOrder".to_string(), Value::Null);
m.insert("createStopOrderWs".to_string(), Value::Null);
m.insert("createTakeProfitOrder".to_string(), Value::Null);
m.insert("createTakeProfitOrderWs".to_string(), Value::Null);
m.insert("createTrailingAmountOrder".to_string(), Value::Null);
m.insert("createTrailingAmountOrderWs".to_string(), Value::Null);
m.insert("createTrailingPercentOrder".to_string(), Value::Null);
m.insert("createTrailingPercentOrderWs".to_string(), Value::Null);
m.insert("createTriggerOrder".to_string(), Value::Null);
m.insert("createTriggerOrderWs".to_string(), Value::Null);
m.insert("deposit".to_string(), Value::Null);
m.insert("editOrder".to_string(), Value::Str("emulated".to_string()));
m.insert("editOrderWithClientOrderId".to_string(), Value::Null);
m.insert("editOrders".to_string(), Value::Null);
m.insert("editOrderWs".to_string(), Value::Null);
m.insert("fetchAccounts".to_string(), Value::Null);
m.insert("fetchADLRank".to_string(), Value::Null);
m.insert("fetchBalance".to_string(), Value::Bool(true));
m.insert("fetchBalanceWs".to_string(), Value::Null);
m.insert("fetchBidsAsks".to_string(), Value::Null);
m.insert("fetchBorrowInterest".to_string(), Value::Null);
m.insert("fetchBorrowRate".to_string(), Value::Null);
m.insert("fetchBorrowRateHistories".to_string(), Value::Null);
m.insert("fetchBorrowRateHistory".to_string(), Value::Null);
m.insert("fetchBorrowRates".to_string(), Value::Null);
m.insert("fetchBorrowRatesPerSymbol".to_string(), Value::Null);
m.insert("fetchCanceledAndClosedOrders".to_string(), Value::Null);
m.insert("fetchCanceledOrders".to_string(), Value::Null);
m.insert("fetchClosedOrder".to_string(), Value::Null);
m.insert("fetchClosedOrders".to_string(), Value::Null);
m.insert("fetchClosedOrdersWs".to_string(), Value::Null);
m.insert("fetchConvertCurrencies".to_string(), Value::Null);
m.insert("fetchConvertQuote".to_string(), Value::Null);
m.insert("fetchConvertTrade".to_string(), Value::Null);
m.insert("fetchConvertTradeHistory".to_string(), Value::Null);
m.insert("fetchCrossBorrowRate".to_string(), Value::Null);
m.insert("fetchCrossBorrowRates".to_string(), Value::Null);
m.insert("fetchCurrencies".to_string(), Value::Str("emulated".to_string()));
m.insert("fetchCurrenciesWs".to_string(), Value::Str("emulated".to_string()));
m.insert("fetchDeposit".to_string(), Value::Null);
m.insert("fetchDepositAddress".to_string(), Value::Null);
m.insert("fetchDepositAddresses".to_string(), Value::Null);
m.insert("fetchDepositAddressesByNetwork".to_string(), Value::Null);
m.insert("fetchDeposits".to_string(), Value::Null);
m.insert("fetchDepositsWithdrawals".to_string(), Value::Null);
m.insert("fetchDepositsWs".to_string(), Value::Null);
m.insert("fetchDepositWithdrawFee".to_string(), Value::Null);
m.insert("fetchDepositWithdrawFees".to_string(), Value::Null);
m.insert("fetchFundingHistory".to_string(), Value::Null);
m.insert("fetchFundingRate".to_string(), Value::Null);
m.insert("fetchFundingRateHistory".to_string(), Value::Null);
m.insert("fetchFundingInterval".to_string(), Value::Null);
m.insert("fetchFundingIntervals".to_string(), Value::Null);
m.insert("fetchFundingRates".to_string(), Value::Null);
m.insert("fetchGreeks".to_string(), Value::Null);
m.insert("fetchIndexOHLCV".to_string(), Value::Null);
m.insert("fetchIsolatedBorrowRate".to_string(), Value::Null);
m.insert("fetchIsolatedBorrowRates".to_string(), Value::Null);
m.insert("fetchMarginAdjustmentHistory".to_string(), Value::Null);
m.insert("fetchIsolatedPositions".to_string(), Value::Null);
m.insert("fetchL2OrderBook".to_string(), Value::Bool(true));
m.insert("fetchL3OrderBook".to_string(), Value::Null);
m.insert("fetchLastPrices".to_string(), Value::Null);
m.insert("fetchLedger".to_string(), Value::Null);
m.insert("fetchLedgerEntry".to_string(), Value::Null);
m.insert("fetchLeverage".to_string(), Value::Null);
m.insert("fetchLeverages".to_string(), Value::Null);
m.insert("fetchLeverageTiers".to_string(), Value::Null);
m.insert("fetchLiquidations".to_string(), Value::Null);
m.insert("fetchLongShortRatio".to_string(), Value::Null);
m.insert("fetchLongShortRatioHistory".to_string(), Value::Null);
m.insert("fetchMarginMode".to_string(), Value::Null);
m.insert("fetchMarginModes".to_string(), Value::Null);
m.insert("fetchMarketLeverageTiers".to_string(), Value::Null);
m.insert("fetchMarkets".to_string(), Value::Bool(true));
m.insert("fetchMarketsWs".to_string(), Value::Null);
m.insert("fetchMarkOHLCV".to_string(), Value::Null);
m.insert("fetchMyLiquidations".to_string(), Value::Null);
m.insert("fetchMySettlementHistory".to_string(), Value::Null);
m.insert("fetchMyTrades".to_string(), Value::Null);
m.insert("fetchMyTradesWs".to_string(), Value::Null);
m.insert("fetchOHLCV".to_string(), Value::Null);
m.insert("fetchOHLCVWs".to_string(), Value::Null);
m.insert("fetchOpenInterest".to_string(), Value::Null);
m.insert("fetchOpenInterests".to_string(), Value::Null);
m.insert("fetchOpenInterestHistory".to_string(), Value::Null);
m.insert("fetchOpenOrder".to_string(), Value::Null);
m.insert("fetchOpenOrders".to_string(), Value::Null);
m.insert("fetchOpenOrdersWs".to_string(), Value::Null);
m.insert("fetchOption".to_string(), Value::Null);
m.insert("fetchOptionChain".to_string(), Value::Null);
m.insert("fetchOrder".to_string(), Value::Null);
m.insert("fetchOrderWithClientOrderId".to_string(), Value::Null);
m.insert("fetchOrderBook".to_string(), Value::Bool(true));
m.insert("fetchOrderBooks".to_string(), Value::Null);
m.insert("fetchOrderBookWs".to_string(), Value::Null);
m.insert("fetchOrders".to_string(), Value::Null);
m.insert("fetchOrdersByStatus".to_string(), Value::Null);
m.insert("fetchOrdersWs".to_string(), Value::Null);
m.insert("fetchOrderTrades".to_string(), Value::Null);
m.insert("fetchOrderWs".to_string(), Value::Null);
m.insert("fetchPosition".to_string(), Value::Null);
m.insert("fetchPositionADLRank".to_string(), Value::Null);
m.insert("fetchPositionsADLRank".to_string(), Value::Null);
m.insert("fetchPositionHistory".to_string(), Value::Null);
m.insert("fetchPositionsHistory".to_string(), Value::Null);
m.insert("fetchPositionWs".to_string(), Value::Null);
m.insert("fetchPositionMode".to_string(), Value::Null);
m.insert("fetchPositions".to_string(), Value::Null);
m.insert("fetchPositionsWs".to_string(), Value::Null);
m.insert("fetchPositionsForSymbol".to_string(), Value::Null);
m.insert("fetchPositionsForSymbolWs".to_string(), Value::Null);
m.insert("fetchPositionsRisk".to_string(), Value::Null);
m.insert("fetchPremiumIndexOHLCV".to_string(), Value::Null);
m.insert("fetchSettlementHistory".to_string(), Value::Null);
m.insert("fetchStatus".to_string(), Value::Null);
m.insert("fetchTicker".to_string(), Value::Bool(true));
m.insert("fetchTickerWs".to_string(), Value::Null);
m.insert("fetchTickers".to_string(), Value::Null);
m.insert("fetchMarkPrices".to_string(), Value::Null);
m.insert("fetchTickersWs".to_string(), Value::Null);
m.insert("fetchTime".to_string(), Value::Null);
m.insert("fetchTrades".to_string(), Value::Bool(true));
m.insert("fetchTradesWs".to_string(), Value::Null);
m.insert("fetchTradingFee".to_string(), Value::Null);
m.insert("fetchTradingFees".to_string(), Value::Null);
m.insert("fetchTradingFeesWs".to_string(), Value::Null);
m.insert("fetchTradingLimits".to_string(), Value::Null);
m.insert("fetchTransactionFee".to_string(), Value::Null);
m.insert("fetchTransactionFees".to_string(), Value::Null);
m.insert("fetchTransactions".to_string(), Value::Null);
m.insert("fetchTransfer".to_string(), Value::Null);
m.insert("fetchTransfers".to_string(), Value::Null);
m.insert("fetchUnderlyingAssets".to_string(), Value::Null);
m.insert("fetchVolatilityHistory".to_string(), Value::Null);
m.insert("fetchWithdrawAddresses".to_string(), Value::Null);
m.insert("fetchWithdrawal".to_string(), Value::Null);
m.insert("fetchWithdrawals".to_string(), Value::Null);
m.insert("fetchWithdrawalsWs".to_string(), Value::Null);
m.insert("fetchWithdrawalWhitelist".to_string(), Value::Null);
m.insert("reduceMargin".to_string(), Value::Null);
m.insert("repayCrossMargin".to_string(), Value::Null);
m.insert("repayIsolatedMargin".to_string(), Value::Null);
m.insert("setLeverage".to_string(), Value::Null);
m.insert("setMargin".to_string(), Value::Null);
m.insert("setMarginMode".to_string(), Value::Null);
m.insert("setPositionMode".to_string(), Value::Null);
m.insert("signIn".to_string(), Value::Null);
m.insert("transfer".to_string(), Value::Null);
m.insert("watchBalance".to_string(), Value::Null);
m.insert("watchMyTrades".to_string(), Value::Null);
m.insert("watchOHLCV".to_string(), Value::Null);
m.insert("watchOHLCVForSymbols".to_string(), Value::Null);
m.insert("watchOrderBook".to_string(), Value::Null);
m.insert("watchBidsAsks".to_string(), Value::Null);
m.insert("watchOrderBookForSymbols".to_string(), Value::Null);
m.insert("watchOrders".to_string(), Value::Null);
m.insert("watchOrdersForSymbols".to_string(), Value::Null);
m.insert("watchPosition".to_string(), Value::Null);
m.insert("watchPositions".to_string(), Value::Null);
m.insert("watchStatus".to_string(), Value::Null);
m.insert("watchTicker".to_string(), Value::Null);
m.insert("watchTickers".to_string(), Value::Null);
m.insert("watchTrades".to_string(), Value::Null);
m.insert("watchTradesForSymbols".to_string(), Value::Null);
m.insert("watchLiquidations".to_string(), Value::Null);
m.insert("watchLiquidationsForSymbols".to_string(), Value::Null);
m.insert("watchMyLiquidations".to_string(), Value::Null);
m.insert("unWatchOrders".to_string(), Value::Null);
m.insert("unWatchTrades".to_string(), Value::Null);
m.insert("unWatchTradesForSymbols".to_string(), Value::Null);
m.insert("unWatchOHLCVForSymbols".to_string(), Value::Null);
m.insert("unWatchOrderBookForSymbols".to_string(), Value::Null);
m.insert("unWatchPositions".to_string(), Value::Null);
m.insert("unWatchOrderBook".to_string(), Value::Null);
m.insert("unWatchTickers".to_string(), Value::Null);
m.insert("unWatchMyTrades".to_string(), Value::Null);
m.insert("unWatchTicker".to_string(), Value::Null);
m.insert("unWatchOHLCV".to_string(), Value::Null);
m.insert("watchMyLiquidationsForSymbols".to_string(), Value::Null);
m.insert("withdraw".to_string(), Value::Null);
m.insert("ws".to_string(), Value::Null);
m
}));
m.insert("urls".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("logo".to_string(), Value::Null);
m.insert("api".to_string(), Value::Null);
m.insert("test".to_string(), Value::Null);
m.insert("www".to_string(), Value::Null);
m.insert("doc".to_string(), Value::Null);
m.insert("api_management".to_string(), Value::Null);
m.insert("fees".to_string(), Value::Null);
m.insert("referral".to_string(), Value::Null);
m
}));
m.insert("api".to_string(), Value::Null);
m.insert("requiredCredentials".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("apiKey".to_string(), Value::Bool(true));
m.insert("secret".to_string(), Value::Bool(true));
m.insert("uid".to_string(), Value::Bool(false));
m.insert("accountId".to_string(), Value::Bool(false));
m.insert("login".to_string(), Value::Bool(false));
m.insert("password".to_string(), Value::Bool(false));
m.insert("twofa".to_string(), Value::Bool(false));
m.insert("privateKey".to_string(), Value::Bool(false));
m.insert("walletAddress".to_string(), Value::Bool(false));
m.insert("token".to_string(), Value::Bool(false));
m
}));
m.insert("markets".to_string(), Value::Null);
m.insert("currencies".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m
}));
m.insert("timeframes".to_string(), Value::Null);
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::Null);
m.insert("percentage".to_string(), Value::Null);
m.insert("taker".to_string(), Value::Null);
m.insert("maker".to_string(), Value::Null);
m
}));
m.insert("funding".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("tierBased".to_string(), Value::Null);
m.insert("percentage".to_string(), Value::Null);
m.insert("withdraw".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m
}));
m.insert("deposit".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m
}));
m
}));
m
}));
m.insert("status".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("status".to_string(), Value::Str("ok".to_string()));
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(), Value::Null);
m
}));
m.insert("exceptions".to_string(), Value::Null);
m.insert("httpExceptions".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("422".to_string(), Value::Str("ExchangeError".to_string()).clone());
m.insert("418".to_string(), Value::Str("DDoSProtection".to_string()).clone());
m.insert("429".to_string(), Value::Str("RateLimitExceeded".to_string()).clone());
m.insert("404".to_string(), Value::Str("ExchangeNotAvailable".to_string()).clone());
m.insert("409".to_string(), Value::Str("ExchangeNotAvailable".to_string()).clone());
m.insert("410".to_string(), Value::Str("ExchangeNotAvailable".to_string()).clone());
m.insert("451".to_string(), Value::Str("ExchangeNotAvailable".to_string()).clone());
m.insert("500".to_string(), Value::Str("ExchangeNotAvailable".to_string()).clone());
m.insert("501".to_string(), Value::Str("ExchangeNotAvailable".to_string()).clone());
m.insert("502".to_string(), Value::Str("ExchangeNotAvailable".to_string()).clone());
m.insert("520".to_string(), Value::Str("ExchangeNotAvailable".to_string()).clone());
m.insert("521".to_string(), Value::Str("ExchangeNotAvailable".to_string()).clone());
m.insert("522".to_string(), Value::Str("ExchangeNotAvailable".to_string()).clone());
m.insert("525".to_string(), Value::Str("ExchangeNotAvailable".to_string()).clone());
m.insert("526".to_string(), Value::Str("ExchangeNotAvailable".to_string()).clone());
m.insert("400".to_string(), Value::Str("ExchangeNotAvailable".to_string()).clone());
m.insert("403".to_string(), Value::Str("ExchangeNotAvailable".to_string()).clone());
m.insert("405".to_string(), Value::Str("ExchangeNotAvailable".to_string()).clone());
m.insert("503".to_string(), Value::Str("ExchangeNotAvailable".to_string()).clone());
m.insert("530".to_string(), Value::Str("ExchangeNotAvailable".to_string()).clone());
m.insert("408".to_string(), Value::Str("RequestTimeout".to_string()).clone());
m.insert("504".to_string(), Value::Str("RequestTimeout".to_string()).clone());
m.insert("401".to_string(), Value::Str("AuthenticationError".to_string()).clone());
m.insert("407".to_string(), Value::Str("AuthenticationError".to_string()).clone());
m.insert("511".to_string(), Value::Str("AuthenticationError".to_string()).clone());
m
}));
m.insert("commonCurrencies".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("XBT".to_string(), Value::Str("BTC".to_string()));
m.insert("BCHSV".to_string(), Value::Str("BSV".to_string()));
m
}));
m.insert("precisionMode".to_string(), Value::Int(crate::runtime::TICK_SIZE));
m.insert("paddingMode".to_string(), Value::Int(crate::runtime::NO_PADDING));
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(), Value::Null);
m.insert("max".to_string(), Value::Null);
m
}));
m.insert("price".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("min".to_string(), Value::Null);
m.insert("max".to_string(), Value::Null);
m
}));
m.insert("cost".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("min".to_string(), Value::Null);
m.insert("max".to_string(), Value::Null);
m
}));
m
}));
m.insert("rollingWindowSize".to_string(), Value::Int(60000));
m
});
Value::Null
}
fn clean_rest_data(&mut self) {
self.ids = Value::Null;
self.markets = Value::Null;
self.markets_by_id = Value::Null;
self.symbols = Value::List(vec![]);
self.codes = Value::Null;
{ let __t = self.create_safe_dictionary(&[]); self.currencies = __t; }
self.currencies_by_id = Value::Null;
self.baseCurrencies = Value::Null;
self.quoteCurrencies = Value::Null;
self.last_http_response = Value::Null;
// this.last_json_response = undefined; // not unified prop
self.last_response_headers = Value::Null;
self.last_request_headers = Value::Null;
}
fn clean_ws_data(&mut self) {
{ let __t = self.create_safe_dictionary(&[Value::Bool(true)]); self.balance = __t; }
{ let __t = self.create_safe_dictionary(&[Value::Bool(true)]); self.orderbooks = __t; }
{ let __t = self.create_safe_dictionary(&[Value::Bool(true)]); self.tickers = __t; }
self.liquidations = Value::Null;
self.myLiquidations = Value::Null;
self.orders = Value::Null;
{ let __t = self.create_safe_dictionary(&[Value::Bool(true)]); self.trades = __t; }
{ let __t = self.create_safe_dictionary(&[]); self.transactions = __t; }
{ let __t = self.create_safe_dictionary(&[Value::Bool(true)]); self.ohlcvs = __t; }
self.myTrades = Value::Null;
self.positions = Value::Null;
}
fn safe_bool_n(&self, mut dictionaryOrList: Value, mut keys: Value, optional_args: &[Value]) -> Value {
let mut defaultValue = get_arg(optional_args, 0, Value::Null);
/*
* @ignore
* @method
* @description safely extract boolean value from dictionary or list
* @returns {bool | undefined}
*/
let mut value: Value = self.safe_value_n(dictionaryOrList.clone(), keys.clone(), &[defaultValue.clone()]);
if is_bool(&value) {
return value;
}
return defaultValue;
Value::Null
}
fn safe_bool2(&self, mut dictionaryOrList: Value, mut key1: Value, mut key2: Value, optional_args: &[Value]) -> Value {
let mut defaultValue = get_arg(optional_args, 0, Value::Null);
/*
* @ignore
* @method
* @description safely extract boolean value from dictionary or list
* @returns {bool | undefined}
*/
let mut value: Value = self.safe_value(dictionaryOrList.clone(), key1.clone(), &[]);
if is_bool(&value) {
return value;
}
let mut value2: Value = self.safe_value(dictionaryOrList.clone(), key2.clone(), &[]);
if is_bool(&value2) {
return value2;
}
return defaultValue;
Value::Null
}
fn safe_bool(&self, mut dictionaryOrList: Value, mut key: Value, optional_args: &[Value]) -> Value {
let mut defaultValue = get_arg(optional_args, 0, Value::Null);
/*
* @ignore
* @method
* @description safely extract boolean value from dictionary or list
* @returns {bool | undefined}
*/
let mut value: Value = self.safe_value(dictionaryOrList.clone(), key.clone(), &[defaultValue.clone()]);
if is_bool(&value) {
return value;
}
return defaultValue;
Value::Null
}
fn safe_dict_n(&self, mut dictionaryOrList: Value, mut keys: Value, optional_args: &[Value]) -> Value {
let mut defaultValue = get_arg(optional_args, 0, Value::Null);
/*
* @ignore
* @method
* @description safely extract a dictionary from dictionary or list
* @returns {object | undefined}
*/
let mut value: Value = self.safe_value_n(dictionaryOrList.clone(), keys.clone(), &[defaultValue.clone()]);
if is_equal(&value, &Value::Null) {
return defaultValue;
}
if is_true(&self.is_dictionary(value.clone())) {
return value;
}
return defaultValue;
Value::Null
}
fn safe_dict(&self, mut dictionaryOrList: Value, mut key: Value, optional_args: &[Value]) -> Value {
let mut defaultValue = get_arg(optional_args, 0, Value::Null);
/*
* @ignore
* @method
* @description safely extract a dictionary from dictionary or list
* @returns {object | undefined}
*/
let mut value: Value = self.safe_value(dictionaryOrList.clone(), key.clone(), &[defaultValue.clone()]);
if is_equal(&value, &Value::Null) {
return defaultValue;
}
if is_true(&self.is_dictionary(value.clone())) {
return value;
}
return defaultValue;
Value::Null
}
fn safe_dict2(&self, mut dictionaryOrList: Value, mut key1: Value, mut key2: Value, optional_args: &[Value]) -> Value {
let mut defaultValue = get_arg(optional_args, 0, Value::Null);
/*
* @ignore
* @method
* @description safely extract a dictionary from dictionary or list
* @returns {object | undefined}
*/
let mut value: Value = self.safe_value(dictionaryOrList.clone(), key1.clone(), &[]);
if is_true(&self.is_dictionary(value.clone())) {
return value;
}
let mut value2: Value = self.safe_value(dictionaryOrList.clone(), key2.clone(), &[]);
if is_true(&self.is_dictionary(value2.clone())) {
return value2;
}
return defaultValue;
Value::Null
}
fn safe_list_n(&self, mut dictionaryOrList: Value, mut keys: Value, optional_args: &[Value]) -> Value {
let mut defaultValue = get_arg(optional_args, 0, Value::Null);
/*
* @ignore
* @method
* @description safely extract an Array from dictionary or list
* @returns {Array | undefined}
*/
let mut value: Value = self.safe_value_n(dictionaryOrList.clone(), keys.clone(), &[defaultValue.clone()]);
if is_equal(&value, &Value::Null) {
return defaultValue;
}
if is_true(&Value::Bool(is_array(&value))) {
return value;
}
return defaultValue;
Value::Null
}
fn safe_list2(&self, mut dictionaryOrList: Value, mut key1: Value, mut key2: Value, optional_args: &[Value]) -> Value {
let mut defaultValue = get_arg(optional_args, 0, Value::Null);
/*
* @ignore
* @method
* @description safely extract an Array from dictionary or list
* @returns {Array | undefined}
*/
let mut value: Value = self.safe_value(dictionaryOrList.clone(), key1.clone(), &[]);
if is_true(&(!is_equal(&value, &Value::Null))) && is_true(&Value::Bool(is_array(&value))) {
return value;
}
let mut value2: Value = self.safe_value(dictionaryOrList.clone(), key2.clone(), &[]);
if is_true(&(!is_equal(&value2, &Value::Null))) && is_true(&Value::Bool(is_array(&value2))) {
return value2;
}
return defaultValue;
Value::Null
}
fn safe_list(&self, mut dictionaryOrList: Value, mut key: Value, optional_args: &[Value]) -> Value {
let mut defaultValue = get_arg(optional_args, 0, Value::Null);
/*
* @ignore
* @method
* @description safely extract an Array from dictionary or list
* @returns {Array | undefined}
*/
let mut value: Value = self.safe_value(dictionaryOrList.clone(), key.clone(), &[defaultValue.clone()]);
if is_equal(&value, &Value::Null) {
return defaultValue;
}
if is_true(&Value::Bool(is_array(&value))) {
return value;
}
return defaultValue;
Value::Null
}
fn store_by_key(&self, mut dict: Value, mut key: Value, mut value: Value) {
/*
* @ignore
* @method
* @description store value under key if key is defined (no-op on undefined)
*/
let mut k: Value = key.clone();
if !is_equal(&k, &Value::Null) {
add_element_to_object(&mut dict, &k, value.clone());
}
}
fn handle_deltas(&self, mut orderbook: Value, mut deltas: Value) {
{
let mut i: Value = Value::Int(0);
let mut __for_first_71: bool = true;
while { if !__for_first_71 { i = add(&i, &Value::Int(1)); } __for_first_71 = false; is_less_than(&i, &get_array_length(&deltas)) } {
self.handle_delta(orderbook.clone(), get_value(&deltas, &i));
}
}
}
fn handle_delta(&self, mut bookside: Value, mut delta: Value) {
panic!("{}", crate::exchange_errors::not_supported(add(&self.id, &Value::Str(" handleDelta not supported yet".to_string()))));
}
fn handle_deltas_with_keys(&self, mut bookSide: Value, mut deltas: Value, optional_args: &[Value]) {
let mut priceKey = get_arg(optional_args, 0, Value::Int(0));
let mut amountKey = get_arg(optional_args, 1, Value::Int(1));
let mut countOrIdKey = get_arg(optional_args, 2, Value::Int(2));
{
let mut i: Value = Value::Int(0);
let mut __for_first_72: bool = true;
while { if !__for_first_72 { i = add(&i, &Value::Int(1)); } __for_first_72 = false; is_less_than(&i, &get_array_length(&deltas)) } {
let mut bidAsk: Value = self.parse_order_book_bid_ask(get_value(&deltas, &i), &[priceKey.clone(), amountKey.clone(), countOrIdKey.clone()]);
bookSide.store_array(bidAsk);
}
}
}
fn get_cache_index(&self, mut orderbook: Value, mut deltas: Value) -> Value {
return negate(&Value::Int(1));
Value::Null
}
fn arrays_concat(&self, mut arraysOfArrays: Value) -> Value {
let mut result: Value = Value::List(vec![]);
{
let mut i: Value = Value::Int(0);
let mut __for_first_73: bool = true;
while { if !__for_first_73 { i = add(&i, &Value::Int(1)); } __for_first_73 = false; is_less_than(&i, &get_array_length(&arraysOfArrays)) } {
result = self.array_concat(result.clone(), get_value(&arraysOfArrays, &i));
}
}
return result;
Value::Null
}
fn find_timeframe(&self, mut timeframe: Value, optional_args: &[Value]) -> Value {
let mut timeframes = get_arg(optional_args, 0, Value::Null);
if is_equal(&timeframes, &Value::Null) {
timeframes = self.timeframes.clone();
}
let mut keys: Value = object_keys(&timeframes);
{
let mut i: Value = Value::Int(0);
let mut __for_first_74: bool = true;
while { if !__for_first_74 { i = add(&i, &Value::Int(1)); } __for_first_74 = false; is_less_than(&i, &get_array_length(&keys)) } {
let mut key: Value = get_value(&keys, &i);
let mut key: Value = get_value(&keys, &i);
if is_equal(&get_value(&timeframes, &key), &timeframe) {
return key;
}
}
}
return Value::Null;
Value::Null
}
fn check_proxy_url_settings(&self, optional_args: &[Value]) -> Value {
let mut url = get_arg(optional_args, 0, Value::Null);
let mut method = get_arg(optional_args, 1, Value::Null);
let mut headers = get_arg(optional_args, 2, Value::Null);
let mut body = get_arg(optional_args, 3, Value::Null);
let mut usedProxies: Value = Value::List(vec![]);
let mut proxyUrl: Value = Value::Null;
if !is_equal(&self.proxyUrl, &Value::Null) {
append_to_array(&mut usedProxies, Value::Str("proxyUrl".to_string()));
proxyUrl = self.proxyUrl.clone();
}
if !is_equal(&self.proxy_url, &Value::Null) {
append_to_array(&mut usedProxies, Value::Str("proxy_url".to_string()));
proxyUrl = self.proxy_url.clone();
}
if !is_equal(&self.proxyUrlCallback, &Value::Null) {
append_to_array(&mut usedProxies, Value::Str("proxyUrlCallback".to_string()));
proxyUrl = self.proxy_url_callback_fn(url.clone(), method.clone(), headers.clone(), body.clone());
}
if !is_equal(&self.proxy_url_callback, &Value::Null) {
append_to_array(&mut usedProxies, Value::Str("proxy_url_callback".to_string()));
proxyUrl = self.proxy_url_callback_fn(url.clone(), method.clone(), headers.clone(), body.clone());
}
// backwards-compatibility
if !is_equal(&self.proxy, &Value::Null) {
append_to_array(&mut usedProxies, Value::Str("proxy".to_string()));
if is_function(&self.proxy) {
proxyUrl = self.proxy_fn(url.clone(), method.clone(), headers.clone(), body.clone());
} else {
proxyUrl = self.proxy.clone();
}
}
let mut length: Value = get_array_length(&usedProxies);
if is_greater_than(&length, &Value::Int(1)) {
let mut joinedProxyNames: Value = join(&usedProxies, &Value::Str(",".to_string()));
panic!("{}", crate::exchange_errors::invalid_proxy_settings(add(&add(&add(&self.id, &Value::Str(" you have multiple conflicting proxy settings (".to_string())), &joinedProxyNames), &Value::Str("), please use only one from : proxyUrl, proxy_url, proxyUrlCallback, proxy_url_callback".to_string()))));
}
return proxyUrl;
Value::Null
}
fn url_encoder_for_proxy_url(&self, mut targetUrl: Value) -> Value {
// to be overriden
let mut includesQuery: bool = is_greater_than_or_equal(&get_index_of(&targetUrl, &Value::Str("?".to_string())), &Value::Int(0));
let mut finalUrl: Value = ternary(is_true(&includesQuery), self.encode_uri_component(targetUrl.clone()), targetUrl.clone());
return finalUrl;
Value::Null
}
fn check_proxy_settings(&self, optional_args: &[Value]) -> Value {
let mut url = get_arg(optional_args, 0, Value::Null);
let mut method = get_arg(optional_args, 1, Value::Null);
let mut headers = get_arg(optional_args, 2, Value::Null);
let mut body = get_arg(optional_args, 3, Value::Null);
let mut usedProxies: Value = Value::List(vec![]);
let mut httpProxy: Value = Value::Null;
let mut httpsProxy: Value = Value::Null;
let mut socksProxy: Value = Value::Null;
// httpProxy
let mut isHttpProxyDefined: Value = self.value_is_defined(self.httpProxy.clone());
let mut isHttp_proxy_defined: Value = self.value_is_defined(self.http_proxy.clone());
if is_true(&isHttpProxyDefined) || is_true(&isHttp_proxy_defined) {
append_to_array(&mut usedProxies, Value::Str("httpProxy".to_string()));
httpProxy = ternary(is_true(&isHttpProxyDefined), self.httpProxy.clone(), self.http_proxy.clone());
}
let mut ishttpProxyCallbackDefined: Value = self.value_is_defined(self.httpProxyCallback.clone());
let mut ishttp_proxy_callback_defined: Value = self.value_is_defined(self.http_proxy_callback.clone());
if is_true(&ishttpProxyCallbackDefined) || is_true(&ishttp_proxy_callback_defined) {
append_to_array(&mut usedProxies, Value::Str("httpProxyCallback".to_string()));
httpProxy = ternary(is_true(&ishttpProxyCallbackDefined), self.http_proxy_callback_fn(url.clone(), method.clone(), headers.clone(), body.clone()), self.http_proxy_callback_fn(url.clone(), method.clone(), headers.clone(), body.clone()));
}
// httpsProxy
let mut isHttpsProxyDefined: Value = self.value_is_defined(self.httpsProxy.clone());
let mut isHttps_proxy_defined: Value = self.value_is_defined(self.https_proxy.clone());
if is_true(&isHttpsProxyDefined) || is_true(&isHttps_proxy_defined) {
append_to_array(&mut usedProxies, Value::Str("httpsProxy".to_string()));
httpsProxy = ternary(is_true(&isHttpsProxyDefined), self.httpsProxy.clone(), self.https_proxy.clone());
}
let mut ishttpsProxyCallbackDefined: Value = self.value_is_defined(self.httpsProxyCallback.clone());
let mut ishttps_proxy_callback_defined: Value = self.value_is_defined(self.https_proxy_callback.clone());
if is_true(&ishttpsProxyCallbackDefined) || is_true(&ishttps_proxy_callback_defined) {
append_to_array(&mut usedProxies, Value::Str("httpsProxyCallback".to_string()));
httpsProxy = ternary(is_true(&ishttpsProxyCallbackDefined), self.https_proxy_callback_fn(url.clone(), method.clone(), headers.clone(), body.clone()), self.https_proxy_callback_fn(url.clone(), method.clone(), headers.clone(), body.clone()));
}
// socksProxy
let mut isSocksProxyDefined: Value = self.value_is_defined(self.socksProxy.clone());
let mut isSocks_proxy_defined: Value = self.value_is_defined(self.socks_proxy.clone());
if is_true(&isSocksProxyDefined) || is_true(&isSocks_proxy_defined) {
append_to_array(&mut usedProxies, Value::Str("socksProxy".to_string()));
socksProxy = ternary(is_true(&isSocksProxyDefined), self.socksProxy.clone(), self.socks_proxy.clone());
}
let mut issocksProxyCallbackDefined: Value = self.value_is_defined(self.socksProxyCallback.clone());
let mut issocks_proxy_callback_defined: Value = self.value_is_defined(self.socks_proxy_callback.clone());
if is_true(&issocksProxyCallbackDefined) || is_true(&issocks_proxy_callback_defined) {
append_to_array(&mut usedProxies, Value::Str("socksProxyCallback".to_string()));
socksProxy = ternary(is_true(&issocksProxyCallbackDefined), self.socks_proxy_callback_fn(url.clone(), method.clone(), headers.clone(), body.clone()), self.socks_proxy_callback_fn(url.clone(), method.clone(), headers.clone(), body.clone()));
}
// check
let mut length: Value = get_array_length(&usedProxies);
if is_greater_than(&length, &Value::Int(1)) {
let mut joinedProxyNames: Value = join(&usedProxies, &Value::Str(",".to_string()));
panic!("{}", crate::exchange_errors::invalid_proxy_settings(add(&add(&add(&self.id, &Value::Str(" you have multiple conflicting proxy settings (".to_string())), &joinedProxyNames), &Value::Str("), please use only one from: httpProxy, httpsProxy, httpProxyCallback, httpsProxyCallback, socksProxy, socksProxyCallback".to_string()))));
}
return Value::List(vec![httpProxy.clone(), httpsProxy.clone(), socksProxy.clone()]);
Value::Null
}
fn check_ws_proxy_settings(&self) -> Value {
let mut usedProxies: Value = Value::List(vec![]);
let mut wsProxy: Value = Value::Null;
let mut wssProxy: Value = Value::Null;
let mut wsSocksProxy: Value = Value::Null;
// ws proxy
let mut isWsProxyDefined: Value = self.value_is_defined(self.wsProxy.clone());
let mut is_ws_proxy_defined: Value = self.value_is_defined(self.ws_proxy.clone());
if is_true(&isWsProxyDefined) || is_true(&is_ws_proxy_defined) {
append_to_array(&mut usedProxies, Value::Str("wsProxy".to_string()));
wsProxy = ternary(is_true(&(isWsProxyDefined)), self.wsProxy.clone(), self.ws_proxy.clone());
}
// wss proxy
let mut isWssProxyDefined: Value = self.value_is_defined(self.wssProxy.clone());
let mut is_wss_proxy_defined: Value = self.value_is_defined(self.wss_proxy.clone());
if is_true(&isWssProxyDefined) || is_true(&is_wss_proxy_defined) {
append_to_array(&mut usedProxies, Value::Str("wssProxy".to_string()));
wssProxy = ternary(is_true(&(isWssProxyDefined)), self.wssProxy.clone(), self.wss_proxy.clone());
}
// ws socks proxy
let mut isWsSocksProxyDefined: Value = self.value_is_defined(self.wsSocksProxy.clone());
let mut is_ws_socks_proxy_defined: Value = self.value_is_defined(self.ws_socks_proxy.clone());
if is_true(&isWsSocksProxyDefined) || is_true(&is_ws_socks_proxy_defined) {
append_to_array(&mut usedProxies, Value::Str("wsSocksProxy".to_string()));
wsSocksProxy = ternary(is_true(&(isWsSocksProxyDefined)), self.wsSocksProxy.clone(), self.ws_socks_proxy.clone());
}
// check
let mut length: Value = get_array_length(&usedProxies);
if is_greater_than(&length, &Value::Int(1)) {
let mut joinedProxyNames: Value = join(&usedProxies, &Value::Str(",".to_string()));
panic!("{}", crate::exchange_errors::invalid_proxy_settings(add(&add(&add(&self.id, &Value::Str(" you have multiple conflicting proxy settings (".to_string())), &joinedProxyNames), &Value::Str("), please use only one from: wsProxy, wssProxy, wsSocksProxy".to_string()))));
}
return Value::List(vec![wsProxy.clone(), wssProxy.clone(), wsSocksProxy.clone()]);
Value::Null
}
fn check_conflicting_proxies(&self, mut proxyAgentSet: Value, mut proxyUrlSet: Value) {
let mut proxyAgentIsSet: bool = is_true(&(!is_equal(&proxyAgentSet, &Value::Null))) && is_true(&(!is_equal(&proxyAgentSet, &Value::Null))) && is_true(&(!is_equal(&proxyAgentSet, &Value::Str("".to_string()))));
let mut proxyUrlIsSet: bool = is_true(&(!is_equal(&proxyUrlSet, &Value::Null))) && is_true(&(!is_equal(&proxyUrlSet, &Value::Null))) && is_true(&(!is_equal(&proxyUrlSet, &Value::Str("".to_string()))));
if is_true(&proxyAgentIsSet) && is_true(&proxyUrlIsSet) {
panic!("{}", crate::exchange_errors::invalid_proxy_settings(add(&self.id, &Value::Str(" you have multiple conflicting proxy settings, please use only one from : proxyUrl, httpProxy, httpsProxy, socksProxy".to_string()))));
}
}
fn check_address(&self, optional_args: &[Value]) -> Value {
let mut address = get_arg(optional_args, 0, Value::Null);
if is_equal(&address, &Value::Null) {
panic!("{}", crate::exchange_errors::invalid_address(add(&self.id, &Value::Str(" address is undefined".to_string()))));
}
// check the address is not the same letter like 'aaaaa' nor too short nor has a space
let mut uniqChars: Value = (self.unique(self.string_to_chars_array(address.clone())));
let mut length: Value = get_array_length(&uniqChars); // py transpiler trick
if is_equal(&length, &Value::Int(1)) || is_less_than(&get_array_length(&address), &self.minFundingAddressLength) || is_greater_than(&get_index_of(&address, &Value::Str(" ".to_string())), &negate(&Value::Int(1))) {
panic!("{}", crate::exchange_errors::invalid_address(add(&add(&add(&add(&add(&self.id, &Value::Str(" address is invalid or has less than ".to_string())), &to_string_val(&self.minFundingAddressLength)), &Value::Str(" characters: \"".to_string())), &to_string_val(&address)), &Value::Str("\"".to_string()))));
}
return address;
Value::Null
}
fn find_message_hashes(&self, mut client: Value, mut element: Value) -> Value {
let mut result: Value = Value::List(vec![]);
let mut messageHashes: Value = object_keys(&get_value(&client, &Value::Str("futures".to_string())));
{
let mut i: Value = Value::Int(0);
let mut __for_first_75: bool = true;
while { if !__for_first_75 { i = add(&i, &Value::Int(1)); } __for_first_75 = false; is_less_than(&i, &get_array_length(&messageHashes)) } {
let mut messageHash: Value = get_value(&messageHashes, &i);
let mut messageHash: Value = get_value(&messageHashes, &i);
if is_greater_than_or_equal(&get_index_of(&messageHash, &element), &Value::Int(0)) {
append_to_array(&mut result, messageHash.clone());
}
}
}
return result;
Value::Null
}
fn filter_by_limit(&self, mut array: Value, optional_args: &[Value]) -> Value {
let mut limit = get_arg(optional_args, 0, Value::Null);
let mut key = get_arg(optional_args, 1, Value::Str("timestamp".to_string()));
let mut fromStart = get_arg(optional_args, 2, Value::Bool(false));
if is_true(&self.value_is_defined(limit.clone())) {
let mut arrayLength: Value = get_array_length(&array);
if is_greater_than(&arrayLength, &Value::Int(0)) {
let mut ascending: bool = true;
if is_true(&(Value::Bool(in_op(&get_value(&array, &Value::Int(0)), &key)))) {
let mut first: Value = get_value(&get_value(&array, &Value::Int(0)), &key);
let mut last: Value = get_value(&get_value(&array, &subtract(&arrayLength, &Value::Int(1))), &key);
if !is_equal(&first, &Value::Null) && !is_equal(&last, &Value::Null) {
ascending = is_less_than_or_equal(&first, &last); // true if array is sorted in ascending order based on 'timestamp'
}
}
if is_true(&fromStart) {
if is_greater_than(&limit, &arrayLength) {
limit = arrayLength.clone();
}
// array = ascending ? this.arraySlice (array, 0, limit) : this.arraySlice (array, -limit);
if is_true(&ascending) {
array = self.array_slice(array.clone(), Value::Int(0), &[limit.clone()]);
} else {
array = self.array_slice(array.clone(), negate(&limit), &[]);
}
} else {
// array = ascending ? this.arraySlice (array, -limit) : this.arraySlice (array, 0, limit);
if is_true(&ascending) {
array = self.array_slice(array.clone(), negate(&limit), &[]);
} else {
array = self.array_slice(array.clone(), Value::Int(0), &[limit.clone()]);
}
}
}
}
return array;
Value::Null
}
fn filter_by_since_limit(&self, mut array: 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 key = get_arg(optional_args, 2, Value::Str("timestamp".to_string()));
let mut tail = get_arg(optional_args, 3, Value::Bool(false));
if is_equal(&array, &Value::Null) {
return Value::List(vec![]);
}
let mut sinceIsDefined: Value = self.value_is_defined(since.clone());
let mut parsedArray: Value = self.to_array(array.clone());
let mut result: Value = parsedArray.clone();
if is_true(&sinceIsDefined) {
result = Value::List(vec![]);
{
let mut i: Value = Value::Int(0);
let mut __for_first_76: bool = true;
while { if !__for_first_76 { i = add(&i, &Value::Int(1)); } __for_first_76 = false; is_less_than(&i, &get_array_length(&parsedArray)) } {
let mut entry: Value = get_value(&parsedArray, &i);
let mut entry: Value = get_value(&parsedArray, &i);
let mut value: Value = self.safe_value(entry.clone(), key.clone(), &[]);
if is_true(&(!is_equal(&value, &Value::Null))) && is_true(&(!is_equal(&value, &Value::Null))) && is_true(&(!is_equal(&value, &Value::Int(0)))) && is_true(&(is_greater_than_or_equal(&value, &since))) {
append_to_array(&mut result, entry.clone());
}
}
}
}
if is_true(&tail) && !is_equal(&limit, &Value::Null) {
return self.array_slice(result.clone(), negate(&limit), &[]);
}
// if the user provided a 'since' argument
// we want to limit the result starting from the 'since'
let mut shouldFilterFromStart: Value = Value::Bool(!is_true(&tail) && is_true(&sinceIsDefined));
return self.filter_by_limit(result.clone(), &[limit.clone(), key.clone(), shouldFilterFromStart.clone()]);
Value::Null
}
fn filter_by_value_since_limit(&self, mut array: Value, mut field: Value, optional_args: &[Value]) -> Value {
let mut value = 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 key = get_arg(optional_args, 3, Value::Str("timestamp".to_string()));
let mut tail = get_arg(optional_args, 4, Value::Bool(false));
let mut valueIsDefined: Value = self.value_is_defined(value.clone());
let mut sinceIsDefined: Value = self.value_is_defined(since.clone());
let mut parsedArray: Value = self.to_array(array.clone());
let mut result: Value = parsedArray.clone();
// single-pass filter for both symbol and since
if is_true(&valueIsDefined) || is_true(&sinceIsDefined) {
result = Value::List(vec![]);
{
let mut i: Value = Value::Int(0);
let mut __for_first_77: bool = true;
while { if !__for_first_77 { i = add(&i, &Value::Int(1)); } __for_first_77 = false; is_less_than(&i, &get_array_length(&parsedArray)) } {
let mut entry: Value = get_value(&parsedArray, &i);
let mut entry: Value = get_value(&parsedArray, &i);
// safeValue (not entry[field]) so a missing field is a non-match, not a
// KeyError in python/php — prediction structures key on outcome, not symbol
let mut entryFiledEqualValue: Value = Value::Bool(is_equal(&self.safe_value(entry.clone(), field.clone(), &[]), &value));
let mut firstCondition: Value = ternary(is_true(&valueIsDefined), entryFiledEqualValue.clone(), Value::Bool(true));
let mut entryKeyValue: Value = self.safe_value(entry.clone(), key.clone(), &[]);
let mut entryKeyGESince: Value = Value::Bool(is_true(&(!is_equal(&entryKeyValue, &Value::Null))) && is_true(&(!is_equal(&entryKeyValue, &Value::Null))) && is_true(&(!is_equal(&entryKeyValue, &Value::Int(0)))) && is_true(&(!is_equal(&since, &Value::Null))) && is_true(&(is_greater_than_or_equal(&entryKeyValue, &since))));
let mut secondCondition: Value = ternary(is_true(&sinceIsDefined), entryKeyGESince.clone(), Value::Bool(true));
if is_true(&firstCondition) && is_true(&secondCondition) {
append_to_array(&mut result, entry.clone());
}
}
}
}
if is_true(&tail) && !is_equal(&limit, &Value::Null) {
return self.array_slice(result.clone(), negate(&limit), &[]);
}
return self.filter_by_limit(result.clone(), &[limit.clone(), key.clone(), sinceIsDefined.clone()]);
Value::Null
}
/*
* @method
* @name Exchange#setSandboxMode
* @description set the sandbox mode for the exchange
* @param {boolean} enabled true to enable sandbox mode, false to disable it
*/
fn set_sandbox_mode(&mut self, mut enabled: Value) {
if is_true(&enabled) {
if is_true(&Value::Bool(in_op(&self.urls, &Value::Str("test".to_string())))) {
if is_string(&get_value(&self.urls, &Value::Str("api".to_string()))) {
{ let __be_tmp = get_value(&self.urls, &Value::Str("api".to_string())); add_element_to_object(&mut self.urls, &Value::Str("apiBackup".to_string()), __be_tmp); };
{ let __be_tmp = get_value(&self.urls, &Value::Str("test".to_string())); add_element_to_object(&mut self.urls, &Value::Str("api".to_string()), __be_tmp); };
} else {
{ let __be_tmp = self.clone_value(get_value(&self.urls, &Value::Str("api".to_string()))); add_element_to_object(&mut self.urls, &Value::Str("apiBackup".to_string()), __be_tmp); };
{ let __be_tmp = self.clone_value(get_value(&self.urls, &Value::Str("test".to_string()))); add_element_to_object(&mut self.urls, &Value::Str("api".to_string()), __be_tmp); };
}
} else {
panic!("{}", crate::exchange_errors::not_supported(add(&self.id, &Value::Str(" does not have a sandbox URL".to_string()))));
}
// set flag
self.isSandboxModeEnabled = Value::Bool(true);
} else if is_true(&Value::Bool(in_op(&self.urls, &Value::Str("apiBackup".to_string())))) {
if is_string(&get_value(&self.urls, &Value::Str("api".to_string()))) {
{ let __be_tmp = get_value(&self.urls, &Value::Str("apiBackup".to_string())); add_element_to_object(&mut self.urls, &Value::Str("api".to_string()), __be_tmp); };
} else {
{ let __be_tmp = self.clone_value(get_value(&self.urls, &Value::Str("apiBackup".to_string()))); add_element_to_object(&mut self.urls, &Value::Str("api".to_string()), __be_tmp); };
}
let mut newUrls: Value = self.omit(self.urls.clone(), Value::Str("apiBackup".to_string()), &[]);
self.urls = newUrls.clone();
// set flag
self.isSandboxModeEnabled = Value::Bool(false);
}
}
/*
* @method
* @name Exchange#enableDemoTrading
* @description enables or disables demo trading mode
* @param {boolean} [enable] true if demo trading should be enabled, false otherwise
*/
fn enable_demo_trading(&mut self, mut enable: Value) {
if is_true(&self.isSandboxModeEnabled) {
panic!("{}", crate::exchange_errors::not_supported(add(&self.id, &Value::Str(" demo trading does not support in sandbox environment. Please check https://www.binance.com/en/support/faq/detail/9be58f73e5e14338809e3b705b9687dd to see the differences".to_string()))));
}
if is_true(&enable) {
{ let __be_tmp = get_value(&self.urls, &Value::Str("api".to_string())); add_element_to_object(&mut self.urls, &Value::Str("apiBackupDemoTrading".to_string()), __be_tmp); };
{ let __be_tmp = get_value(&self.urls, &Value::Str("demo".to_string())); add_element_to_object(&mut self.urls, &Value::Str("api".to_string()), __be_tmp); };
} else if is_true(&Value::Bool(in_op(&self.urls, &Value::Str("apiBackupDemoTrading".to_string())))) {
{ let __be_tmp = get_value(&self.urls, &Value::Str("apiBackupDemoTrading".to_string())); add_element_to_object(&mut self.urls, &Value::Str("api".to_string()), __be_tmp); };
let mut newUrls: Value = self.omit(self.urls.clone(), Value::Str("apiBackupDemoTrading".to_string()), &[]);
self.urls = newUrls.clone();
}
add_element_to_object(&mut self.options, &Value::Str("enableDemoTrading".to_string()), enable.clone());
}
fn sign(&self, mut path: Value, optional_args: &[Value]) -> Value {
// virtual-dispatch (static: DerivedExchange::sign(self, ...))
{ let __v = crate::exchange::DerivedExchange::sign(self, path.clone(), crate::runtime::get_arg(optional_args, 0, crate::Value::Null), crate::runtime::get_arg(optional_args, 1, crate::Value::Null), crate::runtime::get_arg(optional_args, 2, crate::Value::Null), crate::runtime::get_arg(optional_args, 3, crate::Value::Null), crate::runtime::get_arg(optional_args, 4, crate::Value::Null)); if !matches!(__v, crate::Value::Null) { return __v; } }
let mut api = get_arg(optional_args, 0, Value::Str("public".to_string()));
let mut method = get_arg(optional_args, 1, Value::Str("GET".to_string()));
let mut params = get_arg(optional_args, 2, Value::Map({
let mut m = indexmap::IndexMap::new();
m
}));
let mut headers = get_arg(optional_args, 3, Value::Null);
let mut body = get_arg(optional_args, 4, Value::Null);
return Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("url".to_string(), Value::Null);
m.insert("method".to_string(), Value::Null);
m.insert("headers".to_string(), Value::Null);
m.insert("body".to_string(), Value::Null);
m
});
Value::Null
}
fn fetch_accounts(&mut self, optional_args: &[Value]) -> impl ::std::future::Future<Output = Value> + Send { async move {
let mut params = get_arg(optional_args, 0, Value::Map({
let mut m = indexmap::IndexMap::new();
m
}));
panic!("{}", crate::exchange_errors::not_supported(add(&self.id, &Value::Str(" fetchAccounts() is not supported yet".to_string()))));
Value::Null
} }
fn watch_liquidations(&mut self, mut symbol: Value, optional_args: &[Value]) -> impl ::std::future::Future<Output = Value> + Send { async move {
let mut since = get_arg(optional_args, 0, Value::Null);
let mut limit = get_arg(optional_args, 1, Value::Null);
let mut params = get_arg(optional_args, 2, Value::Map({
let mut m = indexmap::IndexMap::new();
m
}));
if !is_equal(&get_value(&self.has, &Value::Str("watchLiquidationsForSymbols".to_string())), &Value::Null) && !is_equal(&get_value(&self.has, &Value::Str("watchLiquidationsForSymbols".to_string())), &Value::Bool(false)) {
return self.watch_liquidations_for_symbols(Value::List(vec![symbol.clone()]), &[since.clone(), limit.clone(), params.clone()]).await;
}
panic!("{}", crate::exchange_errors::not_supported(add(&self.id, &Value::Str(" watchLiquidations() is not supported yet".to_string()))));
Value::Null
} }
fn watch_liquidations_for_symbols(&mut self, mut symbols: Value, optional_args: &[Value]) -> impl ::std::future::Future<Output = Value> + Send { async move {
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
}));
panic!("{}", crate::exchange_errors::not_supported(add(&self.id, &Value::Str(" watchLiquidationsForSymbols() is not supported yet".to_string()))));
Value::Null
} }
fn watch_my_liquidations(&mut self, mut symbol: Value, optional_args: &[Value]) -> impl ::std::future::Future<Output = Value> + Send { async move {
let mut since = get_arg(optional_args, 0, Value::Null);
let mut limit = get_arg(optional_args, 1, Value::Null);
let mut params = get_arg(optional_args, 2, Value::Map({
let mut m = indexmap::IndexMap::new();
m
}));
if !is_equal(&get_value(&self.has, &Value::Str("watchMyLiquidationsForSymbols".to_string())), &Value::Null) && !is_equal(&get_value(&self.has, &Value::Str("watchMyLiquidationsForSymbols".to_string())), &Value::Bool(false)) {
return self.watch_my_liquidations_for_symbols(Value::List(vec![symbol.clone()]), &[since.clone(), limit.clone(), params.clone()]).await;
}
panic!("{}", crate::exchange_errors::not_supported(add(&self.id, &Value::Str(" watchMyLiquidations() is not supported yet".to_string()))));
Value::Null
} }
fn watch_my_liquidations_for_symbols(&mut self, mut symbols: Value, optional_args: &[Value]) -> impl ::std::future::Future<Output = Value> + Send { async move {
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
}));
panic!("{}", crate::exchange_errors::not_supported(add(&self.id, &Value::Str(" watchMyLiquidationsForSymbols() is not supported yet".to_string()))));
Value::Null
} }
fn un_watch_orders(&mut self, optional_args: &[Value]) -> impl ::std::future::Future<Output = Value> + Send { async move {
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
}));
panic!("{}", crate::exchange_errors::not_supported(add(&self.id, &Value::Str(" unWatchOrders() is not supported yet".to_string()))));
Value::Null
} }
fn un_watch_trades(&mut self, mut symbol: Value, optional_args: &[Value]) -> impl ::std::future::Future<Output = Value> + Send { async move {
let mut params = get_arg(optional_args, 0, Value::Map({
let mut m = indexmap::IndexMap::new();
m
}));
panic!("{}", crate::exchange_errors::not_supported(add(&self.id, &Value::Str(" unWatchTrades() is not supported yet".to_string()))));
Value::Null
} }
fn un_watch_trades_for_symbols(&mut self, mut symbols: Value, optional_args: &[Value]) -> impl ::std::future::Future<Output = Value> + Send { async move {
let mut params = get_arg(optional_args, 0, Value::Map({
let mut m = indexmap::IndexMap::new();
m
}));
panic!("{}", crate::exchange_errors::not_supported(add(&self.id, &Value::Str(" unWatchTradesForSymbols() is not supported yet".to_string()))));
Value::Null
} }
fn watch_ohlcv_for_symbols(&mut self, mut symbolsAndTimeframes: Value, optional_args: &[Value]) -> impl ::std::future::Future<Output = Value> + Send { async move {
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
}));
panic!("{}", crate::exchange_errors::not_supported(add(&self.id, &Value::Str(" watchOHLCVForSymbols() is not supported yet".to_string()))));
Value::Null
} }
fn un_watch_ohlcv_for_symbols(&mut self, mut symbolsAndTimeframes: Value, optional_args: &[Value]) -> impl ::std::future::Future<Output = Value> + Send { async move {
let mut params = get_arg(optional_args, 0, Value::Map({
let mut m = indexmap::IndexMap::new();
m
}));
panic!("{}", crate::exchange_errors::not_supported(add(&self.id, &Value::Str(" unWatchOHLCVForSymbols() is not supported yet".to_string()))));
Value::Null
} }
fn un_watch_order_book_for_symbols(&mut self, mut symbols: Value, optional_args: &[Value]) -> impl ::std::future::Future<Output = Value> + Send { async move {
let mut params = get_arg(optional_args, 0, Value::Map({
let mut m = indexmap::IndexMap::new();
m
}));
panic!("{}", crate::exchange_errors::not_supported(add(&self.id, &Value::Str(" unWatchOrderBookForSymbols() is not supported yet".to_string()))));
Value::Null
} }
fn un_watch_positions(&mut self, optional_args: &[Value]) -> impl ::std::future::Future<Output = Value> + Send { async move {
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
}));
panic!("{}", crate::exchange_errors::not_supported(add(&self.id, &Value::Str(" unWatchPositions() is not supported yet".to_string()))));
Value::Null
} }
fn un_watch_ticker(&mut self, mut symbol: Value, optional_args: &[Value]) -> impl ::std::future::Future<Output = Value> + Send { async move {
let mut params = get_arg(optional_args, 0, Value::Map({
let mut m = indexmap::IndexMap::new();
m
}));
panic!("{}", crate::exchange_errors::not_supported(add(&self.id, &Value::Str(" unWatchTicker() is not supported yet".to_string()))));
Value::Null
} }
fn un_watch_mark_price(&mut self, mut symbol: Value, optional_args: &[Value]) -> impl ::std::future::Future<Output = Value> + Send { async move {
let mut params = get_arg(optional_args, 0, Value::Map({
let mut m = indexmap::IndexMap::new();
m
}));
panic!("{}", crate::exchange_errors::not_supported(add(&self.id, &Value::Str(" unWatchMarkPrice() is not supported yet".to_string()))));
Value::Null
} }
fn un_watch_mark_prices(&mut self, optional_args: &[Value]) -> impl ::std::future::Future<Output = Value> + Send { async move {
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
}));
panic!("{}", crate::exchange_errors::not_supported(add(&self.id, &Value::Str(" unWatchMarkPrices() is not supported yet".to_string()))));
Value::Null
} }
fn fetch_deposit_addresses(&mut self, optional_args: &[Value]) -> impl ::std::future::Future<Output = Value> + Send { async move {
// async-virtual: try the derived exchange first
if let Some(__v) = self.dispatch_to_derived("fetch_deposit_addresses", { let mut __args: Vec<crate::Value> = Vec::new(); __args.extend_from_slice(optional_args); __args }).await {
if !matches!(__v, crate::Value::Null) { return __v; }
}
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
}));
panic!("{}", crate::exchange_errors::not_supported(add(&self.id, &Value::Str(" fetchDepositAddresses() is not supported yet".to_string()))));
Value::Null
} }
fn fetch_margin_mode(&mut self, mut symbol: Value, optional_args: &[Value]) -> impl ::std::future::Future<Output = Value> + Send { async move {
// async-virtual: try the derived exchange first
if let Some(__v) = self.dispatch_to_derived("fetch_margin_mode", { let mut __args: Vec<crate::Value> = Vec::new(); __args.push(symbol.clone()); __args.extend_from_slice(optional_args); __args }).await {
if !matches!(__v, crate::Value::Null) { return __v; }
}
let mut params = get_arg(optional_args, 0, Value::Map({
let mut m = indexmap::IndexMap::new();
m
}));
if !is_equal(&get_value(&self.has, &Value::Str("fetchMarginModes".to_string())), &Value::Null) && !is_equal(&get_value(&self.has, &Value::Str("fetchMarginModes".to_string())), &Value::Bool(false)) {
let mut marginModes: Value = self.fetch_margin_modes(&[Value::List(vec![symbol.clone()]), params.clone()]).await;
return self.safe_dict(marginModes.clone(), symbol.clone(), &[]);
} else {
panic!("{}", crate::exchange_errors::not_supported(add(&self.id, &Value::Str(" fetchMarginMode() is not supported yet".to_string()))));
}
Value::Null
} }
fn fetch_margin_modes(&mut self, optional_args: &[Value]) -> impl ::std::future::Future<Output = Value> + Send { async move {
// async-virtual: try the derived exchange first
if let Some(__v) = self.dispatch_to_derived("fetch_margin_modes", { let mut __args: Vec<crate::Value> = Vec::new(); __args.extend_from_slice(optional_args); __args }).await {
if !matches!(__v, crate::Value::Null) { return __v; }
}
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
}));
panic!("{}", crate::exchange_errors::not_supported(add(&self.id, &Value::Str(" fetchMarginModes () is not supported yet".to_string()))));
Value::Null
} }
fn un_watch_order_book(&mut self, mut symbol: Value, optional_args: &[Value]) -> impl ::std::future::Future<Output = Value> + Send { async move {
let mut params = get_arg(optional_args, 0, Value::Map({
let mut m = indexmap::IndexMap::new();
m
}));
panic!("{}", crate::exchange_errors::not_supported(add(&self.id, &Value::Str(" unWatchOrderBook() is not supported yet".to_string()))));
Value::Null
} }
fn fetch_time(&mut self, optional_args: &[Value]) -> impl ::std::future::Future<Output = Value> + Send { async move {
// async-virtual: try the derived exchange first
if let Some(__v) = self.dispatch_to_derived("fetch_time", { let mut __args: Vec<crate::Value> = Vec::new(); __args.extend_from_slice(optional_args); __args }).await {
if !matches!(__v, crate::Value::Null) { return __v; }
}
let mut params = get_arg(optional_args, 0, Value::Map({
let mut m = indexmap::IndexMap::new();
m
}));
panic!("{}", crate::exchange_errors::not_supported(add(&self.id, &Value::Str(" fetchTime() is not supported yet".to_string()))));
Value::Null
} }
fn fetch_trading_limits(&mut self, optional_args: &[Value]) -> impl ::std::future::Future<Output = Value> + Send { async move {
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
}));
panic!("{}", crate::exchange_errors::not_supported(add(&self.id, &Value::Str(" fetchTradingLimits() is not supported yet".to_string()))));
Value::Null
} }
fn parse_currency(&self, mut rawCurrency: Value) -> Value {
// virtual-dispatch (static: DerivedExchange::parse_currency(self, ...))
{ let __v = crate::exchange::DerivedExchange::parse_currency(self, rawCurrency.clone()); if !matches!(__v, crate::Value::Null) { return __v; } }
panic!("{}", crate::exchange_errors::not_supported(add(&self.id, &Value::Str(" parseCurrency() is not supported yet".to_string()))));
Value::Null
}
fn parse_currencies(&self, mut rawCurrencies: Value) -> Value {
let mut result: Value = Value::Map({
let mut m = indexmap::IndexMap::new();
m
});
let mut arr: Value = self.to_array(rawCurrencies.clone());
{
let mut i: Value = Value::Int(0);
let mut __for_first_78: bool = true;
while { if !__for_first_78 { i = add(&i, &Value::Int(1)); } __for_first_78 = false; is_less_than(&i, &get_array_length(&arr)) } {
let mut parsed: Value = <Self as crate::exchange_generated::ExchangeBase>::parse_currency(self, get_value(&arr, &i));
if is_equal(&parsed, &Value::Null) {
continue;
}
let mut code: Value = get_value(&parsed, &Value::Str("code".to_string()));
add_element_to_object(&mut result, &code, parsed.clone());
}
}
return result;
Value::Null
}
fn parse_market(&self, mut market: Value) -> Value {
// virtual-dispatch (static: DerivedExchange::parse_market(self, ...))
{ let __v = crate::exchange::DerivedExchange::parse_market(self, market.clone()); if !matches!(__v, crate::Value::Null) { return __v; } }
panic!("{}", crate::exchange_errors::not_supported(add(&self.id, &Value::Str(" parseMarket() is not supported yet".to_string()))));
Value::Null
}
fn parse_markets(&self, mut markets: Value) -> Value {
let mut result: Value = Value::List(vec![]);
{
let mut i: Value = Value::Int(0);
let mut __for_first_79: bool = true;
while { if !__for_first_79 { i = add(&i, &Value::Int(1)); } __for_first_79 = false; is_less_than(&i, &get_array_length(&markets)) } {
append_to_array(&mut result, <Self as crate::exchange_generated::ExchangeBase>::parse_market(self, get_value(&markets, &i)));
}
}
return result;
Value::Null
}
fn parse_ticker(&self, mut ticker: Value, optional_args: &[Value]) -> Value {
// virtual-dispatch (static: DerivedExchange::parse_ticker(self, ...))
{ let __v = crate::exchange::DerivedExchange::parse_ticker(self, ticker.clone(), crate::runtime::get_arg(optional_args, 0, crate::Value::Null)); if !matches!(__v, crate::Value::Null) { return __v; } }
let mut market = get_arg(optional_args, 0, Value::Null);
panic!("{}", crate::exchange_errors::not_supported(add(&self.id, &Value::Str(" parseTicker() is not supported yet".to_string()))));
Value::Null
}
fn parse_deposit_address(&self, mut depositAddress: Value, optional_args: &[Value]) -> Value {
// virtual-dispatch (static: DerivedExchange::parse_deposit_address(self, ...))
{ let __v = crate::exchange::DerivedExchange::parse_deposit_address(self, depositAddress.clone(), crate::runtime::get_arg(optional_args, 0, crate::Value::Null)); if !matches!(__v, crate::Value::Null) { return __v; } }
let mut currency = get_arg(optional_args, 0, Value::Null);
panic!("{}", crate::exchange_errors::not_supported(add(&self.id, &Value::Str(" parseDepositAddress() is not supported yet".to_string()))));
Value::Null
}
fn parse_trade(&self, mut trade: Value, optional_args: &[Value]) -> Value {
// virtual-dispatch (static: DerivedExchange::parse_trade(self, ...))
{ let __v = crate::exchange::DerivedExchange::parse_trade(self, trade.clone(), crate::runtime::get_arg(optional_args, 0, crate::Value::Null)); if !matches!(__v, crate::Value::Null) { return __v; } }
let mut market = get_arg(optional_args, 0, Value::Null);
panic!("{}", crate::exchange_errors::not_supported(add(&self.id, &Value::Str(" parseTrade() is not supported yet".to_string()))));
Value::Null
}
fn parse_transaction(&self, mut transaction: Value, optional_args: &[Value]) -> Value {
// virtual-dispatch (static: DerivedExchange::parse_transaction(self, ...))
{ let __v = crate::exchange::DerivedExchange::parse_transaction(self, transaction.clone(), crate::runtime::get_arg(optional_args, 0, crate::Value::Null)); if !matches!(__v, crate::Value::Null) { return __v; } }
let mut currency = get_arg(optional_args, 0, Value::Null);
panic!("{}", crate::exchange_errors::not_supported(add(&self.id, &Value::Str(" parseTransaction() is not supported yet".to_string()))));
Value::Null
}
fn parse_transfer(&self, mut transfer: Value, optional_args: &[Value]) -> Value {
// virtual-dispatch (static: DerivedExchange::parse_transfer(self, ...))
{ let __v = crate::exchange::DerivedExchange::parse_transfer(self, transfer.clone(), crate::runtime::get_arg(optional_args, 0, crate::Value::Null)); if !matches!(__v, crate::Value::Null) { return __v; } }
let mut currency = get_arg(optional_args, 0, Value::Null);
if is_equal(&transfer, &Value::Null) {
panic!("{}", crate::exchange_errors::not_supported(add(&self.id, &Value::Str(" parseTransfer() is not supported yet".to_string()))));
}
panic!("{}", crate::exchange_errors::not_supported(add(&self.id, &Value::Str(" parseTransfer() is not supported yet".to_string()))));
Value::Null
}
fn parse_account(&self, mut account: Value) -> Value {
// virtual-dispatch (static: DerivedExchange::parse_account(self, ...))
{ let __v = crate::exchange::DerivedExchange::parse_account(self, account.clone()); if !matches!(__v, crate::Value::Null) { return __v; } }
panic!("{}", crate::exchange_errors::not_supported(add(&self.id, &Value::Str(" parseAccount() is not supported yet".to_string()))));
Value::Null
}
fn parse_ledger_entry(&self, mut item: Value, optional_args: &[Value]) -> Value {
// virtual-dispatch (static: DerivedExchange::parse_ledger_entry(self, ...))
{ let __v = crate::exchange::DerivedExchange::parse_ledger_entry(self, item.clone(), crate::runtime::get_arg(optional_args, 0, crate::Value::Null)); if !matches!(__v, crate::Value::Null) { return __v; } }
let mut currency = get_arg(optional_args, 0, Value::Null);
panic!("{}", crate::exchange_errors::not_supported(add(&self.id, &Value::Str(" parseLedgerEntry() is not supported yet".to_string()))));
Value::Null
}
fn parse_order(&self, mut order: Value, optional_args: &[Value]) -> Value {
// virtual-dispatch (static: DerivedExchange::parse_order(self, ...))
{ let __v = crate::exchange::DerivedExchange::parse_order(self, order.clone(), crate::runtime::get_arg(optional_args, 0, crate::Value::Null)); if !matches!(__v, crate::Value::Null) { return __v; } }
let mut market = get_arg(optional_args, 0, Value::Null);
panic!("{}", crate::exchange_errors::not_supported(add(&self.id, &Value::Str(" parseOrder() is not supported yet".to_string()))));
Value::Null
}
fn fetch_cross_borrow_rates(&mut self, optional_args: &[Value]) -> impl ::std::future::Future<Output = Value> + Send { async move {
let mut params = get_arg(optional_args, 0, Value::Map({
let mut m = indexmap::IndexMap::new();
m
}));
panic!("{}", crate::exchange_errors::not_supported(add(&self.id, &Value::Str(" fetchCrossBorrowRates() is not supported yet".to_string()))));
Value::Null
} }
fn fetch_isolated_borrow_rates(&mut self, optional_args: &[Value]) -> impl ::std::future::Future<Output = Value> + Send { async move {
let mut params = get_arg(optional_args, 0, Value::Map({
let mut m = indexmap::IndexMap::new();
m
}));
panic!("{}", crate::exchange_errors::not_supported(add(&self.id, &Value::Str(" fetchIsolatedBorrowRates() is not supported yet".to_string()))));
Value::Null
} }
fn parse_market_leverage_tiers(&self, mut info: Value, optional_args: &[Value]) -> Value {
// virtual-dispatch (static: DerivedExchange::parse_market_leverage_tiers(self, ...))
{ let __v = crate::exchange::DerivedExchange::parse_market_leverage_tiers(self, info.clone(), crate::runtime::get_arg(optional_args, 0, crate::Value::Null)); if !matches!(__v, crate::Value::Null) { return __v; } }
let mut market = get_arg(optional_args, 0, Value::Null);
panic!("{}", crate::exchange_errors::not_supported(add(&self.id, &Value::Str(" parseMarketLeverageTiers() is not supported yet".to_string()))));
Value::Null
}
fn fetch_leverage_tiers(&mut self, optional_args: &[Value]) -> impl ::std::future::Future<Output = Value> + Send { async move {
// async-virtual: try the derived exchange first
if let Some(__v) = self.dispatch_to_derived("fetch_leverage_tiers", { let mut __args: Vec<crate::Value> = Vec::new(); __args.extend_from_slice(optional_args); __args }).await {
if !matches!(__v, crate::Value::Null) { return __v; }
}
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
}));
panic!("{}", crate::exchange_errors::not_supported(add(&self.id, &Value::Str(" fetchLeverageTiers() is not supported yet".to_string()))));
Value::Null
} }
fn parse_position(&self, mut position: Value, optional_args: &[Value]) -> Value {
// virtual-dispatch (static: DerivedExchange::parse_position(self, ...))
{ let __v = crate::exchange::DerivedExchange::parse_position(self, position.clone(), crate::runtime::get_arg(optional_args, 0, crate::Value::Null)); if !matches!(__v, crate::Value::Null) { return __v; } }
let mut market = get_arg(optional_args, 0, Value::Null);
panic!("{}", crate::exchange_errors::not_supported(add(&self.id, &Value::Str(" parsePosition() is not supported yet".to_string()))));
Value::Null
}
fn parse_funding_rate_history(&self, mut info: Value, optional_args: &[Value]) -> Value {
// virtual-dispatch (static: DerivedExchange::parse_funding_rate_history(self, ...))
{ let __v = crate::exchange::DerivedExchange::parse_funding_rate_history(self, info.clone(), crate::runtime::get_arg(optional_args, 0, crate::Value::Null)); if !matches!(__v, crate::Value::Null) { return __v; } }
let mut market = get_arg(optional_args, 0, Value::Null);
panic!("{}", crate::exchange_errors::not_supported(add(&self.id, &Value::Str(" parseFundingRateHistory() is not supported yet".to_string()))));
Value::Null
}
fn parse_borrow_interest(&self, mut info: Value, optional_args: &[Value]) -> Value {
// virtual-dispatch (static: DerivedExchange::parse_borrow_interest(self, ...))
{ let __v = crate::exchange::DerivedExchange::parse_borrow_interest(self, info.clone(), crate::runtime::get_arg(optional_args, 0, crate::Value::Null)); if !matches!(__v, crate::Value::Null) { return __v; } }
let mut market = get_arg(optional_args, 0, Value::Null);
panic!("{}", crate::exchange_errors::not_supported(add(&self.id, &Value::Str(" parseBorrowInterest() is not supported yet".to_string()))));
Value::Null
}
fn parse_isolated_borrow_rate(&self, mut info: Value, optional_args: &[Value]) -> Value {
let mut market = get_arg(optional_args, 0, Value::Null);
panic!("{}", crate::exchange_errors::not_supported(add(&self.id, &Value::Str(" parseIsolatedBorrowRate() is not supported yet".to_string()))));
Value::Null
}
fn parse_ws_trade(&self, mut trade: Value, optional_args: &[Value]) -> Value {
let mut market = get_arg(optional_args, 0, Value::Null);
panic!("{}", crate::exchange_errors::not_supported(add(&self.id, &Value::Str(" parseWsTrade() is not supported yet".to_string()))));
Value::Null
}
fn parse_ws_order(&self, mut order: Value, optional_args: &[Value]) -> Value {
let mut market = get_arg(optional_args, 0, Value::Null);
panic!("{}", crate::exchange_errors::not_supported(add(&self.id, &Value::Str(" parseWsOrder() is not supported yet".to_string()))));
Value::Null
}
fn parse_ws_order_trade(&self, mut trade: Value, optional_args: &[Value]) -> Value {
let mut market = get_arg(optional_args, 0, Value::Null);
panic!("{}", crate::exchange_errors::not_supported(add(&self.id, &Value::Str(" parseWsOrderTrade() is not supported yet".to_string()))));
Value::Null
}
fn parse_ws_ohlcv(&self, mut ohlcv: Value, optional_args: &[Value]) -> Value {
let mut market = get_arg(optional_args, 0, Value::Null);
return <Self as crate::exchange_generated::ExchangeBase>::parse_ohlcv(self, ohlcv.clone(), &[market.clone()]);
Value::Null
}
fn fetch_funding_rates(&mut self, optional_args: &[Value]) -> impl ::std::future::Future<Output = Value> + Send { async move {
// async-virtual: try the derived exchange first
if let Some(__v) = self.dispatch_to_derived("fetch_funding_rates", { let mut __args: Vec<crate::Value> = Vec::new(); __args.extend_from_slice(optional_args); __args }).await {
if !matches!(__v, crate::Value::Null) { return __v; }
}
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
}));
panic!("{}", crate::exchange_errors::not_supported(add(&self.id, &Value::Str(" fetchFundingRates() is not supported yet".to_string()))));
Value::Null
} }
fn fetch_funding_intervals(&mut self, optional_args: &[Value]) -> impl ::std::future::Future<Output = Value> + Send { async move {
// async-virtual: try the derived exchange first
if let Some(__v) = self.dispatch_to_derived("fetch_funding_intervals", { let mut __args: Vec<crate::Value> = Vec::new(); __args.extend_from_slice(optional_args); __args }).await {
if !matches!(__v, crate::Value::Null) { return __v; }
}
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
}));
panic!("{}", crate::exchange_errors::not_supported(add(&self.id, &Value::Str(" fetchFundingIntervals() is not supported yet".to_string()))));
Value::Null
} }
fn watch_funding_rate(&mut self, mut symbol: Value, optional_args: &[Value]) -> impl ::std::future::Future<Output = Value> + Send { async move {
let mut params = get_arg(optional_args, 0, Value::Map({
let mut m = indexmap::IndexMap::new();
m
}));
panic!("{}", crate::exchange_errors::not_supported(add(&self.id, &Value::Str(" watchFundingRate() is not supported yet".to_string()))));
Value::Null
} }
fn watch_funding_rates(&mut self, optional_args: &[Value]) -> impl ::std::future::Future<Output = Value> + Send { async move {
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
}));
panic!("{}", crate::exchange_errors::not_supported(add(&self.id, &Value::Str(" watchFundingRates() is not supported yet".to_string()))));
Value::Null
} }
fn un_watch_funding_rates(&mut self, optional_args: &[Value]) -> impl ::std::future::Future<Output = Value> + Send { async move {
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
}));
panic!("{}", crate::exchange_errors::not_supported(add(&self.id, &Value::Str(" unWatchFundingRates() is not supported yet".to_string()))));
Value::Null
} }
fn watch_funding_rates_for_symbols(&mut self, mut symbols: Value, optional_args: &[Value]) -> impl ::std::future::Future<Output = Value> + Send { async move {
let mut params = get_arg(optional_args, 0, Value::Map({
let mut m = indexmap::IndexMap::new();
m
}));
return self.watch_funding_rates(&[symbols.clone(), params.clone()]).await;
Value::Null
} }
fn transfer(&mut self, mut code: Value, mut amount: Value, mut fromAccount: Value, mut toAccount: Value, optional_args: &[Value]) -> impl ::std::future::Future<Output = Value> + Send { async move {
// async-virtual: try the derived exchange first
if let Some(__v) = self.dispatch_to_derived("transfer", { let mut __args: Vec<crate::Value> = Vec::new(); __args.push(code.clone()); __args.push(amount.clone()); __args.push(fromAccount.clone()); __args.push(toAccount.clone()); __args.extend_from_slice(optional_args); __args }).await {
if !matches!(__v, crate::Value::Null) { return __v; }
}
let mut params = get_arg(optional_args, 0, Value::Map({
let mut m = indexmap::IndexMap::new();
m
}));
panic!("{}", crate::exchange_errors::not_supported(add(&self.id, &Value::Str(" transfer() is not supported yet".to_string()))));
Value::Null
} }
fn withdraw(&mut self, mut code: Value, mut amount: Value, mut address: Value, optional_args: &[Value]) -> impl ::std::future::Future<Output = Value> + Send { async move {
// async-virtual: try the derived exchange first
if let Some(__v) = self.dispatch_to_derived("withdraw", { let mut __args: Vec<crate::Value> = Vec::new(); __args.push(code.clone()); __args.push(amount.clone()); __args.push(address.clone()); __args.extend_from_slice(optional_args); __args }).await {
if !matches!(__v, crate::Value::Null) { return __v; }
}
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
}));
panic!("{}", crate::exchange_errors::not_supported(add(&self.id, &Value::Str(" withdraw() is not supported yet".to_string()))));
Value::Null
} }
fn create_deposit_address(&mut self, mut code: Value, optional_args: &[Value]) -> impl ::std::future::Future<Output = Value> + Send { async move {
let mut params = get_arg(optional_args, 0, Value::Map({
let mut m = indexmap::IndexMap::new();
m
}));
panic!("{}", crate::exchange_errors::not_supported(add(&self.id, &Value::Str(" createDepositAddress() is not supported yet".to_string()))));
Value::Null
} }
fn set_leverage(&mut self, mut leverage: Value, optional_args: &[Value]) -> impl ::std::future::Future<Output = Value> + Send { async move {
// async-virtual: try the derived exchange first
if let Some(__v) = self.dispatch_to_derived("set_leverage", { let mut __args: Vec<crate::Value> = Vec::new(); __args.push(leverage.clone()); __args.extend_from_slice(optional_args); __args }).await {
if !matches!(__v, crate::Value::Null) { return __v; }
}
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
}));
panic!("{}", crate::exchange_errors::not_supported(add(&self.id, &Value::Str(" setLeverage() is not supported yet".to_string()))));
Value::Null
} }
fn fetch_leverage(&mut self, mut symbol: Value, optional_args: &[Value]) -> impl ::std::future::Future<Output = Value> + Send { async move {
// async-virtual: try the derived exchange first
if let Some(__v) = self.dispatch_to_derived("fetch_leverage", { let mut __args: Vec<crate::Value> = Vec::new(); __args.push(symbol.clone()); __args.extend_from_slice(optional_args); __args }).await {
if !matches!(__v, crate::Value::Null) { return __v; }
}
let mut params = get_arg(optional_args, 0, Value::Map({
let mut m = indexmap::IndexMap::new();
m
}));
if !is_equal(&get_value(&self.has, &Value::Str("fetchLeverages".to_string())), &Value::Null) && !is_equal(&get_value(&self.has, &Value::Str("fetchLeverages".to_string())), &Value::Bool(false)) {
let mut leverages: Value = self.fetch_leverages(&[Value::List(vec![symbol.clone()]), params.clone()]).await;
return self.safe_dict(leverages.clone(), symbol.clone(), &[]);
} else {
panic!("{}", crate::exchange_errors::not_supported(add(&self.id, &Value::Str(" fetchLeverage() is not supported yet".to_string()))));
}
Value::Null
} }
fn fetch_leverages(&mut self, optional_args: &[Value]) -> impl ::std::future::Future<Output = Value> + Send { async move {
// async-virtual: try the derived exchange first
if let Some(__v) = self.dispatch_to_derived("fetch_leverages", { let mut __args: Vec<crate::Value> = Vec::new(); __args.extend_from_slice(optional_args); __args }).await {
if !matches!(__v, crate::Value::Null) { return __v; }
}
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
}));
panic!("{}", crate::exchange_errors::not_supported(add(&self.id, &Value::Str(" fetchLeverages() is not supported yet".to_string()))));
Value::Null
} }
fn set_position_mode(&mut self, mut hedged: Value, optional_args: &[Value]) -> impl ::std::future::Future<Output = Value> + Send { async move {
// async-virtual: try the derived exchange first
if let Some(__v) = self.dispatch_to_derived("set_position_mode", { let mut __args: Vec<crate::Value> = Vec::new(); __args.push(hedged.clone()); __args.extend_from_slice(optional_args); __args }).await {
if !matches!(__v, crate::Value::Null) { return __v; }
}
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
}));
panic!("{}", crate::exchange_errors::not_supported(add(&self.id, &Value::Str(" setPositionMode() is not supported yet".to_string()))));
Value::Null
} }
fn add_margin(&mut self, mut symbol: Value, mut amount: Value, optional_args: &[Value]) -> impl ::std::future::Future<Output = Value> + Send { async move {
// async-virtual: try the derived exchange first
if let Some(__v) = self.dispatch_to_derived("add_margin", { let mut __args: Vec<crate::Value> = Vec::new(); __args.push(symbol.clone()); __args.push(amount.clone()); __args.extend_from_slice(optional_args); __args }).await {
if !matches!(__v, crate::Value::Null) { return __v; }
}
let mut params = get_arg(optional_args, 0, Value::Map({
let mut m = indexmap::IndexMap::new();
m
}));
panic!("{}", crate::exchange_errors::not_supported(add(&self.id, &Value::Str(" addMargin() is not supported yet".to_string()))));
Value::Null
} }
fn reduce_margin(&mut self, mut symbol: Value, mut amount: Value, optional_args: &[Value]) -> impl ::std::future::Future<Output = Value> + Send { async move {
// async-virtual: try the derived exchange first
if let Some(__v) = self.dispatch_to_derived("reduce_margin", { let mut __args: Vec<crate::Value> = Vec::new(); __args.push(symbol.clone()); __args.push(amount.clone()); __args.extend_from_slice(optional_args); __args }).await {
if !matches!(__v, crate::Value::Null) { return __v; }
}
let mut params = get_arg(optional_args, 0, Value::Map({
let mut m = indexmap::IndexMap::new();
m
}));
panic!("{}", crate::exchange_errors::not_supported(add(&self.id, &Value::Str(" reduceMargin() is not supported yet".to_string()))));
Value::Null
} }
fn set_margin(&mut self, mut symbol: Value, mut amount: Value, optional_args: &[Value]) -> impl ::std::future::Future<Output = Value> + Send { async move {
let mut params = get_arg(optional_args, 0, Value::Map({
let mut m = indexmap::IndexMap::new();
m
}));
panic!("{}", crate::exchange_errors::not_supported(add(&self.id, &Value::Str(" setMargin() is not supported yet".to_string()))));
Value::Null
} }
fn fetch_long_short_ratio(&mut self, mut symbol: Value, optional_args: &[Value]) -> impl ::std::future::Future<Output = Value> + Send { async move {
let mut timeframe = get_arg(optional_args, 0, Value::Null);
let mut params = get_arg(optional_args, 1, Value::Map({
let mut m = indexmap::IndexMap::new();
m
}));
panic!("{}", crate::exchange_errors::not_supported(add(&self.id, &Value::Str(" fetchLongShortRatio() is not supported yet".to_string()))));
Value::Null
} }
fn fetch_long_short_ratio_history(&mut self, optional_args: &[Value]) -> impl ::std::future::Future<Output = Value> + Send { async move {
let mut symbol = get_arg(optional_args, 0, Value::Null);
let mut timeframe = get_arg(optional_args, 1, Value::Null);
let mut since = get_arg(optional_args, 2, Value::Null);
let mut limit = get_arg(optional_args, 3, Value::Null);
let mut params = get_arg(optional_args, 4, Value::Map({
let mut m = indexmap::IndexMap::new();
m
}));
panic!("{}", crate::exchange_errors::not_supported(add(&self.id, &Value::Str(" fetchLongShortRatioHistory() is not supported yet".to_string()))));
Value::Null
} }
fn fetch_margin_adjustment_history(&mut self, optional_args: &[Value]) -> impl ::std::future::Future<Output = Value> + Send { async move {
let mut symbol = get_arg(optional_args, 0, Value::Null);
let mut type_var = get_arg(optional_args, 1, Value::Null);
let mut since = get_arg(optional_args, 2, Value::Null);
let mut limit = get_arg(optional_args, 3, Value::Null);
let mut params = get_arg(optional_args, 4, Value::Map({
let mut m = indexmap::IndexMap::new();
m
}));
panic!("{}", crate::exchange_errors::not_supported(add(&self.id, &Value::Str(" fetchMarginAdjustmentHistory() is not supported yet".to_string()))));
Value::Null
} }
fn set_margin_mode(&mut self, mut marginMode: Value, optional_args: &[Value]) -> impl ::std::future::Future<Output = Value> + Send { async move {
// async-virtual: try the derived exchange first
if let Some(__v) = self.dispatch_to_derived("set_margin_mode", { let mut __args: Vec<crate::Value> = Vec::new(); __args.push(marginMode.clone()); __args.extend_from_slice(optional_args); __args }).await {
if !matches!(__v, crate::Value::Null) { return __v; }
}
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
}));
panic!("{}", crate::exchange_errors::not_supported(add(&self.id, &Value::Str(" setMarginMode() is not supported yet".to_string()))));
Value::Null
} }
fn fetch_deposit_addresses_by_network(&mut self, mut code: Value, optional_args: &[Value]) -> impl ::std::future::Future<Output = Value> + Send { async move {
// async-virtual: try the derived exchange first
if let Some(__v) = self.dispatch_to_derived("fetch_deposit_addresses_by_network", { let mut __args: Vec<crate::Value> = Vec::new(); __args.push(code.clone()); __args.extend_from_slice(optional_args); __args }).await {
if !matches!(__v, crate::Value::Null) { return __v; }
}
let mut params = get_arg(optional_args, 0, Value::Map({
let mut m = indexmap::IndexMap::new();
m
}));
panic!("{}", crate::exchange_errors::not_supported(add(&self.id, &Value::Str(" fetchDepositAddressesByNetwork() is not supported yet".to_string()))));
Value::Null
} }
fn fetch_open_interest_history(&mut self, mut symbol: Value, optional_args: &[Value]) -> impl ::std::future::Future<Output = Value> + Send { async move {
let mut timeframe = get_arg(optional_args, 0, Value::Str("1h".to_string()));
let mut since = get_arg(optional_args, 1, Value::Null);
let mut limit = get_arg(optional_args, 2, Value::Null);
let mut params = get_arg(optional_args, 3, Value::Map({
let mut m = indexmap::IndexMap::new();
m
}));
panic!("{}", crate::exchange_errors::not_supported(add(&self.id, &Value::Str(" fetchOpenInterestHistory() is not supported yet".to_string()))));
Value::Null
} }
fn fetch_open_interests(&mut self, optional_args: &[Value]) -> impl ::std::future::Future<Output = Value> + Send { async move {
// async-virtual: try the derived exchange first
if let Some(__v) = self.dispatch_to_derived("fetch_open_interests", { let mut __args: Vec<crate::Value> = Vec::new(); __args.extend_from_slice(optional_args); __args }).await {
if !matches!(__v, crate::Value::Null) { return __v; }
}
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
}));
panic!("{}", crate::exchange_errors::not_supported(add(&self.id, &Value::Str(" fetchOpenInterests() is not supported yet".to_string()))));
Value::Null
} }
fn sign_in(&mut self, optional_args: &[Value]) -> impl ::std::future::Future<Output = Value> + Send { async move {
// async-virtual: try the derived exchange first
if let Some(__v) = self.dispatch_to_derived("sign_in", { let mut __args: Vec<crate::Value> = Vec::new(); __args.extend_from_slice(optional_args); __args }).await {
if !matches!(__v, crate::Value::Null) { return __v; }
}
let mut params = get_arg(optional_args, 0, Value::Map({
let mut m = indexmap::IndexMap::new();
m
}));
panic!("{}", crate::exchange_errors::not_supported(add(&self.id, &Value::Str(" signIn() is not supported yet".to_string()))));
Value::Null
} }
fn fetch_payment_methods(&mut self, optional_args: &[Value]) -> impl ::std::future::Future<Output = Value> + Send { async move {
let mut params = get_arg(optional_args, 0, Value::Map({
let mut m = indexmap::IndexMap::new();
m
}));
panic!("{}", crate::exchange_errors::not_supported(add(&self.id, &Value::Str(" fetchPaymentMethods() is not supported yet".to_string()))));
Value::Null
} }
fn parse_to_int(&self, mut number: Value) -> Value {
// Solve Common parseInt misuse ex: parseInt ((since / 1000).toString ())
// using a number as parameter which is not valid in ts
// numberToString is typed as nullable under strictNullChecks; cast to string
// the cast is erased at transpile-time, so output matches every target language, rather than
// branching to a bare `NaN` literal, which has no symbol in Go/Java/C#
let mut stringifiedNumber: Value = self.number_to_string(number.clone());
let mut convertedNumber: Value = crate::runtime::parse_float(&stringifiedNumber);
return crate::runtime::parse_int(&convertedNumber);
Value::Null
}
fn parse_to_numeric(&self, mut number: Value) -> Value {
let mut stringVersion: Value = self.number_to_string(number.clone()); // this will convert 1.0 and 1 to "1" and 1.1 to "1.1"
// keep this in mind:
// in JS: 1 === 1.0 is true
// in Python: 1 == 1.0 is true
// in PHP: 1 == 1.0 is true, but 1 === 1.0 is false.
if is_greater_than_or_equal(&get_index_of(&stringVersion, &Value::Str(".".to_string())), &Value::Int(0)) {
return crate::runtime::parse_float(&stringVersion);
}
return crate::runtime::parse_int(&stringVersion);
Value::Null
}
fn is_round_number(&self, mut value: Value) -> Value {
// this method is similar to isInteger, but this is more loyal and does not check for types.
// i.e. isRoundNumber(1.000) returns true, while isInteger(1.000) returns false
let mut res: Value = self.parse_to_numeric((mod_val(&value, &Value::Int(1))));
return Value::Bool(is_equal(&res, &Value::Int(0)));
Value::Null
}
fn is_empty_string(&self, mut value: Value) -> Value {
return Value::Bool(!is_true(&self.value_is_defined(value.clone())) || is_equal(&value, &Value::Str("".to_string())));
Value::Null
}
fn safe_number_omit_zero(&self, mut obj: Value, mut key: Value, optional_args: &[Value]) -> Value {
let mut defaultValue = get_arg(optional_args, 0, Value::Null);
let mut value: Value = self.safe_string(obj.clone(), key.clone(), &[]);
let mut final_val: Value = self.parse_number(self.omit_zero(value.clone()), &[]);
return ternary(is_true(&(is_equal(&final_val, &Value::Null))), defaultValue.clone(), final_val.clone());
Value::Null
}
fn safe_integer_omit_zero(&self, mut obj: Value, mut key: Value, optional_args: &[Value]) -> Value {
let mut defaultValue = get_arg(optional_args, 0, Value::Null);
let mut timestamp: Value = self.safe_integer(obj.clone(), key.clone(), &[defaultValue.clone()]);
if is_equal(×tamp, &Value::Null) || is_equal(×tamp, &Value::Int(0)) {
return Value::Null;
}
return timestamp;
Value::Null
}
fn after_construct(&mut self) {
// networks
self.create_networks_by_id_object();
self.features_generator();
// init predefined markets if any
if !is_equal(&self.markets, &Value::Null) {
self.set_markets(self.markets.clone(), &[]);
}
// init the request rate limiter
self.init_rest_rate_limiter();
// sanbox mode
let mut isSandbox: Value = self.safe_bool2(self.options.clone(), Value::Str("sandbox".to_string()), Value::Str("testnet".to_string()), &[Value::Bool(false)]);
if is_equal(&isSandbox, &Value::Bool(true)) {
self.set_sandbox_mode(isSandbox.clone());
}
}
fn init_rest_rate_limiter(&mut self) {
if is_equal(&self.rateLimit, &Value::Null) || is_true(&(!is_equal(&self.id, &Value::Null) && is_equal(&self.rateLimit, &negate(&Value::Int(1))))) {
panic!("{}", crate::exchange_errors::exchange_error(add(&self.id, &Value::Str(".rateLimit property is not configured".to_string()))));
}
let mut refillRate: Value = self.MAX_VALUE.clone();
if is_greater_than(&self.rateLimit, &Value::Int(0)) {
refillRate = divide(&Value::Int(1), &self.rateLimit);
}
let mut useLeaky: bool = is_true(&(is_equal(&self.rollingWindowSize, &Value::Int(0)))) || is_true(&(is_equal(&self.rateLimiterAlgorithm, &Value::Str("leakyBucket".to_string()))));
let mut algorithm: Value = ternary(is_true(&useLeaky), Value::Str("leakyBucket".to_string()), Value::Str("rollingWindow".to_string()));
let mut defaultBucket: Value = Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("delay".to_string(), Value::Float(0.001));
m.insert("capacity".to_string(), Value::Int(1));
m.insert("cost".to_string(), Value::Int(1));
m.insert("refillRate".to_string(), refillRate.clone());
m.insert("algorithm".to_string(), algorithm.clone());
m.insert("windowSize".to_string(), self.rollingWindowSize.clone());
m.insert("rateLimit".to_string(), self.rateLimit.clone());
m
});
let mut existingBucket: Value = ternary(is_true(&(is_equal(&self.tokenBucket, &Value::Null))), Value::Map({
let mut m = indexmap::IndexMap::new();
m
}), self.tokenBucket.clone());
{ let __t = self.extend(defaultBucket.clone(), &[existingBucket.clone()]); self.tokenBucket = __t; }
self.init_throttler();
}
fn features_generator(&mut self) {
//
// in the exchange-specific features can be something like this, where we support 'string' aliases too:
//
// {
// 'my' : {
// 'createOrder' : {...},
// },
// 'swap': {
// 'linear': {
// 'extends': my',
// },
// },
// }
//
if is_equal(&self.features, &Value::Null) {
return;
}
// reconstruct
let mut initialFeatures: Value = self.features.clone();
self.features = Value::Map({
let mut m = indexmap::IndexMap::new();
m
});
let mut unifiedMarketTypes: Value = Value::List(vec![Value::Str("spot".to_string()), Value::Str("swap".to_string()), Value::Str("future".to_string()), Value::Str("option".to_string())]);
let mut subTypes: Value = Value::List(vec![Value::Str("linear".to_string()), Value::Str("inverse".to_string())]);
{
let mut i: Value = Value::Int(0);
let mut __for_first_81: bool = true;
while { if !__for_first_81 { i = add(&i, &Value::Int(1)); } __for_first_81 = false; is_less_than(&i, &get_array_length(&unifiedMarketTypes)) } {
let mut marketType: Value = get_value(&unifiedMarketTypes, &i);
let mut marketType: Value = get_value(&unifiedMarketTypes, &i);
// if marketType is not filled for this exchange, don't add that in `features`
if !is_true(&(Value::Bool(in_op(&initialFeatures, &marketType)))) {
add_element_to_object(&mut self.features, &marketType, Value::Null);
} else {
if is_equal(&marketType, &Value::Str("spot".to_string())) {
{ let __be_tmp = self.features_mapper(initialFeatures.clone(), marketType.clone(), &[]); add_element_to_object(&mut self.features, &marketType, __be_tmp); };
} else {
add_element_to_object(&mut self.features, &marketType, Value::Map({
let mut m = indexmap::IndexMap::new();
m
}));
{
let mut j: Value = Value::Int(0);
let mut __for_first_80: bool = true;
while { if !__for_first_80 { j = add(&j, &Value::Int(1)); } __for_first_80 = false; is_less_than(&j, &get_array_length(&subTypes)) } {
let mut subType: Value = get_value(&subTypes, &j);
let mut subType: Value = get_value(&subTypes, &j);
{ let __be_tmp = self.features_mapper(initialFeatures.clone(), marketType.clone(), &[subType.clone()]); add_element_to_object(get_value_mut(&mut self.features, &marketType), &subType, __be_tmp); };
}
}
}
}
}
}
}
fn features_mapper(&mut self, mut initialFeatures: Value, mut marketType: Value, optional_args: &[Value]) -> Value {
let mut subType = get_arg(optional_args, 0, Value::Null);
let mut featuresObj: Value = ternary(is_true(&(!is_equal(&subType, &Value::Null))), get_value(&get_value(&initialFeatures, &marketType), &subType), get_value(&initialFeatures, &marketType));
// if exchange does not have that market-type (eg. future>inverse)
if is_equal(&featuresObj, &Value::Null) {
return Value::Null;
}
let mut extendsStr: Value = self.safe_string_k(featuresObj.clone(), "extends", &[]);
if !is_equal(&extendsStr, &Value::Null) {
featuresObj = self.omit(featuresObj.clone(), Value::Str("extends".to_string()), &[]);
let mut extendObj: Value = self.features_mapper(initialFeatures.clone(), extendsStr.clone(), &[]);
featuresObj = self.deep_extend(extendObj.clone(), &[featuresObj.clone()]);
}
//
// ### corrections ###
//
// createOrder
if is_true(&Value::Bool(in_op(&featuresObj, &Value::Str("createOrder".to_string())))) {
let mut value: Value = self.safe_dict(get_value(&featuresObj, &Value::Str("createOrder".to_string())), Value::Str("attachedStopLossTakeProfit".to_string()), &[]);
add_element_to_object(get_value_mut(&mut featuresObj, &Value::Str("createOrder".to_string())), &Value::Str("stopLoss".to_string()), value.clone());
add_element_to_object(get_value_mut(&mut featuresObj, &Value::Str("createOrder".to_string())), &Value::Str("takeProfit".to_string()), value.clone());
if is_equal(&marketType, &Value::Str("spot".to_string())) {
// default 'hedged': false
add_element_to_object(get_value_mut(&mut featuresObj, &Value::Str("createOrder".to_string())), &Value::Str("hedged".to_string()), Value::Bool(false));
// default 'leverage': false
if !is_true(&(Value::Bool(in_op(&get_value(&featuresObj, &Value::Str("createOrder".to_string())), &Value::Str("leverage".to_string()))))) {
add_element_to_object(get_value_mut(&mut featuresObj, &Value::Str("createOrder".to_string())), &Value::Str("leverage".to_string()), Value::Bool(false));
}
}
// default 'GTC' to true
if is_equal(&self.safe_bool(get_value(&get_value(&featuresObj, &Value::Str("createOrder".to_string())), &Value::Str("timeInForce".to_string())), Value::Str("GTC".to_string()), &[]), &Value::Null) {
add_element_to_object(get_value_mut(get_value_mut(&mut featuresObj, &Value::Str("createOrder".to_string())), &Value::Str("timeInForce".to_string())), &Value::Str("GTC".to_string()), Value::Bool(true));
}
}
// other methods
let mut keys: Value = object_keys(&featuresObj);
{
let mut i: Value = Value::Int(0);
let mut __for_first_82: bool = true;
while { if !__for_first_82 { i = add(&i, &Value::Int(1)); } __for_first_82 = false; is_less_than(&i, &get_array_length(&keys)) } {
let mut key: Value = get_value(&keys, &i);
let mut key: Value = get_value(&keys, &i);
let mut featureBlock: Value = get_value(&featuresObj, &key);
let mut featureBlock: Value = get_value(&featuresObj, &key);
if !is_true(&self.in_array(key.clone(), Value::List(vec![Value::Str("sandbox".to_string())]))) && !is_equal(&featureBlock, &Value::Null) {
// default "symbolRequired" to false to all methods (except `createOrder`)
if !is_true(&(Value::Bool(in_op(&featureBlock, &Value::Str("symbolRequired".to_string()))))) {
add_element_to_object(&mut featureBlock, &Value::Str("symbolRequired".to_string()), self.in_array(key.clone(), Value::List(vec![Value::Str("createOrder".to_string()), Value::Str("createOrders".to_string()), Value::Str("fetchOHLCV".to_string())])));
}
}
}
}
return featuresObj;
Value::Null
}
fn feature_value(&self, mut symbol: Value, optional_args: &[Value]) -> Value {
let mut methodName = get_arg(optional_args, 0, Value::Null);
let mut paramName = get_arg(optional_args, 1, Value::Null);
let mut defaultValue = get_arg(optional_args, 2, Value::Null);
/*
* @method
* @name exchange#featureValue
* @description this method is a very deterministic to help users to know what feature is supported by the exchange
* @param {string} [symbol] unified symbol
* @param {string} [methodName] view currently supported methods: https://docs.ccxt.com/README?id=features
* @param {string} [paramName] unified param value, like: `triggerPrice`, `stopLoss.triggerPrice` (check docs for supported param names)
* @param {object} [defaultValue] return default value if no result found
* @returns {object} returns feature value
*/
let mut market: Value = self.market(symbol.clone());
return self.feature_value_by_type(get_value(&market, &Value::Str("type".to_string())), get_value(&market, &Value::Str("subType".to_string())), &[methodName.clone(), paramName.clone(), defaultValue.clone()]);
Value::Null
}
fn feature_value_by_type(&self, mut marketType: Value, mut subType: Value, optional_args: &[Value]) -> Value {
let mut methodName = get_arg(optional_args, 0, Value::Null);
let mut paramName = get_arg(optional_args, 1, Value::Null);
let mut defaultValue = get_arg(optional_args, 2, Value::Null);
/*
* @method
* @name exchange#featureValueByType
* @description this method is a very deterministic to help users to know what feature is supported by the exchange
* @param {string} [marketType] supported only: "spot", "swap", "future"
* @param {string} [subType] supported only: "linear", "inverse"
* @param {string} [methodName] view currently supported methods: https://docs.ccxt.com/README?id=features
* @param {string} [paramName] unified param value (check docs for supported param names)
* @param {object} [defaultValue] return default value if no result found
* @returns {object} returns feature value
*/
// if exchange does not yet have features manually implemented
if is_equal(&self.features, &Value::Null) {
return defaultValue;
}
if is_equal(&marketType, &Value::Null) {
return defaultValue;
}
// if marketType (e.g. 'option') does not exist in features
if !is_true(&(Value::Bool(in_op(&self.features, &marketType)))) {
return defaultValue;
}
// if marketType dict undefined
if is_equal(&get_value(&self.features, &marketType), &Value::Null) {
return defaultValue;
}
let mut methodsContainer: Value = get_value(&self.features, &marketType);
if is_equal(&subType, &Value::Null) {
if !is_equal(&marketType, &Value::Str("spot".to_string())) {
return defaultValue;
}
} else {
if !is_true(&(Value::Bool(in_op(&get_value(&self.features, &marketType), &subType)))) {
return defaultValue;
}
// if subType dict undefined
if is_equal(&get_value(&get_value(&self.features, &marketType), &subType), &Value::Null) {
return defaultValue;
}
methodsContainer = get_value(&get_value(&self.features, &marketType), &subType);
}
// if user wanted only marketType and didn't provide methodName, eg: featureIsSupported('spot')
if is_equal(&methodName, &Value::Null) {
return ternary(is_true(&(!is_equal(&defaultValue, &Value::Null))), defaultValue.clone(), methodsContainer.clone());
}
if !is_true(&(Value::Bool(in_op(&methodsContainer, &methodName)))) {
return defaultValue;
}
let mut methodDict: Value = get_value(&methodsContainer, &methodName);
let mut methodDict: Value = get_value(&methodsContainer, &methodName);
if is_equal(&methodDict, &Value::Null) {
return defaultValue;
}
// if user wanted only method and didn't provide `paramName`, eg: featureIsSupported('swap', 'linear', 'createOrder')
if is_equal(¶mName, &Value::Null) {
return ternary(is_true(&(!is_equal(&defaultValue, &Value::Null))), defaultValue.clone(), methodDict.clone());
}
let mut splited: Value = split(¶mName, &Value::Str(".".to_string())); // can be only parent key (`stopLoss`) or with child (`stopLoss.triggerPrice`)
let mut parentKey: Value = get_value(&splited, &Value::Int(0));
let mut subKey: Value = self.safe_string(splited.clone(), Value::Int(1), &[]);
if !is_true(&(Value::Bool(in_op(&methodDict, &parentKey)))) {
return defaultValue;
}
let mut dictionary: Value = self.safe_dict(methodDict.clone(), parentKey.clone(), &[]);
if is_equal(&dictionary, &Value::Null) {
return get_value(&methodDict, &parentKey);
} else {
// return as is, when calling without subKey eg: featureValueByType('spot', undefined, 'createOrder', 'stopLoss')
if is_equal(&subKey, &Value::Null) {
return get_value(&methodDict, &parentKey);
}
// throw an exception for unsupported subKey
if !is_true(&(Value::Bool(in_op(&get_value(&methodDict, &parentKey), &subKey)))) {
return defaultValue;
}
return get_value(&get_value(&methodDict, &parentKey), &subKey);
}
Value::Null
}
fn orderbook_checksum_message(&self, mut symbol: Value) -> Value {
return add(&add(&symbol, &Value::Str(" : ".to_string())), &Value::Str("orderbook data checksum validation failed. You can reconnect by calling watchOrderBook again or you can mute the error by setting exchange.options[\"watchOrderBook\"][\"checksum\"] = false".to_string()));
Value::Null
}
fn create_networks_by_id_object(&mut self) {
// automatically generate network-id-to-code mappings
let mut networkIdsToCodesGenerated: Value = self.invert_flat_string_dictionary(self.safe_value_k(self.options.clone(), "networks", &[Value::Map({
let mut m = indexmap::IndexMap::new();
m
})])); // invert defined networks dictionary
{ let __be_tmp = self.extend(networkIdsToCodesGenerated.clone(), &[self.safe_value_k(self.options.clone(), "networksById", &[Value::Map({
let mut m = indexmap::IndexMap::new();
m
})])]); add_element_to_object(&mut self.options, &Value::Str("networksById".to_string()), __be_tmp); }; // support manually overriden "networksById" dictionary too
}
fn get_default_options(&self) -> Value {
return Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("defaultNetworkCodeReplacements".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("ETH".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("primary".to_string(), Value::Str("ETH".to_string()));
m.insert("secondary".to_string(), Value::Str("ERC20".to_string()));
m.insert("default".to_string(), Value::Str("secondary".to_string()));
m
}));
m.insert("CRO".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("primary".to_string(), Value::Str("CRONOS".to_string()));
m.insert("secondary".to_string(), Value::Str("CRC20".to_string()));
m.insert("default".to_string(), Value::Str("secondary".to_string()));
m
}));
m.insert("TRX".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("primary".to_string(), Value::Str("TRX".to_string()));
m.insert("secondary".to_string(), Value::Str("TRC20".to_string()));
m.insert("default".to_string(), Value::Str("secondary".to_string()));
m
}));
m.insert("BTC".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("primary".to_string(), Value::Str("BTC".to_string()));
m.insert("secondary".to_string(), Value::Str("BRC20".to_string()));
m.insert("default".to_string(), Value::Str("primary".to_string()));
m
}));
m
}));
m.insert("backwardSupportedNetworkCodes".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("ARB".to_string(), Value::Str("ARBITRUM".to_string()));
m.insert("ARBONE".to_string(), Value::Str("ARBITRUM".to_string()));
m.insert("ARBNOVA".to_string(), Value::Str("ARBITRUM_NOVA".to_string()));
m
}));
m
});
Value::Null
}
fn safe_ledger_entry(&self, mut entry: Value, optional_args: &[Value]) -> Value {
let mut currency = get_arg(optional_args, 0, Value::Null);
currency = self.safe_currency(Value::Null, &[currency.clone()]);
let mut direction: Value = self.safe_string_k(entry.clone(), "direction", &[]);
let mut before: Value = self.safe_string_k(entry.clone(), "before", &[]);
let mut after: Value = self.safe_string_k(entry.clone(), "after", &[]);
let mut amount: Value = self.safe_string_k(entry.clone(), "amount", &[]);
if !is_equal(&amount, &Value::Null) {
if is_equal(&before, &Value::Null) && !is_equal(&after, &Value::Null) {
before = crate::precise::Precise::stringSub(&after, &amount);
} else if !is_equal(&before, &Value::Null) && is_equal(&after, &Value::Null) {
after = crate::precise::Precise::stringAdd(&before, &amount);
}
}
if !is_equal(&before, &Value::Null) && !is_equal(&after, &Value::Null) {
if is_equal(&direction, &Value::Null) {
if is_true(&crate::precise::Precise::stringGt(&before, &after)) {
direction = Value::Str("out".to_string());
}
if is_true(&crate::precise::Precise::stringGt(&after, &before)) {
direction = Value::Str("in".to_string());
}
}
}
let mut fee: Value = self.safe_value_k(entry.clone(), "fee", &[]);
if !is_equal(&fee, &Value::Null) {
{ let __be_tmp = self.safe_number_k(fee.clone(), "cost", &[]); add_element_to_object(&mut fee, &Value::Str("cost".to_string()), __be_tmp); };
}
let mut timestamp: Value = self.safe_integer_k(entry.clone(), "timestamp", &[]);
let mut info: Value = self.safe_dict_k(entry.clone(), "info", &[Value::Map({
let mut m = indexmap::IndexMap::new();
m
})]);
return Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("id".to_string(), self.safe_string_k(entry.clone(), "id", &[]));
m.insert("timestamp".to_string(), timestamp.clone());
m.insert("datetime".to_string(), self.iso8601(timestamp.clone()));
m.insert("direction".to_string(), direction.clone());
m.insert("account".to_string(), self.safe_string_k(entry.clone(), "account", &[]));
m.insert("referenceId".to_string(), self.safe_string_k(entry.clone(), "referenceId", &[]));
m.insert("referenceAccount".to_string(), self.safe_string_k(entry.clone(), "referenceAccount", &[]));
m.insert("type".to_string(), self.safe_string_k(entry.clone(), "type", &[]));
m.insert("currency".to_string(), get_value(¤cy, &Value::Str("code".to_string())));
m.insert("amount".to_string(), self.parse_number(amount.clone(), &[]));
m.insert("before".to_string(), self.parse_number(before.clone(), &[]));
m.insert("after".to_string(), self.parse_number(after.clone(), &[]));
m.insert("status".to_string(), self.safe_string_k(entry.clone(), "status", &[]));
m.insert("fee".to_string(), fee.clone());
m.insert("info".to_string(), info.clone());
m
});
Value::Null
}
fn safe_currency_structure(&self, mut currency: Value) -> Value {
// derive data from networks: deposit, withdraw, active, fee, limits, precision
let mut networks: Value = self.safe_dict_k(currency.clone(), "networks", &[Value::Map({
let mut m = indexmap::IndexMap::new();
m
})]);
let mut keys: Value = object_keys(&networks);
let mut length: Value = get_array_length(&keys);
if !is_equal(&length, &Value::Int(0)) {
{
let mut i: Value = Value::Int(0);
let mut __for_first_83: bool = true;
while { if !__for_first_83 { i = add(&i, &Value::Int(1)); } __for_first_83 = false; is_less_than(&i, &length) } {
let mut key: Value = get_value(&keys, &i);
let mut key: Value = get_value(&keys, &i);
let mut network: Value = get_value(&networks, &key);
let mut network: Value = get_value(&networks, &key);
let mut deposit: Value = self.safe_bool_k(network.clone(), "deposit", &[]);
let mut currencyDeposit: Value = self.safe_bool_k(currency.clone(), "deposit", &[]);
if is_equal(¤cyDeposit, &Value::Null) || is_true(&(is_equal(&deposit, &Value::Bool(true)))) {
add_element_to_object(&mut currency, &Value::Str("deposit".to_string()), deposit.clone());
}
let mut withdraw: Value = self.safe_bool_k(network.clone(), "withdraw", &[]);
let mut currencyWithdraw: Value = self.safe_bool_k(currency.clone(), "withdraw", &[]);
if is_equal(¤cyWithdraw, &Value::Null) || is_true(&(is_equal(&withdraw, &Value::Bool(true)))) {
add_element_to_object(&mut currency, &Value::Str("withdraw".to_string()), withdraw.clone());
}
// find lowest fee (which is more desired)
let mut fee: Value = self.safe_string_k(network.clone(), "fee", &[]);
let mut feeMain: Value = self.safe_string_k(currency.clone(), "fee", &[]);
if is_equal(&feeMain, &Value::Null) || is_true(&crate::precise::Precise::stringLt(&fee, &feeMain)) {
add_element_to_object(&mut currency, &Value::Str("fee".to_string()), self.parse_number(fee.clone(), &[]));
}
// find lowest precision (which is more desired)
let mut precision: Value = self.safe_string_k(network.clone(), "precision", &[]);
let mut precisionMain: Value = self.safe_string_k(currency.clone(), "precision", &[]);
if is_equal(&precisionMain, &Value::Null) || is_true(&crate::precise::Precise::stringGt(&precision, &precisionMain)) {
add_element_to_object(&mut currency, &Value::Str("precision".to_string()), self.parse_number(precision.clone(), &[]));
}
// limits
let mut limits: Value = self.safe_dict_k(network.clone(), "limits", &[]);
let mut limitsMain: Value = self.safe_dict_k(currency.clone(), "limits", &[]);
if is_equal(&limitsMain, &Value::Null) {
add_element_to_object(&mut currency, &Value::Str("limits".to_string()), Value::Map({
let mut m = indexmap::IndexMap::new();
m
}));
}
// deposits
let mut limitsDeposit: Value = self.safe_dict_k(limits.clone(), "deposit", &[]);
let mut limitsDepositMain: Value = self.safe_dict_k(limitsMain.clone(), "deposit", &[]);
if is_equal(&limitsDepositMain, &Value::Null) {
add_element_to_object(get_value_mut(&mut currency, &Value::Str("limits".to_string())), &Value::Str("deposit".to_string()), Value::Map({
let mut m = indexmap::IndexMap::new();
m
}));
}
let mut limitsDepositMin: Value = self.safe_string_k(limitsDeposit.clone(), "min", &[]);
let mut limitsDepositMax: Value = self.safe_string_k(limitsDeposit.clone(), "max", &[]);
let mut limitsDepositMinMain: Value = self.safe_string_k(limitsDepositMain.clone(), "min", &[]);
let mut limitsDepositMaxMain: Value = self.safe_string_k(limitsDepositMain.clone(), "max", &[]);
// find min
if is_equal(&limitsDepositMinMain, &Value::Null) || is_true(&crate::precise::Precise::stringLt(&limitsDepositMin, &limitsDepositMinMain)) {
add_element_to_object(get_value_mut(get_value_mut(&mut currency, &Value::Str("limits".to_string())), &Value::Str("deposit".to_string())), &Value::Str("min".to_string()), self.parse_number(limitsDepositMin.clone(), &[]));
}
// find max
if is_equal(&limitsDepositMaxMain, &Value::Null) || is_true(&crate::precise::Precise::stringGt(&limitsDepositMax, &limitsDepositMaxMain)) {
add_element_to_object(get_value_mut(get_value_mut(&mut currency, &Value::Str("limits".to_string())), &Value::Str("deposit".to_string())), &Value::Str("max".to_string()), self.parse_number(limitsDepositMax.clone(), &[]));
}
// withdrawals
let mut limitsWithdraw: Value = self.safe_dict_k(limits.clone(), "withdraw", &[]);
let mut limitsWithdrawMain: Value = self.safe_dict_k(limitsMain.clone(), "withdraw", &[]);
if is_equal(&limitsWithdrawMain, &Value::Null) {
add_element_to_object(get_value_mut(&mut currency, &Value::Str("limits".to_string())), &Value::Str("withdraw".to_string()), Value::Map({
let mut m = indexmap::IndexMap::new();
m
}));
}
let mut limitsWithdrawMin: Value = self.safe_string_k(limitsWithdraw.clone(), "min", &[]);
let mut limitsWithdrawMax: Value = self.safe_string_k(limitsWithdraw.clone(), "max", &[]);
let mut limitsWithdrawMinMain: Value = self.safe_string_k(limitsWithdrawMain.clone(), "min", &[]);
let mut limitsWithdrawMaxMain: Value = self.safe_string_k(limitsWithdrawMain.clone(), "max", &[]);
// find min
if is_equal(&limitsWithdrawMinMain, &Value::Null) || is_true(&crate::precise::Precise::stringLt(&limitsWithdrawMin, &limitsWithdrawMinMain)) {
add_element_to_object(get_value_mut(get_value_mut(&mut currency, &Value::Str("limits".to_string())), &Value::Str("withdraw".to_string())), &Value::Str("min".to_string()), self.parse_number(limitsWithdrawMin.clone(), &[]));
}
// find max
if is_equal(&limitsWithdrawMaxMain, &Value::Null) || is_true(&crate::precise::Precise::stringGt(&limitsWithdrawMax, &limitsWithdrawMaxMain)) {
add_element_to_object(get_value_mut(get_value_mut(&mut currency, &Value::Str("limits".to_string())), &Value::Str("withdraw".to_string())), &Value::Str("max".to_string()), self.parse_number(limitsWithdrawMax.clone(), &[]));
}
}
}
}
return self.extend(Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("info".to_string(), Value::Null);
m.insert("id".to_string(), Value::Null);
m.insert("numericId".to_string(), Value::Null);
m.insert("code".to_string(), Value::Null);
m.insert("precision".to_string(), Value::Null);
m.insert("type".to_string(), Value::Null);
m.insert("name".to_string(), Value::Null);
m.insert("active".to_string(), Value::Null);
m.insert("deposit".to_string(), Value::Null);
m.insert("withdraw".to_string(), Value::Null);
m.insert("fee".to_string(), Value::Null);
m.insert("fees".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m
}));
m.insert("networks".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m
}));
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(), Value::Null);
m.insert("max".to_string(), Value::Null);
m
}));
m.insert("withdraw".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("min".to_string(), Value::Null);
m.insert("max".to_string(), Value::Null);
m
}));
m
}));
m
}), &[currency.clone()]);
Value::Null
}
fn safe_market_structure(&self, optional_args: &[Value]) -> Value {
let mut market = get_arg(optional_args, 0, Value::Null);
let mut cleanStructure: Value = Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("id".to_string(), Value::Null);
m.insert("lowercaseId".to_string(), Value::Null);
m.insert("symbol".to_string(), Value::Null);
m.insert("base".to_string(), Value::Null);
m.insert("quote".to_string(), Value::Null);
m.insert("settle".to_string(), Value::Null);
m.insert("baseId".to_string(), Value::Null);
m.insert("quoteId".to_string(), Value::Null);
m.insert("settleId".to_string(), Value::Null);
m.insert("type".to_string(), Value::Null);
m.insert("spot".to_string(), Value::Null);
m.insert("margin".to_string(), Value::Null);
m.insert("swap".to_string(), Value::Null);
m.insert("future".to_string(), Value::Null);
m.insert("option".to_string(), Value::Null);
m.insert("index".to_string(), Value::Null);
m.insert("active".to_string(), Value::Null);
m.insert("contract".to_string(), Value::Null);
m.insert("linear".to_string(), Value::Null);
m.insert("inverse".to_string(), Value::Null);
m.insert("subType".to_string(), Value::Null);
m.insert("taker".to_string(), Value::Null);
m.insert("maker".to_string(), Value::Null);
m.insert("contractSize".to_string(), Value::Null);
m.insert("expiry".to_string(), Value::Null);
m.insert("expiryDatetime".to_string(), Value::Null);
m.insert("strike".to_string(), Value::Null);
m.insert("optionType".to_string(), Value::Null);
m.insert("precision".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("amount".to_string(), Value::Null);
m.insert("price".to_string(), Value::Null);
m.insert("cost".to_string(), Value::Null);
m.insert("base".to_string(), Value::Null);
m.insert("quote".to_string(), Value::Null);
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(), Value::Null);
m.insert("max".to_string(), Value::Null);
m
}));
m.insert("price".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("min".to_string(), Value::Null);
m.insert("max".to_string(), Value::Null);
m
}));
m.insert("cost".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("min".to_string(), Value::Null);
m.insert("max".to_string(), Value::Null);
m
}));
m
}));
m.insert("marginModes".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cross".to_string(), Value::Null);
m.insert("isolated".to_string(), Value::Null);
m
}));
m.insert("created".to_string(), Value::Null);
m.insert("info".to_string(), Value::Null);
m
});
if !is_equal(&market, &Value::Null) {
let mut result: Value = self.extend(cleanStructure.clone(), &[market.clone()]);
// set undefined swap/future/etc
if is_equal(&get_value(&result, &Value::Str("spot".to_string())), &Value::Bool(true)) {
if is_equal(&get_value(&result, &Value::Str("contract".to_string())), &Value::Null) {
add_element_to_object(&mut result, &Value::Str("contract".to_string()), Value::Bool(false));
}
if is_equal(&get_value(&result, &Value::Str("swap".to_string())), &Value::Null) {
add_element_to_object(&mut result, &Value::Str("swap".to_string()), Value::Bool(false));
}
if is_equal(&get_value(&result, &Value::Str("future".to_string())), &Value::Null) {
add_element_to_object(&mut result, &Value::Str("future".to_string()), Value::Bool(false));
}
if is_equal(&get_value(&result, &Value::Str("option".to_string())), &Value::Null) {
add_element_to_object(&mut result, &Value::Str("option".to_string()), Value::Bool(false));
}
if is_equal(&get_value(&result, &Value::Str("index".to_string())), &Value::Null) {
add_element_to_object(&mut result, &Value::Str("index".to_string()), Value::Bool(false));
}
}
return result;
}
return self.extend(cleanStructure.clone(), &[]);
Value::Null
}
fn set_markets(&mut self, mut markets: Value, optional_args: &[Value]) -> Value {
let mut currencies = get_arg(optional_args, 0, Value::Null);
let mut values: Value = Value::List(vec![]);
{ let __t = self.create_safe_dictionary(&[]); self.markets_by_id = __t; }
// handle marketId conflicts
// we insert spot markets first
let mut marketValues: Value = self.sort_by(self.to_array(markets.clone()), Value::Str("spot".to_string()), &[Value::Bool(true), Value::Bool(true)]);
{
let mut i: Value = Value::Int(0);
let mut __for_first_85: bool = true;
while { if !__for_first_85 { i = add(&i, &Value::Int(1)); } __for_first_85 = false; is_less_than(&i, &get_array_length(&marketValues)) } {
let mut value: Value = get_value(&marketValues, &i);
let mut value: Value = get_value(&marketValues, &i);
if is_true(&Value::Bool(in_op(&self.markets_by_id, &get_value(&value, &Value::Str("id".to_string()))))) {
let mut marketsByIdArray: Value = get_value(&self.markets_by_id, &get_value(&value, &Value::Str("id".to_string())));
append_to_array(&mut marketsByIdArray, value.clone());
add_element_to_object(&mut self.markets_by_id, &get_value(&value, &Value::Str("id".to_string())), marketsByIdArray.clone());
} else {
add_element_to_object(&mut self.markets_by_id, &get_value(&value, &Value::Str("id".to_string())), Value::List(vec![value.clone()]));
}
// strip undefined-valued keys from the parsed market before deepExtend,
// otherwise an explicit `taker: undefined` (from safeMarketStructure)
// would clobber the fee defaults from this.fees['trading'] in the merge
let mut valueDefined: Value = Value::Map({
let mut m = indexmap::IndexMap::new();
m
});
let mut valueKeys: Value = object_keys(&value);
{
let mut j: Value = Value::Int(0);
let mut __for_first_84: bool = true;
while { if !__for_first_84 { j = add(&j, &Value::Int(1)); } __for_first_84 = false; is_less_than(&j, &get_array_length(&valueKeys)) } {
let mut valueKey: Value = get_value(&valueKeys, &j);
let mut valueKey: Value = get_value(&valueKeys, &j);
if !is_equal(&get_value(&value, &valueKey), &Value::Null) {
add_element_to_object(&mut valueDefined, &valueKey, get_value(&value, &valueKey));
}
}
}
let mut market: Value = self.deep_extend(self.safe_market_structure(&[]), &[Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("precision".to_string(), self.precision.clone());
m.insert("limits".to_string(), self.limits.clone());
m
}), get_value(&self.fees, &Value::Str("trading".to_string())), valueDefined.clone()]);
if is_equal(&get_value(&market, &Value::Str("linear".to_string())), &Value::Bool(true)) {
add_element_to_object(&mut market, &Value::Str("subType".to_string()), Value::Str("linear".to_string()));
} else if is_equal(&get_value(&market, &Value::Str("inverse".to_string())), &Value::Bool(true)) {
add_element_to_object(&mut market, &Value::Str("subType".to_string()), Value::Str("inverse".to_string()));
} else {
add_element_to_object(&mut market, &Value::Str("subType".to_string()), Value::Null);
}
append_to_array(&mut values, market.clone());
}
}
{ let __t = self.map_to_safe_map(self.index_by(values.clone(), Value::Str("symbol".to_string()))); self.markets = __t; }
let mut marketsSortedBySymbol: Value = self.keysort(self.markets.clone(), &[]);
let mut marketsSortedById: Value = self.keysort(self.markets_by_id.clone(), &[]);
self.symbols = object_keys(&marketsSortedBySymbol);
self.ids = object_keys(&marketsSortedById);
let mut numCurrencies: Value = Value::Int(0);
if !is_equal(¤cies, &Value::Null) {
let mut keys: Value = object_keys(¤cies);
numCurrencies = get_array_length(&keys);
}
if is_greater_than(&numCurrencies, &Value::Int(0)) {
// currencies is always undefined when called in constructor but not when called from loadMarkets
{ let __t = self.map_to_safe_map(self.deep_extend(self.currencies.clone(), &[currencies.clone()])); self.currencies = __t; }
} else {
let mut baseCurrencies: Value = Value::List(vec![]);
let mut quoteCurrencies: Value = Value::List(vec![]);
{
let mut i: Value = Value::Int(0);
let mut __for_first_86: bool = true;
while { if !__for_first_86 { i = add(&i, &Value::Int(1)); } __for_first_86 = false; is_less_than(&i, &get_array_length(&values)) } {
let mut market: Value = get_value(&values, &i);
let mut market: Value = get_value(&values, &i);
let mut defaultCurrencyPrecision: Value = ternary(is_true(&(is_equal(&self.precisionMode, &Value::Int(crate::runtime::DECIMAL_PLACES)))), Value::Int(8), self.parse_number(Value::Str("1e-8".to_string()), &[]));
let mut marketPrecision: Value = self.safe_dict_k(market.clone(), "precision", &[Value::Map({
let mut m = indexmap::IndexMap::new();
m
})]);
if is_true(&Value::Bool(in_op(&market, &Value::Str("base".to_string())))) {
let mut currency: Value = self.safe_currency_structure(Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("id".to_string(), self.safe_string2(market.clone(), Value::Str("baseId".to_string()), Value::Str("base".to_string()), &[]));
m.insert("numericId".to_string(), self.safe_integer_k(market.clone(), "baseNumericId", &[]));
m.insert("code".to_string(), self.safe_string_k(market.clone(), "base", &[]));
m.insert("precision".to_string(), self.safe_value2(marketPrecision.clone(), Value::Str("base".to_string()), Value::Str("amount".to_string()), &[defaultCurrencyPrecision.clone()]));
m
}));
append_to_array(&mut baseCurrencies, currency.clone());
}
if is_true(&Value::Bool(in_op(&market, &Value::Str("quote".to_string())))) {
let mut currency: Value = self.safe_currency_structure(Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("id".to_string(), self.safe_string2(market.clone(), Value::Str("quoteId".to_string()), Value::Str("quote".to_string()), &[]));
m.insert("numericId".to_string(), self.safe_integer_k(market.clone(), "quoteNumericId", &[]));
m.insert("code".to_string(), self.safe_string_k(market.clone(), "quote", &[]));
m.insert("precision".to_string(), self.safe_value2(marketPrecision.clone(), Value::Str("quote".to_string()), Value::Str("price".to_string()), &[defaultCurrencyPrecision.clone()]));
m
}));
append_to_array(&mut quoteCurrencies, currency.clone());
}
}
}
baseCurrencies = self.sort_by(baseCurrencies.clone(), Value::Str("code".to_string()), &[Value::Bool(false), Value::Str("".to_string())]);
quoteCurrencies = self.sort_by(quoteCurrencies.clone(), Value::Str("code".to_string()), &[Value::Bool(false), Value::Str("".to_string())]);
{ let __t = self.map_to_safe_map(self.index_by(baseCurrencies.clone(), Value::Str("code".to_string()))); self.baseCurrencies = __t; }
{ let __t = self.map_to_safe_map(self.index_by(quoteCurrencies.clone(), Value::Str("code".to_string()))); self.quoteCurrencies = __t; }
let mut allCurrencies: Value = self.array_concat(baseCurrencies.clone(), quoteCurrencies.clone());
let mut groupedCurrencies: Value = self.group_by(allCurrencies.clone(), Value::Str("code".to_string()), &[]);
let mut codes: Value = object_keys(&groupedCurrencies);
let mut resultingCurrencies: Value = Value::List(vec![]);
{
let mut i: Value = Value::Int(0);
let mut __for_first_88: bool = true;
while { if !__for_first_88 { i = add(&i, &Value::Int(1)); } __for_first_88 = false; is_less_than(&i, &get_array_length(&codes)) } {
let mut code: Value = get_value(&codes, &i);
let mut code: Value = get_value(&codes, &i);
let mut groupedCurrenciesCode: Value = self.safe_list(groupedCurrencies.clone(), code.clone(), &[Value::List(vec![])]);
let mut highestPrecisionCurrency: Value = self.safe_value(groupedCurrenciesCode.clone(), Value::Int(0), &[]);
{
let mut j: Value = Value::Int(1);
let mut __for_first_87: bool = true;
while { if !__for_first_87 { j = add(&j, &Value::Int(1)); } __for_first_87 = false; is_less_than(&j, &get_array_length(&groupedCurrenciesCode)) } {
let mut currentCurrency: Value = get_value(&groupedCurrenciesCode, &j);
let mut currentCurrency: Value = get_value(&groupedCurrenciesCode, &j);
if is_equal(&self.precisionMode, &Value::Int(crate::runtime::TICK_SIZE)) {
highestPrecisionCurrency = ternary(is_true(&(is_less_than(&get_value(¤tCurrency, &Value::Str("precision".to_string())), &get_value(&highestPrecisionCurrency, &Value::Str("precision".to_string()))))), currentCurrency.clone(), highestPrecisionCurrency.clone());
} else {
highestPrecisionCurrency = ternary(is_true(&(is_greater_than(&get_value(¤tCurrency, &Value::Str("precision".to_string())), &get_value(&highestPrecisionCurrency, &Value::Str("precision".to_string()))))), currentCurrency.clone(), highestPrecisionCurrency.clone());
}
}
}
append_to_array(&mut resultingCurrencies, highestPrecisionCurrency.clone());
}
}
let mut sortedCurrencies: Value = self.sort_by(resultingCurrencies.clone(), Value::Str("code".to_string()), &[]);
{ let __t = self.map_to_safe_map(self.deep_extend(self.currencies.clone(), &[self.index_by(sortedCurrencies.clone(), Value::Str("code".to_string()))])); self.currencies = __t; }
}
{ let __t = self.index_by_safe(self.currencies.clone(), Value::Str("id".to_string())); self.currencies_by_id = __t; }
let mut currenciesSortedByCode: Value = self.keysort(self.currencies.clone(), &[]);
self.codes = object_keys(¤ciesSortedByCode);
if is_equal(&self.markets, &Value::Null) {
panic!("{}", crate::exchange_errors::exchange_error(add(&self.id, &Value::Str(" setMarkets() markets not set".to_string()))));
}
return self.markets.clone();
Value::Null
}
fn set_markets_from_exchange(&mut self, mut sourceExchange: Value) -> Value {
// Validate that both exchanges are of the same type
if !is_equal(&self.id, &get_value(&sourceExchange, &Value::Str("id".to_string()))) {
panic!("{}", crate::exchange_errors::arguments_required(add(&add(&add(&self.id, &Value::Str(" shareMarkets() can only share markets with exchanges of the same type (got ".to_string())), &get_value(&sourceExchange, &Value::Str("id".to_string()))), &Value::Str(")".to_string()))));
}
// Validate that source exchange has loaded markets
if is_true(&(is_equal(&get_value(&sourceExchange, &Value::Str("markets".to_string())), &Value::Null))) || is_true(&(is_equal(&get_value(&sourceExchange, &Value::Str("markets".to_string())), &Value::Null))) {
panic!("{}", crate::exchange_errors::exchange_error(Value::Str("setMarketsFromExchange() source exchange must have loaded markets first. Can call by using loadMarkets function".to_string())));
}
// Set all market-related data
self.markets = get_value(&sourceExchange, &Value::Str("markets".to_string()));
self.markets_by_id = get_value(&sourceExchange, &Value::Str("markets_by_id".to_string()));
self.symbols = get_value(&sourceExchange, &Value::Str("symbols".to_string()));
self.ids = get_value(&sourceExchange, &Value::Str("ids".to_string()));
self.currencies = get_value(&sourceExchange, &Value::Str("currencies".to_string()));
self.currencies_by_id = get_value(&sourceExchange, &Value::Str("currencies_by_id".to_string()));
self.baseCurrencies = get_value(&sourceExchange, &Value::Str("baseCurrencies".to_string()));
self.quoteCurrencies = get_value(&sourceExchange, &Value::Str("quoteCurrencies".to_string()));
self.codes = get_value(&sourceExchange, &Value::Str("codes".to_string()));
// check marketHelperProps
let mut sourceExchangeHelpers: Value = self.safe_list(get_value(&sourceExchange, &Value::Str("options".to_string())), Value::Str("marketHelperProps".to_string()), &[Value::List(vec![])]);
{
let mut i: Value = Value::Int(0);
let mut __for_first_89: bool = true;
while { if !__for_first_89 { i = add(&i, &Value::Int(1)); } __for_first_89 = false; is_less_than(&i, &get_array_length(&sourceExchangeHelpers)) } {
let mut helper: Value = get_value(&sourceExchangeHelpers, &i);
let mut helper: Value = get_value(&sourceExchangeHelpers, &i);
if !is_equal(&get_value(&get_value(&sourceExchange, &Value::Str("options".to_string())), &helper), &Value::Null) {
add_element_to_object(&mut self.options, &helper, get_value(&get_value(&sourceExchange, &Value::Str("options".to_string())), &helper));
}
}
}
return Value::Null;
Value::Null
}
fn get_describe_for_extended_ws_exchange(&self, mut currentRestInstance: Value, mut parentRestInstance: Value, mut wsBaseDescribe: Value) -> Value {
let mut extendedRestDescribe: Value = self.deep_extend(parentRestInstance.describe(), &[currentRestInstance.describe()]);
let mut superWithRestDescribe: Value = self.deep_extend(extendedRestDescribe.clone(), &[wsBaseDescribe.clone()]);
return superWithRestDescribe;
Value::Null
}
fn safe_balance(&self, mut balance: Value) -> Value {
let mut balances: Value = self.omit(balance.clone(), Value::List(vec![Value::Str("info".to_string()), Value::Str("timestamp".to_string()), Value::Str("datetime".to_string()), Value::Str("free".to_string()), Value::Str("used".to_string()), Value::Str("total".to_string())]), &[]);
let mut codes: Value = object_keys(&balances);
add_element_to_object(&mut balance, &Value::Str("free".to_string()), Value::Map({
let mut m = indexmap::IndexMap::new();
m
}));
add_element_to_object(&mut balance, &Value::Str("used".to_string()), Value::Map({
let mut m = indexmap::IndexMap::new();
m
}));
add_element_to_object(&mut balance, &Value::Str("total".to_string()), Value::Map({
let mut m = indexmap::IndexMap::new();
m
}));
let mut debtBalance: Value = Value::Map({
let mut m = indexmap::IndexMap::new();
m
});
{
let mut i: Value = Value::Int(0);
let mut __for_first_90: bool = true;
while { if !__for_first_90 { i = add(&i, &Value::Int(1)); } __for_first_90 = false; is_less_than(&i, &get_array_length(&codes)) } {
let mut code: Value = get_value(&codes, &i);
let mut code: Value = get_value(&codes, &i);
let mut total: Value = self.safe_string_k(get_value(&balance, &code), "total", &[]);
let mut free: Value = self.safe_string_k(get_value(&balance, &code), "free", &[]);
let mut used: Value = self.safe_string_k(get_value(&balance, &code), "used", &[]);
let mut debt: Value = self.safe_string_k(get_value(&balance, &code), "debt", &[]);
if is_true(&(is_equal(&total, &Value::Null))) && is_true(&(!is_equal(&free, &Value::Null))) && is_true(&(!is_equal(&used, &Value::Null))) {
total = crate::precise::Precise::stringAdd(&free, &used);
}
if is_true(&(is_equal(&free, &Value::Null))) && is_true(&(!is_equal(&total, &Value::Null))) && is_true(&(!is_equal(&used, &Value::Null))) {
free = crate::precise::Precise::stringSub(&total, &used);
}
if is_true(&(is_equal(&used, &Value::Null))) && is_true(&(!is_equal(&total, &Value::Null))) && is_true(&(!is_equal(&free, &Value::Null))) {
used = crate::precise::Precise::stringSub(&total, &free);
}
add_element_to_object(get_value_mut(&mut balance, &code), &Value::Str("free".to_string()), self.parse_number(free.clone(), &[]));
add_element_to_object(get_value_mut(&mut balance, &code), &Value::Str("used".to_string()), self.parse_number(used.clone(), &[]));
add_element_to_object(get_value_mut(&mut balance, &code), &Value::Str("total".to_string()), self.parse_number(total.clone(), &[]));
{ let __be_tmp = get_value(&get_value(&balance, &code), &Value::Str("free".to_string())); add_element_to_object(get_value_mut(&mut balance, &Value::Str("free".to_string())), &code, __be_tmp); };
{ let __be_tmp = get_value(&get_value(&balance, &code), &Value::Str("used".to_string())); add_element_to_object(get_value_mut(&mut balance, &Value::Str("used".to_string())), &code, __be_tmp); };
{ let __be_tmp = get_value(&get_value(&balance, &code), &Value::Str("total".to_string())); add_element_to_object(get_value_mut(&mut balance, &Value::Str("total".to_string())), &code, __be_tmp); };
if !is_equal(&debt, &Value::Null) {
add_element_to_object(get_value_mut(&mut balance, &code), &Value::Str("debt".to_string()), self.parse_number(debt.clone(), &[]));
add_element_to_object(&mut debtBalance, &code, get_value(&get_value(&balance, &code), &Value::Str("debt".to_string())));
}
}
}
let mut debtBalanceArray: Value = object_keys(&debtBalance);
let mut length: Value = get_array_length(&debtBalanceArray);
if is_true(&(!is_equal(&length, &Value::Null))) && is_true(&(!is_equal(&length, &Value::Int(0)))) {
add_element_to_object(&mut balance, &Value::Str("debt".to_string()), debtBalance.clone());
}
return balance;
Value::Null
}
fn safe_order(&self, mut order: Value, optional_args: &[Value]) -> Value {
let mut market = get_arg(optional_args, 0, Value::Null);
// parses numbers as strings
// * it is important pass the trades as unparsed rawTrades
if is_equal(&order, &Value::Null) {
order = Value::Map({
let mut m = indexmap::IndexMap::new();
m
});
}
let mut amount: Value = self.omit_zero(self.safe_string_k(order.clone(), "amount", &[]));
let mut remaining: Value = self.safe_string_k(order.clone(), "remaining", &[]);
let mut filled: Value = self.safe_string_k(order.clone(), "filled", &[]);
let mut cost: Value = self.safe_string_k(order.clone(), "cost", &[]);
let mut average: Value = self.omit_zero(self.safe_string_k(order.clone(), "average", &[]));
let mut price: Value = self.omit_zero(self.safe_string_k(order.clone(), "price", &[]));
let mut lastTradeTimeTimestamp: Value = self.safe_integer_k(order.clone(), "lastTradeTimestamp", &[]);
let mut symbol: Value = self.safe_string_k(order.clone(), "symbol", &[]);
let mut side: Value = self.safe_string_k(order.clone(), "side", &[]);
let mut status: Value = self.safe_string_k(order.clone(), "status", &[]);
let mut parseFilled: bool = is_equal(&filled, &Value::Null);
let mut parseCost: bool = is_equal(&cost, &Value::Null);
let mut parseLastTradeTimeTimestamp: bool = is_equal(&lastTradeTimeTimestamp, &Value::Null);
let mut fee: Value = self.safe_value_k(order.clone(), "fee", &[]);
let mut parseFee: bool = is_equal(&fee, &Value::Null);
let mut parseFees: bool = is_equal(&self.safe_value_k(order.clone(), "fees", &[]), &Value::Null);
let mut parseSymbol: bool = is_equal(&symbol, &Value::Null);
let mut parseSide: bool = is_equal(&side, &Value::Null);
let mut shouldParseFees: bool = is_true(&parseFee) || is_true(&parseFees);
let mut fees: Value = self.safe_list_k(order.clone(), "fees", &[Value::List(vec![])]);
let mut trades: Value = Value::List(vec![]);
let mut isTriggerOrSLTpOrder: bool = is_true(&(!is_equal(&self.safe_string_k(order.clone(), "triggerPrice", &[]), &Value::Null) || is_true(&(!is_equal(&self.safe_string_k(order.clone(), "stopLossPrice", &[]), &Value::Null))))) || is_true(&(!is_equal(&self.safe_string_k(order.clone(), "takeProfitPrice", &[]), &Value::Null)));
if is_true(&parseFilled) || is_true(&parseCost) || is_true(&shouldParseFees) {
let mut rawTrades: Value = self.safe_value_k(order.clone(), "trades", &[trades.clone()]);
// const oldNumber = this.number;
// we parse trades as strings here!
// i don't think this is needed anymore
// (this as any).number = String;
let mut firstTrade: Value = self.safe_value(rawTrades.clone(), Value::Int(0), &[]);
// parse trades if they haven't already been parsed
let mut tradesAreParsed: bool = is_true(&(!is_equal(&firstTrade, &Value::Null))) && is_true(&(Value::Bool(in_op(&firstTrade, &Value::Str("info".to_string()))))) && is_true(&(Value::Bool(in_op(&firstTrade, &Value::Str("id".to_string())))));
if !is_true(&tradesAreParsed) {
trades = self.parse_trades(rawTrades.clone(), &[market.clone()]);
} else {
trades = rawTrades.clone();
}
// this.number = oldNumber; why parse trades as strings if you read the value using `safeString` ?
let mut tradesLength: Value = Value::Int(0);
let mut isArray: bool = is_array(&trades);
if is_true(&isArray) {
tradesLength = get_array_length(&trades);
}
if is_true(&isArray) && is_true(&(is_greater_than(&tradesLength, &Value::Int(0)))) {
// move properties that are defined in trades up into the order
if is_equal(&get_value(&order, &Value::Str("symbol".to_string())), &Value::Null) {
add_element_to_object(&mut order, &Value::Str("symbol".to_string()), get_value(&get_value(&trades, &Value::Int(0)), &Value::Str("symbol".to_string())));
}
if is_equal(&get_value(&order, &Value::Str("side".to_string())), &Value::Null) {
add_element_to_object(&mut order, &Value::Str("side".to_string()), get_value(&get_value(&trades, &Value::Int(0)), &Value::Str("side".to_string())));
}
if is_equal(&get_value(&order, &Value::Str("type".to_string())), &Value::Null) {
add_element_to_object(&mut order, &Value::Str("type".to_string()), get_value(&get_value(&trades, &Value::Int(0)), &Value::Str("type".to_string())));
}
if is_equal(&get_value(&order, &Value::Str("id".to_string())), &Value::Null) {
add_element_to_object(&mut order, &Value::Str("id".to_string()), get_value(&get_value(&trades, &Value::Int(0)), &Value::Str("order".to_string())));
}
if is_true(&parseFilled) {
filled = Value::Str("0".to_string());
}
if is_true(&parseCost) {
cost = Value::Str("0".to_string());
}
{
let mut i: Value = Value::Int(0);
let mut __for_first_92: bool = true;
while { if !__for_first_92 { i = add(&i, &Value::Int(1)); } __for_first_92 = false; is_less_than(&i, &get_array_length(&trades)) } {
let mut trade: Value = get_value(&trades, &i);
let mut trade: Value = get_value(&trades, &i);
let mut tradeAmount: Value = self.safe_string_k(trade.clone(), "amount", &[]);
if is_true(&parseFilled) && is_true(&(!is_equal(&tradeAmount, &Value::Null))) {
filled = crate::precise::Precise::stringAdd(&filled, &tradeAmount);
}
let mut tradeCost: Value = self.safe_string_k(trade.clone(), "cost", &[]);
if is_true(&parseCost) && is_true(&(!is_equal(&tradeCost, &Value::Null))) {
cost = crate::precise::Precise::stringAdd(&cost, &tradeCost);
}
if is_true(&parseSymbol) {
symbol = self.safe_string_k(trade.clone(), "symbol", &[]);
}
if is_true(&parseSide) {
side = self.safe_string_k(trade.clone(), "side", &[]);
}
let mut tradeTimestamp: Value = self.safe_value_k(trade.clone(), "timestamp", &[]);
if is_true(&parseLastTradeTimeTimestamp) && is_true(&(!is_equal(&tradeTimestamp, &Value::Null))) {
if is_equal(&lastTradeTimeTimestamp, &Value::Null) {
lastTradeTimeTimestamp = tradeTimestamp.clone();
} else {
lastTradeTimeTimestamp = crate::runtime::Math::max(&lastTradeTimeTimestamp, &tradeTimestamp);
}
}
if is_true(&shouldParseFees) {
let mut tradeFees: Value = self.safe_value_k(trade.clone(), "fees", &[]);
if !is_equal(&tradeFees, &Value::Null) {
{
let mut j: Value = Value::Int(0);
let mut __for_first_91: bool = true;
while { if !__for_first_91 { j = add(&j, &Value::Int(1)); } __for_first_91 = false; is_less_than(&j, &get_array_length(&tradeFees)) } {
let mut tradeFee: Value = get_value(&tradeFees, &j);
let mut tradeFee: Value = get_value(&tradeFees, &j);
append_to_array(&mut fees, self.extend(Value::Map({
let mut m = indexmap::IndexMap::new();
m
}), &[tradeFee.clone()]));
}
}
} else {
let mut tradeFee: Value = self.safe_value_k(trade.clone(), "fee", &[]);
if !is_equal(&tradeFee, &Value::Null) {
append_to_array(&mut fees, self.extend(Value::Map({
let mut m = indexmap::IndexMap::new();
m
}), &[tradeFee.clone()]));
}
}
}
}
}
}
}
if is_true(&shouldParseFees) {
let mut reducedFees: Value = fees.clone();
if is_true(&self.reduceFees) {
reducedFees = self.reduce_fees_by_currency(fees.clone());
}
if is_equal(&reducedFees, &Value::Null) {
reducedFees = Value::List(vec![]);
}
let mut reducedLength: Value = get_array_length(&reducedFees);
{
let mut i: Value = Value::Int(0);
let mut __for_first_93: bool = true;
while { if !__for_first_93 { i = add(&i, &Value::Int(1)); } __for_first_93 = false; is_less_than(&i, &reducedLength) } {
{ let __be_tmp = self.safe_number_k(get_value(&reducedFees, &i), "cost", &[]); add_element_to_object(get_value_mut(&mut reducedFees, &i), &Value::Str("cost".to_string()), __be_tmp); };
if is_true(&Value::Bool(in_op(&get_value(&reducedFees, &i), &Value::Str("rate".to_string())))) {
{ let __be_tmp = self.safe_number_k(get_value(&reducedFees, &i), "rate", &[]); add_element_to_object(get_value_mut(&mut reducedFees, &i), &Value::Str("rate".to_string()), __be_tmp); };
}
}
}
if !is_true(&parseFee) && is_true(&(is_equal(&reducedLength, &Value::Int(0)))) {
// copy fee to avoid modification by reference
let mut feeCopy: Value = self.deep_extend(fee.clone(), &[]);
{ let __be_tmp = self.safe_number_k(feeCopy.clone(), "cost", &[]); add_element_to_object(&mut feeCopy, &Value::Str("cost".to_string()), __be_tmp); };
if is_true(&Value::Bool(in_op(&feeCopy, &Value::Str("rate".to_string())))) {
{ let __be_tmp = self.safe_number_k(feeCopy.clone(), "rate", &[]); add_element_to_object(&mut feeCopy, &Value::Str("rate".to_string()), __be_tmp); };
}
append_to_array(&mut reducedFees, feeCopy.clone());
}
add_element_to_object(&mut order, &Value::Str("fees".to_string()), reducedFees.clone());
if is_true(&parseFee) && is_true(&(is_equal(&reducedLength, &Value::Int(1)))) {
add_element_to_object(&mut order, &Value::Str("fee".to_string()), get_value(&reducedFees, &Value::Int(0)));
}
}
if is_equal(&amount, &Value::Null) {
// ensure amount = filled + remaining
if !is_equal(&filled, &Value::Null) && !is_equal(&remaining, &Value::Null) {
amount = crate::precise::Precise::stringAdd(&filled, &remaining);
} else if is_equal(&status, &Value::Str("closed".to_string())) {
amount = filled.clone();
}
}
if is_equal(&filled, &Value::Null) {
if !is_equal(&amount, &Value::Null) && !is_equal(&remaining, &Value::Null) {
filled = crate::precise::Precise::stringSub(&amount, &remaining);
} else if is_equal(&status, &Value::Str("closed".to_string())) && !is_equal(&amount, &Value::Null) {
filled = amount.clone();
}
}
if is_equal(&remaining, &Value::Null) {
if !is_equal(&amount, &Value::Null) && !is_equal(&filled, &Value::Null) {
remaining = crate::precise::Precise::stringSub(&amount, &filled);
} else if is_equal(&status, &Value::Str("closed".to_string())) {
remaining = Value::Str("0".to_string());
}
}
// ensure that the average field is calculated correctly
let mut inverse: Value = self.safe_bool_k(market.clone(), "inverse", &[Value::Bool(false)]);
let mut contractSize: Value = self.number_to_string(self.safe_value_k(market.clone(), "contractSize", &[Value::Int(1)]));
// inverse
// price = filled * contract size / cost
//
// linear
// price = cost / (filled * contract size)
if is_equal(&average, &Value::Null) {
if is_true(&(!is_equal(&filled, &Value::Null))) && is_true(&(!is_equal(&cost, &Value::Null))) && is_true(&crate::precise::Precise::stringGt(&filled, &Value::Str("0".to_string()))) {
let mut filledTimesContractSize: Value = crate::precise::Precise::stringMul(&filled, &contractSize);
if is_equal(&inverse, &Value::Bool(true)) {
average = crate::precise::Precise::stringDiv(&filledTimesContractSize, &cost);
} else {
average = crate::precise::Precise::stringDiv(&cost, &filledTimesContractSize);
}
}
}
// similarly
// inverse
// cost = filled * contract size / price
//
// linear
// cost = filled * contract size * price
let mut costPriceExists: bool = is_true(&(!is_equal(&average, &Value::Null))) || is_true(&(!is_equal(&price, &Value::Null)));
if is_true(&parseCost) && is_true(&(!is_equal(&filled, &Value::Null))) && is_true(&costPriceExists) {
let mut multiplyPrice: Value = Value::Null;
if is_equal(&average, &Value::Null) {
multiplyPrice = price.clone();
} else {
multiplyPrice = average.clone();
}
// contract trading
let mut filledTimesContractSize: Value = crate::precise::Precise::stringMul(&filled, &contractSize);
if is_equal(&inverse, &Value::Bool(true)) {
cost = crate::precise::Precise::stringDiv(&filledTimesContractSize, &multiplyPrice);
} else {
cost = crate::precise::Precise::stringMul(&filledTimesContractSize, &multiplyPrice);
}
}
// support for market orders
let mut orderType: Value = self.safe_value_k(order.clone(), "type", &[]);
let mut emptyPrice: bool = is_true(&(is_equal(&price, &Value::Null))) || is_true(&crate::precise::Precise::stringEquals(&price, &Value::Str("0".to_string())));
if is_true(&emptyPrice) && is_true(&(is_equal(&orderType, &Value::Str("market".to_string())))) {
price = average.clone();
}
{
let mut i: Value = Value::Int(0);
let mut __for_first_95: bool = true;
while { if !__for_first_95 { i = add(&i, &Value::Int(1)); } __for_first_95 = false; is_less_than(&i, &get_array_length(&trades)) } {
let mut entry: Value = get_value(&trades, &i);
let mut entry: Value = get_value(&trades, &i);
{ let __be_tmp = self.safe_number_k(entry.clone(), "amount", &[]); add_element_to_object(&mut entry, &Value::Str("amount".to_string()), __be_tmp); };
{ let __be_tmp = self.safe_number_k(entry.clone(), "price", &[]); add_element_to_object(&mut entry, &Value::Str("price".to_string()), __be_tmp); };
{ let __be_tmp = self.safe_number_k(entry.clone(), "cost", &[]); add_element_to_object(&mut entry, &Value::Str("cost".to_string()), __be_tmp); };
let mut tradeFee: Value = self.safe_dict_k(entry.clone(), "fee", &[Value::Map({
let mut m = indexmap::IndexMap::new();
m
})]);
{ let __be_tmp = self.safe_number_k(tradeFee.clone(), "cost", &[]); add_element_to_object(&mut tradeFee, &Value::Str("cost".to_string()), __be_tmp); };
if is_true(&Value::Bool(in_op(&tradeFee, &Value::Str("rate".to_string())))) {
{ let __be_tmp = self.safe_number_k(tradeFee.clone(), "rate", &[]); add_element_to_object(&mut tradeFee, &Value::Str("rate".to_string()), __be_tmp); };
}
let mut entryFees: Value = self.safe_list_k(entry.clone(), "fees", &[Value::List(vec![])]);
{
let mut j: Value = Value::Int(0);
let mut __for_first_94: bool = true;
while { if !__for_first_94 { j = add(&j, &Value::Int(1)); } __for_first_94 = false; is_less_than(&j, &get_array_length(&entryFees)) } {
{ let __be_tmp = self.safe_number_k(get_value(&entryFees, &j), "cost", &[]); add_element_to_object(get_value_mut(&mut entryFees, &j), &Value::Str("cost".to_string()), __be_tmp); };
}
}
add_element_to_object(&mut entry, &Value::Str("fees".to_string()), entryFees.clone());
add_element_to_object(&mut entry, &Value::Str("fee".to_string()), tradeFee.clone());
}
}
let mut timeInForce: Value = self.safe_string_k(order.clone(), "timeInForce", &[]);
let mut postOnly: Value = self.safe_value_k(order.clone(), "postOnly", &[]);
// timeInForceHandling
if is_equal(&timeInForce, &Value::Null) {
if !is_true(&isTriggerOrSLTpOrder) && is_true(&(is_equal(&self.safe_string_k(order.clone(), "type", &[]), &Value::Str("market".to_string())))) {
timeInForce = Value::Str("IOC".to_string());
}
// allow postOnly override
if is_equal(&postOnly, &Value::Bool(true)) {
timeInForce = Value::Str("PO".to_string());
}
} else if is_equal(&postOnly, &Value::Null) {
// timeInForce is not undefined here
postOnly = Value::Bool(is_equal(&timeInForce, &Value::Str("PO".to_string())));
}
let mut timestamp: Value = self.safe_integer_k(order.clone(), "timestamp", &[]);
let mut lastUpdateTimestamp: Value = self.safe_integer_k(order.clone(), "lastUpdateTimestamp", &[]);
let mut datetime: Value = self.safe_string_k(order.clone(), "datetime", &[]);
if is_equal(&datetime, &Value::Null) {
datetime = self.iso8601(timestamp.clone());
}
let mut triggerPrice: Value = self.parse_number(self.safe_string2(order.clone(), Value::Str("triggerPrice".to_string()), Value::Str("stopPrice".to_string()), &[]), &[]);
let mut takeProfitPrice: Value = self.parse_number(self.safe_string_k(order.clone(), "takeProfitPrice", &[]), &[]);
let mut stopLossPrice: Value = self.parse_number(self.safe_string_k(order.clone(), "stopLossPrice", &[]), &[]);
return self.extend(order.clone(), &[Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("id".to_string(), self.safe_string_k(order.clone(), "id", &[]));
m.insert("clientOrderId".to_string(), self.safe_string_k(order.clone(), "clientOrderId", &[]));
m.insert("timestamp".to_string(), timestamp.clone());
m.insert("datetime".to_string(), datetime.clone());
m.insert("symbol".to_string(), symbol.clone());
m.insert("type".to_string(), self.safe_string_k(order.clone(), "type", &[]));
m.insert("side".to_string(), side.clone());
m.insert("lastTradeTimestamp".to_string(), lastTradeTimeTimestamp.clone());
m.insert("lastUpdateTimestamp".to_string(), lastUpdateTimestamp.clone());
m.insert("price".to_string(), self.parse_number(price.clone(), &[]));
m.insert("amount".to_string(), self.parse_number(amount.clone(), &[]));
m.insert("cost".to_string(), self.parse_number(cost.clone(), &[]));
m.insert("average".to_string(), self.parse_number(average.clone(), &[]));
m.insert("filled".to_string(), self.parse_number(filled.clone(), &[]));
m.insert("remaining".to_string(), self.parse_number(remaining.clone(), &[]));
m.insert("timeInForce".to_string(), timeInForce.clone());
m.insert("postOnly".to_string(), postOnly.clone());
m.insert("trades".to_string(), trades.clone());
m.insert("reduceOnly".to_string(), self.safe_value_k(order.clone(), "reduceOnly", &[]));
m.insert("stopPrice".to_string(), triggerPrice.clone());
m.insert("triggerPrice".to_string(), triggerPrice.clone());
m.insert("takeProfitPrice".to_string(), takeProfitPrice.clone());
m.insert("stopLossPrice".to_string(), stopLossPrice.clone());
m.insert("status".to_string(), status.clone());
m.insert("fee".to_string(), self.safe_value_k(order.clone(), "fee", &[]));
m
})]);
Value::Null
}
fn parse_orders(&self, mut orders: 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 params = get_arg(optional_args, 3, Value::Map({
let mut m = indexmap::IndexMap::new();
m
}));
//
// the value of orders is either a dict or a list
//
// dict
//
// {
// 'id1': { ... },
// 'id2': { ... },
// 'id3': { ... },
// ...
// }
//
// list
//
// [
// { 'id': 'id1', ... },
// { 'id': 'id2', ... },
// { 'id': 'id3', ... },
// ...
// ]
//
if is_equal(&orders, &Value::Null) {
return Value::List(vec![]);
}
let mut results: Value = Value::List(vec![]);
if is_true(&Value::Bool(is_array(&orders))) {
{
let mut i: Value = Value::Int(0);
let mut __for_first_96: bool = true;
while { if !__for_first_96 { i = add(&i, &Value::Int(1)); } __for_first_96 = false; is_less_than(&i, &get_array_length(&orders)) } {
let mut parsed: Value = <Self as crate::exchange_generated::ExchangeBase>::parse_order(self, get_value(&orders, &i), &[market.clone()]); // don't inline this call
let mut order: Value = self.extend(parsed.clone(), &[params.clone()]);
append_to_array(&mut results, order.clone());
}
}
} else {
let mut ids: Value = object_keys(&orders);
{
let mut i: Value = Value::Int(0);
let mut __for_first_97: bool = true;
while { if !__for_first_97 { i = add(&i, &Value::Int(1)); } __for_first_97 = false; is_less_than(&i, &get_array_length(&ids)) } {
let mut id: Value = get_value(&ids, &i);
let mut id: Value = get_value(&ids, &i);
let mut idExtended: Value = self.extend(Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("id".to_string(), id.clone());
m
}), &[get_value(&orders, &id)]);
let mut parsedOrder: Value = <Self as crate::exchange_generated::ExchangeBase>::parse_order(self, idExtended.clone(), &[market.clone()]); // don't inline these calls
let mut order: Value = self.extend(parsedOrder.clone(), &[params.clone()]);
append_to_array(&mut results, order.clone());
}
}
}
results = self.sort_by(results.clone(), Value::Str("timestamp".to_string()), &[]);
let mut symbol: Value = self.safe_string_k(market.clone(), "symbol", &[]);
return self.filter_by_symbol_since_limit(results.clone(), &[symbol.clone(), since.clone(), limit.clone()]);
Value::Null
}
fn calculate_fee_with_rate(&self, mut symbol: Value, mut type_var: Value, mut side: Value, mut amount: Value, mut price: Value, optional_args: &[Value]) -> Value {
let mut takerOrMaker = get_arg(optional_args, 0, Value::Str("taker".to_string()));
let mut feeRate = get_arg(optional_args, 1, Value::Null);
let mut params = get_arg(optional_args, 2, Value::Map({
let mut m = indexmap::IndexMap::new();
m
}));
if is_equal(&type_var, &Value::Str("market".to_string())) && is_equal(&takerOrMaker, &Value::Str("maker".to_string())) {
panic!("{}", crate::exchange_errors::arguments_required(add(&self.id, &Value::Str(" calculateFee() - you have provided incompatible arguments - \"market\" type order can not be \"maker\". Change either the \"type\" or the \"takerOrMaker\" argument to calculate the fee.".to_string()))));
}
let mut markets: Value = self.markets.clone();
if is_equal(&markets, &Value::Null) {
panic!("{}", crate::exchange_errors::exchange_error(add(&self.id, &Value::Str(" markets not loaded".to_string()))));
}
let mut market: Value = get_value(&markets, &symbol);
let mut market: Value = get_value(&markets, &symbol);
let mut feeSide: Value = self.safe_string_k(market.clone(), "feeSide", &[Value::Str("quote".to_string())]);
let mut useQuote: Value = Value::Null;
if is_equal(&feeSide, &Value::Str("get".to_string())) {
// the fee is always in the currency you get
useQuote = Value::Bool(is_equal(&side, &Value::Str("sell".to_string())));
} else if is_equal(&feeSide, &Value::Str("give".to_string())) {
// the fee is always in the currency you give
useQuote = Value::Bool(is_equal(&side, &Value::Str("buy".to_string())));
} else {
// the fee is always in feeSide currency
useQuote = Value::Bool(is_equal(&feeSide, &Value::Str("quote".to_string())));
}
let mut cost: Value = self.number_to_string(amount.clone());
let mut key: Value = Value::Null;
if is_true(&useQuote) {
let mut priceString: Value = self.number_to_string(price.clone());
cost = crate::precise::Precise::stringMul(&cost, &priceString);
key = Value::Str("quote".to_string());
} else {
key = Value::Str("base".to_string());
}
// for derivatives, the fee is in 'settle' currency
if !is_equal(&get_value(&market, &Value::Str("spot".to_string())), &Value::Bool(true)) {
key = Value::Str("settle".to_string());
}
// even if `takerOrMaker` argument was set to 'maker', for 'market' orders we should forcefully override it to 'taker'
if is_equal(&type_var, &Value::Str("market".to_string())) {
takerOrMaker = Value::Str("taker".to_string());
}
let mut rate: Value = ternary(is_true(&(!is_equal(&feeRate, &Value::Null))), self.number_to_string(feeRate.clone()), self.safe_string(market.clone(), takerOrMaker.clone(), &[]));
cost = crate::precise::Precise::stringMul(&cost, &rate);
return Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("type".to_string(), takerOrMaker.clone());
m.insert("currency".to_string(), get_value(&market, &key));
m.insert("rate".to_string(), self.parse_number(rate.clone(), &[]));
m.insert("cost".to_string(), self.parse_number(cost.clone(), &[]));
m
});
Value::Null
}
fn calculate_fee(&self, mut symbol: Value, mut type_var: Value, mut side: Value, mut amount: Value, mut price: Value, optional_args: &[Value]) -> Value {
let mut takerOrMaker = get_arg(optional_args, 0, Value::Str("taker".to_string()));
let mut params = get_arg(optional_args, 1, Value::Map({
let mut m = indexmap::IndexMap::new();
m
}));
return self.calculate_fee_with_rate(symbol.clone(), type_var.clone(), side.clone(), amount.clone(), price.clone(), &[takerOrMaker.clone(), Value::Null, params.clone()]);
Value::Null
}
fn safe_liquidation(&self, mut liquidation: Value, optional_args: &[Value]) -> Value {
let mut market = get_arg(optional_args, 0, Value::Null);
let mut contracts: Value = self.safe_string_k(liquidation.clone(), "contracts", &[]);
let mut contractSize: Value = self.safe_string_k(market.clone(), "contractSize", &[]);
let mut price: Value = self.safe_string_k(liquidation.clone(), "price", &[]);
let mut baseValue: Value = self.safe_string_k(liquidation.clone(), "baseValue", &[]);
let mut quoteValue: Value = self.safe_string_k(liquidation.clone(), "quoteValue", &[]);
if is_true(&(is_equal(&baseValue, &Value::Null))) && is_true(&(!is_equal(&contracts, &Value::Null))) && is_true(&(!is_equal(&contractSize, &Value::Null))) && is_true(&(!is_equal(&price, &Value::Null))) {
baseValue = crate::precise::Precise::stringMul(&contracts, &contractSize);
}
if is_true(&(is_equal("eValue, &Value::Null))) && is_true(&(!is_equal(&baseValue, &Value::Null))) && is_true(&(!is_equal(&price, &Value::Null))) {
quoteValue = crate::precise::Precise::stringMul(&baseValue, &price);
}
add_element_to_object(&mut liquidation, &Value::Str("contracts".to_string()), self.parse_number(contracts.clone(), &[]));
add_element_to_object(&mut liquidation, &Value::Str("contractSize".to_string()), self.parse_number(contractSize.clone(), &[]));
add_element_to_object(&mut liquidation, &Value::Str("price".to_string()), self.parse_number(price.clone(), &[]));
add_element_to_object(&mut liquidation, &Value::Str("baseValue".to_string()), self.parse_number(baseValue.clone(), &[]));
add_element_to_object(&mut liquidation, &Value::Str("quoteValue".to_string()), self.parse_number(quoteValue.clone(), &[]));
return liquidation;
Value::Null
}
fn safe_trade(&self, mut trade: Value, optional_args: &[Value]) -> Value {
let mut market = get_arg(optional_args, 0, Value::Null);
let mut amount: Value = self.safe_string_k(trade.clone(), "amount", &[]);
let mut price: Value = self.safe_string_k(trade.clone(), "price", &[]);
let mut cost: Value = self.safe_string_k(trade.clone(), "cost", &[]);
if is_equal(&cost, &Value::Null) {
// contract trading
let mut contractSize: Value = self.safe_string_k(market.clone(), "contractSize", &[]);
let mut multiplyPrice: Value = price.clone();
if !is_equal(&contractSize, &Value::Null) {
let mut inverse: Value = self.safe_bool_k(market.clone(), "inverse", &[Value::Bool(false)]);
if is_equal(&inverse, &Value::Bool(true)) {
multiplyPrice = crate::precise::Precise::stringDiv(&Value::Str("1".to_string()), &price);
}
multiplyPrice = crate::precise::Precise::stringMul(&multiplyPrice, &contractSize);
}
cost = crate::precise::Precise::stringMul(&multiplyPrice, &amount);
}
let mut resultFeeresultFeesVariable = self.parsed_fee_and_fees(trade.clone());
let mut resultFee: Value = get_value(&resultFeeresultFeesVariable, &Value::Int(0));
let mut resultFees: Value = get_value(&resultFeeresultFeesVariable, &Value::Int(1));
add_element_to_object(&mut trade, &Value::Str("fee".to_string()), resultFee.clone());
add_element_to_object(&mut trade, &Value::Str("fees".to_string()), resultFees.clone());
add_element_to_object(&mut trade, &Value::Str("amount".to_string()), self.parse_number(amount.clone(), &[]));
add_element_to_object(&mut trade, &Value::Str("price".to_string()), self.parse_number(price.clone(), &[]));
add_element_to_object(&mut trade, &Value::Str("cost".to_string()), self.parse_number(cost.clone(), &[]));
return trade;
Value::Null
}
fn create_ccxt_trade_id(&self, optional_args: &[Value]) -> Value {
let mut timestamp = get_arg(optional_args, 0, Value::Null);
let mut side = get_arg(optional_args, 1, Value::Null);
let mut amount = get_arg(optional_args, 2, Value::Null);
let mut price = get_arg(optional_args, 3, Value::Null);
let mut takerOrMaker = get_arg(optional_args, 4, Value::Null);
// this approach is being used by multiple exchanges (mexc, woo, coinsbit, dydx, ...)
let mut id: Value = Value::Null;
if !is_equal(×tamp, &Value::Null) {
id = self.number_to_string(timestamp.clone());
if !is_equal(&side, &Value::Null) {
id = add(&id, &add(&Value::Str("-".to_string()), &side));
}
if !is_equal(&amount, &Value::Null) {
id = add(&id, &add(&Value::Str("-".to_string()), &self.number_to_string(amount.clone())));
}
if !is_equal(&price, &Value::Null) {
id = add(&id, &add(&Value::Str("-".to_string()), &self.number_to_string(price.clone())));
}
if !is_equal(&takerOrMaker, &Value::Null) {
id = add(&id, &add(&Value::Str("-".to_string()), &takerOrMaker));
}
}
return id;
Value::Null
}
fn parsed_fee_and_fees(&self, mut container: Value) -> Value {
let mut fee: Value = self.safe_dict_k(container.clone(), "fee", &[]);
let mut fees: Value = self.safe_list_k(container.clone(), "fees", &[]);
let mut feeDefined: bool = !is_equal(&fee, &Value::Null);
let mut feesDefined: bool = !is_equal(&fees, &Value::Null);
// parsing only if at least one of them is defined
let mut shouldParseFees: bool = is_true(&feeDefined) || is_true(&feesDefined);
if is_true(&shouldParseFees) {
if is_true(&feeDefined) {
fee = self.parse_fee_numeric(fee.clone());
}
if !is_true(&feesDefined) {
// just set it directly, no further processing needed.
fees = Value::List(vec![fee.clone()]);
}
// 'fees' were set, so reparse them
let mut reducedFees: Value = fees.clone();
if is_true(&self.reduceFees) {
reducedFees = self.reduce_fees_by_currency(fees.clone());
}
if is_equal(&reducedFees, &Value::Null) {
reducedFees = Value::List(vec![]);
}
let mut reducedLength: Value = get_array_length(&reducedFees);
{
let mut i: Value = Value::Int(0);
let mut __for_first_98: bool = true;
while { if !__for_first_98 { i = add(&i, &Value::Int(1)); } __for_first_98 = false; is_less_than(&i, &reducedLength) } {
{ let __be_tmp = self.parse_fee_numeric(get_value(&reducedFees, &i)); add_element_to_object(&mut reducedFees, &i, __be_tmp); };
}
}
fees = reducedFees.clone();
if is_equal(&reducedLength, &Value::Int(1)) {
fee = get_value(&reducedFees, &Value::Int(0));
} else if is_equal(&reducedLength, &Value::Int(0)) {
fee = Value::Null;
}
}
// in case `fee & fees` are undefined, set `fees` as empty array
if is_equal(&fee, &Value::Null) {
fee = Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Null);
m.insert("currency".to_string(), Value::Null);
m
});
}
if is_equal(&fees, &Value::Null) {
fees = Value::List(vec![]);
}
return Value::List(vec![fee.clone(), fees.clone()]);
Value::Null
}
fn parse_fee_numeric(&self, mut fee: Value) -> Value {
{ let __be_tmp = self.safe_number_k(fee.clone(), "cost", &[]); add_element_to_object(&mut fee, &Value::Str("cost".to_string()), __be_tmp); }; // ensure numeric
if is_true(&Value::Bool(in_op(&fee, &Value::Str("rate".to_string())))) {
{ let __be_tmp = self.safe_number_k(fee.clone(), "rate", &[]); add_element_to_object(&mut fee, &Value::Str("rate".to_string()), __be_tmp); };
}
return fee;
Value::Null
}
fn find_nearest_ceiling(&self, mut arr: Value, mut providedValue: Value) -> Value {
// i.e. findNearestCeiling ([ 10, 30, 50], 23) returns 30
let mut length: Value = get_array_length(&arr);
{
let mut i: Value = Value::Int(0);
let mut __for_first_99: bool = true;
while { if !__for_first_99 { i = add(&i, &Value::Int(1)); } __for_first_99 = false; is_less_than(&i, &length) } {
let mut current: Value = get_value(&arr, &i);
let mut current: Value = get_value(&arr, &i);
if is_less_than_or_equal(&providedValue, ¤t) {
return current;
}
}
}
return get_value(&arr, &subtract(&length, &Value::Int(1)));
Value::Null
}
fn add_key_in_array_items(&self, mut obj: Value, mut keyName: Value) -> Value {
let mut result: Value = Value::List(vec![]);
let mut keys: Value = object_keys(&obj);
{
let mut i: Value = Value::Int(0);
let mut __for_first_100: bool = true;
while { if !__for_first_100 { i = add(&i, &Value::Int(1)); } __for_first_100 = false; is_less_than(&i, &get_array_length(&keys)) } {
let mut key: Value = get_value(&keys, &i);
let mut key: Value = get_value(&keys, &i);
let mut item: Value = get_value(&obj, &key);
let mut item: Value = get_value(&obj, &key);
if is_equal(&item, &Value::Null) {
continue;
}
let mut itemWithKey: Value = self.extend(Value::Map({
let mut m = indexmap::IndexMap::new();
m
}), &[item.clone()]);
add_element_to_object(&mut itemWithKey, &keyName, key.clone());
append_to_array(&mut result, itemWithKey.clone());
}
}
return result;
Value::Null
}
fn invert_flat_string_dictionary(&self, mut dict: Value) -> Value {
let mut reversed: Value = Value::Map({
let mut m = indexmap::IndexMap::new();
m
});
let mut keys: Value = object_keys(&dict);
{
let mut i: Value = Value::Int(0);
let mut __for_first_101: bool = true;
while { if !__for_first_101 { i = add(&i, &Value::Int(1)); } __for_first_101 = false; is_less_than(&i, &get_array_length(&keys)) } {
let mut key: Value = get_value(&keys, &i);
let mut key: Value = get_value(&keys, &i);
let mut value: Value = get_value(&dict, &key);
let mut value: Value = get_value(&dict, &key);
if is_string(&value) {
add_element_to_object(&mut reversed, &value, key.clone());
}
}
}
return reversed;
Value::Null
}
fn string_to_base16(&self, mut str_val: Value) -> Value {
return add(&Value::Str("0x".to_string()), &self.binary_to_base16(self.base64_to_binary(self.string_to_base64(str_val.clone(), &[]), &[]), &[]));
Value::Null
}
fn reduce_fees_by_currency(&self, mut fees: Value) -> Value {
//
// this function takes a list of fee structures having the following format
//
// string = true
//
// [
// { 'currency': 'BTC', 'cost': '0.1' },
// { 'currency': 'BTC', 'cost': '0.2' },
// { 'currency': 'BTC', 'cost': '0.2', 'rate': '0.00123' },
// { 'currency': 'BTC', 'cost': '0.4', 'rate': '0.00123' },
// { 'currency': 'BTC', 'cost': '0.5', 'rate': '0.00456' },
// { 'currency': 'USDT', 'cost': '12.3456' },
// ]
//
// string = false
//
// [
// { 'currency': 'BTC', 'cost': 0.1 },
// { 'currency': 'BTC', 'cost': 0.2 },
// { 'currency': 'BTC', 'cost': 0.2, 'rate': 0.00123 },
// { 'currency': 'BTC', 'cost': 0.4, 'rate': 0.00123 },
// { 'currency': 'BTC', 'cost': 0.5, 'rate': 0.00456 },
// { 'currency': 'USDT', 'cost': 12.3456 },
// ]
//
// and returns a reduced fee list, where fees are summed per currency and rate (if any)
//
// string = true
//
// [
// { 'currency': 'BTC', 'cost': '0.4' },
// { 'currency': 'BTC', 'cost': '0.6', 'rate': '0.00123' },
// { 'currency': 'BTC', 'cost': '0.5', 'rate': '0.00456' },
// { 'currency': 'USDT', 'cost': '12.3456' },
// ]
//
// string = false
//
// [
// { 'currency': 'BTC', 'cost': 0.3 },
// { 'currency': 'BTC', 'cost': 0.6, 'rate': 0.00123 },
// { 'currency': 'BTC', 'cost': 0.5, 'rate': 0.00456 },
// { 'currency': 'USDT', 'cost': 12.3456 },
// ]
//
let mut reduced: Value = Value::Map({
let mut m = indexmap::IndexMap::new();
m
});
{
let mut i: Value = Value::Int(0);
let mut __for_first_102: bool = true;
while { if !__for_first_102 { i = add(&i, &Value::Int(1)); } __for_first_102 = false; is_less_than(&i, &get_array_length(&fees)) } {
let mut fee: Value = get_value(&fees, &i);
let mut fee: Value = get_value(&fees, &i);
let mut code: Value = self.safe_string_k(fee.clone(), "currency", &[]);
let mut feeCurrencyCode: Value = ternary(is_true(&(!is_equal(&code, &Value::Null))), code.clone(), to_string_val(&i));
if !is_equal(&feeCurrencyCode, &Value::Null) {
let mut rate: Value = self.safe_string_k(fee.clone(), "rate", &[]);
let mut cost: Value = self.safe_string_k(fee.clone(), "cost", &[]);
if is_equal(&cost, &Value::Null) {
continue;
}
if !is_true(&(Value::Bool(in_op(&reduced, &feeCurrencyCode)))) {
add_element_to_object(&mut reduced, &feeCurrencyCode, Value::Map({
let mut m = indexmap::IndexMap::new();
m
}));
}
let mut rateKey: Value = ternary(is_true(&(is_equal(&rate, &Value::Null))), Value::Str("".to_string()), rate.clone());
if is_true(&Value::Bool(in_op(&get_value(&reduced, &feeCurrencyCode), &rateKey))) {
{ let __be_tmp = crate::precise::Precise::stringAdd(&get_value(&get_value(&get_value(&reduced, &feeCurrencyCode), &rateKey), &Value::Str("cost".to_string())), &cost); add_element_to_object(get_value_mut(get_value_mut(&mut reduced, &feeCurrencyCode), &rateKey), &Value::Str("cost".to_string()), __be_tmp); };
} else {
add_element_to_object(get_value_mut(&mut reduced, &feeCurrencyCode), &rateKey, Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("currency".to_string(), code.clone());
m.insert("cost".to_string(), cost.clone());
m
}));
if !is_equal(&rate, &Value::Null) {
add_element_to_object(get_value_mut(get_value_mut(&mut reduced, &feeCurrencyCode), &rateKey), &Value::Str("rate".to_string()), rate.clone());
}
}
}
}
}
let mut result: Value = Value::List(vec![]);
let mut feeValues: Value = object_values(&reduced);
{
let mut i: Value = Value::Int(0);
let mut __for_first_103: bool = true;
while { if !__for_first_103 { i = add(&i, &Value::Int(1)); } __for_first_103 = false; is_less_than(&i, &get_array_length(&feeValues)) } {
let mut reducedFeeValues: Value = object_values(&get_value(&feeValues, &i));
result = self.array_concat(result.clone(), reducedFeeValues.clone());
}
}
return result;
Value::Null
}
fn safe_ticker(&self, mut ticker: Value, optional_args: &[Value]) -> Value {
let mut market = get_arg(optional_args, 0, Value::Null);
let mut open: Value = self.omit_zero(self.safe_string_k(ticker.clone(), "open", &[]));
let mut close: Value = self.omit_zero(self.safe_string2(ticker.clone(), Value::Str("close".to_string()), Value::Str("last".to_string()), &[]));
let mut change: Value = self.safe_string_k(ticker.clone(), "change", &[]); // change can be a legitimate zero on a flat day, do not omitZero it, see https://github.com/ccxt/ccxt/issues/25971
let mut percentage: Value = self.omit_zero(self.safe_string_k(ticker.clone(), "percentage", &[]));
let mut average: Value = self.omit_zero(self.safe_string_k(ticker.clone(), "average", &[]));
let mut vwap: Value = self.safe_string_k(ticker.clone(), "vwap", &[]);
let mut baseVolume: Value = self.safe_string_k(ticker.clone(), "baseVolume", &[]);
let mut quoteVolume: Value = self.safe_string_k(ticker.clone(), "quoteVolume", &[]);
if is_equal(&vwap, &Value::Null) {
vwap = crate::precise::Precise::stringDiv(&self.omit_zero(quoteVolume.clone()), &baseVolume);
}
// calculate open
if !is_equal(&change, &Value::Null) {
if is_equal(&close, &Value::Null) && !is_equal(&average, &Value::Null) {
close = crate::precise::Precise::stringAdd(&average, &crate::precise::Precise::stringDiv(&change, &Value::Str("2".to_string())));
}
if is_equal(&open, &Value::Null) && !is_equal(&close, &Value::Null) {
open = crate::precise::Precise::stringSub(&close, &change);
}
} else if !is_equal(&percentage, &Value::Null) {
if is_equal(&close, &Value::Null) && !is_equal(&average, &Value::Null) {
let mut openAddClose: Value = crate::precise::Precise::stringMul(&average, &Value::Str("2".to_string()));
// openAddClose = open * (1 + (100 + percentage)/100)
let mut denominator: Value = crate::precise::Precise::stringAdd(&Value::Str("2".to_string()), &crate::precise::Precise::stringDiv(&percentage, &Value::Str("100".to_string())));
let mut calcOpen: Value = ternary(is_true(&(!is_equal(&open, &Value::Null))), open.clone(), crate::precise::Precise::stringDiv(&openAddClose, &denominator));
close = crate::precise::Precise::stringMul(&calcOpen, &crate::precise::Precise::stringAdd(&Value::Str("1".to_string()), &crate::precise::Precise::stringDiv(&percentage, &Value::Str("100".to_string()))));
}
if is_equal(&open, &Value::Null) && !is_equal(&close, &Value::Null) {
open = crate::precise::Precise::stringDiv(&close, &crate::precise::Precise::stringAdd(&Value::Str("1".to_string()), &crate::precise::Precise::stringDiv(&percentage, &Value::Str("100".to_string()))));
}
}
// change
if is_equal(&change, &Value::Null) {
if !is_equal(&close, &Value::Null) && !is_equal(&open, &Value::Null) {
change = crate::precise::Precise::stringSub(&close, &open);
} else if !is_equal(&close, &Value::Null) && !is_equal(&percentage, &Value::Null) {
change = crate::precise::Precise::stringMul(&crate::precise::Precise::stringDiv(&percentage, &Value::Str("100".to_string())), &crate::precise::Precise::stringDiv(&close, &Value::Str("100".to_string())));
} else if !is_equal(&open, &Value::Null) && !is_equal(&percentage, &Value::Null) {
change = crate::precise::Precise::stringMul(&open, &crate::precise::Precise::stringDiv(&percentage, &Value::Str("100".to_string())));
}
}
// calculate things according to "open" (similar can be done with "close")
if !is_equal(&open, &Value::Null) {
// percentage (using change)
if is_equal(&percentage, &Value::Null) && !is_equal(&change, &Value::Null) {
percentage = crate::precise::Precise::stringMul(&crate::precise::Precise::stringDiv(&change, &open), &Value::Str("100".to_string()));
}
// close (using change)
if is_equal(&close, &Value::Null) && !is_equal(&change, &Value::Null) {
close = crate::precise::Precise::stringAdd(&open, &change);
}
// close (using average)
if is_equal(&close, &Value::Null) && !is_equal(&average, &Value::Null) {
close = crate::precise::Precise::stringMul(&average, &Value::Str("2".to_string()));
}
// average
if is_equal(&average, &Value::Null) && !is_equal(&close, &Value::Null) {
let mut precision: Value = Value::Int(18);
if !is_equal(&market, &Value::Null) && is_true(&self.is_tick_precision()) {
let mut marketPrecision: Value = self.safe_dict_k(market.clone(), "precision", &[]);
let mut precisionPrice: Value = self.safe_string_k(marketPrecision.clone(), "price", &[]);
if !is_equal(&precisionPrice, &Value::Null) {
precision = self.precision_from_string(precisionPrice.clone());
}
}
average = crate::precise::Precise::stringDivPrec(&crate::precise::Precise::stringAdd(&open, &close), &Value::Str("2".to_string()), &precision);
}
}
// timestamp and symbol operations don't belong in safeTicker
// they should be done in the derived classes
let mut closeParsed: Value = self.parse_number(self.omit_zero(close.clone()), &[]);
return self.extend(ticker.clone(), &[Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("bid".to_string(), self.parse_number(self.omit_zero(self.safe_string_k(ticker.clone(), "bid", &[])), &[]));
m.insert("bidVolume".to_string(), self.safe_number_k(ticker.clone(), "bidVolume", &[]));
m.insert("ask".to_string(), self.parse_number(self.omit_zero(self.safe_string_k(ticker.clone(), "ask", &[])), &[]));
m.insert("askVolume".to_string(), self.safe_number_k(ticker.clone(), "askVolume", &[]));
m.insert("high".to_string(), self.parse_number(self.omit_zero(self.safe_string_k(ticker.clone(), "high", &[])), &[]));
m.insert("low".to_string(), self.parse_number(self.omit_zero(self.safe_string_k(ticker.clone(), "low", &[])), &[]));
m.insert("open".to_string(), self.parse_number(self.omit_zero(open.clone()), &[]));
m.insert("close".to_string(), closeParsed.clone());
m.insert("last".to_string(), closeParsed.clone());
m.insert("change".to_string(), self.parse_number(change.clone(), &[]));
m.insert("percentage".to_string(), self.parse_number(percentage.clone(), &[]));
m.insert("average".to_string(), self.parse_number(average.clone(), &[]));
m.insert("vwap".to_string(), self.parse_number(vwap.clone(), &[]));
m.insert("baseVolume".to_string(), self.parse_number(baseVolume.clone(), &[]));
m.insert("quoteVolume".to_string(), self.parse_number(quoteVolume.clone(), &[]));
m.insert("previousClose".to_string(), self.safe_number_k(ticker.clone(), "previousClose", &[]));
m.insert("indexPrice".to_string(), self.safe_number_k(ticker.clone(), "indexPrice", &[]));
m.insert("markPrice".to_string(), self.safe_number_k(ticker.clone(), "markPrice", &[]));
m
})]);
Value::Null
}
fn fetch_borrow_rate(&mut self, mut code: Value, mut amount: Value, optional_args: &[Value]) -> impl ::std::future::Future<Output = Value> + Send { async move {
let mut params = get_arg(optional_args, 0, Value::Map({
let mut m = indexmap::IndexMap::new();
m
}));
panic!("{}", crate::exchange_errors::not_supported(add(&self.id, &Value::Str(" fetchBorrowRate is deprecated, please use fetchCrossBorrowRate or fetchIsolatedBorrowRate instead".to_string()))));
Value::Null
} }
fn repay_cross_margin(&mut self, mut code: Value, mut amount: Value, optional_args: &[Value]) -> impl ::std::future::Future<Output = Value> + Send { async move {
// async-virtual: try the derived exchange first
if let Some(__v) = self.dispatch_to_derived("repay_cross_margin", { let mut __args: Vec<crate::Value> = Vec::new(); __args.push(code.clone()); __args.push(amount.clone()); __args.extend_from_slice(optional_args); __args }).await {
if !matches!(__v, crate::Value::Null) { return __v; }
}
let mut params = get_arg(optional_args, 0, Value::Map({
let mut m = indexmap::IndexMap::new();
m
}));
panic!("{}", crate::exchange_errors::not_supported(add(&self.id, &Value::Str(" repayCrossMargin is not support yet".to_string()))));
Value::Null
} }
fn repay_isolated_margin(&mut self, mut symbol: Value, mut code: Value, mut amount: Value, optional_args: &[Value]) -> impl ::std::future::Future<Output = Value> + Send { async move {
// async-virtual: try the derived exchange first
if let Some(__v) = self.dispatch_to_derived("repay_isolated_margin", { let mut __args: Vec<crate::Value> = Vec::new(); __args.push(symbol.clone()); __args.push(code.clone()); __args.push(amount.clone()); __args.extend_from_slice(optional_args); __args }).await {
if !matches!(__v, crate::Value::Null) { return __v; }
}
let mut params = get_arg(optional_args, 0, Value::Map({
let mut m = indexmap::IndexMap::new();
m
}));
panic!("{}", crate::exchange_errors::not_supported(add(&self.id, &Value::Str(" repayIsolatedMargin is not support yet".to_string()))));
Value::Null
} }
fn borrow_cross_margin(&mut self, mut code: Value, mut amount: Value, optional_args: &[Value]) -> impl ::std::future::Future<Output = Value> + Send { async move {
// async-virtual: try the derived exchange first
if let Some(__v) = self.dispatch_to_derived("borrow_cross_margin", { let mut __args: Vec<crate::Value> = Vec::new(); __args.push(code.clone()); __args.push(amount.clone()); __args.extend_from_slice(optional_args); __args }).await {
if !matches!(__v, crate::Value::Null) { return __v; }
}
let mut params = get_arg(optional_args, 0, Value::Map({
let mut m = indexmap::IndexMap::new();
m
}));
panic!("{}", crate::exchange_errors::not_supported(add(&self.id, &Value::Str(" borrowCrossMargin is not support yet".to_string()))));
Value::Null
} }
fn borrow_isolated_margin(&mut self, mut symbol: Value, mut code: Value, mut amount: Value, optional_args: &[Value]) -> impl ::std::future::Future<Output = Value> + Send { async move {
// async-virtual: try the derived exchange first
if let Some(__v) = self.dispatch_to_derived("borrow_isolated_margin", { let mut __args: Vec<crate::Value> = Vec::new(); __args.push(symbol.clone()); __args.push(code.clone()); __args.push(amount.clone()); __args.extend_from_slice(optional_args); __args }).await {
if !matches!(__v, crate::Value::Null) { return __v; }
}
let mut params = get_arg(optional_args, 0, Value::Map({
let mut m = indexmap::IndexMap::new();
m
}));
panic!("{}", crate::exchange_errors::not_supported(add(&self.id, &Value::Str(" borrowIsolatedMargin is not support yet".to_string()))));
Value::Null
} }
fn borrow_margin(&mut self, mut code: Value, mut amount: Value, optional_args: &[Value]) -> impl ::std::future::Future<Output = Value> + Send { async move {
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
}));
panic!("{}", crate::exchange_errors::not_supported(add(&self.id, &Value::Str(" borrowMargin is deprecated, please use borrowCrossMargin or borrowIsolatedMargin instead".to_string()))));
Value::Null
} }
fn repay_margin(&mut self, mut code: Value, mut amount: Value, optional_args: &[Value]) -> impl ::std::future::Future<Output = Value> + Send { async move {
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
}));
panic!("{}", crate::exchange_errors::not_supported(add(&self.id, &Value::Str(" repayMargin is deprecated, please use repayCrossMargin or repayIsolatedMargin instead".to_string()))));
Value::Null
} }
fn fetch_ohlcv(&mut self, mut symbol: Value, optional_args: &[Value]) -> impl ::std::future::Future<Output = Value> + Send { async move {
// async-virtual: try the derived exchange first
if let Some(__v) = self.dispatch_to_derived("fetch_ohlcv", { let mut __args: Vec<crate::Value> = Vec::new(); __args.push(symbol.clone()); __args.extend_from_slice(optional_args); __args }).await {
if !matches!(__v, crate::Value::Null) { return __v; }
}
let mut timeframe = get_arg(optional_args, 0, Value::Str("1m".to_string()));
let mut since = get_arg(optional_args, 1, Value::Null);
let mut limit = get_arg(optional_args, 2, Value::Null);
let mut params = get_arg(optional_args, 3, Value::Map({
let mut m = indexmap::IndexMap::new();
m
}));
let mut message: Value = Value::Str("".to_string());
if !is_equal(&get_value(&self.has, &Value::Str("fetchTrades".to_string())), &Value::Null) && !is_equal(&get_value(&self.has, &Value::Str("fetchTrades".to_string())), &Value::Bool(false)) {
message = Value::Str(". If you want to build OHLCV candles from trade executions data, visit https://github.com/ccxt/ccxt/tree/master/examples/ and see \"build-ohlcv-bars\" file".to_string());
}
panic!("{}", crate::exchange_errors::not_supported(add(&add(&self.id, &Value::Str(" fetchOHLCV() is not supported yet".to_string())), &message)));
Value::Null
} }
fn fetch_spot_ohlcv(&mut self, mut symbol: Value, optional_args: &[Value]) -> impl ::std::future::Future<Output = Value> + Send { async move {
let mut timeframe = get_arg(optional_args, 0, Value::Str("1m".to_string()));
let mut since = get_arg(optional_args, 1, Value::Null);
let mut limit = get_arg(optional_args, 2, Value::Null);
let mut params = get_arg(optional_args, 3, Value::Map({
let mut m = indexmap::IndexMap::new();
m
}));
panic!("{}", crate::exchange_errors::not_supported(add(&self.id, &Value::Str(" fetchSpotOHLCV() is not supported yet".to_string()))));
Value::Null
} }
fn fetch_contract_ohlcv(&mut self, mut symbol: Value, optional_args: &[Value]) -> impl ::std::future::Future<Output = Value> + Send { async move {
let mut timeframe = get_arg(optional_args, 0, Value::Str("1m".to_string()));
let mut since = get_arg(optional_args, 1, Value::Null);
let mut limit = get_arg(optional_args, 2, Value::Null);
let mut params = get_arg(optional_args, 3, Value::Map({
let mut m = indexmap::IndexMap::new();
m
}));
panic!("{}", crate::exchange_errors::not_supported(add(&self.id, &Value::Str(" fetchContractOHLCV() is not supported yet".to_string()))));
Value::Null
} }
fn fetch_ohlcv_ws(&mut self, mut symbol: Value, optional_args: &[Value]) -> impl ::std::future::Future<Output = Value> + Send { async move {
let mut timeframe = get_arg(optional_args, 0, Value::Str("1m".to_string()));
let mut since = get_arg(optional_args, 1, Value::Null);
let mut limit = get_arg(optional_args, 2, Value::Null);
let mut params = get_arg(optional_args, 3, Value::Map({
let mut m = indexmap::IndexMap::new();
m
}));
let mut message: Value = Value::Str("".to_string());
if !is_equal(&get_value(&self.has, &Value::Str("fetchTradesWs".to_string())), &Value::Null) && !is_equal(&get_value(&self.has, &Value::Str("fetchTradesWs".to_string())), &Value::Bool(false)) {
message = Value::Str(". If you want to build OHLCV candles from trade executions data, visit https://github.com/ccxt/ccxt/tree/master/examples/ and see \"build-ohlcv-bars\" file".to_string());
}
panic!("{}", crate::exchange_errors::not_supported(add(&add(&self.id, &Value::Str(" fetchOHLCVWs() is not supported yet. Try using fetchOHLCV instead.".to_string())), &message)));
Value::Null
} }
fn watch_ohlcv(&mut self, mut symbol: Value, optional_args: &[Value]) -> impl ::std::future::Future<Output = Value> + Send { async move {
let mut timeframe = get_arg(optional_args, 0, Value::Str("1m".to_string()));
let mut since = get_arg(optional_args, 1, Value::Null);
let mut limit = get_arg(optional_args, 2, Value::Null);
let mut params = get_arg(optional_args, 3, Value::Map({
let mut m = indexmap::IndexMap::new();
m
}));
panic!("{}", crate::exchange_errors::not_supported(add(&self.id, &Value::Str(" watchOHLCV() is not supported yet".to_string()))));
Value::Null
} }
fn convert_trading_view_to_ohlcv(&self, mut ohlcvs: Value, optional_args: &[Value]) -> Value {
let mut timestamp = get_arg(optional_args, 0, Value::Str("t".to_string()));
let mut open = get_arg(optional_args, 1, Value::Str("o".to_string()));
let mut high = get_arg(optional_args, 2, Value::Str("h".to_string()));
let mut low = get_arg(optional_args, 3, Value::Str("l".to_string()));
let mut close = get_arg(optional_args, 4, Value::Str("c".to_string()));
let mut volume = get_arg(optional_args, 5, Value::Str("v".to_string()));
let mut ms = get_arg(optional_args, 6, Value::Bool(false));
let mut result: Value = Value::List(vec![]);
let mut timestamps: Value = self.safe_list(ohlcvs.clone(), timestamp.clone(), &[Value::List(vec![])]);
let mut opens: Value = self.safe_list(ohlcvs.clone(), open.clone(), &[Value::List(vec![])]);
let mut highs: Value = self.safe_list(ohlcvs.clone(), high.clone(), &[Value::List(vec![])]);
let mut lows: Value = self.safe_list(ohlcvs.clone(), low.clone(), &[Value::List(vec![])]);
let mut closes: Value = self.safe_list(ohlcvs.clone(), close.clone(), &[Value::List(vec![])]);
let mut volumes: Value = self.safe_list(ohlcvs.clone(), volume.clone(), &[Value::List(vec![])]);
{
let mut i: Value = Value::Int(0);
let mut __for_first_104: bool = true;
while { if !__for_first_104 { i = add(&i, &Value::Int(1)); } __for_first_104 = false; is_less_than(&i, &get_array_length(×tamps)) } {
append_to_array(&mut result, Value::List(vec![ternary(is_true(&ms), self.safe_integer(timestamps.clone(), i.clone(), &[]), self.safe_timestamp(timestamps.clone(), i.clone(), &[])), self.safe_value(opens.clone(), i.clone(), &[]), self.safe_value(highs.clone(), i.clone(), &[]), self.safe_value(lows.clone(), i.clone(), &[]), self.safe_value(closes.clone(), i.clone(), &[]), self.safe_value(volumes.clone(), i.clone(), &[])]));
}
}
return result;
Value::Null
}
fn convert_ohlcv_to_trading_view(&self, mut ohlcvs: Value, optional_args: &[Value]) -> Value {
let mut timestamp = get_arg(optional_args, 0, Value::Str("t".to_string()));
let mut open = get_arg(optional_args, 1, Value::Str("o".to_string()));
let mut high = get_arg(optional_args, 2, Value::Str("h".to_string()));
let mut low = get_arg(optional_args, 3, Value::Str("l".to_string()));
let mut close = get_arg(optional_args, 4, Value::Str("c".to_string()));
let mut volume = get_arg(optional_args, 5, Value::Str("v".to_string()));
let mut ms = get_arg(optional_args, 6, Value::Bool(false));
let mut result: Value = Value::Map({
let mut m = indexmap::IndexMap::new();
m
});
add_element_to_object(&mut result, ×tamp, Value::List(vec![]));
add_element_to_object(&mut result, &open, Value::List(vec![]));
add_element_to_object(&mut result, &high, Value::List(vec![]));
add_element_to_object(&mut result, &low, Value::List(vec![]));
add_element_to_object(&mut result, &close, Value::List(vec![]));
add_element_to_object(&mut result, &volume, Value::List(vec![]));
{
let mut i: Value = Value::Int(0);
let mut __for_first_105: bool = true;
while { if !__for_first_105 { i = add(&i, &Value::Int(1)); } __for_first_105 = false; is_less_than(&i, &get_array_length(&ohlcvs)) } {
let mut ts: Value = ternary(is_true(&ms), get_value(&get_value(&ohlcvs, &i), &Value::Int(0)), self.parse_to_int(divide(&get_value(&get_value(&ohlcvs, &i), &Value::Int(0)), &Value::Int(1000))));
let mut resultTimestamp: Value = get_value(&result, ×tamp);
append_to_array(&mut resultTimestamp, ts.clone());
crate::set_value(&mut result, ×tamp, resultTimestamp.clone());
let mut resultOpen: Value = get_value(&result, &open);
append_to_array(&mut resultOpen, get_value(&get_value(&ohlcvs, &i), &Value::Int(1)));
crate::set_value(&mut result, &open, resultOpen.clone());
let mut resultHigh: Value = get_value(&result, &high);
append_to_array(&mut resultHigh, get_value(&get_value(&ohlcvs, &i), &Value::Int(2)));
crate::set_value(&mut result, &high, resultHigh.clone());
let mut resultLow: Value = get_value(&result, &low);
append_to_array(&mut resultLow, get_value(&get_value(&ohlcvs, &i), &Value::Int(3)));
crate::set_value(&mut result, &low, resultLow.clone());
let mut resultClose: Value = get_value(&result, &close);
append_to_array(&mut resultClose, get_value(&get_value(&ohlcvs, &i), &Value::Int(4)));
crate::set_value(&mut result, &close, resultClose.clone());
let mut resultVolume: Value = get_value(&result, &volume);
append_to_array(&mut resultVolume, get_value(&get_value(&ohlcvs, &i), &Value::Int(5)));
crate::set_value(&mut result, &volume, resultVolume.clone());
}
}
return result;
Value::Null
}
fn fetch_web_endpoint(&mut self, mut method: Value, mut endpointMethod: Value, mut returnAsJson: Value, optional_args: &[Value]) -> impl ::std::future::Future<Output = Value> + Send { async move {
let mut startRegex = get_arg(optional_args, 0, Value::Null);
let mut endRegex = get_arg(optional_args, 1, Value::Null);
let mut errorMessage: Value = Value::Str("".to_string());
let mut options: Value = self.safe_value(self.options.clone(), method.clone(), &[Value::Map({
let mut m = indexmap::IndexMap::new();
m
})]);
let mut muteOnFailure: Value = self.safe_bool_k(options.clone(), "webApiMuteFailure", &[Value::Bool(true)]);
{
// if it was not explicitly disabled, then don't fetch
if !is_true(&self.safe_bool_k(options.clone(), "webApiEnable", &[Value::Bool(true)])) {
return Value::Null;
}
let mut maxRetries: Value = self.safe_value_k(options.clone(), "webApiRetries", &[Value::Int(10)]);
let mut response: Value = Value::Null;
let mut retry: Value = Value::Int(0);
let mut shouldBreak: bool = false;
while is_less_than(&retry, &maxRetries) {
{
response = self.call_method(endpointMethod.clone(), &[Value::Map({
let mut m = indexmap::IndexMap::new();
m
})]).await;
shouldBreak = true;
break;
}
if is_true(&shouldBreak) {
break;
}
}
let mut content: Value = response.clone();
if is_equal(&content, &Value::Null) {
panic!("{}", crate::exchange_errors::null_response(add(&self.id, &Value::Str(" fetchWebEndpoint() returned empty content".to_string()))));
}
if !is_equal(&startRegex, &Value::Null) {
let mut splitted_by_start: Value = split(&content, &startRegex);
content = get_value(&splitted_by_start, &Value::Int(1)); // we need second part after start
}
if is_equal(&content, &Value::Null) {
panic!("{}", crate::exchange_errors::null_response(add(&self.id, &Value::Str(" fetchWebEndpoint() returned empty content".to_string()))));
}
if !is_equal(&endRegex, &Value::Null) {
let mut splitted_by_end: Value = split(&content, &endRegex);
content = get_value(&splitted_by_end, &Value::Int(0)); // we need first part after start
}
if is_true(&(is_equal(&returnAsJson, &Value::Bool(true)))) && is_true(&(is_string(&content))) {
let mut jsoned: Value = self.parse_json_value(trim(&content)); // content should be trimmed before json parsing
if is_true(&(!is_equal(&jsoned, &Value::Null))) && is_true(&(!is_equal(&jsoned, &Value::Null))) {
return jsoned.clone();
} else {
panic!("{}", crate::exchange_errors::bad_response(Value::Str("could not parse the response into json".to_string())));
}
} else {
return content.clone();
}
}
if is_equal(&muteOnFailure, &Value::Bool(true)) {
return Value::Null;
} else {
panic!("{}", crate::exchange_errors::bad_response(errorMessage));
}
} }
fn market_ids(&self, optional_args: &[Value]) -> Value {
let mut symbols = get_arg(optional_args, 0, Value::Null);
/*
* @param {string[]|undefined} symbols list of unified symbols
* @returns {string[]|undefined} list of exchange-specific market ids
* Overloads: non-null `string[]` input yields `string[]`; optional input yields `Strings`.
*/
if is_equal(&symbols, &Value::Null) {
return symbols;
}
let mut result: Value = Value::List(vec![]);
{
let mut i: Value = Value::Int(0);
let mut __for_first_106: bool = true;
while { if !__for_first_106 { i = add(&i, &Value::Int(1)); } __for_first_106 = false; is_less_than(&i, &get_array_length(&symbols)) } {
let mut id: Value = self.market_id(get_value(&symbols, &i));
if !is_equal(&id, &Value::Null) {
append_to_array(&mut result, id.clone());
}
}
}
return result;
Value::Null
}
fn currency_ids(&self, optional_args: &[Value]) -> Value {
let mut codes = get_arg(optional_args, 0, Value::Null);
if is_equal(&codes, &Value::Null) {
return codes;
}
let mut result: Value = Value::List(vec![]);
{
let mut i: Value = Value::Int(0);
let mut __for_first_107: bool = true;
while { if !__for_first_107 { i = add(&i, &Value::Int(1)); } __for_first_107 = false; is_less_than(&i, &get_array_length(&codes)) } {
let mut id: Value = self.currency_id(get_value(&codes, &i));
if !is_equal(&id, &Value::Null) {
append_to_array(&mut result, id.clone());
}
}
}
return result;
Value::Null
}
fn markets_for_symbols(&self, optional_args: &[Value]) -> Value {
let mut symbols = get_arg(optional_args, 0, Value::Null);
if is_equal(&symbols, &Value::Null) {
return Value::Null;
}
let mut result: Value = Value::List(vec![]);
{
let mut i: Value = Value::Int(0);
let mut __for_first_108: bool = true;
while { if !__for_first_108 { i = add(&i, &Value::Int(1)); } __for_first_108 = false; is_less_than(&i, &get_array_length(&symbols)) } {
append_to_array(&mut result, self.market(get_value(&symbols, &i)));
}
}
return result;
Value::Null
}
// allowEmpty: false always returns string[] (throws on empty/undefined at runtime)
fn market_symbols(&self, optional_args: &[Value]) -> Value {
let mut symbols = get_arg(optional_args, 0, Value::Null);
let mut type_var = get_arg(optional_args, 1, Value::Null);
let mut allowEmpty = get_arg(optional_args, 2, Value::Bool(true));
let mut sameTypeOnly = get_arg(optional_args, 3, Value::Bool(false));
let mut sameSubTypeOnly = get_arg(optional_args, 4, Value::Bool(false));
/*
* @param {string[]|undefined} symbols list of unified symbols
* @param {string|undefined} type filter by market type
* @param {boolean} allowEmpty whether empty/undefined symbols is allowed
* @param {boolean} sameTypeOnly require all markets to share type
* @param {boolean} sameSubTypeOnly require all markets to share linear/inverse subType
* @returns {string[]|undefined} validated unified symbols
* Overloads: `allowEmpty: false` or non-null `string[]` input yields `string[]`; permissive form yields `Strings`.
*/
if is_equal(&symbols, &Value::Null) {
if !is_true(&allowEmpty) {
panic!("{}", crate::exchange_errors::arguments_required(add(&self.id, &Value::Str(" empty list of symbols is not supported".to_string()))));
}
return symbols;
}
let mut symbolsLength: Value = get_array_length(&symbols);
if is_equal(&symbolsLength, &Value::Int(0)) {
if !is_true(&allowEmpty) {
panic!("{}", crate::exchange_errors::arguments_required(add(&self.id, &Value::Str(" empty list of symbols is not supported".to_string()))));
}
return symbols;
}
let mut result: Value = Value::List(vec![]);
let mut marketType: Value = Value::Null;
let mut isLinearSubType: Value = Value::Null;
{
let mut i: Value = Value::Int(0);
let mut __for_first_109: bool = true;
while { if !__for_first_109 { i = add(&i, &Value::Int(1)); } __for_first_109 = false; is_less_than(&i, &get_array_length(&symbols)) } {
let mut market: Value = self.market(get_value(&symbols, &i));
if is_true(&sameTypeOnly) && is_true(&(!is_equal(&marketType, &Value::Null))) {
if !is_equal(&get_value(&market, &Value::Str("type".to_string())), &marketType) {
panic!("{}", crate::exchange_errors::bad_request(add(&add(&add(&add(&add(&self.id, &Value::Str(" symbols must be of the same type, either ".to_string())), &marketType), &Value::Str(" or ".to_string())), &get_value(&market, &Value::Str("type".to_string()))), &Value::Str(".".to_string()))));
}
}
if is_true(&sameSubTypeOnly) && is_true(&(!is_equal(&isLinearSubType, &Value::Null))) {
if !is_equal(&get_value(&market, &Value::Str("linear".to_string())), &isLinearSubType) {
panic!("{}", crate::exchange_errors::bad_request(add(&self.id, &Value::Str(" symbols must be of the same subType, either linear or inverse.".to_string()))));
}
}
if !is_equal(&type_var, &Value::Null) && !is_equal(&get_value(&market, &Value::Str("type".to_string())), &type_var) {
panic!("{}", crate::exchange_errors::bad_request(add(&add(&add(&self.id, &Value::Str(" symbols must be of the same type ".to_string())), &type_var), &Value::Str(". If the type is incorrect you can change it in options or the params of the request".to_string()))));
}
marketType = get_value(&market, &Value::Str("type".to_string()));
if !is_equal(&get_value(&market, &Value::Str("spot".to_string())), &Value::Bool(true)) {
isLinearSubType = get_value(&market, &Value::Str("linear".to_string()));
}
let mut symbol: Value = self.safe_string_k(market.clone(), "symbol", &[get_value(&symbols, &i)]);
append_to_array(&mut result, symbol.clone());
}
}
return result;
Value::Null
}
fn market_codes(&self, optional_args: &[Value]) -> Value {
let mut codes = get_arg(optional_args, 0, Value::Null);
if is_equal(&codes, &Value::Null) {
return codes;
}
let mut result: Value = Value::List(vec![]);
{
let mut i: Value = Value::Int(0);
let mut __for_first_110: bool = true;
while { if !__for_first_110 { i = add(&i, &Value::Int(1)); } __for_first_110 = false; is_less_than(&i, &get_array_length(&codes)) } {
append_to_array(&mut result, self.common_currency_code(get_value(&codes, &i)));
}
}
return result;
Value::Null
}
fn parse_order_book_bids_asks(&self, mut bidasks: Value, optional_args: &[Value]) -> Value {
let mut priceKey = get_arg(optional_args, 0, Value::Int(0));
let mut amountKey = get_arg(optional_args, 1, Value::Int(1));
let mut countOrIdKey = get_arg(optional_args, 2, Value::Int(2));
bidasks = self.to_array(bidasks.clone());
let mut result: Value = Value::List(vec![]);
{
let mut i: Value = Value::Int(0);
let mut __for_first_111: bool = true;
while { if !__for_first_111 { i = add(&i, &Value::Int(1)); } __for_first_111 = false; is_less_than(&i, &get_array_length(&bidasks)) } {
append_to_array(&mut result, self.parse_order_book_bid_ask(get_value(&bidasks, &i), &[priceKey.clone(), amountKey.clone(), countOrIdKey.clone()]));
}
}
return result;
Value::Null
}
fn filter_by_key(&self, mut objects: Value, mut key: Value, optional_args: &[Value]) -> Value {
let mut value = get_arg(optional_args, 0, Value::Null);
if is_equal(&value, &Value::Null) {
return objects;
}
let mut result: Value = Value::List(vec![]);
{
let mut i: Value = Value::Int(0);
let mut __for_first_112: bool = true;
while { if !__for_first_112 { i = add(&i, &Value::Int(1)); } __for_first_112 = false; is_less_than(&i, &get_array_length(&objects)) } {
let mut objectValue: Value = self.safe_string(get_value(&objects, &i), key.clone(), &[]);
if is_equal(&objectValue, &value) {
append_to_array(&mut result, get_value(&objects, &i));
}
}
}
return result;
Value::Null
}
fn filter_by_symbol(&self, mut objects: Value, optional_args: &[Value]) -> Value {
let mut symbol = get_arg(optional_args, 0, Value::Null);
return self.filter_by_key(objects.clone(), Value::Str("symbol".to_string()), &[symbol.clone()]);
Value::Null
}
fn parse_ohlcv(&self, mut ohlcv: Value, optional_args: &[Value]) -> Value {
// virtual-dispatch (static: DerivedExchange::parse_ohlcv(self, ...))
{ let __v = crate::exchange::DerivedExchange::parse_ohlcv(self, ohlcv.clone(), crate::runtime::get_arg(optional_args, 0, crate::Value::Null)); if !matches!(__v, crate::Value::Null) { return __v; } }
let mut market = get_arg(optional_args, 0, Value::Null);
if is_true(&Value::Bool(is_array(&ohlcv))) {
return Value::List(vec![self.safe_integer(ohlcv.clone(), Value::Int(0), &[]), self.safe_number(ohlcv.clone(), Value::Int(1), &[]), self.safe_number(ohlcv.clone(), Value::Int(2), &[]), self.safe_number(ohlcv.clone(), Value::Int(3), &[]), self.safe_number(ohlcv.clone(), Value::Int(4), &[]), self.safe_number(ohlcv.clone(), Value::Int(5), &[])]);
}
return ohlcv;
Value::Null
}
fn safe_network(&self, mut network: Value) -> Value {
let mut withdrawEnabled: Value = self.safe_bool_k(network.clone(), "withdraw", &[]);
let mut depositEnabled: Value = self.safe_bool_k(network.clone(), "deposit", &[]);
let mut limits: Value = self.safe_dict_k(network.clone(), "limits", &[]);
let mut withdraw: Value = self.safe_dict_k(limits.clone(), "withdraw", &[]);
let mut deposit: Value = self.safe_dict_k(limits.clone(), "deposit", &[]);
let mut isEnabled: Value = withdrawEnabled.clone();
if is_equal(&withdrawEnabled, &Value::Bool(true)) {
isEnabled = depositEnabled.clone();
}
return Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("info".to_string(), get_value(&network, &Value::Str("info".to_string())));
m.insert("id".to_string(), self.safe_string_k(network.clone(), "id", &[]));
m.insert("name".to_string(), self.safe_string_k(network.clone(), "name", &[]));
m.insert("network".to_string(), self.safe_string_k(network.clone(), "network", &[]));
m.insert("active".to_string(), self.safe_bool_k(network.clone(), "active", &[isEnabled.clone()]));
m.insert("deposit".to_string(), depositEnabled.clone());
m.insert("withdraw".to_string(), withdrawEnabled.clone());
m.insert("fee".to_string(), self.safe_number_k(network.clone(), "fee", &[]));
m.insert("precision".to_string(), self.safe_number_k(network.clone(), "precision", &[]));
m.insert("limits".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("withdraw".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("min".to_string(), self.safe_number_k(withdraw.clone(), "min", &[]));
m.insert("max".to_string(), self.safe_number_k(withdraw.clone(), "max", &[]));
m
}));
m.insert("deposit".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("min".to_string(), self.safe_number_k(deposit.clone(), "min", &[]));
m.insert("max".to_string(), self.safe_number_k(deposit.clone(), "max", &[]));
m
}));
m
}));
m
});
Value::Null
}
fn prioritized_network_aliases(&self, optional_args: &[Value]) -> Value {
let mut networkCode = get_arg(optional_args, 0, Value::Null);
let mut currencyCode = get_arg(optional_args, 1, Value::Null);
let mut allowDefault = get_arg(optional_args, 2, Value::Bool(false));
/*
* @method
* @name Exchange#prioritizedNetworkAliases
* @description returns the chain pair [preferred, alternative] for the given networkCode & currency, e.g:
* ---------------------------------
* | input | output |
* --------------------------------|
* | ETH & USDC | ERC20, ETH |
* | ERC20 & USDC | ERC20, ETH |
* | ETH & ETH | ETH, ERC20 |
* | ERC20 & ETH | ETH, ERC20 |
* | ERC20 | ERC20, ETH |
* | ETH | ERC20, ETH |
* ---------------------------------
* @param {string} networkCode unified network-code
* @param {string} currencyCode unified currency-code
* @param {boolean} allowDefault when currencyCode is undefined, order by replacement's "default" instead of by user input
* @returns {string[]} [preferredChain, alternativeChain]
*/
if is_equal(&networkCode, &Value::Null) {
return Value::Null;
}
let mut replacements: Value = self.safe_dict_k(self.options.clone(), "defaultNetworkCodeReplacements", &[Value::Map({
let mut m = indexmap::IndexMap::new();
m
})]);
let mut keys: Value = object_keys(&replacements);
{
let mut i: Value = Value::Int(0);
let mut __for_first_113: bool = true;
while { if !__for_first_113 { i = add(&i, &Value::Int(1)); } __for_first_113 = false; is_less_than(&i, &get_array_length(&keys)) } {
let mut baseCoin: Value = get_value(&keys, &i);
let mut baseCoin: Value = get_value(&keys, &i);
let mut entry: Value = get_value(&replacements, &baseCoin);
let mut entry: Value = get_value(&replacements, &baseCoin);
let mut primary: Value = get_value(&entry, &Value::Str("primary".to_string()));
let mut secondary: Value = get_value(&entry, &Value::Str("secondary".to_string()));
if !is_equal(&networkCode, &primary) && !is_equal(&networkCode, &secondary) {
continue;
}
// pick which form goes first in the returned pair
let mut preferPrimary: Value = Value::Bool(false);
if is_equal(¤cyCode, &baseCoin) {
preferPrimary = Value::Bool(true); // mainnet currency uses primary chain
} else if !is_equal(¤cyCode, &Value::Null) {
preferPrimary = Value::Bool(false); // any other (token) currency uses secondary chain
} else if is_true(&allowDefault) {
preferPrimary = Value::Bool(is_equal(&get_value(&entry, &Value::Str("default".to_string())), &Value::Str("primary".to_string())));
} else {
preferPrimary = Value::Bool(is_equal(&networkCode, &primary)); // keep user input first
}
return ternary(is_true(&(preferPrimary)), Value::List(vec![primary.clone(), secondary.clone()]), Value::List(vec![secondary.clone(), primary.clone()]));
}
}
return Value::List(vec![networkCode.clone(), networkCode.clone()]);
Value::Null
}
fn network_code_to_id(&self, mut networkCode: Value, optional_args: &[Value]) -> Value {
let mut currencyCode = get_arg(optional_args, 0, Value::Null);
/*
* @ignore
* @method
* @name exchange#networkCodeToId
* @description tries to convert the provided networkCode (which is expected to be an unified network code) to a network id. In order to achieve this, derived class needs to have 'options->networks' defined.
* @param {string} networkCode unified network code
* @param {string} currencyCode unified currency code, but this argument is not required by default, unless there is an exchange (like huobi) that needs an override of the method to be able to pass currencyCode argument additionally
* @returns {string|undefined} exchange-specific network id
*/
if is_equal(&networkCode, &Value::Null) {
return Value::Null;
}
let mut networkIdsByCodes: Value = self.safe_dict_k(self.options.clone(), "networks", &[Value::Map({
let mut m = indexmap::IndexMap::new();
m
})]);
// try the preferred form first, fall back to its alternative (e.g. when only 'ETH' or only 'ERC20' is defined)
let mut chainPair: Value = self.prioritized_network_aliases(&[networkCode.clone(), currencyCode.clone(), Value::Bool(false)]);
let mut preferredChain: Value = ternary(is_true(&(is_equal(&chainPair, &Value::Null))), networkCode.clone(), get_value(&chainPair, &Value::Int(0)));
let mut alternativeChain: Value = ternary(is_true(&(is_equal(&chainPair, &Value::Null))), networkCode.clone(), get_value(&chainPair, &Value::Int(1)));
let mut networkId: Value = self.safe_string2(networkIdsByCodes.clone(), preferredChain.clone(), alternativeChain.clone(), &[]);
if !is_equal(&networkId, &Value::Null) {
return networkId;
}
// fall back to scanning loaded currencies
let mut currenciesToCheck: Value = Value::List(vec![]);
if is_equal(¤cyCode, &Value::Null) {
currenciesToCheck = object_keys(&self.currencies);
} else {
currenciesToCheck = Value::List(vec![self.safe_dict(self.currencies.clone(), currencyCode.clone(), &[])]);
}
{
let mut i: Value = Value::Int(0);
let mut __for_first_114: bool = true;
while { if !__for_first_114 { i = add(&i, &Value::Int(1)); } __for_first_114 = false; is_less_than(&i, &get_array_length(¤ciesToCheck)) } {
let mut networks: Value = self.safe_dict_k(get_value(¤ciesToCheck, &i), "networks", &[Value::Map({
let mut m = indexmap::IndexMap::new();
m
})]);
if is_true(&Value::Bool(in_op(&networks, &networkCode))) {
return self.safe_string_k(get_value(&networks, &networkCode), "id", &[]);
}
}
}
// before returning the original input, try to match if it's backward-maintained networkCode
let mut oldCodes: Value = self.safe_dict_k(self.options.clone(), "backwardSupportedNetworkCodes", &[Value::Map({
let mut m = indexmap::IndexMap::new();
m
})]);
if is_true(&Value::Bool(in_op(&oldCodes, &networkCode))) {
return self.network_code_to_id(get_value(&oldCodes, &networkCode), &[currencyCode.clone()]);
}
return networkCode;
Value::Null
}
fn network_id_to_code(&self, optional_args: &[Value]) -> Value {
let mut networkId = get_arg(optional_args, 0, Value::Null);
let mut currencyCode = get_arg(optional_args, 1, Value::Null);
/*
* @ignore
* @method
* @name exchange#networkIdToCode
* @description tries to convert the provided exchange-specific networkId to an unified network Code. In order to achieve this, derived class needs to have "options['networksById']" defined.
* @param {string} networkId exchange specific network id/title, like: TRON, Trc-20, usdt-erc20, etc
* @param {string|undefined} currencyCode unified currency code, but this argument is not required by default, unless there is an exchange (like huobi) that needs an override of the method to be able to pass currencyCode argument additionally
* @returns {string|undefined} unified network code
*/
if is_equal(&networkId, &Value::Null) {
return Value::Null;
}
let mut networkCodesByIds: Value = self.safe_dict_k(self.options.clone(), "networksById", &[Value::Map({
let mut m = indexmap::IndexMap::new();
m
})]);
let mut networkCode: Value = self.safe_string(networkCodesByIds.clone(), networkId.clone(), &[networkId.clone()]);
let mut chainPair: Value = self.prioritized_network_aliases(&[networkCode.clone(), currencyCode.clone(), Value::Bool(true)]);
if is_equal(&chainPair, &Value::Null) {
return networkCode;
}
let mut preferredChain: Value = get_value(&chainPair, &Value::Int(0));
let mut alternativeChain: Value = get_value(&chainPair, &Value::Int(1));
// when the exchange explicitly defines both forms in options.networks (e.g. BTC + BRC20),
// it disambiguates them — trust the direct id→code inversion instead of guessing
if is_equal(¤cyCode, &Value::Null) {
let mut networkIdsByCodes: Value = self.safe_dict_k(self.options.clone(), "networks", &[Value::Map({
let mut m = indexmap::IndexMap::new();
m
})]);
if is_true(&(Value::Bool(in_op(&networkIdsByCodes, &preferredChain)))) && is_true(&(Value::Bool(in_op(&networkIdsByCodes, &alternativeChain)))) {
return networkCode;
}
}
return preferredChain;
Value::Null
}
fn handle_network_code_and_params(&self, mut params: Value) -> Value {
let mut networkCodeInParams: Value = self.safe_string2(params.clone(), Value::Str("networkCode".to_string()), Value::Str("network".to_string()), &[]);
if !is_equal(&networkCodeInParams, &Value::Null) {
params = self.omit(params.clone(), Value::List(vec![Value::Str("networkCode".to_string()), Value::Str("network".to_string())]), &[]);
}
return Value::List(vec![networkCodeInParams.clone(), params.clone()]);
Value::Null
}
fn default_network_code(&self, mut currencyCode: Value) -> Value {
let mut defaultNetworkCode: Value = Value::Null;
let mut defaultNetworks: Value = self.safe_dict_k(self.options.clone(), "defaultNetworks", &[Value::Map({
let mut m = indexmap::IndexMap::new();
m
})]);
if is_true(&Value::Bool(in_op(&defaultNetworks, ¤cyCode))) {
// if currency had set its network in "defaultNetworks", use it
defaultNetworkCode = get_value(&defaultNetworks, ¤cyCode);
} else {
// otherwise, try to use the global-scope 'defaultNetwork' value (even if that network is not supported by currency, it doesn't make any problem, this will be just used "at first" if currency supports this network at all)
let mut defaultNetwork: Value = self.safe_string_k(self.options.clone(), "defaultNetwork", &[]);
if !is_equal(&defaultNetwork, &Value::Null) {
defaultNetworkCode = defaultNetwork.clone();
}
}
return defaultNetworkCode;
Value::Null
}
fn select_network_code_from_unified_networks(&self, mut currencyCode: Value, mut networkCode: Value, mut indexedNetworkEntries: Value) -> Value {
return self.select_network_key_from_networks(currencyCode.clone(), networkCode.clone(), indexedNetworkEntries.clone(), &[Value::Bool(true)]);
Value::Null
}
fn select_network_id_from_raw_networks(&self, mut currencyCode: Value, mut networkCode: Value, mut indexedNetworkEntries: Value) -> Value {
return self.select_network_key_from_networks(currencyCode.clone(), networkCode.clone(), indexedNetworkEntries.clone(), &[Value::Bool(false)]);
Value::Null
}
fn select_network_key_from_networks(&self, mut currencyCode: Value, mut networkCode: Value, mut indexedNetworkEntries: Value, optional_args: &[Value]) -> Value {
let mut isIndexedByUnifiedNetworkCode = get_arg(optional_args, 0, Value::Bool(false));
// this method is used against raw & unparse network entries, which are just indexed by network id
let mut chosenNetworkId: Value = Value::Null;
let mut availableNetworkIds: Value = object_keys(&indexedNetworkEntries);
let mut responseNetworksLength: Value = get_array_length(&availableNetworkIds);
if !is_equal(&networkCode, &Value::Null) {
if is_equal(&responseNetworksLength, &Value::Int(0)) {
panic!("{}", crate::exchange_errors::not_supported(add(&add(&add(&add(&self.id, &Value::Str(" - ".to_string())), &networkCode), &Value::Str(" network did not return any result for ".to_string())), ¤cyCode)));
} else {
// if networkCode was provided by user, we should check it after response, as the referenced exchange doesn't support network-code during request
let mut networkIdOrCode: Value = ternary(is_true(&isIndexedByUnifiedNetworkCode), networkCode.clone(), self.network_code_to_id(networkCode.clone(), &[currencyCode.clone()]));
if is_true(&Value::Bool(in_op(&indexedNetworkEntries, &networkIdOrCode))) {
chosenNetworkId = networkIdOrCode.clone();
} else {
panic!("{}", crate::exchange_errors::not_supported(add(&add(&add(&add(&add(&add(&self.id, &Value::Str(" - ".to_string())), &networkIdOrCode), &Value::Str(" network was not found for ".to_string())), ¤cyCode), &Value::Str(", use one of ".to_string())), &join(&availableNetworkIds, &Value::Str(", ".to_string())))));
}
}
} else {
if is_equal(&responseNetworksLength, &Value::Int(0)) {
panic!("{}", crate::exchange_errors::not_supported(add(&add(&self.id, &Value::Str(" - no networks were returned for ".to_string())), ¤cyCode)));
} else {
// if networkCode was not provided by user, then we try to use the default network (if it was defined in "defaultNetworks"), otherwise, we just return the first network entry
let mut defaultNetworkCode: Value = self.default_network_code(currencyCode.clone());
let mut defaultNetworkId: Value = ternary(is_true(&isIndexedByUnifiedNetworkCode), defaultNetworkCode.clone(), self.network_code_to_id(defaultNetworkCode.clone(), &[currencyCode.clone()]));
if is_equal(&defaultNetworkId, &Value::Null) {
panic!("{}", crate::exchange_errors::exchange_error(add(&self.id, &Value::Str(" selectNetworkKeyFromNetworks() missing defaultNetworkId".to_string()))));
}
if is_true(&Value::Bool(in_op(&indexedNetworkEntries, &defaultNetworkId))) {
return defaultNetworkId;
}
panic!("{}", crate::exchange_errors::not_supported(add(&add(&self.id, &Value::Str(" - can not determine the default network, please pass param[\"network\"] one from : ".to_string())), &join(&availableNetworkIds, &Value::Str(", ".to_string())))));
}
}
return chosenNetworkId;
Value::Null
}
fn safe_number2(&self, mut dictionary: Value, mut key1: Value, mut key2: Value, optional_args: &[Value]) -> Value {
let mut d = get_arg(optional_args, 0, Value::Null);
let mut value: Value = self.safe_string2(dictionary.clone(), key1.clone(), key2.clone(), &[]);
return self.parse_number(value.clone(), &[d.clone()]);
Value::Null
}
fn parse_order_book(&self, mut orderbook: Value, mut symbol: Value, optional_args: &[Value]) -> Value {
// virtual-dispatch (static: DerivedExchange::parse_order_book(self, ...))
{ let __v = crate::exchange::DerivedExchange::parse_order_book(self, orderbook.clone(), symbol.clone(), crate::runtime::get_arg(optional_args, 0, crate::Value::Null), crate::runtime::get_arg(optional_args, 1, crate::Value::Null), crate::runtime::get_arg(optional_args, 2, crate::Value::Null), crate::runtime::get_arg(optional_args, 3, crate::Value::Null), crate::runtime::get_arg(optional_args, 4, crate::Value::Null), crate::runtime::get_arg(optional_args, 5, crate::Value::Null)); if !matches!(__v, crate::Value::Null) { return __v; } }
let mut timestamp = get_arg(optional_args, 0, Value::Null);
let mut bidsKey = get_arg(optional_args, 1, Value::Str("bids".to_string()));
let mut asksKey = get_arg(optional_args, 2, Value::Str("asks".to_string()));
let mut priceKey = get_arg(optional_args, 3, Value::Int(0));
let mut amountKey = get_arg(optional_args, 4, Value::Int(1));
let mut countOrIdKey = get_arg(optional_args, 5, Value::Int(2));
if is_equal(&orderbook, &Value::Null) {
orderbook = Value::Map({
let mut m = indexmap::IndexMap::new();
m
});
}
let mut bids: Value = self.parse_order_book_bids_asks(self.safe_value(orderbook.clone(), bidsKey.clone(), &[Value::List(vec![])]), &[priceKey.clone(), amountKey.clone(), countOrIdKey.clone()]);
let mut asks: Value = self.parse_order_book_bids_asks(self.safe_value(orderbook.clone(), asksKey.clone(), &[Value::List(vec![])]), &[priceKey.clone(), amountKey.clone(), countOrIdKey.clone()]);
return Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("symbol".to_string(), symbol.clone());
m.insert("bids".to_string(), self.sort_by(bids.clone(), Value::Int(0), &[Value::Bool(true)]));
m.insert("asks".to_string(), self.sort_by(asks.clone(), Value::Int(0), &[]));
m.insert("timestamp".to_string(), timestamp.clone());
m.insert("datetime".to_string(), self.iso8601(timestamp.clone()));
m.insert("nonce".to_string(), Value::Null);
m
});
Value::Null
}
fn parse_ohlc_vs(&self, mut ohlcvs: Value, optional_args: &[Value]) -> Value {
let mut market = get_arg(optional_args, 0, Value::Null);
let mut timeframe = get_arg(optional_args, 1, Value::Str("1m".to_string()));
let mut since = get_arg(optional_args, 2, Value::Null);
let mut limit = get_arg(optional_args, 3, Value::Null);
let mut tail = get_arg(optional_args, 4, Value::Bool(false));
if is_equal(&ohlcvs, &Value::Null) {
return Value::List(vec![]);
}
let mut results: Value = Value::List(vec![]);
{
let mut i: Value = Value::Int(0);
let mut __for_first_115: bool = true;
while { if !__for_first_115 { i = add(&i, &Value::Int(1)); } __for_first_115 = false; is_less_than(&i, &get_array_length(&ohlcvs)) } {
append_to_array(&mut results, <Self as crate::exchange_generated::ExchangeBase>::parse_ohlcv(self, get_value(&ohlcvs, &i), &[market.clone()]));
}
}
let mut sorted: Value = self.sort_by(results.clone(), Value::Int(0), &[]);
return self.filter_by_since_limit(sorted.clone(), &[since.clone(), limit.clone(), Value::Int(0), tail.clone()]);
Value::Null
}
fn parse_leverage_tiers(&self, mut response: Value, optional_args: &[Value]) -> Value {
let mut symbols = get_arg(optional_args, 0, Value::Null);
let mut marketIdKey = get_arg(optional_args, 1, Value::Null);
// marketIdKey should only be undefined when response is a dictionary.
symbols = self.market_symbols(&[symbols.clone()]);
let mut tiers: Value = Value::Map({
let mut m = indexmap::IndexMap::new();
m
});
let mut symbolsLength: Value = Value::Int(0);
if !is_equal(&symbols, &Value::Null) {
symbolsLength = get_array_length(&symbols);
}
let mut noSymbols: bool = is_true(&(is_equal(&symbols, &Value::Null))) || is_true(&(is_equal(&symbolsLength, &Value::Int(0))));
if is_true(&Value::Bool(is_array(&response))) {
{
let mut i: Value = Value::Int(0);
let mut __for_first_116: bool = true;
while { if !__for_first_116 { i = add(&i, &Value::Int(1)); } __for_first_116 = false; is_less_than(&i, &get_array_length(&response)) } {
let mut item: Value = get_value(&response, &i);
let mut item: Value = get_value(&response, &i);
let mut id: Value = ternary(is_true(&(is_equal(&marketIdKey, &Value::Null))), Value::Null, self.safe_string(item.clone(), marketIdKey.clone(), &[]));
let mut market: Value = self.safe_market(&[id.clone(), Value::Null, Value::Null, Value::Str("swap".to_string())]);
let mut symbol: Value = get_value(&market, &Value::Str("symbol".to_string()));
let mut contract: Value = self.safe_bool_k(market.clone(), "contract", &[Value::Bool(false)]);
if is_true(&(is_equal(&contract, &Value::Bool(true)))) && is_true(&(is_true(&noSymbols) || is_true(&(is_true(&(!is_equal(&symbols, &Value::Null))) && is_true(&self.in_array(symbol.clone(), symbols.clone())))))) {
add_element_to_object(&mut tiers, &symbol, <Self as crate::exchange_generated::ExchangeBase>::parse_market_leverage_tiers(self, item.clone(), &[market.clone()]));
}
}
}
} else {
let mut keys: Value = object_keys(&response);
{
let mut i: Value = Value::Int(0);
let mut __for_first_117: bool = true;
while { if !__for_first_117 { i = add(&i, &Value::Int(1)); } __for_first_117 = false; is_less_than(&i, &get_array_length(&keys)) } {
let mut marketId: Value = get_value(&keys, &i);
let mut marketId: Value = get_value(&keys, &i);
let mut item: Value = get_value(&response, &marketId);
let mut item: Value = get_value(&response, &marketId);
let mut market: Value = self.safe_market(&[marketId.clone(), Value::Null, Value::Null, Value::Str("swap".to_string())]);
let mut symbol: Value = get_value(&market, &Value::Str("symbol".to_string()));
let mut contract: Value = self.safe_bool_k(market.clone(), "contract", &[Value::Bool(false)]);
if is_true(&(is_equal(&contract, &Value::Bool(true)))) && is_true(&(is_true(&noSymbols) || is_true(&(is_true(&(!is_equal(&symbols, &Value::Null))) && is_true(&self.in_array(symbol.clone(), symbols.clone())))))) {
add_element_to_object(&mut tiers, &symbol, <Self as crate::exchange_generated::ExchangeBase>::parse_market_leverage_tiers(self, item.clone(), &[market.clone()]));
}
}
}
}
return tiers;
Value::Null
}
fn load_trading_limits(&mut self, optional_args: &[Value]) -> impl ::std::future::Future<Output = Value> + Send { async move {
let mut symbols = get_arg(optional_args, 0, Value::Null);
let mut reload = get_arg(optional_args, 1, Value::Bool(false));
let mut params = get_arg(optional_args, 2, Value::Map({
let mut m = indexmap::IndexMap::new();
m
}));
if !is_equal(&get_value(&self.has, &Value::Str("fetchTradingLimits".to_string())), &Value::Null) && !is_equal(&get_value(&self.has, &Value::Str("fetchTradingLimits".to_string())), &Value::Bool(false)) {
if is_true(&reload) || !is_true(&(Value::Bool(in_op(&self.options, &Value::Str("limitsLoaded".to_string()))))) {
let mut response: Value = self.fetch_trading_limits(&[symbols.clone()]).await;
let mut symbolsArray: Value = self.require_value(symbols.clone(), &[Value::Str("loadTradingLimits() requires a symbols argument".to_string())]);
let mut markets: Value = self.markets.clone();
if is_equal(&markets, &Value::Null) {
panic!("{}", crate::exchange_errors::exchange_error(add(&self.id, &Value::Str(" markets not loaded".to_string()))));
}
{
let mut i: Value = Value::Int(0);
let mut __for_first_118: bool = true;
while { if !__for_first_118 { i = add(&i, &Value::Int(1)); } __for_first_118 = false; is_less_than(&i, &get_array_length(&symbolsArray)) } {
let mut symbol: Value = get_value(&symbolsArray, &i);
let mut symbol: Value = get_value(&symbolsArray, &i);
{ let __be_tmp = self.deep_extend(get_value(&markets, &symbol), &[get_value(&response, &symbol)]); add_element_to_object(&mut markets, &symbol, __be_tmp); };
}
}
{ let __be_tmp = self.milliseconds(); add_element_to_object(&mut self.options, &Value::Str("limitsLoaded".to_string()), __be_tmp); };
}
}
return self.markets.clone();
Value::Null
} }
fn safe_position(&self, mut position: Value) -> Value {
// simplified version of: /pull/12765/
let mut unrealizedPnlString: Value = self.safe_string_k(position.clone(), "unrealizedPnl", &[]);
let mut initialMarginString: Value = self.safe_string_k(position.clone(), "initialMargin", &[]);
//
// PERCENTAGE
//
let mut percentage: Value = self.safe_value_k(position.clone(), "percentage", &[]);
if is_true(&(is_equal(&percentage, &Value::Null))) && is_true(&(!is_equal(&unrealizedPnlString, &Value::Null))) && is_true(&(!is_equal(&initialMarginString, &Value::Null))) {
// as it was done in all implementations ( aax, btcex, bybit, deribit, gate, kucoinfutures, phemex )
let mut percentageString: Value = crate::precise::Precise::stringMul(&crate::precise::Precise::stringDivPrec(&unrealizedPnlString, &initialMarginString, &Value::Int(4)), &Value::Str("100".to_string()));
add_element_to_object(&mut position, &Value::Str("percentage".to_string()), self.parse_number(percentageString.clone(), &[]));
}
// if contractSize is undefined get from market
let mut contractSize: Value = self.safe_number_k(position.clone(), "contractSize", &[]);
let mut symbol: Value = self.safe_string_k(position.clone(), "symbol", &[]);
let mut market: Value = Value::Null;
if !is_equal(&symbol, &Value::Null) {
market = self.safe_value(self.markets.clone(), symbol.clone(), &[]);
}
if is_equal(&contractSize, &Value::Null) && !is_equal(&market, &Value::Null) {
contractSize = self.safe_number_k(market.clone(), "contractSize", &[]);
add_element_to_object(&mut position, &Value::Str("contractSize".to_string()), contractSize.clone());
}
return position;
Value::Null
}
fn parse_positions(&self, mut positions: Value, 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
}));
symbols = self.market_symbols(&[symbols.clone()]);
let mut positionsArray: Value = self.to_array(positions.clone());
let mut result: Value = Value::List(vec![]);
{
let mut i: Value = Value::Int(0);
let mut __for_first_119: bool = true;
while { if !__for_first_119 { i = add(&i, &Value::Int(1)); } __for_first_119 = false; is_less_than(&i, &get_array_length(&positionsArray)) } {
let mut position: Value = self.extend(<Self as crate::exchange_generated::ExchangeBase>::parse_position(self, get_value(&positionsArray, &i), &[]), &[params.clone()]);
append_to_array(&mut result, position.clone());
}
}
return self.filter_by_array_positions(result.clone(), Value::Str("symbol".to_string()), &[symbols.clone(), Value::Bool(false)]);
Value::Null
}
fn parse_adl_rank(&self, mut info: Value, optional_args: &[Value]) -> Value {
// virtual-dispatch (static: DerivedExchange::parse_adl_rank(self, ...))
{ let __v = crate::exchange::DerivedExchange::parse_adl_rank(self, info.clone(), crate::runtime::get_arg(optional_args, 0, crate::Value::Null)); if !matches!(__v, crate::Value::Null) { return __v; } }
let mut market = get_arg(optional_args, 0, Value::Null);
if is_equal(&info, &Value::Null) {
panic!("{}", crate::exchange_errors::not_supported(add(&self.id, &Value::Str(" parseADLRank() is not supported yet".to_string()))));
}
panic!("{}", crate::exchange_errors::not_supported(add(&self.id, &Value::Str(" parseADLRank() is not supported yet".to_string()))));
Value::Null
}
fn parse_adl_ranks(&self, mut ranks: Value, 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
}));
symbols = self.market_symbols(&[symbols.clone()]);
let mut ranksArray: Value = self.to_array(ranks.clone());
let mut result: Value = Value::List(vec![]);
{
let mut i: Value = Value::Int(0);
let mut __for_first_120: bool = true;
while { if !__for_first_120 { i = add(&i, &Value::Int(1)); } __for_first_120 = false; is_less_than(&i, &get_array_length(&ranksArray)) } {
let mut rank: Value = self.extend(<Self as crate::exchange_generated::ExchangeBase>::parse_adl_rank(self, get_value(&ranksArray, &i), &[]), &[params.clone()]);
append_to_array(&mut result, rank.clone());
}
}
return self.filter_by_array_positions(result.clone(), Value::Str("symbol".to_string()), &[symbols.clone(), Value::Bool(false)]);
Value::Null
}
fn parse_accounts(&self, mut accounts: Value, optional_args: &[Value]) -> Value {
let mut params = get_arg(optional_args, 0, Value::Map({
let mut m = indexmap::IndexMap::new();
m
}));
let mut accountsArray: Value = self.to_array(accounts.clone());
let mut result: Value = Value::List(vec![]);
{
let mut i: Value = Value::Int(0);
let mut __for_first_121: bool = true;
while { if !__for_first_121 { i = add(&i, &Value::Int(1)); } __for_first_121 = false; is_less_than(&i, &get_array_length(&accountsArray)) } {
let mut account: Value = self.extend(<Self as crate::exchange_generated::ExchangeBase>::parse_account(self, get_value(&accountsArray, &i)), &[params.clone()]);
append_to_array(&mut result, account.clone());
}
}
return result;
Value::Null
}
fn parse_trades_helper(&self, mut isWs: Value, mut trades: 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 params = get_arg(optional_args, 3, Value::Map({
let mut m = indexmap::IndexMap::new();
m
}));
let mut tradesArray: Value = self.to_array(trades.clone());
let mut result: Value = Value::List(vec![]);
{
let mut i: Value = Value::Int(0);
let mut __for_first_122: bool = true;
while { if !__for_first_122 { i = add(&i, &Value::Int(1)); } __for_first_122 = false; is_less_than(&i, &get_array_length(&tradesArray)) } {
let mut parsed: Value = Value::Null;
if is_true(&isWs) {
parsed = self.parse_ws_trade(get_value(&tradesArray, &i), &[market.clone()]);
} else {
parsed = <Self as crate::exchange_generated::ExchangeBase>::parse_trade(self, get_value(&tradesArray, &i), &[market.clone()]);
}
let mut trade: Value = self.extend(parsed.clone(), &[params.clone()]);
append_to_array(&mut result, trade.clone());
}
}
result = self.sort_by2(result.clone(), Value::Str("timestamp".to_string()), Value::Str("id".to_string()), &[]);
let mut symbol: Value = self.safe_string_k(market.clone(), "symbol", &[]);
return self.filter_by_symbol_since_limit(result.clone(), &[symbol.clone(), since.clone(), limit.clone()]);
Value::Null
}
fn parse_trades(&self, mut trades: 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 params = get_arg(optional_args, 3, Value::Map({
let mut m = indexmap::IndexMap::new();
m
}));
return self.parse_trades_helper(Value::Bool(false), trades.clone(), &[market.clone(), since.clone(), limit.clone(), params.clone()]);
Value::Null
}
fn parse_ws_trades(&self, mut trades: 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 params = get_arg(optional_args, 3, Value::Map({
let mut m = indexmap::IndexMap::new();
m
}));
return self.parse_trades_helper(Value::Bool(true), trades.clone(), &[market.clone(), since.clone(), limit.clone(), params.clone()]);
Value::Null
}
fn parse_transactions(&self, mut transactions: Value, optional_args: &[Value]) -> Value {
let mut currency = get_arg(optional_args, 0, Value::Null);
let mut since = get_arg(optional_args, 1, Value::Null);
let mut limit = get_arg(optional_args, 2, Value::Null);
let mut params = get_arg(optional_args, 3, Value::Map({
let mut m = indexmap::IndexMap::new();
m
}));
let mut transactionsArray: Value = self.to_array(transactions.clone());
let mut result: Value = Value::List(vec![]);
{
let mut i: Value = Value::Int(0);
let mut __for_first_123: bool = true;
while { if !__for_first_123 { i = add(&i, &Value::Int(1)); } __for_first_123 = false; is_less_than(&i, &get_array_length(&transactionsArray)) } {
let mut transaction: Value = self.extend(<Self as crate::exchange_generated::ExchangeBase>::parse_transaction(self, get_value(&transactionsArray, &i), &[currency.clone()]), &[params.clone()]);
append_to_array(&mut result, transaction.clone());
}
}
result = self.sort_by(result.clone(), Value::Str("timestamp".to_string()), &[]);
let mut code: Value = ternary(is_true(&(!is_equal(¤cy, &Value::Null))), get_value(¤cy, &Value::Str("code".to_string())), Value::Null);
return self.filter_by_currency_since_limit(result.clone(), &[code.clone(), since.clone(), limit.clone()]);
Value::Null
}
fn parse_transfers(&self, mut transfers: Value, optional_args: &[Value]) -> Value {
let mut currency = get_arg(optional_args, 0, Value::Null);
let mut since = get_arg(optional_args, 1, Value::Null);
let mut limit = get_arg(optional_args, 2, Value::Null);
let mut params = get_arg(optional_args, 3, Value::Map({
let mut m = indexmap::IndexMap::new();
m
}));
let mut transfersArray: Value = self.to_array(transfers.clone());
let mut result: Value = Value::List(vec![]);
{
let mut i: Value = Value::Int(0);
let mut __for_first_124: bool = true;
while { if !__for_first_124 { i = add(&i, &Value::Int(1)); } __for_first_124 = false; is_less_than(&i, &get_array_length(&transfersArray)) } {
let mut transfer: Value = self.extend(<Self as crate::exchange_generated::ExchangeBase>::parse_transfer(self, get_value(&transfersArray, &i), &[currency.clone()]), &[params.clone()]);
append_to_array(&mut result, transfer.clone());
}
}
result = self.sort_by(result.clone(), Value::Str("timestamp".to_string()), &[]);
let mut code: Value = ternary(is_true(&(!is_equal(¤cy, &Value::Null))), get_value(¤cy, &Value::Str("code".to_string())), Value::Null);
return self.filter_by_currency_since_limit(result.clone(), &[code.clone(), since.clone(), limit.clone()]);
Value::Null
}
fn parse_ledger(&self, mut data: Value, optional_args: &[Value]) -> Value {
let mut currency = get_arg(optional_args, 0, Value::Null);
let mut since = get_arg(optional_args, 1, Value::Null);
let mut limit = get_arg(optional_args, 2, Value::Null);
let mut params = get_arg(optional_args, 3, Value::Map({
let mut m = indexmap::IndexMap::new();
m
}));
let mut result: Value = Value::List(vec![]);
let mut arrayData: Value = self.to_array(data.clone());
{
let mut i: Value = Value::Int(0);
let mut __for_first_126: bool = true;
while { if !__for_first_126 { i = add(&i, &Value::Int(1)); } __for_first_126 = false; is_less_than(&i, &get_array_length(&arrayData)) } {
let mut itemOrItems: Value = <Self as crate::exchange_generated::ExchangeBase>::parse_ledger_entry(self, get_value(&arrayData, &i), &[currency.clone()]);
if is_true(&Value::Bool(is_array(&itemOrItems))) {
{
let mut j: Value = Value::Int(0);
let mut __for_first_125: bool = true;
while { if !__for_first_125 { j = add(&j, &Value::Int(1)); } __for_first_125 = false; is_less_than(&j, &get_array_length(&itemOrItems)) } {
append_to_array(&mut result, self.extend(get_value(&itemOrItems, &j), &[params.clone()]));
}
}
} else {
append_to_array(&mut result, self.extend(itemOrItems.clone(), &[params.clone()]));
}
}
}
result = self.sort_by(result.clone(), Value::Str("timestamp".to_string()), &[]);
let mut code: Value = ternary(is_true(&(!is_equal(¤cy, &Value::Null))), get_value(¤cy, &Value::Str("code".to_string())), Value::Null);
return self.filter_by_currency_since_limit(result.clone(), &[code.clone(), since.clone(), limit.clone()]);
Value::Null
}
fn nonce(&self) -> Value {
// virtual-dispatch (static: DerivedExchange::nonce(self, ...))
{ let __v = crate::exchange::DerivedExchange::nonce(self, ); if !matches!(__v, crate::Value::Null) { return __v; } }
return self.seconds();
Value::Null
}
fn set_headers(&self, mut headers: Value) -> Value {
return headers;
Value::Null
}
fn currency_id(&self, mut code: Value) -> Value {
if is_equal(&code, &Value::Null) {
return code;
}
let mut currency: Value = self.safe_dict(self.currencies.clone(), code.clone(), &[]);
if is_equal(¤cy, &Value::Null) {
currency = self.safe_currency(code.clone(), &[]);
}
if !is_equal(¤cy, &Value::Null) {
return get_value(¤cy, &Value::Str("id".to_string()));
}
return code;
Value::Null
}
fn market_id(&self, mut symbol: Value) -> Value {
let mut market: Value = self.market(symbol.clone());
if !is_equal(&market, &Value::Null) {
return get_value(&market, &Value::Str("id".to_string()));
}
return symbol;
Value::Null
}
fn symbol(&self, mut symbol: Value) -> Value {
if is_equal(&symbol, &Value::Null) {
panic!("{}", crate::exchange_errors::arguments_required(add(&self.id, &Value::Str(" symbol() requires a symbol argument".to_string()))));
}
let mut market: Value = self.market(symbol.clone());
return self.safe_string_k(market.clone(), "symbol", &[symbol.clone()]);
Value::Null
}
/* eslint-disable no-unused-vars */
/* eslint-enable no-unused-vars */
fn handle_param_string(&self, mut params: Value, mut paramName: Value, optional_args: &[Value]) -> Value {
let mut defaultValue = get_arg(optional_args, 0, Value::Null);
let mut value: Value = self.safe_string(params.clone(), paramName.clone(), &[defaultValue.clone()]);
if !is_equal(&value, &Value::Null) {
params = self.omit(params.clone(), paramName.clone(), &[]);
}
return Value::List(vec![value.clone(), params.clone()]);
Value::Null
}
/* eslint-disable no-unused-vars */
/* eslint-enable no-unused-vars */
fn handle_param_string2(&self, mut params: Value, mut paramName1: Value, mut paramName2: Value, optional_args: &[Value]) -> Value {
let mut defaultValue = get_arg(optional_args, 0, Value::Null);
let mut value: Value = self.safe_string2(params.clone(), paramName1.clone(), paramName2.clone(), &[defaultValue.clone()]);
if !is_equal(&value, &Value::Null) {
params = self.omit(params.clone(), Value::List(vec![paramName1.clone(), paramName2.clone()]), &[]);
}
return Value::List(vec![value.clone(), params.clone()]);
Value::Null
}
fn handle_param_integer(&self, mut params: Value, mut paramName: Value, optional_args: &[Value]) -> Value {
let mut defaultValue = get_arg(optional_args, 0, Value::Null);
let mut value: Value = self.safe_integer(params.clone(), paramName.clone(), &[defaultValue.clone()]);
if !is_equal(&value, &Value::Null) {
params = self.omit(params.clone(), paramName.clone(), &[]);
}
return Value::List(vec![value.clone(), params.clone()]);
Value::Null
}
fn handle_param_integer2(&self, mut params: Value, mut paramName1: Value, mut paramName2: Value, optional_args: &[Value]) -> Value {
let mut defaultValue = get_arg(optional_args, 0, Value::Null);
let mut value: Value = self.safe_integer2(params.clone(), paramName1.clone(), paramName2.clone(), &[defaultValue.clone()]);
if !is_equal(&value, &Value::Null) {
params = self.omit(params.clone(), Value::List(vec![paramName1.clone(), paramName2.clone()]), &[]);
}
return Value::List(vec![value.clone(), params.clone()]);
Value::Null
}
fn handle_param_bool(&self, mut params: Value, mut paramName: Value, optional_args: &[Value]) -> Value {
let mut defaultValue = get_arg(optional_args, 0, Value::Null);
let mut value: Value = self.safe_bool(params.clone(), paramName.clone(), &[defaultValue.clone()]);
if !is_equal(&value, &Value::Null) {
params = self.omit(params.clone(), paramName.clone(), &[]);
}
return Value::List(vec![value.clone(), params.clone()]);
Value::Null
}
fn handle_param_bool2(&self, mut params: Value, mut paramName1: Value, mut paramName2: Value, optional_args: &[Value]) -> Value {
let mut defaultValue = get_arg(optional_args, 0, Value::Null);
let mut value: Value = self.safe_bool2(params.clone(), paramName1.clone(), paramName2.clone(), &[defaultValue.clone()]);
if !is_equal(&value, &Value::Null) {
params = self.omit(params.clone(), Value::List(vec![paramName1.clone(), paramName2.clone()]), &[]);
}
return Value::List(vec![value.clone(), params.clone()]);
Value::Null
}
/*
* @param {object} params - extra parameters
* @param {object} request - existing dictionary of request
* @param {string} exchangeSpecificKey - the key for chain id to be set in request
* @param {object} currencyCode - (optional) existing dictionary of request
* @param {boolean} isRequired - (optional) whether that param is required to be present
* @returns {object[]} - returns [request, params] where request is the modified request object and params is the modified params object
*/
fn handle_request_network(&self, mut params: Value, mut request: Value, mut exchangeSpecificKey: Value, optional_args: &[Value]) -> Value {
let mut currencyCode = get_arg(optional_args, 0, Value::Null);
let mut isRequired = get_arg(optional_args, 1, Value::Bool(false));
let mut networkCode: Value = Value::Null;
{ let __destr_tmp = self.handle_network_code_and_params(params.clone()); networkCode = get_value(&__destr_tmp, &Value::Int(0)); params = get_value(&__destr_tmp, &Value::Int(1)); }
if !is_equal(&networkCode, &Value::Null) {
add_element_to_object(&mut request, &exchangeSpecificKey, self.network_code_to_id(networkCode.clone(), &[currencyCode.clone()]));
} else if is_true(&isRequired) {
panic!("{}", crate::exchange_errors::arguments_required(add(&self.id, &Value::Str(" - \"network\" param is required for this request".to_string()))));
}
return Value::List(vec![request.clone(), params.clone()]);
Value::Null
}
fn resolve_path(&self, mut path: Value, mut params: Value) -> Value {
return Value::List(vec![self.implode_params(path.clone(), params.clone()), self.omit(params.clone(), self.extract_params(path.clone()), &[])]);
Value::Null
}
fn get_list_from_object_values(&self, mut objects: Value, mut key: Value) -> Value {
let mut newArray: Value = objects.clone();
if !is_true(&Value::Bool(is_array(&objects))) {
newArray = self.to_array(objects.clone());
}
let mut results: Value = Value::List(vec![]);
{
let mut i: Value = Value::Int(0);
let mut __for_first_127: bool = true;
while { if !__for_first_127 { i = add(&i, &Value::Int(1)); } __for_first_127 = false; is_less_than(&i, &get_array_length(&newArray)) } {
append_to_array(&mut results, get_value(&get_value(&newArray, &i), &key));
}
}
return results;
Value::Null
}
fn get_symbols_for_market_type(&self, optional_args: &[Value]) -> Value {
let mut marketType = get_arg(optional_args, 0, Value::Null);
let mut subType = get_arg(optional_args, 1, Value::Null);
let mut symbolWithActiveStatus = get_arg(optional_args, 2, Value::Bool(true));
let mut symbolWithUnknownStatus = get_arg(optional_args, 3, Value::Bool(true));
let mut filteredMarkets: Value = self.markets.clone();
if !is_equal(&marketType, &Value::Null) {
filteredMarkets = self.filter_by(filteredMarkets.clone(), Value::Str("type".to_string()), marketType.clone(), &[]);
}
if !is_equal(&subType, &Value::Null) {
self.check_required_argument(Value::Str("getSymbolsForMarketType".to_string()), subType.clone(), Value::Str("subType".to_string()), &[Value::List(vec![Value::Str("linear".to_string()), Value::Str("inverse".to_string()), Value::Str("quanto".to_string())])]);
filteredMarkets = self.filter_by(filteredMarkets.clone(), Value::Str("subType".to_string()), subType.clone(), &[]);
}
let mut activeStatuses: Value = Value::List(vec![]);
if is_true(&symbolWithActiveStatus) {
append_to_array(&mut activeStatuses, Value::Bool(true));
}
if is_true(&symbolWithUnknownStatus) {
append_to_array(&mut activeStatuses, Value::Null);
}
filteredMarkets = self.filter_by_array(filteredMarkets.clone(), Value::Str("active".to_string()), &[activeStatuses.clone(), Value::Bool(false)]);
return self.get_list_from_object_values(filteredMarkets.clone(), Value::Str("symbol".to_string()));
Value::Null
}
fn filter_by_array(&self, mut objects: Value, mut key: Value, optional_args: &[Value]) -> Value {
let mut values = get_arg(optional_args, 0, Value::Null);
let mut indexed = get_arg(optional_args, 1, Value::Bool(true));
objects = self.to_array(objects.clone());
// return all of them if no values were passed
if is_true(&(is_equal(&values, &Value::Null))) || is_true(&(is_equal(&values, &Value::Null))) || is_true(&(is_equal(&values, &Value::Bool(false)))) || is_true(&(is_equal(&values, &Value::Int(0)))) || is_true(&(is_equal(&values, &Value::Str("".to_string())))) {
// return indexed ? this.indexBy (objects, key) : objects;
if is_true(&indexed) {
return self.index_by(objects.clone(), key.clone());
} else {
return objects;
}
}
let mut results: Value = Value::List(vec![]);
{
let mut i: Value = Value::Int(0);
let mut __for_first_128: bool = true;
while { if !__for_first_128 { i = add(&i, &Value::Int(1)); } __for_first_128 = false; is_less_than(&i, &get_array_length(&objects)) } {
if is_true(&self.in_array(get_value(&get_value(&objects, &i), &key), values.clone())) {
append_to_array(&mut results, get_value(&objects, &i));
}
}
}
// return indexed ? this.indexBy (results, key) : results;
if is_true(&indexed) {
return self.index_by(results.clone(), key.clone());
}
return results;
Value::Null
}
fn filter_out_by_array(&self, mut objects: Value, mut key: Value, optional_args: &[Value]) -> Value {
let mut values = get_arg(optional_args, 0, Value::Null);
let mut indexed = get_arg(optional_args, 1, Value::Bool(true));
objects = self.to_array(objects.clone());
// return all of them if no values were passed
if is_true(&(is_equal(&values, &Value::Null))) || is_true(&(is_equal(&values, &Value::Null))) || is_true(&(is_equal(&values, &Value::Bool(false)))) || is_true(&(is_equal(&values, &Value::Int(0)))) || is_true(&(is_equal(&values, &Value::Str("".to_string())))) {
// return indexed ? this.indexBy (objects, key) : objects;
if is_true(&indexed) {
return self.index_by(objects.clone(), key.clone());
} else {
return objects;
}
}
let mut results: Value = Value::List(vec![]);
{
let mut i: Value = Value::Int(0);
let mut __for_first_129: bool = true;
while { if !__for_first_129 { i = add(&i, &Value::Int(1)); } __for_first_129 = false; is_less_than(&i, &get_array_length(&objects)) } {
if !is_true(&self.in_array(get_value(&get_value(&objects, &i), &key), values.clone())) {
append_to_array(&mut results, get_value(&objects, &i));
}
}
}
// return indexed ? this.indexBy (results, key) : results;
if is_true(&indexed) {
return self.index_by(results.clone(), key.clone());
}
return results;
Value::Null
}
fn fetch2(&mut self, mut path: Value, optional_args: &[Value]) -> impl ::std::future::Future<Output = Value> + Send { async move {
let mut api = get_arg(optional_args, 0, Value::Str("public".to_string()));
let mut method = get_arg(optional_args, 1, Value::Str("GET".to_string()));
let mut params = get_arg(optional_args, 2, Value::Map({
let mut m = indexmap::IndexMap::new();
m
}));
let mut headers = get_arg(optional_args, 3, Value::Null);
let mut body = get_arg(optional_args, 4, Value::Null);
let mut config = get_arg(optional_args, 5, Value::Map({
let mut m = indexmap::IndexMap::new();
m
}));
if is_true(&self.enableRateLimit) {
let mut cost: Value = self.calculate_rate_limiter_cost(api.clone(), method.clone(), path.clone(), params.clone(), &[config.clone()]);
self.throttle(&[cost.clone()]).await;
}
let mut retries: Value = Value::Int(0);
{ let __destr_tmp = self.handle_option_and_params(params.clone(), path.clone(), Value::Str("maxRetriesOnFailure".to_string()), &[retries.clone()]); retries = get_value(&__destr_tmp, &Value::Int(0)); params = get_value(&__destr_tmp, &Value::Int(1)); }
let mut retryDelay: Value = Value::Int(0);
{ let __destr_tmp = self.handle_option_and_params(params.clone(), path.clone(), Value::Str("maxRetriesOnFailureDelay".to_string()), &[retryDelay.clone()]); retryDelay = get_value(&__destr_tmp, &Value::Int(0)); params = get_value(&__destr_tmp, &Value::Int(1)); }
let mut fetchData: Value = Value::Null;
let mut fetchDataCacheEnabled: bool = is_greater_than(&self.fetchHistoryCacheSize, &Value::Int(0));
{
let mut i: Value = Value::Int(0);
let mut __for_first_130: bool = true;
while { if !__for_first_130 { i = add(&i, &Value::Int(1)); } __for_first_130 = false; is_less_than(&i, &add(&retries, &Value::Int(1))) } {
if is_true(&fetchDataCacheEnabled) {
fetchData = Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("request".to_string(), Value::Null);
m.insert("response".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("body".to_string(), Value::Null);
m
}));
m.insert("error".to_string(), Value::Null);
m
});
}
let _try_result = futures::FutureExt::catch_unwind(std::panic::AssertUnwindSafe(async {
self.set_last_rest_request_timestamp();
let mut request: Value = <Self as crate::exchange_generated::ExchangeBase>::sign(self, path.clone(), &[api.clone(), method.clone(), params.clone(), headers.clone(), body.clone()]);
if is_true(&fetchDataCacheEnabled) && is_true(&(!is_equal(&fetchData, &Value::Null))) {
add_element_to_object(&mut fetchData, &Value::Str("request".to_string()), request.clone());
}
self.set_last_request(request.clone());
let mut response: Value = self.fetch(get_value(&request, &Value::Str("url".to_string())), &[get_value(&request, &Value::Str("method".to_string())), get_value(&request, &Value::Str("headers".to_string())), get_value(&request, &Value::Str("body".to_string()))]).await;
if is_true(&fetchDataCacheEnabled) && is_true(&(!is_equal(&fetchData, &Value::Null))) {
add_element_to_object(get_value_mut(&mut fetchData, &Value::Str("response".to_string())), &Value::Str("body".to_string()), response.clone());
self.add_fetch_cache(fetchData.clone());
}
return response.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 e: Value = panic_to_value(_try_err);
if is_true(&fetchDataCacheEnabled) && is_true(&(!is_equal(&fetchData, &Value::Null))) {
add_element_to_object(&mut fetchData, &Value::Str("error".to_string()), e.clone());
self.add_fetch_cache(fetchData.clone());
}
if is_true(&is_instance(&e, &Value::Str("OperationFailed".to_string()))) {
if is_less_than(&i, &retries) {
if is_true(&self.verbose) {
let mut index: Value = add(&i, &Value::Int(1));
self.log(add(&add(&add(&add(&add(&add(&Value::Str("Request failed with the error: ".to_string()), &to_string_val(&e)), &Value::Str(", retrying ".to_string())), &to_string_val(&index)), &Value::Str(" of ".to_string())), &to_string_val(&retries)), &Value::Str("...".to_string())));
}
if is_true(&(!is_equal(&retryDelay, &Value::Null))) && is_true(&(!is_equal(&retryDelay, &Value::Int(0)))) {
self.sleep(retryDelay.clone()).await;
}
} else {
panic!("{}", e);
}
} else {
panic!("{}", e);
}
} }
}
}
return Value::Null;
Value::Null
} }
fn request(&mut self, mut path: Value, optional_args: &[Value]) -> impl ::std::future::Future<Output = Value> + Send { async move {
let mut api = get_arg(optional_args, 0, Value::Str("public".to_string()));
let mut method = get_arg(optional_args, 1, Value::Str("GET".to_string()));
let mut params = get_arg(optional_args, 2, Value::Map({
let mut m = indexmap::IndexMap::new();
m
}));
let mut headers = get_arg(optional_args, 3, Value::Null);
let mut body = get_arg(optional_args, 4, Value::Null);
let mut config = get_arg(optional_args, 5, Value::Map({
let mut m = indexmap::IndexMap::new();
m
}));
return self.fetch2(path.clone(), &[api.clone(), method.clone(), params.clone(), headers.clone(), body.clone(), config.clone()]).await;
Value::Null
} }
fn load_accounts(&mut self, optional_args: &[Value]) -> impl ::std::future::Future<Output = Value> + Send { async move {
let mut reload = get_arg(optional_args, 0, Value::Bool(false));
let mut params = get_arg(optional_args, 1, Value::Map({
let mut m = indexmap::IndexMap::new();
m
}));
if is_true(&reload) {
{ let __t = self.fetch_accounts(&[params.clone()]).await; self.accounts = __t; }
} else {
if !is_equal(&self.accounts, &Value::Null) {
return self.accounts.clone();
} else {
{ let __t = self.fetch_accounts(&[params.clone()]).await; self.accounts = __t; }
}
}
{ let __t = self.index_by(self.accounts.clone(), Value::Str("id".to_string())); self.accountsById = __t; }
return self.accounts.clone();
Value::Null
} }
fn build_ohlcvc(&self, mut trades: Value, optional_args: &[Value]) -> Value {
let mut timeframe = get_arg(optional_args, 0, Value::Str("1m".to_string()));
let mut since = get_arg(optional_args, 1, Value::Int(0));
let mut limit = get_arg(optional_args, 2, Value::Int(2147483647));
// given a sorted arrays of trades (recent last) and a timeframe builds an array of OHLCV candles
// note, default limit value (2147483647) is max int32 value
let mut ms: Value = multiply(&self.parse_timeframe(timeframe.clone()), &Value::Int(1000));
let mut ohlcvs: Value = Value::List(vec![]);
let mut i_timestamp: Value = Value::Int(0);
// const open = 1;
let mut i_high: Value = Value::Int(2);
let mut i_low: Value = Value::Int(3);
let mut i_close: Value = Value::Int(4);
let mut i_volume: Value = Value::Int(5);
let mut i_count: Value = Value::Int(6);
let mut tradesLength: Value = get_array_length(&trades);
let mut oldest: Value = crate::runtime::Math::min(&tradesLength, &limit);
let mut options: Value = self.safe_dict_k(self.options.clone(), "buildOHLCVC", &[Value::Map({
let mut m = indexmap::IndexMap::new();
m
})]);
let mut skipZeroPrices: Value = self.safe_bool_k(options.clone(), "skipZeroPrices", &[Value::Bool(true)]);
{
let mut i: Value = Value::Int(0);
let mut __for_first_131: bool = true;
while { if !__for_first_131 { i = add(&i, &Value::Int(1)); } __for_first_131 = false; is_less_than(&i, &oldest) } {
let mut trade: Value = get_value(&trades, &i);
let mut trade: Value = get_value(&trades, &i);
let mut ts: Value = get_value(&trade, &Value::Str("timestamp".to_string()));
let mut price: Value = get_value(&trade, &Value::Str("price".to_string()));
if is_true(&(is_equal(&ts, &Value::Null))) || is_true(&(is_equal(&price, &Value::Null))) {
continue;
}
if is_less_than(&ts, &since) {
continue;
}
if is_equal(&ts, &Value::Null) {
panic!("{}", crate::exchange_errors::exchange_error(add(&self.id, &Value::Str(" buildOHLCVC() missing ts".to_string()))));
}
let mut openingTime: Value = multiply(&math_floor(÷(&ts, &ms)), &ms); // shift to the edge of m/h/d (but not M)
if is_less_than(&openingTime, &since) {
continue;
}
let mut ohlcv_length: Value = get_array_length(&ohlcvs);
let mut candle: Value = subtract(&ohlcv_length, &Value::Int(1));
if is_equal(&price, &Value::Null) {
panic!("{}", crate::exchange_errors::arguments_required(add(&self.id, &Value::Str(" buildOHLCVC() requires a price argument".to_string()))));
}
if is_true(&(is_equal(&skipZeroPrices, &Value::Bool(true)))) && !is_true(&(is_greater_than(&price, &Value::Int(0)))) && !is_true(&(is_less_than(&price, &Value::Int(0)))) {
continue;
}
let mut isFirstCandle: bool = is_equal(&candle, &negate(&Value::Int(1)));
if is_true(&isFirstCandle) || is_greater_than_or_equal(&openingTime, &self.sum(&[get_value(&get_value(&ohlcvs, &candle), &i_timestamp), ms.clone()])) {
// moved to a new timeframe -> create a new candle from opening trade
append_to_array(&mut ohlcvs, Value::List(vec![openingTime.clone(), price.clone(), price.clone(), price.clone(), price.clone(), get_value(&trade, &Value::Str("amount".to_string())), Value::Int(1)]));
} else {
// still processing the same timeframe -> update opening trade
let mut prevHigh: Value = get_value(&get_value(&ohlcvs, &candle), &i_high);
let mut prevLow: Value = get_value(&get_value(&ohlcvs, &candle), &i_low);
let mut prevHighValue: Value = ternary(is_true(&(is_equal(&prevHigh, &Value::Null))), price.clone(), prevHigh.clone());
let mut prevLowValue: Value = ternary(is_true(&(is_equal(&prevLow, &Value::Null))), price.clone(), prevLow.clone());
add_element_to_object(get_value_mut(&mut ohlcvs, &candle), &i_high, crate::runtime::Math::max(&prevHighValue, &price));
add_element_to_object(get_value_mut(&mut ohlcvs, &candle), &i_low, crate::runtime::Math::min(&prevLowValue, &price));
add_element_to_object(get_value_mut(&mut ohlcvs, &candle), &i_close, price.clone());
{ let __be_tmp = self.sum(&[get_value(&get_value(&ohlcvs, &candle), &i_volume), get_value(&trade, &Value::Str("amount".to_string()))]); add_element_to_object(get_value_mut(&mut ohlcvs, &candle), &i_volume, __be_tmp); };
{ let __be_tmp = self.sum(&[get_value(&get_value(&ohlcvs, &candle), &i_count), Value::Int(1)]); add_element_to_object(get_value_mut(&mut ohlcvs, &candle), &i_count, __be_tmp); };
}
}
}
return ohlcvs;
Value::Null
}
fn parse_trading_view_ohlcv(&self, mut ohlcvs: Value, optional_args: &[Value]) -> Value {
let mut market = get_arg(optional_args, 0, Value::Null);
let mut timeframe = get_arg(optional_args, 1, Value::Str("1m".to_string()));
let mut since = get_arg(optional_args, 2, Value::Null);
let mut limit = get_arg(optional_args, 3, Value::Null);
let mut result: Value = self.convert_trading_view_to_ohlcv(ohlcvs.clone(), &[]);
return self.parse_ohlc_vs(result.clone(), &[market.clone(), timeframe.clone(), since.clone(), limit.clone()]);
Value::Null
}
fn fetch_borrow_interest(&mut self, optional_args: &[Value]) -> impl ::std::future::Future<Output = Value> + Send { async move {
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
}));
panic!("{}", crate::exchange_errors::not_supported(add(&self.id, &Value::Str(" fetchBorrowInterest() is not supported yet".to_string()))));
Value::Null
} }
fn fetch_ledger(&mut self, optional_args: &[Value]) -> impl ::std::future::Future<Output = Value> + Send { async move {
// async-virtual: try the derived exchange first
if let Some(__v) = self.dispatch_to_derived("fetch_ledger", { let mut __args: Vec<crate::Value> = Vec::new(); __args.extend_from_slice(optional_args); __args }).await {
if !matches!(__v, crate::Value::Null) { return __v; }
}
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
}));
panic!("{}", crate::exchange_errors::not_supported(add(&self.id, &Value::Str(" fetchLedger() is not supported yet".to_string()))));
Value::Null
} }
fn fetch_ledger_entry(&mut self, mut id: Value, optional_args: &[Value]) -> impl ::std::future::Future<Output = Value> + Send { async move {
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
}));
panic!("{}", crate::exchange_errors::not_supported(add(&self.id, &Value::Str(" fetchLedgerEntry() is not supported yet".to_string()))));
Value::Null
} }
fn parse_order_book_bid_ask(&self, mut bidask: Value, optional_args: &[Value]) -> Value {
let mut priceKey = get_arg(optional_args, 0, Value::Int(0));
let mut amountKey = get_arg(optional_args, 1, Value::Int(1));
let mut countOrIdKey = get_arg(optional_args, 2, Value::Int(2));
let mut price: Value = self.safe_float(bidask.clone(), priceKey.clone(), &[]);
let mut amount: Value = self.safe_float(bidask.clone(), amountKey.clone(), &[]);
let mut countOrId: Value = self.safe_integer(bidask.clone(), countOrIdKey.clone(), &[]);
let mut bidAsk: Value = Value::List(vec![price.clone(), amount.clone()]);
if !is_equal(&countOrId, &Value::Null) {
append_to_array(&mut bidAsk, countOrId.clone());
}
return bidAsk;
Value::Null
}
fn safe_currency(&self, mut currencyId: Value, optional_args: &[Value]) -> Value {
let mut currency = get_arg(optional_args, 0, Value::Null);
if is_true(&(is_equal(¤cyId, &Value::Null))) && is_true(&(!is_equal(¤cy, &Value::Null))) {
return currency;
}
if is_true(&(!is_equal(¤cyId, &Value::Null))) && is_true(&(!is_equal(&self.currencies_by_id, &Value::Null))) && is_true(&(Value::Bool(in_op(&self.currencies_by_id, ¤cyId)))) && is_true(&(!is_equal(&get_value(&self.currencies_by_id, ¤cyId), &Value::Null))) {
return get_value(&self.currencies_by_id, ¤cyId);
}
let mut code: Value = currencyId.clone();
if !is_equal(¤cyId, &Value::Null) {
code = self.common_currency_code(to_upper(¤cyId));
}
return self.safe_currency_structure(Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("id".to_string(), currencyId.clone());
m.insert("code".to_string(), code.clone());
m.insert("precision".to_string(), Value::Null);
m
}));
Value::Null
}
fn safe_market(&self, optional_args: &[Value]) -> Value {
let mut marketId = get_arg(optional_args, 0, Value::Null);
let mut market = get_arg(optional_args, 1, Value::Null);
let mut delimiter = get_arg(optional_args, 2, Value::Null);
let mut marketType = get_arg(optional_args, 3, Value::Null);
if !is_equal(&marketId, &Value::Null) {
if is_true(&(!is_equal(&self.markets_by_id, &Value::Null))) && is_true(&(Value::Bool(in_op(&self.markets_by_id, &marketId)))) {
let mut markets: Value = get_value(&self.markets_by_id, &marketId);
let mut numMarkets: Value = get_array_length(&markets);
if is_equal(&numMarkets, &Value::Int(1)) {
return get_value(&markets, &Value::Int(0));
} else {
if is_equal(&marketType, &Value::Null) {
if is_equal(&market, &Value::Null) {
panic!("{}", crate::exchange_errors::arguments_required(add(&add(&add(&self.id, &Value::Str(" safeMarket() requires a fourth argument for ".to_string())), &marketId), &Value::Str(" to disambiguate between different markets with the same market id".to_string()))));
} else {
marketType = get_value(&market, &Value::Str("type".to_string()));
}
}
{
let mut i: Value = Value::Int(0);
let mut __for_first_132: bool = true;
while { if !__for_first_132 { i = add(&i, &Value::Int(1)); } __for_first_132 = false; is_less_than(&i, &get_array_length(&markets)) } {
let mut currentMarket: Value = get_value(&markets, &i);
let mut currentMarket: Value = get_value(&markets, &i);
if is_equal(&get_value(¤tMarket, &marketType), &Value::Bool(true)) {
return currentMarket;
}
}
}
}
} else if !is_equal(&delimiter, &Value::Null) && !is_equal(&delimiter, &Value::Str("".to_string())) {
let mut parts: Value = split(&marketId, &delimiter);
let mut partsLength: Value = get_array_length(&parts);
let mut result: Value = self.safe_market_structure(&[Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("symbol".to_string(), marketId.clone());
m.insert("marketId".to_string(), marketId.clone());
m
})]);
if is_equal(&result, &Value::Null) {
panic!("{}", crate::exchange_errors::exchange_error(add(&self.id, &Value::Str(" safeMarket() failed to build market structure".to_string()))));
}
if is_equal(&partsLength, &Value::Int(2)) {
let mut baseId: Value = self.safe_string(parts.clone(), Value::Int(0), &[]);
let mut quoteId: Value = self.safe_string(parts.clone(), Value::Int(1), &[]);
let mut base: Value = self.safe_currency_code(baseId.clone(), &[]);
let mut quote: Value = self.safe_currency_code(quoteId.clone(), &[]);
add_element_to_object(&mut result, &Value::Str("baseId".to_string()), baseId.clone());
add_element_to_object(&mut result, &Value::Str("quoteId".to_string()), quoteId.clone());
if !is_equal(&base, &Value::Null) {
add_element_to_object(&mut result, &Value::Str("base".to_string()), base.clone());
}
if !is_equal("e, &Value::Null) {
add_element_to_object(&mut result, &Value::Str("quote".to_string()), quote.clone());
}
if is_true(&(!is_equal(&base, &Value::Null))) && is_true(&(!is_equal("e, &Value::Null))) {
add_element_to_object(&mut result, &Value::Str("symbol".to_string()), add(&add(&base, &Value::Str("/".to_string())), "e));
}
}
return result;
}
}
if !is_equal(&market, &Value::Null) {
return market;
}
let mut emptyMarket: Value = self.safe_market_structure(&[Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("symbol".to_string(), marketId.clone());
m.insert("marketId".to_string(), marketId.clone());
m
})]);
if is_equal(&emptyMarket, &Value::Null) {
panic!("{}", crate::exchange_errors::exchange_error(add(&self.id, &Value::Str(" safeMarket() failed to build market structure".to_string()))));
}
return emptyMarket;
Value::Null
}
fn market_or_null(&self, optional_args: &[Value]) -> Value {
let mut symbol = get_arg(optional_args, 0, Value::Null);
if is_equal(&symbol, &Value::Null) {
return Value::Null;
}
return self.market(symbol.clone());
Value::Null
}
fn check_required_credentials(&self, optional_args: &[Value]) -> Value {
let mut error = get_arg(optional_args, 0, Value::Bool(true));
/*
* @ignore
* @method
* @param {boolean} error throw an error that a credential is required if true
* @returns {boolean} true if all required credentials have been set, otherwise false or an error is thrown is param error=true
*/
let mut keys: Value = object_keys(&self.requiredCredentials);
{
let mut i: Value = Value::Int(0);
let mut __for_first_133: bool = true;
while { if !__for_first_133 { i = add(&i, &Value::Int(1)); } __for_first_133 = false; is_less_than(&i, &get_array_length(&keys)) } {
let mut key: Value = get_value(&keys, &i);
let mut key: Value = get_value(&keys, &i);
let mut credentialValue: Value = self.prop(&key);
let mut credentialMissing: bool = is_true(&(is_equal(&credentialValue, &Value::Null))) || is_true(&(is_equal(&credentialValue, &Value::Null))) || is_true(&(is_equal(&credentialValue, &Value::Bool(false)))) || is_true(&(is_equal(&credentialValue, &Value::Str("".to_string()))));
if is_true(&(is_equal(&get_value(&self.requiredCredentials, &key), &Value::Bool(true)))) && is_true(&credentialMissing) {
if is_true(&error) {
panic!("{}", crate::exchange_errors::authentication_error(add(&add(&add(&self.id, &Value::Str(" requires \"".to_string())), &key), &Value::Str("\" credential".to_string()))));
} else {
return Value::Bool(false);
}
}
}
}
return Value::Bool(true);
Value::Null
}
fn oath(&self) -> Value {
if !is_equal(&self.twofa, &Value::Null) {
return totp(self.twofa.clone());
} else {
panic!("{}", crate::exchange_errors::exchange_error(add(&self.id, &Value::Str(" exchange.twofa has not been set for 2FA Two-Factor Authentication".to_string()))));
}
Value::Null
}
fn fetch_balance(&mut self, optional_args: &[Value]) -> impl ::std::future::Future<Output = Value> + Send { async move {
// async-virtual: try the derived exchange first
if let Some(__v) = self.dispatch_to_derived("fetch_balance", { let mut __args: Vec<crate::Value> = Vec::new(); __args.extend_from_slice(optional_args); __args }).await {
if !matches!(__v, crate::Value::Null) { return __v; }
}
let mut params = get_arg(optional_args, 0, Value::Map({
let mut m = indexmap::IndexMap::new();
m
}));
panic!("{}", crate::exchange_errors::not_supported(add(&self.id, &Value::Str(" fetchBalance() is not supported yet".to_string()))));
Value::Null
} }
fn fetch_balance_ws(&mut self, optional_args: &[Value]) -> impl ::std::future::Future<Output = Value> + Send { async move {
let mut params = get_arg(optional_args, 0, Value::Map({
let mut m = indexmap::IndexMap::new();
m
}));
panic!("{}", crate::exchange_errors::not_supported(add(&self.id, &Value::Str(" fetchBalanceWs() is not supported yet".to_string()))));
Value::Null
} }
fn parse_balance(&self, mut response: Value) -> Value {
// virtual-dispatch (static: DerivedExchange::parse_balance(self, ...))
{ let __v = crate::exchange::DerivedExchange::parse_balance(self, response.clone()); if !matches!(__v, crate::Value::Null) { return __v; } }
panic!("{}", crate::exchange_errors::not_supported(add(&self.id, &Value::Str(" parseBalance() is not supported yet".to_string()))));
Value::Null
}
fn watch_balance(&mut self, optional_args: &[Value]) -> impl ::std::future::Future<Output = Value> + Send { async move {
let mut params = get_arg(optional_args, 0, Value::Map({
let mut m = indexmap::IndexMap::new();
m
}));
panic!("{}", crate::exchange_errors::not_supported(add(&self.id, &Value::Str(" watchBalance() is not supported yet".to_string()))));
Value::Null
} }
fn fetch_partial_balance(&mut self, mut part: Value, optional_args: &[Value]) -> impl ::std::future::Future<Output = Value> + Send { async move {
let mut params = get_arg(optional_args, 0, Value::Map({
let mut m = indexmap::IndexMap::new();
m
}));
let mut balance: Value = self.fetch_balance(&[params.clone()]).await;
return get_value(&balance, &part);
Value::Null
} }
fn fetch_free_balance(&mut self, optional_args: &[Value]) -> impl ::std::future::Future<Output = Value> + Send { async move {
let mut params = get_arg(optional_args, 0, Value::Map({
let mut m = indexmap::IndexMap::new();
m
}));
return self.fetch_partial_balance(Value::Str("free".to_string()), &[params.clone()]).await;
Value::Null
} }
fn fetch_used_balance(&mut self, optional_args: &[Value]) -> impl ::std::future::Future<Output = Value> + Send { async move {
let mut params = get_arg(optional_args, 0, Value::Map({
let mut m = indexmap::IndexMap::new();
m
}));
return self.fetch_partial_balance(Value::Str("used".to_string()), &[params.clone()]).await;
Value::Null
} }
fn fetch_total_balance(&mut self, optional_args: &[Value]) -> impl ::std::future::Future<Output = Value> + Send { async move {
let mut params = get_arg(optional_args, 0, Value::Map({
let mut m = indexmap::IndexMap::new();
m
}));
return self.fetch_partial_balance(Value::Str("total".to_string()), &[params.clone()]).await;
Value::Null
} }
fn fetch_status(&mut self, optional_args: &[Value]) -> impl ::std::future::Future<Output = Value> + Send { async move {
// async-virtual: try the derived exchange first
if let Some(__v) = self.dispatch_to_derived("fetch_status", { let mut __args: Vec<crate::Value> = Vec::new(); __args.extend_from_slice(optional_args); __args }).await {
if !matches!(__v, crate::Value::Null) { return __v; }
}
let mut params = get_arg(optional_args, 0, Value::Map({
let mut m = indexmap::IndexMap::new();
m
}));
panic!("{}", crate::exchange_errors::not_supported(add(&self.id, &Value::Str(" fetchStatus() is not supported yet".to_string()))));
Value::Null
} }
fn fetch_transaction_fee(&mut self, mut code: Value, optional_args: &[Value]) -> impl ::std::future::Future<Output = Value> + Send { async move {
let mut params = get_arg(optional_args, 0, Value::Map({
let mut m = indexmap::IndexMap::new();
m
}));
if is_equal(&get_value(&self.has, &Value::Str("fetchTransactionFees".to_string())), &Value::Null) || is_equal(&get_value(&self.has, &Value::Str("fetchTransactionFees".to_string())), &Value::Bool(false)) {
panic!("{}", crate::exchange_errors::not_supported(add(&self.id, &Value::Str(" fetchTransactionFee() is not supported yet".to_string()))));
}
return self.fetch_transaction_fees(&[Value::List(vec![code.clone()]), params.clone()]).await;
Value::Null
} }
fn fetch_transaction_fees(&mut self, optional_args: &[Value]) -> impl ::std::future::Future<Output = Value> + Send { async move {
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
}));
panic!("{}", crate::exchange_errors::not_supported(add(&self.id, &Value::Str(" fetchTransactionFees() is not supported yet".to_string()))));
Value::Null
} }
fn fetch_deposit_withdraw_fees(&mut self, optional_args: &[Value]) -> impl ::std::future::Future<Output = Value> + Send { async move {
// async-virtual: try the derived exchange first
if let Some(__v) = self.dispatch_to_derived("fetch_deposit_withdraw_fees", { let mut __args: Vec<crate::Value> = Vec::new(); __args.extend_from_slice(optional_args); __args }).await {
if !matches!(__v, crate::Value::Null) { return __v; }
}
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
}));
panic!("{}", crate::exchange_errors::not_supported(add(&self.id, &Value::Str(" fetchDepositWithdrawFees() is not supported yet".to_string()))));
Value::Null
} }
fn fetch_deposit_withdraw_fee(&mut self, mut code: Value, optional_args: &[Value]) -> impl ::std::future::Future<Output = Value> + Send { async move {
// async-virtual: try the derived exchange first
if let Some(__v) = self.dispatch_to_derived("fetch_deposit_withdraw_fee", { let mut __args: Vec<crate::Value> = Vec::new(); __args.push(code.clone()); __args.extend_from_slice(optional_args); __args }).await {
if !matches!(__v, crate::Value::Null) { return __v; }
}
let mut params = get_arg(optional_args, 0, Value::Map({
let mut m = indexmap::IndexMap::new();
m
}));
if is_equal(&get_value(&self.has, &Value::Str("fetchDepositWithdrawFees".to_string())), &Value::Null) || is_equal(&get_value(&self.has, &Value::Str("fetchDepositWithdrawFees".to_string())), &Value::Bool(false)) {
panic!("{}", crate::exchange_errors::not_supported(add(&self.id, &Value::Str(" fetchDepositWithdrawFee() is not supported yet".to_string()))));
}
let mut fees: Value = self.fetch_deposit_withdraw_fees(&[Value::List(vec![code.clone()]), params.clone()]).await;
return self.safe_value(fees.clone(), code.clone(), &[]);
Value::Null
} }
fn get_supported_mapping(&self, mut key: Value, optional_args: &[Value]) -> Value {
let mut mapping = get_arg(optional_args, 0, Value::Map({
let mut m = indexmap::IndexMap::new();
m
}));
if is_true(&Value::Bool(in_op(&mapping, &key))) {
return get_value(&mapping, &key);
} else {
panic!("{}", crate::exchange_errors::not_supported(add(&add(&add(&self.id, &Value::Str(" ".to_string())), &key), &Value::Str(" does not have a value in mapping".to_string()))));
}
Value::Null
}
fn fetch_cross_borrow_rate(&mut self, mut code: Value, optional_args: &[Value]) -> impl ::std::future::Future<Output = Value> + Send { async move {
let mut params = get_arg(optional_args, 0, Value::Map({
let mut m = indexmap::IndexMap::new();
m
}));
self.load_markets(&[]).await;
if is_equal(&get_value(&self.has, &Value::Str("fetchBorrowRates".to_string())), &Value::Null) || is_equal(&get_value(&self.has, &Value::Str("fetchBorrowRates".to_string())), &Value::Bool(false)) {
panic!("{}", crate::exchange_errors::not_supported(add(&self.id, &Value::Str(" fetchCrossBorrowRate() is not supported yet".to_string()))));
}
let mut borrowRates: Value = self.fetch_cross_borrow_rates(&[params.clone()]).await;
let mut rate: Value = self.safe_value(borrowRates.clone(), code.clone(), &[]);
if is_equal(&rate, &Value::Null) {
panic!("{}", crate::exchange_errors::exchange_error(add(&add(&self.id, &Value::Str(" fetchCrossBorrowRate() could not find the borrow rate for currency code ".to_string())), &code)));
}
return rate;
Value::Null
} }
fn fetch_isolated_borrow_rate(&mut self, mut symbol: Value, optional_args: &[Value]) -> impl ::std::future::Future<Output = Value> + Send { async move {
let mut params = get_arg(optional_args, 0, Value::Map({
let mut m = indexmap::IndexMap::new();
m
}));
self.load_markets(&[]).await;
if is_equal(&get_value(&self.has, &Value::Str("fetchBorrowRates".to_string())), &Value::Null) || is_equal(&get_value(&self.has, &Value::Str("fetchBorrowRates".to_string())), &Value::Bool(false)) {
panic!("{}", crate::exchange_errors::not_supported(add(&self.id, &Value::Str(" fetchIsolatedBorrowRate() is not supported yet".to_string()))));
}
let mut borrowRates: Value = self.fetch_isolated_borrow_rates(&[params.clone()]).await;
let mut rate: Value = self.safe_dict(borrowRates.clone(), symbol.clone(), &[]);
if is_equal(&rate, &Value::Null) {
panic!("{}", crate::exchange_errors::exchange_error(add(&add(&self.id, &Value::Str(" fetchIsolatedBorrowRate() could not find the borrow rate for market symbol ".to_string())), &symbol)));
}
return rate;
Value::Null
} }
/* eslint-disable no-unused-vars */
/* eslint-enable no-unused-vars */
fn require_value(&self, mut value: Value, optional_args: &[Value]) -> Value {
let mut message = get_arg(optional_args, 0, Value::Null);
if is_equal(&value, &Value::Null) {
let mut errorMessage: Value = ternary(is_true(&(!is_equal(&message, &Value::Null))), message.clone(), Value::Str("value is required".to_string()));
panic!("{}", crate::exchange_errors::arguments_required(add(&add(&self.id, &Value::Str(" ".to_string())), &errorMessage)));
}
return value;
Value::Null
}
/* eslint-disable no-unused-vars */
/* eslint-enable no-unused-vars */
fn handle_option_and_params(&self, mut params: Value, mut methodName: Value, mut optionName: Value, optional_args: &[Value]) -> Value {
let mut defaultValue = get_arg(optional_args, 0, Value::Null);
// This method can be used to obtain method specific properties, i.e: this.handleOptionAndParams (params, 'fetchPosition', 'marginMode', 'isolated')
let mut defaultOptionName: Value = add(&Value::Str("default".to_string()), &self.capitalize(optionName.clone())); // we also need to check the 'defaultXyzWhatever'
// check if params contain the key
let mut value: Value = self.safe_value2(params.clone(), optionName.clone(), defaultOptionName.clone(), &[]);
if !is_equal(&value, &Value::Null) {
params = self.omit(params.clone(), Value::List(vec![optionName.clone(), defaultOptionName.clone()]), &[]);
} else {
// handle routed methods like "watchTrades > watchTradesForSymbols" (or "watchTicker > watchTickers")
{ let __destr_tmp = self.handle_param_string(params.clone(), Value::Str("callerMethodName".to_string()), &[methodName.clone()]); methodName = get_value(&__destr_tmp, &Value::Int(0)); params = get_value(&__destr_tmp, &Value::Int(1)); }
// check if exchange has properties for this method
let mut exchangeWideMethodOptions: Value = self.safe_value(self.options.clone(), methodName.clone(), &[]);
if !is_equal(&exchangeWideMethodOptions, &Value::Null) {
// check if the option is defined inside this method's props
value = self.safe_value2(exchangeWideMethodOptions.clone(), optionName.clone(), defaultOptionName.clone(), &[]);
}
if is_equal(&value, &Value::Null) {
// if it's still undefined, check if global exchange-wide option exists
value = self.safe_value2(self.options.clone(), optionName.clone(), defaultOptionName.clone(), &[]);
}
// if it's still undefined, use the default value
value = ternary(is_true(&(!is_equal(&value, &Value::Null))), value.clone(), defaultValue.clone());
}
return Value::List(vec![value.clone(), params.clone()]);
Value::Null
}
/* eslint-disable no-unused-vars */
/* eslint-enable no-unused-vars */
fn handle_option_and_params2(&self, mut params: Value, mut methodName1: Value, mut optionName1: Value, mut optionName2: Value, optional_args: &[Value]) -> Value {
let mut defaultValue = get_arg(optional_args, 0, Value::Null);
let mut value: Value = Value::Null;
{ let __destr_tmp = self.handle_option_and_params(params.clone(), methodName1.clone(), optionName1.clone(), &[]); value = get_value(&__destr_tmp, &Value::Int(0)); params = get_value(&__destr_tmp, &Value::Int(1)); }
if !is_equal(&value, &Value::Null) {
// omit optionName2 too from params
params = self.omit(params.clone(), optionName2.clone(), &[]);
return Value::List(vec![value.clone(), params.clone()]);
}
// if still undefined, try optionName2
let mut value2: Value = Value::Null;
{ let __destr_tmp = self.handle_option_and_params(params.clone(), methodName1.clone(), optionName2.clone(), &[defaultValue.clone()]); value2 = get_value(&__destr_tmp, &Value::Int(0)); params = get_value(&__destr_tmp, &Value::Int(1)); }
return Value::List(vec![value2.clone(), params.clone()]);
Value::Null
}
fn handle_option(&self, mut methodName: Value, mut optionName: Value, optional_args: &[Value]) -> Value {
let mut defaultValue = get_arg(optional_args, 0, Value::Null);
let mut res: Value = self.handle_option_and_params(Value::Map({
let mut m = indexmap::IndexMap::new();
m
}), methodName.clone(), optionName.clone(), &[defaultValue.clone()]);
return self.safe_value(res.clone(), Value::Int(0), &[]);
Value::Null
}
fn handle_market_type_and_params(&self, mut methodName: Value, optional_args: &[Value]) -> Value {
let mut market = get_arg(optional_args, 0, Value::Null);
let mut params = get_arg(optional_args, 1, Value::Map({
let mut m = indexmap::IndexMap::new();
m
}));
let mut defaultValue = get_arg(optional_args, 2, Value::Null);
/*
* @ignore
* @method
* @name exchange#handleMarketTypeAndParams
* @param methodName the method calling handleMarketTypeAndParams
* @param {Market} market
* @param {object} params
* @param {string} [params.type] type assigned by user
* @param {string} [params.defaultType] same as params.type
* @param {string} [defaultValue] assigned programatically in the method calling handleMarketTypeAndParams
* @returns {[string, object]} the market type and params with type and defaultType omitted
*/
// type from param
let mut type_var: Value = self.safe_string2(params.clone(), Value::Str("defaultType".to_string()), Value::Str("type".to_string()), &[]);
if !is_equal(&type_var, &Value::Null) {
params = self.omit(params.clone(), Value::List(vec![Value::Str("defaultType".to_string()), Value::Str("type".to_string())]), &[]);
return Value::List(vec![type_var.clone(), params.clone()]);
}
// type from market
if !is_equal(&market, &Value::Null) {
return Value::List(vec![get_value(&market, &Value::Str("type".to_string())), params.clone()]);
}
// type from default-argument
if !is_equal(&defaultValue, &Value::Null) {
return Value::List(vec![defaultValue.clone(), params.clone()]);
}
let mut methodOptions: Value = self.safe_dict(self.options.clone(), methodName.clone(), &[]);
if !is_equal(&methodOptions, &Value::Null) {
if is_string(&methodOptions) {
return Value::List(vec![methodOptions.clone(), params.clone()]);
} else {
let mut typeFromMethod: Value = self.safe_string2(methodOptions.clone(), Value::Str("defaultType".to_string()), Value::Str("type".to_string()), &[]);
if !is_equal(&typeFromMethod, &Value::Null) {
return Value::List(vec![typeFromMethod.clone(), params.clone()]);
}
}
}
let mut defaultType: Value = self.safe_string2(self.options.clone(), Value::Str("defaultType".to_string()), Value::Str("type".to_string()), &[Value::Str("spot".to_string())]);
return Value::List(vec![defaultType.clone(), params.clone()]);
Value::Null
}
fn handle_sub_type_and_params(&self, mut methodName: Value, optional_args: &[Value]) -> Value {
let mut market = get_arg(optional_args, 0, Value::Null);
let mut params = get_arg(optional_args, 1, Value::Map({
let mut m = indexmap::IndexMap::new();
m
}));
let mut defaultValue = get_arg(optional_args, 2, Value::Null);
let mut subType: Value = Value::Null;
// if set in params, it takes precedence
let mut subTypeInParams: Value = self.safe_string2(params.clone(), Value::Str("subType".to_string()), Value::Str("defaultSubType".to_string()), &[]);
// avoid omitting if it's not present
if !is_equal(&subTypeInParams, &Value::Null) {
if is_true(&(is_equal(&subTypeInParams, &Value::Str("linear".to_string())))) || is_true(&(is_equal(&subTypeInParams, &Value::Str("inverse".to_string())))) {
subType = subTypeInParams.clone();
}
params = self.omit(params.clone(), Value::List(vec![Value::Str("subType".to_string()), Value::Str("defaultSubType".to_string())]), &[]);
} else {
// at first, check from market object
if !is_equal(&market, &Value::Null) {
if is_equal(&get_value(&market, &Value::Str("linear".to_string())), &Value::Bool(true)) {
subType = Value::Str("linear".to_string());
} else if is_equal(&get_value(&market, &Value::Str("inverse".to_string())), &Value::Bool(true)) {
subType = Value::Str("inverse".to_string());
}
}
// if it was not defined in market object
if is_equal(&subType, &Value::Null) {
let mut values: Value = self.handle_option_and_params(Value::Map({
let mut m = indexmap::IndexMap::new();
m
}), methodName.clone(), Value::Str("subType".to_string()), &[defaultValue.clone()]); // no need to re-test params here
subType = get_value(&values, &Value::Int(0));
}
}
return Value::List(vec![subType.clone(), params.clone()]);
Value::Null
}
fn handle_margin_mode_and_params(&self, mut methodName: Value, optional_args: &[Value]) -> Value {
let mut params = get_arg(optional_args, 0, Value::Map({
let mut m = indexmap::IndexMap::new();
m
}));
let mut defaultValue = get_arg(optional_args, 1, Value::Null);
return self.handle_option_and_params(params.clone(), methodName.clone(), Value::Str("marginMode".to_string()), &[defaultValue.clone()]);
Value::Null
}
fn throw_exactly_matched_exception(&self, mut exact: Value, mut string: Value, mut message: Value) {
if is_equal(&string, &Value::Null) {
return;
}
if is_true(&Value::Bool(in_op(&exact, &string))) {
panic!("{}", crate::exchange_errors::create_error(&crate::runtime::stringify_param(&(get_value(&exact, &string))), &crate::runtime::stringify_param(&(message))));
}
}
fn throw_broadly_matched_exception(&self, mut broad: Value, mut string: Value, mut message: Value) {
let mut broadKey: Value = self.find_broadly_matched_key(broad.clone(), string.clone());
if !is_equal(&broadKey, &Value::Null) {
panic!("{}", crate::exchange_errors::create_error(&crate::runtime::stringify_param(&(get_value(&broad, &broadKey))), &crate::runtime::stringify_param(&(message))));
}
}
fn find_broadly_matched_key(&self, mut broad: Value, mut string: Value) -> Value {
// a helper for matching error strings exactly vs broadly
let mut keys: Value = object_keys(&broad);
{
let mut i: Value = Value::Int(0);
let mut __for_first_134: bool = true;
while { if !__for_first_134 { i = add(&i, &Value::Int(1)); } __for_first_134 = false; is_less_than(&i, &get_array_length(&keys)) } {
let mut key: Value = get_value(&keys, &i);
let mut key: Value = get_value(&keys, &i);
if !is_equal(&string, &Value::Null) {
if is_greater_than_or_equal(&get_index_of(&string, &key), &Value::Int(0)) {
return key;
}
}
}
}
return Value::Null;
Value::Null
}
fn handle_errors(&self, mut statusCode: Value, mut statusText: Value, mut url: Value, mut method: Value, mut responseHeaders: Value, mut responseBody: Value, mut response: Value, mut requestHeaders: Value, mut requestBody: Value) -> Value {
// virtual-dispatch (static: DerivedExchange::handle_errors(self, ...))
{ let __v = crate::exchange::DerivedExchange::handle_errors(self, statusCode.clone(), statusText.clone(), url.clone(), method.clone(), responseHeaders.clone(), responseBody.clone(), response.clone(), requestHeaders.clone(), requestBody.clone()); if !matches!(__v, crate::Value::Null) { return __v; } }
return Value::Null;
Value::Null
}
fn calculate_rate_limiter_cost(&self, mut api: Value, mut method: Value, mut path: Value, mut params: Value, optional_args: &[Value]) -> Value {
let mut config = get_arg(optional_args, 0, Value::Map({
let mut m = indexmap::IndexMap::new();
m
}));
return self.safe_value_k(config.clone(), "cost", &[Value::Int(1)]);
Value::Null
}
fn fetch_spot_tickers(&mut self, optional_args: &[Value]) -> impl ::std::future::Future<Output = Value> + Send { async move {
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
}));
panic!("{}", crate::exchange_errors::not_supported(add(&self.id, &Value::Str(" fetchSpotTickers() is not supported yet".to_string()))));
Value::Null
} }
fn fetch_contract_tickers(&mut self, optional_args: &[Value]) -> impl ::std::future::Future<Output = Value> + Send { async move {
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
}));
panic!("{}", crate::exchange_errors::not_supported(add(&self.id, &Value::Str(" fetchContractTickers() is not supported yet".to_string()))));
Value::Null
} }
fn fetch_order_books(&mut self, optional_args: &[Value]) -> impl ::std::future::Future<Output = Value> + Send { async move {
let mut symbols = 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
}));
panic!("{}", crate::exchange_errors::not_supported(add(&self.id, &Value::Str(" fetchOrderBooks() is not supported yet".to_string()))));
Value::Null
} }
fn un_watch_tickers(&mut self, optional_args: &[Value]) -> impl ::std::future::Future<Output = Value> + Send { async move {
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
}));
panic!("{}", crate::exchange_errors::not_supported(add(&self.id, &Value::Str(" unWatchTickers() is not supported yet".to_string()))));
Value::Null
} }
fn un_watch_funding_rate(&mut self, mut symbol: Value, optional_args: &[Value]) -> impl ::std::future::Future<Output = Value> + Send { async move {
let mut params = get_arg(optional_args, 0, Value::Map({
let mut m = indexmap::IndexMap::new();
m
}));
panic!("{}", crate::exchange_errors::not_supported(add(&self.id, &Value::Str(" unWatchFundingRate() is not supported yet".to_string()))));
Value::Null
} }
fn create_twap_order(&mut self, mut symbol: Value, mut side: Value, mut amount: Value, mut duration: Value, optional_args: &[Value]) -> impl ::std::future::Future<Output = Value> + Send { async move {
let mut params = get_arg(optional_args, 0, Value::Map({
let mut m = indexmap::IndexMap::new();
m
}));
panic!("{}", crate::exchange_errors::not_supported(add(&self.id, &Value::Str(" createTwapOrder() is not supported yet".to_string()))));
Value::Null
} }
fn create_convert_trade(&mut self, mut id: Value, mut fromCode: Value, mut toCode: Value, optional_args: &[Value]) -> impl ::std::future::Future<Output = Value> + Send { async move {
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
}));
panic!("{}", crate::exchange_errors::not_supported(add(&self.id, &Value::Str(" createConvertTrade() is not supported yet".to_string()))));
Value::Null
} }
fn fetch_convert_trade(&mut self, mut id: Value, optional_args: &[Value]) -> impl ::std::future::Future<Output = Value> + Send { async move {
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
}));
panic!("{}", crate::exchange_errors::not_supported(add(&self.id, &Value::Str(" fetchConvertTrade() is not supported yet".to_string()))));
Value::Null
} }
fn fetch_convert_trade_history(&mut self, optional_args: &[Value]) -> impl ::std::future::Future<Output = Value> + Send { async move {
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
}));
panic!("{}", crate::exchange_errors::not_supported(add(&self.id, &Value::Str(" fetchConvertTradeHistory() is not supported yet".to_string()))));
Value::Null
} }
fn fetch_position_mode(&mut self, optional_args: &[Value]) -> impl ::std::future::Future<Output = Value> + Send { async move {
// async-virtual: try the derived exchange first
if let Some(__v) = self.dispatch_to_derived("fetch_position_mode", { let mut __args: Vec<crate::Value> = Vec::new(); __args.extend_from_slice(optional_args); __args }).await {
if !matches!(__v, crate::Value::Null) { return __v; }
}
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
}));
panic!("{}", crate::exchange_errors::not_supported(add(&self.id, &Value::Str(" fetchPositionMode() is not supported yet".to_string()))));
Value::Null
} }
fn fetch_adl_rank(&mut self, mut symbol: Value, optional_args: &[Value]) -> impl ::std::future::Future<Output = Value> + Send { async move {
let mut params = get_arg(optional_args, 0, Value::Map({
let mut m = indexmap::IndexMap::new();
m
}));
panic!("{}", crate::exchange_errors::not_supported(add(&self.id, &Value::Str(" fetchADLRank() is not supported yet".to_string()))));
Value::Null
} }
fn fetch_positions_adl_rank(&mut self, optional_args: &[Value]) -> impl ::std::future::Future<Output = Value> + Send { async move {
// async-virtual: try the derived exchange first
if let Some(__v) = self.dispatch_to_derived("fetch_positions_adl_rank", { let mut __args: Vec<crate::Value> = Vec::new(); __args.extend_from_slice(optional_args); __args }).await {
if !matches!(__v, crate::Value::Null) { return __v; }
}
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
}));
panic!("{}", crate::exchange_errors::not_supported(add(&self.id, &Value::Str(" fetchPositionsADLRank() is not supported yet".to_string()))));
Value::Null
} }
fn fetch_position_adl_rank(&mut self, mut symbol: Value, optional_args: &[Value]) -> impl ::std::future::Future<Output = Value> + Send { async move {
// async-virtual: try the derived exchange first
if let Some(__v) = self.dispatch_to_derived("fetch_position_adl_rank", { let mut __args: Vec<crate::Value> = Vec::new(); __args.push(symbol.clone()); __args.extend_from_slice(optional_args); __args }).await {
if !matches!(__v, crate::Value::Null) { return __v; }
}
let mut params = get_arg(optional_args, 0, Value::Map({
let mut m = indexmap::IndexMap::new();
m
}));
if !is_equal(&get_value(&self.has, &Value::Str("fetchPositionsADLRank".to_string())), &Value::Null) && !is_equal(&get_value(&self.has, &Value::Str("fetchPositionsADLRank".to_string())), &Value::Bool(false)) {
self.load_markets(&[]).await;
let mut market: Value = self.market(symbol.clone());
symbol = get_value(&market, &Value::Str("symbol".to_string()));
let mut ranks: Value = self.fetch_positions_adl_rank(&[Value::List(vec![symbol.clone()]), params.clone()]).await;
let mut rank: Value = self.safe_dict(ranks.clone(), Value::Int(0), &[]);
if is_equal(&rank, &Value::Null) {
panic!("{}", crate::exchange_errors::null_response(add(&add(&self.id, &Value::Str(" fetchPositionsADLRank() could not find a rank for ".to_string())), &symbol)));
} else {
return rank;
}
} else {
panic!("{}", crate::exchange_errors::not_supported(add(&self.id, &Value::Str(" fetchPositionsADLRank() is not supported yet".to_string()))));
}
Value::Null
} }
fn set_take_profit_and_stop_loss_params(&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 takeProfit = get_arg(optional_args, 1, Value::Null);
let mut stopLoss = get_arg(optional_args, 2, Value::Null);
let mut params = get_arg(optional_args, 3, Value::Map({
let mut m = indexmap::IndexMap::new();
m
}));
if is_true(&(is_equal(&takeProfit, &Value::Null))) && is_true(&(is_equal(&stopLoss, &Value::Null))) {
panic!("{}", crate::exchange_errors::arguments_required(add(&self.id, &Value::Str(" createOrderWithTakeProfitAndStopLoss() requires either a takeProfit or stopLoss argument".to_string()))));
}
if !is_equal(&takeProfit, &Value::Null) {
add_element_to_object(&mut params, &Value::Str("takeProfit".to_string()), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("triggerPrice".to_string(), takeProfit.clone());
m
}));
}
if !is_equal(&stopLoss, &Value::Null) {
add_element_to_object(&mut params, &Value::Str("stopLoss".to_string()), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("triggerPrice".to_string(), stopLoss.clone());
m
}));
}
let mut takeProfitType: Value = self.safe_string_k(params.clone(), "takeProfitType", &[]);
let mut takeProfitPriceType: Value = self.safe_string_k(params.clone(), "takeProfitPriceType", &[]);
let mut takeProfitLimitPrice: Value = self.safe_string_k(params.clone(), "takeProfitLimitPrice", &[]);
let mut takeProfitAmount: Value = self.safe_string_k(params.clone(), "takeProfitAmount", &[]);
let mut stopLossType: Value = self.safe_string_k(params.clone(), "stopLossType", &[]);
let mut stopLossPriceType: Value = self.safe_string_k(params.clone(), "stopLossPriceType", &[]);
let mut stopLossLimitPrice: Value = self.safe_string_k(params.clone(), "stopLossLimitPrice", &[]);
let mut stopLossAmount: Value = self.safe_string_k(params.clone(), "stopLossAmount", &[]);
if !is_equal(&takeProfitType, &Value::Null) {
add_element_to_object(get_value_mut(&mut params, &Value::Str("takeProfit".to_string())), &Value::Str("type".to_string()), takeProfitType.clone());
}
if !is_equal(&takeProfitPriceType, &Value::Null) {
add_element_to_object(get_value_mut(&mut params, &Value::Str("takeProfit".to_string())), &Value::Str("priceType".to_string()), takeProfitPriceType.clone());
}
if !is_equal(&takeProfitLimitPrice, &Value::Null) {
add_element_to_object(get_value_mut(&mut params, &Value::Str("takeProfit".to_string())), &Value::Str("price".to_string()), self.parse_to_numeric(takeProfitLimitPrice.clone()));
}
if !is_equal(&takeProfitAmount, &Value::Null) {
add_element_to_object(get_value_mut(&mut params, &Value::Str("takeProfit".to_string())), &Value::Str("amount".to_string()), self.parse_to_numeric(takeProfitAmount.clone()));
}
if !is_equal(&stopLossType, &Value::Null) {
add_element_to_object(get_value_mut(&mut params, &Value::Str("stopLoss".to_string())), &Value::Str("type".to_string()), stopLossType.clone());
}
if !is_equal(&stopLossPriceType, &Value::Null) {
add_element_to_object(get_value_mut(&mut params, &Value::Str("stopLoss".to_string())), &Value::Str("priceType".to_string()), stopLossPriceType.clone());
}
if !is_equal(&stopLossLimitPrice, &Value::Null) {
add_element_to_object(get_value_mut(&mut params, &Value::Str("stopLoss".to_string())), &Value::Str("price".to_string()), self.parse_to_numeric(stopLossLimitPrice.clone()));
}
if !is_equal(&stopLossAmount, &Value::Null) {
add_element_to_object(get_value_mut(&mut params, &Value::Str("stopLoss".to_string())), &Value::Str("amount".to_string()), self.parse_to_numeric(stopLossAmount.clone()));
}
params = self.omit(params.clone(), Value::List(vec![Value::Str("takeProfitType".to_string()), Value::Str("takeProfitPriceType".to_string()), Value::Str("takeProfitLimitPrice".to_string()), Value::Str("takeProfitAmount".to_string()), Value::Str("stopLossType".to_string()), Value::Str("stopLossPriceType".to_string()), Value::Str("stopLossLimitPrice".to_string()), Value::Str("stopLossAmount".to_string())]), &[]);
return params;
Value::Null
}
fn create_spot_orders(&mut self, mut orders: Value, optional_args: &[Value]) -> impl ::std::future::Future<Output = Value> + Send { async move {
let mut params = get_arg(optional_args, 0, Value::Map({
let mut m = indexmap::IndexMap::new();
m
}));
panic!("{}", crate::exchange_errors::not_supported(add(&self.id, &Value::Str(" createSpotOrders() is not supported yet".to_string()))));
Value::Null
} }
fn create_contract_orders(&mut self, mut orders: Value, optional_args: &[Value]) -> impl ::std::future::Future<Output = Value> + Send { async move {
let mut params = get_arg(optional_args, 0, Value::Map({
let mut m = indexmap::IndexMap::new();
m
}));
panic!("{}", crate::exchange_errors::not_supported(add(&self.id, &Value::Str(" createContractOrders() is not supported yet".to_string()))));
Value::Null
} }
fn cancel_spot_order(&mut self, mut id: Value, optional_args: &[Value]) -> impl ::std::future::Future<Output = Value> + Send { async move {
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
}));
panic!("{}", crate::exchange_errors::not_supported(add(&self.id, &Value::Str(" cancelSpotOrder() is not supported yet".to_string()))));
Value::Null
} }
fn cancel_contract_order(&mut self, mut id: Value, optional_args: &[Value]) -> impl ::std::future::Future<Output = Value> + Send { async move {
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
}));
panic!("{}", crate::exchange_errors::not_supported(add(&self.id, &Value::Str(" cancelContractOrder() is not supported yet".to_string()))));
Value::Null
} }
fn cancel_all_spot_orders(&mut self, optional_args: &[Value]) -> impl ::std::future::Future<Output = Value> + Send { async move {
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
}));
panic!("{}", crate::exchange_errors::not_supported(add(&self.id, &Value::Str(" cancelAllSpotOrders() is not supported yet".to_string()))));
Value::Null
} }
fn cancel_all_contract_orders(&mut self, optional_args: &[Value]) -> impl ::std::future::Future<Output = Value> + Send { async move {
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
}));
panic!("{}", crate::exchange_errors::not_supported(add(&self.id, &Value::Str(" cancelAllContractOrders() is not supported yet".to_string()))));
Value::Null
} }
fn cancel_all_orders_after(&mut self, mut timeout: Value, optional_args: &[Value]) -> impl ::std::future::Future<Output = Value> + Send { async move {
let mut params = get_arg(optional_args, 0, Value::Map({
let mut m = indexmap::IndexMap::new();
m
}));
panic!("{}", crate::exchange_errors::not_supported(add(&self.id, &Value::Str(" cancelAllOrdersAfter() is not supported yet".to_string()))));
Value::Null
} }
fn cancel_orders_for_symbols(&mut self, mut orders: Value, optional_args: &[Value]) -> impl ::std::future::Future<Output = Value> + Send { async move {
let mut params = get_arg(optional_args, 0, Value::Map({
let mut m = indexmap::IndexMap::new();
m
}));
panic!("{}", crate::exchange_errors::not_supported(add(&self.id, &Value::Str(" cancelOrdersForSymbols() is not supported yet".to_string()))));
Value::Null
} }
fn fetch_my_liquidations(&mut self, optional_args: &[Value]) -> impl ::std::future::Future<Output = Value> + Send { async move {
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
}));
panic!("{}", crate::exchange_errors::not_supported(add(&self.id, &Value::Str(" fetchMyLiquidations() is not supported yet".to_string()))));
Value::Null
} }
fn fetch_liquidations(&mut self, mut symbol: Value, optional_args: &[Value]) -> impl ::std::future::Future<Output = Value> + Send { async move {
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
}));
panic!("{}", crate::exchange_errors::not_supported(add(&self.id, &Value::Str(" fetchLiquidations() is not supported yet".to_string()))));
Value::Null
} }
fn fetch_greeks(&mut self, mut symbol: Value, optional_args: &[Value]) -> impl ::std::future::Future<Output = Value> + Send { async move {
let mut params = get_arg(optional_args, 0, Value::Map({
let mut m = indexmap::IndexMap::new();
m
}));
panic!("{}", crate::exchange_errors::not_supported(add(&self.id, &Value::Str(" fetchGreeks() is not supported yet".to_string()))));
Value::Null
} }
fn fetch_all_greeks(&mut self, optional_args: &[Value]) -> impl ::std::future::Future<Output = Value> + Send { async move {
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
}));
panic!("{}", crate::exchange_errors::not_supported(add(&self.id, &Value::Str(" fetchAllGreeks() is not supported yet".to_string()))));
Value::Null
} }
fn fetch_option_chain(&mut self, mut code: Value, optional_args: &[Value]) -> impl ::std::future::Future<Output = Value> + Send { async move {
let mut params = get_arg(optional_args, 0, Value::Map({
let mut m = indexmap::IndexMap::new();
m
}));
panic!("{}", crate::exchange_errors::not_supported(add(&self.id, &Value::Str(" fetchOptionChain() is not supported yet".to_string()))));
Value::Null
} }
fn fetch_option(&mut self, mut symbol: Value, optional_args: &[Value]) -> impl ::std::future::Future<Output = Value> + Send { async move {
let mut params = get_arg(optional_args, 0, Value::Map({
let mut m = indexmap::IndexMap::new();
m
}));
panic!("{}", crate::exchange_errors::not_supported(add(&self.id, &Value::Str(" fetchOption() is not supported yet".to_string()))));
Value::Null
} }
fn fetch_convert_quote(&mut self, mut fromCode: Value, mut toCode: Value, optional_args: &[Value]) -> impl ::std::future::Future<Output = Value> + Send { async move {
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
}));
panic!("{}", crate::exchange_errors::not_supported(add(&self.id, &Value::Str(" fetchConvertQuote() is not supported yet".to_string()))));
Value::Null
} }
fn fetch_deposits_withdrawals(&mut self, optional_args: &[Value]) -> impl ::std::future::Future<Output = Value> + Send { async move {
// async-virtual: try the derived exchange first
if let Some(__v) = self.dispatch_to_derived("fetch_deposits_withdrawals", { let mut __args: Vec<crate::Value> = Vec::new(); __args.extend_from_slice(optional_args); __args }).await {
if !matches!(__v, crate::Value::Null) { return __v; }
}
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
}));
panic!("{}", crate::exchange_errors::not_supported(add(&self.id, &Value::Str(" fetchDepositsWithdrawals() is not supported yet".to_string()))));
Value::Null
} }
fn fetch_deposits(&mut self, optional_args: &[Value]) -> impl ::std::future::Future<Output = Value> + Send { async move {
// async-virtual: try the derived exchange first
if let Some(__v) = self.dispatch_to_derived("fetch_deposits", { let mut __args: Vec<crate::Value> = Vec::new(); __args.extend_from_slice(optional_args); __args }).await {
if !matches!(__v, crate::Value::Null) { return __v; }
}
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
}));
panic!("{}", crate::exchange_errors::not_supported(add(&self.id, &Value::Str(" fetchDeposits() is not supported yet".to_string()))));
Value::Null
} }
fn fetch_withdrawals(&mut self, optional_args: &[Value]) -> impl ::std::future::Future<Output = Value> + Send { async move {
// async-virtual: try the derived exchange first
if let Some(__v) = self.dispatch_to_derived("fetch_withdrawals", { let mut __args: Vec<crate::Value> = Vec::new(); __args.extend_from_slice(optional_args); __args }).await {
if !matches!(__v, crate::Value::Null) { return __v; }
}
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
}));
panic!("{}", crate::exchange_errors::not_supported(add(&self.id, &Value::Str(" fetchWithdrawals() is not supported yet".to_string()))));
Value::Null
} }
fn fetch_deposits_ws(&mut self, optional_args: &[Value]) -> impl ::std::future::Future<Output = Value> + Send { async move {
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
}));
panic!("{}", crate::exchange_errors::not_supported(add(&self.id, &Value::Str(" fetchDepositsWs() is not supported yet".to_string()))));
Value::Null
} }
fn fetch_withdrawals_ws(&mut self, optional_args: &[Value]) -> impl ::std::future::Future<Output = Value> + Send { async move {
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
}));
panic!("{}", crate::exchange_errors::not_supported(add(&self.id, &Value::Str(" fetchWithdrawalsWs() is not supported yet".to_string()))));
Value::Null
} }
fn fetch_funding_rate_history(&mut self, optional_args: &[Value]) -> impl ::std::future::Future<Output = Value> + Send { async move {
// async-virtual: try the derived exchange first
if let Some(__v) = self.dispatch_to_derived("fetch_funding_rate_history", { let mut __args: Vec<crate::Value> = Vec::new(); __args.extend_from_slice(optional_args); __args }).await {
if !matches!(__v, crate::Value::Null) { return __v; }
}
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
}));
panic!("{}", crate::exchange_errors::not_supported(add(&self.id, &Value::Str(" fetchFundingRateHistory() is not supported yet".to_string()))));
Value::Null
} }
fn fetch_funding_history(&mut self, optional_args: &[Value]) -> impl ::std::future::Future<Output = Value> + Send { async move {
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
}));
panic!("{}", crate::exchange_errors::not_supported(add(&self.id, &Value::Str(" fetchFundingHistory() is not supported yet".to_string()))));
Value::Null
} }
fn parse_last_price(&self, mut price: Value, optional_args: &[Value]) -> Value {
// virtual-dispatch (static: DerivedExchange::parse_last_price(self, ...))
{ let __v = crate::exchange::DerivedExchange::parse_last_price(self, price.clone(), crate::runtime::get_arg(optional_args, 0, crate::Value::Null)); if !matches!(__v, crate::Value::Null) { return __v; } }
let mut market = get_arg(optional_args, 0, Value::Null);
panic!("{}", crate::exchange_errors::not_supported(add(&self.id, &Value::Str(" parseLastPrice() is not supported yet".to_string()))));
Value::Null
}
fn fetch_deposit_address(&mut self, mut code: Value, optional_args: &[Value]) -> impl ::std::future::Future<Output = Value> + Send { async move {
// async-virtual: try the derived exchange first
if let Some(__v) = self.dispatch_to_derived("fetch_deposit_address", { let mut __args: Vec<crate::Value> = Vec::new(); __args.push(code.clone()); __args.extend_from_slice(optional_args); __args }).await {
if !matches!(__v, crate::Value::Null) { return __v; }
}
let mut params = get_arg(optional_args, 0, Value::Map({
let mut m = indexmap::IndexMap::new();
m
}));
if !is_equal(&get_value(&self.has, &Value::Str("fetchDepositAddresses".to_string())), &Value::Null) && !is_equal(&get_value(&self.has, &Value::Str("fetchDepositAddresses".to_string())), &Value::Bool(false)) {
let mut depositAddresses: Value = self.fetch_deposit_addresses(&[Value::List(vec![code.clone()]), params.clone()]).await;
let mut depositAddress: Value = self.safe_value(depositAddresses.clone(), code.clone(), &[]);
if is_equal(&depositAddress, &Value::Null) {
panic!("{}", crate::exchange_errors::invalid_address(add(&add(&add(&self.id, &Value::Str(" fetchDepositAddress() could not find a deposit address for ".to_string())), &code), &Value::Str(", make sure you have created a corresponding deposit address in your wallet on the exchange website".to_string()))));
} else {
return depositAddress;
}
} else if !is_equal(&get_value(&self.has, &Value::Str("fetchDepositAddressesByNetwork".to_string())), &Value::Null) && !is_equal(&get_value(&self.has, &Value::Str("fetchDepositAddressesByNetwork".to_string())), &Value::Bool(false)) {
let mut network: Value = self.safe_string_k(params.clone(), "network", &[]);
params = self.omit(params.clone(), Value::Str("network".to_string()), &[]);
let mut addressStructures: Value = self.fetch_deposit_addresses_by_network(code.clone(), &[params.clone()]).await;
if !is_equal(&network, &Value::Null) {
return self.safe_dict(addressStructures.clone(), network.clone(), &[]);
} else {
let mut keys: Value = object_keys(&addressStructures);
let mut key: Value = get_value(&keys, &Value::Int(0));
return self.safe_dict(addressStructures.clone(), key.clone(), &[]);
}
} else {
panic!("{}", crate::exchange_errors::not_supported(add(&self.id, &Value::Str(" fetchDepositAddress() is not supported yet".to_string()))));
}
Value::Null
} }
fn fetch_contract_deposit_address(&mut self, mut code: Value, optional_args: &[Value]) -> impl ::std::future::Future<Output = Value> + Send { async move {
let mut params = get_arg(optional_args, 0, Value::Map({
let mut m = indexmap::IndexMap::new();
m
}));
panic!("{}", crate::exchange_errors::not_supported(add(&self.id, &Value::Str(" fetchContractDepositAddress() is not supported yet".to_string()))));
Value::Null
} }
fn account(&self) -> Value {
return Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("free".to_string(), Value::Null);
m.insert("used".to_string(), Value::Null);
m.insert("total".to_string(), Value::Null);
m
});
Value::Null
}
/*
* @ignore
* @method
* @description merges a per-market (isolated margin) account into a flat code-keyed balance dict, summing string fields when the code recurs across markets
* @param {object} result the code-keyed balance dict being built
* @param {string} code unified currency code
* @param {object} account a balance account with string free/used/total/debt
* @returns {object} result — callers MUST reassign (`result = this.mergeBalanceAccount (result, ...)`): PHP arrays are passed by value, so the mutation is not visible through the argument
*/
fn merge_balance_account(&self, mut result: Value, mut code: Value, mut account: Value) -> Value {
if !is_true(&(Value::Bool(in_op(&result, &code)))) {
add_element_to_object(&mut result, &code, account.clone());
return result;
}
let mut fields: Value = Value::List(vec![Value::Str("free".to_string()), Value::Str("used".to_string()), Value::Str("total".to_string()), Value::Str("debt".to_string())]);
{
let mut i: Value = Value::Int(0);
let mut __for_first_135: bool = true;
while { if !__for_first_135 { i = add(&i, &Value::Int(1)); } __for_first_135 = false; is_less_than(&i, &get_array_length(&fields)) } {
let mut field: Value = get_value(&fields, &i);
let mut field: Value = get_value(&fields, &i);
let mut current: Value = self.safe_string(get_value(&result, &code), field.clone(), &[]);
let mut incoming: Value = self.safe_string(account.clone(), field.clone(), &[]);
if is_equal(¤t, &Value::Null) {
add_element_to_object(get_value_mut(&mut result, &code), &field, incoming.clone());
} else if !is_equal(&incoming, &Value::Null) {
add_element_to_object(get_value_mut(&mut result, &code), &field, crate::precise::Precise::stringAdd(¤t, &incoming));
}
}
}
return result;
Value::Null
}
fn common_currency_code(&self, mut code: Value) -> Value {
if !is_true(&self.substituteCommonCurrencyCodes) {
return code;
}
return self.safe_string(self.commonCurrencies.clone(), code.clone(), &[code.clone()]);
Value::Null
}
fn currency(&self, mut code: Value) -> Value {
if is_equal(&code, &Value::Null) {
panic!("{}", crate::exchange_errors::arguments_required(add(&self.id, &Value::Str(" currency() requires a code argument".to_string()))));
}
let mut keys: Value = object_keys(&self.currencies);
let mut numCurrencies: Value = get_array_length(&keys);
if is_equal(&numCurrencies, &Value::Int(0)) {
panic!("{}", crate::exchange_errors::exchange_error(add(&self.id, &Value::Str(" currencies not loaded".to_string()))));
}
if is_string(&code) {
let mut currencies: Value = self.currencies.clone();
let mut currenciesById: Value = self.currencies_by_id.clone();
if is_true(&Value::Bool(in_op(¤cies, &code))) {
return get_value(¤cies, &code);
} else if is_true(&(!is_equal(¤ciesById, &Value::Null))) && is_true(&(Value::Bool(in_op(¤ciesById, &code)))) {
return get_value(¤ciesById, &code);
}
}
panic!("{}", crate::exchange_errors::exchange_error(add(&add(&self.id, &Value::Str(" does not have currency code ".to_string())), &code)));
Value::Null
}
fn market(&self, mut symbol: Value) -> Value {
if is_equal(&symbol, &Value::Null) {
panic!("{}", crate::exchange_errors::arguments_required(add(&self.id, &Value::Str(" market() requires a symbol argument".to_string()))));
}
let mut markets: Value = self.markets.clone();
if is_equal(&markets, &Value::Null) {
panic!("{}", crate::exchange_errors::exchange_error(add(&self.id, &Value::Str(" markets not loaded".to_string()))));
}
let mut marketsById: Value = self.markets_by_id.clone();
if is_true(&Value::Bool(in_op(&markets, &symbol))) {
return get_value(&markets, &symbol);
} else if is_true(&(!is_equal(&marketsById, &Value::Null))) && is_true(&(Value::Bool(in_op(&marketsById, &symbol)))) {
let mut marketsList: Value = get_value(&marketsById, &symbol);
let mut marketsList: Value = get_value(&marketsById, &symbol);
let mut defaultType: Value = self.safe_string2(self.options.clone(), Value::Str("defaultType".to_string()), Value::Str("defaultSubType".to_string()), &[Value::Str("spot".to_string())]);
{
let mut i: Value = Value::Int(0);
let mut __for_first_136: bool = true;
while { if !__for_first_136 { i = add(&i, &Value::Int(1)); } __for_first_136 = false; is_less_than(&i, &get_array_length(&marketsList)) } {
let mut market: Value = get_value(&marketsList, &i);
let mut market: Value = get_value(&marketsList, &i);
if is_equal(&get_value(&market, &defaultType), &Value::Bool(true)) {
return market;
}
}
}
return get_value(&marketsList, &Value::Int(0));
} else if is_true(&(Value::Bool(ends_with(&symbol, &Value::Str("-C".to_string()))))) || is_true(&(Value::Bool(ends_with(&symbol, &Value::Str("-P".to_string()))))) || is_true(&(Value::Bool(starts_with(&symbol, &Value::Str("C-".to_string()))))) || is_true(&(Value::Bool(starts_with(&symbol, &Value::Str("P-".to_string()))))) {
return <Self as crate::exchange_generated::ExchangeBase>::create_expired_option_market(self, symbol.clone());
}
panic!("{}", crate::exchange_errors::bad_symbol(add(&add(&self.id, &Value::Str(" does not have market symbol ".to_string())), &symbol)));
Value::Null
}
fn create_expired_option_market(&self, mut symbol: Value) -> Value {
// virtual-dispatch (static: DerivedExchange::create_expired_option_market(self, ...))
{ let __v = crate::exchange::DerivedExchange::create_expired_option_market(self, symbol.clone()); if !matches!(__v, crate::Value::Null) { return __v; } }
panic!("{}", crate::exchange_errors::not_supported(add(&self.id, &Value::Str(" createExpiredOptionMarket () is not supported yet".to_string()))));
Value::Null
}
fn is_leveraged_currency(&self, mut currencyCode: Value, optional_args: &[Value]) -> Value {
let mut checkBaseCoin = get_arg(optional_args, 0, Value::Bool(false));
let mut existingCurrencies = get_arg(optional_args, 1, Value::Null);
let mut leverageSuffixes: Value = Value::List(vec![Value::Str("2L".to_string()), Value::Str("2S".to_string()), Value::Str("3L".to_string()), Value::Str("3S".to_string()), Value::Str("4L".to_string()), Value::Str("4S".to_string()), Value::Str("5L".to_string()), Value::Str("5S".to_string()), Value::Str("UP".to_string()), Value::Str("DOWN".to_string()), Value::Str("BULL".to_string()), Value::Str("BEAR".to_string())]);
{
let mut i: Value = Value::Int(0);
let mut __for_first_137: bool = true;
while { if !__for_first_137 { i = add(&i, &Value::Int(1)); } __for_first_137 = false; is_less_than(&i, &get_array_length(&leverageSuffixes)) } {
let mut leverageSuffix: Value = get_value(&leverageSuffixes, &i);
let mut leverageSuffix: Value = get_value(&leverageSuffixes, &i);
let mut endsWithSuffix: bool = ends_with(¤cyCode, &leverageSuffix);
if is_true(&endsWithSuffix) {
if !is_true(&checkBaseCoin) {
return Value::Bool(true);
} else {
// check if base currency is inside dict
let mut baseCurrencyCode: Value = replace_str(¤cyCode, &leverageSuffix, &Value::Str("".to_string()));
if is_true(&(!is_equal(&existingCurrencies, &Value::Null))) && is_true(&(Value::Bool(in_op(&existingCurrencies, &baseCurrencyCode)))) {
return Value::Bool(true);
}
}
}
}
}
return Value::Bool(false);
Value::Null
}
fn handle_withdraw_tag_and_params(&self, mut tag: Value, mut params: Value) -> Value {
if is_true(&self.is_dictionary(tag.clone())) {
params = self.extend(tag.clone(), &[params.clone()]);
tag = Value::Null;
}
if is_equal(&tag, &Value::Null) {
tag = self.safe_string_k(params.clone(), "tag", &[]);
if !is_equal(&tag, &Value::Null) {
params = self.omit(params.clone(), Value::Str("tag".to_string()), &[]);
}
}
return Value::List(vec![tag.clone(), params.clone()]);
Value::Null
}
fn cost_to_precision(&self, mut symbol: Value, mut cost: Value) -> Value {
if is_equal(&cost, &Value::Null) {
return Value::Null;
}
let mut market: Value = self.market(symbol.clone());
return self.decimal_to_precision(cost.clone(), Value::Int(crate::runtime::TRUNCATE), self.safe_string2(get_value(&market, &Value::Str("precision".to_string())), Value::Str("cost".to_string()), Value::Str("price".to_string()), &[]), &[self.precisionMode.clone(), self.paddingMode.clone()]);
Value::Null
}
fn price_to_precision(&self, mut symbol: Value, mut price: Value) -> Value {
if is_equal(&price, &Value::Null) {
return Value::Null;
}
let mut market: Value = self.market(symbol.clone());
let mut result: Value = self.decimal_to_precision(price.clone(), Value::Int(crate::runtime::ROUND), get_value(&get_value(&market, &Value::Str("precision".to_string())), &Value::Str("price".to_string())), &[self.precisionMode.clone(), self.paddingMode.clone()]);
if is_equal(&result, &Value::Str("0".to_string())) {
panic!("{}", crate::exchange_errors::invalid_order(add(&add(&add(&add(&self.id, &Value::Str(" price of ".to_string())), &get_value(&market, &Value::Str("symbol".to_string()))), &Value::Str(" must be greater than minimum price precision of ".to_string())), &self.number_to_string(get_value(&get_value(&market, &Value::Str("precision".to_string())), &Value::Str("price".to_string()))))));
}
return result;
Value::Null
}
fn amount_to_precision(&self, mut symbol: Value, mut amount: Value) -> Value {
if is_equal(&amount, &Value::Null) {
return Value::Null;
}
let mut market: Value = self.market(symbol.clone());
let mut result: Value = self.decimal_to_precision(amount.clone(), Value::Int(crate::runtime::TRUNCATE), get_value(&get_value(&market, &Value::Str("precision".to_string())), &Value::Str("amount".to_string())), &[self.precisionMode.clone(), self.paddingMode.clone()]);
if is_equal(&result, &Value::Str("0".to_string())) {
panic!("{}", crate::exchange_errors::invalid_order(add(&add(&add(&add(&self.id, &Value::Str(" amount of ".to_string())), &get_value(&market, &Value::Str("symbol".to_string()))), &Value::Str(" must be greater than minimum amount precision of ".to_string())), &self.number_to_string(get_value(&get_value(&market, &Value::Str("precision".to_string())), &Value::Str("amount".to_string()))))));
}
return result;
Value::Null
}
fn fee_to_precision(&self, mut symbol: Value, mut fee: Value) -> Value {
if is_equal(&fee, &Value::Null) {
return Value::Null;
}
let mut market: Value = self.market(symbol.clone());
return self.decimal_to_precision(fee.clone(), Value::Int(crate::runtime::ROUND), get_value(&get_value(&market, &Value::Str("precision".to_string())), &Value::Str("price".to_string())), &[self.precisionMode.clone(), self.paddingMode.clone()]);
Value::Null
}
fn currency_to_precision(&self, mut code: Value, mut fee: Value, optional_args: &[Value]) -> Value {
let mut networkCode = get_arg(optional_args, 0, Value::Null);
if is_equal(&code, &Value::Null) {
panic!("{}", crate::exchange_errors::arguments_required(add(&self.id, &Value::Str(" currencyToPrecision() requires a code argument".to_string()))));
}
let mut currency: Value = get_value(&self.currencies, &code);
let mut precision: Value = self.safe_value_k(currency.clone(), "precision", &[]);
if !is_equal(&networkCode, &Value::Null) {
let mut networks: Value = self.safe_dict_k(currency.clone(), "networks", &[Value::Map({
let mut m = indexmap::IndexMap::new();
m
})]);
let mut networkItem: Value = self.safe_dict(networks.clone(), networkCode.clone(), &[Value::Map({
let mut m = indexmap::IndexMap::new();
m
})]);
precision = self.safe_value_k(networkItem.clone(), "precision", &[precision.clone()]);
}
if is_equal(&precision, &Value::Null) {
return self.force_string(fee.clone());
} else {
let mut roundingMode: Value = self.safe_integer_k(self.options.clone(), "currencyToPrecisionRoundingMode", &[Value::Int(crate::runtime::ROUND)]);
return self.decimal_to_precision(fee.clone(), roundingMode.clone(), precision.clone(), &[self.precisionMode.clone(), self.paddingMode.clone()]);
}
Value::Null
}
fn force_string(&self, mut value: Value) -> Value {
if !is_string(&value) {
return self.number_to_string(value.clone());
}
return value;
Value::Null
}
fn is_tick_precision(&self) -> Value {
return Value::Bool(is_equal(&self.precisionMode, &Value::Int(crate::runtime::TICK_SIZE)));
Value::Null
}
fn is_decimal_precision(&self) -> Value {
return Value::Bool(is_equal(&self.precisionMode, &Value::Int(crate::runtime::DECIMAL_PLACES)));
Value::Null
}
fn is_significant_precision(&self) -> Value {
return Value::Bool(is_equal(&self.precisionMode, &Value::Int(crate::runtime::SIGNIFICANT_DIGITS)));
Value::Null
}
fn safe_number(&self, mut obj: Value, mut key: Value, optional_args: &[Value]) -> Value {
let mut defaultNumber = get_arg(optional_args, 0, Value::Null);
let mut value: Value = self.safe_string(obj.clone(), key.clone(), &[]);
return self.parse_number(value.clone(), &[defaultNumber.clone()]);
Value::Null
}
fn safe_number_n(&self, mut obj: Value, mut arr: Value, optional_args: &[Value]) -> Value {
let mut defaultNumber = get_arg(optional_args, 0, Value::Null);
let mut value: Value = self.safe_string_n(obj.clone(), arr.clone(), &[]);
return self.parse_number(value.clone(), &[defaultNumber.clone()]);
Value::Null
}
fn parse_precision(&self, optional_args: &[Value]) -> Value {
let mut precision = get_arg(optional_args, 0, Value::Null);
/*
* @ignore
* @method
* @param {string} precision The number of digits to the right of the decimal
* @returns {string} a string number equal to 1e-precision
*/
if is_equal(&precision, &Value::Null) {
return Value::Null;
}
let mut precisionNumber: Value = crate::runtime::parse_int(&precision);
if is_equal(&precisionNumber, &Value::Int(0)) {
return Value::Str("1".to_string());
}
if is_greater_than(&precisionNumber, &Value::Int(0)) {
let mut parsedPrecision: Value = Value::Str("0.".to_string());
{
let mut i: Value = Value::Int(0);
let mut __for_first_138: bool = true;
while { if !__for_first_138 { i = add(&i, &Value::Int(1)); } __for_first_138 = false; is_less_than(&i, &subtract(&precisionNumber, &Value::Int(1))) } {
parsedPrecision = add(&parsedPrecision, &Value::Str("0".to_string()));
}
}
return add(&parsedPrecision, &Value::Str("1".to_string()));
} else {
let mut parsedPrecision: Value = Value::Str("1".to_string());
{
let mut i: Value = Value::Int(0);
let mut __for_first_139: bool = true;
while { if !__for_first_139 { i = add(&i, &Value::Int(1)); } __for_first_139 = false; is_less_than(&i, &subtract(&multiply(&precisionNumber, &negate(&Value::Int(1))), &Value::Int(1))) } {
parsedPrecision = add(&parsedPrecision, &Value::Str("0".to_string()));
}
}
return add(&parsedPrecision, &Value::Str("0".to_string()));
}
Value::Null
}
fn integer_precision_to_amount(&self, mut precision: Value) -> Value {
/*
* @ignore
* @method
* @description handles positive & negative numbers too. parsePrecision() does not handle negative numbers, but this method handles
* @param {string} precision The number of digits to the right of the decimal
* @returns {string} a string number equal to 1e-precision
*/
if is_equal(&precision, &Value::Null) {
return Value::Null;
}
if is_true(&crate::precise::Precise::stringGe(&precision, &Value::Str("0".to_string()))) {
return self.parse_precision(&[precision.clone()]);
} else {
let mut positivePrecisionString: Value = crate::precise::Precise::stringAbs(&precision);
if is_equal(&positivePrecisionString, &Value::Null) {
return Value::Null;
}
let mut positivePrecision: Value = crate::runtime::parse_int(&positivePrecisionString);
let mut parsedPrecision: Value = Value::Str("1".to_string());
{
let mut i: Value = Value::Int(0);
let mut __for_first_140: bool = true;
while { if !__for_first_140 { i = add(&i, &Value::Int(1)); } __for_first_140 = false; is_less_than(&i, &subtract(&positivePrecision, &Value::Int(1))) } {
parsedPrecision = add(&parsedPrecision, &Value::Str("0".to_string()));
}
}
return add(&parsedPrecision, &Value::Str("0".to_string()));
}
}
fn load_time_difference(&mut self, optional_args: &[Value]) -> impl ::std::future::Future<Output = Value> + Send { async move {
let mut params = get_arg(optional_args, 0, Value::Map({
let mut m = indexmap::IndexMap::new();
m
}));
let mut serverTime: Value = self.fetch_time(&[params.clone()]).await;
let mut after: Value = self.milliseconds();
if is_equal(&serverTime, &Value::Null) {
panic!("{}", crate::exchange_errors::exchange_error(add(&self.id, &Value::Str(" loadTimeDifference() missing serverTime".to_string()))));
}
add_element_to_object(&mut self.options, &Value::Str("timeDifference".to_string()), subtract(&after, &serverTime));
return get_value(&self.options, &Value::Str("timeDifference".to_string()));
Value::Null
} }
fn implode_hostname(&self, mut url: Value) -> Value {
return self.implode_params(url.clone(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("hostname".to_string(), self.hostname.clone());
m
}));
Value::Null
}
fn fetch_market_leverage_tiers(&mut self, mut symbol: Value, optional_args: &[Value]) -> impl ::std::future::Future<Output = Value> + Send { async move {
// async-virtual: try the derived exchange first
if let Some(__v) = self.dispatch_to_derived("fetch_market_leverage_tiers", { let mut __args: Vec<crate::Value> = Vec::new(); __args.push(symbol.clone()); __args.extend_from_slice(optional_args); __args }).await {
if !matches!(__v, crate::Value::Null) { return __v; }
}
let mut params = get_arg(optional_args, 0, Value::Map({
let mut m = indexmap::IndexMap::new();
m
}));
if !is_equal(&get_value(&self.has, &Value::Str("fetchLeverageTiers".to_string())), &Value::Null) && !is_equal(&get_value(&self.has, &Value::Str("fetchLeverageTiers".to_string())), &Value::Bool(false)) {
let mut market: Value = self.market(symbol.clone());
if !is_equal(&get_value(&market, &Value::Str("contract".to_string())), &Value::Bool(true)) {
panic!("{}", crate::exchange_errors::bad_symbol(add(&self.id, &Value::Str(" fetchMarketLeverageTiers() supports contract markets only".to_string()))));
}
let mut tiers: Value = self.fetch_leverage_tiers(&[Value::List(vec![symbol.clone()])]).await;
return self.safe_value(tiers.clone(), symbol.clone(), &[]);
} else {
panic!("{}", crate::exchange_errors::not_supported(add(&self.id, &Value::Str(" fetchMarketLeverageTiers() is not supported yet".to_string()))));
}
Value::Null
} }
fn create_sub_account(&mut self, mut name: Value, optional_args: &[Value]) -> impl ::std::future::Future<Output = Value> + Send { async move {
let mut params = get_arg(optional_args, 0, Value::Map({
let mut m = indexmap::IndexMap::new();
m
}));
panic!("{}", crate::exchange_errors::not_supported(add(&self.id, &Value::Str(" createSubAccount() is not supported yet".to_string()))));
Value::Null
} }
fn safe_currency_code(&self, mut currencyId: Value, optional_args: &[Value]) -> Value {
let mut currency = get_arg(optional_args, 0, Value::Null);
currency = self.safe_currency(currencyId.clone(), &[currency.clone()]);
return get_value(¤cy, &Value::Str("code".to_string()));
Value::Null
}
fn filter_by_symbol_since_limit(&self, mut array: 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 tail = get_arg(optional_args, 3, Value::Bool(false));
return self.filter_by_value_since_limit(array.clone(), Value::Str("symbol".to_string()), &[symbol.clone(), since.clone(), limit.clone(), Value::Str("timestamp".to_string()), tail.clone()]);
Value::Null
}
fn filter_by_currency_since_limit(&self, mut array: Value, 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 tail = get_arg(optional_args, 3, Value::Bool(false));
return self.filter_by_value_since_limit(array.clone(), Value::Str("currency".to_string()), &[code.clone(), since.clone(), limit.clone(), Value::Str("timestamp".to_string()), tail.clone()]);
Value::Null
}
fn filter_by_symbols_since_limit(&self, mut array: Value, optional_args: &[Value]) -> Value {
let mut symbols = get_arg(optional_args, 0, Value::Null);
let mut since = get_arg(optional_args, 1, Value::Null);
let mut limit = get_arg(optional_args, 2, Value::Null);
let mut tail = get_arg(optional_args, 3, Value::Bool(false));
let mut result: Value = self.filter_by_array(array.clone(), Value::Str("symbol".to_string()), &[symbols.clone(), Value::Bool(false)]);
return self.filter_by_since_limit(result.clone(), &[since.clone(), limit.clone(), Value::Str("timestamp".to_string()), tail.clone()]);
Value::Null
}
fn parse_last_prices(&self, mut pricesData: Value, 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
}));
//
// the value of tickers is either a dict or a list
//
// dict
//
// {
// 'marketId1': { ... },
// 'marketId2': { ... },
// ...
// }
//
// list
//
// [
// { 'market': 'marketId1', ... },
// { 'market': 'marketId2', ... },
// ...
// ]
//
let mut results: Value = Value::List(vec![]);
if is_true(&Value::Bool(is_array(&pricesData))) {
{
let mut i: Value = Value::Int(0);
let mut __for_first_141: bool = true;
while { if !__for_first_141 { i = add(&i, &Value::Int(1)); } __for_first_141 = false; is_less_than(&i, &get_array_length(&pricesData)) } {
let mut priceData: Value = self.extend(<Self as crate::exchange_generated::ExchangeBase>::parse_last_price(self, get_value(&pricesData, &i), &[]), &[params.clone()]);
append_to_array(&mut results, priceData.clone());
}
}
} else {
let mut marketIds: Value = object_keys(&pricesData);
{
let mut i: Value = Value::Int(0);
let mut __for_first_142: bool = true;
while { if !__for_first_142 { i = add(&i, &Value::Int(1)); } __for_first_142 = false; is_less_than(&i, &get_array_length(&marketIds)) } {
let mut marketId: Value = get_value(&marketIds, &i);
let mut marketId: Value = get_value(&marketIds, &i);
let mut market: Value = self.safe_market(&[marketId.clone()]);
let mut priceData: Value = self.extend(<Self as crate::exchange_generated::ExchangeBase>::parse_last_price(self, get_value(&pricesData, &marketId), &[market.clone()]), &[params.clone()]);
append_to_array(&mut results, priceData.clone());
}
}
}
symbols = self.market_symbols(&[symbols.clone()]);
return self.filter_by_array(results.clone(), Value::Str("symbol".to_string()), &[symbols.clone()]);
Value::Null
}
fn parse_tickers(&self, mut tickers: Value, 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
}));
//
// the value of tickers is either a dict or a list
//
//
// dict
//
// {
// 'marketId1': { ... },
// 'marketId2': { ... },
// 'marketId3': { ... },
// ...
// }
//
// list
//
// [
// { 'market': 'marketId1', ... },
// { 'market': 'marketId2', ... },
// { 'market': 'marketId3', ... },
// ...
// ]
//
let mut results: Value = Value::List(vec![]);
if is_true(&Value::Bool(is_array(&tickers))) {
{
let mut i: Value = Value::Int(0);
let mut __for_first_143: bool = true;
while { if !__for_first_143 { i = add(&i, &Value::Int(1)); } __for_first_143 = false; is_less_than(&i, &get_array_length(&tickers)) } {
let mut parsedTicker: Value = <Self as crate::exchange_generated::ExchangeBase>::parse_ticker(self, get_value(&tickers, &i), &[]);
let mut ticker: Value = self.extend(parsedTicker.clone(), &[params.clone()]);
append_to_array(&mut results, ticker.clone());
}
}
} else {
let mut marketIds: Value = object_keys(&tickers);
{
let mut i: Value = Value::Int(0);
let mut __for_first_144: bool = true;
while { if !__for_first_144 { i = add(&i, &Value::Int(1)); } __for_first_144 = false; is_less_than(&i, &get_array_length(&marketIds)) } {
let mut marketId: Value = get_value(&marketIds, &i);
let mut marketId: Value = get_value(&marketIds, &i);
let mut market: Value = self.safe_market(&[marketId.clone()]);
let mut parsed: Value = <Self as crate::exchange_generated::ExchangeBase>::parse_ticker(self, get_value(&tickers, &marketId), &[market.clone()]);
let mut ticker: Value = self.extend(parsed.clone(), &[params.clone()]);
append_to_array(&mut results, ticker.clone());
}
}
}
symbols = self.market_symbols(&[symbols.clone()]);
return self.filter_by_array(results.clone(), Value::Str("symbol".to_string()), &[symbols.clone()]);
Value::Null
}
fn parse_deposit_addresses(&self, mut addresses: Value, optional_args: &[Value]) -> Value {
let mut codes = get_arg(optional_args, 0, Value::Null);
let mut indexed = get_arg(optional_args, 1, Value::Bool(true));
let mut params = get_arg(optional_args, 2, Value::Map({
let mut m = indexmap::IndexMap::new();
m
}));
let mut result: Value = Value::List(vec![]);
{
let mut i: Value = Value::Int(0);
let mut __for_first_145: bool = true;
while { if !__for_first_145 { i = add(&i, &Value::Int(1)); } __for_first_145 = false; is_less_than(&i, &get_array_length(&addresses)) } {
let mut address: Value = self.extend(<Self as crate::exchange_generated::ExchangeBase>::parse_deposit_address(self, get_value(&addresses, &i), &[]), &[params.clone()]);
append_to_array(&mut result, address.clone());
}
}
if !is_equal(&codes, &Value::Null) {
result = self.filter_by_array(result.clone(), Value::Str("currency".to_string()), &[codes.clone(), Value::Bool(false)]);
}
if is_true(&indexed) {
result = self.filter_by_array(result.clone(), Value::Str("currency".to_string()), &[Value::Null, indexed.clone()]);
}
return result;
Value::Null
}
fn parse_borrow_interests(&self, mut response: Value, optional_args: &[Value]) -> Value {
let mut market = get_arg(optional_args, 0, Value::Null);
let mut interests: Value = Value::List(vec![]);
{
let mut i: Value = Value::Int(0);
let mut __for_first_146: bool = true;
while { if !__for_first_146 { i = add(&i, &Value::Int(1)); } __for_first_146 = false; is_less_than(&i, &get_array_length(&response)) } {
let mut row: Value = get_value(&response, &i);
let mut row: Value = get_value(&response, &i);
append_to_array(&mut interests, <Self as crate::exchange_generated::ExchangeBase>::parse_borrow_interest(self, row.clone(), &[market.clone()]));
}
}
return interests;
Value::Null
}
fn parse_borrow_rate(&self, mut info: Value, optional_args: &[Value]) -> Value {
// virtual-dispatch (static: DerivedExchange::parse_borrow_rate(self, ...))
{ let __v = crate::exchange::DerivedExchange::parse_borrow_rate(self, info.clone(), crate::runtime::get_arg(optional_args, 0, crate::Value::Null)); if !matches!(__v, crate::Value::Null) { return __v; } }
let mut currency = get_arg(optional_args, 0, Value::Null);
panic!("{}", crate::exchange_errors::not_supported(add(&self.id, &Value::Str(" parseBorrowRate() is not supported yet".to_string()))));
Value::Null
}
fn parse_borrow_rate_history(&self, mut response: Value, mut code: Value, mut since: Value, mut limit: Value) -> Value {
let mut result: Value = Value::List(vec![]);
{
let mut i: Value = Value::Int(0);
let mut __for_first_147: bool = true;
while { if !__for_first_147 { i = add(&i, &Value::Int(1)); } __for_first_147 = false; is_less_than(&i, &get_array_length(&response)) } {
let mut item: Value = get_value(&response, &i);
let mut item: Value = get_value(&response, &i);
let mut borrowRate: Value = <Self as crate::exchange_generated::ExchangeBase>::parse_borrow_rate(self, item.clone(), &[]);
append_to_array(&mut result, borrowRate.clone());
}
}
let mut sorted: Value = self.sort_by(result.clone(), Value::Str("timestamp".to_string()), &[]);
return self.filter_by_currency_since_limit(sorted.clone(), &[code.clone(), since.clone(), limit.clone()]);
Value::Null
}
fn parse_isolated_borrow_rates(&self, mut info: Value) -> Value {
let mut result: Value = Value::Map({
let mut m = indexmap::IndexMap::new();
m
});
{
let mut i: Value = Value::Int(0);
let mut __for_first_148: bool = true;
while { if !__for_first_148 { i = add(&i, &Value::Int(1)); } __for_first_148 = false; is_less_than(&i, &get_array_length(&info)) } {
let mut item: Value = get_value(&info, &i);
let mut item: Value = get_value(&info, &i);
let mut borrowRate: Value = self.parse_isolated_borrow_rate(item.clone(), &[]);
let mut symbol: Value = self.safe_string_k(borrowRate.clone(), "symbol", &[]);
add_element_to_object(&mut result, &symbol, borrowRate.clone());
}
}
return result;
Value::Null
}
fn parse_funding_rate_histories(&self, mut response: 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 rates: Value = Value::List(vec![]);
{
let mut i: Value = Value::Int(0);
let mut __for_first_149: bool = true;
while { if !__for_first_149 { i = add(&i, &Value::Int(1)); } __for_first_149 = false; is_less_than(&i, &get_array_length(&response)) } {
let mut entry: Value = get_value(&response, &i);
let mut entry: Value = get_value(&response, &i);
append_to_array(&mut rates, <Self as crate::exchange_generated::ExchangeBase>::parse_funding_rate_history(self, entry.clone(), &[market.clone()]));
}
}
let mut sorted: Value = self.sort_by(rates.clone(), Value::Str("timestamp".to_string()), &[]);
let mut symbol: Value = ternary(is_true(&(is_equal(&market, &Value::Null))), Value::Null, get_value(&market, &Value::Str("symbol".to_string())));
return self.filter_by_symbol_since_limit(sorted.clone(), &[symbol.clone(), since.clone(), limit.clone()]);
Value::Null
}
fn safe_symbol(&self, mut marketId: Value, optional_args: &[Value]) -> Value {
let mut market = get_arg(optional_args, 0, Value::Null);
let mut delimiter = get_arg(optional_args, 1, Value::Null);
let mut marketType = get_arg(optional_args, 2, Value::Null);
market = self.safe_market(&[marketId.clone(), market.clone(), delimiter.clone(), marketType.clone()]);
return get_value(&market, &Value::Str("symbol".to_string()));
Value::Null
}
fn parse_funding_rate(&self, mut contract: Value, optional_args: &[Value]) -> Value {
// virtual-dispatch (static: DerivedExchange::parse_funding_rate(self, ...))
{ let __v = crate::exchange::DerivedExchange::parse_funding_rate(self, contract.clone(), crate::runtime::get_arg(optional_args, 0, crate::Value::Null)); if !matches!(__v, crate::Value::Null) { return __v; } }
let mut market = get_arg(optional_args, 0, Value::Null);
panic!("{}", crate::exchange_errors::not_supported(add(&self.id, &Value::Str(" parseFundingRate() is not supported yet".to_string()))));
Value::Null
}
fn parse_funding_rates(&self, mut response: Value, optional_args: &[Value]) -> Value {
let mut symbols = get_arg(optional_args, 0, Value::Null);
let mut fundingRates: Value = Value::Map({
let mut m = indexmap::IndexMap::new();
m
});
{
let mut i: Value = Value::Int(0);
let mut __for_first_150: bool = true;
while { if !__for_first_150 { i = add(&i, &Value::Int(1)); } __for_first_150 = false; is_less_than(&i, &get_array_length(&response)) } {
let mut entry: Value = get_value(&response, &i);
let mut entry: Value = get_value(&response, &i);
let mut parsed: Value = <Self as crate::exchange_generated::ExchangeBase>::parse_funding_rate(self, entry.clone(), &[]);
if !is_equal(&get_value(&parsed, &Value::Str("symbol".to_string())), &Value::Null) {
add_element_to_object(&mut fundingRates, &get_value(&parsed, &Value::Str("symbol".to_string())), parsed.clone());
}
}
}
return self.filter_by_array(fundingRates.clone(), Value::Str("symbol".to_string()), &[symbols.clone()]);
Value::Null
}
fn parse_long_short_ratio(&self, mut info: Value, optional_args: &[Value]) -> Value {
let mut market = get_arg(optional_args, 0, Value::Null);
panic!("{}", crate::exchange_errors::not_supported(add(&self.id, &Value::Str(" parseLongShortRatio() is not supported yet".to_string()))));
Value::Null
}
fn parse_long_short_ratio_history(&self, mut response: 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 rates: Value = Value::List(vec![]);
{
let mut i: Value = Value::Int(0);
let mut __for_first_151: bool = true;
while { if !__for_first_151 { i = add(&i, &Value::Int(1)); } __for_first_151 = false; is_less_than(&i, &get_array_length(&response)) } {
let mut entry: Value = get_value(&response, &i);
let mut entry: Value = get_value(&response, &i);
append_to_array(&mut rates, self.parse_long_short_ratio(entry.clone(), &[market.clone()]));
}
}
let mut sorted: Value = self.sort_by(rates.clone(), Value::Str("timestamp".to_string()), &[]);
let mut symbol: Value = ternary(is_true(&(is_equal(&market, &Value::Null))), Value::Null, get_value(&market, &Value::Str("symbol".to_string())));
return self.filter_by_symbol_since_limit(sorted.clone(), &[symbol.clone(), since.clone(), limit.clone()]);
Value::Null
}
fn handle_trigger_prices_and_params(&self, mut symbol: Value, mut params: Value, optional_args: &[Value]) -> Value {
let mut omitParams = get_arg(optional_args, 0, Value::Bool(true));
//
let mut triggerPrice: Value = self.safe_string2(params.clone(), Value::Str("triggerPrice".to_string()), Value::Str("stopPrice".to_string()), &[]);
let mut triggerPriceStr: Value = Value::Null;
let mut stopLossPrice: Value = self.safe_string_k(params.clone(), "stopLossPrice", &[]);
let mut stopLossPriceStr: Value = Value::Null;
let mut takeProfitPrice: Value = self.safe_string_k(params.clone(), "takeProfitPrice", &[]);
let mut takeProfitPriceStr: Value = Value::Null;
//
if !is_equal(&triggerPrice, &Value::Null) {
if is_true(&omitParams) {
params = self.omit(params.clone(), Value::List(vec![Value::Str("triggerPrice".to_string()), Value::Str("stopPrice".to_string())]), &[]);
}
triggerPriceStr = self.price_to_precision(symbol.clone(), crate::runtime::parse_float(&triggerPrice));
}
if !is_equal(&stopLossPrice, &Value::Null) {
if is_true(&omitParams) {
params = self.omit(params.clone(), Value::Str("stopLossPrice".to_string()), &[]);
}
stopLossPriceStr = self.price_to_precision(symbol.clone(), crate::runtime::parse_float(&stopLossPrice));
}
if !is_equal(&takeProfitPrice, &Value::Null) {
if is_true(&omitParams) {
params = self.omit(params.clone(), Value::Str("takeProfitPrice".to_string()), &[]);
}
takeProfitPriceStr = self.price_to_precision(symbol.clone(), crate::runtime::parse_float(&takeProfitPrice));
}
return Value::List(vec![triggerPriceStr.clone(), stopLossPriceStr.clone(), takeProfitPriceStr.clone(), params.clone()]);
Value::Null
}
fn handle_trigger_direction_and_params(&self, mut params: Value, optional_args: &[Value]) -> Value {
let mut exchangeSpecificKey = get_arg(optional_args, 0, Value::Null);
let mut allowEmpty = get_arg(optional_args, 1, Value::Bool(false));
/*
* @ignore
* @method
* @returns {[string, object]} the trigger-direction value and omited params
*/
let mut triggerDirection: Value = self.safe_string_k(params.clone(), "triggerDirection", &[]);
let mut exchangeSpecificDefined: bool = is_true(&(!is_equal(&exchangeSpecificKey, &Value::Null))) && is_true(&(Value::Bool(in_op(¶ms, &exchangeSpecificKey))));
if !is_equal(&triggerDirection, &Value::Null) {
params = self.omit(params.clone(), Value::Str("triggerDirection".to_string()), &[]);
}
// throw exception if:
// A) if provided value is not unified (support old "up/down" strings too)
// B) if exchange specific "trigger direction key" (eg. "stopPriceSide") was not provided
if !is_true(&self.in_array(triggerDirection.clone(), Value::List(vec![Value::Str("ascending".to_string()), Value::Str("descending".to_string()), Value::Str("up".to_string()), Value::Str("down".to_string()), Value::Str("above".to_string()), Value::Str("below".to_string())]))) && !is_true(&exchangeSpecificDefined) && !is_true(&allowEmpty) {
panic!("{}", crate::exchange_errors::arguments_required(add(&self.id, &Value::Str(" createOrder() : trigger orders require params[\"triggerDirection\"] to be either \"ascending\" or \"descending\"".to_string()))));
}
// if old format was provided, overwrite to new
if is_equal(&triggerDirection, &Value::Str("up".to_string())) || is_equal(&triggerDirection, &Value::Str("above".to_string())) {
triggerDirection = Value::Str("ascending".to_string());
} else if is_equal(&triggerDirection, &Value::Str("down".to_string())) || is_equal(&triggerDirection, &Value::Str("below".to_string())) {
triggerDirection = Value::Str("descending".to_string());
}
return Value::List(vec![triggerDirection.clone(), params.clone()]);
Value::Null
}
fn handle_trigger_and_params(&self, mut params: Value) -> Value {
let mut isTrigger: Value = self.safe_bool2(params.clone(), Value::Str("trigger".to_string()), Value::Str("stop".to_string()), &[]);
if is_equal(&isTrigger, &Value::Bool(true)) {
params = self.omit(params.clone(), Value::List(vec![Value::Str("trigger".to_string()), Value::Str("stop".to_string())]), &[]);
}
return Value::List(vec![isTrigger.clone(), params.clone()]);
Value::Null
}
fn is_trigger_order(&self, mut params: Value) -> Value {
return self.handle_trigger_and_params(params.clone());
Value::Null
}
fn is_post_only(&self, mut isMarketOrder: Value, mut exchangeSpecificParam: Value, optional_args: &[Value]) -> Value {
let mut params = get_arg(optional_args, 0, Value::Map({
let mut m = indexmap::IndexMap::new();
m
}));
/*
* @ignore
* @method
* @param {string} type Order type
* @param {boolean} exchangeSpecificParam exchange specific postOnly
* @param {object} [params] exchange specific params
* @returns {boolean} true if a post only order, false otherwise
*/
let mut timeInForce: Value = self.safe_string_upper(params.clone(), Value::Str("timeInForce".to_string()), &[]);
let mut postOnly: Value = self.safe_bool2(params.clone(), Value::Str("postOnly".to_string()), Value::Str("post_only".to_string()), &[Value::Bool(false)]);
// we assume timeInForce is uppercase from safeStringUpper (params, 'timeInForce')
let mut ioc: bool = is_equal(&timeInForce, &Value::Str("IOC".to_string()));
let mut fok: bool = is_equal(&timeInForce, &Value::Str("FOK".to_string()));
let mut timeInForcePostOnly: Value = Value::Bool(is_equal(&timeInForce, &Value::Str("PO".to_string())));
if !is_equal(&postOnly, &Value::Bool(true)) {
postOnly = timeInForcePostOnly.clone();
}
if !is_equal(&postOnly, &Value::Bool(true)) {
postOnly = exchangeSpecificParam.clone();
}
if is_equal(&postOnly, &Value::Bool(true)) {
if is_true(&ioc) || is_true(&fok) {
panic!("{}", crate::exchange_errors::invalid_order(add(&add(&self.id, &Value::Str(" postOnly orders cannot have timeInForce equal to ".to_string())), &timeInForce)));
} else if is_true(&isMarketOrder) {
panic!("{}", crate::exchange_errors::invalid_order(add(&self.id, &Value::Str(" market orders cannot be postOnly".to_string()))));
} else {
return Value::Bool(true);
}
} else {
return Value::Bool(false);
}
Value::Null
}
fn handle_post_only(&self, mut isMarketOrder: Value, mut exchangeSpecificPostOnlyOption: Value, optional_args: &[Value]) -> Value {
let mut params = get_arg(optional_args, 0, Value::Map({
let mut m = indexmap::IndexMap::new();
m
}));
/*
* @ignore
* @method
* @param {string} type Order type
* @param {boolean} exchangeSpecificBoolean exchange specific postOnly
* @param {object} [params] exchange specific params
* @returns {Array}
*/
let mut timeInForce: Value = self.safe_string_upper(params.clone(), Value::Str("timeInForce".to_string()), &[]);
let mut postOnly: Value = self.safe_bool_k(params.clone(), "postOnly", &[Value::Bool(false)]);
let mut ioc: bool = is_equal(&timeInForce, &Value::Str("IOC".to_string()));
let mut fok: bool = is_equal(&timeInForce, &Value::Str("FOK".to_string()));
let mut po: Value = Value::Bool(is_equal(&timeInForce, &Value::Str("PO".to_string())));
if !is_equal(&postOnly, &Value::Bool(true)) {
postOnly = po.clone();
}
if !is_equal(&postOnly, &Value::Bool(true)) {
postOnly = exchangeSpecificPostOnlyOption.clone();
}
if is_equal(&postOnly, &Value::Bool(true)) {
if is_true(&ioc) || is_true(&fok) {
panic!("{}", crate::exchange_errors::invalid_order(add(&add(&self.id, &Value::Str(" postOnly orders cannot have timeInForce equal to ".to_string())), &timeInForce)));
} else if is_true(&isMarketOrder) {
panic!("{}", crate::exchange_errors::invalid_order(add(&self.id, &Value::Str(" market orders cannot be postOnly".to_string()))));
} else {
if is_true(&po) {
params = self.omit(params.clone(), Value::Str("timeInForce".to_string()), &[]);
}
params = self.omit(params.clone(), Value::Str("postOnly".to_string()), &[]);
return Value::List(vec![Value::Bool(true), params.clone()]);
}
}
return Value::List(vec![Value::Bool(false), params.clone()]);
Value::Null
}
fn fetch_last_prices(&mut self, optional_args: &[Value]) -> impl ::std::future::Future<Output = Value> + Send { async move {
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
}));
panic!("{}", crate::exchange_errors::not_supported(add(&self.id, &Value::Str(" fetchLastPrices() is not supported yet".to_string()))));
Value::Null
} }
fn fetch_trading_fees(&mut self, optional_args: &[Value]) -> impl ::std::future::Future<Output = Value> + Send { async move {
// async-virtual: try the derived exchange first
if let Some(__v) = self.dispatch_to_derived("fetch_trading_fees", { let mut __args: Vec<crate::Value> = Vec::new(); __args.extend_from_slice(optional_args); __args }).await {
if !matches!(__v, crate::Value::Null) { return __v; }
}
let mut params = get_arg(optional_args, 0, Value::Map({
let mut m = indexmap::IndexMap::new();
m
}));
panic!("{}", crate::exchange_errors::not_supported(add(&self.id, &Value::Str(" fetchTradingFees() is not supported yet".to_string()))));
Value::Null
} }
fn fetch_trading_fees_ws(&mut self, optional_args: &[Value]) -> impl ::std::future::Future<Output = Value> + Send { async move {
let mut params = get_arg(optional_args, 0, Value::Map({
let mut m = indexmap::IndexMap::new();
m
}));
panic!("{}", crate::exchange_errors::not_supported(add(&self.id, &Value::Str(" fetchTradingFeesWs() is not supported yet".to_string()))));
Value::Null
} }
fn fetch_convert_currencies(&mut self, optional_args: &[Value]) -> impl ::std::future::Future<Output = Value> + Send { async move {
let mut params = get_arg(optional_args, 0, Value::Map({
let mut m = indexmap::IndexMap::new();
m
}));
panic!("{}", crate::exchange_errors::not_supported(add(&self.id, &Value::Str(" fetchConvertCurrencies() is not supported yet".to_string()))));
Value::Null
} }
fn parse_open_interest(&self, mut interest: Value, optional_args: &[Value]) -> Value {
// virtual-dispatch (static: DerivedExchange::parse_open_interest(self, ...))
{ let __v = crate::exchange::DerivedExchange::parse_open_interest(self, interest.clone(), crate::runtime::get_arg(optional_args, 0, crate::Value::Null)); if !matches!(__v, crate::Value::Null) { return __v; } }
let mut market = get_arg(optional_args, 0, Value::Null);
panic!("{}", crate::exchange_errors::not_supported(add(&self.id, &Value::Str(" parseOpenInterest () is not supported yet".to_string()))));
Value::Null
}
fn parse_open_interests(&self, mut response: Value, optional_args: &[Value]) -> Value {
let mut symbols = get_arg(optional_args, 0, Value::Null);
let mut result: Value = Value::Map({
let mut m = indexmap::IndexMap::new();
m
});
{
let mut i: Value = Value::Int(0);
let mut __for_first_152: bool = true;
while { if !__for_first_152 { i = add(&i, &Value::Int(1)); } __for_first_152 = false; is_less_than(&i, &get_array_length(&response)) } {
let mut entry: Value = get_value(&response, &i);
let mut entry: Value = get_value(&response, &i);
let mut parsed: Value = <Self as crate::exchange_generated::ExchangeBase>::parse_open_interest(self, entry.clone(), &[]);
if !is_equal(&get_value(&parsed, &Value::Str("symbol".to_string())), &Value::Null) {
add_element_to_object(&mut result, &get_value(&parsed, &Value::Str("symbol".to_string())), parsed.clone());
}
}
}
return self.filter_by_array(result.clone(), Value::Str("symbol".to_string()), &[symbols.clone()]);
Value::Null
}
fn parse_open_interests_history(&self, mut response: 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 interests: Value = Value::List(vec![]);
{
let mut i: Value = Value::Int(0);
let mut __for_first_153: bool = true;
while { if !__for_first_153 { i = add(&i, &Value::Int(1)); } __for_first_153 = false; is_less_than(&i, &get_array_length(&response)) } {
let mut entry: Value = get_value(&response, &i);
let mut entry: Value = get_value(&response, &i);
let mut interest: Value = <Self as crate::exchange_generated::ExchangeBase>::parse_open_interest(self, entry.clone(), &[market.clone()]);
append_to_array(&mut interests, interest.clone());
}
}
let mut sorted: Value = self.sort_by(interests.clone(), Value::Str("timestamp".to_string()), &[]);
let mut symbol: Value = self.safe_string_k(market.clone(), "symbol", &[]);
return self.filter_by_symbol_since_limit(sorted.clone(), &[symbol.clone(), since.clone(), limit.clone()]);
Value::Null
}
fn fetch_funding_rate(&mut self, mut symbol: Value, optional_args: &[Value]) -> impl ::std::future::Future<Output = Value> + Send { async move {
// async-virtual: try the derived exchange first
if let Some(__v) = self.dispatch_to_derived("fetch_funding_rate", { let mut __args: Vec<crate::Value> = Vec::new(); __args.push(symbol.clone()); __args.extend_from_slice(optional_args); __args }).await {
if !matches!(__v, crate::Value::Null) { return __v; }
}
let mut params = get_arg(optional_args, 0, Value::Map({
let mut m = indexmap::IndexMap::new();
m
}));
if !is_equal(&get_value(&self.has, &Value::Str("fetchFundingRates".to_string())), &Value::Null) && !is_equal(&get_value(&self.has, &Value::Str("fetchFundingRates".to_string())), &Value::Bool(false)) {
self.load_markets(&[]).await;
let mut market: Value = self.market(symbol.clone());
symbol = get_value(&market, &Value::Str("symbol".to_string()));
if !is_equal(&get_value(&market, &Value::Str("contract".to_string())), &Value::Bool(true)) {
panic!("{}", crate::exchange_errors::bad_symbol(add(&self.id, &Value::Str(" fetchFundingRate() supports contract markets only".to_string()))));
}
let mut rates: Value = self.fetch_funding_rates(&[Value::List(vec![symbol.clone()]), params.clone()]).await;
let mut rate: Value = self.safe_value(rates.clone(), symbol.clone(), &[]);
if is_equal(&rate, &Value::Null) {
panic!("{}", crate::exchange_errors::null_response(add(&add(&self.id, &Value::Str(" fetchFundingRate () returned no data for ".to_string())), &symbol)));
} else {
return rate;
}
} else {
panic!("{}", crate::exchange_errors::not_supported(add(&self.id, &Value::Str(" fetchFundingRate () is not supported yet".to_string()))));
}
Value::Null
} }
fn fetch_funding_interval(&mut self, mut symbol: Value, optional_args: &[Value]) -> impl ::std::future::Future<Output = Value> + Send { async move {
// async-virtual: try the derived exchange first
if let Some(__v) = self.dispatch_to_derived("fetch_funding_interval", { let mut __args: Vec<crate::Value> = Vec::new(); __args.push(symbol.clone()); __args.extend_from_slice(optional_args); __args }).await {
if !matches!(__v, crate::Value::Null) { return __v; }
}
let mut params = get_arg(optional_args, 0, Value::Map({
let mut m = indexmap::IndexMap::new();
m
}));
if !is_equal(&get_value(&self.has, &Value::Str("fetchFundingIntervals".to_string())), &Value::Null) && !is_equal(&get_value(&self.has, &Value::Str("fetchFundingIntervals".to_string())), &Value::Bool(false)) {
self.load_markets(&[]).await;
let mut market: Value = self.market(symbol.clone());
symbol = get_value(&market, &Value::Str("symbol".to_string()));
if !is_equal(&get_value(&market, &Value::Str("contract".to_string())), &Value::Bool(true)) {
panic!("{}", crate::exchange_errors::bad_symbol(add(&self.id, &Value::Str(" fetchFundingInterval() supports contract markets only".to_string()))));
}
let mut rates: Value = self.fetch_funding_intervals(&[Value::List(vec![symbol.clone()]), params.clone()]).await;
let mut rate: Value = self.safe_value(rates.clone(), symbol.clone(), &[]);
if is_equal(&rate, &Value::Null) {
panic!("{}", crate::exchange_errors::null_response(add(&add(&self.id, &Value::Str(" fetchFundingInterval() returned no data for ".to_string())), &symbol)));
} else {
return rate;
}
} else {
panic!("{}", crate::exchange_errors::not_supported(add(&self.id, &Value::Str(" fetchFundingInterval() is not supported yet".to_string()))));
}
Value::Null
} }
fn fetch_mark_ohlcv(&mut self, mut symbol: Value, optional_args: &[Value]) -> impl ::std::future::Future<Output = Value> + Send { async move {
let mut timeframe = get_arg(optional_args, 0, Value::Str("1m".to_string()));
let mut since = get_arg(optional_args, 1, Value::Null);
let mut limit = get_arg(optional_args, 2, Value::Null);
let mut params = get_arg(optional_args, 3, Value::Map({
let mut m = indexmap::IndexMap::new();
m
}));
/*
* @method
* @name exchange#fetchMarkOHLCV
* @description fetches historical mark price candlestick data containing the open, high, low, and close price of a market
* @param {string} symbol unified symbol of the market to fetch OHLCV data for
* @param {string} timeframe the length of time each candle represents
* @param {int} [since] timestamp in ms of the earliest candle to fetch
* @param {int} [limit] the maximum amount of candles to fetch
* @param {object} [params] extra parameters specific to the exchange API endpoint
* @returns {float[][]} A list of candles ordered as timestamp, open, high, low, close, undefined
*/
if !is_equal(&get_value(&self.has, &Value::Str("fetchMarkOHLCV".to_string())), &Value::Null) && !is_equal(&get_value(&self.has, &Value::Str("fetchMarkOHLCV".to_string())), &Value::Bool(false)) {
let mut request: Value = Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("price".to_string(), Value::Str("mark".to_string()));
m
});
return self.fetch_ohlcv(symbol.clone(), &[timeframe.clone(), since.clone(), limit.clone(), self.extend(request.clone(), &[params.clone()])]).await;
} else {
panic!("{}", crate::exchange_errors::not_supported(add(&self.id, &Value::Str(" fetchMarkOHLCV () is not supported yet".to_string()))));
}
} }
fn fetch_index_ohlcv(&mut self, mut symbol: Value, optional_args: &[Value]) -> impl ::std::future::Future<Output = Value> + Send { async move {
let mut timeframe = get_arg(optional_args, 0, Value::Str("1m".to_string()));
let mut since = get_arg(optional_args, 1, Value::Null);
let mut limit = get_arg(optional_args, 2, Value::Null);
let mut params = get_arg(optional_args, 3, Value::Map({
let mut m = indexmap::IndexMap::new();
m
}));
/*
* @method
* @name exchange#fetchIndexOHLCV
* @description fetches historical index price candlestick data containing the open, high, low, and close price of a market
* @param {string} symbol unified symbol of the market to fetch OHLCV data for
* @param {string} timeframe the length of time each candle represents
* @param {int} [since] timestamp in ms of the earliest candle to fetch
* @param {int} [limit] the maximum amount of candles to fetch
* @param {object} [params] extra parameters specific to the exchange API endpoint
* @returns {} A list of candles ordered as timestamp, open, high, low, close, undefined
*/
if !is_equal(&get_value(&self.has, &Value::Str("fetchIndexOHLCV".to_string())), &Value::Null) && !is_equal(&get_value(&self.has, &Value::Str("fetchIndexOHLCV".to_string())), &Value::Bool(false)) {
let mut request: Value = Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("price".to_string(), Value::Str("index".to_string()));
m
});
return self.fetch_ohlcv(symbol.clone(), &[timeframe.clone(), since.clone(), limit.clone(), self.extend(request.clone(), &[params.clone()])]).await;
} else {
panic!("{}", crate::exchange_errors::not_supported(add(&self.id, &Value::Str(" fetchIndexOHLCV () is not supported yet".to_string()))));
}
} }
fn fetch_premium_index_ohlcv(&mut self, mut symbol: Value, optional_args: &[Value]) -> impl ::std::future::Future<Output = Value> + Send { async move {
// async-virtual: try the derived exchange first
if let Some(__v) = self.dispatch_to_derived("fetch_premium_index_ohlcv", { let mut __args: Vec<crate::Value> = Vec::new(); __args.push(symbol.clone()); __args.extend_from_slice(optional_args); __args }).await {
if !matches!(__v, crate::Value::Null) { return __v; }
}
let mut timeframe = get_arg(optional_args, 0, Value::Str("1m".to_string()));
let mut since = get_arg(optional_args, 1, Value::Null);
let mut limit = get_arg(optional_args, 2, Value::Null);
let mut params = get_arg(optional_args, 3, Value::Map({
let mut m = indexmap::IndexMap::new();
m
}));
/*
* @method
* @name exchange#fetchPremiumIndexOHLCV
* @description fetches historical premium index price candlestick data containing the open, high, low, and close price of a market
* @param {string} symbol unified symbol of the market to fetch OHLCV data for
* @param {string} timeframe the length of time each candle represents
* @param {int} [since] timestamp in ms of the earliest candle to fetch
* @param {int} [limit] the maximum amount of candles to fetch
* @param {object} [params] extra parameters specific to the exchange API endpoint
* @returns {float[][]} A list of candles ordered as timestamp, open, high, low, close, undefined
*/
if !is_equal(&get_value(&self.has, &Value::Str("fetchPremiumIndexOHLCV".to_string())), &Value::Null) && !is_equal(&get_value(&self.has, &Value::Str("fetchPremiumIndexOHLCV".to_string())), &Value::Bool(false)) {
let mut request: Value = Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("price".to_string(), Value::Str("premiumIndex".to_string()));
m
});
return self.fetch_ohlcv(symbol.clone(), &[timeframe.clone(), since.clone(), limit.clone(), self.extend(request.clone(), &[params.clone()])]).await;
} else {
panic!("{}", crate::exchange_errors::not_supported(add(&self.id, &Value::Str(" fetchPremiumIndexOHLCV () is not supported yet".to_string()))));
}
} }
fn handle_time_in_force(&self, optional_args: &[Value]) -> Value {
let mut params = get_arg(optional_args, 0, Value::Map({
let mut m = indexmap::IndexMap::new();
m
}));
/*
* @ignore
* @method
* Must add timeInForce to this.options to use this method
* @returns {string} returns the exchange specific value for timeInForce
*/
let mut timeInForce: Value = self.safe_string_upper(params.clone(), Value::Str("timeInForce".to_string()), &[]); // supported values GTC, IOC, PO
if !is_equal(&timeInForce, &Value::Null) {
let mut exchangeValue: Value = self.safe_string(get_value(&self.options, &Value::Str("timeInForce".to_string())), timeInForce.clone(), &[]);
if is_equal(&exchangeValue, &Value::Null) {
panic!("{}", crate::exchange_errors::exchange_error(add(&add(&add(&self.id, &Value::Str(" does not support timeInForce \"".to_string())), &timeInForce), &Value::Str("\"".to_string()))));
}
return exchangeValue;
}
return Value::Null;
Value::Null
}
fn convert_type_to_account(&self, mut account: Value) -> Value {
/*
* @ignore
* @method
* Must add accountsByType to this.options to use this method
* @param {string} account key for account name in this.options['accountsByType']
* @returns the exchange specific account name or the isolated margin id for transfers
*/
let mut accountsByType: Value = self.safe_dict_k(self.options.clone(), "accountsByType", &[Value::Map({
let mut m = indexmap::IndexMap::new();
m
})]);
let mut lowercaseAccount: Value = to_lower(&account);
if is_true(&Value::Bool(in_op(&accountsByType, &lowercaseAccount))) {
return get_value(&accountsByType, &lowercaseAccount);
}
let mut markets: Value = self.markets.clone();
let mut marketsById: Value = self.markets_by_id.clone();
if is_true(&(is_true(&(!is_equal(&markets, &Value::Null))) && is_true(&(Value::Bool(in_op(&markets, &account)))))) || is_true(&(is_true(&(!is_equal(&marketsById, &Value::Null))) && is_true(&(Value::Bool(in_op(&marketsById, &account)))))) {
let mut market: Value = self.market(account.clone());
return get_value(&market, &Value::Str("id".to_string()));
} else {
return account;
}
Value::Null
}
fn check_required_argument(&self, mut methodName: Value, mut argument: Value, mut argumentName: Value, optional_args: &[Value]) {
let mut options = get_arg(optional_args, 0, Value::List(vec![]));
/*
* @ignore
* @method
* @param {string} methodName the name of the method that the argument is being checked for
* @param {string} argument the argument's actual value provided
* @param {string} argumentName the name of the argument being checked (for logging purposes)
* @param {string[]} options a list of options that the argument can be
* @returns {undefined}
*/
let mut optionsLength: Value = get_array_length(&options);
if is_true(&(is_equal(&argument, &Value::Null))) || is_true(&(is_true(&(is_greater_than(&optionsLength, &Value::Int(0)))) && is_true(&(!is_true(&(self.in_array(argument.clone(), options.clone()))))))) {
let mut messageOptions: Value = join(&options, &Value::Str(", ".to_string()));
let mut message: Value = add(&add(&add(&add(&add(&self.id, &Value::Str(" ".to_string())), &methodName), &Value::Str("() requires a ".to_string())), &argumentName), &Value::Str(" argument".to_string()));
if !is_equal(&messageOptions, &Value::Str("".to_string())) {
message = add(&message, &add(&add(&add(&Value::Str(", one of ".to_string()), &Value::Str("(".to_string())), &messageOptions), &Value::Str(")".to_string())));
}
panic!("{}", crate::exchange_errors::arguments_required(message));
}
}
fn check_required_margin_argument(&self, mut methodName: Value, mut symbol: Value, mut marginMode: Value) {
/*
* @ignore
* @method
* @param {string} symbol unified symbol of the market
* @param {string} methodName name of the method that requires a symbol
* @param {string} marginMode is either 'isolated' or 'cross'
*/
if is_true(&(is_equal(&marginMode, &Value::Str("isolated".to_string())))) && is_true(&(is_equal(&symbol, &Value::Null))) {
panic!("{}", crate::exchange_errors::arguments_required(add(&add(&add(&self.id, &Value::Str(" ".to_string())), &methodName), &Value::Str("() requires a symbol argument for isolated margin".to_string()))));
} else if is_true(&(is_equal(&marginMode, &Value::Str("cross".to_string())))) && is_true(&(!is_equal(&symbol, &Value::Null))) {
panic!("{}", crate::exchange_errors::arguments_required(add(&add(&add(&self.id, &Value::Str(" ".to_string())), &methodName), &Value::Str("() cannot have a symbol argument for cross margin".to_string()))));
}
}
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);
/*
* @ignore
* @method
* @param {object[]|object} response unparsed response from the exchange
* @param {string[]|undefined} codes the unified currency codes to fetch transactions fees for, returns all currencies when undefined
* @param {str} currencyIdKey *should only be undefined when response is a dictionary* the object key that corresponds to the currency id
* @returns {object} objects with withdraw and deposit fees, indexed by currency codes
*/
let mut depositWithdrawFees: Value = Value::Map({
let mut m = indexmap::IndexMap::new();
m
});
let mut isArray: bool = is_array(&response);
let mut responseKeys: Value = response.clone();
if !is_true(&isArray) {
responseKeys = object_keys(&response);
}
{
let mut i: Value = Value::Int(0);
let mut __for_first_154: bool = true;
while { if !__for_first_154 { i = add(&i, &Value::Int(1)); } __for_first_154 = false; is_less_than(&i, &get_array_length(&responseKeys)) } {
let mut entry: Value = get_value(&responseKeys, &i);
let mut entry: Value = get_value(&responseKeys, &i);
let mut dictionary: Value = ternary(is_true(&isArray), entry.clone(), get_value(&response, &entry));
let mut currencyId: Value = entry.clone();
if is_true(&isArray) {
currencyId = ternary(is_true(&(is_equal(¤cyIdKey, &Value::Null))), Value::Null, self.safe_string(dictionary.clone(), currencyIdKey.clone(), &[]));
}
let mut currency: Value = self.safe_currency(currencyId.clone(), &[]);
let mut code: Value = self.safe_string_k(currency.clone(), "code", &[]);
if is_true(&(is_equal(&codes, &Value::Null))) || is_true(&(self.in_array(code.clone(), codes.clone()))) {
add_element_to_object(&mut depositWithdrawFees, &code, <Self as crate::exchange_generated::ExchangeBase>::parse_deposit_withdraw_fee(self, dictionary.clone(), &[currency.clone()]));
}
}
}
return depositWithdrawFees;
Value::Null
}
fn parse_deposit_withdraw_fee(&self, mut fee: Value, optional_args: &[Value]) -> Value {
// virtual-dispatch (static: DerivedExchange::parse_deposit_withdraw_fee(self, ...))
{ let __v = crate::exchange::DerivedExchange::parse_deposit_withdraw_fee(self, fee.clone(), crate::runtime::get_arg(optional_args, 0, crate::Value::Null)); if !matches!(__v, crate::Value::Null) { return __v; } }
let mut currency = get_arg(optional_args, 0, Value::Null);
panic!("{}", crate::exchange_errors::not_supported(add(&self.id, &Value::Str(" parseDepositWithdrawFee() is not supported yet".to_string()))));
Value::Null
}
fn deposit_withdraw_fee(&self, mut info: Value) -> Value {
return Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("info".to_string(), info.clone());
m.insert("withdraw".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("fee".to_string(), Value::Null);
m.insert("percentage".to_string(), Value::Null);
m
}));
m.insert("deposit".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("fee".to_string(), Value::Null);
m.insert("percentage".to_string(), Value::Null);
m
}));
m.insert("networks".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m
}));
m
});
Value::Null
}
fn assign_default_deposit_withdraw_fees(&self, mut fee: Value, optional_args: &[Value]) -> Value {
let mut currency = get_arg(optional_args, 0, Value::Null);
/*
* @ignore
* @method
* @description Takes a depositWithdrawFee structure and assigns the default values for withdraw and deposit
* @param {object} fee A deposit withdraw fee structure
* @param {object} currency A currency structure, the response from this.currency ()
* @returns {object} A deposit withdraw fee structure
*/
let mut networkKeys: Value = object_keys(&get_value(&fee, &Value::Str("networks".to_string())));
let mut numNetworks: Value = get_array_length(&networkKeys);
if is_equal(&numNetworks, &Value::Int(1)) {
{ let __be_tmp = get_value(&get_value(&get_value(&fee, &Value::Str("networks".to_string())), &get_value(&networkKeys, &Value::Int(0))), &Value::Str("withdraw".to_string())); add_element_to_object(&mut fee, &Value::Str("withdraw".to_string()), __be_tmp); };
{ let __be_tmp = get_value(&get_value(&get_value(&fee, &Value::Str("networks".to_string())), &get_value(&networkKeys, &Value::Int(0))), &Value::Str("deposit".to_string())); add_element_to_object(&mut fee, &Value::Str("deposit".to_string()), __be_tmp); };
return fee;
}
let mut currencyCode: Value = self.safe_string_k(currency.clone(), "code", &[]);
{
let mut i: Value = Value::Int(0);
let mut __for_first_155: bool = true;
while { if !__for_first_155 { i = add(&i, &Value::Int(1)); } __for_first_155 = false; is_less_than(&i, &numNetworks) } {
let mut network: Value = get_value(&networkKeys, &i);
let mut network: Value = get_value(&networkKeys, &i);
if is_equal(&network, ¤cyCode) {
{ let __be_tmp = get_value(&get_value(&get_value(&fee, &Value::Str("networks".to_string())), &get_value(&networkKeys, &i)), &Value::Str("withdraw".to_string())); add_element_to_object(&mut fee, &Value::Str("withdraw".to_string()), __be_tmp); };
{ let __be_tmp = get_value(&get_value(&get_value(&fee, &Value::Str("networks".to_string())), &get_value(&networkKeys, &i)), &Value::Str("deposit".to_string())); add_element_to_object(&mut fee, &Value::Str("deposit".to_string()), __be_tmp); };
}
}
}
return fee;
Value::Null
}
fn parse_income(&self, mut info: Value, optional_args: &[Value]) -> Value {
// virtual-dispatch (static: DerivedExchange::parse_income(self, ...))
{ let __v = crate::exchange::DerivedExchange::parse_income(self, info.clone(), crate::runtime::get_arg(optional_args, 0, crate::Value::Null)); if !matches!(__v, crate::Value::Null) { return __v; } }
let mut market = get_arg(optional_args, 0, Value::Null);
panic!("{}", crate::exchange_errors::not_supported(add(&self.id, &Value::Str(" parseIncome () is not supported yet".to_string()))));
Value::Null
}
fn parse_incomes(&self, mut incomes: 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);
/*
* @ignore
* @method
* @description parses funding fee info from exchange response
* @param {object[]} incomes each item describes once instance of currency being received or paid
* @param {object} market ccxt market
* @param {int} [since] when defined, the response items are filtered to only include items after this timestamp
* @param {int} [limit] limits the number of items in the response
* @returns {object[]} an array of [funding history structures]{@link https://docs.ccxt.com/?id=funding-history-structure}
*/
let mut result: Value = Value::List(vec![]);
{
let mut i: Value = Value::Int(0);
let mut __for_first_156: bool = true;
while { if !__for_first_156 { i = add(&i, &Value::Int(1)); } __for_first_156 = false; is_less_than(&i, &get_array_length(&incomes)) } {
let mut entry: Value = get_value(&incomes, &i);
let mut entry: Value = get_value(&incomes, &i);
let mut parsed: Value = <Self as crate::exchange_generated::ExchangeBase>::parse_income(self, entry.clone(), &[market.clone()]);
append_to_array(&mut result, parsed.clone());
}
}
let mut sorted: Value = self.sort_by(result.clone(), Value::Str("timestamp".to_string()), &[]);
let mut symbol: Value = self.safe_string_k(market.clone(), "symbol", &[]);
return self.filter_by_symbol_since_limit(sorted.clone(), &[symbol.clone(), since.clone(), limit.clone()]);
Value::Null
}
fn get_market_from_symbols(&self, optional_args: &[Value]) -> Value {
let mut symbols = get_arg(optional_args, 0, Value::Null);
/*
* @param {string[]|undefined} symbols list of unified symbols (first element selects the market)
* @returns {MarketInterface|undefined} market structure for the first symbol, or undefined if symbols is undefined
* Overloads: non-null `string[]` input yields `MarketInterface`; optional input yields `Market`.
*/
if is_equal(&symbols, &Value::Null) {
return Value::Null;
}
let mut firstMarket: Value = self.safe_string(symbols.clone(), Value::Int(0), &[]);
if is_equal(&firstMarket, &Value::Null) {
return Value::Null;
}
let mut market: Value = self.market(firstMarket.clone());
return market;
Value::Null
}
fn parse_ws_ohlc_vs(&self, mut ohlcvs: Value, optional_args: &[Value]) -> Value {
let mut market = get_arg(optional_args, 0, Value::Null);
let mut timeframe = get_arg(optional_args, 1, Value::Str("1m".to_string()));
let mut since = get_arg(optional_args, 2, Value::Null);
let mut limit = get_arg(optional_args, 3, Value::Null);
let mut results: Value = Value::List(vec![]);
{
let mut i: Value = Value::Int(0);
let mut __for_first_157: bool = true;
while { if !__for_first_157 { i = add(&i, &Value::Int(1)); } __for_first_157 = false; is_less_than(&i, &get_array_length(&ohlcvs)) } {
append_to_array(&mut results, self.parse_ws_ohlcv(get_value(&ohlcvs, &i), &[market.clone()]));
}
}
return results;
Value::Null
}
fn fetch_transactions(&mut self, optional_args: &[Value]) -> impl ::std::future::Future<Output = Value> + Send { async move {
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
}));
/*
* @method
* @name exchange#fetchTransactions
* @deprecated
* @description *DEPRECATED* use fetchDepositsWithdrawals instead
* @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 is undefined
* @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}
*/
if !is_equal(&get_value(&self.has, &Value::Str("fetchDepositsWithdrawals".to_string())), &Value::Null) && !is_equal(&get_value(&self.has, &Value::Str("fetchDepositsWithdrawals".to_string())), &Value::Bool(false)) {
return self.fetch_deposits_withdrawals(&[code.clone(), since.clone(), limit.clone(), params.clone()]).await;
} else {
panic!("{}", crate::exchange_errors::not_supported(add(&self.id, &Value::Str(" fetchTransactions () is not supported yet".to_string()))));
}
} }
fn filter_by_array_positions(&self, mut objects: Value, mut key: Value, optional_args: &[Value]) -> Value {
let mut values = get_arg(optional_args, 0, Value::Null);
let mut indexed = get_arg(optional_args, 1, Value::Bool(true));
return self.filter_by_array(objects.clone(), key.clone(), &[values.clone(), indexed.clone()]);
Value::Null
}
fn filter_by_array_tickers(&self, mut objects: Value, mut key: Value, optional_args: &[Value]) -> Value {
let mut values = get_arg(optional_args, 0, Value::Null);
let mut indexed = get_arg(optional_args, 1, Value::Bool(true));
return self.filter_by_array(objects.clone(), key.clone(), &[values.clone(), indexed.clone()]);
Value::Null
}
fn filter_by_array_adl_ranks(&self, mut objects: Value, mut key: Value, optional_args: &[Value]) -> Value {
let mut values = get_arg(optional_args, 0, Value::Null);
let mut indexed = get_arg(optional_args, 1, Value::Bool(true));
return self.filter_by_array(objects.clone(), key.clone(), &[values.clone(), indexed.clone()]);
Value::Null
}
fn create_ohlcv_object(&self, mut symbol: Value, mut timeframe: Value, mut data: Value) -> Value {
let mut res: Value = Value::Map({
let mut m = indexmap::IndexMap::new();
m
});
add_element_to_object(&mut res, &symbol, Value::Map({
let mut m = indexmap::IndexMap::new();
m
}));
add_element_to_object(get_value_mut(&mut res, &symbol), &timeframe, data.clone());
return res;
Value::Null
}
fn handle_max_entries_per_request_and_params(&self, mut method: Value, optional_args: &[Value]) -> Value {
let mut maxEntriesPerRequest = get_arg(optional_args, 0, Value::Null);
let mut params = get_arg(optional_args, 1, Value::Map({
let mut m = indexmap::IndexMap::new();
m
}));
let mut newMaxEntriesPerRequest: Value = Value::Null;
{ let __destr_tmp = self.handle_option_and_params(params.clone(), method.clone(), Value::Str("maxEntriesPerRequest".to_string()), &[]); newMaxEntriesPerRequest = get_value(&__destr_tmp, &Value::Int(0)); params = get_value(&__destr_tmp, &Value::Int(1)); }
if is_true(&(!is_equal(&newMaxEntriesPerRequest, &Value::Null))) && is_true(&(!is_equal(&newMaxEntriesPerRequest, &maxEntriesPerRequest))) {
maxEntriesPerRequest = newMaxEntriesPerRequest.clone();
}
if is_equal(&maxEntriesPerRequest, &Value::Null) {
maxEntriesPerRequest = Value::Int(1000); // default to 1000
}
return Value::List(vec![maxEntriesPerRequest.clone(), params.clone()]);
Value::Null
}
fn fetch_paginated_call_dynamic(&mut self, mut method: Value, optional_args: &[Value]) -> impl ::std::future::Future<Output = Value> + Send { async move {
let mut symbol = get_arg(optional_args, 0, Value::Null);
let mut since = get_arg(optional_args, 1, Value::Null);
let mut limit = get_arg(optional_args, 2, Value::Null);
let mut params = get_arg(optional_args, 3, Value::Map({
let mut m = indexmap::IndexMap::new();
m
}));
let mut maxEntriesPerRequest = get_arg(optional_args, 4, Value::Null);
let mut removeRepeated = get_arg(optional_args, 5, Value::Bool(true));
let mut maxCalls: Value = Value::Int(10);
{ let __destr_tmp = self.handle_option_and_params(params.clone(), method.clone(), Value::Str("paginationCalls".to_string()), &[maxCalls.clone()]); maxCalls = get_value(&__destr_tmp, &Value::Int(0)); params = get_value(&__destr_tmp, &Value::Int(1)); }
let mut maxRetries: Value = Value::Int(3);
{ let __destr_tmp = self.handle_option_and_params(params.clone(), method.clone(), Value::Str("maxRetries".to_string()), &[maxRetries.clone()]); maxRetries = get_value(&__destr_tmp, &Value::Int(0)); params = get_value(&__destr_tmp, &Value::Int(1)); }
let mut paginationDirection: Value = Value::Null;
{ let __destr_tmp = self.handle_option_and_params(params.clone(), method.clone(), Value::Str("paginationDirection".to_string()), &[Value::Str("backward".to_string())]); paginationDirection = get_value(&__destr_tmp, &Value::Int(0)); params = get_value(&__destr_tmp, &Value::Int(1)); }
let mut paginationTimestamp: Value = Value::Null;
let mut removeRepeatedOption: Value = removeRepeated.clone();
{ let __destr_tmp = self.handle_option_and_params(params.clone(), method.clone(), Value::Str("removeRepeated".to_string()), &[removeRepeated.clone()]); removeRepeatedOption = get_value(&__destr_tmp, &Value::Int(0)); params = get_value(&__destr_tmp, &Value::Int(1)); }
let mut calls: Value = Value::Int(0);
let mut result: Value = Value::List(vec![]);
let mut errors: Value = Value::Int(0);
let mut until: Value = self.safe_integer_n(params.clone(), Value::List(vec![Value::Str("until".to_string()), Value::Str("untill".to_string()), Value::Str("till".to_string())]), &[]); // do not omit it from params here
{ let __destr_tmp = self.handle_max_entries_per_request_and_params(method.clone(), &[maxEntriesPerRequest.clone(), params.clone()]); maxEntriesPerRequest = get_value(&__destr_tmp, &Value::Int(0)); params = get_value(&__destr_tmp, &Value::Int(1)); }
if is_true(&(is_equal(&paginationDirection, &Value::Str("forward".to_string())))) {
if is_equal(&since, &Value::Null) {
panic!("{}", crate::exchange_errors::arguments_required(add(&self.id, &Value::Str(" pagination requires a since argument when paginationDirection set to forward".to_string()))));
}
paginationTimestamp = since.clone();
}
while is_true(&(is_less_than(&calls, &maxCalls))) {
calls = add(&calls, &Value::Int(1));
{
if is_equal(&paginationDirection, &Value::Str("backward".to_string())) {
// do it backwards, starting from the last
// UNTIL filtering is required in order to work
if !is_equal(&paginationTimestamp, &Value::Null) {
add_element_to_object(&mut params, &Value::Str("until".to_string()), subtract(&paginationTimestamp, &Value::Int(1)));
}
let mut response: Value = self.call_method(method.clone(), &[symbol.clone(), Value::Null, maxEntriesPerRequest.clone(), params.clone()]).await;
let mut responseLength: Value = get_array_length(&response);
if is_true(&self.verbose) {
let mut backwardMessage: Value = add(&add(&add(&add(&add(&Value::Str("Dynamic pagination call ".to_string()), &self.number_to_string(calls.clone())), &Value::Str(" method ".to_string())), &method), &Value::Str(" response length ".to_string())), &self.number_to_string(responseLength.clone()));
if !is_equal(&paginationTimestamp, &Value::Null) {
backwardMessage = add(&backwardMessage, &add(&Value::Str(" timestamp ".to_string()), &self.number_to_string(paginationTimestamp.clone())));
}
self.log(backwardMessage.clone());
}
if is_equal(&responseLength, &Value::Int(0)) {
break;
}
errors = Value::Int(0);
result = self.array_concat(result.clone(), response.clone());
let mut firstElement: Value = self.safe_value(response.clone(), Value::Int(0), &[]);
paginationTimestamp = self.safe_integer2(firstElement.clone(), Value::Str("timestamp".to_string()), Value::Int(0), &[]);
if is_equal(&paginationTimestamp, &Value::Null) {
break;
}
if is_true(&(!is_equal(&since, &Value::Null))) && is_true(&(is_less_than_or_equal(&paginationTimestamp, &since))) {
break;
}
} else {
// do it forwards, starting from the since
let mut response: Value = self.call_method(method.clone(), &[symbol.clone(), paginationTimestamp.clone(), maxEntriesPerRequest.clone(), params.clone()]).await;
let mut responseLength: Value = get_array_length(&response);
if is_true(&self.verbose) {
let mut forwardMessage: Value = add(&add(&add(&add(&add(&Value::Str("Dynamic pagination call ".to_string()), &self.number_to_string(calls.clone())), &Value::Str(" method ".to_string())), &method), &Value::Str(" response length ".to_string())), &self.number_to_string(responseLength.clone()));
if !is_equal(&paginationTimestamp, &Value::Null) {
forwardMessage = add(&forwardMessage, &add(&Value::Str(" timestamp ".to_string()), &self.number_to_string(paginationTimestamp.clone())));
}
self.log(forwardMessage.clone());
}
if is_equal(&responseLength, &Value::Int(0)) {
break;
}
errors = Value::Int(0);
result = self.array_concat(result.clone(), response.clone());
let mut last: Value = self.safe_value(response.clone(), subtract(&responseLength, &Value::Int(1)), &[]);
let mut lastTimestamp: Value = self.safe_integer_k(last.clone(), "timestamp", &[Value::Int(0)]);
if is_equal(&lastTimestamp, &Value::Null) {
break;
}
let mut nextPaginationTimestamp: Value = add(&lastTimestamp, &Value::Int(1));
paginationTimestamp = nextPaginationTimestamp.clone();
if is_true(&(!is_equal(&until, &Value::Null))) && is_true(&(is_greater_than_or_equal(&nextPaginationTimestamp, &until))) {
break;
}
}
}
}
let mut uniqueResults: Value = result.clone();
if is_true(&removeRepeatedOption) {
uniqueResults = self.remove_repeated_elements_from_array(result.clone(), &[]);
}
let mut key: Value = ternary(is_true(&(is_equal(&method, &Value::Str("fetchOHLCV".to_string())))), Value::Int(0), Value::Str("timestamp".to_string()));
let mut sortedRes: Value = self.sort_by(uniqueResults.clone(), key.clone(), &[]);
return self.filter_by_since_limit(sortedRes.clone(), &[since.clone(), limit.clone(), key.clone()]);
Value::Null
} }
fn safe_deterministic_call(&mut self, mut method: Value, optional_args: &[Value]) -> impl ::std::future::Future<Output = Value> + Send { async move {
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 timeframe = get_arg(optional_args, 3, Value::Null);
let mut params = get_arg(optional_args, 4, Value::Map({
let mut m = indexmap::IndexMap::new();
m
}));
let mut maxRetries: Value = Value::Int(3);
{ let __destr_tmp = self.handle_option_and_params(params.clone(), method.clone(), Value::Str("maxRetries".to_string()), &[maxRetries.clone()]); maxRetries = get_value(&__destr_tmp, &Value::Int(0)); params = get_value(&__destr_tmp, &Value::Int(1)); }
let mut errors: Value = Value::Int(0);
while is_less_than_or_equal(&errors, &maxRetries) {
let _try_result = futures::FutureExt::catch_unwind(std::panic::AssertUnwindSafe(async {
if is_true(&(!is_equal(&timeframe, &Value::Null) && !is_equal(&timeframe, &Value::Str("".to_string())))) && !is_equal(&method, &Value::Str("fetchFundingRateHistory".to_string())) {
return self.call_method(method.clone(), &[symbol.clone(), timeframe.clone(), since.clone(), limit.clone(), params.clone()]).await;
} else {
return self.call_method(method.clone(), &[symbol.clone(), since.clone(), limit.clone(), params.clone()]).await;
}
#[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 e: Value = panic_to_value(_try_err);
if is_true(&is_instance(&e, &Value::Str("RateLimitExceeded".to_string()))) {
panic!("{}", e);
}
errors = add(&errors, &Value::Int(1));
if is_greater_than(&errors, &maxRetries) {
panic!("{}", e);
}
} }
}
return Value::List(vec![]);
Value::Null
} }
fn fetch_paginated_call_deterministic(&mut self, mut method: Value, optional_args: &[Value]) -> impl ::std::future::Future<Output = Value> + Send { async move {
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 timeframe = get_arg(optional_args, 3, Value::Null);
let mut params = get_arg(optional_args, 4, Value::Map({
let mut m = indexmap::IndexMap::new();
m
}));
let mut maxEntriesPerRequest = get_arg(optional_args, 5, Value::Null);
let mut maxCalls: Value = Value::Int(10);
{ let __destr_tmp = self.handle_option_and_params(params.clone(), method.clone(), Value::Str("paginationCalls".to_string()), &[maxCalls.clone()]); maxCalls = get_value(&__destr_tmp, &Value::Int(0)); params = get_value(&__destr_tmp, &Value::Int(1)); }
{ let __destr_tmp = self.handle_max_entries_per_request_and_params(method.clone(), &[maxEntriesPerRequest.clone(), params.clone()]); maxEntriesPerRequest = get_value(&__destr_tmp, &Value::Int(0)); params = get_value(&__destr_tmp, &Value::Int(1)); }
// paginationDirection is only relevant to fetchPaginatedCallDynamic/Cursor; deterministic
// pagination always walks forward internally, so strip it here to avoid leaking an
// unrecognized param into the underlying exchange request (e.g. binance -1104 errors)
params = self.omit(params.clone(), Value::Str("paginationDirection".to_string()), &[]);
let mut current: Value = self.milliseconds();
let mut tasks: Value = Value::List(vec![]);
let mut time: Value = multiply(&self.parse_timeframe(timeframe.clone()), &Value::Int(1000));
maxEntriesPerRequest = self.require_value(maxEntriesPerRequest.clone(), &[Value::Str("fetchPaginatedCallDeterministic() maxEntriesPerRequest is required".to_string())]);
let mut step: Value = multiply(&time, &maxEntriesPerRequest);
let mut until: Value = self.safe_integer2(params.clone(), Value::Str("until".to_string()), Value::Str("till".to_string()), &[]); // do not omit it here
let mut currentSince: Value = subtract(&subtract(¤t, &(multiply(&maxCalls, &step))), &Value::Int(1));
if !is_equal(&since, &Value::Null) {
if !is_equal(&until, &Value::Null) {
// the recent-window floor below would jump past a fully-historical [ since, until ]
// range and return an empty result - requiredCalls is validated against maxCalls
// further down, so anchoring at since directly is safe here,
// see https://github.com/ccxt/ccxt/issues/26252
currentSince = since.clone();
} else {
currentSince = crate::runtime::Math::max(¤tSince, &since);
}
} else {
currentSince = crate::runtime::Math::max(¤tSince, &Value::Int(1241440531000)); // avoid timestamps older than 2009
}
if !is_equal(&until, &Value::Null) {
if is_equal(&since, &Value::Null) {
panic!("{}", crate::exchange_errors::arguments_required(add(&self.id, &Value::Str(" fetchPaginatedCallDeterministic() requires a since argument when until is set".to_string()))));
}
let mut requiredCalls: Value = math_ceil(÷(&(subtract(&until, &since)), &step));
if is_greater_than(&requiredCalls, &maxCalls) {
panic!("{}", crate::exchange_errors::bad_request(add(&add(&add(&add(&self.id, &Value::Str(" the number of required calls is greater than the max number of calls allowed, either increase the paginationCalls or decrease the since-until gap. Current paginationCalls limit is ".to_string())), &to_string_val(&maxCalls)), &Value::Str(" required calls is ".to_string())), &to_string_val(&requiredCalls))));
}
}
{
let mut i: Value = Value::Int(0);
let mut __for_first_158: bool = true;
while { if !__for_first_158 { i = add(&i, &Value::Int(1)); } __for_first_158 = false; is_less_than(&i, &maxCalls) } {
if is_true(&(!is_equal(&until, &Value::Null))) && is_true(&(is_greater_than_or_equal(¤tSince, &until))) {
break;
}
if is_greater_than_or_equal(¤tSince, ¤t) {
break;
}
append_to_array(&mut tasks, self.safe_deterministic_call(method.clone(), &[symbol.clone(), currentSince.clone(), maxEntriesPerRequest.clone(), timeframe.clone(), params.clone()]).await);
currentSince = subtract(&self.sum(&[currentSince.clone(), step.clone()]), &Value::Int(1));
}
}
let mut results: Value = promise_all(&tasks).await;
let mut result: Value = Value::List(vec![]);
{
let mut i: Value = Value::Int(0);
let mut __for_first_159: bool = true;
while { if !__for_first_159 { i = add(&i, &Value::Int(1)); } __for_first_159 = false; is_less_than(&i, &get_array_length(&results)) } {
result = self.array_concat(result.clone(), get_value(&results, &i));
}
}
let mut uniqueResults: Value = self.remove_repeated_elements_from_array(result.clone(), &[]);
let mut key: Value = ternary(is_true(&(is_equal(&method, &Value::Str("fetchOHLCV".to_string())))), Value::Int(0), Value::Str("timestamp".to_string()));
return self.filter_by_since_limit(uniqueResults.clone(), &[since.clone(), limit.clone(), key.clone()]);
Value::Null
} }
// the 'symbol' slot is forwarded to `this[method]` untouched and is only compared against
// undefined here, so fetchPositions/fetchPositionsHistory legitimately pass a symbol list
fn fetch_paginated_call_cursor(&mut self, mut method: Value, optional_args: &[Value]) -> impl ::std::future::Future<Output = Value> + Send { async move {
let mut symbol = get_arg(optional_args, 0, Value::Null);
let mut since = get_arg(optional_args, 1, Value::Null);
let mut limit = get_arg(optional_args, 2, Value::Null);
let mut params = get_arg(optional_args, 3, Value::Map({
let mut m = indexmap::IndexMap::new();
m
}));
let mut cursorReceived = get_arg(optional_args, 4, Value::Null);
let mut cursorSent = get_arg(optional_args, 5, Value::Null);
let mut cursorIncrement = get_arg(optional_args, 6, Value::Null);
let mut maxEntriesPerRequest = get_arg(optional_args, 7, Value::Null);
let mut maxCalls: Value = Value::Int(10);
{ let __destr_tmp = self.handle_option_and_params(params.clone(), method.clone(), Value::Str("paginationCalls".to_string()), &[maxCalls.clone()]); maxCalls = get_value(&__destr_tmp, &Value::Int(0)); params = get_value(&__destr_tmp, &Value::Int(1)); }
let mut maxRetries: Value = Value::Int(3);
{ let __destr_tmp = self.handle_option_and_params(params.clone(), method.clone(), Value::Str("maxRetries".to_string()), &[maxRetries.clone()]); maxRetries = get_value(&__destr_tmp, &Value::Int(0)); params = get_value(&__destr_tmp, &Value::Int(1)); }
{ let __destr_tmp = self.handle_max_entries_per_request_and_params(method.clone(), &[maxEntriesPerRequest.clone(), params.clone()]); maxEntriesPerRequest = get_value(&__destr_tmp, &Value::Int(0)); params = get_value(&__destr_tmp, &Value::Int(1)); }
let mut cursorValue: Value = Value::Null;
let mut i: Value = Value::Int(0);
let mut errors: Value = Value::Int(0);
let mut result: Value = Value::List(vec![]);
let mut timeframe: Value = self.safe_string_k(params.clone(), "timeframe", &[]);
params = self.omit(params.clone(), Value::Str("timeframe".to_string()), &[]); // reading the timeframe from the method arguments to avoid changing the signature
while is_less_than(&i, &maxCalls) {
{
if !is_equal(&cursorValue, &Value::Null) {
if !is_equal(&cursorIncrement, &Value::Null) {
cursorValue = add(&self.parse_to_int(cursorValue.clone()), &cursorIncrement);
}
add_element_to_object(&mut params, &cursorSent, cursorValue.clone());
}
let mut response: Value = Value::Null;
if is_equal(&method, &Value::Str("fetchAccounts".to_string())) {
response = self.call_method(method.clone(), &[params.clone()]).await;
} else if is_equal(&method, &Value::Str("getLeverageTiersPaginated".to_string())) || is_equal(&method, &Value::Str("fetchPositions".to_string())) {
response = self.call_method(method.clone(), &[symbol.clone(), params.clone()]).await;
} else if is_equal(&method, &Value::Str("fetchOpenInterestHistory".to_string())) {
if !is_string(&symbol) {
panic!("{}", crate::exchange_errors::arguments_required(add(&self.id, &Value::Str(" fetchPaginatedCallCursor() requires a symbol argument".to_string()))));
}
if is_equal(&timeframe, &Value::Null) {
panic!("{}", crate::exchange_errors::arguments_required(add(&self.id, &Value::Str(" fetchPaginatedCallCursor() requires a timeframe argument".to_string()))));
}
response = self.call_method(method.clone(), &[symbol.clone(), timeframe.clone(), since.clone(), maxEntriesPerRequest.clone(), params.clone()]).await;
} else {
response = self.call_method(method.clone(), &[symbol.clone(), since.clone(), maxEntriesPerRequest.clone(), params.clone()]).await;
}
errors = Value::Int(0);
if is_equal(&response, &Value::Null) {
panic!("{}", crate::exchange_errors::null_response(add(&self.id, &Value::Str(" fetchPaginatedCallCursor() returned empty response".to_string()))));
}
let mut responseLength: Value = get_array_length(&response);
if is_true(&self.verbose) {
let mut cursorString: Value = ternary(is_true(&(is_equal(&cursorValue, &Value::Null))), Value::Str("".to_string()), cursorValue.clone());
let mut iteration: Value = (add(&i, &Value::Int(1)));
let mut cursorMessage: Value = add(&add(&add(&add(&add(&add(&add(&Value::Str("Cursor pagination call ".to_string()), &to_string_val(&iteration)), &Value::Str(" method ".to_string())), &method), &Value::Str(" response length ".to_string())), &to_string_val(&responseLength)), &Value::Str(" cursor ".to_string())), &cursorString);
self.log(cursorMessage.clone());
}
if is_equal(&responseLength, &Value::Int(0)) {
break;
}
if !is_equal(&response, &Value::Null) {
result = self.array_concat(result.clone(), response.clone());
}
let mut last: Value = self.safe_dict(response.clone(), subtract(&responseLength, &Value::Int(1)), &[]);
// cursorValue = this.safeValue (last['info'], cursorReceived);
cursorValue = Value::Null; // search for the cursor
{
let mut j: Value = Value::Int(0);
let mut __for_first_160: bool = true;
while { if !__for_first_160 { j = add(&j, &Value::Int(1)); } __for_first_160 = false; is_less_than(&j, &responseLength) } {
let mut index: Value = subtract(&subtract(&responseLength, &j), &Value::Int(1));
let mut entry: Value = self.safe_dict(response.clone(), index.clone(), &[]);
let mut info: Value = self.safe_dict_k(entry.clone(), "info", &[]);
let mut cursor: Value = ternary(is_true(&(is_equal(&cursorReceived, &Value::Null))), Value::Null, self.safe_value(info.clone(), cursorReceived.clone(), &[]));
if !is_equal(&cursor, &Value::Null) {
cursorValue = cursor.clone();
break;
}
}
}
if is_equal(&cursorValue, &Value::Null) {
break;
}
let mut lastTimestamp: Value = self.safe_integer_k(last.clone(), "timestamp", &[]);
if is_equal(&since, &Value::Null) {
panic!("{}", crate::exchange_errors::arguments_required(add(&self.id, &Value::Str(" fetchPaginatedCallCursor() requires a since argument".to_string()))));
}
if !is_equal(&lastTimestamp, &Value::Null) && is_less_than(&lastTimestamp, &since) {
break;
}
}
i = add(&i, &Value::Int(1));
}
let mut sorted: Value = self.sort_cursor_paginated_result(result.clone());
let mut key: Value = ternary(is_true(&(is_equal(&method, &Value::Str("fetchOHLCV".to_string())))), Value::Int(0), Value::Str("timestamp".to_string()));
return self.filter_by_since_limit(sorted.clone(), &[since.clone(), limit.clone(), key.clone()]);
Value::Null
} }
fn fetch_paginated_call_incremental(&mut self, mut method: Value, optional_args: &[Value]) -> impl ::std::future::Future<Output = Value> + Send { async move {
let mut symbol = get_arg(optional_args, 0, Value::Null);
let mut since = get_arg(optional_args, 1, Value::Null);
let mut limit = get_arg(optional_args, 2, Value::Null);
let mut params = get_arg(optional_args, 3, Value::Map({
let mut m = indexmap::IndexMap::new();
m
}));
let mut pageKey = get_arg(optional_args, 4, Value::Null);
let mut maxEntriesPerRequest = get_arg(optional_args, 5, Value::Null);
let mut maxCalls: Value = Value::Int(10);
{ let __destr_tmp = self.handle_option_and_params(params.clone(), method.clone(), Value::Str("paginationCalls".to_string()), &[maxCalls.clone()]); maxCalls = get_value(&__destr_tmp, &Value::Int(0)); params = get_value(&__destr_tmp, &Value::Int(1)); }
let mut maxRetries: Value = Value::Int(3);
{ let __destr_tmp = self.handle_option_and_params(params.clone(), method.clone(), Value::Str("maxRetries".to_string()), &[maxRetries.clone()]); maxRetries = get_value(&__destr_tmp, &Value::Int(0)); params = get_value(&__destr_tmp, &Value::Int(1)); }
{ let __destr_tmp = self.handle_max_entries_per_request_and_params(method.clone(), &[maxEntriesPerRequest.clone(), params.clone()]); maxEntriesPerRequest = get_value(&__destr_tmp, &Value::Int(0)); params = get_value(&__destr_tmp, &Value::Int(1)); }
let mut i: Value = Value::Int(0);
let mut errors: Value = Value::Int(0);
let mut result: Value = Value::List(vec![]);
while is_less_than(&i, &maxCalls) {
{
add_element_to_object(&mut params, &pageKey, add(&i, &Value::Int(1)));
let mut response: Value = self.call_method(method.clone(), &[symbol.clone(), since.clone(), maxEntriesPerRequest.clone(), params.clone()]).await;
errors = Value::Int(0);
let mut responseLength: Value = get_array_length(&response);
if is_true(&self.verbose) {
let mut iteration: Value = to_string_val(&(add(&i, &Value::Int(1))));
let mut incrementalMessage: Value = add(&add(&add(&add(&add(&Value::Str("Incremental pagination call ".to_string()), &iteration), &Value::Str(" method ".to_string())), &method), &Value::Str(" response length ".to_string())), &to_string_val(&responseLength));
self.log(incrementalMessage.clone());
}
if is_equal(&responseLength, &Value::Int(0)) {
break;
}
result = self.array_concat(result.clone(), response.clone());
}
i = add(&i, &Value::Int(1));
}
let mut sorted: Value = self.sort_cursor_paginated_result(result.clone());
let mut key: Value = ternary(is_true(&(is_equal(&method, &Value::Str("fetchOHLCV".to_string())))), Value::Int(0), Value::Str("timestamp".to_string()));
return self.filter_by_since_limit(sorted.clone(), &[since.clone(), limit.clone(), key.clone()]);
Value::Null
} }
fn sort_cursor_paginated_result(&self, mut result: Value) -> Value {
let mut first: Value = self.safe_value(result.clone(), Value::Int(0), &[]);
if !is_equal(&first, &Value::Null) {
if is_true(&Value::Bool(in_op(&first, &Value::Str("timestamp".to_string())))) {
return self.sort_by(result.clone(), Value::Str("timestamp".to_string()), &[Value::Bool(true)]);
}
if is_true(&Value::Bool(in_op(&first, &Value::Str("id".to_string())))) {
return self.sort_by(result.clone(), Value::Str("id".to_string()), &[Value::Bool(true)]);
}
}
return result;
Value::Null
}
fn remove_repeated_elements_from_array(&self, mut input: Value, optional_args: &[Value]) -> Value {
let mut fallbackToTimestamp = get_arg(optional_args, 0, Value::Bool(true));
let mut uniqueDic: Value = Value::Map({
let mut m = indexmap::IndexMap::new();
m
});
let mut uniqueResult: Value = Value::List(vec![]);
{
let mut i: Value = Value::Int(0);
let mut __for_first_161: bool = true;
while { if !__for_first_161 { i = add(&i, &Value::Int(1)); } __for_first_161 = false; is_less_than(&i, &get_array_length(&input)) } {
let mut entry: Value = get_value(&input, &i);
let mut entry: Value = get_value(&input, &i);
let mut uniqValue: Value = ternary(is_true(&fallbackToTimestamp), self.safe_string_n(entry.clone(), Value::List(vec![Value::Str("id".to_string()), Value::Str("timestamp".to_string()), Value::Int(0)]), &[]), self.safe_string_k(entry.clone(), "id", &[]));
if !is_equal(&uniqValue, &Value::Null) && !is_true(&(Value::Bool(in_op(&uniqueDic, &uniqValue)))) {
add_element_to_object(&mut uniqueDic, &uniqValue, Value::Int(1));
append_to_array(&mut uniqueResult, entry.clone());
}
}
}
let mut valuesLength: Value = get_array_length(&uniqueResult);
if is_greater_than(&valuesLength, &Value::Int(0)) {
return uniqueResult;
}
return input;
Value::Null
}
fn remove_repeated_trades_from_array(&self, mut input: Value) -> Value {
let mut uniqueResult: Value = Value::Map({
let mut m = indexmap::IndexMap::new();
m
});
{
let mut i: Value = Value::Int(0);
let mut __for_first_162: bool = true;
while { if !__for_first_162 { i = add(&i, &Value::Int(1)); } __for_first_162 = false; is_less_than(&i, &get_array_length(&input)) } {
let mut entry: Value = get_value(&input, &i);
let mut entry: Value = get_value(&input, &i);
let mut id: Value = self.safe_string_k(entry.clone(), "id", &[]);
if is_equal(&id, &Value::Null) {
let mut price: Value = self.safe_string_k(entry.clone(), "price", &[]);
let mut amount: Value = self.safe_string_k(entry.clone(), "amount", &[]);
let mut timestamp: Value = self.safe_string_k(entry.clone(), "timestamp", &[]);
let mut side: Value = self.safe_string_k(entry.clone(), "side", &[]);
// unique trade identifier
if is_equal(×tamp, &Value::Null) {
panic!("{}", crate::exchange_errors::exchange_error(add(&self.id, &Value::Str(" removeRepeatedTradesFromArray() missing timestamp".to_string()))));
}
id = add(&add(&add(&add(&add(&add(&add(&Value::Str("t_".to_string()), &to_string_val(×tamp)), &Value::Str("_".to_string())), &side), &Value::Str("_".to_string())), &price), &Value::Str("_".to_string())), &amount);
}
if !is_equal(&id, &Value::Null) && !is_true(&(Value::Bool(in_op(&uniqueResult, &id)))) {
add_element_to_object(&mut uniqueResult, &id, entry.clone());
}
}
}
let mut values: Value = object_values(&uniqueResult);
return values;
Value::Null
}
fn remove_keys_from_dict(&self, mut dict: Value, mut removeKeys: Value) -> Value {
let mut keys: Value = object_keys(&dict);
let mut newDict: Value = Value::Map({
let mut m = indexmap::IndexMap::new();
m
});
{
let mut i: Value = Value::Int(0);
let mut __for_first_163: bool = true;
while { if !__for_first_163 { i = add(&i, &Value::Int(1)); } __for_first_163 = false; is_less_than(&i, &get_array_length(&keys)) } {
let mut key: Value = get_value(&keys, &i);
let mut key: Value = get_value(&keys, &i);
if !is_true(&self.in_array(key.clone(), removeKeys.clone())) {
add_element_to_object(&mut newDict, &key, get_value(&dict, &key));
}
}
}
return newDict;
Value::Null
}
fn handle_until_option(&self, mut key: Value, mut request: Value, mut params: Value, optional_args: &[Value]) -> Value {
let mut multiplier = get_arg(optional_args, 0, Value::Int(1));
let mut until: Value = self.safe_integer2(params.clone(), Value::Str("until".to_string()), Value::Str("till".to_string()), &[]);
if !is_equal(&until, &Value::Null) {
add_element_to_object(&mut request, &key, self.parse_to_int(multiply(&until, &multiplier)));
params = self.omit(params.clone(), Value::List(vec![Value::Str("until".to_string()), Value::Str("till".to_string())]), &[]);
}
return Value::List(vec![request.clone(), params.clone()]);
Value::Null
}
fn safe_open_interest(&self, mut interest: Value, optional_args: &[Value]) -> Value {
let mut market = get_arg(optional_args, 0, Value::Null);
let mut symbol: Value = self.safe_string_k(interest.clone(), "symbol", &[]);
if is_equal(&symbol, &Value::Null) {
symbol = self.safe_string_k(market.clone(), "symbol", &[]);
}
return self.extend(interest.clone(), &[Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("symbol".to_string(), symbol.clone());
m.insert("baseVolume".to_string(), self.safe_number_k(interest.clone(), "baseVolume", &[]));
m.insert("quoteVolume".to_string(), self.safe_number_k(interest.clone(), "quoteVolume", &[]));
m.insert("openInterestAmount".to_string(), self.safe_number_k(interest.clone(), "openInterestAmount", &[]));
m.insert("openInterestValue".to_string(), self.safe_number_k(interest.clone(), "openInterestValue", &[]));
m.insert("timestamp".to_string(), self.safe_integer_k(interest.clone(), "timestamp", &[]));
m.insert("datetime".to_string(), self.safe_string_k(interest.clone(), "datetime", &[]));
m.insert("info".to_string(), self.safe_value_k(interest.clone(), "info", &[]));
m
})]);
Value::Null
}
fn parse_liquidation(&self, mut liquidation: Value, optional_args: &[Value]) -> Value {
// virtual-dispatch (static: DerivedExchange::parse_liquidation(self, ...))
{ let __v = crate::exchange::DerivedExchange::parse_liquidation(self, liquidation.clone(), crate::runtime::get_arg(optional_args, 0, crate::Value::Null)); if !matches!(__v, crate::Value::Null) { return __v; } }
let mut market = get_arg(optional_args, 0, Value::Null);
panic!("{}", crate::exchange_errors::not_supported(add(&self.id, &Value::Str(" parseLiquidation () is not supported yet".to_string()))));
Value::Null
}
fn parse_liquidations(&self, mut liquidations: 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);
/*
* @ignore
* @method
* @description parses liquidation info from the exchange response
* @param {object[]} liquidations each item describes an instance of a liquidation event
* @param {object} market ccxt market
* @param {int} [since] when defined, the response items are filtered to only include items after this timestamp
* @param {int} [limit] limits the number of items in the response
* @returns {object[]} an array of [liquidation structures]{@link https://docs.ccxt.com/?id=liquidation-structure}
*/
let mut result: Value = Value::List(vec![]);
{
let mut i: Value = Value::Int(0);
let mut __for_first_164: bool = true;
while { if !__for_first_164 { i = add(&i, &Value::Int(1)); } __for_first_164 = false; is_less_than(&i, &get_array_length(&liquidations)) } {
let mut entry: Value = get_value(&liquidations, &i);
let mut entry: Value = get_value(&liquidations, &i);
let mut parsed: Value = <Self as crate::exchange_generated::ExchangeBase>::parse_liquidation(self, entry.clone(), &[market.clone()]);
append_to_array(&mut result, parsed.clone());
}
}
let mut sorted: Value = self.sort_by(result.clone(), Value::Str("timestamp".to_string()), &[]);
let mut symbol: Value = self.safe_string_k(market.clone(), "symbol", &[]);
return self.filter_by_symbol_since_limit(sorted.clone(), &[symbol.clone(), since.clone(), limit.clone()]);
Value::Null
}
fn parse_greeks(&self, mut greeks: Value, optional_args: &[Value]) -> Value {
// virtual-dispatch (static: DerivedExchange::parse_greeks(self, ...))
{ let __v = crate::exchange::DerivedExchange::parse_greeks(self, greeks.clone(), crate::runtime::get_arg(optional_args, 0, crate::Value::Null)); if !matches!(__v, crate::Value::Null) { return __v; } }
let mut market = get_arg(optional_args, 0, Value::Null);
panic!("{}", crate::exchange_errors::not_supported(add(&self.id, &Value::Str(" parseGreeks () is not supported yet".to_string()))));
Value::Null
}
fn parse_all_greeks(&self, mut greeks: Value, 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
}));
//
// the value of greeks is either a dict or a list
//
let mut results: Value = Value::List(vec![]);
if is_true(&Value::Bool(is_array(&greeks))) {
{
let mut i: Value = Value::Int(0);
let mut __for_first_165: bool = true;
while { if !__for_first_165 { i = add(&i, &Value::Int(1)); } __for_first_165 = false; is_less_than(&i, &get_array_length(&greeks)) } {
let mut parsedTicker: Value = <Self as crate::exchange_generated::ExchangeBase>::parse_greeks(self, get_value(&greeks, &i), &[]);
let mut greek: Value = self.extend(parsedTicker.clone(), &[params.clone()]);
append_to_array(&mut results, greek.clone());
}
}
} else {
let mut marketIds: Value = object_keys(&greeks);
{
let mut i: Value = Value::Int(0);
let mut __for_first_166: bool = true;
while { if !__for_first_166 { i = add(&i, &Value::Int(1)); } __for_first_166 = false; is_less_than(&i, &get_array_length(&marketIds)) } {
let mut marketId: Value = get_value(&marketIds, &i);
let mut marketId: Value = get_value(&marketIds, &i);
let mut market: Value = self.safe_market(&[marketId.clone()]);
let mut parsed: Value = <Self as crate::exchange_generated::ExchangeBase>::parse_greeks(self, get_value(&greeks, &marketId), &[market.clone()]);
let mut greek: Value = self.extend(parsed.clone(), &[params.clone()]);
append_to_array(&mut results, greek.clone());
}
}
}
symbols = self.market_symbols(&[symbols.clone()]);
return self.filter_by_array(results.clone(), Value::Str("symbol".to_string()), &[symbols.clone()]);
Value::Null
}
fn parse_option(&self, mut chain: Value, optional_args: &[Value]) -> Value {
let mut currency = get_arg(optional_args, 0, Value::Null);
let mut market = get_arg(optional_args, 1, Value::Null);
panic!("{}", crate::exchange_errors::not_supported(add(&self.id, &Value::Str(" parseOption () is not supported yet".to_string()))));
Value::Null
}
fn parse_option_chain(&self, mut response: Value, optional_args: &[Value]) -> Value {
let mut currencyKey = get_arg(optional_args, 0, Value::Null);
let mut symbolKey = get_arg(optional_args, 1, Value::Null);
let mut optionStructures: Value = Value::Map({
let mut m = indexmap::IndexMap::new();
m
});
{
let mut i: Value = Value::Int(0);
let mut __for_first_167: bool = true;
while { if !__for_first_167 { i = add(&i, &Value::Int(1)); } __for_first_167 = false; is_less_than(&i, &get_array_length(&response)) } {
let mut info: Value = get_value(&response, &i);
let mut info: Value = get_value(&response, &i);
let mut currencyId: Value = ternary(is_true(&(is_equal(¤cyKey, &Value::Null))), Value::Null, self.safe_string(info.clone(), currencyKey.clone(), &[]));
let mut currency: Value = self.safe_currency(currencyId.clone(), &[]);
let mut marketId: Value = ternary(is_true(&(is_equal(&symbolKey, &Value::Null))), Value::Null, self.safe_string(info.clone(), symbolKey.clone(), &[]));
let mut market: Value = self.safe_market(&[marketId.clone(), Value::Null, Value::Null, Value::Str("option".to_string())]);
add_element_to_object(&mut optionStructures, &get_value(&market, &Value::Str("symbol".to_string())), self.parse_option(info.clone(), &[currency.clone(), market.clone()]));
}
}
return optionStructures;
Value::Null
}
fn parse_margin_modes(&self, mut response: Value, optional_args: &[Value]) -> Value {
let mut symbols = get_arg(optional_args, 0, Value::Null);
let mut symbolKey = get_arg(optional_args, 1, Value::Null);
let mut marketType = get_arg(optional_args, 2, Value::Null);
let mut marginModeStructures: Value = Value::Map({
let mut m = indexmap::IndexMap::new();
m
});
if is_equal(&marketType, &Value::Null) {
marketType = Value::Str("swap".to_string()); // default to swap
}
{
let mut i: Value = Value::Int(0);
let mut __for_first_168: bool = true;
while { if !__for_first_168 { i = add(&i, &Value::Int(1)); } __for_first_168 = false; is_less_than(&i, &get_array_length(&response)) } {
let mut info: Value = get_value(&response, &i);
let mut info: Value = get_value(&response, &i);
let mut marketId: Value = ternary(is_true(&(is_equal(&symbolKey, &Value::Null))), Value::Null, self.safe_string(info.clone(), symbolKey.clone(), &[]));
let mut market: Value = self.safe_market(&[marketId.clone(), Value::Null, Value::Null, marketType.clone()]);
if is_true(&(is_equal(&symbols, &Value::Null))) || is_true(&self.in_array(get_value(&market, &Value::Str("symbol".to_string())), symbols.clone())) {
add_element_to_object(&mut marginModeStructures, &get_value(&market, &Value::Str("symbol".to_string())), <Self as crate::exchange_generated::ExchangeBase>::parse_margin_mode(self, info.clone(), &[market.clone()]));
}
}
}
return marginModeStructures;
Value::Null
}
fn parse_margin_mode(&self, mut marginMode: Value, optional_args: &[Value]) -> Value {
// virtual-dispatch (static: DerivedExchange::parse_margin_mode(self, ...))
{ let __v = crate::exchange::DerivedExchange::parse_margin_mode(self, marginMode.clone(), crate::runtime::get_arg(optional_args, 0, crate::Value::Null)); if !matches!(__v, crate::Value::Null) { return __v; } }
let mut market = get_arg(optional_args, 0, Value::Null);
panic!("{}", crate::exchange_errors::not_supported(add(&self.id, &Value::Str(" parseMarginMode () is not supported yet".to_string()))));
Value::Null
}
fn parse_leverages(&self, mut response: Value, optional_args: &[Value]) -> Value {
let mut symbols = get_arg(optional_args, 0, Value::Null);
let mut symbolKey = get_arg(optional_args, 1, Value::Null);
let mut marketType = get_arg(optional_args, 2, Value::Null);
let mut leverageStructures: Value = Value::Map({
let mut m = indexmap::IndexMap::new();
m
});
if is_equal(&marketType, &Value::Null) {
marketType = Value::Str("swap".to_string()); // default to swap
}
{
let mut i: Value = Value::Int(0);
let mut __for_first_169: bool = true;
while { if !__for_first_169 { i = add(&i, &Value::Int(1)); } __for_first_169 = false; is_less_than(&i, &get_array_length(&response)) } {
let mut info: Value = get_value(&response, &i);
let mut info: Value = get_value(&response, &i);
let mut marketId: Value = ternary(is_true(&(is_equal(&symbolKey, &Value::Null))), Value::Null, self.safe_string(info.clone(), symbolKey.clone(), &[]));
let mut market: Value = self.safe_market(&[marketId.clone(), Value::Null, Value::Null, marketType.clone()]);
if is_true(&(is_equal(&symbols, &Value::Null))) || is_true(&self.in_array(get_value(&market, &Value::Str("symbol".to_string())), symbols.clone())) {
add_element_to_object(&mut leverageStructures, &get_value(&market, &Value::Str("symbol".to_string())), <Self as crate::exchange_generated::ExchangeBase>::parse_leverage(self, info.clone(), &[market.clone()]));
}
}
}
return leverageStructures;
Value::Null
}
fn parse_leverage(&self, mut leverage: Value, optional_args: &[Value]) -> Value {
// virtual-dispatch (static: DerivedExchange::parse_leverage(self, ...))
{ let __v = crate::exchange::DerivedExchange::parse_leverage(self, leverage.clone(), crate::runtime::get_arg(optional_args, 0, crate::Value::Null)); if !matches!(__v, crate::Value::Null) { return __v; } }
let mut market = get_arg(optional_args, 0, Value::Null);
panic!("{}", crate::exchange_errors::not_supported(add(&self.id, &Value::Str(" parseLeverage () is not supported yet".to_string()))));
Value::Null
}
fn parse_conversions(&self, mut conversions: Value, optional_args: &[Value]) -> Value {
let mut code = get_arg(optional_args, 0, Value::Null);
let mut fromCurrencyKey = get_arg(optional_args, 1, Value::Null);
let mut toCurrencyKey = get_arg(optional_args, 2, Value::Null);
let mut since = get_arg(optional_args, 3, Value::Null);
let mut limit = get_arg(optional_args, 4, Value::Null);
let mut params = get_arg(optional_args, 5, Value::Map({
let mut m = indexmap::IndexMap::new();
m
}));
let mut conversionsArray: Value = self.to_array(conversions.clone());
let mut result: Value = Value::List(vec![]);
let mut fromCurrency: Value = Value::Null;
let mut toCurrency: Value = Value::Null;
{
let mut i: Value = Value::Int(0);
let mut __for_first_170: bool = true;
while { if !__for_first_170 { i = add(&i, &Value::Int(1)); } __for_first_170 = false; is_less_than(&i, &get_array_length(&conversionsArray)) } {
let mut entry: Value = get_value(&conversionsArray, &i);
let mut entry: Value = get_value(&conversionsArray, &i);
let mut fromId: Value = ternary(is_true(&(is_equal(&fromCurrencyKey, &Value::Null))), Value::Null, self.safe_string(entry.clone(), fromCurrencyKey.clone(), &[]));
let mut toId: Value = ternary(is_true(&(is_equal(&toCurrencyKey, &Value::Null))), Value::Null, self.safe_string(entry.clone(), toCurrencyKey.clone(), &[]));
if !is_equal(&fromId, &Value::Null) {
fromCurrency = self.safe_currency(fromId.clone(), &[]);
}
if !is_equal(&toId, &Value::Null) {
toCurrency = self.safe_currency(toId.clone(), &[]);
}
let mut conversion: Value = self.extend(<Self as crate::exchange_generated::ExchangeBase>::parse_conversion(self, entry.clone(), &[fromCurrency.clone(), toCurrency.clone()]), &[params.clone()]);
append_to_array(&mut result, conversion.clone());
}
}
let mut sorted: Value = self.sort_by(result.clone(), Value::Str("timestamp".to_string()), &[]);
let mut currency: Value = Value::Null;
if !is_equal(&code, &Value::Null) {
currency = self.safe_currency(code.clone(), &[]);
if is_equal(¤cy, &Value::Null) {
panic!("{}", crate::exchange_errors::exchange_error(add(&self.id, &Value::Str(" parseConversions() could not resolve currency".to_string()))));
}
code = get_value(¤cy, &Value::Str("code".to_string()));
}
if is_equal(&code, &Value::Null) {
return self.filter_by_since_limit(sorted.clone(), &[since.clone(), limit.clone()]);
}
let mut fromConversion: Value = self.filter_by(sorted.clone(), Value::Str("fromCurrency".to_string()), code.clone(), &[]);
let mut toConversion: Value = self.filter_by(sorted.clone(), Value::Str("toCurrency".to_string()), code.clone(), &[]);
let mut both: Value = self.array_concat(fromConversion.clone(), toConversion.clone());
return self.filter_by_since_limit(both.clone(), &[since.clone(), limit.clone()]);
Value::Null
}
fn parse_conversion(&self, mut conversion: Value, optional_args: &[Value]) -> Value {
// virtual-dispatch (static: DerivedExchange::parse_conversion(self, ...))
{ let __v = crate::exchange::DerivedExchange::parse_conversion(self, conversion.clone(), crate::runtime::get_arg(optional_args, 0, crate::Value::Null), crate::runtime::get_arg(optional_args, 1, crate::Value::Null)); if !matches!(__v, crate::Value::Null) { return __v; } }
let mut fromCurrency = get_arg(optional_args, 0, Value::Null);
let mut toCurrency = get_arg(optional_args, 1, Value::Null);
if is_equal(&conversion, &Value::Null) {
panic!("{}", crate::exchange_errors::not_supported(add(&self.id, &Value::Str(" parseConversion () is not supported yet".to_string()))));
}
panic!("{}", crate::exchange_errors::not_supported(add(&self.id, &Value::Str(" parseConversion () is not supported yet".to_string()))));
Value::Null
}
fn convert_expire_date(&self, mut date: Value) -> Value {
if is_equal(&date, &Value::Null) {
return Value::Null;
}
// parse YYMMDD to datetime string
let mut year: Value = slice(&date, &Value::Int(0), &Value::Int(2));
let mut month: Value = slice(&date, &Value::Int(2), &Value::Int(4));
let mut day: Value = slice(&date, &Value::Int(4), &Value::Int(6));
let mut reconstructedDate: Value = add(&add(&add(&add(&add(&add(&Value::Str("20".to_string()), &year), &Value::Str("-".to_string())), &month), &Value::Str("-".to_string())), &day), &Value::Str("T00:00:00Z".to_string()));
return reconstructedDate;
Value::Null
}
fn convert_expire_date_to_market_id_date(&self, mut date: Value) -> Value {
if is_equal(&date, &Value::Null) {
return Value::Null;
}
// parse 240119 to 19JAN24
let mut year: Value = slice(&date, &Value::Int(0), &Value::Int(2));
let mut monthRaw: Value = slice(&date, &Value::Int(2), &Value::Int(4));
let mut month: Value = Value::Null;
let mut day: Value = slice(&date, &Value::Int(4), &Value::Int(6));
if is_equal(&monthRaw, &Value::Str("01".to_string())) {
month = Value::Str("JAN".to_string());
} else if is_equal(&monthRaw, &Value::Str("02".to_string())) {
month = Value::Str("FEB".to_string());
} else if is_equal(&monthRaw, &Value::Str("03".to_string())) {
month = Value::Str("MAR".to_string());
} else if is_equal(&monthRaw, &Value::Str("04".to_string())) {
month = Value::Str("APR".to_string());
} else if is_equal(&monthRaw, &Value::Str("05".to_string())) {
month = Value::Str("MAY".to_string());
} else if is_equal(&monthRaw, &Value::Str("06".to_string())) {
month = Value::Str("JUN".to_string());
} else if is_equal(&monthRaw, &Value::Str("07".to_string())) {
month = Value::Str("JUL".to_string());
} else if is_equal(&monthRaw, &Value::Str("08".to_string())) {
month = Value::Str("AUG".to_string());
} else if is_equal(&monthRaw, &Value::Str("09".to_string())) {
month = Value::Str("SEP".to_string());
} else if is_equal(&monthRaw, &Value::Str("10".to_string())) {
month = Value::Str("OCT".to_string());
} else if is_equal(&monthRaw, &Value::Str("11".to_string())) {
month = Value::Str("NOV".to_string());
} else if is_equal(&monthRaw, &Value::Str("12".to_string())) {
month = Value::Str("DEC".to_string());
}
let mut reconstructedDate: Value = add(&add(&day, &month), &year);
return reconstructedDate;
Value::Null
}
fn convert_market_id_expire_date(&self, mut date: Value) -> Value {
if is_equal(&date, &Value::Null) {
return Value::Null;
}
// parse 03JAN24 to 240103.
let mut monthMappping: Value = Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("JAN".to_string(), Value::Str("01".to_string()));
m.insert("FEB".to_string(), Value::Str("02".to_string()));
m.insert("MAR".to_string(), Value::Str("03".to_string()));
m.insert("APR".to_string(), Value::Str("04".to_string()));
m.insert("MAY".to_string(), Value::Str("05".to_string()));
m.insert("JUN".to_string(), Value::Str("06".to_string()));
m.insert("JUL".to_string(), Value::Str("07".to_string()));
m.insert("AUG".to_string(), Value::Str("08".to_string()));
m.insert("SEP".to_string(), Value::Str("09".to_string()));
m.insert("OCT".to_string(), Value::Str("10".to_string()));
m.insert("NOV".to_string(), Value::Str("11".to_string()));
m.insert("DEC".to_string(), Value::Str("12".to_string()));
m
});
// if exchange omits first zero and provides i.e. '3JAN24' instead of '03JAN24'
if is_equal(&get_array_length(&date), &Value::Int(6)) {
date = add(&Value::Str("0".to_string()), &date);
}
let mut year: Value = slice(&date, &Value::Int(0), &Value::Int(2));
let mut monthName: Value = slice(&date, &Value::Int(2), &Value::Int(5));
let mut month: Value = self.safe_string(monthMappping.clone(), monthName.clone(), &[]);
let mut day: Value = slice(&date, &Value::Int(5), &Value::Int(7));
let mut reconstructedDate: Value = add(&add(&day, &month), &year);
return reconstructedDate;
Value::Null
}
fn load_markets_and_sign_in(&mut self) -> impl ::std::future::Future<Output = Value> + Send { async move {
promise_all(&Value::List(vec![self.load_markets(&[]).await, self.sign_in(&[]).await])).await;
Value::Null
} }
fn parse_margin_modification(&self, mut data: Value, optional_args: &[Value]) -> Value {
// virtual-dispatch (static: DerivedExchange::parse_margin_modification(self, ...))
{ let __v = crate::exchange::DerivedExchange::parse_margin_modification(self, data.clone(), crate::runtime::get_arg(optional_args, 0, crate::Value::Null)); if !matches!(__v, crate::Value::Null) { return __v; } }
let mut market = get_arg(optional_args, 0, Value::Null);
if is_equal(&data, &Value::Null) {
panic!("{}", crate::exchange_errors::not_supported(add(&self.id, &Value::Str(" parseMarginModification() is not supported yet".to_string()))));
}
panic!("{}", crate::exchange_errors::not_supported(add(&self.id, &Value::Str(" parseMarginModification() is not supported yet".to_string()))));
Value::Null
}
fn parse_margin_modifications(&self, mut response: Value, optional_args: &[Value]) -> Value {
let mut symbols = get_arg(optional_args, 0, Value::Null);
let mut symbolKey = get_arg(optional_args, 1, Value::Null);
let mut marketType = get_arg(optional_args, 2, Value::Null);
let mut marginModifications: Value = Value::List(vec![]);
if is_equal(&response, &Value::Null) {
return marginModifications;
}
{
let mut i: Value = Value::Int(0);
let mut __for_first_171: bool = true;
while { if !__for_first_171 { i = add(&i, &Value::Int(1)); } __for_first_171 = false; is_less_than(&i, &get_array_length(&response)) } {
let mut info: Value = get_value(&response, &i);
let mut info: Value = get_value(&response, &i);
let mut marketId: Value = ternary(is_true(&(is_equal(&symbolKey, &Value::Null))), Value::Null, self.safe_string(info.clone(), symbolKey.clone(), &[]));
let mut market: Value = self.safe_market(&[marketId.clone(), Value::Null, Value::Null, marketType.clone()]);
if is_true(&(is_equal(&symbols, &Value::Null))) || is_true(&self.in_array(get_value(&market, &Value::Str("symbol".to_string())), symbols.clone())) {
append_to_array(&mut marginModifications, <Self as crate::exchange_generated::ExchangeBase>::parse_margin_modification(self, info.clone(), &[market.clone()]));
}
}
}
return marginModifications;
Value::Null
}
fn fetch_transfer(&mut self, mut id: Value, optional_args: &[Value]) -> impl ::std::future::Future<Output = Value> + Send { async move {
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
}));
panic!("{}", crate::exchange_errors::not_supported(add(&self.id, &Value::Str(" fetchTransfer () is not supported yet".to_string()))));
Value::Null
} }
fn fetch_transfers(&mut self, optional_args: &[Value]) -> impl ::std::future::Future<Output = Value> + Send { async move {
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
}));
panic!("{}", crate::exchange_errors::not_supported(add(&self.id, &Value::Str(" fetchTransfers () is not supported yet".to_string()))));
Value::Null
} }
fn un_watch_ohlcv(&mut self, mut symbol: Value, optional_args: &[Value]) -> impl ::std::future::Future<Output = Value> + Send { async move {
let mut timeframe = get_arg(optional_args, 0, Value::Str("1m".to_string()));
let mut params = get_arg(optional_args, 1, Value::Map({
let mut m = indexmap::IndexMap::new();
m
}));
panic!("{}", crate::exchange_errors::not_supported(add(&self.id, &Value::Str(" unWatchOHLCV () is not supported yet".to_string()))));
Value::Null
} }
fn withdraw_ws(&mut self, mut code: Value, mut amount: Value, mut address: Value, optional_args: &[Value]) -> impl ::std::future::Future<Output = Value> + Send { async move {
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
}));
panic!("{}", crate::exchange_errors::not_supported(add(&self.id, &Value::Str(" withdrawWs () is not supported yet".to_string()))));
Value::Null
} }
fn un_watch_my_trades(&mut self, optional_args: &[Value]) -> impl ::std::future::Future<Output = Value> + Send { async move {
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
}));
panic!("{}", crate::exchange_errors::not_supported(add(&self.id, &Value::Str(" unWatchMyTrades () is not supported yet".to_string()))));
Value::Null
} }
fn fetch_orders_by_status_ws(&mut self, mut status: Value, optional_args: &[Value]) -> impl ::std::future::Future<Output = Value> + Send { async move {
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
}));
panic!("{}", crate::exchange_errors::not_supported(add(&self.id, &Value::Str(" fetchOrdersByStatusWs () is not supported yet".to_string()))));
Value::Null
} }
fn un_watch_bids_asks(&mut self, optional_args: &[Value]) -> impl ::std::future::Future<Output = Value> + Send { async move {
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
}));
panic!("{}", crate::exchange_errors::not_supported(add(&self.id, &Value::Str(" unWatchBidsAsks () is not supported yet".to_string()))));
Value::Null
} }
fn clean_unsubscription(&self, mut client: Value, mut subHash: Value, mut unsubHash: Value, optional_args: &[Value]) {
let mut subHashIsPrefix = get_arg(optional_args, 0, Value::Bool(false));
if is_true(&(!is_equal(&unsubHash, &Value::Null))) && is_true(&(Value::Bool(in_op(&get_value(&client, &Value::Str("subscriptions".to_string())), &unsubHash)))) {
remove(&mut get_value(&client, &Value::Str("subscriptions".to_string())), &unsubHash);
}
if !is_true(&subHashIsPrefix) {
if is_true(&(!is_equal(&subHash, &Value::Null))) && is_true(&(Value::Bool(in_op(&get_value(&client, &Value::Str("subscriptions".to_string())), &subHash)))) {
remove(&mut get_value(&client, &Value::Str("subscriptions".to_string())), &subHash);
}
if is_true(&(!is_equal(&subHash, &Value::Null))) && is_true(&(Value::Bool(in_op(&get_value(&client, &Value::Str("futures".to_string())), &subHash)))) {
let mut error = crate::exchange_errors::unsubscribe_error(add(&add(&self.id, &Value::Str(" ".to_string())), &subHash));
client.reject(&[Value::from(error.clone()), subHash.clone()]);
}
} else {
let mut clientSubscriptions: Value = object_keys(&get_value(&client, &Value::Str("subscriptions".to_string())));
{
let mut i: Value = Value::Int(0);
let mut __for_first_172: bool = true;
while { if !__for_first_172 { i = add(&i, &Value::Int(1)); } __for_first_172 = false; is_less_than(&i, &get_array_length(&clientSubscriptions)) } {
let mut sub: Value = get_value(&clientSubscriptions, &i);
let mut sub: Value = get_value(&clientSubscriptions, &i);
if is_true(&(!is_equal(&sub, &Value::Null))) && is_true(&(!is_equal(&subHash, &Value::Null))) && is_true(&Value::Bool(starts_with(&sub, &subHash))) {
remove(&mut get_value(&client, &Value::Str("subscriptions".to_string())), &sub);
}
}
}
let mut clientFutures: Value = object_keys(&get_value(&client, &Value::Str("futures".to_string())));
{
let mut i: Value = Value::Int(0);
let mut __for_first_173: bool = true;
while { if !__for_first_173 { i = add(&i, &Value::Int(1)); } __for_first_173 = false; is_less_than(&i, &get_array_length(&clientFutures)) } {
let mut future: Value = get_value(&clientFutures, &i);
let mut future: Value = get_value(&clientFutures, &i);
if is_true(&(!is_equal(&future, &Value::Null))) && is_true(&(!is_equal(&subHash, &Value::Null))) && is_true(&Value::Bool(starts_with(&future, &subHash))) {
let mut error = crate::exchange_errors::unsubscribe_error(add(&add(&self.id, &Value::Str(" ".to_string())), &future));
client.reject(&[Value::from(error.clone()), future.clone()]);
}
}
}
}
client.resolve(&[Value::Bool(true), unsubHash.clone()]);
}
fn clean_cache(&mut self, mut subscription: Value) {
let mut topic: Value = self.safe_string_k(subscription.clone(), "topic", &[]);
let mut symbols: Value = self.safe_list_k(subscription.clone(), "symbols", &[Value::List(vec![])]);
let mut symbolsLength: Value = get_array_length(&symbols);
if is_equal(&topic, &Value::Str("ohlcv".to_string())) {
let mut symbolsAndTimeframes: Value = self.safe_list_k(subscription.clone(), "symbolsAndTimeframes", &[Value::List(vec![])]);
{
let mut i: Value = Value::Int(0);
let mut __for_first_174: bool = true;
while { if !__for_first_174 { i = add(&i, &Value::Int(1)); } __for_first_174 = false; is_less_than(&i, &get_array_length(&symbolsAndTimeframes)) } {
let mut symbolAndTimeFrame: Value = get_value(&symbolsAndTimeframes, &i);
let mut symbolAndTimeFrame: Value = get_value(&symbolsAndTimeframes, &i);
let mut symbol: Value = self.safe_string(symbolAndTimeFrame.clone(), Value::Int(0), &[]);
let mut timeframe: Value = self.safe_string(symbolAndTimeFrame.clone(), Value::Int(1), &[]);
if is_equal(&symbol, &Value::Null) {
panic!("{}", crate::exchange_errors::arguments_required(add(&self.id, &Value::Str(" cleanCache() requires a symbol argument".to_string()))));
}
if is_equal(&timeframe, &Value::Null) {
panic!("{}", crate::exchange_errors::arguments_required(add(&self.id, &Value::Str(" cleanCache() requires a timeframe argument".to_string()))));
}
if is_true(&(!is_equal(&self.ohlcvs, &Value::Null))) && is_true(&(Value::Bool(in_op(&self.ohlcvs, &symbol)))) {
if is_true(&Value::Bool(in_op(&get_value(&self.ohlcvs, &symbol), &timeframe))) {
remove(&mut get_value(&self.ohlcvs, &symbol), &timeframe);
}
}
}
}
} else if is_greater_than(&symbolsLength, &Value::Int(0)) {
{
let mut i: Value = Value::Int(0);
let mut __for_first_175: bool = true;
while { if !__for_first_175 { i = add(&i, &Value::Int(1)); } __for_first_175 = false; is_less_than(&i, &get_array_length(&symbols)) } {
let mut symbol: Value = get_value(&symbols, &i);
let mut symbol: Value = get_value(&symbols, &i);
if is_equal(&topic, &Value::Str("trades".to_string())) {
if is_true(&Value::Bool(in_op(&self.trades, &symbol))) {
remove(&mut self.trades.clone(), &symbol);
}
} else if is_equal(&topic, &Value::Str("orderbook".to_string())) {
if is_true(&Value::Bool(in_op(&self.orderbooks, &symbol))) {
remove(&mut self.orderbooks.clone(), &symbol);
}
} else if is_equal(&topic, &Value::Str("ticker".to_string())) {
if is_true(&Value::Bool(in_op(&self.tickers, &symbol))) {
remove(&mut self.tickers.clone(), &symbol);
}
} else if is_equal(&topic, &Value::Str("bidsasks".to_string())) {
if is_true(&Value::Bool(in_op(&self.bidsasks, &symbol))) {
remove(&mut self.bidsasks.clone(), &symbol);
}
}
}
}
} else {
if is_equal(&topic, &Value::Str("myTrades".to_string())) && is_true(&(!is_equal(&self.myTrades, &Value::Null))) {
self.myTrades = Value::Null;
} else if is_equal(&topic, &Value::Str("orders".to_string())) && is_true(&(!is_equal(&self.orders, &Value::Null))) {
self.orders = Value::Null;
} else if is_equal(&topic, &Value::Str("positions".to_string())) && is_true(&(!is_equal(&self.positions, &Value::Null))) {
self.positions = Value::Null;
let mut clients: Value = object_values(&self.clients);
{
let mut i: Value = Value::Int(0);
let mut __for_first_176: bool = true;
while { if !__for_first_176 { i = add(&i, &Value::Int(1)); } __for_first_176 = false; is_less_than(&i, &get_array_length(&clients)) } {
let mut client: Value = get_value(&clients, &i);
let mut client: Value = get_value(&clients, &i);
let mut futures: Value = get_value(&client, &Value::Str("futures".to_string()));
if is_true(&(!is_equal(&futures, &Value::Null))) && is_true(&(Value::Bool(in_op(&futures, &Value::Str("fetchPositionsSnapshot".to_string()))))) {
remove(&mut futures, &Value::Str("fetchPositionsSnapshot".to_string()));
}
}
}
} else if is_true(&(is_equal(&topic, &Value::Str("ticker".to_string())) || is_equal(&topic, &Value::Str("markPrice".to_string())))) && is_true(&(!is_equal(&self.tickers, &Value::Null))) {
let mut tickerSymbols: Value = object_keys(&self.tickers);
{
let mut i: Value = Value::Int(0);
let mut __for_first_177: bool = true;
while { if !__for_first_177 { i = add(&i, &Value::Int(1)); } __for_first_177 = false; is_less_than(&i, &get_array_length(&tickerSymbols)) } {
let mut tickerSymbol: Value = get_value(&tickerSymbols, &i);
let mut tickerSymbol: Value = get_value(&tickerSymbols, &i);
if is_true(&Value::Bool(in_op(&self.tickers, &tickerSymbol))) {
remove(&mut self.tickers.clone(), &tickerSymbol);
}
}
}
} else if is_equal(&topic, &Value::Str("bidsasks".to_string())) && is_true(&(!is_equal(&self.bidsasks, &Value::Null))) {
let mut bidsaskSymbols: Value = object_keys(&self.bidsasks);
{
let mut i: Value = Value::Int(0);
let mut __for_first_178: bool = true;
while { if !__for_first_178 { i = add(&i, &Value::Int(1)); } __for_first_178 = false; is_less_than(&i, &get_array_length(&bidsaskSymbols)) } {
let mut bidsaskSymbol: Value = get_value(&bidsaskSymbols, &i);
let mut bidsaskSymbol: Value = get_value(&bidsaskSymbols, &i);
if is_true(&Value::Bool(in_op(&self.bidsasks, &bidsaskSymbol))) {
remove(&mut self.bidsasks.clone(), &bidsaskSymbol);
}
}
}
}
}
}
fn timeframe_from_milliseconds(&self, mut ms: Value) -> Value {
if is_less_than_or_equal(&ms, &Value::Int(0)) {
return Value::Str("".to_string());
}
let mut second: Value = Value::Int(1000);
let mut minute: Value = multiply(&Value::Int(60), &second);
let mut hour: Value = multiply(&Value::Int(60), &minute);
let mut day: Value = multiply(&Value::Int(24), &hour);
let mut week: Value = multiply(&Value::Int(7), &day);
if is_equal(&mod_val(&ms, &week), &Value::Int(0)) {
return add(&(divide(&ms, &week)), &Value::Str("w".to_string()));
}
if is_equal(&mod_val(&ms, &day), &Value::Int(0)) {
return add(&(divide(&ms, &day)), &Value::Str("d".to_string()));
}
if is_equal(&mod_val(&ms, &hour), &Value::Int(0)) {
return add(&(divide(&ms, &hour)), &Value::Str("h".to_string()));
}
if is_equal(&mod_val(&ms, &minute), &Value::Int(0)) {
return add(&(divide(&ms, &minute)), &Value::Str("m".to_string()));
}
if is_equal(&mod_val(&ms, &second), &Value::Int(0)) {
return add(&(divide(&ms, &second)), &Value::Str("s".to_string()));
}
return Value::Str("".to_string());
Value::Null
}
fn is_uta_enabled(&mut self, optional_args: &[Value]) -> impl ::std::future::Future<Output = Value> + Send { async move {
let mut params = get_arg(optional_args, 0, Value::Map({
let mut m = indexmap::IndexMap::new();
m
}));
return Value::Bool(false);
Value::Null
} }
fn close_position(&mut self, mut symbol: Value, optional_args: &[Value]) -> impl ::std::future::Future<Output = Value> + Send { async move {
let mut side = get_arg(optional_args, 0, Value::Null);
let mut params = get_arg(optional_args, 1, Value::Map({
let mut m = indexmap::IndexMap::new();
m
}));
panic!("{}", crate::exchange_errors::not_supported(add(&self.id, &Value::Str(" closePosition() is not supported yet".to_string()))));
Value::Null
} }
fn close_all_positions(&mut self, optional_args: &[Value]) -> impl ::std::future::Future<Output = Value> + Send { async move {
let mut params = get_arg(optional_args, 0, Value::Map({
let mut m = indexmap::IndexMap::new();
m
}));
panic!("{}", crate::exchange_errors::not_supported(add(&self.id, &Value::Str(" closeAllPositions() is not supported yet".to_string()))));
Value::Null
} }
fn edit_orders(&mut self, mut orders: Value, optional_args: &[Value]) -> impl ::std::future::Future<Output = Value> + Send { async move {
let mut params = get_arg(optional_args, 0, Value::Map({
let mut m = indexmap::IndexMap::new();
m
}));
panic!("{}", crate::exchange_errors::not_supported(add(&self.id, &Value::Str(" editOrders() is not supported yet".to_string()))));
Value::Null
} }
fn fetch_canceled_and_closed_orders(&mut self, optional_args: &[Value]) -> impl ::std::future::Future<Output = Value> + Send { async move {
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
}));
panic!("{}", crate::exchange_errors::not_supported(add(&self.id, &Value::Str(" fetchCanceledAndClosedOrders() is not supported yet".to_string()))));
Value::Null
} }
fn fetch_position_history(&mut self, mut symbol: Value, optional_args: &[Value]) -> impl ::std::future::Future<Output = Value> + Send { async move {
// async-virtual: try the derived exchange first
if let Some(__v) = self.dispatch_to_derived("fetch_position_history", { let mut __args: Vec<crate::Value> = Vec::new(); __args.push(symbol.clone()); __args.extend_from_slice(optional_args); __args }).await {
if !matches!(__v, crate::Value::Null) { return __v; }
}
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
}));
/*
* @method
* @name exchange#fetchPositionHistory
* @description fetches the history of margin added or reduced from contract isolated positions
* @param {string} [symbol] unified market symbol
* @param {int} [since] timestamp in ms of the position
* @param {int} [limit] the maximum amount of candles to fetch, default=1000
* @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}
*/
if !is_equal(&get_value(&self.has, &Value::Str("fetchPositionsHistory".to_string())), &Value::Null) && !is_equal(&get_value(&self.has, &Value::Str("fetchPositionsHistory".to_string())), &Value::Bool(false)) {
let mut positions: Value = self.fetch_positions_history(&[Value::List(vec![symbol.clone()]), since.clone(), limit.clone(), params.clone()]).await;
return positions;
} else {
panic!("{}", crate::exchange_errors::not_supported(add(&self.id, &Value::Str(" fetchPositionHistory () is not supported yet".to_string()))));
}
} }
fn fetch_positions_history(&mut self, optional_args: &[Value]) -> impl ::std::future::Future<Output = Value> + Send { async move {
// async-virtual: try the derived exchange first
if let Some(__v) = self.dispatch_to_derived("fetch_positions_history", { let mut __args: Vec<crate::Value> = Vec::new(); __args.extend_from_slice(optional_args); __args }).await {
if !matches!(__v, crate::Value::Null) { return __v; }
}
let mut symbols = get_arg(optional_args, 0, Value::Null);
let mut since = get_arg(optional_args, 1, Value::Null);
let mut limit = get_arg(optional_args, 2, Value::Null);
let mut params = get_arg(optional_args, 3, Value::Map({
let mut m = indexmap::IndexMap::new();
m
}));
panic!("{}", crate::exchange_errors::not_supported(add(&self.id, &Value::Str(" fetchPositionsHistory () is not supported yet".to_string()))));
Value::Null
} }
fn fetch_positions_risk(&mut self, optional_args: &[Value]) -> impl ::std::future::Future<Output = Value> + Send { async move {
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
}));
panic!("{}", crate::exchange_errors::not_supported(add(&self.id, &Value::Str(" fetchPositionsRisk() is not supported yet".to_string()))));
Value::Null
} }
fn fetch_positions_for_symbol(&mut self, mut symbol: Value, optional_args: &[Value]) -> impl ::std::future::Future<Output = Value> + Send { async move {
let mut params = get_arg(optional_args, 0, Value::Map({
let mut m = indexmap::IndexMap::new();
m
}));
panic!("{}", crate::exchange_errors::not_supported(add(&self.id, &Value::Str(" fetchPositionsForSymbol() is not supported yet".to_string()))));
Value::Null
} }
fn fetch_positions_for_symbol_ws(&mut self, mut symbol: Value, optional_args: &[Value]) -> impl ::std::future::Future<Output = Value> + Send { async move {
let mut params = get_arg(optional_args, 0, Value::Map({
let mut m = indexmap::IndexMap::new();
m
}));
panic!("{}", crate::exchange_errors::not_supported(add(&self.id, &Value::Str(" fetchPositionsForSymbol() is not supported yet".to_string()))));
Value::Null
} }
fn watch_position(&mut self, optional_args: &[Value]) -> impl ::std::future::Future<Output = Value> + Send { async move {
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
}));
panic!("{}", crate::exchange_errors::not_supported(add(&self.id, &Value::Str(" watchPosition() is not supported yet".to_string()))));
Value::Null
} }
fn watch_my_trades_for_symbols(&mut self, mut symbols: Value, optional_args: &[Value]) -> impl ::std::future::Future<Output = Value> + Send { async move {
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
}));
panic!("{}", crate::exchange_errors::not_supported(add(&self.id, &Value::Str(" watchMyTradesForSymbols() is not supported yet".to_string()))));
Value::Null
} }
fn watch_trades_for_symbols(&mut self, mut symbols: Value, optional_args: &[Value]) -> impl ::std::future::Future<Output = Value> + Send { async move {
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
}));
panic!("{}", crate::exchange_errors::not_supported(add(&self.id, &Value::Str(" watchTradesForSymbols() is not supported yet".to_string()))));
Value::Null
} }
fn fetch_bids_asks(&mut self, optional_args: &[Value]) -> impl ::std::future::Future<Output = Value> + Send { async move {
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
}));
panic!("{}", crate::exchange_errors::not_supported(add(&self.id, &Value::Str(" fetchBidsAsks() is not supported yet".to_string()))));
Value::Null
} }
fn fetch_mark_price(&mut self, mut symbol: Value, optional_args: &[Value]) -> impl ::std::future::Future<Output = Value> + Send { async move {
let mut params = get_arg(optional_args, 0, Value::Map({
let mut m = indexmap::IndexMap::new();
m
}));
if !is_equal(&get_value(&self.has, &Value::Str("fetchMarkPrices".to_string())), &Value::Null) && !is_equal(&get_value(&self.has, &Value::Str("fetchMarkPrices".to_string())), &Value::Bool(false)) {
self.load_markets(&[]).await;
let mut market: Value = self.market(symbol.clone());
symbol = get_value(&market, &Value::Str("symbol".to_string()));
let mut tickers: Value = self.fetch_mark_prices(&[Value::List(vec![symbol.clone()]), params.clone()]).await;
let mut ticker: Value = self.safe_dict(tickers.clone(), symbol.clone(), &[]);
if is_equal(&ticker, &Value::Null) {
panic!("{}", crate::exchange_errors::null_response(add(&add(&self.id, &Value::Str(" fetchMarkPrices() could not find a ticker for ".to_string())), &symbol)));
} else {
return ticker;
}
} else {
panic!("{}", crate::exchange_errors::not_supported(add(&self.id, &Value::Str(" fetchMarkPrices() is not supported yet".to_string()))));
}
Value::Null
} }
fn fetch_mark_prices(&mut self, optional_args: &[Value]) -> impl ::std::future::Future<Output = Value> + Send { async move {
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
}));
panic!("{}", crate::exchange_errors::not_supported(add(&self.id, &Value::Str(" fetchMarkPrices() is not supported yet".to_string()))));
Value::Null
} }
fn watch_bids_asks(&mut self, optional_args: &[Value]) -> impl ::std::future::Future<Output = Value> + Send { async move {
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
}));
panic!("{}", crate::exchange_errors::not_supported(add(&self.id, &Value::Str(" watchBidsAsks() is not supported yet".to_string()))));
Value::Null
} }
fn watch_mark_price(&mut self, mut symbol: Value, optional_args: &[Value]) -> impl ::std::future::Future<Output = Value> + Send { async move {
let mut params = get_arg(optional_args, 0, Value::Map({
let mut m = indexmap::IndexMap::new();
m
}));
panic!("{}", crate::exchange_errors::not_supported(add(&self.id, &Value::Str(" watchMarkPrice () is not supported yet".to_string()))));
Value::Null
} }
fn watch_mark_prices(&mut self, optional_args: &[Value]) -> impl ::std::future::Future<Output = Value> + Send { async move {
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
}));
panic!("{}", crate::exchange_errors::not_supported(add(&self.id, &Value::Str(" watchMarkPrices () is not supported yet".to_string()))));
Value::Null
} }
fn fetch_l3_order_book(&mut self, mut symbol: Value, optional_args: &[Value]) -> impl ::std::future::Future<Output = Value> + Send { async move {
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
}));
panic!("{}", crate::exchange_errors::bad_request(add(&self.id, &Value::Str(" fetchL3OrderBook() is not supported yet".to_string()))));
Value::Null
} }
fn watch_order_book_for_symbols(&mut self, mut symbols: Value, optional_args: &[Value]) -> impl ::std::future::Future<Output = Value> + Send { async move {
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
}));
panic!("{}", crate::exchange_errors::not_supported(add(&self.id, &Value::Str(" watchOrderBookForSymbols() is not supported yet".to_string()))));
Value::Null
} }
fn watch_orders_for_symbols(&mut self, mut symbols: Value, optional_args: &[Value]) -> impl ::std::future::Future<Output = Value> + Send { async move {
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
}));
panic!("{}", crate::exchange_errors::not_supported(add(&self.id, &Value::Str(" watchOrdersForSymbols() is not supported yet".to_string()))));
Value::Null
} }
fn cancel_all_orders_ws(&mut self, optional_args: &[Value]) -> impl ::std::future::Future<Output = Value> + Send { async move {
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
}));
panic!("{}", crate::exchange_errors::not_supported(add(&self.id, &Value::Str(" cancelAllOrdersWs() is not supported yet".to_string()))));
Value::Null
} }
fn cancel_order_ws(&mut self, mut id: Value, optional_args: &[Value]) -> impl ::std::future::Future<Output = Value> + Send { async move {
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
}));
panic!("{}", crate::exchange_errors::not_supported(add(&self.id, &Value::Str(" cancelOrderWs() is not supported yet".to_string()))));
Value::Null
} }
fn cancel_orders_ws(&mut self, mut ids: Value, optional_args: &[Value]) -> impl ::std::future::Future<Output = Value> + Send { async move {
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
}));
panic!("{}", crate::exchange_errors::not_supported(add(&self.id, &Value::Str(" cancelOrdersWs() is not supported yet".to_string()))));
Value::Null
} }
fn create_limit_buy_order_ws(&mut self, mut symbol: Value, mut amount: Value, mut price: Value, optional_args: &[Value]) -> impl ::std::future::Future<Output = Value> + Send { async move {
let mut params = get_arg(optional_args, 0, Value::Map({
let mut m = indexmap::IndexMap::new();
m
}));
return self.create_order_ws(symbol.clone(), Value::Str("limit".to_string()), Value::Str("buy".to_string()), amount.clone(), &[price.clone(), params.clone()]).await;
Value::Null
} }
fn create_limit_order_ws(&mut self, mut symbol: Value, mut side: Value, mut amount: Value, mut price: Value, optional_args: &[Value]) -> impl ::std::future::Future<Output = Value> + Send { async move {
let mut params = get_arg(optional_args, 0, Value::Map({
let mut m = indexmap::IndexMap::new();
m
}));
return self.create_order_ws(symbol.clone(), Value::Str("limit".to_string()), side.clone(), amount.clone(), &[price.clone(), params.clone()]).await;
Value::Null
} }
fn create_limit_sell_order_ws(&mut self, mut symbol: Value, mut amount: Value, mut price: Value, optional_args: &[Value]) -> impl ::std::future::Future<Output = Value> + Send { async move {
let mut params = get_arg(optional_args, 0, Value::Map({
let mut m = indexmap::IndexMap::new();
m
}));
return self.create_order_ws(symbol.clone(), Value::Str("limit".to_string()), Value::Str("sell".to_string()), amount.clone(), &[price.clone(), params.clone()]).await;
Value::Null
} }
fn create_market_buy_order_ws(&mut self, mut symbol: Value, mut amount: Value, optional_args: &[Value]) -> impl ::std::future::Future<Output = Value> + Send { async move {
let mut params = get_arg(optional_args, 0, Value::Map({
let mut m = indexmap::IndexMap::new();
m
}));
return self.create_order_ws(symbol.clone(), Value::Str("market".to_string()), Value::Str("buy".to_string()), amount.clone(), &[Value::Null, params.clone()]).await;
Value::Null
} }
fn create_market_order_with_cost_ws(&mut self, mut symbol: Value, mut side: Value, mut cost: Value, optional_args: &[Value]) -> impl ::std::future::Future<Output = Value> + Send { async move {
let mut params = get_arg(optional_args, 0, Value::Map({
let mut m = indexmap::IndexMap::new();
m
}));
/*
* @method
* @name createMarketOrderWithCostWs
* @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}
*/
if is_true(&(!is_equal(&get_value(&self.has, &Value::Str("createMarketOrderWithCostWs".to_string())), &Value::Null) && !is_equal(&get_value(&self.has, &Value::Str("createMarketOrderWithCostWs".to_string())), &Value::Bool(false)))) || is_true(&(is_true(&(!is_equal(&get_value(&self.has, &Value::Str("createMarketBuyOrderWithCostWs".to_string())), &Value::Null) && !is_equal(&get_value(&self.has, &Value::Str("createMarketBuyOrderWithCostWs".to_string())), &Value::Bool(false)))) && is_true(&(!is_equal(&get_value(&self.has, &Value::Str("createMarketSellOrderWithCostWs".to_string())), &Value::Null) && !is_equal(&get_value(&self.has, &Value::Str("createMarketSellOrderWithCostWs".to_string())), &Value::Bool(false)))))) {
return self.create_order_ws(symbol.clone(), Value::Str("market".to_string()), side.clone(), cost.clone(), &[Value::Int(1), params.clone()]).await;
}
panic!("{}", crate::exchange_errors::not_supported(add(&self.id, &Value::Str(" createMarketOrderWithCostWs() is not supported yet".to_string()))));
Value::Null
} }
fn create_market_order_ws(&mut self, mut symbol: Value, mut side: Value, mut amount: Value, optional_args: &[Value]) -> impl ::std::future::Future<Output = Value> + Send { async move {
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
}));
return self.create_order_ws(symbol.clone(), Value::Str("market".to_string()), side.clone(), amount.clone(), &[price.clone(), params.clone()]).await;
Value::Null
} }
fn create_market_sell_order_ws(&mut self, mut symbol: Value, mut amount: Value, optional_args: &[Value]) -> impl ::std::future::Future<Output = Value> + Send { async move {
let mut params = get_arg(optional_args, 0, Value::Map({
let mut m = indexmap::IndexMap::new();
m
}));
return self.create_order_ws(symbol.clone(), Value::Str("market".to_string()), Value::Str("sell".to_string()), amount.clone(), &[Value::Null, params.clone()]).await;
Value::Null
} }
fn create_order_with_take_profit_and_stop_loss_ws(&mut self, mut symbol: Value, mut type_var: Value, mut side: Value, mut amount: Value, optional_args: &[Value]) -> impl ::std::future::Future<Output = Value> + Send { async move {
let mut price = get_arg(optional_args, 0, Value::Null);
let mut takeProfit = get_arg(optional_args, 1, Value::Null);
let mut stopLoss = get_arg(optional_args, 2, Value::Null);
let mut params = get_arg(optional_args, 3, Value::Map({
let mut m = indexmap::IndexMap::new();
m
}));
/*
* @method
* @name createOrderWithTakeProfitAndStopLossWs
* @description create an order with a stop loss or take profit attached (type 3)
* @param {string} symbol unified symbol of the market to create an order in
* @param {string} type 'market' or 'limit'
* @param {string} side 'buy' or 'sell'
* @param {float} amount how much you want to trade in units of the base currency or the number of contracts
* @param {float} [price] the price to fulfill the order, in units of the quote currency, ignored in market orders
* @param {float} [takeProfit] the take profit price, in units of the quote currency
* @param {float} [stopLoss] the stop loss price, in units of the quote currency
* @param {object} [params] extra parameters specific to the exchange API endpoint
* @param {string} [params.takeProfitType] *not available on all exchanges* 'limit' or 'market'
* @param {string} [params.stopLossType] *not available on all exchanges* 'limit' or 'market'
* @param {string} [params.takeProfitPriceType] *not available on all exchanges* 'last', 'mark' or 'index'
* @param {string} [params.stopLossPriceType] *not available on all exchanges* 'last', 'mark' or 'index'
* @param {float} [params.takeProfitLimitPrice] *not available on all exchanges* limit price for a limit take profit order
* @param {float} [params.stopLossLimitPrice] *not available on all exchanges* stop loss for a limit stop loss order
* @param {float} [params.takeProfitAmount] *not available on all exchanges* the amount for a take profit
* @param {float} [params.stopLossAmount] *not available on all exchanges* the amount for a stop loss
* @returns {object} an [order structure]{@link https://docs.ccxt.com/?id=order-structure}
*/
params = self.set_take_profit_and_stop_loss_params(symbol.clone(), type_var.clone(), side.clone(), amount.clone(), &[price.clone(), takeProfit.clone(), stopLoss.clone(), params.clone()]);
if !is_equal(&get_value(&self.has, &Value::Str("createOrderWithTakeProfitAndStopLossWs".to_string())), &Value::Null) && !is_equal(&get_value(&self.has, &Value::Str("createOrderWithTakeProfitAndStopLossWs".to_string())), &Value::Bool(false)) {
return self.create_order_ws(symbol.clone(), type_var.clone(), side.clone(), amount.clone(), &[price.clone(), params.clone()]).await;
}
panic!("{}", crate::exchange_errors::not_supported(add(&self.id, &Value::Str(" createOrderWithTakeProfitAndStopLossWs() is not supported yet".to_string()))));
Value::Null
} }
fn create_order_ws(&mut self, mut symbol: Value, mut type_var: Value, mut side: Value, mut amount: Value, optional_args: &[Value]) -> impl ::std::future::Future<Output = Value> + Send { async move {
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
}));
panic!("{}", crate::exchange_errors::not_supported(add(&self.id, &Value::Str(" createOrderWs() is not supported yet".to_string()))));
Value::Null
} }
fn create_orders_ws(&mut self, mut orders: Value, optional_args: &[Value]) -> impl ::std::future::Future<Output = Value> + Send { async move {
let mut params = get_arg(optional_args, 0, Value::Map({
let mut m = indexmap::IndexMap::new();
m
}));
panic!("{}", crate::exchange_errors::not_supported(add(&self.id, &Value::Str(" createOrdersWs () is not supported yet".to_string()))));
Value::Null
} }
fn create_post_only_order_ws(&mut self, mut symbol: Value, mut type_var: Value, mut side: Value, mut amount: Value, optional_args: &[Value]) -> impl ::std::future::Future<Output = Value> + Send { async move {
let mut price = get_arg(optional_args, 0, Value::Null);
let mut params = get_arg(optional_args, 1, Value::Map({
let mut m = indexmap::IndexMap::new();
m
}));
if is_equal(&get_value(&self.has, &Value::Str("createPostOnlyOrderWs".to_string())), &Value::Null) || is_equal(&get_value(&self.has, &Value::Str("createPostOnlyOrderWs".to_string())), &Value::Bool(false)) {
panic!("{}", crate::exchange_errors::not_supported(add(&self.id, &Value::Str(" createPostOnlyOrderWs() is not supported yet".to_string()))));
}
let mut query: Value = self.extend(params.clone(), &[Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("postOnly".to_string(), Value::Bool(true));
m
})]);
return self.create_order_ws(symbol.clone(), type_var.clone(), side.clone(), amount.clone(), &[price.clone(), query.clone()]).await;
Value::Null
} }
fn create_reduce_only_order_ws(&mut self, mut symbol: Value, mut type_var: Value, mut side: Value, mut amount: Value, optional_args: &[Value]) -> impl ::std::future::Future<Output = Value> + Send { async move {
let mut price = get_arg(optional_args, 0, Value::Null);
let mut params = get_arg(optional_args, 1, Value::Map({
let mut m = indexmap::IndexMap::new();
m
}));
if is_equal(&get_value(&self.has, &Value::Str("createReduceOnlyOrderWs".to_string())), &Value::Null) || is_equal(&get_value(&self.has, &Value::Str("createReduceOnlyOrderWs".to_string())), &Value::Bool(false)) {
panic!("{}", crate::exchange_errors::not_supported(add(&self.id, &Value::Str(" createReduceOnlyOrderWs() is not supported yet".to_string()))));
}
let mut query: Value = self.extend(params.clone(), &[Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("reduceOnly".to_string(), Value::Bool(true));
m
})]);
return self.create_order_ws(symbol.clone(), type_var.clone(), side.clone(), amount.clone(), &[price.clone(), query.clone()]).await;
Value::Null
} }
fn create_stop_limit_order_ws(&mut self, mut symbol: Value, mut side: Value, mut amount: Value, mut price: Value, mut triggerPrice: Value, optional_args: &[Value]) -> impl ::std::future::Future<Output = Value> + Send { async move {
let mut params = get_arg(optional_args, 0, Value::Map({
let mut m = indexmap::IndexMap::new();
m
}));
if is_equal(&get_value(&self.has, &Value::Str("createStopLimitOrderWs".to_string())), &Value::Null) || is_equal(&get_value(&self.has, &Value::Str("createStopLimitOrderWs".to_string())), &Value::Bool(false)) {
panic!("{}", crate::exchange_errors::not_supported(add(&self.id, &Value::Str(" createStopLimitOrderWs() is not supported yet".to_string()))));
}
let mut query: Value = self.extend(params.clone(), &[Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("stopPrice".to_string(), triggerPrice.clone());
m
})]);
return self.create_order_ws(symbol.clone(), Value::Str("limit".to_string()), side.clone(), amount.clone(), &[price.clone(), query.clone()]).await;
Value::Null
} }
fn create_stop_loss_order_ws(&mut self, mut symbol: Value, mut type_var: Value, mut side: Value, mut amount: Value, optional_args: &[Value]) -> impl ::std::future::Future<Output = Value> + Send { async move {
let mut price = get_arg(optional_args, 0, Value::Null);
let mut stopLossPrice = get_arg(optional_args, 1, Value::Null);
let mut params = get_arg(optional_args, 2, Value::Map({
let mut m = indexmap::IndexMap::new();
m
}));
/*
* @method
* @name createStopLossOrderWs
* @description create a trigger stop loss order (type 2)
* @param {string} symbol unified symbol of the market to create an order in
* @param {string} type 'market' or 'limit'
* @param {string} side 'buy' or 'sell'
* @param {float} amount how much you want to trade in units of the base currency or the number of contracts
* @param {float} [price] the price to fulfill the order, in units of the quote currency, ignored in market orders
* @param {float} stopLossPrice the price to trigger the stop loss order, 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}
*/
if is_equal(&stopLossPrice, &Value::Null) {
panic!("{}", crate::exchange_errors::arguments_required(add(&self.id, &Value::Str(" createStopLossOrderWs() requires a stopLossPrice argument".to_string()))));
}
params = self.extend(params.clone(), &[Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("stopLossPrice".to_string(), stopLossPrice.clone());
m
})]);
if !is_equal(&get_value(&self.has, &Value::Str("createStopLossOrderWs".to_string())), &Value::Null) && !is_equal(&get_value(&self.has, &Value::Str("createStopLossOrderWs".to_string())), &Value::Bool(false)) {
return self.create_order_ws(symbol.clone(), type_var.clone(), side.clone(), amount.clone(), &[price.clone(), params.clone()]).await;
}
panic!("{}", crate::exchange_errors::not_supported(add(&self.id, &Value::Str(" createStopLossOrderWs() is not supported yet".to_string()))));
Value::Null
} }
fn create_stop_market_order_ws(&mut self, mut symbol: Value, mut side: Value, mut amount: Value, mut triggerPrice: Value, optional_args: &[Value]) -> impl ::std::future::Future<Output = Value> + Send { async move {
let mut params = get_arg(optional_args, 0, Value::Map({
let mut m = indexmap::IndexMap::new();
m
}));
if is_equal(&get_value(&self.has, &Value::Str("createStopMarketOrderWs".to_string())), &Value::Null) || is_equal(&get_value(&self.has, &Value::Str("createStopMarketOrderWs".to_string())), &Value::Bool(false)) {
panic!("{}", crate::exchange_errors::not_supported(add(&self.id, &Value::Str(" createStopMarketOrderWs() is not supported yet".to_string()))));
}
let mut query: Value = self.extend(params.clone(), &[Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("stopPrice".to_string(), triggerPrice.clone());
m
})]);
return self.create_order_ws(symbol.clone(), Value::Str("market".to_string()), side.clone(), amount.clone(), &[Value::Null, query.clone()]).await;
Value::Null
} }
fn create_stop_order_ws(&mut self, mut symbol: Value, mut type_var: Value, mut side: Value, mut amount: Value, optional_args: &[Value]) -> impl ::std::future::Future<Output = Value> + Send { async move {
let mut price = get_arg(optional_args, 0, Value::Null);
let mut triggerPrice = get_arg(optional_args, 1, Value::Null);
let mut params = get_arg(optional_args, 2, Value::Map({
let mut m = indexmap::IndexMap::new();
m
}));
if is_equal(&get_value(&self.has, &Value::Str("createStopOrderWs".to_string())), &Value::Null) || is_equal(&get_value(&self.has, &Value::Str("createStopOrderWs".to_string())), &Value::Bool(false)) {
panic!("{}", crate::exchange_errors::not_supported(add(&self.id, &Value::Str(" createStopOrderWs() is not supported yet".to_string()))));
}
if is_equal(&triggerPrice, &Value::Null) {
panic!("{}", crate::exchange_errors::arguments_required(add(&self.id, &Value::Str(" createStopOrderWs() requires a stopPrice argument".to_string()))));
}
let mut query: Value = self.extend(params.clone(), &[Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("stopPrice".to_string(), triggerPrice.clone());
m
})]);
return self.create_order_ws(symbol.clone(), type_var.clone(), side.clone(), amount.clone(), &[price.clone(), query.clone()]).await;
Value::Null
} }
fn create_take_profit_order_ws(&mut self, mut symbol: Value, mut type_var: Value, mut side: Value, mut amount: Value, optional_args: &[Value]) -> impl ::std::future::Future<Output = Value> + Send { async move {
let mut price = get_arg(optional_args, 0, Value::Null);
let mut takeProfitPrice = get_arg(optional_args, 1, Value::Null);
let mut params = get_arg(optional_args, 2, Value::Map({
let mut m = indexmap::IndexMap::new();
m
}));
/*
* @method
* @name createTakeProfitOrderWs
* @description create a trigger take profit order (type 2)
* @param {string} symbol unified symbol of the market to create an order in
* @param {string} type 'market' or 'limit'
* @param {string} side 'buy' or 'sell'
* @param {float} amount how much you want to trade in units of the base currency or the number of contracts
* @param {float} [price] the price to fulfill the order, in units of the quote currency, ignored in market orders
* @param {float} takeProfitPrice the price to trigger the take profit order, 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}
*/
if is_equal(&takeProfitPrice, &Value::Null) {
panic!("{}", crate::exchange_errors::arguments_required(add(&self.id, &Value::Str(" createTakeProfitOrderWs() requires a takeProfitPrice argument".to_string()))));
}
params = self.extend(params.clone(), &[Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("takeProfitPrice".to_string(), takeProfitPrice.clone());
m
})]);
if !is_equal(&get_value(&self.has, &Value::Str("createTakeProfitOrderWs".to_string())), &Value::Null) && !is_equal(&get_value(&self.has, &Value::Str("createTakeProfitOrderWs".to_string())), &Value::Bool(false)) {
return self.create_order_ws(symbol.clone(), type_var.clone(), side.clone(), amount.clone(), &[price.clone(), params.clone()]).await;
}
panic!("{}", crate::exchange_errors::not_supported(add(&self.id, &Value::Str(" createTakeProfitOrderWs() is not supported yet".to_string()))));
Value::Null
} }
fn create_trailing_amount_order_ws(&mut self, mut symbol: Value, mut type_var: Value, mut side: Value, mut amount: Value, optional_args: &[Value]) -> impl ::std::future::Future<Output = Value> + Send { async move {
let mut price = get_arg(optional_args, 0, Value::Null);
let mut trailingAmount = get_arg(optional_args, 1, Value::Null);
let mut trailingTriggerPrice = get_arg(optional_args, 2, Value::Null);
let mut params = get_arg(optional_args, 3, Value::Map({
let mut m = indexmap::IndexMap::new();
m
}));
/*
* @method
* @name createTrailingAmountOrderWs
* @description create a trailing order by providing the symbol, type, side, amount, price and trailingAmount
* @param {string} symbol unified symbol of the market to create an order in
* @param {string} type 'market' or 'limit'
* @param {string} side 'buy' or 'sell'
* @param {float} amount how much you want to trade in units of the base currency, or number of contracts
* @param {float} [price] the price for the order to be filled at, in units of the quote currency, ignored in market orders
* @param {float} trailingAmount the quote amount to trail away from the current market price
* @param {float} [trailingTriggerPrice] the price to activate a trailing order, default uses the price argument
* @param {object} [params] extra parameters specific to the exchange API endpoint
* @returns {object} an [order structure]{@link https://docs.ccxt.com/?id=order-structure}
*/
if is_equal(&trailingAmount, &Value::Null) {
panic!("{}", crate::exchange_errors::arguments_required(add(&self.id, &Value::Str(" createTrailingAmountOrderWs() requires a trailingAmount argument".to_string()))));
}
add_element_to_object(&mut params, &Value::Str("trailingAmount".to_string()), trailingAmount.clone());
if !is_equal(&trailingTriggerPrice, &Value::Null) {
add_element_to_object(&mut params, &Value::Str("trailingTriggerPrice".to_string()), trailingTriggerPrice.clone());
}
if !is_equal(&get_value(&self.has, &Value::Str("createTrailingAmountOrderWs".to_string())), &Value::Null) && !is_equal(&get_value(&self.has, &Value::Str("createTrailingAmountOrderWs".to_string())), &Value::Bool(false)) {
return self.create_order_ws(symbol.clone(), type_var.clone(), side.clone(), amount.clone(), &[price.clone(), params.clone()]).await;
}
panic!("{}", crate::exchange_errors::not_supported(add(&self.id, &Value::Str(" createTrailingAmountOrderWs() is not supported yet".to_string()))));
Value::Null
} }
fn create_trailing_percent_order_ws(&mut self, mut symbol: Value, mut type_var: Value, mut side: Value, mut amount: Value, optional_args: &[Value]) -> impl ::std::future::Future<Output = Value> + Send { async move {
let mut price = get_arg(optional_args, 0, Value::Null);
let mut trailingPercent = get_arg(optional_args, 1, Value::Null);
let mut trailingTriggerPrice = get_arg(optional_args, 2, Value::Null);
let mut params = get_arg(optional_args, 3, Value::Map({
let mut m = indexmap::IndexMap::new();
m
}));
/*
* @method
* @name createTrailingPercentOrderWs
* @description create a trailing order by providing the symbol, type, side, amount, price and trailingPercent
* @param {string} symbol unified symbol of the market to create an order in
* @param {string} type 'market' or 'limit'
* @param {string} side 'buy' or 'sell'
* @param {float} amount how much you want to trade in units of the base currency, or number of contracts
* @param {float} [price] the price for the order to be filled at, in units of the quote currency, ignored in market orders
* @param {float} trailingPercent the percent to trail away from the current market price
* @param {float} [trailingTriggerPrice] the price to activate a trailing order, default uses the price argument
* @param {object} [params] extra parameters specific to the exchange API endpoint
* @returns {object} an [order structure]{@link https://docs.ccxt.com/?id=order-structure}
*/
if is_equal(&trailingPercent, &Value::Null) {
panic!("{}", crate::exchange_errors::arguments_required(add(&self.id, &Value::Str(" createTrailingPercentOrderWs() requires a trailingPercent argument".to_string()))));
}
add_element_to_object(&mut params, &Value::Str("trailingPercent".to_string()), trailingPercent.clone());
if !is_equal(&trailingTriggerPrice, &Value::Null) {
add_element_to_object(&mut params, &Value::Str("trailingTriggerPrice".to_string()), trailingTriggerPrice.clone());
}
if !is_equal(&get_value(&self.has, &Value::Str("createTrailingPercentOrderWs".to_string())), &Value::Null) && !is_equal(&get_value(&self.has, &Value::Str("createTrailingPercentOrderWs".to_string())), &Value::Bool(false)) {
return self.create_order_ws(symbol.clone(), type_var.clone(), side.clone(), amount.clone(), &[price.clone(), params.clone()]).await;
}
panic!("{}", crate::exchange_errors::not_supported(add(&self.id, &Value::Str(" createTrailingPercentOrderWs() is not supported yet".to_string()))));
Value::Null
} }
fn create_trigger_order_ws(&mut self, mut symbol: Value, mut type_var: Value, mut side: Value, mut amount: Value, optional_args: &[Value]) -> impl ::std::future::Future<Output = Value> + Send { async move {
let mut price = get_arg(optional_args, 0, Value::Null);
let mut triggerPrice = get_arg(optional_args, 1, Value::Null);
let mut params = get_arg(optional_args, 2, Value::Map({
let mut m = indexmap::IndexMap::new();
m
}));
/*
* @method
* @name createTriggerOrderWs
* @description create a trigger stop order (type 1)
* @param {string} symbol unified symbol of the market to create an order in
* @param {string} type 'market' or 'limit'
* @param {string} side 'buy' or 'sell'
* @param {float} amount how much you want to trade in units of the base currency or the number of contracts
* @param {float} [price] the price to fulfill the order, in units of the quote currency, ignored in market orders
* @param {float} triggerPrice the price to trigger the stop order, 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}
*/
if is_equal(&triggerPrice, &Value::Null) {
panic!("{}", crate::exchange_errors::arguments_required(add(&self.id, &Value::Str(" createTriggerOrderWs() requires a triggerPrice argument".to_string()))));
}
params = self.extend(params.clone(), &[Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("triggerPrice".to_string(), triggerPrice.clone());
m
})]);
if !is_equal(&get_value(&self.has, &Value::Str("createTriggerOrderWs".to_string())), &Value::Null) && !is_equal(&get_value(&self.has, &Value::Str("createTriggerOrderWs".to_string())), &Value::Bool(false)) {
return self.create_order_ws(symbol.clone(), type_var.clone(), side.clone(), amount.clone(), &[price.clone(), params.clone()]).await;
}
panic!("{}", crate::exchange_errors::not_supported(add(&self.id, &Value::Str(" createTriggerOrderWs() is not supported yet".to_string()))));
Value::Null
} }
fn edit_order_ws(&mut self, mut id: Value, mut symbol: Value, mut type_var: Value, mut side: Value, optional_args: &[Value]) -> impl ::std::future::Future<Output = Value> + Send { async move {
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
}));
self.cancel_order_ws(id.clone(), &[symbol.clone()]).await;
return self.create_order_ws(symbol.clone(), type_var.clone(), side.clone(), amount.clone(), &[price.clone(), params.clone()]).await;
Value::Null
} }
fn fetch_closed_orders_ws(&mut self, optional_args: &[Value]) -> impl ::std::future::Future<Output = Value> + Send { async move {
let mut symbol = get_arg(optional_args, 0, Value::Null);
let mut since = get_arg(optional_args, 1, Value::Null);
let mut limit = get_arg(optional_args, 2, Value::Null);
let mut params = get_arg(optional_args, 3, Value::Map({
let mut m = indexmap::IndexMap::new();
m
}));
if !is_equal(&get_value(&self.has, &Value::Str("fetchOrdersWs".to_string())), &Value::Null) && !is_equal(&get_value(&self.has, &Value::Str("fetchOrdersWs".to_string())), &Value::Bool(false)) {
let mut orders: Value = self.fetch_orders_ws(&[symbol.clone(), since.clone(), limit.clone(), params.clone()]).await;
return self.filter_by(orders.clone(), Value::Str("status".to_string()), Value::Str("closed".to_string()), &[]);
}
panic!("{}", crate::exchange_errors::not_supported(add(&self.id, &Value::Str(" fetchClosedOrdersWs() is not supported yet".to_string()))));
Value::Null
} }
fn fetch_my_trades_ws(&mut self, optional_args: &[Value]) -> impl ::std::future::Future<Output = Value> + Send { async move {
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
}));
panic!("{}", crate::exchange_errors::not_supported(add(&self.id, &Value::Str(" fetchMyTradesWs() is not supported yet".to_string()))));
Value::Null
} }
fn fetch_open_orders_ws(&mut self, optional_args: &[Value]) -> impl ::std::future::Future<Output = Value> + Send { async move {
let mut symbol = get_arg(optional_args, 0, Value::Null);
let mut since = get_arg(optional_args, 1, Value::Null);
let mut limit = get_arg(optional_args, 2, Value::Null);
let mut params = get_arg(optional_args, 3, Value::Map({
let mut m = indexmap::IndexMap::new();
m
}));
if !is_equal(&get_value(&self.has, &Value::Str("fetchOrdersWs".to_string())), &Value::Null) && !is_equal(&get_value(&self.has, &Value::Str("fetchOrdersWs".to_string())), &Value::Bool(false)) {
let mut orders: Value = self.fetch_orders_ws(&[symbol.clone(), since.clone(), limit.clone(), params.clone()]).await;
return self.filter_by(orders.clone(), Value::Str("status".to_string()), Value::Str("open".to_string()), &[]);
}
panic!("{}", crate::exchange_errors::not_supported(add(&self.id, &Value::Str(" fetchOpenOrdersWs() is not supported yet".to_string()))));
Value::Null
} }
fn fetch_order_book_ws(&mut self, mut symbol: Value, optional_args: &[Value]) -> impl ::std::future::Future<Output = Value> + Send { async move {
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
}));
panic!("{}", crate::exchange_errors::not_supported(add(&self.id, &Value::Str(" fetchOrderBookWs() is not supported yet".to_string()))));
Value::Null
} }
fn fetch_order_ws(&mut self, mut id: Value, optional_args: &[Value]) -> impl ::std::future::Future<Output = Value> + Send { async move {
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
}));
panic!("{}", crate::exchange_errors::not_supported(add(&self.id, &Value::Str(" fetchOrderWs() is not supported yet".to_string()))));
Value::Null
} }
fn fetch_orders_ws(&mut self, optional_args: &[Value]) -> impl ::std::future::Future<Output = Value> + Send { async move {
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
}));
panic!("{}", crate::exchange_errors::not_supported(add(&self.id, &Value::Str(" fetchOrdersWs() is not supported yet".to_string()))));
Value::Null
} }
fn fetch_position_ws(&mut self, mut symbol: Value, optional_args: &[Value]) -> impl ::std::future::Future<Output = Value> + Send { async move {
let mut params = get_arg(optional_args, 0, Value::Map({
let mut m = indexmap::IndexMap::new();
m
}));
panic!("{}", crate::exchange_errors::not_supported(add(&self.id, &Value::Str(" fetchPositionWs() is not supported yet".to_string()))));
Value::Null
} }
fn fetch_positions_ws(&mut self, optional_args: &[Value]) -> impl ::std::future::Future<Output = Value> + Send { async move {
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
}));
panic!("{}", crate::exchange_errors::not_supported(add(&self.id, &Value::Str(" fetchPositions() is not supported yet".to_string()))));
Value::Null
} }
fn fetch_ticker_ws(&mut self, mut symbol: Value, optional_args: &[Value]) -> impl ::std::future::Future<Output = Value> + Send { async move {
let mut params = get_arg(optional_args, 0, Value::Map({
let mut m = indexmap::IndexMap::new();
m
}));
if !is_equal(&get_value(&self.has, &Value::Str("fetchTickersWs".to_string())), &Value::Null) && !is_equal(&get_value(&self.has, &Value::Str("fetchTickersWs".to_string())), &Value::Bool(false)) {
self.load_markets(&[]).await;
let mut market: Value = self.market(symbol.clone());
symbol = get_value(&market, &Value::Str("symbol".to_string()));
let mut tickers: Value = self.fetch_tickers_ws(&[Value::List(vec![symbol.clone()]), params.clone()]).await;
let mut ticker: Value = self.safe_dict(tickers.clone(), symbol.clone(), &[]);
if is_equal(&ticker, &Value::Null) {
panic!("{}", crate::exchange_errors::null_response(add(&add(&self.id, &Value::Str(" fetchTickerWs() could not find a ticker for ".to_string())), &symbol)));
} else {
return ticker;
}
} else {
panic!("{}", crate::exchange_errors::not_supported(add(&self.id, &Value::Str(" fetchTickerWs() is not supported yet".to_string()))));
}
Value::Null
} }
fn fetch_tickers_ws(&mut self, optional_args: &[Value]) -> impl ::std::future::Future<Output = Value> + Send { async move {
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
}));
panic!("{}", crate::exchange_errors::not_supported(add(&self.id, &Value::Str(" fetchTickersWs() is not supported yet".to_string()))));
Value::Null
} }
fn fetch_trades_ws(&mut self, mut symbol: Value, optional_args: &[Value]) -> impl ::std::future::Future<Output = Value> + Send { async move {
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
}));
panic!("{}", crate::exchange_errors::not_supported(add(&self.id, &Value::Str(" fetchTradesWs() is not supported yet".to_string()))));
Value::Null
} }
fn fetch_trades(&mut self, mut symbol: Value, optional_args: &[Value]) -> impl ::std::future::Future<Output = Value> + Send { async move {
// async-virtual: try the derived exchange first
if let Some(__v) = self.dispatch_to_derived("fetch_trades", { let mut __args: Vec<crate::Value> = Vec::new(); __args.push(symbol.clone()); __args.extend_from_slice(optional_args); __args }).await {
if !matches!(__v, crate::Value::Null) { return __v; }
}
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
}));
panic!("{}", crate::exchange_errors::not_supported(add(&self.id, &Value::Str(" fetchTrades() is not supported yet".to_string()))));
Value::Null
} }
fn watch_trades(&mut self, mut symbol: Value, optional_args: &[Value]) -> impl ::std::future::Future<Output = Value> + Send { async move {
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
}));
panic!("{}", crate::exchange_errors::not_supported(add(&self.id, &Value::Str(" watchTrades() is not supported yet".to_string()))));
Value::Null
} }
fn fetch_order_book(&mut self, mut symbol: Value, optional_args: &[Value]) -> impl ::std::future::Future<Output = Value> + Send { async move {
// async-virtual: try the derived exchange first
if let Some(__v) = self.dispatch_to_derived("fetch_order_book", { let mut __args: Vec<crate::Value> = Vec::new(); __args.push(symbol.clone()); __args.extend_from_slice(optional_args); __args }).await {
if !matches!(__v, crate::Value::Null) { return __v; }
}
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
}));
panic!("{}", crate::exchange_errors::not_supported(add(&self.id, &Value::Str(" fetchOrderBook() is not supported yet".to_string()))));
Value::Null
} }
fn fetch_rest_order_book_safe(&mut self, mut symbol: Value, optional_args: &[Value]) -> impl ::std::future::Future<Output = Value> + Send { async move {
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
}));
let mut fetchSnapshotMaxRetries: Value = self.handle_option(Value::Str("watchOrderBook".to_string()), Value::Str("maxRetries".to_string()), &[Value::Int(3)]);
{
let mut i: Value = Value::Int(0);
let mut __for_first_179: bool = true;
while { if !__for_first_179 { i = add(&i, &Value::Int(1)); } __for_first_179 = false; is_less_than(&i, &fetchSnapshotMaxRetries) } {
let _try_result = futures::FutureExt::catch_unwind(std::panic::AssertUnwindSafe(async {
let mut orderBook: Value = self.fetch_order_book(symbol.clone(), &[limit.clone(), params.clone()]).await;
return orderBook.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 e: Value = panic_to_value(_try_err);
if is_equal(&(add(&i, &Value::Int(1))), &fetchSnapshotMaxRetries) {
panic!("{}", e);
}
} }
}
}
return Value::Null;
Value::Null
} }
fn watch_order_book(&mut self, mut symbol: Value, optional_args: &[Value]) -> impl ::std::future::Future<Output = Value> + Send { async move {
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
}));
panic!("{}", crate::exchange_errors::not_supported(add(&self.id, &Value::Str(" watchOrderBook() is not supported yet".to_string()))));
Value::Null
} }
fn fetch_open_interest(&mut self, mut symbol: Value, optional_args: &[Value]) -> impl ::std::future::Future<Output = Value> + Send { async move {
// async-virtual: try the derived exchange first
if let Some(__v) = self.dispatch_to_derived("fetch_open_interest", { let mut __args: Vec<crate::Value> = Vec::new(); __args.push(symbol.clone()); __args.extend_from_slice(optional_args); __args }).await {
if !matches!(__v, crate::Value::Null) { return __v; }
}
let mut params = get_arg(optional_args, 0, Value::Map({
let mut m = indexmap::IndexMap::new();
m
}));
if !is_equal(&get_value(&self.has, &Value::Str("fetchOpenInterests".to_string())), &Value::Null) && !is_equal(&get_value(&self.has, &Value::Str("fetchOpenInterests".to_string())), &Value::Bool(false)) {
let mut openInterests: Value = self.fetch_open_interests(&[Value::List(vec![symbol.clone()]), params.clone()]).await;
return self.safe_dict(openInterests.clone(), symbol.clone(), &[]);
} else {
panic!("{}", crate::exchange_errors::not_supported(add(&self.id, &Value::Str(" fetchOpenInterest() is not supported yet".to_string()))));
}
Value::Null
} }
fn fetch_l2_order_book(&mut self, mut symbol: Value, optional_args: &[Value]) -> impl ::std::future::Future<Output = Value> + Send { async move {
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
}));
let mut orderbook: Value = self.fetch_order_book(symbol.clone(), &[limit.clone(), params.clone()]).await;
return self.extend(orderbook.clone(), &[Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("asks".to_string(), self.sort_by(self.aggregate(get_value(&orderbook, &Value::Str("asks".to_string()))), Value::Int(0), &[]));
m.insert("bids".to_string(), self.sort_by(self.aggregate(get_value(&orderbook, &Value::Str("bids".to_string()))), Value::Int(0), &[Value::Bool(true)]));
m
})]);
Value::Null
} }
fn edit_limit_buy_order(&mut self, mut id: Value, mut symbol: Value, mut amount: Value, optional_args: &[Value]) -> impl ::std::future::Future<Output = Value> + Send { async move {
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
}));
return self.edit_limit_order(id.clone(), symbol.clone(), Value::Str("buy".to_string()), amount.clone(), &[price.clone(), params.clone()]).await;
Value::Null
} }
fn edit_limit_sell_order(&mut self, mut id: Value, mut symbol: Value, mut amount: Value, optional_args: &[Value]) -> impl ::std::future::Future<Output = Value> + Send { async move {
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
}));
return self.edit_limit_order(id.clone(), symbol.clone(), Value::Str("sell".to_string()), amount.clone(), &[price.clone(), params.clone()]).await;
Value::Null
} }
fn edit_limit_order(&mut self, mut id: Value, mut symbol: Value, mut side: Value, mut amount: Value, optional_args: &[Value]) -> impl ::std::future::Future<Output = Value> + Send { async move {
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
}));
return self.edit_order(id.clone(), symbol.clone(), Value::Str("limit".to_string()), side.clone(), &[amount.clone(), price.clone(), params.clone()]).await;
Value::Null
} }
fn edit_order(&mut self, mut id: Value, mut symbol: Value, mut type_var: Value, mut side: Value, optional_args: &[Value]) -> impl ::std::future::Future<Output = Value> + Send { async move {
// async-virtual: try the derived exchange first
if let Some(__v) = self.dispatch_to_derived("edit_order", { let mut __args: Vec<crate::Value> = Vec::new(); __args.push(id.clone()); __args.push(symbol.clone()); __args.push(type_var.clone()); __args.push(side.clone()); __args.extend_from_slice(optional_args); __args }).await {
if !matches!(__v, crate::Value::Null) { return __v; }
}
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
}));
self.cancel_order(id.clone(), &[symbol.clone()]).await;
return self.create_order(symbol.clone(), type_var.clone(), side.clone(), amount.clone(), &[price.clone(), params.clone()]).await;
Value::Null
} }
fn edit_order_with_client_order_id(&mut self, mut clientOrderId: Value, mut symbol: Value, mut type_var: Value, mut side: Value, optional_args: &[Value]) -> impl ::std::future::Future<Output = Value> + Send { async move {
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
}));
let mut extendedParams: Value = self.extend(params.clone(), &[Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("clientOrderId".to_string(), clientOrderId.clone());
m
})]);
return self.edit_order(Value::Str("".to_string()), symbol.clone(), type_var.clone(), side.clone(), &[amount.clone(), price.clone(), extendedParams.clone()]).await;
Value::Null
} }
fn fetch_position(&mut self, mut symbol: Value, optional_args: &[Value]) -> impl ::std::future::Future<Output = Value> + Send { async move {
// async-virtual: try the derived exchange first
if let Some(__v) = self.dispatch_to_derived("fetch_position", { let mut __args: Vec<crate::Value> = Vec::new(); __args.push(symbol.clone()); __args.extend_from_slice(optional_args); __args }).await {
if !matches!(__v, crate::Value::Null) { return __v; }
}
let mut params = get_arg(optional_args, 0, Value::Map({
let mut m = indexmap::IndexMap::new();
m
}));
panic!("{}", crate::exchange_errors::not_supported(add(&self.id, &Value::Str(" fetchPosition() is not supported yet".to_string()))));
Value::Null
} }
fn watch_positions(&mut self, optional_args: &[Value]) -> impl ::std::future::Future<Output = Value> + Send { async move {
let mut symbols = get_arg(optional_args, 0, Value::Null);
let mut since = get_arg(optional_args, 1, Value::Null);
let mut limit = get_arg(optional_args, 2, Value::Null);
let mut params = get_arg(optional_args, 3, Value::Map({
let mut m = indexmap::IndexMap::new();
m
}));
panic!("{}", crate::exchange_errors::not_supported(add(&self.id, &Value::Str(" watchPositions() is not supported yet".to_string()))));
Value::Null
} }
fn watch_position_for_symbols(&mut self, optional_args: &[Value]) -> impl ::std::future::Future<Output = Value> + Send { async move {
let mut symbols = get_arg(optional_args, 0, Value::Null);
let mut since = get_arg(optional_args, 1, Value::Null);
let mut limit = get_arg(optional_args, 2, Value::Null);
let mut params = get_arg(optional_args, 3, Value::Map({
let mut m = indexmap::IndexMap::new();
m
}));
return self.watch_positions(&[symbols.clone(), since.clone(), limit.clone(), params.clone()]).await;
Value::Null
} }
fn fetch_positions(&mut self, optional_args: &[Value]) -> impl ::std::future::Future<Output = Value> + Send { async move {
// async-virtual: try the derived exchange first
if let Some(__v) = self.dispatch_to_derived("fetch_positions", { let mut __args: Vec<crate::Value> = Vec::new(); __args.extend_from_slice(optional_args); __args }).await {
if !matches!(__v, crate::Value::Null) { return __v; }
}
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
}));
panic!("{}", crate::exchange_errors::not_supported(add(&self.id, &Value::Str(" fetchPositions() is not supported yet".to_string()))));
Value::Null
} }
fn fetch_ticker(&mut self, mut symbol: Value, optional_args: &[Value]) -> impl ::std::future::Future<Output = Value> + Send { async move {
// async-virtual: try the derived exchange first
if let Some(__v) = self.dispatch_to_derived("fetch_ticker", { let mut __args: Vec<crate::Value> = Vec::new(); __args.push(symbol.clone()); __args.extend_from_slice(optional_args); __args }).await {
if !matches!(__v, crate::Value::Null) { return __v; }
}
let mut params = get_arg(optional_args, 0, Value::Map({
let mut m = indexmap::IndexMap::new();
m
}));
if !is_equal(&get_value(&self.has, &Value::Str("fetchTickers".to_string())), &Value::Null) && !is_equal(&get_value(&self.has, &Value::Str("fetchTickers".to_string())), &Value::Bool(false)) {
self.load_markets(&[]).await;
let mut market: Value = self.market(symbol.clone());
symbol = get_value(&market, &Value::Str("symbol".to_string()));
let mut tickers: Value = self.fetch_tickers(&[Value::List(vec![symbol.clone()]), params.clone()]).await;
let mut ticker: Value = self.safe_dict(tickers.clone(), symbol.clone(), &[]);
if is_equal(&ticker, &Value::Null) {
panic!("{}", crate::exchange_errors::null_response(add(&add(&self.id, &Value::Str(" fetchTickers() could not find a ticker for ".to_string())), &symbol)));
} else {
return ticker;
}
} else {
panic!("{}", crate::exchange_errors::not_supported(add(&self.id, &Value::Str(" fetchTicker() is not supported yet".to_string()))));
}
Value::Null
} }
fn watch_ticker(&mut self, mut symbol: Value, optional_args: &[Value]) -> impl ::std::future::Future<Output = Value> + Send { async move {
let mut params = get_arg(optional_args, 0, Value::Map({
let mut m = indexmap::IndexMap::new();
m
}));
panic!("{}", crate::exchange_errors::not_supported(add(&self.id, &Value::Str(" watchTicker() is not supported yet".to_string()))));
Value::Null
} }
fn fetch_tickers(&mut self, optional_args: &[Value]) -> impl ::std::future::Future<Output = Value> + Send { async move {
// async-virtual: try the derived exchange first
if let Some(__v) = self.dispatch_to_derived("fetch_tickers", { let mut __args: Vec<crate::Value> = Vec::new(); __args.extend_from_slice(optional_args); __args }).await {
if !matches!(__v, crate::Value::Null) { return __v; }
}
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
}));
panic!("{}", crate::exchange_errors::not_supported(add(&self.id, &Value::Str(" fetchTickers() is not supported yet".to_string()))));
Value::Null
} }
fn watch_tickers(&mut self, optional_args: &[Value]) -> impl ::std::future::Future<Output = Value> + Send { async move {
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
}));
panic!("{}", crate::exchange_errors::not_supported(add(&self.id, &Value::Str(" watchTickers() is not supported yet".to_string()))));
Value::Null
} }
fn fetch_order(&mut self, mut id: Value, optional_args: &[Value]) -> impl ::std::future::Future<Output = Value> + Send { async move {
// async-virtual: try the derived exchange first
if let Some(__v) = self.dispatch_to_derived("fetch_order", { let mut __args: Vec<crate::Value> = Vec::new(); __args.push(id.clone()); __args.extend_from_slice(optional_args); __args }).await {
if !matches!(__v, crate::Value::Null) { return __v; }
}
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
}));
panic!("{}", crate::exchange_errors::not_supported(add(&self.id, &Value::Str(" fetchOrder() is not supported yet".to_string()))));
Value::Null
} }
/*
* @method
* @name fetchOrderWithClientOrderId
* @description create a market order by providing the symbol, side and cost
* @param {string} clientOrderId client order Id
* @param {string} symbol unified symbol of the market to create an order 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}
*/
fn fetch_order_with_client_order_id(&mut self, mut clientOrderId: Value, optional_args: &[Value]) -> impl ::std::future::Future<Output = Value> + Send { async move {
let mut symbol = get_arg(optional_args, 0, Value::Null);
let mut params = get_arg(optional_args, 1, Value::Map({
let mut m = indexmap::IndexMap::new();
m
}));
let mut extendedParams: Value = self.extend(params.clone(), &[Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("clientOrderId".to_string(), clientOrderId.clone());
m
})]);
return self.fetch_order(Value::Str("".to_string()), &[symbol.clone(), extendedParams.clone()]).await;
Value::Null
} }
fn fetch_order_status(&mut self, mut id: Value, optional_args: &[Value]) -> impl ::std::future::Future<Output = Value> + Send { async move {
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
}));
// TODO: TypeScript: change method signature by replacing
// Promise<string> with Promise<Order['status']>.
let mut order: Value = self.fetch_order(id.clone(), &[symbol.clone(), params.clone()]).await;
return get_value(&order, &Value::Str("status".to_string()));
Value::Null
} }
fn fetch_unified_order(&mut self, mut order: Value, optional_args: &[Value]) -> impl ::std::future::Future<Output = Value> + Send { async move {
let mut params = get_arg(optional_args, 0, Value::Map({
let mut m = indexmap::IndexMap::new();
m
}));
return self.fetch_order(self.safe_string_k(order.clone(), "id", &[]), &[self.safe_string_k(order.clone(), "symbol", &[]), params.clone()]).await;
Value::Null
} }
fn create_order(&mut self, mut symbol: Value, mut type_var: Value, mut side: Value, mut amount: Value, optional_args: &[Value]) -> impl ::std::future::Future<Output = Value> + Send { async move {
// async-virtual: try the derived exchange first
if let Some(__v) = self.dispatch_to_derived("create_order", { let mut __args: Vec<crate::Value> = Vec::new(); __args.push(symbol.clone()); __args.push(type_var.clone()); __args.push(side.clone()); __args.push(amount.clone()); __args.extend_from_slice(optional_args); __args }).await {
if !matches!(__v, crate::Value::Null) { return __v; }
}
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
}));
panic!("{}", crate::exchange_errors::not_supported(add(&self.id, &Value::Str(" createOrder() is not supported yet".to_string()))));
Value::Null
} }
fn create_trailing_amount_order(&mut self, mut symbol: Value, mut type_var: Value, mut side: Value, mut amount: Value, optional_args: &[Value]) -> impl ::std::future::Future<Output = Value> + Send { async move {
let mut price = get_arg(optional_args, 0, Value::Null);
let mut trailingAmount = get_arg(optional_args, 1, Value::Null);
let mut trailingTriggerPrice = get_arg(optional_args, 2, Value::Null);
let mut params = get_arg(optional_args, 3, Value::Map({
let mut m = indexmap::IndexMap::new();
m
}));
/*
* @method
* @name createTrailingAmountOrder
* @description create a trailing order by providing the symbol, type, side, amount, price and trailingAmount
* @param {string} symbol unified symbol of the market to create an order in
* @param {string} type 'market' or 'limit'
* @param {string} side 'buy' or 'sell'
* @param {float} amount how much you want to trade in units of the base currency, or number of contracts
* @param {float} [price] the price for the order to be filled at, in units of the quote currency, ignored in market orders
* @param {float} trailingAmount the quote amount to trail away from the current market price
* @param {float} [trailingTriggerPrice] the price to activate a trailing order, default uses the price argument
* @param {object} [params] extra parameters specific to the exchange API endpoint
* @returns {object} an [order structure]{@link https://docs.ccxt.com/?id=order-structure}
*/
if is_equal(&trailingAmount, &Value::Null) {
panic!("{}", crate::exchange_errors::arguments_required(add(&self.id, &Value::Str(" createTrailingAmountOrder() requires a trailingAmount argument".to_string()))));
}
add_element_to_object(&mut params, &Value::Str("trailingAmount".to_string()), trailingAmount.clone());
if !is_equal(&trailingTriggerPrice, &Value::Null) {
add_element_to_object(&mut params, &Value::Str("trailingTriggerPrice".to_string()), trailingTriggerPrice.clone());
}
if !is_equal(&get_value(&self.has, &Value::Str("createTrailingAmountOrder".to_string())), &Value::Null) && !is_equal(&get_value(&self.has, &Value::Str("createTrailingAmountOrder".to_string())), &Value::Bool(false)) {
return self.create_order(symbol.clone(), type_var.clone(), side.clone(), amount.clone(), &[price.clone(), params.clone()]).await;
}
panic!("{}", crate::exchange_errors::not_supported(add(&self.id, &Value::Str(" createTrailingAmountOrder() is not supported yet".to_string()))));
Value::Null
} }
fn create_trailing_percent_order(&mut self, mut symbol: Value, mut type_var: Value, mut side: Value, mut amount: Value, optional_args: &[Value]) -> impl ::std::future::Future<Output = Value> + Send { async move {
let mut price = get_arg(optional_args, 0, Value::Null);
let mut trailingPercent = get_arg(optional_args, 1, Value::Null);
let mut trailingTriggerPrice = get_arg(optional_args, 2, Value::Null);
let mut params = get_arg(optional_args, 3, Value::Map({
let mut m = indexmap::IndexMap::new();
m
}));
/*
* @method
* @name createTrailingPercentOrder
* @description create a trailing order by providing the symbol, type, side, amount, price and trailingPercent
* @param {string} symbol unified symbol of the market to create an order in
* @param {string} type 'market' or 'limit'
* @param {string} side 'buy' or 'sell'
* @param {float} amount how much you want to trade in units of the base currency, or number of contracts
* @param {float} [price] the price for the order to be filled at, in units of the quote currency, ignored in market orders
* @param {float} trailingPercent the percent to trail away from the current market price
* @param {float} [trailingTriggerPrice] the price to activate a trailing order, default uses the price argument
* @param {object} [params] extra parameters specific to the exchange API endpoint
* @returns {object} an [order structure]{@link https://docs.ccxt.com/?id=order-structure}
*/
if is_equal(&trailingPercent, &Value::Null) {
panic!("{}", crate::exchange_errors::arguments_required(add(&self.id, &Value::Str(" createTrailingPercentOrder() requires a trailingPercent argument".to_string()))));
}
add_element_to_object(&mut params, &Value::Str("trailingPercent".to_string()), trailingPercent.clone());
if !is_equal(&trailingTriggerPrice, &Value::Null) {
add_element_to_object(&mut params, &Value::Str("trailingTriggerPrice".to_string()), trailingTriggerPrice.clone());
}
if !is_equal(&get_value(&self.has, &Value::Str("createTrailingPercentOrder".to_string())), &Value::Null) && !is_equal(&get_value(&self.has, &Value::Str("createTrailingPercentOrder".to_string())), &Value::Bool(false)) {
return self.create_order(symbol.clone(), type_var.clone(), side.clone(), amount.clone(), &[price.clone(), params.clone()]).await;
}
panic!("{}", crate::exchange_errors::not_supported(add(&self.id, &Value::Str(" createTrailingPercentOrder() is not supported yet".to_string()))));
Value::Null
} }
fn create_market_order_with_cost(&mut self, mut symbol: Value, mut side: Value, mut cost: Value, optional_args: &[Value]) -> impl ::std::future::Future<Output = Value> + Send { async move {
let mut params = get_arg(optional_args, 0, Value::Map({
let mut m = indexmap::IndexMap::new();
m
}));
/*
* @method
* @name 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}
*/
if is_true(&(!is_equal(&get_value(&self.has, &Value::Str("createMarketOrderWithCost".to_string())), &Value::Null) && !is_equal(&get_value(&self.has, &Value::Str("createMarketOrderWithCost".to_string())), &Value::Bool(false)))) || is_true(&(is_true(&(!is_equal(&get_value(&self.has, &Value::Str("createMarketBuyOrderWithCost".to_string())), &Value::Null) && !is_equal(&get_value(&self.has, &Value::Str("createMarketBuyOrderWithCost".to_string())), &Value::Bool(false)))) && is_true(&(!is_equal(&get_value(&self.has, &Value::Str("createMarketSellOrderWithCost".to_string())), &Value::Null) && !is_equal(&get_value(&self.has, &Value::Str("createMarketSellOrderWithCost".to_string())), &Value::Bool(false)))))) {
return self.create_order(symbol.clone(), Value::Str("market".to_string()), side.clone(), cost.clone(), &[Value::Int(1), params.clone()]).await;
}
panic!("{}", crate::exchange_errors::not_supported(add(&self.id, &Value::Str(" createMarketOrderWithCost() is not supported yet".to_string()))));
Value::Null
} }
fn create_market_buy_order_with_cost(&mut self, mut symbol: Value, mut cost: Value, optional_args: &[Value]) -> impl ::std::future::Future<Output = Value> + Send { async move {
let mut params = get_arg(optional_args, 0, Value::Map({
let mut m = indexmap::IndexMap::new();
m
}));
/*
* @method
* @name 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}
*/
if is_true(&(is_equal(&get_value(&self.options, &Value::Str("createMarketBuyOrderRequiresPrice".to_string())), &Value::Bool(true)))) || is_true(&(!is_equal(&get_value(&self.has, &Value::Str("createMarketBuyOrderWithCost".to_string())), &Value::Null) && !is_equal(&get_value(&self.has, &Value::Str("createMarketBuyOrderWithCost".to_string())), &Value::Bool(false)))) {
return self.create_order(symbol.clone(), Value::Str("market".to_string()), Value::Str("buy".to_string()), cost.clone(), &[Value::Int(1), params.clone()]).await;
}
panic!("{}", crate::exchange_errors::not_supported(add(&self.id, &Value::Str(" createMarketBuyOrderWithCost() is not supported yet".to_string()))));
Value::Null
} }
fn create_market_sell_order_with_cost(&mut self, mut symbol: Value, mut cost: Value, optional_args: &[Value]) -> impl ::std::future::Future<Output = Value> + Send { async move {
let mut params = get_arg(optional_args, 0, Value::Map({
let mut m = indexmap::IndexMap::new();
m
}));
/*
* @method
* @name createMarketSellOrderWithCost
* @description create a market sell 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}
*/
if is_true(&(is_equal(&get_value(&self.options, &Value::Str("createMarketSellOrderRequiresPrice".to_string())), &Value::Bool(true)))) || is_true(&(!is_equal(&get_value(&self.has, &Value::Str("createMarketSellOrderWithCost".to_string())), &Value::Null) && !is_equal(&get_value(&self.has, &Value::Str("createMarketSellOrderWithCost".to_string())), &Value::Bool(false)))) {
return self.create_order(symbol.clone(), Value::Str("market".to_string()), Value::Str("sell".to_string()), cost.clone(), &[Value::Int(1), params.clone()]).await;
}
panic!("{}", crate::exchange_errors::not_supported(add(&self.id, &Value::Str(" createMarketSellOrderWithCost() is not supported yet".to_string()))));
Value::Null
} }
fn create_trigger_order(&mut self, mut symbol: Value, mut type_var: Value, mut side: Value, mut amount: Value, optional_args: &[Value]) -> impl ::std::future::Future<Output = Value> + Send { async move {
let mut price = get_arg(optional_args, 0, Value::Null);
let mut triggerPrice = get_arg(optional_args, 1, Value::Null);
let mut params = get_arg(optional_args, 2, Value::Map({
let mut m = indexmap::IndexMap::new();
m
}));
/*
* @method
* @name createTriggerOrder
* @description create a trigger stop order (type 1)
* @param {string} symbol unified symbol of the market to create an order in
* @param {string} type 'market' or 'limit'
* @param {string} side 'buy' or 'sell'
* @param {float} amount how much you want to trade in units of the base currency or the number of contracts
* @param {float} [price] the price to fulfill the order, in units of the quote currency, ignored in market orders
* @param {float} triggerPrice the price to trigger the stop order, 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}
*/
if is_equal(&triggerPrice, &Value::Null) {
panic!("{}", crate::exchange_errors::arguments_required(add(&self.id, &Value::Str(" createTriggerOrder() requires a triggerPrice argument".to_string()))));
}
params = self.extend(params.clone(), &[Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("triggerPrice".to_string(), triggerPrice.clone());
m
})]);
if !is_equal(&get_value(&self.has, &Value::Str("createTriggerOrder".to_string())), &Value::Null) && !is_equal(&get_value(&self.has, &Value::Str("createTriggerOrder".to_string())), &Value::Bool(false)) {
return self.create_order(symbol.clone(), type_var.clone(), side.clone(), amount.clone(), &[price.clone(), params.clone()]).await;
}
panic!("{}", crate::exchange_errors::not_supported(add(&self.id, &Value::Str(" createTriggerOrder() is not supported yet".to_string()))));
Value::Null
} }
fn create_stop_loss_order(&mut self, mut symbol: Value, mut type_var: Value, mut side: Value, mut amount: Value, optional_args: &[Value]) -> impl ::std::future::Future<Output = Value> + Send { async move {
let mut price = get_arg(optional_args, 0, Value::Null);
let mut stopLossPrice = get_arg(optional_args, 1, Value::Null);
let mut params = get_arg(optional_args, 2, Value::Map({
let mut m = indexmap::IndexMap::new();
m
}));
/*
* @method
* @name createStopLossOrder
* @description create a trigger stop loss order (type 2)
* @param {string} symbol unified symbol of the market to create an order in
* @param {string} type 'market' or 'limit'
* @param {string} side 'buy' or 'sell'
* @param {float} amount how much you want to trade in units of the base currency or the number of contracts
* @param {float} [price] the price to fulfill the order, in units of the quote currency, ignored in market orders
* @param {float} stopLossPrice the price to trigger the stop loss order, 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}
*/
if is_equal(&stopLossPrice, &Value::Null) {
panic!("{}", crate::exchange_errors::arguments_required(add(&self.id, &Value::Str(" createStopLossOrder() requires a stopLossPrice argument".to_string()))));
}
params = self.extend(params.clone(), &[Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("stopLossPrice".to_string(), stopLossPrice.clone());
m
})]);
if !is_equal(&get_value(&self.has, &Value::Str("createStopLossOrder".to_string())), &Value::Null) && !is_equal(&get_value(&self.has, &Value::Str("createStopLossOrder".to_string())), &Value::Bool(false)) {
return self.create_order(symbol.clone(), type_var.clone(), side.clone(), amount.clone(), &[price.clone(), params.clone()]).await;
}
panic!("{}", crate::exchange_errors::not_supported(add(&self.id, &Value::Str(" createStopLossOrder() is not supported yet".to_string()))));
Value::Null
} }
fn create_take_profit_order(&mut self, mut symbol: Value, mut type_var: Value, mut side: Value, mut amount: Value, optional_args: &[Value]) -> impl ::std::future::Future<Output = Value> + Send { async move {
let mut price = get_arg(optional_args, 0, Value::Null);
let mut takeProfitPrice = get_arg(optional_args, 1, Value::Null);
let mut params = get_arg(optional_args, 2, Value::Map({
let mut m = indexmap::IndexMap::new();
m
}));
/*
* @method
* @name createTakeProfitOrder
* @description create a trigger take profit order (type 2)
* @param {string} symbol unified symbol of the market to create an order in
* @param {string} type 'market' or 'limit'
* @param {string} side 'buy' or 'sell'
* @param {float} amount how much you want to trade in units of the base currency or the number of contracts
* @param {float} [price] the price to fulfill the order, in units of the quote currency, ignored in market orders
* @param {float} takeProfitPrice the price to trigger the take profit order, 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}
*/
if is_equal(&takeProfitPrice, &Value::Null) {
panic!("{}", crate::exchange_errors::arguments_required(add(&self.id, &Value::Str(" createTakeProfitOrder() requires a takeProfitPrice argument".to_string()))));
}
params = self.extend(params.clone(), &[Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("takeProfitPrice".to_string(), takeProfitPrice.clone());
m
})]);
if !is_equal(&get_value(&self.has, &Value::Str("createTakeProfitOrder".to_string())), &Value::Null) && !is_equal(&get_value(&self.has, &Value::Str("createTakeProfitOrder".to_string())), &Value::Bool(false)) {
return self.create_order(symbol.clone(), type_var.clone(), side.clone(), amount.clone(), &[price.clone(), params.clone()]).await;
}
panic!("{}", crate::exchange_errors::not_supported(add(&self.id, &Value::Str(" createTakeProfitOrder() is not supported yet".to_string()))));
Value::Null
} }
fn create_order_with_take_profit_and_stop_loss(&mut self, mut symbol: Value, mut type_var: Value, mut side: Value, mut amount: Value, optional_args: &[Value]) -> impl ::std::future::Future<Output = Value> + Send { async move {
let mut price = get_arg(optional_args, 0, Value::Null);
let mut takeProfit = get_arg(optional_args, 1, Value::Null);
let mut stopLoss = get_arg(optional_args, 2, Value::Null);
let mut params = get_arg(optional_args, 3, Value::Map({
let mut m = indexmap::IndexMap::new();
m
}));
/*
* @method
* @name createOrderWithTakeProfitAndStopLoss
* @description create an order with a stop loss or take profit attached (type 3)
* @param {string} symbol unified symbol of the market to create an order in
* @param {string} type 'market' or 'limit'
* @param {string} side 'buy' or 'sell'
* @param {float} amount how much you want to trade in units of the base currency or the number of contracts
* @param {float} [price] the price to fulfill the order, in units of the quote currency, ignored in market orders
* @param {float} [takeProfit] the take profit price, in units of the quote currency
* @param {float} [stopLoss] the stop loss price, in units of the quote currency
* @param {object} [params] extra parameters specific to the exchange API endpoint
* @param {string} [params.takeProfitType] *not available on all exchanges* 'limit' or 'market'
* @param {string} [params.stopLossType] *not available on all exchanges* 'limit' or 'market'
* @param {string} [params.takeProfitPriceType] *not available on all exchanges* 'last', 'mark' or 'index'
* @param {string} [params.stopLossPriceType] *not available on all exchanges* 'last', 'mark' or 'index'
* @param {float} [params.takeProfitLimitPrice] *not available on all exchanges* limit price for a limit take profit order
* @param {float} [params.stopLossLimitPrice] *not available on all exchanges* stop loss for a limit stop loss order
* @param {float} [params.takeProfitAmount] *not available on all exchanges* the amount for a take profit
* @param {float} [params.stopLossAmount] *not available on all exchanges* the amount for a stop loss
* @returns {object} an [order structure]{@link https://docs.ccxt.com/?id=order-structure}
*/
params = self.set_take_profit_and_stop_loss_params(symbol.clone(), type_var.clone(), side.clone(), amount.clone(), &[price.clone(), takeProfit.clone(), stopLoss.clone(), params.clone()]);
if !is_equal(&get_value(&self.has, &Value::Str("createOrderWithTakeProfitAndStopLoss".to_string())), &Value::Null) && !is_equal(&get_value(&self.has, &Value::Str("createOrderWithTakeProfitAndStopLoss".to_string())), &Value::Bool(false)) {
return self.create_order(symbol.clone(), type_var.clone(), side.clone(), amount.clone(), &[price.clone(), params.clone()]).await;
}
panic!("{}", crate::exchange_errors::not_supported(add(&self.id, &Value::Str(" createOrderWithTakeProfitAndStopLoss() is not supported yet".to_string()))));
Value::Null
} }
fn create_orders(&mut self, mut orders: Value, optional_args: &[Value]) -> impl ::std::future::Future<Output = Value> + Send { async move {
// async-virtual: try the derived exchange first
if let Some(__v) = self.dispatch_to_derived("create_orders", { let mut __args: Vec<crate::Value> = Vec::new(); __args.push(orders.clone()); __args.extend_from_slice(optional_args); __args }).await {
if !matches!(__v, crate::Value::Null) { return __v; }
}
let mut params = get_arg(optional_args, 0, Value::Map({
let mut m = indexmap::IndexMap::new();
m
}));
panic!("{}", crate::exchange_errors::not_supported(add(&self.id, &Value::Str(" createOrders() is not supported yet".to_string()))));
Value::Null
} }
fn cancel_order(&mut self, mut id: Value, optional_args: &[Value]) -> impl ::std::future::Future<Output = Value> + Send { async move {
// async-virtual: try the derived exchange first
if let Some(__v) = self.dispatch_to_derived("cancel_order", { let mut __args: Vec<crate::Value> = Vec::new(); __args.push(id.clone()); __args.extend_from_slice(optional_args); __args }).await {
if !matches!(__v, crate::Value::Null) { return __v; }
}
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
}));
panic!("{}", crate::exchange_errors::not_supported(add(&self.id, &Value::Str(" cancelOrder() is not supported yet".to_string()))));
Value::Null
} }
/*
* @method
* @name cancelOrderWithClientOrderId
* @description create a market order by providing the symbol, side and cost
* @param {string} clientOrderId client order Id
* @param {string} symbol unified symbol of the market to create an order 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}
*/
fn cancel_order_with_client_order_id(&mut self, mut clientOrderId: Value, optional_args: &[Value]) -> impl ::std::future::Future<Output = Value> + Send { async move {
let mut symbol = get_arg(optional_args, 0, Value::Null);
let mut params = get_arg(optional_args, 1, Value::Map({
let mut m = indexmap::IndexMap::new();
m
}));
let mut extendedParams: Value = self.extend(params.clone(), &[Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("clientOrderId".to_string(), clientOrderId.clone());
m
})]);
return self.cancel_order(Value::Str("".to_string()), &[symbol.clone(), extendedParams.clone()]).await;
Value::Null
} }
fn cancel_orders(&mut self, mut ids: Value, optional_args: &[Value]) -> impl ::std::future::Future<Output = Value> + Send { async move {
// async-virtual: try the derived exchange first
if let Some(__v) = self.dispatch_to_derived("cancel_orders", { let mut __args: Vec<crate::Value> = Vec::new(); __args.push(ids.clone()); __args.extend_from_slice(optional_args); __args }).await {
if !matches!(__v, crate::Value::Null) { return __v; }
}
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
}));
panic!("{}", crate::exchange_errors::not_supported(add(&self.id, &Value::Str(" cancelOrders() is not supported yet".to_string()))));
Value::Null
} }
/*
* @method
* @name cancelOrdersWithClientOrderIds
* @description create a market order by providing the symbol, side and cost
* @param {string[]} clientOrderIds client order Ids
* @param {string} symbol unified symbol of the market to create an order 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}
*/
fn cancel_orders_with_client_order_ids(&mut self, mut clientOrderIds: Value, optional_args: &[Value]) -> impl ::std::future::Future<Output = Value> + Send { async move {
let mut symbol = get_arg(optional_args, 0, Value::Null);
let mut params = get_arg(optional_args, 1, Value::Map({
let mut m = indexmap::IndexMap::new();
m
}));
let mut extendedParams: Value = self.extend(params.clone(), &[Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("clientOrderIds".to_string(), clientOrderIds.clone());
m
})]);
return self.cancel_orders(Value::List(vec![]), &[symbol.clone(), extendedParams.clone()]).await;
Value::Null
} }
fn cancel_all_orders(&mut self, optional_args: &[Value]) -> impl ::std::future::Future<Output = Value> + Send { async move {
// async-virtual: try the derived exchange first
if let Some(__v) = self.dispatch_to_derived("cancel_all_orders", { let mut __args: Vec<crate::Value> = Vec::new(); __args.extend_from_slice(optional_args); __args }).await {
if !matches!(__v, crate::Value::Null) { return __v; }
}
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
}));
panic!("{}", crate::exchange_errors::not_supported(add(&self.id, &Value::Str(" cancelAllOrders() is not supported yet".to_string()))));
Value::Null
} }
fn cancel_unified_order(&mut self, mut order: Value, optional_args: &[Value]) -> impl ::std::future::Future<Output = Value> + Send { async move {
let mut params = get_arg(optional_args, 0, Value::Map({
let mut m = indexmap::IndexMap::new();
m
}));
return self.cancel_order(self.safe_string_k(order.clone(), "id", &[]), &[self.safe_string_k(order.clone(), "symbol", &[]), params.clone()]).await;
Value::Null
} }
fn fetch_orders(&mut self, optional_args: &[Value]) -> impl ::std::future::Future<Output = Value> + Send { async move {
// async-virtual: try the derived exchange first
if let Some(__v) = self.dispatch_to_derived("fetch_orders", { let mut __args: Vec<crate::Value> = Vec::new(); __args.extend_from_slice(optional_args); __args }).await {
if !matches!(__v, crate::Value::Null) { return __v; }
}
let mut symbol = get_arg(optional_args, 0, Value::Null);
let mut since = get_arg(optional_args, 1, Value::Null);
let mut limit = get_arg(optional_args, 2, Value::Null);
let mut params = get_arg(optional_args, 3, Value::Map({
let mut m = indexmap::IndexMap::new();
m
}));
if is_true(&(!is_equal(&get_value(&self.has, &Value::Str("fetchOpenOrders".to_string())), &Value::Null) && !is_equal(&get_value(&self.has, &Value::Str("fetchOpenOrders".to_string())), &Value::Bool(false)))) && is_true(&(!is_equal(&get_value(&self.has, &Value::Str("fetchClosedOrders".to_string())), &Value::Null) && !is_equal(&get_value(&self.has, &Value::Str("fetchClosedOrders".to_string())), &Value::Bool(false)))) {
panic!("{}", crate::exchange_errors::not_supported(add(&self.id, &Value::Str(" fetchOrders() is not supported yet, consider using fetchOpenOrders() and fetchClosedOrders() instead".to_string()))));
}
panic!("{}", crate::exchange_errors::not_supported(add(&self.id, &Value::Str(" fetchOrders() is not supported yet".to_string()))));
Value::Null
} }
fn fetch_order_trades(&mut self, mut id: Value, optional_args: &[Value]) -> impl ::std::future::Future<Output = Value> + Send { async move {
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
}));
panic!("{}", crate::exchange_errors::not_supported(add(&self.id, &Value::Str(" fetchOrderTrades() is not supported yet".to_string()))));
Value::Null
} }
fn watch_orders(&mut self, optional_args: &[Value]) -> impl ::std::future::Future<Output = Value> + Send { async move {
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
}));
panic!("{}", crate::exchange_errors::not_supported(add(&self.id, &Value::Str(" watchOrders() is not supported yet".to_string()))));
Value::Null
} }
fn fetch_open_orders(&mut self, optional_args: &[Value]) -> impl ::std::future::Future<Output = Value> + Send { async move {
// async-virtual: try the derived exchange first
if let Some(__v) = self.dispatch_to_derived("fetch_open_orders", { let mut __args: Vec<crate::Value> = Vec::new(); __args.extend_from_slice(optional_args); __args }).await {
if !matches!(__v, crate::Value::Null) { return __v; }
}
let mut symbol = get_arg(optional_args, 0, Value::Null);
let mut since = get_arg(optional_args, 1, Value::Null);
let mut limit = get_arg(optional_args, 2, Value::Null);
let mut params = get_arg(optional_args, 3, Value::Map({
let mut m = indexmap::IndexMap::new();
m
}));
if !is_equal(&get_value(&self.has, &Value::Str("fetchOrders".to_string())), &Value::Null) && !is_equal(&get_value(&self.has, &Value::Str("fetchOrders".to_string())), &Value::Bool(false)) {
let mut orders: Value = self.fetch_orders(&[symbol.clone(), since.clone(), limit.clone(), params.clone()]).await;
return self.filter_by(orders.clone(), Value::Str("status".to_string()), Value::Str("open".to_string()), &[]);
}
panic!("{}", crate::exchange_errors::not_supported(add(&self.id, &Value::Str(" fetchOpenOrders() is not supported yet".to_string()))));
Value::Null
} }
fn fetch_closed_orders(&mut self, optional_args: &[Value]) -> impl ::std::future::Future<Output = Value> + Send { async move {
// async-virtual: try the derived exchange first
if let Some(__v) = self.dispatch_to_derived("fetch_closed_orders", { let mut __args: Vec<crate::Value> = Vec::new(); __args.extend_from_slice(optional_args); __args }).await {
if !matches!(__v, crate::Value::Null) { return __v; }
}
let mut symbol = get_arg(optional_args, 0, Value::Null);
let mut since = get_arg(optional_args, 1, Value::Null);
let mut limit = get_arg(optional_args, 2, Value::Null);
let mut params = get_arg(optional_args, 3, Value::Map({
let mut m = indexmap::IndexMap::new();
m
}));
if !is_equal(&get_value(&self.has, &Value::Str("fetchOrders".to_string())), &Value::Null) && !is_equal(&get_value(&self.has, &Value::Str("fetchOrders".to_string())), &Value::Bool(false)) {
let mut orders: Value = self.fetch_orders(&[symbol.clone(), since.clone(), limit.clone(), params.clone()]).await;
return self.filter_by(orders.clone(), Value::Str("status".to_string()), Value::Str("closed".to_string()), &[]);
}
panic!("{}", crate::exchange_errors::not_supported(add(&self.id, &Value::Str(" fetchClosedOrders() is not supported yet".to_string()))));
Value::Null
} }
fn fetch_canceled_orders(&mut self, optional_args: &[Value]) -> impl ::std::future::Future<Output = Value> + Send { async move {
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
}));
panic!("{}", crate::exchange_errors::not_supported(add(&self.id, &Value::Str(" fetchCanceledOrders() is not supported yet".to_string()))));
Value::Null
} }
fn fetch_my_trades(&mut self, optional_args: &[Value]) -> impl ::std::future::Future<Output = Value> + Send { async move {
// async-virtual: try the derived exchange first
if let Some(__v) = self.dispatch_to_derived("fetch_my_trades", { let mut __args: Vec<crate::Value> = Vec::new(); __args.extend_from_slice(optional_args); __args }).await {
if !matches!(__v, crate::Value::Null) { return __v; }
}
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
}));
panic!("{}", crate::exchange_errors::not_supported(add(&self.id, &Value::Str(" fetchMyTrades() is not supported yet".to_string()))));
Value::Null
} }
fn watch_my_trades(&mut self, optional_args: &[Value]) -> impl ::std::future::Future<Output = Value> + Send { async move {
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
}));
panic!("{}", crate::exchange_errors::not_supported(add(&self.id, &Value::Str(" watchMyTrades() is not supported yet".to_string()))));
Value::Null
} }
fn create_limit_order(&mut self, mut symbol: Value, mut side: Value, mut amount: Value, mut price: Value, optional_args: &[Value]) -> impl ::std::future::Future<Output = Value> + Send { async move {
let mut params = get_arg(optional_args, 0, Value::Map({
let mut m = indexmap::IndexMap::new();
m
}));
return self.create_order(symbol.clone(), Value::Str("limit".to_string()), side.clone(), amount.clone(), &[price.clone(), params.clone()]).await;
Value::Null
} }
fn create_market_order(&mut self, mut symbol: Value, mut side: Value, mut amount: Value, optional_args: &[Value]) -> impl ::std::future::Future<Output = Value> + Send { async move {
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
}));
return self.create_order(symbol.clone(), Value::Str("market".to_string()), side.clone(), amount.clone(), &[price.clone(), params.clone()]).await;
Value::Null
} }
fn create_limit_buy_order(&mut self, mut symbol: Value, mut amount: Value, mut price: Value, optional_args: &[Value]) -> impl ::std::future::Future<Output = Value> + Send { async move {
let mut params = get_arg(optional_args, 0, Value::Map({
let mut m = indexmap::IndexMap::new();
m
}));
return self.create_order(symbol.clone(), Value::Str("limit".to_string()), Value::Str("buy".to_string()), amount.clone(), &[price.clone(), params.clone()]).await;
Value::Null
} }
fn create_limit_sell_order(&mut self, mut symbol: Value, mut amount: Value, mut price: Value, optional_args: &[Value]) -> impl ::std::future::Future<Output = Value> + Send { async move {
let mut params = get_arg(optional_args, 0, Value::Map({
let mut m = indexmap::IndexMap::new();
m
}));
return self.create_order(symbol.clone(), Value::Str("limit".to_string()), Value::Str("sell".to_string()), amount.clone(), &[price.clone(), params.clone()]).await;
Value::Null
} }
fn create_market_buy_order(&mut self, mut symbol: Value, mut amount: Value, optional_args: &[Value]) -> impl ::std::future::Future<Output = Value> + Send { async move {
let mut params = get_arg(optional_args, 0, Value::Map({
let mut m = indexmap::IndexMap::new();
m
}));
return self.create_order(symbol.clone(), Value::Str("market".to_string()), Value::Str("buy".to_string()), amount.clone(), &[Value::Null, params.clone()]).await;
Value::Null
} }
fn create_market_sell_order(&mut self, mut symbol: Value, mut amount: Value, optional_args: &[Value]) -> impl ::std::future::Future<Output = Value> + Send { async move {
let mut params = get_arg(optional_args, 0, Value::Map({
let mut m = indexmap::IndexMap::new();
m
}));
return self.create_order(symbol.clone(), Value::Str("market".to_string()), Value::Str("sell".to_string()), amount.clone(), &[Value::Null, params.clone()]).await;
Value::Null
} }
fn create_post_only_order(&mut self, mut symbol: Value, mut type_var: Value, mut side: Value, mut amount: Value, optional_args: &[Value]) -> impl ::std::future::Future<Output = Value> + Send { async move {
let mut price = get_arg(optional_args, 0, Value::Null);
let mut params = get_arg(optional_args, 1, Value::Map({
let mut m = indexmap::IndexMap::new();
m
}));
if is_equal(&get_value(&self.has, &Value::Str("createPostOnlyOrder".to_string())), &Value::Null) || is_equal(&get_value(&self.has, &Value::Str("createPostOnlyOrder".to_string())), &Value::Bool(false)) {
panic!("{}", crate::exchange_errors::not_supported(add(&self.id, &Value::Str(" createPostOnlyOrder() is not supported yet".to_string()))));
}
let mut query: Value = self.extend(params.clone(), &[Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("postOnly".to_string(), Value::Bool(true));
m
})]);
return self.create_order(symbol.clone(), type_var.clone(), side.clone(), amount.clone(), &[price.clone(), query.clone()]).await;
Value::Null
} }
fn create_reduce_only_order(&mut self, mut symbol: Value, mut type_var: Value, mut side: Value, mut amount: Value, optional_args: &[Value]) -> impl ::std::future::Future<Output = Value> + Send { async move {
let mut price = get_arg(optional_args, 0, Value::Null);
let mut params = get_arg(optional_args, 1, Value::Map({
let mut m = indexmap::IndexMap::new();
m
}));
if is_equal(&get_value(&self.has, &Value::Str("createReduceOnlyOrder".to_string())), &Value::Null) || is_equal(&get_value(&self.has, &Value::Str("createReduceOnlyOrder".to_string())), &Value::Bool(false)) {
panic!("{}", crate::exchange_errors::not_supported(add(&self.id, &Value::Str(" createReduceOnlyOrder() is not supported yet".to_string()))));
}
let mut query: Value = self.extend(params.clone(), &[Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("reduceOnly".to_string(), Value::Bool(true));
m
})]);
return self.create_order(symbol.clone(), type_var.clone(), side.clone(), amount.clone(), &[price.clone(), query.clone()]).await;
Value::Null
} }
fn create_stop_order(&mut self, mut symbol: Value, mut type_var: Value, mut side: Value, mut amount: Value, optional_args: &[Value]) -> impl ::std::future::Future<Output = Value> + Send { async move {
let mut price = get_arg(optional_args, 0, Value::Null);
let mut triggerPrice = get_arg(optional_args, 1, Value::Null);
let mut params = get_arg(optional_args, 2, Value::Map({
let mut m = indexmap::IndexMap::new();
m
}));
if is_equal(&get_value(&self.has, &Value::Str("createStopOrder".to_string())), &Value::Null) || is_equal(&get_value(&self.has, &Value::Str("createStopOrder".to_string())), &Value::Bool(false)) {
panic!("{}", crate::exchange_errors::not_supported(add(&self.id, &Value::Str(" createStopOrder() is not supported yet".to_string()))));
}
if is_equal(&triggerPrice, &Value::Null) {
panic!("{}", crate::exchange_errors::arguments_required(add(&self.id, &Value::Str(" create_stop_order() requires a stopPrice argument".to_string()))));
}
let mut query: Value = self.extend(params.clone(), &[Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("stopPrice".to_string(), triggerPrice.clone());
m
})]);
return self.create_order(symbol.clone(), type_var.clone(), side.clone(), amount.clone(), &[price.clone(), query.clone()]).await;
Value::Null
} }
fn create_stop_limit_order(&mut self, mut symbol: Value, mut side: Value, mut amount: Value, mut price: Value, mut triggerPrice: Value, optional_args: &[Value]) -> impl ::std::future::Future<Output = Value> + Send { async move {
let mut params = get_arg(optional_args, 0, Value::Map({
let mut m = indexmap::IndexMap::new();
m
}));
if is_equal(&get_value(&self.has, &Value::Str("createStopLimitOrder".to_string())), &Value::Null) || is_equal(&get_value(&self.has, &Value::Str("createStopLimitOrder".to_string())), &Value::Bool(false)) {
panic!("{}", crate::exchange_errors::not_supported(add(&self.id, &Value::Str(" createStopLimitOrder() is not supported yet".to_string()))));
}
let mut query: Value = self.extend(params.clone(), &[Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("stopPrice".to_string(), triggerPrice.clone());
m
})]);
return self.create_order(symbol.clone(), Value::Str("limit".to_string()), side.clone(), amount.clone(), &[price.clone(), query.clone()]).await;
Value::Null
} }
fn create_stop_market_order(&mut self, mut symbol: Value, mut side: Value, mut amount: Value, mut triggerPrice: Value, optional_args: &[Value]) -> impl ::std::future::Future<Output = Value> + Send { async move {
let mut params = get_arg(optional_args, 0, Value::Map({
let mut m = indexmap::IndexMap::new();
m
}));
if is_equal(&get_value(&self.has, &Value::Str("createStopMarketOrder".to_string())), &Value::Null) || is_equal(&get_value(&self.has, &Value::Str("createStopMarketOrder".to_string())), &Value::Bool(false)) {
panic!("{}", crate::exchange_errors::not_supported(add(&self.id, &Value::Str(" createStopMarketOrder() is not supported yet".to_string()))));
}
let mut query: Value = self.extend(params.clone(), &[Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("stopPrice".to_string(), triggerPrice.clone());
m
})]);
return self.create_order(symbol.clone(), Value::Str("market".to_string()), side.clone(), amount.clone(), &[Value::Null, query.clone()]).await;
Value::Null
} }
fn fetch_trading_fee(&mut self, mut symbol: Value, optional_args: &[Value]) -> impl ::std::future::Future<Output = Value> + Send { async move {
// async-virtual: try the derived exchange first
if let Some(__v) = self.dispatch_to_derived("fetch_trading_fee", { let mut __args: Vec<crate::Value> = Vec::new(); __args.push(symbol.clone()); __args.extend_from_slice(optional_args); __args }).await {
if !matches!(__v, crate::Value::Null) { return __v; }
}
let mut params = get_arg(optional_args, 0, Value::Map({
let mut m = indexmap::IndexMap::new();
m
}));
if is_equal(&get_value(&self.has, &Value::Str("fetchTradingFees".to_string())), &Value::Null) || is_equal(&get_value(&self.has, &Value::Str("fetchTradingFees".to_string())), &Value::Bool(false)) {
panic!("{}", crate::exchange_errors::not_supported(add(&self.id, &Value::Str(" fetchTradingFee() is not supported yet".to_string()))));
}
let mut fees: Value = self.fetch_trading_fees(&[params.clone()]).await;
return self.safe_dict(fees.clone(), symbol.clone(), &[]);
Value::Null
} }
/// Base-method fall-through for a core's `call_dynamic`.
fn call_dynamic_base<'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 {
"account" => self.account(),
"add_key_in_array_items" => self.add_key_in_array_items(args.get(0).cloned().unwrap_or(crate::Value::Null), args.get(1).cloned().unwrap_or(crate::Value::Null)),
"add_margin" => self.add_margin(args.get(0).cloned().unwrap_or(crate::Value::Null), args.get(1).cloned().unwrap_or(crate::Value::Null), &args.get(2..).unwrap_or(&[]).to_vec()[..]).await,
"amount_to_precision" => self.amount_to_precision(args.get(0).cloned().unwrap_or(crate::Value::Null), args.get(1).cloned().unwrap_or(crate::Value::Null)),
"arrays_concat" => self.arrays_concat(args.get(0).cloned().unwrap_or(crate::Value::Null)),
"assign_default_deposit_withdraw_fees" => self.assign_default_deposit_withdraw_fees(args.get(0).cloned().unwrap_or(crate::Value::Null), &args.get(1..).unwrap_or(&[]).to_vec()[..]),
"borrow_cross_margin" => self.borrow_cross_margin(args.get(0).cloned().unwrap_or(crate::Value::Null), args.get(1).cloned().unwrap_or(crate::Value::Null), &args.get(2..).unwrap_or(&[]).to_vec()[..]).await,
"borrow_isolated_margin" => self.borrow_isolated_margin(args.get(0).cloned().unwrap_or(crate::Value::Null), args.get(1).cloned().unwrap_or(crate::Value::Null), args.get(2).cloned().unwrap_or(crate::Value::Null), &args.get(3..).unwrap_or(&[]).to_vec()[..]).await,
"borrow_margin" => self.borrow_margin(args.get(0).cloned().unwrap_or(crate::Value::Null), args.get(1).cloned().unwrap_or(crate::Value::Null), &args.get(2..).unwrap_or(&[]).to_vec()[..]).await,
"build_ohlcvc" => self.build_ohlcvc(args.get(0).cloned().unwrap_or(crate::Value::Null), &args.get(1..).unwrap_or(&[]).to_vec()[..]),
"calculate_fee" => self.calculate_fee(args.get(0).cloned().unwrap_or(crate::Value::Null), args.get(1).cloned().unwrap_or(crate::Value::Null), args.get(2).cloned().unwrap_or(crate::Value::Null), args.get(3).cloned().unwrap_or(crate::Value::Null), args.get(4).cloned().unwrap_or(crate::Value::Null), &args.get(5..).unwrap_or(&[]).to_vec()[..]),
"calculate_fee_with_rate" => self.calculate_fee_with_rate(args.get(0).cloned().unwrap_or(crate::Value::Null), args.get(1).cloned().unwrap_or(crate::Value::Null), args.get(2).cloned().unwrap_or(crate::Value::Null), args.get(3).cloned().unwrap_or(crate::Value::Null), args.get(4).cloned().unwrap_or(crate::Value::Null), &args.get(5..).unwrap_or(&[]).to_vec()[..]),
"calculate_rate_limiter_cost" => self.calculate_rate_limiter_cost(args.get(0).cloned().unwrap_or(crate::Value::Null), args.get(1).cloned().unwrap_or(crate::Value::Null), args.get(2).cloned().unwrap_or(crate::Value::Null), args.get(3).cloned().unwrap_or(crate::Value::Null), &args.get(4..).unwrap_or(&[]).to_vec()[..]),
"call_method" => self.call_method(args.get(0).cloned().unwrap_or(crate::Value::Null), &args.get(1..).unwrap_or(&[]).to_vec()[..]).await,
"cancel_all_contract_orders" => self.cancel_all_contract_orders(&args.get(0..).unwrap_or(&[]).to_vec()[..]).await,
"cancel_all_orders" => self.cancel_all_orders(&args.get(0..).unwrap_or(&[]).to_vec()[..]).await,
"cancel_all_orders_after" => self.cancel_all_orders_after(args.get(0).cloned().unwrap_or(crate::Value::Null), &args.get(1..).unwrap_or(&[]).to_vec()[..]).await,
"cancel_all_orders_ws" => self.cancel_all_orders_ws(&args.get(0..).unwrap_or(&[]).to_vec()[..]).await,
"cancel_all_spot_orders" => self.cancel_all_spot_orders(&args.get(0..).unwrap_or(&[]).to_vec()[..]).await,
"cancel_contract_order" => self.cancel_contract_order(args.get(0).cloned().unwrap_or(crate::Value::Null), &args.get(1..).unwrap_or(&[]).to_vec()[..]).await,
"cancel_order" => self.cancel_order(args.get(0).cloned().unwrap_or(crate::Value::Null), &args.get(1..).unwrap_or(&[]).to_vec()[..]).await,
"cancel_order_with_client_order_id" => self.cancel_order_with_client_order_id(args.get(0).cloned().unwrap_or(crate::Value::Null), &args.get(1..).unwrap_or(&[]).to_vec()[..]).await,
"cancel_order_ws" => self.cancel_order_ws(args.get(0).cloned().unwrap_or(crate::Value::Null), &args.get(1..).unwrap_or(&[]).to_vec()[..]).await,
"cancel_orders" => self.cancel_orders(args.get(0).cloned().unwrap_or(crate::Value::Null), &args.get(1..).unwrap_or(&[]).to_vec()[..]).await,
"cancel_orders_for_symbols" => self.cancel_orders_for_symbols(args.get(0).cloned().unwrap_or(crate::Value::Null), &args.get(1..).unwrap_or(&[]).to_vec()[..]).await,
"cancel_orders_with_client_order_ids" => self.cancel_orders_with_client_order_ids(args.get(0).cloned().unwrap_or(crate::Value::Null), &args.get(1..).unwrap_or(&[]).to_vec()[..]).await,
"cancel_orders_ws" => self.cancel_orders_ws(args.get(0).cloned().unwrap_or(crate::Value::Null), &args.get(1..).unwrap_or(&[]).to_vec()[..]).await,
"cancel_spot_order" => self.cancel_spot_order(args.get(0).cloned().unwrap_or(crate::Value::Null), &args.get(1..).unwrap_or(&[]).to_vec()[..]).await,
"cancel_unified_order" => self.cancel_unified_order(args.get(0).cloned().unwrap_or(crate::Value::Null), &args.get(1..).unwrap_or(&[]).to_vec()[..]).await,
"check_address" => self.check_address(&args.get(0..).unwrap_or(&[]).to_vec()[..]),
"check_proxy_settings" => self.check_proxy_settings(&args.get(0..).unwrap_or(&[]).to_vec()[..]),
"check_proxy_url_settings" => self.check_proxy_url_settings(&args.get(0..).unwrap_or(&[]).to_vec()[..]),
"check_required_credentials" => self.check_required_credentials(&args.get(0..).unwrap_or(&[]).to_vec()[..]),
"check_ws_proxy_settings" => self.check_ws_proxy_settings(),
"close_all_positions" => self.close_all_positions(&args.get(0..).unwrap_or(&[]).to_vec()[..]).await,
"close_position" => self.close_position(args.get(0).cloned().unwrap_or(crate::Value::Null), &args.get(1..).unwrap_or(&[]).to_vec()[..]).await,
"common_currency_code" => self.common_currency_code(args.get(0).cloned().unwrap_or(crate::Value::Null)),
"convert_expire_date" => self.convert_expire_date(args.get(0).cloned().unwrap_or(crate::Value::Null)),
"convert_expire_date_to_market_id_date" => self.convert_expire_date_to_market_id_date(args.get(0).cloned().unwrap_or(crate::Value::Null)),
"convert_market_id_expire_date" => self.convert_market_id_expire_date(args.get(0).cloned().unwrap_or(crate::Value::Null)),
"convert_ohlcv_to_trading_view" => self.convert_ohlcv_to_trading_view(args.get(0).cloned().unwrap_or(crate::Value::Null), &args.get(1..).unwrap_or(&[]).to_vec()[..]),
"convert_trading_view_to_ohlcv" => self.convert_trading_view_to_ohlcv(args.get(0).cloned().unwrap_or(crate::Value::Null), &args.get(1..).unwrap_or(&[]).to_vec()[..]),
"convert_type_to_account" => self.convert_type_to_account(args.get(0).cloned().unwrap_or(crate::Value::Null)),
"cost_to_precision" => self.cost_to_precision(args.get(0).cloned().unwrap_or(crate::Value::Null), args.get(1).cloned().unwrap_or(crate::Value::Null)),
"create_ccxt_trade_id" => self.create_ccxt_trade_id(&args.get(0..).unwrap_or(&[]).to_vec()[..]),
"create_contract_orders" => self.create_contract_orders(args.get(0).cloned().unwrap_or(crate::Value::Null), &args.get(1..).unwrap_or(&[]).to_vec()[..]).await,
"create_convert_trade" => self.create_convert_trade(args.get(0).cloned().unwrap_or(crate::Value::Null), args.get(1).cloned().unwrap_or(crate::Value::Null), args.get(2).cloned().unwrap_or(crate::Value::Null), &args.get(3..).unwrap_or(&[]).to_vec()[..]).await,
"create_deposit_address" => self.create_deposit_address(args.get(0).cloned().unwrap_or(crate::Value::Null), &args.get(1..).unwrap_or(&[]).to_vec()[..]).await,
"create_expired_option_market" => <Self as crate::exchange_generated::ExchangeBase>::create_expired_option_market(self, args.get(0).cloned().unwrap_or(crate::Value::Null)),
"create_limit_buy_order" => self.create_limit_buy_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..).unwrap_or(&[]).to_vec()[..]).await,
"create_limit_buy_order_ws" => self.create_limit_buy_order_ws(args.get(0).cloned().unwrap_or(crate::Value::Null), args.get(1).cloned().unwrap_or(crate::Value::Null), args.get(2).cloned().unwrap_or(crate::Value::Null), &args.get(3..).unwrap_or(&[]).to_vec()[..]).await,
"create_limit_order" => self.create_limit_order(args.get(0).cloned().unwrap_or(crate::Value::Null), args.get(1).cloned().unwrap_or(crate::Value::Null), args.get(2).cloned().unwrap_or(crate::Value::Null), args.get(3).cloned().unwrap_or(crate::Value::Null), &args.get(4..).unwrap_or(&[]).to_vec()[..]).await,
"create_limit_order_ws" => self.create_limit_order_ws(args.get(0).cloned().unwrap_or(crate::Value::Null), args.get(1).cloned().unwrap_or(crate::Value::Null), args.get(2).cloned().unwrap_or(crate::Value::Null), args.get(3).cloned().unwrap_or(crate::Value::Null), &args.get(4..).unwrap_or(&[]).to_vec()[..]).await,
"create_limit_sell_order" => self.create_limit_sell_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..).unwrap_or(&[]).to_vec()[..]).await,
"create_limit_sell_order_ws" => self.create_limit_sell_order_ws(args.get(0).cloned().unwrap_or(crate::Value::Null), args.get(1).cloned().unwrap_or(crate::Value::Null), args.get(2).cloned().unwrap_or(crate::Value::Null), &args.get(3..).unwrap_or(&[]).to_vec()[..]).await,
"create_market_buy_order" => self.create_market_buy_order(args.get(0).cloned().unwrap_or(crate::Value::Null), args.get(1).cloned().unwrap_or(crate::Value::Null), &args.get(2..).unwrap_or(&[]).to_vec()[..]).await,
"create_market_buy_order_with_cost" => self.create_market_buy_order_with_cost(args.get(0).cloned().unwrap_or(crate::Value::Null), args.get(1).cloned().unwrap_or(crate::Value::Null), &args.get(2..).unwrap_or(&[]).to_vec()[..]).await,
"create_market_buy_order_ws" => self.create_market_buy_order_ws(args.get(0).cloned().unwrap_or(crate::Value::Null), args.get(1).cloned().unwrap_or(crate::Value::Null), &args.get(2..).unwrap_or(&[]).to_vec()[..]).await,
"create_market_order" => self.create_market_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..).unwrap_or(&[]).to_vec()[..]).await,
"create_market_order_with_cost" => self.create_market_order_with_cost(args.get(0).cloned().unwrap_or(crate::Value::Null), args.get(1).cloned().unwrap_or(crate::Value::Null), args.get(2).cloned().unwrap_or(crate::Value::Null), &args.get(3..).unwrap_or(&[]).to_vec()[..]).await,
"create_market_order_with_cost_ws" => self.create_market_order_with_cost_ws(args.get(0).cloned().unwrap_or(crate::Value::Null), args.get(1).cloned().unwrap_or(crate::Value::Null), args.get(2).cloned().unwrap_or(crate::Value::Null), &args.get(3..).unwrap_or(&[]).to_vec()[..]).await,
"create_market_order_ws" => self.create_market_order_ws(args.get(0).cloned().unwrap_or(crate::Value::Null), args.get(1).cloned().unwrap_or(crate::Value::Null), args.get(2).cloned().unwrap_or(crate::Value::Null), &args.get(3..).unwrap_or(&[]).to_vec()[..]).await,
"create_market_sell_order" => self.create_market_sell_order(args.get(0).cloned().unwrap_or(crate::Value::Null), args.get(1).cloned().unwrap_or(crate::Value::Null), &args.get(2..).unwrap_or(&[]).to_vec()[..]).await,
"create_market_sell_order_with_cost" => self.create_market_sell_order_with_cost(args.get(0).cloned().unwrap_or(crate::Value::Null), args.get(1).cloned().unwrap_or(crate::Value::Null), &args.get(2..).unwrap_or(&[]).to_vec()[..]).await,
"create_market_sell_order_ws" => self.create_market_sell_order_ws(args.get(0).cloned().unwrap_or(crate::Value::Null), args.get(1).cloned().unwrap_or(crate::Value::Null), &args.get(2..).unwrap_or(&[]).to_vec()[..]).await,
"create_ohlcv_object" => self.create_ohlcv_object(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)),
"create_order" => self.create_order(args.get(0).cloned().unwrap_or(crate::Value::Null), args.get(1).cloned().unwrap_or(crate::Value::Null), args.get(2).cloned().unwrap_or(crate::Value::Null), args.get(3).cloned().unwrap_or(crate::Value::Null), &args.get(4..).unwrap_or(&[]).to_vec()[..]).await,
"create_order_with_take_profit_and_stop_loss" => self.create_order_with_take_profit_and_stop_loss(args.get(0).cloned().unwrap_or(crate::Value::Null), args.get(1).cloned().unwrap_or(crate::Value::Null), args.get(2).cloned().unwrap_or(crate::Value::Null), args.get(3).cloned().unwrap_or(crate::Value::Null), &args.get(4..).unwrap_or(&[]).to_vec()[..]).await,
"create_order_with_take_profit_and_stop_loss_ws" => self.create_order_with_take_profit_and_stop_loss_ws(args.get(0).cloned().unwrap_or(crate::Value::Null), args.get(1).cloned().unwrap_or(crate::Value::Null), args.get(2).cloned().unwrap_or(crate::Value::Null), args.get(3).cloned().unwrap_or(crate::Value::Null), &args.get(4..).unwrap_or(&[]).to_vec()[..]).await,
"create_order_ws" => self.create_order_ws(args.get(0).cloned().unwrap_or(crate::Value::Null), args.get(1).cloned().unwrap_or(crate::Value::Null), args.get(2).cloned().unwrap_or(crate::Value::Null), args.get(3).cloned().unwrap_or(crate::Value::Null), &args.get(4..).unwrap_or(&[]).to_vec()[..]).await,
"create_orders" => self.create_orders(args.get(0).cloned().unwrap_or(crate::Value::Null), &args.get(1..).unwrap_or(&[]).to_vec()[..]).await,
"create_orders_ws" => self.create_orders_ws(args.get(0).cloned().unwrap_or(crate::Value::Null), &args.get(1..).unwrap_or(&[]).to_vec()[..]).await,
"create_post_only_order" => self.create_post_only_order(args.get(0).cloned().unwrap_or(crate::Value::Null), args.get(1).cloned().unwrap_or(crate::Value::Null), args.get(2).cloned().unwrap_or(crate::Value::Null), args.get(3).cloned().unwrap_or(crate::Value::Null), &args.get(4..).unwrap_or(&[]).to_vec()[..]).await,
"create_post_only_order_ws" => self.create_post_only_order_ws(args.get(0).cloned().unwrap_or(crate::Value::Null), args.get(1).cloned().unwrap_or(crate::Value::Null), args.get(2).cloned().unwrap_or(crate::Value::Null), args.get(3).cloned().unwrap_or(crate::Value::Null), &args.get(4..).unwrap_or(&[]).to_vec()[..]).await,
"create_reduce_only_order" => self.create_reduce_only_order(args.get(0).cloned().unwrap_or(crate::Value::Null), args.get(1).cloned().unwrap_or(crate::Value::Null), args.get(2).cloned().unwrap_or(crate::Value::Null), args.get(3).cloned().unwrap_or(crate::Value::Null), &args.get(4..).unwrap_or(&[]).to_vec()[..]).await,
"create_reduce_only_order_ws" => self.create_reduce_only_order_ws(args.get(0).cloned().unwrap_or(crate::Value::Null), args.get(1).cloned().unwrap_or(crate::Value::Null), args.get(2).cloned().unwrap_or(crate::Value::Null), args.get(3).cloned().unwrap_or(crate::Value::Null), &args.get(4..).unwrap_or(&[]).to_vec()[..]).await,
"create_spot_orders" => self.create_spot_orders(args.get(0).cloned().unwrap_or(crate::Value::Null), &args.get(1..).unwrap_or(&[]).to_vec()[..]).await,
"create_stop_limit_order" => self.create_stop_limit_order(args.get(0).cloned().unwrap_or(crate::Value::Null), args.get(1).cloned().unwrap_or(crate::Value::Null), args.get(2).cloned().unwrap_or(crate::Value::Null), args.get(3).cloned().unwrap_or(crate::Value::Null), args.get(4).cloned().unwrap_or(crate::Value::Null), &args.get(5..).unwrap_or(&[]).to_vec()[..]).await,
"create_stop_limit_order_ws" => self.create_stop_limit_order_ws(args.get(0).cloned().unwrap_or(crate::Value::Null), args.get(1).cloned().unwrap_or(crate::Value::Null), args.get(2).cloned().unwrap_or(crate::Value::Null), args.get(3).cloned().unwrap_or(crate::Value::Null), args.get(4).cloned().unwrap_or(crate::Value::Null), &args.get(5..).unwrap_or(&[]).to_vec()[..]).await,
"create_stop_loss_order" => self.create_stop_loss_order(args.get(0).cloned().unwrap_or(crate::Value::Null), args.get(1).cloned().unwrap_or(crate::Value::Null), args.get(2).cloned().unwrap_or(crate::Value::Null), args.get(3).cloned().unwrap_or(crate::Value::Null), &args.get(4..).unwrap_or(&[]).to_vec()[..]).await,
"create_stop_loss_order_ws" => self.create_stop_loss_order_ws(args.get(0).cloned().unwrap_or(crate::Value::Null), args.get(1).cloned().unwrap_or(crate::Value::Null), args.get(2).cloned().unwrap_or(crate::Value::Null), args.get(3).cloned().unwrap_or(crate::Value::Null), &args.get(4..).unwrap_or(&[]).to_vec()[..]).await,
"create_stop_market_order" => self.create_stop_market_order(args.get(0).cloned().unwrap_or(crate::Value::Null), args.get(1).cloned().unwrap_or(crate::Value::Null), args.get(2).cloned().unwrap_or(crate::Value::Null), args.get(3).cloned().unwrap_or(crate::Value::Null), &args.get(4..).unwrap_or(&[]).to_vec()[..]).await,
"create_stop_market_order_ws" => self.create_stop_market_order_ws(args.get(0).cloned().unwrap_or(crate::Value::Null), args.get(1).cloned().unwrap_or(crate::Value::Null), args.get(2).cloned().unwrap_or(crate::Value::Null), args.get(3).cloned().unwrap_or(crate::Value::Null), &args.get(4..).unwrap_or(&[]).to_vec()[..]).await,
"create_stop_order" => self.create_stop_order(args.get(0).cloned().unwrap_or(crate::Value::Null), args.get(1).cloned().unwrap_or(crate::Value::Null), args.get(2).cloned().unwrap_or(crate::Value::Null), args.get(3).cloned().unwrap_or(crate::Value::Null), &args.get(4..).unwrap_or(&[]).to_vec()[..]).await,
"create_stop_order_ws" => self.create_stop_order_ws(args.get(0).cloned().unwrap_or(crate::Value::Null), args.get(1).cloned().unwrap_or(crate::Value::Null), args.get(2).cloned().unwrap_or(crate::Value::Null), args.get(3).cloned().unwrap_or(crate::Value::Null), &args.get(4..).unwrap_or(&[]).to_vec()[..]).await,
"create_sub_account" => self.create_sub_account(args.get(0).cloned().unwrap_or(crate::Value::Null), &args.get(1..).unwrap_or(&[]).to_vec()[..]).await,
"create_take_profit_order" => self.create_take_profit_order(args.get(0).cloned().unwrap_or(crate::Value::Null), args.get(1).cloned().unwrap_or(crate::Value::Null), args.get(2).cloned().unwrap_or(crate::Value::Null), args.get(3).cloned().unwrap_or(crate::Value::Null), &args.get(4..).unwrap_or(&[]).to_vec()[..]).await,
"create_take_profit_order_ws" => self.create_take_profit_order_ws(args.get(0).cloned().unwrap_or(crate::Value::Null), args.get(1).cloned().unwrap_or(crate::Value::Null), args.get(2).cloned().unwrap_or(crate::Value::Null), args.get(3).cloned().unwrap_or(crate::Value::Null), &args.get(4..).unwrap_or(&[]).to_vec()[..]).await,
"create_trailing_amount_order" => self.create_trailing_amount_order(args.get(0).cloned().unwrap_or(crate::Value::Null), args.get(1).cloned().unwrap_or(crate::Value::Null), args.get(2).cloned().unwrap_or(crate::Value::Null), args.get(3).cloned().unwrap_or(crate::Value::Null), &args.get(4..).unwrap_or(&[]).to_vec()[..]).await,
"create_trailing_amount_order_ws" => self.create_trailing_amount_order_ws(args.get(0).cloned().unwrap_or(crate::Value::Null), args.get(1).cloned().unwrap_or(crate::Value::Null), args.get(2).cloned().unwrap_or(crate::Value::Null), args.get(3).cloned().unwrap_or(crate::Value::Null), &args.get(4..).unwrap_or(&[]).to_vec()[..]).await,
"create_trailing_percent_order" => self.create_trailing_percent_order(args.get(0).cloned().unwrap_or(crate::Value::Null), args.get(1).cloned().unwrap_or(crate::Value::Null), args.get(2).cloned().unwrap_or(crate::Value::Null), args.get(3).cloned().unwrap_or(crate::Value::Null), &args.get(4..).unwrap_or(&[]).to_vec()[..]).await,
"create_trailing_percent_order_ws" => self.create_trailing_percent_order_ws(args.get(0).cloned().unwrap_or(crate::Value::Null), args.get(1).cloned().unwrap_or(crate::Value::Null), args.get(2).cloned().unwrap_or(crate::Value::Null), args.get(3).cloned().unwrap_or(crate::Value::Null), &args.get(4..).unwrap_or(&[]).to_vec()[..]).await,
"create_trigger_order" => self.create_trigger_order(args.get(0).cloned().unwrap_or(crate::Value::Null), args.get(1).cloned().unwrap_or(crate::Value::Null), args.get(2).cloned().unwrap_or(crate::Value::Null), args.get(3).cloned().unwrap_or(crate::Value::Null), &args.get(4..).unwrap_or(&[]).to_vec()[..]).await,
"create_trigger_order_ws" => self.create_trigger_order_ws(args.get(0).cloned().unwrap_or(crate::Value::Null), args.get(1).cloned().unwrap_or(crate::Value::Null), args.get(2).cloned().unwrap_or(crate::Value::Null), args.get(3).cloned().unwrap_or(crate::Value::Null), &args.get(4..).unwrap_or(&[]).to_vec()[..]).await,
"create_twap_order" => self.create_twap_order(args.get(0).cloned().unwrap_or(crate::Value::Null), args.get(1).cloned().unwrap_or(crate::Value::Null), args.get(2).cloned().unwrap_or(crate::Value::Null), args.get(3).cloned().unwrap_or(crate::Value::Null), &args.get(4..).unwrap_or(&[]).to_vec()[..]).await,
"currency" => self.currency(args.get(0).cloned().unwrap_or(crate::Value::Null)),
"currency_id" => self.currency_id(args.get(0).cloned().unwrap_or(crate::Value::Null)),
"currency_ids" => self.currency_ids(&args.get(0..).unwrap_or(&[]).to_vec()[..]),
"currency_to_precision" => self.currency_to_precision(args.get(0).cloned().unwrap_or(crate::Value::Null), args.get(1).cloned().unwrap_or(crate::Value::Null), &args.get(2..).unwrap_or(&[]).to_vec()[..]),
"default_network_code" => self.default_network_code(args.get(0).cloned().unwrap_or(crate::Value::Null)),
"deposit_withdraw_fee" => self.deposit_withdraw_fee(args.get(0).cloned().unwrap_or(crate::Value::Null)),
"edit_limit_buy_order" => self.edit_limit_buy_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..).unwrap_or(&[]).to_vec()[..]).await,
"edit_limit_order" => self.edit_limit_order(args.get(0).cloned().unwrap_or(crate::Value::Null), args.get(1).cloned().unwrap_or(crate::Value::Null), args.get(2).cloned().unwrap_or(crate::Value::Null), args.get(3).cloned().unwrap_or(crate::Value::Null), &args.get(4..).unwrap_or(&[]).to_vec()[..]).await,
"edit_limit_sell_order" => self.edit_limit_sell_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..).unwrap_or(&[]).to_vec()[..]).await,
"edit_order" => self.edit_order(args.get(0).cloned().unwrap_or(crate::Value::Null), args.get(1).cloned().unwrap_or(crate::Value::Null), args.get(2).cloned().unwrap_or(crate::Value::Null), args.get(3).cloned().unwrap_or(crate::Value::Null), &args.get(4..).unwrap_or(&[]).to_vec()[..]).await,
"edit_order_with_client_order_id" => self.edit_order_with_client_order_id(args.get(0).cloned().unwrap_or(crate::Value::Null), args.get(1).cloned().unwrap_or(crate::Value::Null), args.get(2).cloned().unwrap_or(crate::Value::Null), args.get(3).cloned().unwrap_or(crate::Value::Null), &args.get(4..).unwrap_or(&[]).to_vec()[..]).await,
"edit_order_ws" => self.edit_order_ws(args.get(0).cloned().unwrap_or(crate::Value::Null), args.get(1).cloned().unwrap_or(crate::Value::Null), args.get(2).cloned().unwrap_or(crate::Value::Null), args.get(3).cloned().unwrap_or(crate::Value::Null), &args.get(4..).unwrap_or(&[]).to_vec()[..]).await,
"edit_orders" => self.edit_orders(args.get(0).cloned().unwrap_or(crate::Value::Null), &args.get(1..).unwrap_or(&[]).to_vec()[..]).await,
"feature_value" => self.feature_value(args.get(0).cloned().unwrap_or(crate::Value::Null), &args.get(1..).unwrap_or(&[]).to_vec()[..]),
"feature_value_by_type" => self.feature_value_by_type(args.get(0).cloned().unwrap_or(crate::Value::Null), args.get(1).cloned().unwrap_or(crate::Value::Null), &args.get(2..).unwrap_or(&[]).to_vec()[..]),
"features_mapper" => self.features_mapper(args.get(0).cloned().unwrap_or(crate::Value::Null), args.get(1).cloned().unwrap_or(crate::Value::Null), &args.get(2..).unwrap_or(&[]).to_vec()[..]),
"fee_to_precision" => self.fee_to_precision(args.get(0).cloned().unwrap_or(crate::Value::Null), args.get(1).cloned().unwrap_or(crate::Value::Null)),
"fetch" => self.fetch(args.get(0).cloned().unwrap_or(crate::Value::Null), &args.get(1..).unwrap_or(&[]).to_vec()[..]).await,
"fetch2" => self.fetch2(args.get(0).cloned().unwrap_or(crate::Value::Null), &args.get(1..).unwrap_or(&[]).to_vec()[..]).await,
"fetch_accounts" => self.fetch_accounts(&args.get(0..).unwrap_or(&[]).to_vec()[..]).await,
"fetch_adl_rank" => self.fetch_adl_rank(args.get(0).cloned().unwrap_or(crate::Value::Null), &args.get(1..).unwrap_or(&[]).to_vec()[..]).await,
"fetch_all_greeks" => self.fetch_all_greeks(&args.get(0..).unwrap_or(&[]).to_vec()[..]).await,
"fetch_balance" => self.fetch_balance(&args.get(0..).unwrap_or(&[]).to_vec()[..]).await,
"fetch_balance_ws" => self.fetch_balance_ws(&args.get(0..).unwrap_or(&[]).to_vec()[..]).await,
"fetch_bids_asks" => self.fetch_bids_asks(&args.get(0..).unwrap_or(&[]).to_vec()[..]).await,
"fetch_borrow_interest" => self.fetch_borrow_interest(&args.get(0..).unwrap_or(&[]).to_vec()[..]).await,
"fetch_borrow_rate" => self.fetch_borrow_rate(args.get(0).cloned().unwrap_or(crate::Value::Null), args.get(1).cloned().unwrap_or(crate::Value::Null), &args.get(2..).unwrap_or(&[]).to_vec()[..]).await,
"fetch_canceled_and_closed_orders" => self.fetch_canceled_and_closed_orders(&args.get(0..).unwrap_or(&[]).to_vec()[..]).await,
"fetch_canceled_orders" => self.fetch_canceled_orders(&args.get(0..).unwrap_or(&[]).to_vec()[..]).await,
"fetch_closed_orders" => self.fetch_closed_orders(&args.get(0..).unwrap_or(&[]).to_vec()[..]).await,
"fetch_closed_orders_ws" => self.fetch_closed_orders_ws(&args.get(0..).unwrap_or(&[]).to_vec()[..]).await,
"fetch_contract_deposit_address" => self.fetch_contract_deposit_address(args.get(0).cloned().unwrap_or(crate::Value::Null), &args.get(1..).unwrap_or(&[]).to_vec()[..]).await,
"fetch_contract_ohlcv" => self.fetch_contract_ohlcv(args.get(0).cloned().unwrap_or(crate::Value::Null), &args.get(1..).unwrap_or(&[]).to_vec()[..]).await,
"fetch_contract_tickers" => self.fetch_contract_tickers(&args.get(0..).unwrap_or(&[]).to_vec()[..]).await,
"fetch_convert_currencies" => self.fetch_convert_currencies(&args.get(0..).unwrap_or(&[]).to_vec()[..]).await,
"fetch_convert_quote" => self.fetch_convert_quote(args.get(0).cloned().unwrap_or(crate::Value::Null), args.get(1).cloned().unwrap_or(crate::Value::Null), &args.get(2..).unwrap_or(&[]).to_vec()[..]).await,
"fetch_convert_trade" => self.fetch_convert_trade(args.get(0).cloned().unwrap_or(crate::Value::Null), &args.get(1..).unwrap_or(&[]).to_vec()[..]).await,
"fetch_convert_trade_history" => self.fetch_convert_trade_history(&args.get(0..).unwrap_or(&[]).to_vec()[..]).await,
"fetch_cross_borrow_rate" => self.fetch_cross_borrow_rate(args.get(0).cloned().unwrap_or(crate::Value::Null), &args.get(1..).unwrap_or(&[]).to_vec()[..]).await,
"fetch_cross_borrow_rates" => self.fetch_cross_borrow_rates(&args.get(0..).unwrap_or(&[]).to_vec()[..]).await,
"fetch_deposit_address" => self.fetch_deposit_address(args.get(0).cloned().unwrap_or(crate::Value::Null), &args.get(1..).unwrap_or(&[]).to_vec()[..]).await,
"fetch_deposit_addresses" => self.fetch_deposit_addresses(&args.get(0..).unwrap_or(&[]).to_vec()[..]).await,
"fetch_deposit_addresses_by_network" => self.fetch_deposit_addresses_by_network(args.get(0).cloned().unwrap_or(crate::Value::Null), &args.get(1..).unwrap_or(&[]).to_vec()[..]).await,
"fetch_deposit_withdraw_fee" => self.fetch_deposit_withdraw_fee(args.get(0).cloned().unwrap_or(crate::Value::Null), &args.get(1..).unwrap_or(&[]).to_vec()[..]).await,
"fetch_deposit_withdraw_fees" => self.fetch_deposit_withdraw_fees(&args.get(0..).unwrap_or(&[]).to_vec()[..]).await,
"fetch_deposits" => self.fetch_deposits(&args.get(0..).unwrap_or(&[]).to_vec()[..]).await,
"fetch_deposits_withdrawals" => self.fetch_deposits_withdrawals(&args.get(0..).unwrap_or(&[]).to_vec()[..]).await,
"fetch_deposits_ws" => self.fetch_deposits_ws(&args.get(0..).unwrap_or(&[]).to_vec()[..]).await,
"fetch_free_balance" => self.fetch_free_balance(&args.get(0..).unwrap_or(&[]).to_vec()[..]).await,
"fetch_funding_history" => self.fetch_funding_history(&args.get(0..).unwrap_or(&[]).to_vec()[..]).await,
"fetch_funding_interval" => self.fetch_funding_interval(args.get(0).cloned().unwrap_or(crate::Value::Null), &args.get(1..).unwrap_or(&[]).to_vec()[..]).await,
"fetch_funding_intervals" => self.fetch_funding_intervals(&args.get(0..).unwrap_or(&[]).to_vec()[..]).await,
"fetch_funding_rate" => self.fetch_funding_rate(args.get(0).cloned().unwrap_or(crate::Value::Null), &args.get(1..).unwrap_or(&[]).to_vec()[..]).await,
"fetch_funding_rate_history" => self.fetch_funding_rate_history(&args.get(0..).unwrap_or(&[]).to_vec()[..]).await,
"fetch_funding_rates" => self.fetch_funding_rates(&args.get(0..).unwrap_or(&[]).to_vec()[..]).await,
"fetch_greeks" => self.fetch_greeks(args.get(0).cloned().unwrap_or(crate::Value::Null), &args.get(1..).unwrap_or(&[]).to_vec()[..]).await,
"fetch_index_ohlcv" => self.fetch_index_ohlcv(args.get(0).cloned().unwrap_or(crate::Value::Null), &args.get(1..).unwrap_or(&[]).to_vec()[..]).await,
"fetch_isolated_borrow_rate" => self.fetch_isolated_borrow_rate(args.get(0).cloned().unwrap_or(crate::Value::Null), &args.get(1..).unwrap_or(&[]).to_vec()[..]).await,
"fetch_isolated_borrow_rates" => self.fetch_isolated_borrow_rates(&args.get(0..).unwrap_or(&[]).to_vec()[..]).await,
"fetch_l2_order_book" => self.fetch_l2_order_book(args.get(0).cloned().unwrap_or(crate::Value::Null), &args.get(1..).unwrap_or(&[]).to_vec()[..]).await,
"fetch_l3_order_book" => self.fetch_l3_order_book(args.get(0).cloned().unwrap_or(crate::Value::Null), &args.get(1..).unwrap_or(&[]).to_vec()[..]).await,
"fetch_last_prices" => self.fetch_last_prices(&args.get(0..).unwrap_or(&[]).to_vec()[..]).await,
"fetch_ledger" => self.fetch_ledger(&args.get(0..).unwrap_or(&[]).to_vec()[..]).await,
"fetch_ledger_entry" => self.fetch_ledger_entry(args.get(0).cloned().unwrap_or(crate::Value::Null), &args.get(1..).unwrap_or(&[]).to_vec()[..]).await,
"fetch_leverage" => self.fetch_leverage(args.get(0).cloned().unwrap_or(crate::Value::Null), &args.get(1..).unwrap_or(&[]).to_vec()[..]).await,
"fetch_leverage_tiers" => self.fetch_leverage_tiers(&args.get(0..).unwrap_or(&[]).to_vec()[..]).await,
"fetch_leverages" => self.fetch_leverages(&args.get(0..).unwrap_or(&[]).to_vec()[..]).await,
"fetch_liquidations" => self.fetch_liquidations(args.get(0).cloned().unwrap_or(crate::Value::Null), &args.get(1..).unwrap_or(&[]).to_vec()[..]).await,
"fetch_long_short_ratio" => self.fetch_long_short_ratio(args.get(0).cloned().unwrap_or(crate::Value::Null), &args.get(1..).unwrap_or(&[]).to_vec()[..]).await,
"fetch_long_short_ratio_history" => self.fetch_long_short_ratio_history(&args.get(0..).unwrap_or(&[]).to_vec()[..]).await,
"fetch_margin_adjustment_history" => self.fetch_margin_adjustment_history(&args.get(0..).unwrap_or(&[]).to_vec()[..]).await,
"fetch_margin_mode" => self.fetch_margin_mode(args.get(0).cloned().unwrap_or(crate::Value::Null), &args.get(1..).unwrap_or(&[]).to_vec()[..]).await,
"fetch_margin_modes" => self.fetch_margin_modes(&args.get(0..).unwrap_or(&[]).to_vec()[..]).await,
"fetch_mark_ohlcv" => self.fetch_mark_ohlcv(args.get(0).cloned().unwrap_or(crate::Value::Null), &args.get(1..).unwrap_or(&[]).to_vec()[..]).await,
"fetch_mark_price" => self.fetch_mark_price(args.get(0).cloned().unwrap_or(crate::Value::Null), &args.get(1..).unwrap_or(&[]).to_vec()[..]).await,
"fetch_mark_prices" => self.fetch_mark_prices(&args.get(0..).unwrap_or(&[]).to_vec()[..]).await,
"fetch_market_leverage_tiers" => self.fetch_market_leverage_tiers(args.get(0).cloned().unwrap_or(crate::Value::Null), &args.get(1..).unwrap_or(&[]).to_vec()[..]).await,
"fetch_my_liquidations" => self.fetch_my_liquidations(&args.get(0..).unwrap_or(&[]).to_vec()[..]).await,
"fetch_my_trades" => self.fetch_my_trades(&args.get(0..).unwrap_or(&[]).to_vec()[..]).await,
"fetch_my_trades_ws" => self.fetch_my_trades_ws(&args.get(0..).unwrap_or(&[]).to_vec()[..]).await,
"fetch_ohlcv" => self.fetch_ohlcv(args.get(0).cloned().unwrap_or(crate::Value::Null), &args.get(1..).unwrap_or(&[]).to_vec()[..]).await,
"fetch_ohlcv_ws" => self.fetch_ohlcv_ws(args.get(0).cloned().unwrap_or(crate::Value::Null), &args.get(1..).unwrap_or(&[]).to_vec()[..]).await,
"fetch_open_interest" => self.fetch_open_interest(args.get(0).cloned().unwrap_or(crate::Value::Null), &args.get(1..).unwrap_or(&[]).to_vec()[..]).await,
"fetch_open_interest_history" => self.fetch_open_interest_history(args.get(0).cloned().unwrap_or(crate::Value::Null), &args.get(1..).unwrap_or(&[]).to_vec()[..]).await,
"fetch_open_interests" => self.fetch_open_interests(&args.get(0..).unwrap_or(&[]).to_vec()[..]).await,
"fetch_open_orders" => self.fetch_open_orders(&args.get(0..).unwrap_or(&[]).to_vec()[..]).await,
"fetch_open_orders_ws" => self.fetch_open_orders_ws(&args.get(0..).unwrap_or(&[]).to_vec()[..]).await,
"fetch_option" => self.fetch_option(args.get(0).cloned().unwrap_or(crate::Value::Null), &args.get(1..).unwrap_or(&[]).to_vec()[..]).await,
"fetch_option_chain" => self.fetch_option_chain(args.get(0).cloned().unwrap_or(crate::Value::Null), &args.get(1..).unwrap_or(&[]).to_vec()[..]).await,
"fetch_order" => self.fetch_order(args.get(0).cloned().unwrap_or(crate::Value::Null), &args.get(1..).unwrap_or(&[]).to_vec()[..]).await,
"fetch_order_book" => self.fetch_order_book(args.get(0).cloned().unwrap_or(crate::Value::Null), &args.get(1..).unwrap_or(&[]).to_vec()[..]).await,
"fetch_order_book_ws" => self.fetch_order_book_ws(args.get(0).cloned().unwrap_or(crate::Value::Null), &args.get(1..).unwrap_or(&[]).to_vec()[..]).await,
"fetch_order_books" => self.fetch_order_books(&args.get(0..).unwrap_or(&[]).to_vec()[..]).await,
"fetch_order_status" => self.fetch_order_status(args.get(0).cloned().unwrap_or(crate::Value::Null), &args.get(1..).unwrap_or(&[]).to_vec()[..]).await,
"fetch_order_trades" => self.fetch_order_trades(args.get(0).cloned().unwrap_or(crate::Value::Null), &args.get(1..).unwrap_or(&[]).to_vec()[..]).await,
"fetch_order_with_client_order_id" => self.fetch_order_with_client_order_id(args.get(0).cloned().unwrap_or(crate::Value::Null), &args.get(1..).unwrap_or(&[]).to_vec()[..]).await,
"fetch_order_ws" => self.fetch_order_ws(args.get(0).cloned().unwrap_or(crate::Value::Null), &args.get(1..).unwrap_or(&[]).to_vec()[..]).await,
"fetch_orders" => self.fetch_orders(&args.get(0..).unwrap_or(&[]).to_vec()[..]).await,
"fetch_orders_by_status_ws" => self.fetch_orders_by_status_ws(args.get(0).cloned().unwrap_or(crate::Value::Null), &args.get(1..).unwrap_or(&[]).to_vec()[..]).await,
"fetch_orders_ws" => self.fetch_orders_ws(&args.get(0..).unwrap_or(&[]).to_vec()[..]).await,
"fetch_paginated_call_cursor" => self.fetch_paginated_call_cursor(args.get(0).cloned().unwrap_or(crate::Value::Null), &args.get(1..).unwrap_or(&[]).to_vec()[..]).await,
"fetch_paginated_call_deterministic" => self.fetch_paginated_call_deterministic(args.get(0).cloned().unwrap_or(crate::Value::Null), &args.get(1..).unwrap_or(&[]).to_vec()[..]).await,
"fetch_paginated_call_dynamic" => self.fetch_paginated_call_dynamic(args.get(0).cloned().unwrap_or(crate::Value::Null), &args.get(1..).unwrap_or(&[]).to_vec()[..]).await,
"fetch_paginated_call_incremental" => self.fetch_paginated_call_incremental(args.get(0).cloned().unwrap_or(crate::Value::Null), &args.get(1..).unwrap_or(&[]).to_vec()[..]).await,
"fetch_partial_balance" => self.fetch_partial_balance(args.get(0).cloned().unwrap_or(crate::Value::Null), &args.get(1..).unwrap_or(&[]).to_vec()[..]).await,
"fetch_payment_methods" => self.fetch_payment_methods(&args.get(0..).unwrap_or(&[]).to_vec()[..]).await,
"fetch_position" => self.fetch_position(args.get(0).cloned().unwrap_or(crate::Value::Null), &args.get(1..).unwrap_or(&[]).to_vec()[..]).await,
"fetch_position_adl_rank" => self.fetch_position_adl_rank(args.get(0).cloned().unwrap_or(crate::Value::Null), &args.get(1..).unwrap_or(&[]).to_vec()[..]).await,
"fetch_position_history" => self.fetch_position_history(args.get(0).cloned().unwrap_or(crate::Value::Null), &args.get(1..).unwrap_or(&[]).to_vec()[..]).await,
"fetch_position_mode" => self.fetch_position_mode(&args.get(0..).unwrap_or(&[]).to_vec()[..]).await,
"fetch_position_ws" => self.fetch_position_ws(args.get(0).cloned().unwrap_or(crate::Value::Null), &args.get(1..).unwrap_or(&[]).to_vec()[..]).await,
"fetch_positions" => self.fetch_positions(&args.get(0..).unwrap_or(&[]).to_vec()[..]).await,
"fetch_positions_adl_rank" => self.fetch_positions_adl_rank(&args.get(0..).unwrap_or(&[]).to_vec()[..]).await,
"fetch_positions_for_symbol" => self.fetch_positions_for_symbol(args.get(0).cloned().unwrap_or(crate::Value::Null), &args.get(1..).unwrap_or(&[]).to_vec()[..]).await,
"fetch_positions_for_symbol_ws" => self.fetch_positions_for_symbol_ws(args.get(0).cloned().unwrap_or(crate::Value::Null), &args.get(1..).unwrap_or(&[]).to_vec()[..]).await,
"fetch_positions_history" => self.fetch_positions_history(&args.get(0..).unwrap_or(&[]).to_vec()[..]).await,
"fetch_positions_risk" => self.fetch_positions_risk(&args.get(0..).unwrap_or(&[]).to_vec()[..]).await,
"fetch_positions_ws" => self.fetch_positions_ws(&args.get(0..).unwrap_or(&[]).to_vec()[..]).await,
"fetch_premium_index_ohlcv" => self.fetch_premium_index_ohlcv(args.get(0).cloned().unwrap_or(crate::Value::Null), &args.get(1..).unwrap_or(&[]).to_vec()[..]).await,
"fetch_rest_order_book_safe" => self.fetch_rest_order_book_safe(args.get(0).cloned().unwrap_or(crate::Value::Null), &args.get(1..).unwrap_or(&[]).to_vec()[..]).await,
"fetch_spot_ohlcv" => self.fetch_spot_ohlcv(args.get(0).cloned().unwrap_or(crate::Value::Null), &args.get(1..).unwrap_or(&[]).to_vec()[..]).await,
"fetch_spot_tickers" => self.fetch_spot_tickers(&args.get(0..).unwrap_or(&[]).to_vec()[..]).await,
"fetch_status" => self.fetch_status(&args.get(0..).unwrap_or(&[]).to_vec()[..]).await,
"fetch_ticker" => self.fetch_ticker(args.get(0).cloned().unwrap_or(crate::Value::Null), &args.get(1..).unwrap_or(&[]).to_vec()[..]).await,
"fetch_ticker_ws" => self.fetch_ticker_ws(args.get(0).cloned().unwrap_or(crate::Value::Null), &args.get(1..).unwrap_or(&[]).to_vec()[..]).await,
"fetch_tickers" => self.fetch_tickers(&args.get(0..).unwrap_or(&[]).to_vec()[..]).await,
"fetch_tickers_ws" => self.fetch_tickers_ws(&args.get(0..).unwrap_or(&[]).to_vec()[..]).await,
"fetch_time" => self.fetch_time(&args.get(0..).unwrap_or(&[]).to_vec()[..]).await,
"fetch_total_balance" => self.fetch_total_balance(&args.get(0..).unwrap_or(&[]).to_vec()[..]).await,
"fetch_trades" => self.fetch_trades(args.get(0).cloned().unwrap_or(crate::Value::Null), &args.get(1..).unwrap_or(&[]).to_vec()[..]).await,
"fetch_trades_ws" => self.fetch_trades_ws(args.get(0).cloned().unwrap_or(crate::Value::Null), &args.get(1..).unwrap_or(&[]).to_vec()[..]).await,
"fetch_trading_fee" => self.fetch_trading_fee(args.get(0).cloned().unwrap_or(crate::Value::Null), &args.get(1..).unwrap_or(&[]).to_vec()[..]).await,
"fetch_trading_fees" => self.fetch_trading_fees(&args.get(0..).unwrap_or(&[]).to_vec()[..]).await,
"fetch_trading_fees_ws" => self.fetch_trading_fees_ws(&args.get(0..).unwrap_or(&[]).to_vec()[..]).await,
"fetch_trading_limits" => self.fetch_trading_limits(&args.get(0..).unwrap_or(&[]).to_vec()[..]).await,
"fetch_transaction_fee" => self.fetch_transaction_fee(args.get(0).cloned().unwrap_or(crate::Value::Null), &args.get(1..).unwrap_or(&[]).to_vec()[..]).await,
"fetch_transaction_fees" => self.fetch_transaction_fees(&args.get(0..).unwrap_or(&[]).to_vec()[..]).await,
"fetch_transactions" => self.fetch_transactions(&args.get(0..).unwrap_or(&[]).to_vec()[..]).await,
"fetch_transfer" => self.fetch_transfer(args.get(0).cloned().unwrap_or(crate::Value::Null), &args.get(1..).unwrap_or(&[]).to_vec()[..]).await,
"fetch_transfers" => self.fetch_transfers(&args.get(0..).unwrap_or(&[]).to_vec()[..]).await,
"fetch_unified_order" => self.fetch_unified_order(args.get(0).cloned().unwrap_or(crate::Value::Null), &args.get(1..).unwrap_or(&[]).to_vec()[..]).await,
"fetch_used_balance" => self.fetch_used_balance(&args.get(0..).unwrap_or(&[]).to_vec()[..]).await,
"fetch_web_endpoint" => self.fetch_web_endpoint(args.get(0).cloned().unwrap_or(crate::Value::Null), args.get(1).cloned().unwrap_or(crate::Value::Null), args.get(2).cloned().unwrap_or(crate::Value::Null), &args.get(3..).unwrap_or(&[]).to_vec()[..]).await,
"fetch_withdrawals" => self.fetch_withdrawals(&args.get(0..).unwrap_or(&[]).to_vec()[..]).await,
"fetch_withdrawals_ws" => self.fetch_withdrawals_ws(&args.get(0..).unwrap_or(&[]).to_vec()[..]).await,
"filter_by_array" => self.filter_by_array(args.get(0).cloned().unwrap_or(crate::Value::Null), args.get(1).cloned().unwrap_or(crate::Value::Null), &args.get(2..).unwrap_or(&[]).to_vec()[..]),
"filter_by_array_adl_ranks" => self.filter_by_array_adl_ranks(args.get(0).cloned().unwrap_or(crate::Value::Null), args.get(1).cloned().unwrap_or(crate::Value::Null), &args.get(2..).unwrap_or(&[]).to_vec()[..]),
"filter_by_array_positions" => self.filter_by_array_positions(args.get(0).cloned().unwrap_or(crate::Value::Null), args.get(1).cloned().unwrap_or(crate::Value::Null), &args.get(2..).unwrap_or(&[]).to_vec()[..]),
"filter_by_array_tickers" => self.filter_by_array_tickers(args.get(0).cloned().unwrap_or(crate::Value::Null), args.get(1).cloned().unwrap_or(crate::Value::Null), &args.get(2..).unwrap_or(&[]).to_vec()[..]),
"filter_by_currency_since_limit" => self.filter_by_currency_since_limit(args.get(0).cloned().unwrap_or(crate::Value::Null), &args.get(1..).unwrap_or(&[]).to_vec()[..]),
"filter_by_key" => self.filter_by_key(args.get(0).cloned().unwrap_or(crate::Value::Null), args.get(1).cloned().unwrap_or(crate::Value::Null), &args.get(2..).unwrap_or(&[]).to_vec()[..]),
"filter_by_limit" => self.filter_by_limit(args.get(0).cloned().unwrap_or(crate::Value::Null), &args.get(1..).unwrap_or(&[]).to_vec()[..]),
"filter_by_since_limit" => self.filter_by_since_limit(args.get(0).cloned().unwrap_or(crate::Value::Null), &args.get(1..).unwrap_or(&[]).to_vec()[..]),
"filter_by_symbol" => self.filter_by_symbol(args.get(0).cloned().unwrap_or(crate::Value::Null), &args.get(1..).unwrap_or(&[]).to_vec()[..]),
"filter_by_symbol_since_limit" => self.filter_by_symbol_since_limit(args.get(0).cloned().unwrap_or(crate::Value::Null), &args.get(1..).unwrap_or(&[]).to_vec()[..]),
"filter_by_symbols_since_limit" => self.filter_by_symbols_since_limit(args.get(0).cloned().unwrap_or(crate::Value::Null), &args.get(1..).unwrap_or(&[]).to_vec()[..]),
"filter_by_value_since_limit" => self.filter_by_value_since_limit(args.get(0).cloned().unwrap_or(crate::Value::Null), args.get(1).cloned().unwrap_or(crate::Value::Null), &args.get(2..).unwrap_or(&[]).to_vec()[..]),
"filter_out_by_array" => self.filter_out_by_array(args.get(0).cloned().unwrap_or(crate::Value::Null), args.get(1).cloned().unwrap_or(crate::Value::Null), &args.get(2..).unwrap_or(&[]).to_vec()[..]),
"find_broadly_matched_key" => self.find_broadly_matched_key(args.get(0).cloned().unwrap_or(crate::Value::Null), args.get(1).cloned().unwrap_or(crate::Value::Null)),
"find_message_hashes" => self.find_message_hashes(args.get(0).cloned().unwrap_or(crate::Value::Null), args.get(1).cloned().unwrap_or(crate::Value::Null)),
"find_nearest_ceiling" => self.find_nearest_ceiling(args.get(0).cloned().unwrap_or(crate::Value::Null), args.get(1).cloned().unwrap_or(crate::Value::Null)),
"find_timeframe" => self.find_timeframe(args.get(0).cloned().unwrap_or(crate::Value::Null), &args.get(1..).unwrap_or(&[]).to_vec()[..]),
"force_string" => self.force_string(args.get(0).cloned().unwrap_or(crate::Value::Null)),
"get_cache_index" => self.get_cache_index(args.get(0).cloned().unwrap_or(crate::Value::Null), args.get(1).cloned().unwrap_or(crate::Value::Null)),
"get_default_options" => self.get_default_options(),
"get_describe_for_extended_ws_exchange" => self.get_describe_for_extended_ws_exchange(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)),
"get_list_from_object_values" => self.get_list_from_object_values(args.get(0).cloned().unwrap_or(crate::Value::Null), args.get(1).cloned().unwrap_or(crate::Value::Null)),
"get_market_from_symbols" => self.get_market_from_symbols(&args.get(0..).unwrap_or(&[]).to_vec()[..]),
"get_supported_mapping" => self.get_supported_mapping(args.get(0).cloned().unwrap_or(crate::Value::Null), &args.get(1..).unwrap_or(&[]).to_vec()[..]),
"get_symbols_for_market_type" => self.get_symbols_for_market_type(&args.get(0..).unwrap_or(&[]).to_vec()[..]),
"handle_errors" => <Self as crate::exchange_generated::ExchangeBase>::handle_errors(self, args.get(0).cloned().unwrap_or(crate::Value::Null), args.get(1).cloned().unwrap_or(crate::Value::Null), args.get(2).cloned().unwrap_or(crate::Value::Null), args.get(3).cloned().unwrap_or(crate::Value::Null), args.get(4).cloned().unwrap_or(crate::Value::Null), args.get(5).cloned().unwrap_or(crate::Value::Null), args.get(6).cloned().unwrap_or(crate::Value::Null), args.get(7).cloned().unwrap_or(crate::Value::Null), args.get(8).cloned().unwrap_or(crate::Value::Null)),
"handle_margin_mode_and_params" => self.handle_margin_mode_and_params(args.get(0).cloned().unwrap_or(crate::Value::Null), &args.get(1..).unwrap_or(&[]).to_vec()[..]),
"handle_market_type_and_params" => self.handle_market_type_and_params(args.get(0).cloned().unwrap_or(crate::Value::Null), &args.get(1..).unwrap_or(&[]).to_vec()[..]),
"handle_max_entries_per_request_and_params" => self.handle_max_entries_per_request_and_params(args.get(0).cloned().unwrap_or(crate::Value::Null), &args.get(1..).unwrap_or(&[]).to_vec()[..]),
"handle_network_code_and_params" => self.handle_network_code_and_params(args.get(0).cloned().unwrap_or(crate::Value::Null)),
"handle_option" => self.handle_option(args.get(0).cloned().unwrap_or(crate::Value::Null), args.get(1).cloned().unwrap_or(crate::Value::Null), &args.get(2..).unwrap_or(&[]).to_vec()[..]),
"handle_option_and_params" => self.handle_option_and_params(args.get(0).cloned().unwrap_or(crate::Value::Null), args.get(1).cloned().unwrap_or(crate::Value::Null), args.get(2).cloned().unwrap_or(crate::Value::Null), &args.get(3..).unwrap_or(&[]).to_vec()[..]),
"handle_option_and_params2" => self.handle_option_and_params2(args.get(0).cloned().unwrap_or(crate::Value::Null), args.get(1).cloned().unwrap_or(crate::Value::Null), args.get(2).cloned().unwrap_or(crate::Value::Null), args.get(3).cloned().unwrap_or(crate::Value::Null), &args.get(4..).unwrap_or(&[]).to_vec()[..]),
"handle_param_bool" => self.handle_param_bool(args.get(0).cloned().unwrap_or(crate::Value::Null), args.get(1).cloned().unwrap_or(crate::Value::Null), &args.get(2..).unwrap_or(&[]).to_vec()[..]),
"handle_param_bool2" => self.handle_param_bool2(args.get(0).cloned().unwrap_or(crate::Value::Null), args.get(1).cloned().unwrap_or(crate::Value::Null), args.get(2).cloned().unwrap_or(crate::Value::Null), &args.get(3..).unwrap_or(&[]).to_vec()[..]),
"handle_param_integer" => self.handle_param_integer(args.get(0).cloned().unwrap_or(crate::Value::Null), args.get(1).cloned().unwrap_or(crate::Value::Null), &args.get(2..).unwrap_or(&[]).to_vec()[..]),
"handle_param_integer2" => self.handle_param_integer2(args.get(0).cloned().unwrap_or(crate::Value::Null), args.get(1).cloned().unwrap_or(crate::Value::Null), args.get(2).cloned().unwrap_or(crate::Value::Null), &args.get(3..).unwrap_or(&[]).to_vec()[..]),
"handle_param_string" => self.handle_param_string(args.get(0).cloned().unwrap_or(crate::Value::Null), args.get(1).cloned().unwrap_or(crate::Value::Null), &args.get(2..).unwrap_or(&[]).to_vec()[..]),
"handle_param_string2" => self.handle_param_string2(args.get(0).cloned().unwrap_or(crate::Value::Null), args.get(1).cloned().unwrap_or(crate::Value::Null), args.get(2).cloned().unwrap_or(crate::Value::Null), &args.get(3..).unwrap_or(&[]).to_vec()[..]),
"handle_post_only" => self.handle_post_only(args.get(0).cloned().unwrap_or(crate::Value::Null), args.get(1).cloned().unwrap_or(crate::Value::Null), &args.get(2..).unwrap_or(&[]).to_vec()[..]),
"handle_request_network" => self.handle_request_network(args.get(0).cloned().unwrap_or(crate::Value::Null), args.get(1).cloned().unwrap_or(crate::Value::Null), args.get(2).cloned().unwrap_or(crate::Value::Null), &args.get(3..).unwrap_or(&[]).to_vec()[..]),
"handle_sub_type_and_params" => self.handle_sub_type_and_params(args.get(0).cloned().unwrap_or(crate::Value::Null), &args.get(1..).unwrap_or(&[]).to_vec()[..]),
"handle_time_in_force" => self.handle_time_in_force(&args.get(0..).unwrap_or(&[]).to_vec()[..]),
"handle_trigger_and_params" => self.handle_trigger_and_params(args.get(0).cloned().unwrap_or(crate::Value::Null)),
"handle_trigger_direction_and_params" => self.handle_trigger_direction_and_params(args.get(0).cloned().unwrap_or(crate::Value::Null), &args.get(1..).unwrap_or(&[]).to_vec()[..]),
"handle_trigger_prices_and_params" => self.handle_trigger_prices_and_params(args.get(0).cloned().unwrap_or(crate::Value::Null), args.get(1).cloned().unwrap_or(crate::Value::Null), &args.get(2..).unwrap_or(&[]).to_vec()[..]),
"handle_until_option" => self.handle_until_option(args.get(0).cloned().unwrap_or(crate::Value::Null), args.get(1).cloned().unwrap_or(crate::Value::Null), args.get(2).cloned().unwrap_or(crate::Value::Null), &args.get(3..).unwrap_or(&[]).to_vec()[..]),
"handle_withdraw_tag_and_params" => self.handle_withdraw_tag_and_params(args.get(0).cloned().unwrap_or(crate::Value::Null), args.get(1).cloned().unwrap_or(crate::Value::Null)),
"implode_hostname" => self.implode_hostname(args.get(0).cloned().unwrap_or(crate::Value::Null)),
"integer_precision_to_amount" => self.integer_precision_to_amount(args.get(0).cloned().unwrap_or(crate::Value::Null)),
"invert_flat_string_dictionary" => self.invert_flat_string_dictionary(args.get(0).cloned().unwrap_or(crate::Value::Null)),
"is_decimal_precision" => self.is_decimal_precision(),
"is_empty_string" => self.is_empty_string(args.get(0).cloned().unwrap_or(crate::Value::Null)),
"is_leveraged_currency" => self.is_leveraged_currency(args.get(0).cloned().unwrap_or(crate::Value::Null), &args.get(1..).unwrap_or(&[]).to_vec()[..]),
"is_post_only" => self.is_post_only(args.get(0).cloned().unwrap_or(crate::Value::Null), args.get(1).cloned().unwrap_or(crate::Value::Null), &args.get(2..).unwrap_or(&[]).to_vec()[..]),
"is_round_number" => self.is_round_number(args.get(0).cloned().unwrap_or(crate::Value::Null)),
"is_significant_precision" => self.is_significant_precision(),
"is_tick_precision" => self.is_tick_precision(),
"is_trigger_order" => self.is_trigger_order(args.get(0).cloned().unwrap_or(crate::Value::Null)),
"is_uta_enabled" => self.is_uta_enabled(&args.get(0..).unwrap_or(&[]).to_vec()[..]).await,
"load_accounts" => self.load_accounts(&args.get(0..).unwrap_or(&[]).to_vec()[..]).await,
"load_markets" => self.load_markets(&args.get(0..).unwrap_or(&[]).to_vec()[..]).await,
"load_markets_and_sign_in" => self.load_markets_and_sign_in().await,
"load_time_difference" => self.load_time_difference(&args.get(0..).unwrap_or(&[]).to_vec()[..]).await,
"load_trading_limits" => self.load_trading_limits(&args.get(0..).unwrap_or(&[]).to_vec()[..]).await,
"market" => self.market(args.get(0).cloned().unwrap_or(crate::Value::Null)),
"market_codes" => self.market_codes(&args.get(0..).unwrap_or(&[]).to_vec()[..]),
"market_id" => self.market_id(args.get(0).cloned().unwrap_or(crate::Value::Null)),
"market_ids" => self.market_ids(&args.get(0..).unwrap_or(&[]).to_vec()[..]),
"market_or_null" => self.market_or_null(&args.get(0..).unwrap_or(&[]).to_vec()[..]),
"market_symbols" => self.market_symbols(&args.get(0..).unwrap_or(&[]).to_vec()[..]),
"markets_for_symbols" => self.markets_for_symbols(&args.get(0..).unwrap_or(&[]).to_vec()[..]),
"merge_balance_account" => self.merge_balance_account(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)),
"network_code_to_id" => self.network_code_to_id(args.get(0).cloned().unwrap_or(crate::Value::Null), &args.get(1..).unwrap_or(&[]).to_vec()[..]),
"network_id_to_code" => self.network_id_to_code(&args.get(0..).unwrap_or(&[]).to_vec()[..]),
"nonce" => <Self as crate::exchange_generated::ExchangeBase>::nonce(self),
"oath" => self.oath(),
"orderbook_checksum_message" => self.orderbook_checksum_message(args.get(0).cloned().unwrap_or(crate::Value::Null)),
"parse_account" => <Self as crate::exchange_generated::ExchangeBase>::parse_account(self, args.get(0).cloned().unwrap_or(crate::Value::Null)),
"parse_accounts" => self.parse_accounts(args.get(0).cloned().unwrap_or(crate::Value::Null), &args.get(1..).unwrap_or(&[]).to_vec()[..]),
"parse_adl_rank" => <Self as crate::exchange_generated::ExchangeBase>::parse_adl_rank(self, args.get(0).cloned().unwrap_or(crate::Value::Null), &args.get(1..).unwrap_or(&[]).to_vec()[..]),
"parse_adl_ranks" => self.parse_adl_ranks(args.get(0).cloned().unwrap_or(crate::Value::Null), &args.get(1..).unwrap_or(&[]).to_vec()[..]),
"parse_all_greeks" => self.parse_all_greeks(args.get(0).cloned().unwrap_or(crate::Value::Null), &args.get(1..).unwrap_or(&[]).to_vec()[..]),
"parse_balance" => <Self as crate::exchange_generated::ExchangeBase>::parse_balance(self, args.get(0).cloned().unwrap_or(crate::Value::Null)),
"parse_borrow_interest" => <Self as crate::exchange_generated::ExchangeBase>::parse_borrow_interest(self, args.get(0).cloned().unwrap_or(crate::Value::Null), &args.get(1..).unwrap_or(&[]).to_vec()[..]),
"parse_borrow_interests" => self.parse_borrow_interests(args.get(0).cloned().unwrap_or(crate::Value::Null), &args.get(1..).unwrap_or(&[]).to_vec()[..]),
"parse_borrow_rate" => <Self as crate::exchange_generated::ExchangeBase>::parse_borrow_rate(self, args.get(0).cloned().unwrap_or(crate::Value::Null), &args.get(1..).unwrap_or(&[]).to_vec()[..]),
"parse_borrow_rate_history" => self.parse_borrow_rate_history(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)),
"parse_conversion" => <Self as crate::exchange_generated::ExchangeBase>::parse_conversion(self, args.get(0).cloned().unwrap_or(crate::Value::Null), &args.get(1..).unwrap_or(&[]).to_vec()[..]),
"parse_conversions" => self.parse_conversions(args.get(0).cloned().unwrap_or(crate::Value::Null), &args.get(1..).unwrap_or(&[]).to_vec()[..]),
"parse_currencies" => self.parse_currencies(args.get(0).cloned().unwrap_or(crate::Value::Null)),
"parse_currency" => <Self as crate::exchange_generated::ExchangeBase>::parse_currency(self, args.get(0).cloned().unwrap_or(crate::Value::Null)),
"parse_deposit_address" => <Self as crate::exchange_generated::ExchangeBase>::parse_deposit_address(self, args.get(0).cloned().unwrap_or(crate::Value::Null), &args.get(1..).unwrap_or(&[]).to_vec()[..]),
"parse_deposit_addresses" => self.parse_deposit_addresses(args.get(0).cloned().unwrap_or(crate::Value::Null), &args.get(1..).unwrap_or(&[]).to_vec()[..]),
"parse_deposit_withdraw_fee" => <Self as crate::exchange_generated::ExchangeBase>::parse_deposit_withdraw_fee(self, args.get(0).cloned().unwrap_or(crate::Value::Null), &args.get(1..).unwrap_or(&[]).to_vec()[..]),
"parse_deposit_withdraw_fees" => self.parse_deposit_withdraw_fees(args.get(0).cloned().unwrap_or(crate::Value::Null), &args.get(1..).unwrap_or(&[]).to_vec()[..]),
"parse_fee_numeric" => self.parse_fee_numeric(args.get(0).cloned().unwrap_or(crate::Value::Null)),
"parse_funding_rate" => <Self as crate::exchange_generated::ExchangeBase>::parse_funding_rate(self, args.get(0).cloned().unwrap_or(crate::Value::Null), &args.get(1..).unwrap_or(&[]).to_vec()[..]),
"parse_funding_rate_histories" => self.parse_funding_rate_histories(args.get(0).cloned().unwrap_or(crate::Value::Null), &args.get(1..).unwrap_or(&[]).to_vec()[..]),
"parse_funding_rate_history" => <Self as crate::exchange_generated::ExchangeBase>::parse_funding_rate_history(self, args.get(0).cloned().unwrap_or(crate::Value::Null), &args.get(1..).unwrap_or(&[]).to_vec()[..]),
"parse_funding_rates" => self.parse_funding_rates(args.get(0).cloned().unwrap_or(crate::Value::Null), &args.get(1..).unwrap_or(&[]).to_vec()[..]),
"parse_greeks" => <Self as crate::exchange_generated::ExchangeBase>::parse_greeks(self, args.get(0).cloned().unwrap_or(crate::Value::Null), &args.get(1..).unwrap_or(&[]).to_vec()[..]),
"parse_income" => <Self as crate::exchange_generated::ExchangeBase>::parse_income(self, args.get(0).cloned().unwrap_or(crate::Value::Null), &args.get(1..).unwrap_or(&[]).to_vec()[..]),
"parse_incomes" => self.parse_incomes(args.get(0).cloned().unwrap_or(crate::Value::Null), &args.get(1..).unwrap_or(&[]).to_vec()[..]),
"parse_isolated_borrow_rate" => self.parse_isolated_borrow_rate(args.get(0).cloned().unwrap_or(crate::Value::Null), &args.get(1..).unwrap_or(&[]).to_vec()[..]),
"parse_isolated_borrow_rates" => self.parse_isolated_borrow_rates(args.get(0).cloned().unwrap_or(crate::Value::Null)),
"parse_last_price" => <Self as crate::exchange_generated::ExchangeBase>::parse_last_price(self, args.get(0).cloned().unwrap_or(crate::Value::Null), &args.get(1..).unwrap_or(&[]).to_vec()[..]),
"parse_last_prices" => self.parse_last_prices(args.get(0).cloned().unwrap_or(crate::Value::Null), &args.get(1..).unwrap_or(&[]).to_vec()[..]),
"parse_ledger" => self.parse_ledger(args.get(0).cloned().unwrap_or(crate::Value::Null), &args.get(1..).unwrap_or(&[]).to_vec()[..]),
"parse_ledger_entry" => <Self as crate::exchange_generated::ExchangeBase>::parse_ledger_entry(self, args.get(0).cloned().unwrap_or(crate::Value::Null), &args.get(1..).unwrap_or(&[]).to_vec()[..]),
"parse_leverage" => <Self as crate::exchange_generated::ExchangeBase>::parse_leverage(self, args.get(0).cloned().unwrap_or(crate::Value::Null), &args.get(1..).unwrap_or(&[]).to_vec()[..]),
"parse_leverage_tiers" => self.parse_leverage_tiers(args.get(0).cloned().unwrap_or(crate::Value::Null), &args.get(1..).unwrap_or(&[]).to_vec()[..]),
"parse_leverages" => self.parse_leverages(args.get(0).cloned().unwrap_or(crate::Value::Null), &args.get(1..).unwrap_or(&[]).to_vec()[..]),
"parse_liquidation" => <Self as crate::exchange_generated::ExchangeBase>::parse_liquidation(self, args.get(0).cloned().unwrap_or(crate::Value::Null), &args.get(1..).unwrap_or(&[]).to_vec()[..]),
"parse_liquidations" => self.parse_liquidations(args.get(0).cloned().unwrap_or(crate::Value::Null), &args.get(1..).unwrap_or(&[]).to_vec()[..]),
"parse_long_short_ratio" => self.parse_long_short_ratio(args.get(0).cloned().unwrap_or(crate::Value::Null), &args.get(1..).unwrap_or(&[]).to_vec()[..]),
"parse_long_short_ratio_history" => self.parse_long_short_ratio_history(args.get(0).cloned().unwrap_or(crate::Value::Null), &args.get(1..).unwrap_or(&[]).to_vec()[..]),
"parse_margin_mode" => <Self as crate::exchange_generated::ExchangeBase>::parse_margin_mode(self, args.get(0).cloned().unwrap_or(crate::Value::Null), &args.get(1..).unwrap_or(&[]).to_vec()[..]),
"parse_margin_modes" => self.parse_margin_modes(args.get(0).cloned().unwrap_or(crate::Value::Null), &args.get(1..).unwrap_or(&[]).to_vec()[..]),
"parse_margin_modification" => <Self as crate::exchange_generated::ExchangeBase>::parse_margin_modification(self, args.get(0).cloned().unwrap_or(crate::Value::Null), &args.get(1..).unwrap_or(&[]).to_vec()[..]),
"parse_margin_modifications" => self.parse_margin_modifications(args.get(0).cloned().unwrap_or(crate::Value::Null), &args.get(1..).unwrap_or(&[]).to_vec()[..]),
"parse_market" => <Self as crate::exchange_generated::ExchangeBase>::parse_market(self, args.get(0).cloned().unwrap_or(crate::Value::Null)),
"parse_market_leverage_tiers" => <Self as crate::exchange_generated::ExchangeBase>::parse_market_leverage_tiers(self, args.get(0).cloned().unwrap_or(crate::Value::Null), &args.get(1..).unwrap_or(&[]).to_vec()[..]),
"parse_markets" => self.parse_markets(args.get(0).cloned().unwrap_or(crate::Value::Null)),
"parse_ohlc_vs" => self.parse_ohlc_vs(args.get(0).cloned().unwrap_or(crate::Value::Null), &args.get(1..).unwrap_or(&[]).to_vec()[..]),
"parse_ohlcv" => <Self as crate::exchange_generated::ExchangeBase>::parse_ohlcv(self, args.get(0).cloned().unwrap_or(crate::Value::Null), &args.get(1..).unwrap_or(&[]).to_vec()[..]),
"parse_open_interest" => <Self as crate::exchange_generated::ExchangeBase>::parse_open_interest(self, args.get(0).cloned().unwrap_or(crate::Value::Null), &args.get(1..).unwrap_or(&[]).to_vec()[..]),
"parse_open_interests" => self.parse_open_interests(args.get(0).cloned().unwrap_or(crate::Value::Null), &args.get(1..).unwrap_or(&[]).to_vec()[..]),
"parse_open_interests_history" => self.parse_open_interests_history(args.get(0).cloned().unwrap_or(crate::Value::Null), &args.get(1..).unwrap_or(&[]).to_vec()[..]),
"parse_option" => self.parse_option(args.get(0).cloned().unwrap_or(crate::Value::Null), &args.get(1..).unwrap_or(&[]).to_vec()[..]),
"parse_option_chain" => self.parse_option_chain(args.get(0).cloned().unwrap_or(crate::Value::Null), &args.get(1..).unwrap_or(&[]).to_vec()[..]),
"parse_order" => <Self as crate::exchange_generated::ExchangeBase>::parse_order(self, args.get(0).cloned().unwrap_or(crate::Value::Null), &args.get(1..).unwrap_or(&[]).to_vec()[..]),
"parse_order_book" => <Self as crate::exchange_generated::ExchangeBase>::parse_order_book(self, args.get(0).cloned().unwrap_or(crate::Value::Null), args.get(1).cloned().unwrap_or(crate::Value::Null), &args.get(2..).unwrap_or(&[]).to_vec()[..]),
"parse_order_book_bid_ask" => self.parse_order_book_bid_ask(args.get(0).cloned().unwrap_or(crate::Value::Null), &args.get(1..).unwrap_or(&[]).to_vec()[..]),
"parse_order_book_bids_asks" => self.parse_order_book_bids_asks(args.get(0).cloned().unwrap_or(crate::Value::Null), &args.get(1..).unwrap_or(&[]).to_vec()[..]),
"parse_orders" => self.parse_orders(args.get(0).cloned().unwrap_or(crate::Value::Null), &args.get(1..).unwrap_or(&[]).to_vec()[..]),
"parse_position" => <Self as crate::exchange_generated::ExchangeBase>::parse_position(self, args.get(0).cloned().unwrap_or(crate::Value::Null), &args.get(1..).unwrap_or(&[]).to_vec()[..]),
"parse_positions" => self.parse_positions(args.get(0).cloned().unwrap_or(crate::Value::Null), &args.get(1..).unwrap_or(&[]).to_vec()[..]),
"parse_precision" => self.parse_precision(&args.get(0..).unwrap_or(&[]).to_vec()[..]),
"parse_ticker" => <Self as crate::exchange_generated::ExchangeBase>::parse_ticker(self, args.get(0).cloned().unwrap_or(crate::Value::Null), &args.get(1..).unwrap_or(&[]).to_vec()[..]),
"parse_tickers" => self.parse_tickers(args.get(0).cloned().unwrap_or(crate::Value::Null), &args.get(1..).unwrap_or(&[]).to_vec()[..]),
"parse_to_int" => self.parse_to_int(args.get(0).cloned().unwrap_or(crate::Value::Null)),
"parse_to_numeric" => self.parse_to_numeric(args.get(0).cloned().unwrap_or(crate::Value::Null)),
"parse_trade" => <Self as crate::exchange_generated::ExchangeBase>::parse_trade(self, args.get(0).cloned().unwrap_or(crate::Value::Null), &args.get(1..).unwrap_or(&[]).to_vec()[..]),
"parse_trades" => self.parse_trades(args.get(0).cloned().unwrap_or(crate::Value::Null), &args.get(1..).unwrap_or(&[]).to_vec()[..]),
"parse_trades_helper" => self.parse_trades_helper(args.get(0).cloned().unwrap_or(crate::Value::Null), args.get(1).cloned().unwrap_or(crate::Value::Null), &args.get(2..).unwrap_or(&[]).to_vec()[..]),
"parse_trading_view_ohlcv" => self.parse_trading_view_ohlcv(args.get(0).cloned().unwrap_or(crate::Value::Null), &args.get(1..).unwrap_or(&[]).to_vec()[..]),
"parse_transaction" => <Self as crate::exchange_generated::ExchangeBase>::parse_transaction(self, args.get(0).cloned().unwrap_or(crate::Value::Null), &args.get(1..).unwrap_or(&[]).to_vec()[..]),
"parse_transactions" => self.parse_transactions(args.get(0).cloned().unwrap_or(crate::Value::Null), &args.get(1..).unwrap_or(&[]).to_vec()[..]),
"parse_transfer" => <Self as crate::exchange_generated::ExchangeBase>::parse_transfer(self, args.get(0).cloned().unwrap_or(crate::Value::Null), &args.get(1..).unwrap_or(&[]).to_vec()[..]),
"parse_transfers" => self.parse_transfers(args.get(0).cloned().unwrap_or(crate::Value::Null), &args.get(1..).unwrap_or(&[]).to_vec()[..]),
"parse_ws_ohlc_vs" => self.parse_ws_ohlc_vs(args.get(0).cloned().unwrap_or(crate::Value::Null), &args.get(1..).unwrap_or(&[]).to_vec()[..]),
"parse_ws_ohlcv" => self.parse_ws_ohlcv(args.get(0).cloned().unwrap_or(crate::Value::Null), &args.get(1..).unwrap_or(&[]).to_vec()[..]),
"parse_ws_order" => self.parse_ws_order(args.get(0).cloned().unwrap_or(crate::Value::Null), &args.get(1..).unwrap_or(&[]).to_vec()[..]),
"parse_ws_order_trade" => self.parse_ws_order_trade(args.get(0).cloned().unwrap_or(crate::Value::Null), &args.get(1..).unwrap_or(&[]).to_vec()[..]),
"parse_ws_trade" => self.parse_ws_trade(args.get(0).cloned().unwrap_or(crate::Value::Null), &args.get(1..).unwrap_or(&[]).to_vec()[..]),
"parse_ws_trades" => self.parse_ws_trades(args.get(0).cloned().unwrap_or(crate::Value::Null), &args.get(1..).unwrap_or(&[]).to_vec()[..]),
"parsed_fee_and_fees" => self.parsed_fee_and_fees(args.get(0).cloned().unwrap_or(crate::Value::Null)),
"price_to_precision" => self.price_to_precision(args.get(0).cloned().unwrap_or(crate::Value::Null), args.get(1).cloned().unwrap_or(crate::Value::Null)),
"prioritized_network_aliases" => self.prioritized_network_aliases(&args.get(0..).unwrap_or(&[]).to_vec()[..]),
"reduce_fees_by_currency" => self.reduce_fees_by_currency(args.get(0).cloned().unwrap_or(crate::Value::Null)),
"reduce_margin" => self.reduce_margin(args.get(0).cloned().unwrap_or(crate::Value::Null), args.get(1).cloned().unwrap_or(crate::Value::Null), &args.get(2..).unwrap_or(&[]).to_vec()[..]).await,
"remove_keys_from_dict" => self.remove_keys_from_dict(args.get(0).cloned().unwrap_or(crate::Value::Null), args.get(1).cloned().unwrap_or(crate::Value::Null)),
"remove_repeated_elements_from_array" => self.remove_repeated_elements_from_array(args.get(0).cloned().unwrap_or(crate::Value::Null), &args.get(1..).unwrap_or(&[]).to_vec()[..]),
"remove_repeated_trades_from_array" => self.remove_repeated_trades_from_array(args.get(0).cloned().unwrap_or(crate::Value::Null)),
"repay_cross_margin" => self.repay_cross_margin(args.get(0).cloned().unwrap_or(crate::Value::Null), args.get(1).cloned().unwrap_or(crate::Value::Null), &args.get(2..).unwrap_or(&[]).to_vec()[..]).await,
"repay_isolated_margin" => self.repay_isolated_margin(args.get(0).cloned().unwrap_or(crate::Value::Null), args.get(1).cloned().unwrap_or(crate::Value::Null), args.get(2).cloned().unwrap_or(crate::Value::Null), &args.get(3..).unwrap_or(&[]).to_vec()[..]).await,
"repay_margin" => self.repay_margin(args.get(0).cloned().unwrap_or(crate::Value::Null), args.get(1).cloned().unwrap_or(crate::Value::Null), &args.get(2..).unwrap_or(&[]).to_vec()[..]).await,
"request" => self.request(args.get(0).cloned().unwrap_or(crate::Value::Null), &args.get(1..).unwrap_or(&[]).to_vec()[..]).await,
"require_value" => self.require_value(args.get(0).cloned().unwrap_or(crate::Value::Null), &args.get(1..).unwrap_or(&[]).to_vec()[..]),
"resolve_path" => self.resolve_path(args.get(0).cloned().unwrap_or(crate::Value::Null), args.get(1).cloned().unwrap_or(crate::Value::Null)),
"safe_balance" => self.safe_balance(args.get(0).cloned().unwrap_or(crate::Value::Null)),
"safe_bool" => self.safe_bool(args.get(0).cloned().unwrap_or(crate::Value::Null), args.get(1).cloned().unwrap_or(crate::Value::Null), &args.get(2..).unwrap_or(&[]).to_vec()[..]),
"safe_bool2" => self.safe_bool2(args.get(0).cloned().unwrap_or(crate::Value::Null), args.get(1).cloned().unwrap_or(crate::Value::Null), args.get(2).cloned().unwrap_or(crate::Value::Null), &args.get(3..).unwrap_or(&[]).to_vec()[..]),
"safe_bool_n" => self.safe_bool_n(args.get(0).cloned().unwrap_or(crate::Value::Null), args.get(1).cloned().unwrap_or(crate::Value::Null), &args.get(2..).unwrap_or(&[]).to_vec()[..]),
"safe_currency" => self.safe_currency(args.get(0).cloned().unwrap_or(crate::Value::Null), &args.get(1..).unwrap_or(&[]).to_vec()[..]),
"safe_currency_code" => self.safe_currency_code(args.get(0).cloned().unwrap_or(crate::Value::Null), &args.get(1..).unwrap_or(&[]).to_vec()[..]),
"safe_currency_structure" => self.safe_currency_structure(args.get(0).cloned().unwrap_or(crate::Value::Null)),
"safe_deterministic_call" => self.safe_deterministic_call(args.get(0).cloned().unwrap_or(crate::Value::Null), &args.get(1..).unwrap_or(&[]).to_vec()[..]).await,
"safe_dict" => self.safe_dict(args.get(0).cloned().unwrap_or(crate::Value::Null), args.get(1).cloned().unwrap_or(crate::Value::Null), &args.get(2..).unwrap_or(&[]).to_vec()[..]),
"safe_dict2" => self.safe_dict2(args.get(0).cloned().unwrap_or(crate::Value::Null), args.get(1).cloned().unwrap_or(crate::Value::Null), args.get(2).cloned().unwrap_or(crate::Value::Null), &args.get(3..).unwrap_or(&[]).to_vec()[..]),
"safe_dict_n" => self.safe_dict_n(args.get(0).cloned().unwrap_or(crate::Value::Null), args.get(1).cloned().unwrap_or(crate::Value::Null), &args.get(2..).unwrap_or(&[]).to_vec()[..]),
"safe_integer_omit_zero" => self.safe_integer_omit_zero(args.get(0).cloned().unwrap_or(crate::Value::Null), args.get(1).cloned().unwrap_or(crate::Value::Null), &args.get(2..).unwrap_or(&[]).to_vec()[..]),
"safe_ledger_entry" => self.safe_ledger_entry(args.get(0).cloned().unwrap_or(crate::Value::Null), &args.get(1..).unwrap_or(&[]).to_vec()[..]),
"safe_liquidation" => self.safe_liquidation(args.get(0).cloned().unwrap_or(crate::Value::Null), &args.get(1..).unwrap_or(&[]).to_vec()[..]),
"safe_list" => self.safe_list(args.get(0).cloned().unwrap_or(crate::Value::Null), args.get(1).cloned().unwrap_or(crate::Value::Null), &args.get(2..).unwrap_or(&[]).to_vec()[..]),
"safe_list2" => self.safe_list2(args.get(0).cloned().unwrap_or(crate::Value::Null), args.get(1).cloned().unwrap_or(crate::Value::Null), args.get(2).cloned().unwrap_or(crate::Value::Null), &args.get(3..).unwrap_or(&[]).to_vec()[..]),
"safe_list_n" => self.safe_list_n(args.get(0).cloned().unwrap_or(crate::Value::Null), args.get(1).cloned().unwrap_or(crate::Value::Null), &args.get(2..).unwrap_or(&[]).to_vec()[..]),
"safe_market" => self.safe_market(&args.get(0..).unwrap_or(&[]).to_vec()[..]),
"safe_market_structure" => self.safe_market_structure(&args.get(0..).unwrap_or(&[]).to_vec()[..]),
"safe_network" => self.safe_network(args.get(0).cloned().unwrap_or(crate::Value::Null)),
"safe_number" => self.safe_number(args.get(0).cloned().unwrap_or(crate::Value::Null), args.get(1).cloned().unwrap_or(crate::Value::Null), &args.get(2..).unwrap_or(&[]).to_vec()[..]),
"safe_number2" => self.safe_number2(args.get(0).cloned().unwrap_or(crate::Value::Null), args.get(1).cloned().unwrap_or(crate::Value::Null), args.get(2).cloned().unwrap_or(crate::Value::Null), &args.get(3..).unwrap_or(&[]).to_vec()[..]),
"safe_number_n" => self.safe_number_n(args.get(0).cloned().unwrap_or(crate::Value::Null), args.get(1).cloned().unwrap_or(crate::Value::Null), &args.get(2..).unwrap_or(&[]).to_vec()[..]),
"safe_number_omit_zero" => self.safe_number_omit_zero(args.get(0).cloned().unwrap_or(crate::Value::Null), args.get(1).cloned().unwrap_or(crate::Value::Null), &args.get(2..).unwrap_or(&[]).to_vec()[..]),
"safe_open_interest" => self.safe_open_interest(args.get(0).cloned().unwrap_or(crate::Value::Null), &args.get(1..).unwrap_or(&[]).to_vec()[..]),
"safe_order" => self.safe_order(args.get(0).cloned().unwrap_or(crate::Value::Null), &args.get(1..).unwrap_or(&[]).to_vec()[..]),
"safe_position" => self.safe_position(args.get(0).cloned().unwrap_or(crate::Value::Null)),
"safe_symbol" => self.safe_symbol(args.get(0).cloned().unwrap_or(crate::Value::Null), &args.get(1..).unwrap_or(&[]).to_vec()[..]),
"safe_ticker" => self.safe_ticker(args.get(0).cloned().unwrap_or(crate::Value::Null), &args.get(1..).unwrap_or(&[]).to_vec()[..]),
"safe_trade" => self.safe_trade(args.get(0).cloned().unwrap_or(crate::Value::Null), &args.get(1..).unwrap_or(&[]).to_vec()[..]),
"select_network_code_from_unified_networks" => self.select_network_code_from_unified_networks(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)),
"select_network_id_from_raw_networks" => self.select_network_id_from_raw_networks(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)),
"select_network_key_from_networks" => self.select_network_key_from_networks(args.get(0).cloned().unwrap_or(crate::Value::Null), args.get(1).cloned().unwrap_or(crate::Value::Null), args.get(2).cloned().unwrap_or(crate::Value::Null), &args.get(3..).unwrap_or(&[]).to_vec()[..]),
"set_headers" => self.set_headers(args.get(0).cloned().unwrap_or(crate::Value::Null)),
"set_leverage" => self.set_leverage(args.get(0).cloned().unwrap_or(crate::Value::Null), &args.get(1..).unwrap_or(&[]).to_vec()[..]).await,
"set_margin" => self.set_margin(args.get(0).cloned().unwrap_or(crate::Value::Null), args.get(1).cloned().unwrap_or(crate::Value::Null), &args.get(2..).unwrap_or(&[]).to_vec()[..]).await,
"set_margin_mode" => self.set_margin_mode(args.get(0).cloned().unwrap_or(crate::Value::Null), &args.get(1..).unwrap_or(&[]).to_vec()[..]).await,
"set_markets" => self.set_markets(args.get(0).cloned().unwrap_or(crate::Value::Null), &args.get(1..).unwrap_or(&[]).to_vec()[..]),
"set_markets_from_exchange" => self.set_markets_from_exchange(args.get(0).cloned().unwrap_or(crate::Value::Null)),
"set_position_mode" => self.set_position_mode(args.get(0).cloned().unwrap_or(crate::Value::Null), &args.get(1..).unwrap_or(&[]).to_vec()[..]).await,
"set_take_profit_and_stop_loss_params" => self.set_take_profit_and_stop_loss_params(args.get(0).cloned().unwrap_or(crate::Value::Null), args.get(1).cloned().unwrap_or(crate::Value::Null), args.get(2).cloned().unwrap_or(crate::Value::Null), args.get(3).cloned().unwrap_or(crate::Value::Null), &args.get(4..).unwrap_or(&[]).to_vec()[..]),
"sign" => <Self as crate::exchange_generated::ExchangeBase>::sign(self, args.get(0).cloned().unwrap_or(crate::Value::Null), &args.get(1..).unwrap_or(&[]).to_vec()[..]),
"sign_in" => self.sign_in(&args.get(0..).unwrap_or(&[]).to_vec()[..]).await,
"sort_cursor_paginated_result" => self.sort_cursor_paginated_result(args.get(0).cloned().unwrap_or(crate::Value::Null)),
"string_to_base16" => self.string_to_base16(args.get(0).cloned().unwrap_or(crate::Value::Null)),
"symbol" => self.symbol(args.get(0).cloned().unwrap_or(crate::Value::Null)),
"timeframe_from_milliseconds" => self.timeframe_from_milliseconds(args.get(0).cloned().unwrap_or(crate::Value::Null)),
"transfer" => self.transfer(args.get(0).cloned().unwrap_or(crate::Value::Null), args.get(1).cloned().unwrap_or(crate::Value::Null), args.get(2).cloned().unwrap_or(crate::Value::Null), args.get(3).cloned().unwrap_or(crate::Value::Null), &args.get(4..).unwrap_or(&[]).to_vec()[..]).await,
"un_watch_bids_asks" => self.un_watch_bids_asks(&args.get(0..).unwrap_or(&[]).to_vec()[..]).await,
"un_watch_funding_rate" => self.un_watch_funding_rate(args.get(0).cloned().unwrap_or(crate::Value::Null), &args.get(1..).unwrap_or(&[]).to_vec()[..]).await,
"un_watch_funding_rates" => self.un_watch_funding_rates(&args.get(0..).unwrap_or(&[]).to_vec()[..]).await,
"un_watch_mark_price" => self.un_watch_mark_price(args.get(0).cloned().unwrap_or(crate::Value::Null), &args.get(1..).unwrap_or(&[]).to_vec()[..]).await,
"un_watch_mark_prices" => self.un_watch_mark_prices(&args.get(0..).unwrap_or(&[]).to_vec()[..]).await,
"un_watch_my_trades" => self.un_watch_my_trades(&args.get(0..).unwrap_or(&[]).to_vec()[..]).await,
"un_watch_ohlcv" => self.un_watch_ohlcv(args.get(0).cloned().unwrap_or(crate::Value::Null), &args.get(1..).unwrap_or(&[]).to_vec()[..]).await,
"un_watch_ohlcv_for_symbols" => self.un_watch_ohlcv_for_symbols(args.get(0).cloned().unwrap_or(crate::Value::Null), &args.get(1..).unwrap_or(&[]).to_vec()[..]).await,
"un_watch_order_book" => self.un_watch_order_book(args.get(0).cloned().unwrap_or(crate::Value::Null), &args.get(1..).unwrap_or(&[]).to_vec()[..]).await,
"un_watch_order_book_for_symbols" => self.un_watch_order_book_for_symbols(args.get(0).cloned().unwrap_or(crate::Value::Null), &args.get(1..).unwrap_or(&[]).to_vec()[..]).await,
"un_watch_orders" => self.un_watch_orders(&args.get(0..).unwrap_or(&[]).to_vec()[..]).await,
"un_watch_positions" => self.un_watch_positions(&args.get(0..).unwrap_or(&[]).to_vec()[..]).await,
"un_watch_ticker" => self.un_watch_ticker(args.get(0).cloned().unwrap_or(crate::Value::Null), &args.get(1..).unwrap_or(&[]).to_vec()[..]).await,
"un_watch_tickers" => self.un_watch_tickers(&args.get(0..).unwrap_or(&[]).to_vec()[..]).await,
"un_watch_trades" => self.un_watch_trades(args.get(0).cloned().unwrap_or(crate::Value::Null), &args.get(1..).unwrap_or(&[]).to_vec()[..]).await,
"un_watch_trades_for_symbols" => self.un_watch_trades_for_symbols(args.get(0).cloned().unwrap_or(crate::Value::Null), &args.get(1..).unwrap_or(&[]).to_vec()[..]).await,
"url_encoder_for_proxy_url" => self.url_encoder_for_proxy_url(args.get(0).cloned().unwrap_or(crate::Value::Null)),
"watch_balance" => self.watch_balance(&args.get(0..).unwrap_or(&[]).to_vec()[..]).await,
"watch_bids_asks" => self.watch_bids_asks(&args.get(0..).unwrap_or(&[]).to_vec()[..]).await,
"watch_funding_rate" => self.watch_funding_rate(args.get(0).cloned().unwrap_or(crate::Value::Null), &args.get(1..).unwrap_or(&[]).to_vec()[..]).await,
"watch_funding_rates" => self.watch_funding_rates(&args.get(0..).unwrap_or(&[]).to_vec()[..]).await,
"watch_funding_rates_for_symbols" => self.watch_funding_rates_for_symbols(args.get(0).cloned().unwrap_or(crate::Value::Null), &args.get(1..).unwrap_or(&[]).to_vec()[..]).await,
"watch_liquidations" => self.watch_liquidations(args.get(0).cloned().unwrap_or(crate::Value::Null), &args.get(1..).unwrap_or(&[]).to_vec()[..]).await,
"watch_liquidations_for_symbols" => self.watch_liquidations_for_symbols(args.get(0).cloned().unwrap_or(crate::Value::Null), &args.get(1..).unwrap_or(&[]).to_vec()[..]).await,
"watch_mark_price" => self.watch_mark_price(args.get(0).cloned().unwrap_or(crate::Value::Null), &args.get(1..).unwrap_or(&[]).to_vec()[..]).await,
"watch_mark_prices" => self.watch_mark_prices(&args.get(0..).unwrap_or(&[]).to_vec()[..]).await,
"watch_my_liquidations" => self.watch_my_liquidations(args.get(0).cloned().unwrap_or(crate::Value::Null), &args.get(1..).unwrap_or(&[]).to_vec()[..]).await,
"watch_my_liquidations_for_symbols" => self.watch_my_liquidations_for_symbols(args.get(0).cloned().unwrap_or(crate::Value::Null), &args.get(1..).unwrap_or(&[]).to_vec()[..]).await,
"watch_my_trades" => self.watch_my_trades(&args.get(0..).unwrap_or(&[]).to_vec()[..]).await,
"watch_my_trades_for_symbols" => self.watch_my_trades_for_symbols(args.get(0).cloned().unwrap_or(crate::Value::Null), &args.get(1..).unwrap_or(&[]).to_vec()[..]).await,
"watch_ohlcv" => self.watch_ohlcv(args.get(0).cloned().unwrap_or(crate::Value::Null), &args.get(1..).unwrap_or(&[]).to_vec()[..]).await,
"watch_ohlcv_for_symbols" => self.watch_ohlcv_for_symbols(args.get(0).cloned().unwrap_or(crate::Value::Null), &args.get(1..).unwrap_or(&[]).to_vec()[..]).await,
"watch_order_book" => self.watch_order_book(args.get(0).cloned().unwrap_or(crate::Value::Null), &args.get(1..).unwrap_or(&[]).to_vec()[..]).await,
"watch_order_book_for_symbols" => self.watch_order_book_for_symbols(args.get(0).cloned().unwrap_or(crate::Value::Null), &args.get(1..).unwrap_or(&[]).to_vec()[..]).await,
"watch_orders" => self.watch_orders(&args.get(0..).unwrap_or(&[]).to_vec()[..]).await,
"watch_orders_for_symbols" => self.watch_orders_for_symbols(args.get(0).cloned().unwrap_or(crate::Value::Null), &args.get(1..).unwrap_or(&[]).to_vec()[..]).await,
"watch_position" => self.watch_position(&args.get(0..).unwrap_or(&[]).to_vec()[..]).await,
"watch_position_for_symbols" => self.watch_position_for_symbols(&args.get(0..).unwrap_or(&[]).to_vec()[..]).await,
"watch_positions" => self.watch_positions(&args.get(0..).unwrap_or(&[]).to_vec()[..]).await,
"watch_ticker" => self.watch_ticker(args.get(0).cloned().unwrap_or(crate::Value::Null), &args.get(1..).unwrap_or(&[]).to_vec()[..]).await,
"watch_tickers" => self.watch_tickers(&args.get(0..).unwrap_or(&[]).to_vec()[..]).await,
"watch_trades" => self.watch_trades(args.get(0).cloned().unwrap_or(crate::Value::Null), &args.get(1..).unwrap_or(&[]).to_vec()[..]).await,
"watch_trades_for_symbols" => self.watch_trades_for_symbols(args.get(0).cloned().unwrap_or(crate::Value::Null), &args.get(1..).unwrap_or(&[]).to_vec()[..]).await,
"withdraw" => self.withdraw(args.get(0).cloned().unwrap_or(crate::Value::Null), args.get(1).cloned().unwrap_or(crate::Value::Null), args.get(2).cloned().unwrap_or(crate::Value::Null), &args.get(3..).unwrap_or(&[]).to_vec()[..]).await,
"withdraw_ws" => self.withdraw_ws(args.get(0).cloned().unwrap_or(crate::Value::Null), args.get(1).cloned().unwrap_or(crate::Value::Null), args.get(2).cloned().unwrap_or(crate::Value::Null), &args.get(3..).unwrap_or(&[]).to_vec()[..]).await,
// Implicit-API endpoints (`publicGetX`) exist only as inherent
// methods on the venue's `<id>_api.rs`, which no name-based
// dispatch arm covers — a static-request test named after one
// (bingx's accountV1PrivateGetAccountApiRestrictions) otherwise
// computes a null url. Route them the way those wrappers do.
// Guarded on the api block so a genuinely unknown name still
// returns Null rather than panicking inside call_method.
_ => {
if self.internals.implicit_api.is_empty() {
self.build_implicit_api();
}
if self.internals.implicit_api.contains_key(method) {
self.call_method(crate::Value::Str(method.to_string()), &args[..]).await
} else {
crate::Value::Null
}
}
}
})
}
}