Skip to main content

ccxt_common/
exchange_generated.rs

1// PLEASE DO NOT EDIT THIS FILE, IT IS GENERATED AND WILL BE OVERWRITTEN:
2// https://github.com/ccxt/ccxt/blob/master/CONTRIBUTING.md#how-to-contribute-code
3
4// Generated from `ts/src/base/Exchange.ts` — methods below the
5// "METHODS BELOW THIS LINE ARE TRANSPILED" marker. Everything
6// above the marker is hand-written (src/exchange.rs / src/prediction_exchange.rs).
7
8#![allow(unused, non_snake_case, clippy::all)]
9
10use crate::Value;
11use crate::ExchangeError;
12use crate::exchange::Exchange;
13use crate::exchange::ExchangeRuntime;
14use crate::exchange::CallDynamicChecked;
15
16
17
18use crate::runtime::*;
19
20pub trait ExchangeBase:
21    crate::exchange::DerivedExchange
22    + std::ops::DerefMut<Target = Exchange>
23    + Send
24    + Sized
25{
26    /// Dispatch a snake_case method name to this core's inherent async
27    /// methods, falling through to `call_dynamic_base` for base-only methods.
28    /// The single required method — every override reaches the core statically.
29    fn call_dynamic<'a>(&'a mut self, method: &'a str, args: Vec<crate::Value>)
30        -> std::pin::Pin<Box<dyn std::future::Future<Output = crate::Value> + Send + 'a>>;
31
32    /// Route `method(args)` to the derived override by name, with a per-method
33    /// re-entry guard (so a base method calling its own name falls through to
34    /// the base body instead of looping). Replaces `Exchange::dispatch_to_derived`
35    /// — no stored pointer; `call_dynamic` is a static trait call.
36    fn dispatch_to_derived<'a>(&'a mut self, method: &'a str, args: Vec<crate::Value>)
37        -> std::pin::Pin<Box<dyn std::future::Future<Output = Option<crate::Value>> + Send + 'a>>
38    {
39        Box::pin(async move {
40            if !self.dispatch_guard_enter(method) { return None; }
41            let out = futures::FutureExt::catch_unwind(
42                std::panic::AssertUnwindSafe(self.call_dynamic(method, args))
43            ).await;
44            self.dispatch_guard_exit();
45            match out {
46                Ok(v)  => Some(v),
47                Err(p) => std::panic::resume_unwind(p),
48            }
49        })
50    }
51
52    /// `isDictionary(value)` — hand-provided base method. The ast-transpiler
53    /// drops `Exchange.ts`'s `typeof value === 'object'` body, so supply it here
54    /// as a trait default reachable by every Core (used across the base +
55    /// derived exchanges).
56    fn is_dictionary(&self, value: crate::Value) -> crate::Value {
57        crate::Value::Bool(
58            !crate::runtime::is_equal(&value, &crate::Value::Null)
59            && crate::runtime::is_object(&value)
60            && !crate::runtime::is_array(&value)
61        )
62    }
63
64
65    fn describe(&self) -> Value {
66        return Value::Map({
67    let mut m = indexmap::IndexMap::new();
68        m.insert("id".to_string(), self.id.clone());
69        m.insert("name".to_string(), self.name.clone());
70        m.insert("countries".to_string(), self.countries.clone());
71        m.insert("enableRateLimit".to_string(), self.enableRateLimit.clone());
72        m.insert("rateLimit".to_string(), self.rateLimit.clone());
73        m.insert("rateLimiterAlgorithm".to_string(), self.rateLimiterAlgorithm.clone());
74        m.insert("timeout".to_string(), self.timeout.clone());
75        m.insert("certified".to_string(), self.certified.clone());
76        m.insert("pro".to_string(), self.pro.clone());
77        m.insert("alias".to_string(), self.alias.clone());
78        m.insert("dex".to_string(), Value::Bool(false));
79        m.insert("has".to_string(), Value::Map({
80    let mut m = indexmap::IndexMap::new();
81        m.insert("publicAPI".to_string(), Value::Bool(true));
82        m.insert("privateAPI".to_string(), Value::Bool(true));
83        m.insert("CORS".to_string(), Value::Null);
84        m.insert("sandbox".to_string(), Value::Null);
85        m.insert("spot".to_string(), Value::Null);
86        m.insert("margin".to_string(), Value::Null);
87        m.insert("swap".to_string(), Value::Null);
88        m.insert("future".to_string(), Value::Null);
89        m.insert("option".to_string(), Value::Null);
90        m.insert("index".to_string(), Value::Null);
91        m.insert("addMargin".to_string(), Value::Null);
92        m.insert("borrowCrossMargin".to_string(), Value::Null);
93        m.insert("borrowIsolatedMargin".to_string(), Value::Null);
94        m.insert("borrowMargin".to_string(), Value::Null);
95        m.insert("cancelAllOrders".to_string(), Value::Null);
96        m.insert("cancelAllOrdersWs".to_string(), Value::Null);
97        m.insert("cancelOrder".to_string(), Value::Null);
98        m.insert("cancelOrderWithClientOrderId".to_string(), Value::Null);
99        m.insert("cancelOrderWs".to_string(), Value::Null);
100        m.insert("cancelOrders".to_string(), Value::Null);
101        m.insert("cancelOrdersWithClientOrderId".to_string(), Value::Null);
102        m.insert("cancelOrdersWs".to_string(), Value::Null);
103        m.insert("closeAllPositions".to_string(), Value::Null);
104        m.insert("closePosition".to_string(), Value::Null);
105        m.insert("createDepositAddress".to_string(), Value::Null);
106        m.insert("createLimitBuyOrder".to_string(), Value::Null);
107        m.insert("createLimitBuyOrderWs".to_string(), Value::Null);
108        m.insert("createLimitOrder".to_string(), Value::Null);
109        m.insert("createLimitOrderWs".to_string(), Value::Null);
110        m.insert("createLimitSellOrder".to_string(), Value::Null);
111        m.insert("createLimitSellOrderWs".to_string(), Value::Null);
112        m.insert("createMarketBuyOrder".to_string(), Value::Null);
113        m.insert("createMarketBuyOrderWs".to_string(), Value::Null);
114        m.insert("createMarketBuyOrderWithCost".to_string(), Value::Null);
115        m.insert("createMarketBuyOrderWithCostWs".to_string(), Value::Null);
116        m.insert("createMarketOrder".to_string(), Value::Null);
117        m.insert("createMarketOrderWs".to_string(), Value::Null);
118        m.insert("createMarketOrderWithCost".to_string(), Value::Null);
119        m.insert("createMarketOrderWithCostWs".to_string(), Value::Null);
120        m.insert("createMarketSellOrder".to_string(), Value::Null);
121        m.insert("createMarketSellOrderWs".to_string(), Value::Null);
122        m.insert("createMarketSellOrderWithCost".to_string(), Value::Null);
123        m.insert("createMarketSellOrderWithCostWs".to_string(), Value::Null);
124        m.insert("createOrder".to_string(), Value::Null);
125        m.insert("createOrderWs".to_string(), Value::Null);
126        m.insert("createOrders".to_string(), Value::Null);
127        m.insert("createOrderWithTakeProfitAndStopLoss".to_string(), Value::Null);
128        m.insert("createOrderWithTakeProfitAndStopLossWs".to_string(), Value::Null);
129        m.insert("createPostOnlyOrder".to_string(), Value::Null);
130        m.insert("createPostOnlyOrderWs".to_string(), Value::Null);
131        m.insert("createReduceOnlyOrder".to_string(), Value::Null);
132        m.insert("createReduceOnlyOrderWs".to_string(), Value::Null);
133        m.insert("createStopLimitOrder".to_string(), Value::Null);
134        m.insert("createStopLimitOrderWs".to_string(), Value::Null);
135        m.insert("createStopLossOrder".to_string(), Value::Null);
136        m.insert("createStopLossOrderWs".to_string(), Value::Null);
137        m.insert("createStopMarketOrder".to_string(), Value::Null);
138        m.insert("createStopMarketOrderWs".to_string(), Value::Null);
139        m.insert("createStopOrder".to_string(), Value::Null);
140        m.insert("createStopOrderWs".to_string(), Value::Null);
141        m.insert("createTakeProfitOrder".to_string(), Value::Null);
142        m.insert("createTakeProfitOrderWs".to_string(), Value::Null);
143        m.insert("createTrailingAmountOrder".to_string(), Value::Null);
144        m.insert("createTrailingAmountOrderWs".to_string(), Value::Null);
145        m.insert("createTrailingPercentOrder".to_string(), Value::Null);
146        m.insert("createTrailingPercentOrderWs".to_string(), Value::Null);
147        m.insert("createTriggerOrder".to_string(), Value::Null);
148        m.insert("createTriggerOrderWs".to_string(), Value::Null);
149        m.insert("deposit".to_string(), Value::Null);
150        m.insert("editOrder".to_string(), Value::Str("emulated".into()));
151        m.insert("editOrderWithClientOrderId".to_string(), Value::Null);
152        m.insert("editOrders".to_string(), Value::Null);
153        m.insert("editOrderWs".to_string(), Value::Null);
154        m.insert("fetchAccounts".to_string(), Value::Null);
155        m.insert("fetchADLRank".to_string(), Value::Null);
156        m.insert("fetchBalance".to_string(), Value::Null);
157        m.insert("fetchBalanceWs".to_string(), Value::Null);
158        m.insert("fetchBidsAsks".to_string(), Value::Null);
159        m.insert("fetchBorrowInterest".to_string(), Value::Null);
160        m.insert("fetchBorrowRate".to_string(), Value::Null);
161        m.insert("fetchBorrowRateHistories".to_string(), Value::Null);
162        m.insert("fetchBorrowRateHistory".to_string(), Value::Null);
163        m.insert("fetchBorrowRates".to_string(), Value::Null);
164        m.insert("fetchBorrowRatesPerSymbol".to_string(), Value::Null);
165        m.insert("fetchCanceledAndClosedOrders".to_string(), Value::Null);
166        m.insert("fetchCanceledOrders".to_string(), Value::Null);
167        m.insert("fetchClosedOrder".to_string(), Value::Null);
168        m.insert("fetchClosedOrders".to_string(), Value::Null);
169        m.insert("fetchClosedOrdersWs".to_string(), Value::Null);
170        m.insert("fetchConvertCurrencies".to_string(), Value::Null);
171        m.insert("fetchConvertQuote".to_string(), Value::Null);
172        m.insert("fetchConvertTrade".to_string(), Value::Null);
173        m.insert("fetchConvertTradeHistory".to_string(), Value::Null);
174        m.insert("fetchCrossBorrowRate".to_string(), Value::Null);
175        m.insert("fetchCrossBorrowRates".to_string(), Value::Null);
176        m.insert("fetchCurrencies".to_string(), Value::Str("emulated".into()));
177        m.insert("fetchCurrenciesWs".to_string(), Value::Str("emulated".into()));
178        m.insert("fetchDeposit".to_string(), Value::Null);
179        m.insert("fetchDepositAddress".to_string(), Value::Null);
180        m.insert("fetchDepositAddresses".to_string(), Value::Null);
181        m.insert("fetchDepositAddressesByNetwork".to_string(), Value::Null);
182        m.insert("fetchDeposits".to_string(), Value::Null);
183        m.insert("fetchDepositsWithdrawals".to_string(), Value::Null);
184        m.insert("fetchDepositsWs".to_string(), Value::Null);
185        m.insert("fetchDepositWithdrawFee".to_string(), Value::Null);
186        m.insert("fetchDepositWithdrawFees".to_string(), Value::Null);
187        m.insert("fetchFundingHistory".to_string(), Value::Null);
188        m.insert("fetchFundingRate".to_string(), Value::Null);
189        m.insert("fetchFundingRateHistory".to_string(), Value::Null);
190        m.insert("fetchFundingInterval".to_string(), Value::Null);
191        m.insert("fetchFundingIntervals".to_string(), Value::Null);
192        m.insert("fetchFundingRates".to_string(), Value::Null);
193        m.insert("fetchGreeks".to_string(), Value::Null);
194        m.insert("fetchIndexOHLCV".to_string(), Value::Null);
195        m.insert("fetchIsolatedBorrowRate".to_string(), Value::Null);
196        m.insert("fetchIsolatedBorrowRates".to_string(), Value::Null);
197        m.insert("fetchMarginAdjustmentHistory".to_string(), Value::Null);
198        m.insert("fetchIsolatedPositions".to_string(), Value::Null);
199        m.insert("fetchL2OrderBook".to_string(), Value::Null);
200        m.insert("fetchL3OrderBook".to_string(), Value::Null);
201        m.insert("fetchLastPrices".to_string(), Value::Null);
202        m.insert("fetchLedger".to_string(), Value::Null);
203        m.insert("fetchLedgerEntry".to_string(), Value::Null);
204        m.insert("fetchLeverage".to_string(), Value::Null);
205        m.insert("fetchLeverages".to_string(), Value::Null);
206        m.insert("fetchLeverageTiers".to_string(), Value::Null);
207        m.insert("fetchLiquidations".to_string(), Value::Null);
208        m.insert("fetchLongShortRatio".to_string(), Value::Null);
209        m.insert("fetchLongShortRatioHistory".to_string(), Value::Null);
210        m.insert("fetchMarginMode".to_string(), Value::Null);
211        m.insert("fetchMarginModes".to_string(), Value::Null);
212        m.insert("fetchMarketLeverageTiers".to_string(), Value::Null);
213        m.insert("fetchMarkets".to_string(), Value::Bool(true));
214        m.insert("fetchMarketsWs".to_string(), Value::Null);
215        m.insert("fetchMarkOHLCV".to_string(), Value::Null);
216        m.insert("fetchMyLiquidations".to_string(), Value::Null);
217        m.insert("fetchMySettlementHistory".to_string(), Value::Null);
218        m.insert("fetchMyTrades".to_string(), Value::Null);
219        m.insert("fetchMyTradesWs".to_string(), Value::Null);
220        m.insert("fetchOHLCV".to_string(), Value::Null);
221        m.insert("fetchOHLCVWs".to_string(), Value::Null);
222        m.insert("fetchOpenInterest".to_string(), Value::Null);
223        m.insert("fetchOpenInterests".to_string(), Value::Null);
224        m.insert("fetchOpenInterestHistory".to_string(), Value::Null);
225        m.insert("fetchOpenOrder".to_string(), Value::Null);
226        m.insert("fetchOpenOrders".to_string(), Value::Null);
227        m.insert("fetchOpenOrdersWs".to_string(), Value::Null);
228        m.insert("fetchOption".to_string(), Value::Null);
229        m.insert("fetchOptionChain".to_string(), Value::Null);
230        m.insert("fetchOrder".to_string(), Value::Null);
231        m.insert("fetchOrderWithClientOrderId".to_string(), Value::Null);
232        m.insert("fetchOrderBook".to_string(), Value::Null);
233        m.insert("fetchOrderBooks".to_string(), Value::Null);
234        m.insert("fetchOrderBookWs".to_string(), Value::Null);
235        m.insert("fetchOrders".to_string(), Value::Null);
236        m.insert("fetchOrdersByStatus".to_string(), Value::Null);
237        m.insert("fetchOrdersWs".to_string(), Value::Null);
238        m.insert("fetchOrderTrades".to_string(), Value::Null);
239        m.insert("fetchOrderWs".to_string(), Value::Null);
240        m.insert("fetchPosition".to_string(), Value::Null);
241        m.insert("fetchPositionADLRank".to_string(), Value::Null);
242        m.insert("fetchPositionsADLRank".to_string(), Value::Null);
243        m.insert("fetchPositionHistory".to_string(), Value::Null);
244        m.insert("fetchPositionsHistory".to_string(), Value::Null);
245        m.insert("fetchPositionWs".to_string(), Value::Null);
246        m.insert("fetchPositionMode".to_string(), Value::Null);
247        m.insert("fetchPositions".to_string(), Value::Null);
248        m.insert("fetchPositionsWs".to_string(), Value::Null);
249        m.insert("fetchPositionsForSymbol".to_string(), Value::Null);
250        m.insert("fetchPositionsForSymbolWs".to_string(), Value::Null);
251        m.insert("fetchPositionsRisk".to_string(), Value::Null);
252        m.insert("fetchPremiumIndexOHLCV".to_string(), Value::Null);
253        m.insert("fetchSettlementHistory".to_string(), Value::Null);
254        m.insert("fetchStatus".to_string(), Value::Null);
255        m.insert("fetchTicker".to_string(), Value::Str("emulated".into()));
256        m.insert("fetchTickerWs".to_string(), Value::Null);
257        m.insert("fetchTickers".to_string(), Value::Null);
258        m.insert("fetchMarkPrices".to_string(), Value::Null);
259        m.insert("fetchTickersWs".to_string(), Value::Null);
260        m.insert("fetchTime".to_string(), Value::Null);
261        m.insert("fetchTrades".to_string(), Value::Null);
262        m.insert("fetchTradesWs".to_string(), Value::Null);
263        m.insert("fetchTradingFee".to_string(), Value::Null);
264        m.insert("fetchTradingFees".to_string(), Value::Null);
265        m.insert("fetchTradingFeesWs".to_string(), Value::Null);
266        m.insert("fetchTradingLimits".to_string(), Value::Null);
267        m.insert("fetchTransactionFee".to_string(), Value::Null);
268        m.insert("fetchTransactionFees".to_string(), Value::Null);
269        m.insert("fetchTransactions".to_string(), Value::Null);
270        m.insert("fetchTransfer".to_string(), Value::Null);
271        m.insert("fetchTransfers".to_string(), Value::Null);
272        m.insert("fetchUnderlyingAssets".to_string(), Value::Null);
273        m.insert("fetchVolatilityHistory".to_string(), Value::Null);
274        m.insert("fetchWithdrawAddresses".to_string(), Value::Null);
275        m.insert("fetchWithdrawal".to_string(), Value::Null);
276        m.insert("fetchWithdrawals".to_string(), Value::Null);
277        m.insert("fetchWithdrawalsWs".to_string(), Value::Null);
278        m.insert("fetchWithdrawalWhitelist".to_string(), Value::Null);
279        m.insert("reduceMargin".to_string(), Value::Null);
280        m.insert("repayCrossMargin".to_string(), Value::Null);
281        m.insert("repayIsolatedMargin".to_string(), Value::Null);
282        m.insert("setLeverage".to_string(), Value::Null);
283        m.insert("setMargin".to_string(), Value::Null);
284        m.insert("setMarginMode".to_string(), Value::Null);
285        m.insert("setPositionMode".to_string(), Value::Null);
286        m.insert("signIn".to_string(), Value::Null);
287        m.insert("transfer".to_string(), Value::Null);
288        m.insert("watchBalance".to_string(), Value::Null);
289        m.insert("watchMyTrades".to_string(), Value::Null);
290        m.insert("watchOHLCV".to_string(), Value::Null);
291        m.insert("watchOHLCVForSymbols".to_string(), Value::Null);
292        m.insert("watchOrderBook".to_string(), Value::Null);
293        m.insert("watchBidsAsks".to_string(), Value::Null);
294        m.insert("watchOrderBookForSymbols".to_string(), Value::Null);
295        m.insert("watchOrders".to_string(), Value::Null);
296        m.insert("watchOrdersForSymbols".to_string(), Value::Null);
297        m.insert("watchPosition".to_string(), Value::Null);
298        m.insert("watchPositions".to_string(), Value::Null);
299        m.insert("watchStatus".to_string(), Value::Null);
300        m.insert("watchTicker".to_string(), Value::Null);
301        m.insert("watchTickers".to_string(), Value::Null);
302        m.insert("watchTrades".to_string(), Value::Null);
303        m.insert("watchTradesForSymbols".to_string(), Value::Null);
304        m.insert("watchLiquidations".to_string(), Value::Null);
305        m.insert("watchLiquidationsForSymbols".to_string(), Value::Null);
306        m.insert("watchMyLiquidations".to_string(), Value::Null);
307        m.insert("unWatchOrders".to_string(), Value::Null);
308        m.insert("unWatchTrades".to_string(), Value::Null);
309        m.insert("unWatchTradesForSymbols".to_string(), Value::Null);
310        m.insert("unWatchOHLCVForSymbols".to_string(), Value::Null);
311        m.insert("unWatchOrderBookForSymbols".to_string(), Value::Null);
312        m.insert("unWatchPositions".to_string(), Value::Null);
313        m.insert("unWatchOrderBook".to_string(), Value::Null);
314        m.insert("unWatchTickers".to_string(), Value::Null);
315        m.insert("unWatchMyTrades".to_string(), Value::Null);
316        m.insert("unWatchTicker".to_string(), Value::Null);
317        m.insert("unWatchOHLCV".to_string(), Value::Null);
318        m.insert("watchMyLiquidationsForSymbols".to_string(), Value::Null);
319        m.insert("withdraw".to_string(), Value::Null);
320        m.insert("ws".to_string(), Value::Null);
321    m
322}));
323        m.insert("urls".to_string(), Value::Map({
324    let mut m = indexmap::IndexMap::new();
325        m.insert("logo".to_string(), Value::Null);
326        m.insert("api".to_string(), Value::Null);
327        m.insert("test".to_string(), Value::Null);
328        m.insert("www".to_string(), Value::Null);
329        m.insert("doc".to_string(), Value::Null);
330        m.insert("api_management".to_string(), Value::Null);
331        m.insert("fees".to_string(), Value::Null);
332        m.insert("referral".to_string(), Value::Null);
333    m
334}));
335        m.insert("api".to_string(), Value::Null);
336        m.insert("requiredCredentials".to_string(), Value::Map({
337    let mut m = indexmap::IndexMap::new();
338        m.insert("apiKey".to_string(), Value::Bool(true));
339        m.insert("secret".to_string(), Value::Bool(true));
340        m.insert("uid".to_string(), Value::Bool(false));
341        m.insert("accountId".to_string(), Value::Bool(false));
342        m.insert("login".to_string(), Value::Bool(false));
343        m.insert("password".to_string(), Value::Bool(false));
344        m.insert("twofa".to_string(), Value::Bool(false));
345        m.insert("privateKey".to_string(), Value::Bool(false));
346        m.insert("walletAddress".to_string(), Value::Bool(false));
347        m.insert("token".to_string(), Value::Bool(false));
348    m
349}));
350        m.insert("markets".to_string(), Value::Null);
351        m.insert("currencies".to_string(), Value::Map({
352    let mut m = indexmap::IndexMap::new();
353    m
354}));
355        m.insert("timeframes".to_string(), Value::Null);
356        m.insert("fees".to_string(), Value::Map({
357    let mut m = indexmap::IndexMap::new();
358        m.insert("trading".to_string(), Value::Map({
359    let mut m = indexmap::IndexMap::new();
360        m.insert("tierBased".to_string(), Value::Null);
361        m.insert("percentage".to_string(), Value::Null);
362        m.insert("taker".to_string(), Value::Null);
363        m.insert("maker".to_string(), Value::Null);
364    m
365}));
366        m.insert("funding".to_string(), Value::Map({
367    let mut m = indexmap::IndexMap::new();
368        m.insert("tierBased".to_string(), Value::Null);
369        m.insert("percentage".to_string(), Value::Null);
370        m.insert("withdraw".to_string(), Value::Map({
371    let mut m = indexmap::IndexMap::new();
372    m
373}));
374        m.insert("deposit".to_string(), Value::Map({
375    let mut m = indexmap::IndexMap::new();
376    m
377}));
378    m
379}));
380    m
381}));
382        m.insert("status".to_string(), Value::Map({
383    let mut m = indexmap::IndexMap::new();
384        m.insert("status".to_string(), Value::Str("ok".into()));
385        m.insert("updated".to_string(), Value::Null);
386        m.insert("eta".to_string(), Value::Null);
387        m.insert("url".to_string(), Value::Null);
388        m.insert("info".to_string(), Value::Null);
389    m
390}));
391        m.insert("exceptions".to_string(), Value::Null);
392        m.insert("httpExceptions".to_string(), Value::Map({
393    let mut m = indexmap::IndexMap::new();
394        m.insert("422".to_string(), Value::Str("ExchangeError".into()).clone());
395        m.insert("418".to_string(), Value::Str("DDoSProtection".into()).clone());
396        m.insert("429".to_string(), Value::Str("RateLimitExceeded".into()).clone());
397        m.insert("404".to_string(), Value::Str("ExchangeNotAvailable".into()).clone());
398        m.insert("409".to_string(), Value::Str("ExchangeNotAvailable".into()).clone());
399        m.insert("410".to_string(), Value::Str("ExchangeNotAvailable".into()).clone());
400        m.insert("451".to_string(), Value::Str("ExchangeNotAvailable".into()).clone());
401        m.insert("500".to_string(), Value::Str("ExchangeNotAvailable".into()).clone());
402        m.insert("501".to_string(), Value::Str("ExchangeNotAvailable".into()).clone());
403        m.insert("502".to_string(), Value::Str("ExchangeNotAvailable".into()).clone());
404        m.insert("520".to_string(), Value::Str("ExchangeNotAvailable".into()).clone());
405        m.insert("521".to_string(), Value::Str("ExchangeNotAvailable".into()).clone());
406        m.insert("522".to_string(), Value::Str("ExchangeNotAvailable".into()).clone());
407        m.insert("525".to_string(), Value::Str("ExchangeNotAvailable".into()).clone());
408        m.insert("526".to_string(), Value::Str("ExchangeNotAvailable".into()).clone());
409        m.insert("400".to_string(), Value::Str("ExchangeNotAvailable".into()).clone());
410        m.insert("403".to_string(), Value::Str("ExchangeNotAvailable".into()).clone());
411        m.insert("405".to_string(), Value::Str("ExchangeNotAvailable".into()).clone());
412        m.insert("503".to_string(), Value::Str("ExchangeNotAvailable".into()).clone());
413        m.insert("530".to_string(), Value::Str("ExchangeNotAvailable".into()).clone());
414        m.insert("408".to_string(), Value::Str("RequestTimeout".into()).clone());
415        m.insert("504".to_string(), Value::Str("RequestTimeout".into()).clone());
416        m.insert("401".to_string(), Value::Str("AuthenticationError".into()).clone());
417        m.insert("407".to_string(), Value::Str("AuthenticationError".into()).clone());
418        m.insert("511".to_string(), Value::Str("AuthenticationError".into()).clone());
419    m
420}));
421        m.insert("commonCurrencies".to_string(), Value::Map({
422    let mut m = indexmap::IndexMap::new();
423        m.insert("XBT".to_string(), Value::Str("BTC".into()));
424        m.insert("BCHSV".to_string(), Value::Str("BSV".into()));
425    m
426}));
427        m.insert("precisionMode".to_string(), Value::Int(crate::runtime::TICK_SIZE));
428        m.insert("paddingMode".to_string(), Value::Int(crate::runtime::NO_PADDING));
429        m.insert("limits".to_string(), Value::Map({
430    let mut m = indexmap::IndexMap::new();
431        m.insert("leverage".to_string(), Value::Map({
432    let mut m = indexmap::IndexMap::new();
433        m.insert("min".to_string(), Value::Null);
434        m.insert("max".to_string(), Value::Null);
435    m
436}));
437        m.insert("amount".to_string(), Value::Map({
438    let mut m = indexmap::IndexMap::new();
439        m.insert("min".to_string(), Value::Null);
440        m.insert("max".to_string(), Value::Null);
441    m
442}));
443        m.insert("price".to_string(), Value::Map({
444    let mut m = indexmap::IndexMap::new();
445        m.insert("min".to_string(), Value::Null);
446        m.insert("max".to_string(), Value::Null);
447    m
448}));
449        m.insert("cost".to_string(), Value::Map({
450    let mut m = indexmap::IndexMap::new();
451        m.insert("min".to_string(), Value::Null);
452        m.insert("max".to_string(), Value::Null);
453    m
454}));
455    m
456}));
457        m.insert("rollingWindowSize".to_string(), Value::Int(60000));
458    m
459});
460
461    Value::Null
462}
463
464    fn clean_rest_data(&mut self) {
465        self.ids = Value::Null;
466        self.markets = Value::Null;
467        self.markets_by_id = Value::Null;
468        self.symbols = Value::from(vec![]);
469        self.codes = Value::Null;
470        { let __t = self.create_safe_dictionary(&[]); self.currencies = __t; }
471        self.currencies_by_id = Value::Null;
472        self.baseCurrencies = Value::Null;
473        self.quoteCurrencies = Value::Null;
474        self.last_http_response = Value::Null;
475        // this.last_json_response = undefined; // not unified prop
476        self.last_response_headers = Value::Null;
477        self.last_request_headers = Value::Null;
478}
479
480    fn clean_ws_data(&mut self) {
481        { let __t = self.create_safe_dictionary(&[Value::Bool(true)]); self.balance = __t; }
482        { let __t = self.create_safe_dictionary(&[Value::Bool(true)]); self.orderbooks = __t; }
483        { let __t = self.create_safe_dictionary(&[Value::Bool(true)]); self.tickers = __t; }
484        self.liquidations = Value::Null;
485        self.myLiquidations = Value::Null;
486        self.orders = Value::Null;
487        { let __t = self.create_safe_dictionary(&[Value::Bool(true)]); self.trades = __t; }
488        { let __t = self.create_safe_dictionary(&[]); self.transactions = __t; }
489        { let __t = self.create_safe_dictionary(&[Value::Bool(true)]); self.ohlcvs = __t; }
490        self.myTrades = Value::Null;
491        self.positions = Value::Null;
492}
493
494    fn safe_bool_n(&self, mut dictionaryOrList: Value, mut keys: Value, optional_args: &[Value]) -> Value {
495        let mut defaultValue = get_arg(optional_args, 0, Value::Null);
496        /*
497         * @ignore
498         * @method
499         * @description safely extract boolean value from dictionary or list
500         * @returns {bool | undefined}
501         */
502        let mut value: Value = self.safe_value_n(dictionaryOrList, keys, &[defaultValue.clone()]);
503        if matches!(&value, Value::Bool(_)) {
504            return value;
505        }
506        return defaultValue;
507
508    Value::Null
509}
510
511    fn safe_bool2(&self, mut dictionaryOrList: Value, mut key1: Value, mut key2: Value, optional_args: &[Value]) -> Value {
512        let mut defaultValue = get_arg(optional_args, 0, Value::Null);
513        /*
514         * @ignore
515         * @method
516         * @description safely extract boolean value from dictionary or list
517         * @returns {bool | undefined}
518         */
519        let mut value: Value = self.safe_value(dictionaryOrList.clone(), key1, &[]);
520        if matches!(&value, Value::Bool(_)) {
521            return value;
522        }
523        let mut value2: Value = self.safe_value(dictionaryOrList, key2, &[]);
524        if matches!(&value2, Value::Bool(_)) {
525            return value2;
526        }
527        return defaultValue;
528
529    Value::Null
530}
531
532    fn safe_bool(&self, mut dictionaryOrList: Value, mut key: Value, optional_args: &[Value]) -> Value {
533        let mut defaultValue = get_arg(optional_args, 0, Value::Null);
534        /*
535         * @ignore
536         * @method
537         * @description safely extract boolean value from dictionary or list
538         * @returns {bool | undefined}
539         */
540        let mut value: Value = self.safe_value(dictionaryOrList, key, &[defaultValue.clone()]);
541        if matches!(&value, Value::Bool(_)) {
542            return value;
543        }
544        return defaultValue;
545
546    Value::Null
547}
548
549    fn safe_dict_n(&self, mut dictionaryOrList: Value, mut keys: Value, optional_args: &[Value]) -> Value {
550        let mut defaultValue = get_arg(optional_args, 0, Value::Null);
551        /*
552         * @ignore
553         * @method
554         * @description safely extract a dictionary from dictionary or list
555         * @returns {object | undefined}
556         */
557        let mut value: Value = self.safe_value_n(dictionaryOrList, keys, &[defaultValue.clone()]);
558        if (value == Value::Null) {
559            return defaultValue;
560        }
561        if is_true(&self.is_dictionary(value.clone())) {
562            return value;
563        }
564        return defaultValue;
565
566    Value::Null
567}
568
569    fn safe_dict(&self, mut dictionaryOrList: Value, mut key: Value, optional_args: &[Value]) -> Value {
570        let mut defaultValue = get_arg(optional_args, 0, Value::Null);
571        /*
572         * @ignore
573         * @method
574         * @description safely extract a dictionary from dictionary or list
575         * @returns {object | undefined}
576         */
577        let mut value: Value = self.safe_value(dictionaryOrList, key, &[defaultValue.clone()]);
578        if (value == Value::Null) {
579            return defaultValue;
580        }
581        if is_true(&self.is_dictionary(value.clone())) {
582            return value;
583        }
584        return defaultValue;
585
586    Value::Null
587}
588
589    fn safe_dict2(&self, mut dictionaryOrList: Value, mut key1: Value, mut key2: Value, optional_args: &[Value]) -> Value {
590        let mut defaultValue = get_arg(optional_args, 0, Value::Null);
591        /*
592         * @ignore
593         * @method
594         * @description safely extract a dictionary from dictionary or list
595         * @returns {object | undefined}
596         */
597        let mut value: Value = self.safe_value(dictionaryOrList.clone(), key1, &[]);
598        if is_true(&self.is_dictionary(value.clone())) {
599            return value;
600        }
601        let mut value2: Value = self.safe_value(dictionaryOrList, key2, &[]);
602        if is_true(&self.is_dictionary(value2.clone())) {
603            return value2;
604        }
605        return defaultValue;
606
607    Value::Null
608}
609
610    fn safe_list_n(&self, mut dictionaryOrList: Value, mut keys: Value, optional_args: &[Value]) -> Value {
611        let mut defaultValue = get_arg(optional_args, 0, Value::Null);
612        /*
613         * @ignore
614         * @method
615         * @description safely extract an Array from dictionary or list
616         * @returns {Array | undefined}
617         */
618        let mut value: Value = self.safe_value_n(dictionaryOrList, keys, &[defaultValue.clone()]);
619        if (value == Value::Null) {
620            return defaultValue;
621        }
622        if (matches!(&value, Value::Arr(_))) {
623            return value;
624        }
625        return defaultValue;
626
627    Value::Null
628}
629
630    fn safe_list2(&self, mut dictionaryOrList: Value, mut key1: Value, mut key2: Value, optional_args: &[Value]) -> Value {
631        let mut defaultValue = get_arg(optional_args, 0, Value::Null);
632        /*
633         * @ignore
634         * @method
635         * @description safely extract an Array from dictionary or list
636         * @returns {Array | undefined}
637         */
638        let mut value: Value = self.safe_value(dictionaryOrList.clone(), key1, &[]);
639        if (value != Value::Null) && (matches!(&value, Value::Arr(_))) {
640            return value;
641        }
642        let mut value2: Value = self.safe_value(dictionaryOrList, key2, &[]);
643        if (value2 != Value::Null) && (matches!(&value2, Value::Arr(_))) {
644            return value2;
645        }
646        return defaultValue;
647
648    Value::Null
649}
650
651    fn safe_list(&self, mut dictionaryOrList: Value, mut key: Value, optional_args: &[Value]) -> Value {
652        let mut defaultValue = get_arg(optional_args, 0, Value::Null);
653        /*
654         * @ignore
655         * @method
656         * @description safely extract an Array from dictionary or list
657         * @returns {Array | undefined}
658         */
659        let mut value: Value = self.safe_value(dictionaryOrList, key, &[defaultValue.clone()]);
660        if (value == Value::Null) {
661            return defaultValue;
662        }
663        if (matches!(&value, Value::Arr(_))) {
664            return value;
665        }
666        return defaultValue;
667
668    Value::Null
669}
670
671    fn store_by_key(&self, mut dict: Value, mut key: Value, mut value: Value) {
672        /*
673         * @ignore
674         * @method
675         * @description store value under key if key is defined (no-op on undefined)
676         */
677        let mut k: Value = key.clone();
678        if (k != Value::Null) {
679            add_element_to_object(&mut dict, &k, value);
680        }
681}
682
683    fn handle_deltas(&self, mut bookside: Value, mut deltas: Value) {
684        {
685                        let mut i: Value = Value::Int(0);
686            let mut __for_first_71: bool = true;
687            while { if !__for_first_71 { i = (match (&(i), &(Value::Int(1))) { (Value::Int(x), Value::Int(y)) => Value::Int(x + y), (Value::Int(x), Value::Float(y)) => Value::Float(*x as f64 + *y), (Value::Float(x), Value::Int(y)) => Value::Float(*x + *y as f64), (Value::Float(x), Value::Float(y)) => Value::Float(x + y), _ => Value::Null }); } __for_first_71 = false; i.as_f64().unwrap_or(f64::NAN) < get_array_length(&deltas).as_f64().unwrap_or(f64::NAN) } {
688            self.handle_delta(bookside.clone(), get_value(&deltas, &i));
689        }
690        }
691}
692
693    fn handle_delta(&self, mut bookside: Value, mut delta: Value) {
694        panic!("{}", crate::exchange_errors::not_supported(format!("{}{}", self.id.clone(), Value::Str(" handleDelta not supported yet".into()))));
695}
696
697    fn handle_book_deltas(&self, mut orderbook: Value, mut deltas: Value) {
698        {
699                        let mut i: Value = Value::Int(0);
700            let mut __for_first_72: bool = true;
701            while { if !__for_first_72 { i = (match (&(i), &(Value::Int(1))) { (Value::Int(x), Value::Int(y)) => Value::Int(x + y), (Value::Int(x), Value::Float(y)) => Value::Float(*x as f64 + *y), (Value::Float(x), Value::Int(y)) => Value::Float(*x + *y as f64), (Value::Float(x), Value::Float(y)) => Value::Float(x + y), _ => Value::Null }); } __for_first_72 = false; i.as_f64().unwrap_or(f64::NAN) < get_array_length(&deltas).as_f64().unwrap_or(f64::NAN) } {
702            self.handle_book_delta(orderbook.clone(), get_value(&deltas, &i));
703        }
704        }
705}
706
707    fn handle_book_delta(&self, mut orderbook: Value, mut delta: Value) {
708        panic!("{}", crate::exchange_errors::not_supported(format!("{}{}", self.id.clone(), Value::Str(" handleBookDelta not supported yet".into()))));
709}
710
711    fn handle_deltas_with_keys(&self, mut bookSide: Value, mut deltas: Value, optional_args: &[Value]) {
712        let mut priceKey = get_arg(optional_args, 0, Value::Int(0));
713        let mut amountKey = get_arg(optional_args, 1, Value::Int(1));
714        let mut countOrIdKey = get_arg(optional_args, 2, Value::Int(2));
715        {
716                        let mut i: Value = Value::Int(0);
717            let mut __for_first_73: bool = true;
718            while { if !__for_first_73 { i = (match (&(i), &(Value::Int(1))) { (Value::Int(x), Value::Int(y)) => Value::Int(x + y), (Value::Int(x), Value::Float(y)) => Value::Float(*x as f64 + *y), (Value::Float(x), Value::Int(y)) => Value::Float(*x + *y as f64), (Value::Float(x), Value::Float(y)) => Value::Float(x + y), _ => Value::Null }); } __for_first_73 = false; i.as_f64().unwrap_or(f64::NAN) < get_array_length(&deltas).as_f64().unwrap_or(f64::NAN) } {
719            let mut bidAsk: Value = self.parse_order_book_bid_ask(get_value(&deltas, &i), &[priceKey.clone(), amountKey.clone(), countOrIdKey.clone()]);
720            bookSide.store_array(bidAsk);
721        }
722        }
723}
724
725    fn get_cache_index(&self, mut orderbook: Value, mut deltas: Value) -> Value {
726        return Value::Int(-1);
727
728    Value::Null
729}
730
731    fn arrays_concat(&self, mut arraysOfArrays: Value) -> Value {
732        let mut result: Value = Value::from(vec![]);
733        {
734                        let mut i: Value = Value::Int(0);
735            let mut __for_first_74: bool = true;
736            while { if !__for_first_74 { i = (match (&(i), &(Value::Int(1))) { (Value::Int(x), Value::Int(y)) => Value::Int(x + y), (Value::Int(x), Value::Float(y)) => Value::Float(*x as f64 + *y), (Value::Float(x), Value::Int(y)) => Value::Float(*x + *y as f64), (Value::Float(x), Value::Float(y)) => Value::Float(x + y), _ => Value::Null }); } __for_first_74 = false; i.as_f64().unwrap_or(f64::NAN) < ((arraysOfArrays.len() as i64) as f64) } {
737            result = self.array_concat(result.clone(), arraysOfArrays.as_array().and_then(|__arr| match &i { Value::Int(__n) => __arr.get(*__n as usize), Value::Str(__s) => __s.parse::<usize>().ok().and_then(|__n| __arr.get(__n)), _ => None }).cloned().unwrap_or(Value::Null));
738        }
739        }
740        return result;
741
742    Value::Null
743}
744
745    fn find_timeframe(&self, mut timeframe: Value, optional_args: &[Value]) -> Value {
746        let mut timeframes = get_arg(optional_args, 0, Value::Null);
747        let mut timeframesResolved: Value = (if (timeframes == Value::Null) { self.timeframes.clone() } else { timeframes });
748        let mut keys: Value = object_keys(&timeframesResolved);
749        {
750                        let mut i: Value = Value::Int(0);
751            let mut __for_first_75: bool = true;
752            while { if !__for_first_75 { i = (match (&(i), &(Value::Int(1))) { (Value::Int(x), Value::Int(y)) => Value::Int(x + y), (Value::Int(x), Value::Float(y)) => Value::Float(*x as f64 + *y), (Value::Float(x), Value::Int(y)) => Value::Float(*x + *y as f64), (Value::Float(x), Value::Float(y)) => Value::Float(x + y), _ => Value::Null }); } __for_first_75 = false; i.as_f64().unwrap_or(f64::NAN) < ((keys.len() as i64) as f64) } {
753            let mut key: Value = keys.as_array().and_then(|__arr| match &i { Value::Int(__n) => __arr.get(*__n as usize), Value::Str(__s) => __s.parse::<usize>().ok().and_then(|__n| __arr.get(__n)), _ => None }).cloned().unwrap_or(Value::Null);
754            if is_equal(&timeframesResolved.as_map().and_then(|__m| key.as_str().and_then(|__k| __m.get(__k))).cloned().unwrap_or(Value::Null), &timeframe) {
755                return key;
756            }
757        }
758        }
759        return Value::Null;
760
761    Value::Null
762}
763
764    fn check_proxy_url_settings(&self, optional_args: &[Value]) -> Value {
765        let mut url = get_arg(optional_args, 0, Value::Null);
766        let mut method = get_arg(optional_args, 1, Value::Null);
767        let mut headers = get_arg(optional_args, 2, Value::Null);
768        let mut body = get_arg(optional_args, 3, Value::Null);
769        let mut usedProxies: Value = Value::from(vec![]);
770        let mut proxyUrl: Value = Value::Null;
771        if (self.proxyUrl.clone() != Value::Null) {
772            append_to_array(&mut usedProxies, Value::Str("proxyUrl".into()));
773            proxyUrl = self.proxyUrl.clone();
774        }
775        if (self.proxy_url.clone() != Value::Null) {
776            append_to_array(&mut usedProxies, Value::Str("proxy_url".into()));
777            proxyUrl = self.proxy_url.clone();
778        }
779        if (self.proxyUrlCallback.clone() != Value::Null) {
780            append_to_array(&mut usedProxies, Value::Str("proxyUrlCallback".into()));
781            proxyUrl = self.proxy_url_callback_fn(url.clone(), method.clone(), headers.clone(), body.clone());
782        }
783        if (self.proxy_url_callback.clone() != Value::Null) {
784            append_to_array(&mut usedProxies, Value::Str("proxy_url_callback".into()));
785            proxyUrl = self.proxy_url_callback_fn(url.clone(), method.clone(), headers.clone(), body.clone());
786        }
787        // backwards-compatibility
788        if (self.proxy.clone() != Value::Null) {
789            append_to_array(&mut usedProxies, Value::Str("proxy".into()));
790            if is_function(&self.proxy) {
791                proxyUrl = self.proxy_fn(url, method, headers, body);
792            }  else {
793                proxyUrl = self.proxy.clone();
794            }
795        }
796        let mut length: f64 = ((usedProxies.len() as i64) as f64);
797        if length > ((1i64) as f64) {
798            let mut joinedProxyNames: Value = join(&usedProxies, &Value::Str(",".into()));
799            panic!("{}", crate::exchange_errors::invalid_proxy_settings(format!("{}{}", Value::Str(format!("{}{}", Value::Str(format!("{}{}", self.id.clone(), Value::Str(" you have multiple conflicting proxy settings (".into())).into()), joinedProxyNames).into()), Value::Str("), please use only one from : proxyUrl, proxy_url, proxyUrlCallback, proxy_url_callback".into()))));
800        }
801        return proxyUrl;
802
803    Value::Null
804}
805
806    fn url_encoder_for_proxy_url(&self, mut targetUrl: Value) -> Value {
807        // to be overriden
808        let mut includesQuery: bool = Value::Int(targetUrl.as_str().and_then(|__s| __s.find("?")).map(|__i| __i as i64).unwrap_or(-1)).as_f64().unwrap_or(f64::NAN) >= ((0i64) as f64);
809        let mut finalUrl: Value = (if includesQuery { self.encode_uri_component(targetUrl.clone()) } else { targetUrl });
810        return finalUrl;
811
812    Value::Null
813}
814
815    fn check_proxy_settings(&self, optional_args: &[Value]) -> Value {
816        let mut url = get_arg(optional_args, 0, Value::Null);
817        let mut method = get_arg(optional_args, 1, Value::Null);
818        let mut headers = get_arg(optional_args, 2, Value::Null);
819        let mut body = get_arg(optional_args, 3, Value::Null);
820        let mut usedProxies: Value = Value::from(vec![]);
821        let mut httpProxy: Value = Value::Null;
822        let mut httpsProxy: Value = Value::Null;
823        let mut socksProxy: Value = Value::Null;
824        // httpProxy
825        let mut isHttpProxyDefined: Value = self.value_is_defined(self.httpProxy.clone());
826        let mut isHttp_proxy_defined: Value = self.value_is_defined(self.http_proxy.clone());
827        if is_true(&isHttpProxyDefined) || is_true(&isHttp_proxy_defined) {
828            append_to_array(&mut usedProxies, Value::Str("httpProxy".into()));
829            httpProxy = (if is_true(&isHttpProxyDefined) { self.httpProxy.clone() } else { self.http_proxy.clone() });
830        }
831        let mut ishttpProxyCallbackDefined: Value = self.value_is_defined(self.httpProxyCallback.clone());
832        let mut ishttp_proxy_callback_defined: Value = self.value_is_defined(self.http_proxy_callback.clone());
833        if is_true(&ishttpProxyCallbackDefined) || is_true(&ishttp_proxy_callback_defined) {
834            append_to_array(&mut usedProxies, Value::Str("httpProxyCallback".into()));
835            httpProxy = (if is_true(&ishttpProxyCallbackDefined) { self.http_proxy_callback_fn(url.clone(), method.clone(), headers.clone(), body.clone()) } else { self.http_proxy_callback_fn(url.clone(), method.clone(), headers.clone(), body.clone()) });
836        }
837        // httpsProxy
838        let mut isHttpsProxyDefined: Value = self.value_is_defined(self.httpsProxy.clone());
839        let mut isHttps_proxy_defined: Value = self.value_is_defined(self.https_proxy.clone());
840        if is_true(&isHttpsProxyDefined) || is_true(&isHttps_proxy_defined) {
841            append_to_array(&mut usedProxies, Value::Str("httpsProxy".into()));
842            httpsProxy = (if is_true(&isHttpsProxyDefined) { self.httpsProxy.clone() } else { self.https_proxy.clone() });
843        }
844        let mut ishttpsProxyCallbackDefined: Value = self.value_is_defined(self.httpsProxyCallback.clone());
845        let mut ishttps_proxy_callback_defined: Value = self.value_is_defined(self.https_proxy_callback.clone());
846        if is_true(&ishttpsProxyCallbackDefined) || is_true(&ishttps_proxy_callback_defined) {
847            append_to_array(&mut usedProxies, Value::Str("httpsProxyCallback".into()));
848            httpsProxy = (if is_true(&ishttpsProxyCallbackDefined) { self.https_proxy_callback_fn(url.clone(), method.clone(), headers.clone(), body.clone()) } else { self.https_proxy_callback_fn(url.clone(), method.clone(), headers.clone(), body.clone()) });
849        }
850        // socksProxy
851        let mut isSocksProxyDefined: Value = self.value_is_defined(self.socksProxy.clone());
852        let mut isSocks_proxy_defined: Value = self.value_is_defined(self.socks_proxy.clone());
853        if is_true(&isSocksProxyDefined) || is_true(&isSocks_proxy_defined) {
854            append_to_array(&mut usedProxies, Value::Str("socksProxy".into()));
855            socksProxy = (if is_true(&isSocksProxyDefined) { self.socksProxy.clone() } else { self.socks_proxy.clone() });
856        }
857        let mut issocksProxyCallbackDefined: Value = self.value_is_defined(self.socksProxyCallback.clone());
858        let mut issocks_proxy_callback_defined: Value = self.value_is_defined(self.socks_proxy_callback.clone());
859        if is_true(&issocksProxyCallbackDefined) || is_true(&issocks_proxy_callback_defined) {
860            append_to_array(&mut usedProxies, Value::Str("socksProxyCallback".into()));
861            socksProxy = (if is_true(&issocksProxyCallbackDefined) { self.socks_proxy_callback_fn(url.clone(), method.clone(), headers.clone(), body.clone()) } else { self.socks_proxy_callback_fn(url, method, headers, body) });
862        }
863        // check
864        let mut length: f64 = ((usedProxies.len() as i64) as f64);
865        if length > ((1i64) as f64) {
866            let mut joinedProxyNames: Value = join(&usedProxies, &Value::Str(",".into()));
867            panic!("{}", crate::exchange_errors::invalid_proxy_settings(format!("{}{}", Value::Str(format!("{}{}", Value::Str(format!("{}{}", self.id.clone(), Value::Str(" you have multiple conflicting proxy settings (".into())).into()), joinedProxyNames).into()), Value::Str("), please use only one from: httpProxy, httpsProxy, httpProxyCallback, httpsProxyCallback, socksProxy, socksProxyCallback".into()))));
868        }
869        return Value::from(vec![httpProxy, httpsProxy, socksProxy]);
870
871    Value::Null
872}
873
874    fn check_ws_proxy_settings(&self) -> Value {
875        let mut usedProxies: Value = Value::from(vec![]);
876        let mut wsProxy: Value = Value::Null;
877        let mut wssProxy: Value = Value::Null;
878        let mut wsSocksProxy: Value = Value::Null;
879        // ws proxy
880        let mut isWsProxyDefined: Value = self.value_is_defined(self.wsProxy.clone());
881        let mut is_ws_proxy_defined: Value = self.value_is_defined(self.ws_proxy.clone());
882        if is_true(&isWsProxyDefined) || is_true(&is_ws_proxy_defined) {
883            append_to_array(&mut usedProxies, Value::Str("wsProxy".into()));
884            wsProxy = (if is_true(&(isWsProxyDefined)) { self.wsProxy.clone() } else { self.ws_proxy.clone() });
885        }
886        // wss proxy
887        let mut isWssProxyDefined: Value = self.value_is_defined(self.wssProxy.clone());
888        let mut is_wss_proxy_defined: Value = self.value_is_defined(self.wss_proxy.clone());
889        if is_true(&isWssProxyDefined) || is_true(&is_wss_proxy_defined) {
890            append_to_array(&mut usedProxies, Value::Str("wssProxy".into()));
891            wssProxy = (if is_true(&(isWssProxyDefined)) { self.wssProxy.clone() } else { self.wss_proxy.clone() });
892        }
893        // ws socks proxy
894        let mut isWsSocksProxyDefined: Value = self.value_is_defined(self.wsSocksProxy.clone());
895        let mut is_ws_socks_proxy_defined: Value = self.value_is_defined(self.ws_socks_proxy.clone());
896        if is_true(&isWsSocksProxyDefined) || is_true(&is_ws_socks_proxy_defined) {
897            append_to_array(&mut usedProxies, Value::Str("wsSocksProxy".into()));
898            wsSocksProxy = (if is_true(&(isWsSocksProxyDefined)) { self.wsSocksProxy.clone() } else { self.ws_socks_proxy.clone() });
899        }
900        // check
901        let mut length: f64 = ((usedProxies.len() as i64) as f64);
902        if length > ((1i64) as f64) {
903            let mut joinedProxyNames: Value = join(&usedProxies, &Value::Str(",".into()));
904            panic!("{}", crate::exchange_errors::invalid_proxy_settings(format!("{}{}", Value::Str(format!("{}{}", Value::Str(format!("{}{}", self.id.clone(), Value::Str(" you have multiple conflicting proxy settings (".into())).into()), joinedProxyNames).into()), Value::Str("), please use only one from: wsProxy, wssProxy, wsSocksProxy".into()))));
905        }
906        return Value::from(vec![wsProxy, wssProxy, wsSocksProxy]);
907
908    Value::Null
909}
910
911    fn check_conflicting_proxies(&self, mut proxyAgentSet: Value, mut proxyUrlSet: Value) {
912        let mut proxyAgentIsSet: bool = (proxyAgentSet != Value::Null) && (proxyAgentSet != Value::Null) && (proxyAgentSet.as_str() != Some(""));
913        let mut proxyUrlIsSet: bool = (proxyUrlSet != Value::Null) && (proxyUrlSet != Value::Null) && (proxyUrlSet.as_str() != Some(""));
914        if proxyAgentIsSet && proxyUrlIsSet {
915            panic!("{}", crate::exchange_errors::invalid_proxy_settings(format!("{}{}", self.id.clone(), Value::Str(" you have multiple conflicting proxy settings, please use only one from : proxyUrl, httpProxy, httpsProxy, socksProxy".into()))));
916        }
917}
918
919    fn check_address(&self, optional_args: &[Value]) -> Value {
920        let mut address = get_arg(optional_args, 0, Value::Null);
921        let mut code = get_arg(optional_args, 1, Value::Null);
922        let mut tag = get_arg(optional_args, 2, Value::Null);
923        if (address == Value::Null) {
924            panic!("{}", crate::exchange_errors::invalid_address(format!("{}{}", self.id.clone(), Value::Str(" address is undefined".into()))));
925        }
926        // check the address is not the same letter like 'aaaaa' nor too short nor has a space
927        let mut uniqChars: Value = (self.unique(self.string_to_chars_array(address.clone())));
928        let mut length: f64 = ((uniqChars.len() as i64) as f64); // py transpiler trick
929        if (length == 1.0) || ((address.len() as i64) as f64) < self.minFundingAddressLength.as_f64().unwrap_or(f64::NAN) || Value::Int(address.as_str().and_then(|__s| __s.find(" ")).map(|__i| __i as i64).unwrap_or(-1)).as_f64().unwrap_or(f64::NAN) > ((-1i64) as f64) {
930            panic!("{}", crate::exchange_errors::invalid_address(format!("{}{}", Value::Str(format!("{}{}", Value::Str(format!("{}{}", Value::Str(format!("{}{}", Value::Str(format!("{}{}", self.id.clone(), Value::Str(" address is invalid or has less than ".into())).into()), to_string_val(&self.minFundingAddressLength)).into()), Value::Str(" characters: \"".into())).into()), to_string_val(&address)).into()), Value::Str("\"".into()))));
931        }
932        if (code != Value::Null) {
933            let mut tagRequiredCurrencies: Value = self.safe_list_k(self.options.clone(), "withdrawTagRequiredCurrencies", &[Value::from(vec![])]);
934            if self.in_array(code.clone(), tagRequiredCurrencies).as_bool() == Some(true) {
935                if (tag == Value::Null) {
936                    panic!("{}", crate::exchange_errors::arguments_required(format!("{}{}", Value::Str(format!("{}{}", self.id.clone(), Value::Str(" withdraw() requires params[\"tag\"] for ".into())).into()), code)));
937                }
938            }
939        }
940        return address;
941
942    Value::Null
943}
944
945    fn find_message_hashes(&self, mut client: Value, mut element: Value) -> Value {
946        let mut result: Value = Value::from(vec![]);
947        let mut messageHashes: Value = object_keys(&get_value(&client, &Value::Str("futures".into())));
948        {
949                        let mut i: Value = Value::Int(0);
950            let mut __for_first_76: bool = true;
951            while { if !__for_first_76 { i = (match (&(i), &(Value::Int(1))) { (Value::Int(x), Value::Int(y)) => Value::Int(x + y), (Value::Int(x), Value::Float(y)) => Value::Float(*x as f64 + *y), (Value::Float(x), Value::Int(y)) => Value::Float(*x + *y as f64), (Value::Float(x), Value::Float(y)) => Value::Float(x + y), _ => Value::Null }); } __for_first_76 = false; i.as_f64().unwrap_or(f64::NAN) < ((messageHashes.len() as i64) as f64) } {
952            let mut messageHash: Value = messageHashes.as_array().and_then(|__arr| match &i { Value::Int(__n) => __arr.get(*__n as usize), Value::Str(__s) => __s.parse::<usize>().ok().and_then(|__n| __arr.get(__n)), _ => None }).cloned().unwrap_or(Value::Null);
953            if get_index_of(&messageHash, &element).as_f64().unwrap_or(f64::NAN) >= ((0i64) as f64) {
954                append_to_array(&mut result, messageHash.clone());
955            }
956        }
957        }
958        return result;
959
960    Value::Null
961}
962
963    fn filter_by_limit(&self, mut array: Value, optional_args: &[Value]) -> Value {
964        let mut limit = get_arg(optional_args, 0, Value::Null);
965        let mut key = get_arg(optional_args, 1, Value::Str("timestamp".into()));
966        let mut fromStart = get_arg(optional_args, 2, Value::Bool(false));
967        if self.value_is_defined(limit.clone()).as_bool() == Some(true) {
968            let mut arrayLength: Value = Value::Int(array.len() as i64);
969            if arrayLength.as_f64().unwrap_or(f64::NAN) > ((0i64) as f64) {
970                let mut ascending: bool = true;
971                if (in_op(&array.as_array().and_then(|__arr| __arr.get(0)).cloned().unwrap_or(Value::Null), &key)) {
972                    let mut first: Value = get_value(&array.as_array().and_then(|__arr| __arr.get(0)).cloned().unwrap_or(Value::Null), &key);
973                    let mut last: Value = get_value(&get_value(&array, &(match (&(arrayLength), &(Value::Int(1))) { (Value::Int(x), Value::Int(y)) => Value::Int(x - y), (Value::Int(x), Value::Float(y)) => Value::Float(*x as f64 - *y), (Value::Float(x), Value::Int(y)) => Value::Float(*x - *y as f64), (Value::Float(x), Value::Float(y)) => Value::Float(x - y), _ => Value::Null })), &key);
974                    if (first != Value::Null) && (last != Value::Null) {
975                        ascending = is_less_than_or_equal(&first, &last); // true if array is sorted in ascending order based on 'timestamp'
976                    }
977                }
978                if is_true(&fromStart) {
979                    let mut limitResolved: Value = (if (limit.as_f64().unwrap_or(f64::NAN) > arrayLength.as_f64().unwrap_or(f64::NAN)) { arrayLength } else { limit.clone() });
980                    if ascending {
981                        return self.array_slice(array.clone(), Value::Int(0), &[limitResolved.clone()]);
982                    }
983                    return self.array_slice(array.clone(), negate(&limitResolved), &[]);
984                }
985                if ascending {
986                    return self.array_slice(array.clone(), negate(&limit), &[]);
987                }
988                return self.array_slice(array.clone(), Value::Int(0), &[limit]);
989            }
990        }
991        return array;
992
993    Value::Null
994}
995
996    fn filter_by_since_limit(&self, mut array: Value, optional_args: &[Value]) -> Value {
997        let mut since = get_arg(optional_args, 0, Value::Null);
998        let mut limit = get_arg(optional_args, 1, Value::Null);
999        let mut key = get_arg(optional_args, 2, Value::Str("timestamp".into()));
1000        let mut tail = get_arg(optional_args, 3, Value::Bool(false));
1001        if (array == Value::Null) {
1002            return Value::from(vec![]);
1003        }
1004        let mut sinceIsDefined: Value = self.value_is_defined(since.clone());
1005        let mut parsedArray: Value = self.to_array(array);
1006        let mut result: Value = parsedArray.clone();
1007        if is_true(&sinceIsDefined) {
1008            result = Value::from(vec![]);
1009            {
1010                                let mut i: Value = Value::Int(0);
1011                let mut __for_first_77: bool = true;
1012                while { if !__for_first_77 { i = (match (&(i), &(Value::Int(1))) { (Value::Int(x), Value::Int(y)) => Value::Int(x + y), (Value::Int(x), Value::Float(y)) => Value::Float(*x as f64 + *y), (Value::Float(x), Value::Int(y)) => Value::Float(*x + *y as f64), (Value::Float(x), Value::Float(y)) => Value::Float(x + y), _ => Value::Null }); } __for_first_77 = false; i.as_f64().unwrap_or(f64::NAN) < get_array_length(&parsedArray).as_f64().unwrap_or(f64::NAN) } {
1013                let mut entry: Value = get_value(&parsedArray, &i);
1014                let mut entry: Value = get_value(&parsedArray, &i);
1015                let mut value: Value = self.safe_value(entry.clone(), key.clone(), &[]);
1016                if (value != Value::Null) && (value != Value::Null) && (!is_equal(&value, &Value::Int(0))) && (is_greater_than_or_equal(&value, &since)) {
1017                    append_to_array(&mut result, entry);
1018                }
1019            }
1020            }
1021        }
1022        if is_true(&tail) && (limit != Value::Null) {
1023            return self.array_slice(result.clone(), negate(&limit), &[]);
1024        }
1025        // if the user provided a 'since' argument
1026        // we want to limit the result starting from the 'since'
1027        let mut shouldFilterFromStart: Value = Value::Bool(!is_true(&tail) && is_true(&sinceIsDefined));
1028        return self.filter_by_limit(result, &[limit, key, shouldFilterFromStart]);
1029
1030    Value::Null
1031}
1032
1033    fn filter_by_value_since_limit(&self, mut array: Value, mut field: Value, optional_args: &[Value]) -> Value {
1034        let mut value = get_arg(optional_args, 0, Value::Null);
1035        let mut since = get_arg(optional_args, 1, Value::Null);
1036        let mut limit = get_arg(optional_args, 2, Value::Null);
1037        let mut key = get_arg(optional_args, 3, Value::Str("timestamp".into()));
1038        let mut tail = get_arg(optional_args, 4, Value::Bool(false));
1039        let mut valueIsDefined: Value = self.value_is_defined(value.clone());
1040        let mut sinceIsDefined: Value = self.value_is_defined(since.clone());
1041        let mut parsedArray: Value = self.to_array(array);
1042        let mut result: Value = parsedArray.clone();
1043        // single-pass filter for both symbol and since
1044        if is_true(&valueIsDefined) || is_true(&sinceIsDefined) {
1045            result = Value::from(vec![]);
1046            {
1047                                let mut i: Value = Value::Int(0);
1048                let mut __for_first_78: bool = true;
1049                while { if !__for_first_78 { i = (match (&(i), &(Value::Int(1))) { (Value::Int(x), Value::Int(y)) => Value::Int(x + y), (Value::Int(x), Value::Float(y)) => Value::Float(*x as f64 + *y), (Value::Float(x), Value::Int(y)) => Value::Float(*x + *y as f64), (Value::Float(x), Value::Float(y)) => Value::Float(x + y), _ => Value::Null }); } __for_first_78 = false; i.as_f64().unwrap_or(f64::NAN) < get_array_length(&parsedArray).as_f64().unwrap_or(f64::NAN) } {
1050                let mut entry: Value = get_value(&parsedArray, &i);
1051                let mut entry: Value = get_value(&parsedArray, &i);
1052                // safeValue (not entry[field]) so a missing field is a non-match, not a
1053                // KeyError in python/php — prediction structures key on outcome, not symbol
1054                let mut entryFiledEqualValue: Value = Value::Bool(is_equal(&self.safe_value(entry.clone(), field.clone(), &[]), &value));
1055                let mut firstCondition: Value = (if is_true(&valueIsDefined) { entryFiledEqualValue } else { Value::Bool(true) });
1056                let mut entryKeyValue: Value = self.safe_value(entry.clone(), key.clone(), &[]);
1057                let mut entryKeyGESince: Value = Value::Bool((entryKeyValue != Value::Null) && (entryKeyValue != Value::Null) && (!is_equal(&entryKeyValue, &Value::Int(0))) && (since != Value::Null) && (is_greater_than_or_equal(&entryKeyValue, &since)));
1058                let mut secondCondition: Value = (if is_true(&sinceIsDefined) { entryKeyGESince } else { Value::Bool(true) });
1059                if is_true(&firstCondition) && is_true(&secondCondition) {
1060                    append_to_array(&mut result, entry);
1061                }
1062            }
1063            }
1064        }
1065        if is_true(&tail) && (limit != Value::Null) {
1066            return self.array_slice(result.clone(), negate(&limit), &[]);
1067        }
1068        return self.filter_by_limit(result, &[limit, key, sinceIsDefined]);
1069
1070    Value::Null
1071}
1072
1073/*
1074 * @method
1075 * @name Exchange#setSandboxMode
1076 * @description set the sandbox mode for the exchange
1077 * @param {boolean} enabled true to enable sandbox mode, false to disable it
1078 */
1079    fn set_sandbox_mode(&mut self, mut enabled: Value) {
1080        if is_true(&enabled) {
1081            if (matches!(&self.urls, Value::Dict(__d) if __d.contains_key("test"))) {
1082                if matches!(&self.urls.as_map().and_then(|__m| __m.get("api")).cloned().unwrap_or(Value::Null), Value::Str(_)) {
1083                    { let __be_tmp = crate::value::get_value_k(&self.urls, "api"); add_element_to_object(&mut self.urls, &Value::Str("apiBackup".into()), __be_tmp); };
1084                    { let __be_tmp = crate::value::get_value_k(&self.urls, "test"); add_element_to_object(&mut self.urls, &Value::Str("api".into()), __be_tmp); };
1085                }  else {
1086                    { let __be_tmp = self.clone_value(crate::value::get_value_k(&self.urls, "api")); add_element_to_object(&mut self.urls, &Value::Str("apiBackup".into()), __be_tmp); };
1087                    { let __be_tmp = self.clone_value(crate::value::get_value_k(&self.urls, "test")); add_element_to_object(&mut self.urls, &Value::Str("api".into()), __be_tmp); };
1088                }
1089            }  else {
1090                panic!("{}", crate::exchange_errors::not_supported(format!("{}{}", self.id.clone(), Value::Str(" does not have a sandbox URL".into()))));
1091            }
1092            // set flag
1093            self.isSandboxModeEnabled = Value::Bool(true);
1094        }  else if (matches!(&self.urls, Value::Dict(__d) if __d.contains_key("apiBackup"))) {
1095            if matches!(&self.urls.as_map().and_then(|__m| __m.get("api")).cloned().unwrap_or(Value::Null), Value::Str(_)) {
1096                { let __be_tmp = crate::value::get_value_k(&self.urls, "apiBackup"); add_element_to_object(&mut self.urls, &Value::Str("api".into()), __be_tmp); };
1097            }  else {
1098                { let __be_tmp = self.clone_value(crate::value::get_value_k(&self.urls, "apiBackup")); add_element_to_object(&mut self.urls, &Value::Str("api".into()), __be_tmp); };
1099            }
1100            let mut newUrls: Value = self.omit(self.urls.clone(), Value::Str("apiBackup".into()), &[]);
1101            self.urls = newUrls;
1102            // set flag
1103            self.isSandboxModeEnabled = Value::Bool(false);
1104        }
1105}
1106
1107/*
1108 * @method
1109 * @name Exchange#enableDemoTrading
1110 * @description enables or disables demo trading mode
1111 * @param {boolean} [enable] true if demo trading should be enabled, false otherwise
1112 */
1113    fn enable_demo_trading(&mut self, mut enable: Value) {
1114        if is_true(&self.isSandboxModeEnabled) {
1115            panic!("{}", crate::exchange_errors::not_supported(format!("{}{}", self.id.clone(), 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".into()))));
1116        }
1117        if is_true(&enable) {
1118            { let __be_tmp = crate::value::get_value_k(&self.urls, "api"); add_element_to_object(&mut self.urls, &Value::Str("apiBackupDemoTrading".into()), __be_tmp); };
1119            { let __be_tmp = crate::value::get_value_k(&self.urls, "demo"); add_element_to_object(&mut self.urls, &Value::Str("api".into()), __be_tmp); };
1120        }  else if (matches!(&self.urls, Value::Dict(__d) if __d.contains_key("apiBackupDemoTrading"))) {
1121            { let __be_tmp = crate::value::get_value_k(&self.urls, "apiBackupDemoTrading"); add_element_to_object(&mut self.urls, &Value::Str("api".into()), __be_tmp); };
1122            let mut newUrls: Value = self.omit(self.urls.clone(), Value::Str("apiBackupDemoTrading".into()), &[]);
1123            self.urls = newUrls;
1124        }
1125        if let Value::Dict(__d) = &mut self.options { std::sync::Arc::make_mut(__d).insert("enableDemoTrading".into(), enable); }
1126}
1127
1128    fn sign(&self, mut path: Value, optional_args: &[Value]) -> Value {
1129        // virtual-dispatch (static: DerivedExchange::sign(self, ...))
1130        { let __v = crate::exchange::DerivedExchange::sign(self, path, 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; } }
1131
1132        let mut api = get_arg(optional_args, 0, Value::from(vec![Value::Str("public".into())]));
1133        let mut method = get_arg(optional_args, 1, Value::Str("GET".into()));
1134        let mut params = get_arg(optional_args, 2, Value::Map({
1135    let mut m = indexmap::IndexMap::new();
1136    m
1137}));
1138        return Value::Map({
1139    let mut m = indexmap::IndexMap::new();
1140        m.insert("url".to_string(), Value::Null);
1141        m.insert("method".to_string(), Value::Null);
1142        m.insert("headers".to_string(), Value::Null);
1143        m.insert("body".to_string(), Value::Null);
1144    m
1145});
1146
1147    Value::Null
1148}
1149
1150    fn fetch_accounts(&mut self, optional_args: &[Value]) -> impl ::std::future::Future<Output = Value> + Send { async move {
1151        let mut params = get_arg(optional_args, 0, Value::Map({
1152    let mut m = indexmap::IndexMap::new();
1153    m
1154}));
1155        panic!("{}", crate::exchange_errors::not_supported(format!("{}{}", self.id.clone(), Value::Str(" fetchAccounts() is not supported yet".into()))));
1156
1157    Value::Null
1158} }
1159
1160    fn watch_liquidations(&mut self, mut symbol: Value, optional_args: &[Value]) -> impl ::std::future::Future<Output = Value> + Send { async move {
1161        let mut since = get_arg(optional_args, 0, Value::Null);
1162        let mut limit = get_arg(optional_args, 1, Value::Null);
1163        let mut params = get_arg(optional_args, 2, Value::Map({
1164    let mut m = indexmap::IndexMap::new();
1165    m
1166}));
1167        if (self.has.as_map().and_then(|__m| __m.get("watchLiquidationsForSymbols")).cloned().unwrap_or(Value::Null) != Value::Null) && (self.has.as_map().and_then(|__m| __m.get("watchLiquidationsForSymbols")).cloned().unwrap_or(Value::Null).as_bool() != Some(false)) {
1168            return self.watch_liquidations_for_symbols(Value::from(vec![symbol]), &[since, limit, params]).await;
1169        }
1170        panic!("{}", crate::exchange_errors::not_supported(format!("{}{}", self.id.clone(), Value::Str(" watchLiquidations() is not supported yet".into()))));
1171
1172    Value::Null
1173} }
1174
1175    fn watch_liquidations_for_symbols(&mut self, mut symbols: Value, optional_args: &[Value]) -> impl ::std::future::Future<Output = Value> + Send { async move {
1176        let mut since = get_arg(optional_args, 0, Value::Null);
1177        let mut limit = get_arg(optional_args, 1, Value::Null);
1178        let mut params = get_arg(optional_args, 2, Value::Map({
1179    let mut m = indexmap::IndexMap::new();
1180    m
1181}));
1182        panic!("{}", crate::exchange_errors::not_supported(format!("{}{}", self.id.clone(), Value::Str(" watchLiquidationsForSymbols() is not supported yet".into()))));
1183
1184    Value::Null
1185} }
1186
1187    fn watch_my_liquidations(&mut self, mut symbol: Value, optional_args: &[Value]) -> impl ::std::future::Future<Output = Value> + Send { async move {
1188        let mut since = get_arg(optional_args, 0, Value::Null);
1189        let mut limit = get_arg(optional_args, 1, Value::Null);
1190        let mut params = get_arg(optional_args, 2, Value::Map({
1191    let mut m = indexmap::IndexMap::new();
1192    m
1193}));
1194        if (self.has.as_map().and_then(|__m| __m.get("watchMyLiquidationsForSymbols")).cloned().unwrap_or(Value::Null) != Value::Null) && (self.has.as_map().and_then(|__m| __m.get("watchMyLiquidationsForSymbols")).cloned().unwrap_or(Value::Null).as_bool() != Some(false)) {
1195            return self.watch_my_liquidations_for_symbols(Value::from(vec![symbol]), &[since, limit, params]).await;
1196        }
1197        panic!("{}", crate::exchange_errors::not_supported(format!("{}{}", self.id.clone(), Value::Str(" watchMyLiquidations() is not supported yet".into()))));
1198
1199    Value::Null
1200} }
1201
1202    fn watch_my_liquidations_for_symbols(&mut self, mut symbols: Value, optional_args: &[Value]) -> impl ::std::future::Future<Output = Value> + Send { async move {
1203        let mut since = get_arg(optional_args, 0, Value::Null);
1204        let mut limit = get_arg(optional_args, 1, Value::Null);
1205        let mut params = get_arg(optional_args, 2, Value::Map({
1206    let mut m = indexmap::IndexMap::new();
1207    m
1208}));
1209        panic!("{}", crate::exchange_errors::not_supported(format!("{}{}", self.id.clone(), Value::Str(" watchMyLiquidationsForSymbols() is not supported yet".into()))));
1210
1211    Value::Null
1212} }
1213
1214    fn un_watch_orders(&mut self, optional_args: &[Value]) -> impl ::std::future::Future<Output = Value> + Send { async move {
1215        let mut symbol = get_arg(optional_args, 0, Value::Null);
1216        let mut params = get_arg(optional_args, 1, Value::Map({
1217    let mut m = indexmap::IndexMap::new();
1218    m
1219}));
1220        panic!("{}", crate::exchange_errors::not_supported(format!("{}{}", self.id.clone(), Value::Str(" unWatchOrders() is not supported yet".into()))));
1221
1222    Value::Null
1223} }
1224
1225    fn un_watch_trades(&mut self, mut symbol: Value, optional_args: &[Value]) -> impl ::std::future::Future<Output = Value> + Send { async move {
1226        let mut params = get_arg(optional_args, 0, Value::Map({
1227    let mut m = indexmap::IndexMap::new();
1228    m
1229}));
1230        panic!("{}", crate::exchange_errors::not_supported(format!("{}{}", self.id.clone(), Value::Str(" unWatchTrades() is not supported yet".into()))));
1231
1232    Value::Null
1233} }
1234
1235    fn un_watch_trades_for_symbols(&mut self, mut symbols: Value, optional_args: &[Value]) -> impl ::std::future::Future<Output = Value> + Send { async move {
1236        let mut params = get_arg(optional_args, 0, Value::Map({
1237    let mut m = indexmap::IndexMap::new();
1238    m
1239}));
1240        panic!("{}", crate::exchange_errors::not_supported(format!("{}{}", self.id.clone(), Value::Str(" unWatchTradesForSymbols() is not supported yet".into()))));
1241
1242    Value::Null
1243} }
1244
1245    fn watch_ohlcv_for_symbols(&mut self, mut symbolsAndTimeframes: Value, optional_args: &[Value]) -> impl ::std::future::Future<Output = Value> + Send { async move {
1246        let mut since = get_arg(optional_args, 0, Value::Null);
1247        let mut limit = get_arg(optional_args, 1, Value::Null);
1248        let mut params = get_arg(optional_args, 2, Value::Map({
1249    let mut m = indexmap::IndexMap::new();
1250    m
1251}));
1252        panic!("{}", crate::exchange_errors::not_supported(format!("{}{}", self.id.clone(), Value::Str(" watchOHLCVForSymbols() is not supported yet".into()))));
1253
1254    Value::Null
1255} }
1256
1257    fn un_watch_ohlcv_for_symbols(&mut self, mut symbolsAndTimeframes: Value, optional_args: &[Value]) -> impl ::std::future::Future<Output = Value> + Send { async move {
1258        let mut params = get_arg(optional_args, 0, Value::Map({
1259    let mut m = indexmap::IndexMap::new();
1260    m
1261}));
1262        panic!("{}", crate::exchange_errors::not_supported(format!("{}{}", self.id.clone(), Value::Str(" unWatchOHLCVForSymbols() is not supported yet".into()))));
1263
1264    Value::Null
1265} }
1266
1267    fn un_watch_order_book_for_symbols(&mut self, mut symbols: Value, optional_args: &[Value]) -> impl ::std::future::Future<Output = Value> + Send { async move {
1268        let mut params = get_arg(optional_args, 0, Value::Map({
1269    let mut m = indexmap::IndexMap::new();
1270    m
1271}));
1272        panic!("{}", crate::exchange_errors::not_supported(format!("{}{}", self.id.clone(), Value::Str(" unWatchOrderBookForSymbols() is not supported yet".into()))));
1273
1274    Value::Null
1275} }
1276
1277    fn un_watch_positions(&mut self, optional_args: &[Value]) -> impl ::std::future::Future<Output = Value> + Send { async move {
1278        let mut symbols = get_arg(optional_args, 0, Value::Null);
1279        let mut params = get_arg(optional_args, 1, Value::Map({
1280    let mut m = indexmap::IndexMap::new();
1281    m
1282}));
1283        panic!("{}", crate::exchange_errors::not_supported(format!("{}{}", self.id.clone(), Value::Str(" unWatchPositions() is not supported yet".into()))));
1284
1285    Value::Null
1286} }
1287
1288    fn un_watch_ticker(&mut self, mut symbol: Value, optional_args: &[Value]) -> impl ::std::future::Future<Output = Value> + Send { async move {
1289        let mut params = get_arg(optional_args, 0, Value::Map({
1290    let mut m = indexmap::IndexMap::new();
1291    m
1292}));
1293        panic!("{}", crate::exchange_errors::not_supported(format!("{}{}", self.id.clone(), Value::Str(" unWatchTicker() is not supported yet".into()))));
1294
1295    Value::Null
1296} }
1297
1298    fn un_watch_mark_price(&mut self, mut symbol: Value, optional_args: &[Value]) -> impl ::std::future::Future<Output = Value> + Send { async move {
1299        let mut params = get_arg(optional_args, 0, Value::Map({
1300    let mut m = indexmap::IndexMap::new();
1301    m
1302}));
1303        panic!("{}", crate::exchange_errors::not_supported(format!("{}{}", self.id.clone(), Value::Str(" unWatchMarkPrice() is not supported yet".into()))));
1304
1305    Value::Null
1306} }
1307
1308    fn un_watch_mark_prices(&mut self, optional_args: &[Value]) -> impl ::std::future::Future<Output = Value> + Send { async move {
1309        let mut symbols = get_arg(optional_args, 0, Value::Null);
1310        let mut params = get_arg(optional_args, 1, Value::Map({
1311    let mut m = indexmap::IndexMap::new();
1312    m
1313}));
1314        panic!("{}", crate::exchange_errors::not_supported(format!("{}{}", self.id.clone(), Value::Str(" unWatchMarkPrices() is not supported yet".into()))));
1315
1316    Value::Null
1317} }
1318
1319    fn fetch_deposit_addresses(&mut self, optional_args: &[Value]) -> impl ::std::future::Future<Output = Value> + Send { async move {
1320        // async-virtual: try the derived exchange first
1321        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 {
1322            if !matches!(__v, crate::Value::Null) { return __v; }
1323        }
1324
1325        let mut codes = get_arg(optional_args, 0, Value::Null);
1326        let mut params = get_arg(optional_args, 1, Value::Map({
1327    let mut m = indexmap::IndexMap::new();
1328    m
1329}));
1330        panic!("{}", crate::exchange_errors::not_supported(format!("{}{}", self.id.clone(), Value::Str(" fetchDepositAddresses() is not supported yet".into()))));
1331
1332    Value::Null
1333} }
1334
1335    fn fetch_margin_mode(&mut self, mut symbol: Value, optional_args: &[Value]) -> impl ::std::future::Future<Output = Value> + Send { async move {
1336        // async-virtual: try the derived exchange first
1337        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 {
1338            if !matches!(__v, crate::Value::Null) { return __v; }
1339        }
1340
1341        let mut params = get_arg(optional_args, 0, Value::Map({
1342    let mut m = indexmap::IndexMap::new();
1343    m
1344}));
1345        if (self.has.as_map().and_then(|__m| __m.get("fetchMarginModes")).cloned().unwrap_or(Value::Null) != Value::Null) && (self.has.as_map().and_then(|__m| __m.get("fetchMarginModes")).cloned().unwrap_or(Value::Null).as_bool() != Some(false)) {
1346            let mut marginModes: Value = self.fetch_margin_modes(&[Value::from(vec![symbol.clone()]), params]).await;
1347            let mut marginMode: Value = self.safe_dict(marginModes, symbol, &[]);
1348            return marginMode;
1349        }  else {
1350            panic!("{}", crate::exchange_errors::not_supported(format!("{}{}", self.id.clone(), Value::Str(" fetchMarginMode() is not supported yet".into()))));
1351        }
1352
1353    Value::Null
1354} }
1355
1356    fn fetch_margin_modes(&mut self, optional_args: &[Value]) -> impl ::std::future::Future<Output = Value> + Send { async move {
1357        // async-virtual: try the derived exchange first
1358        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 {
1359            if !matches!(__v, crate::Value::Null) { return __v; }
1360        }
1361
1362        let mut symbols = get_arg(optional_args, 0, Value::Null);
1363        let mut params = get_arg(optional_args, 1, Value::Map({
1364    let mut m = indexmap::IndexMap::new();
1365    m
1366}));
1367        panic!("{}", crate::exchange_errors::not_supported(format!("{}{}", self.id.clone(), Value::Str(" fetchMarginModes () is not supported yet".into()))));
1368
1369    Value::Null
1370} }
1371
1372    fn un_watch_order_book(&mut self, mut symbol: Value, optional_args: &[Value]) -> impl ::std::future::Future<Output = Value> + Send { async move {
1373        let mut params = get_arg(optional_args, 0, Value::Map({
1374    let mut m = indexmap::IndexMap::new();
1375    m
1376}));
1377        panic!("{}", crate::exchange_errors::not_supported(format!("{}{}", self.id.clone(), Value::Str(" unWatchOrderBook() is not supported yet".into()))));
1378
1379    Value::Null
1380} }
1381
1382    fn fetch_time(&mut self, optional_args: &[Value]) -> impl ::std::future::Future<Output = Value> + Send { async move {
1383        // async-virtual: try the derived exchange first
1384        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 {
1385            if !matches!(__v, crate::Value::Null) { return __v; }
1386        }
1387
1388        let mut params = get_arg(optional_args, 0, Value::Map({
1389    let mut m = indexmap::IndexMap::new();
1390    m
1391}));
1392        panic!("{}", crate::exchange_errors::not_supported(format!("{}{}", self.id.clone(), Value::Str(" fetchTime() is not supported yet".into()))));
1393
1394    Value::Null
1395} }
1396
1397    fn fetch_trading_limits(&mut self, optional_args: &[Value]) -> impl ::std::future::Future<Output = Value> + Send { async move {
1398        let mut symbols = get_arg(optional_args, 0, Value::Null);
1399        let mut params = get_arg(optional_args, 1, Value::Map({
1400    let mut m = indexmap::IndexMap::new();
1401    m
1402}));
1403        panic!("{}", crate::exchange_errors::not_supported(format!("{}{}", self.id.clone(), Value::Str(" fetchTradingLimits() is not supported yet".into()))));
1404
1405    Value::Null
1406} }
1407
1408    fn parse_currency(&self, mut rawCurrency: Value) -> Value {
1409        // virtual-dispatch (static: DerivedExchange::parse_currency(self, ...))
1410        { let __v = crate::exchange::DerivedExchange::parse_currency(self, rawCurrency); if !matches!(__v, crate::Value::Null) { return __v; } }
1411
1412        panic!("{}", crate::exchange_errors::not_supported(format!("{}{}", self.id.clone(), Value::Str(" parseCurrency() is not supported yet".into()))));
1413
1414    Value::Null
1415}
1416
1417    fn parse_currencies(&self, mut rawCurrencies: Value) -> Value {
1418        let mut result: Value = Value::Map({
1419            let mut m = indexmap::IndexMap::new();
1420            m
1421        });
1422        let mut arr: Value = self.to_array(rawCurrencies);
1423        {
1424                        let mut i: Value = Value::Int(0);
1425            let mut __for_first_79: bool = true;
1426            while { if !__for_first_79 { i = (match (&(i), &(Value::Int(1))) { (Value::Int(x), Value::Int(y)) => Value::Int(x + y), (Value::Int(x), Value::Float(y)) => Value::Float(*x as f64 + *y), (Value::Float(x), Value::Int(y)) => Value::Float(*x + *y as f64), (Value::Float(x), Value::Float(y)) => Value::Float(x + y), _ => Value::Null }); } __for_first_79 = false; i.as_f64().unwrap_or(f64::NAN) < ((arr.len() as i64) as f64) } {
1427            let mut parsed: Value = <Self as crate::exchange_generated::ExchangeBase>::parse_currency(self, arr.as_array().and_then(|__arr| match &i { Value::Int(__n) => __arr.get(*__n as usize), Value::Str(__s) => __s.parse::<usize>().ok().and_then(|__n| __arr.get(__n)), _ => None }).cloned().unwrap_or(Value::Null));
1428            if (parsed == Value::Null) {
1429                continue;
1430            }
1431            let mut code: Value = parsed.as_map().and_then(|__m| __m.get("code")).cloned().unwrap_or(Value::Null);
1432            if let Value::Dict(__d) = &mut result { std::sync::Arc::make_mut(__d).insert(crate::runtime::stringify_param(&code), parsed); }
1433        }
1434        }
1435        return result;
1436
1437    Value::Null
1438}
1439
1440    fn parse_market(&self, mut market: Value) -> Value {
1441        // virtual-dispatch (static: DerivedExchange::parse_market(self, ...))
1442        { let __v = crate::exchange::DerivedExchange::parse_market(self, market); if !matches!(__v, crate::Value::Null) { return __v; } }
1443
1444        panic!("{}", crate::exchange_errors::not_supported(format!("{}{}", self.id.clone(), Value::Str(" parseMarket() is not supported yet".into()))));
1445
1446    Value::Null
1447}
1448
1449    fn parse_markets(&self, mut markets: Value) -> Value {
1450        let mut result: Value = Value::from(vec![]);
1451        {
1452                        let mut i: Value = Value::Int(0);
1453            let mut __for_first_80: bool = true;
1454            while { if !__for_first_80 { i = (match (&(i), &(Value::Int(1))) { (Value::Int(x), Value::Int(y)) => Value::Int(x + y), (Value::Int(x), Value::Float(y)) => Value::Float(*x as f64 + *y), (Value::Float(x), Value::Int(y)) => Value::Float(*x + *y as f64), (Value::Float(x), Value::Float(y)) => Value::Float(x + y), _ => Value::Null }); } __for_first_80 = false; i.as_f64().unwrap_or(f64::NAN) < get_array_length(&markets).as_f64().unwrap_or(f64::NAN) } {
1455            let mut market: Value = <Self as crate::exchange_generated::ExchangeBase>::parse_market(self, get_value(&markets, &i));
1456            // parseMarket returns undefined for a market it cannot build (e.g. unknown base or quote)
1457            if (market != Value::Null) {
1458                append_to_array(&mut result, market);
1459            }
1460        }
1461        }
1462        return result;
1463
1464    Value::Null
1465}
1466
1467    fn parse_ticker(&self, mut ticker: Value, optional_args: &[Value]) -> Value {
1468        // virtual-dispatch (static: DerivedExchange::parse_ticker(self, ...))
1469        { let __v = crate::exchange::DerivedExchange::parse_ticker(self, ticker, crate::runtime::get_arg(optional_args, 0, crate::Value::Null)); if !matches!(__v, crate::Value::Null) { return __v; } }
1470
1471        let mut market = get_arg(optional_args, 0, Value::Null);
1472        panic!("{}", crate::exchange_errors::not_supported(format!("{}{}", self.id.clone(), Value::Str(" parseTicker() is not supported yet".into()))));
1473
1474    Value::Null
1475}
1476
1477    fn parse_deposit_address(&self, mut depositAddress: Value, optional_args: &[Value]) -> Value {
1478        // virtual-dispatch (static: DerivedExchange::parse_deposit_address(self, ...))
1479        { let __v = crate::exchange::DerivedExchange::parse_deposit_address(self, depositAddress, crate::runtime::get_arg(optional_args, 0, crate::Value::Null)); if !matches!(__v, crate::Value::Null) { return __v; } }
1480
1481        let mut currency = get_arg(optional_args, 0, Value::Null);
1482        panic!("{}", crate::exchange_errors::not_supported(format!("{}{}", self.id.clone(), Value::Str(" parseDepositAddress() is not supported yet".into()))));
1483
1484    Value::Null
1485}
1486
1487    fn parse_trade(&self, mut trade: Value, optional_args: &[Value]) -> Value {
1488        // virtual-dispatch (static: DerivedExchange::parse_trade(self, ...))
1489        { let __v = crate::exchange::DerivedExchange::parse_trade(self, trade, crate::runtime::get_arg(optional_args, 0, crate::Value::Null)); if !matches!(__v, crate::Value::Null) { return __v; } }
1490
1491        let mut market = get_arg(optional_args, 0, Value::Null);
1492        panic!("{}", crate::exchange_errors::not_supported(format!("{}{}", self.id.clone(), Value::Str(" parseTrade() is not supported yet".into()))));
1493
1494    Value::Null
1495}
1496
1497    fn parse_transaction(&self, mut transaction: Value, optional_args: &[Value]) -> Value {
1498        // virtual-dispatch (static: DerivedExchange::parse_transaction(self, ...))
1499        { let __v = crate::exchange::DerivedExchange::parse_transaction(self, transaction, crate::runtime::get_arg(optional_args, 0, crate::Value::Null)); if !matches!(__v, crate::Value::Null) { return __v; } }
1500
1501        let mut currency = get_arg(optional_args, 0, Value::Null);
1502        panic!("{}", crate::exchange_errors::not_supported(format!("{}{}", self.id.clone(), Value::Str(" parseTransaction() is not supported yet".into()))));
1503
1504    Value::Null
1505}
1506
1507    fn parse_transfer(&self, mut transfer: Value, optional_args: &[Value]) -> Value {
1508        // virtual-dispatch (static: DerivedExchange::parse_transfer(self, ...))
1509        { 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; } }
1510
1511        let mut currency = get_arg(optional_args, 0, Value::Null);
1512        if (transfer == Value::Null) {
1513            panic!("{}", crate::exchange_errors::not_supported(format!("{}{}", self.id.clone(), Value::Str(" parseTransfer() is not supported yet".into()))));
1514        }
1515        panic!("{}", crate::exchange_errors::not_supported(format!("{}{}", self.id.clone(), Value::Str(" parseTransfer() is not supported yet".into()))));
1516
1517    Value::Null
1518}
1519
1520    fn parse_account(&self, mut account: Value) -> Value {
1521        // virtual-dispatch (static: DerivedExchange::parse_account(self, ...))
1522        { let __v = crate::exchange::DerivedExchange::parse_account(self, account); if !matches!(__v, crate::Value::Null) { return __v; } }
1523
1524        panic!("{}", crate::exchange_errors::not_supported(format!("{}{}", self.id.clone(), Value::Str(" parseAccount() is not supported yet".into()))));
1525
1526    Value::Null
1527}
1528
1529    fn parse_ledger_entry(&self, mut item: Value, optional_args: &[Value]) -> Value {
1530        // virtual-dispatch (static: DerivedExchange::parse_ledger_entry(self, ...))
1531        { let __v = crate::exchange::DerivedExchange::parse_ledger_entry(self, item, crate::runtime::get_arg(optional_args, 0, crate::Value::Null)); if !matches!(__v, crate::Value::Null) { return __v; } }
1532
1533        let mut currency = get_arg(optional_args, 0, Value::Null);
1534        panic!("{}", crate::exchange_errors::not_supported(format!("{}{}", self.id.clone(), Value::Str(" parseLedgerEntry() is not supported yet".into()))));
1535
1536    Value::Null
1537}
1538
1539    fn parse_order(&self, mut order: Value, optional_args: &[Value]) -> Value {
1540        // virtual-dispatch (static: DerivedExchange::parse_order(self, ...))
1541        { let __v = crate::exchange::DerivedExchange::parse_order(self, order, crate::runtime::get_arg(optional_args, 0, crate::Value::Null)); if !matches!(__v, crate::Value::Null) { return __v; } }
1542
1543        let mut market = get_arg(optional_args, 0, Value::Null);
1544        panic!("{}", crate::exchange_errors::not_supported(format!("{}{}", self.id.clone(), Value::Str(" parseOrder() is not supported yet".into()))));
1545
1546    Value::Null
1547}
1548
1549    fn fetch_cross_borrow_rates(&mut self, optional_args: &[Value]) -> impl ::std::future::Future<Output = Value> + Send { async move {
1550        let mut params = get_arg(optional_args, 0, Value::Map({
1551    let mut m = indexmap::IndexMap::new();
1552    m
1553}));
1554        panic!("{}", crate::exchange_errors::not_supported(format!("{}{}", self.id.clone(), Value::Str(" fetchCrossBorrowRates() is not supported yet".into()))));
1555
1556    Value::Null
1557} }
1558
1559    fn fetch_isolated_borrow_rates(&mut self, optional_args: &[Value]) -> impl ::std::future::Future<Output = Value> + Send { async move {
1560        let mut params = get_arg(optional_args, 0, Value::Map({
1561    let mut m = indexmap::IndexMap::new();
1562    m
1563}));
1564        panic!("{}", crate::exchange_errors::not_supported(format!("{}{}", self.id.clone(), Value::Str(" fetchIsolatedBorrowRates() is not supported yet".into()))));
1565
1566    Value::Null
1567} }
1568
1569    fn parse_market_leverage_tiers(&self, mut info: Value, optional_args: &[Value]) -> Value {
1570        // virtual-dispatch (static: DerivedExchange::parse_market_leverage_tiers(self, ...))
1571        { let __v = crate::exchange::DerivedExchange::parse_market_leverage_tiers(self, info, crate::runtime::get_arg(optional_args, 0, crate::Value::Null)); if !matches!(__v, crate::Value::Null) { return __v; } }
1572
1573        let mut market = get_arg(optional_args, 0, Value::Null);
1574        panic!("{}", crate::exchange_errors::not_supported(format!("{}{}", self.id.clone(), Value::Str(" parseMarketLeverageTiers() is not supported yet".into()))));
1575
1576    Value::Null
1577}
1578
1579    fn fetch_leverage_tiers(&mut self, optional_args: &[Value]) -> impl ::std::future::Future<Output = Value> + Send { async move {
1580        // async-virtual: try the derived exchange first
1581        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 {
1582            if !matches!(__v, crate::Value::Null) { return __v; }
1583        }
1584
1585        let mut symbols = get_arg(optional_args, 0, Value::Null);
1586        let mut params = get_arg(optional_args, 1, Value::Map({
1587    let mut m = indexmap::IndexMap::new();
1588    m
1589}));
1590        panic!("{}", crate::exchange_errors::not_supported(format!("{}{}", self.id.clone(), Value::Str(" fetchLeverageTiers() is not supported yet".into()))));
1591
1592    Value::Null
1593} }
1594
1595    fn parse_position(&self, mut position: Value, optional_args: &[Value]) -> Value {
1596        // virtual-dispatch (static: DerivedExchange::parse_position(self, ...))
1597        { let __v = crate::exchange::DerivedExchange::parse_position(self, position, crate::runtime::get_arg(optional_args, 0, crate::Value::Null)); if !matches!(__v, crate::Value::Null) { return __v; } }
1598
1599        let mut market = get_arg(optional_args, 0, Value::Null);
1600        panic!("{}", crate::exchange_errors::not_supported(format!("{}{}", self.id.clone(), Value::Str(" parsePosition() is not supported yet".into()))));
1601
1602    Value::Null
1603}
1604
1605    fn parse_funding_rate_history(&self, mut info: Value, optional_args: &[Value]) -> Value {
1606        // virtual-dispatch (static: DerivedExchange::parse_funding_rate_history(self, ...))
1607        { let __v = crate::exchange::DerivedExchange::parse_funding_rate_history(self, info, crate::runtime::get_arg(optional_args, 0, crate::Value::Null)); if !matches!(__v, crate::Value::Null) { return __v; } }
1608
1609        let mut market = get_arg(optional_args, 0, Value::Null);
1610        panic!("{}", crate::exchange_errors::not_supported(format!("{}{}", self.id.clone(), Value::Str(" parseFundingRateHistory() is not supported yet".into()))));
1611
1612    Value::Null
1613}
1614
1615    fn parse_borrow_interest(&self, mut info: Value, optional_args: &[Value]) -> Value {
1616        // virtual-dispatch (static: DerivedExchange::parse_borrow_interest(self, ...))
1617        { let __v = crate::exchange::DerivedExchange::parse_borrow_interest(self, info, crate::runtime::get_arg(optional_args, 0, crate::Value::Null)); if !matches!(__v, crate::Value::Null) { return __v; } }
1618
1619        let mut market = get_arg(optional_args, 0, Value::Null);
1620        panic!("{}", crate::exchange_errors::not_supported(format!("{}{}", self.id.clone(), Value::Str(" parseBorrowInterest() is not supported yet".into()))));
1621
1622    Value::Null
1623}
1624
1625    fn parse_isolated_borrow_rate(&self, mut info: Value, optional_args: &[Value]) -> Value {
1626        let mut market = get_arg(optional_args, 0, Value::Null);
1627        panic!("{}", crate::exchange_errors::not_supported(format!("{}{}", self.id.clone(), Value::Str(" parseIsolatedBorrowRate() is not supported yet".into()))));
1628
1629    Value::Null
1630}
1631
1632    fn parse_ws_trade(&self, mut trade: Value, optional_args: &[Value]) -> Value {
1633        let mut market = get_arg(optional_args, 0, Value::Null);
1634        panic!("{}", crate::exchange_errors::not_supported(format!("{}{}", self.id.clone(), Value::Str(" parseWsTrade() is not supported yet".into()))));
1635
1636    Value::Null
1637}
1638
1639    fn parse_ws_order(&self, mut order: Value, optional_args: &[Value]) -> Value {
1640        let mut market = get_arg(optional_args, 0, Value::Null);
1641        panic!("{}", crate::exchange_errors::not_supported(format!("{}{}", self.id.clone(), Value::Str(" parseWsOrder() is not supported yet".into()))));
1642
1643    Value::Null
1644}
1645
1646    fn parse_ws_order_trade(&self, mut trade: Value, optional_args: &[Value]) -> Value {
1647        let mut market = get_arg(optional_args, 0, Value::Null);
1648        panic!("{}", crate::exchange_errors::not_supported(format!("{}{}", self.id.clone(), Value::Str(" parseWsOrderTrade() is not supported yet".into()))));
1649
1650    Value::Null
1651}
1652
1653    fn parse_ws_ohlcv(&self, mut ohlcv: Value, optional_args: &[Value]) -> Value {
1654        let mut market = get_arg(optional_args, 0, Value::Null);
1655        return <Self as crate::exchange_generated::ExchangeBase>::parse_ohlcv(self, ohlcv, &[market]);
1656
1657    Value::Null
1658}
1659
1660    fn fetch_funding_rates(&mut self, optional_args: &[Value]) -> impl ::std::future::Future<Output = Value> + Send { async move {
1661        // async-virtual: try the derived exchange first
1662        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 {
1663            if !matches!(__v, crate::Value::Null) { return __v; }
1664        }
1665
1666        let mut symbols = get_arg(optional_args, 0, Value::Null);
1667        let mut params = get_arg(optional_args, 1, Value::Map({
1668    let mut m = indexmap::IndexMap::new();
1669    m
1670}));
1671        panic!("{}", crate::exchange_errors::not_supported(format!("{}{}", self.id.clone(), Value::Str(" fetchFundingRates() is not supported yet".into()))));
1672
1673    Value::Null
1674} }
1675
1676    fn fetch_funding_intervals(&mut self, optional_args: &[Value]) -> impl ::std::future::Future<Output = Value> + Send { async move {
1677        // async-virtual: try the derived exchange first
1678        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 {
1679            if !matches!(__v, crate::Value::Null) { return __v; }
1680        }
1681
1682        let mut symbols = get_arg(optional_args, 0, Value::Null);
1683        let mut params = get_arg(optional_args, 1, Value::Map({
1684    let mut m = indexmap::IndexMap::new();
1685    m
1686}));
1687        panic!("{}", crate::exchange_errors::not_supported(format!("{}{}", self.id.clone(), Value::Str(" fetchFundingIntervals() is not supported yet".into()))));
1688
1689    Value::Null
1690} }
1691
1692    fn watch_funding_rate(&mut self, mut symbol: Value, optional_args: &[Value]) -> impl ::std::future::Future<Output = Value> + Send { async move {
1693        let mut params = get_arg(optional_args, 0, Value::Map({
1694    let mut m = indexmap::IndexMap::new();
1695    m
1696}));
1697        panic!("{}", crate::exchange_errors::not_supported(format!("{}{}", self.id.clone(), Value::Str(" watchFundingRate() is not supported yet".into()))));
1698
1699    Value::Null
1700} }
1701
1702    fn watch_funding_rates(&mut self, optional_args: &[Value]) -> impl ::std::future::Future<Output = Value> + Send { async move {
1703        let mut symbols = get_arg(optional_args, 0, Value::Null);
1704        let mut params = get_arg(optional_args, 1, Value::Map({
1705    let mut m = indexmap::IndexMap::new();
1706    m
1707}));
1708        panic!("{}", crate::exchange_errors::not_supported(format!("{}{}", self.id.clone(), Value::Str(" watchFundingRates() is not supported yet".into()))));
1709
1710    Value::Null
1711} }
1712
1713    fn un_watch_funding_rates(&mut self, optional_args: &[Value]) -> impl ::std::future::Future<Output = Value> + Send { async move {
1714        let mut symbols = get_arg(optional_args, 0, Value::Null);
1715        let mut params = get_arg(optional_args, 1, Value::Map({
1716    let mut m = indexmap::IndexMap::new();
1717    m
1718}));
1719        panic!("{}", crate::exchange_errors::not_supported(format!("{}{}", self.id.clone(), Value::Str(" unWatchFundingRates() is not supported yet".into()))));
1720
1721    Value::Null
1722} }
1723
1724    fn watch_funding_rates_for_symbols(&mut self, mut symbols: Value, optional_args: &[Value]) -> impl ::std::future::Future<Output = Value> + Send { async move {
1725        let mut params = get_arg(optional_args, 0, Value::Map({
1726    let mut m = indexmap::IndexMap::new();
1727    m
1728}));
1729        return self.watch_funding_rates(&[symbols, params]).await;
1730
1731    Value::Null
1732} }
1733
1734    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 {
1735        // async-virtual: try the derived exchange first
1736        if let Some(__v) = self.dispatch_to_derived("transfer", { let mut __args: Vec<crate::Value> = Vec::new(); __args.push(code); __args.push(amount); __args.push(fromAccount); __args.push(toAccount); __args.extend_from_slice(optional_args); __args }).await {
1737            if !matches!(__v, crate::Value::Null) { return __v; }
1738        }
1739
1740        let mut params = get_arg(optional_args, 0, Value::Map({
1741    let mut m = indexmap::IndexMap::new();
1742    m
1743}));
1744        panic!("{}", crate::exchange_errors::not_supported(format!("{}{}", self.id.clone(), Value::Str(" transfer() is not supported yet".into()))));
1745
1746    Value::Null
1747} }
1748
1749    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 {
1750        // async-virtual: try the derived exchange first
1751        if let Some(__v) = self.dispatch_to_derived("withdraw", { let mut __args: Vec<crate::Value> = Vec::new(); __args.push(code); __args.push(amount); __args.push(address); __args.extend_from_slice(optional_args); __args }).await {
1752            if !matches!(__v, crate::Value::Null) { return __v; }
1753        }
1754
1755        let mut params = get_arg(optional_args, 0, Value::Map({
1756    let mut m = indexmap::IndexMap::new();
1757    m
1758}));
1759        panic!("{}", crate::exchange_errors::not_supported(format!("{}{}", self.id.clone(), Value::Str(" withdraw() is not supported yet".into()))));
1760
1761    Value::Null
1762} }
1763
1764    fn create_deposit_address(&mut self, mut code: Value, optional_args: &[Value]) -> impl ::std::future::Future<Output = Value> + Send { async move {
1765        let mut params = get_arg(optional_args, 0, Value::Map({
1766    let mut m = indexmap::IndexMap::new();
1767    m
1768}));
1769        panic!("{}", crate::exchange_errors::not_supported(format!("{}{}", self.id.clone(), Value::Str(" createDepositAddress() is not supported yet".into()))));
1770
1771    Value::Null
1772} }
1773
1774    fn set_leverage(&mut self, mut leverage: Value, optional_args: &[Value]) -> impl ::std::future::Future<Output = Value> + Send { async move {
1775        // async-virtual: try the derived exchange first
1776        if let Some(__v) = self.dispatch_to_derived("set_leverage", { let mut __args: Vec<crate::Value> = Vec::new(); __args.push(leverage); __args.extend_from_slice(optional_args); __args }).await {
1777            if !matches!(__v, crate::Value::Null) { return __v; }
1778        }
1779
1780        let mut symbol = get_arg(optional_args, 0, Value::Null);
1781        let mut params = get_arg(optional_args, 1, Value::Map({
1782    let mut m = indexmap::IndexMap::new();
1783    m
1784}));
1785        panic!("{}", crate::exchange_errors::not_supported(format!("{}{}", self.id.clone(), Value::Str(" setLeverage() is not supported yet".into()))));
1786
1787    Value::Null
1788} }
1789
1790    fn fetch_leverage(&mut self, mut symbol: Value, optional_args: &[Value]) -> impl ::std::future::Future<Output = Value> + Send { async move {
1791        // async-virtual: try the derived exchange first
1792        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 {
1793            if !matches!(__v, crate::Value::Null) { return __v; }
1794        }
1795
1796        let mut params = get_arg(optional_args, 0, Value::Map({
1797    let mut m = indexmap::IndexMap::new();
1798    m
1799}));
1800        if (self.has.as_map().and_then(|__m| __m.get("fetchLeverages")).cloned().unwrap_or(Value::Null) != Value::Null) && (self.has.as_map().and_then(|__m| __m.get("fetchLeverages")).cloned().unwrap_or(Value::Null).as_bool() != Some(false)) {
1801            let mut leverages: Value = self.fetch_leverages(&[Value::from(vec![symbol.clone()]), params]).await;
1802            let mut leverage: Value = self.safe_dict(leverages, symbol, &[]);
1803            return leverage;
1804        }  else {
1805            panic!("{}", crate::exchange_errors::not_supported(format!("{}{}", self.id.clone(), Value::Str(" fetchLeverage() is not supported yet".into()))));
1806        }
1807
1808    Value::Null
1809} }
1810
1811    fn fetch_leverages(&mut self, optional_args: &[Value]) -> impl ::std::future::Future<Output = Value> + Send { async move {
1812        // async-virtual: try the derived exchange first
1813        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 {
1814            if !matches!(__v, crate::Value::Null) { return __v; }
1815        }
1816
1817        let mut symbols = get_arg(optional_args, 0, Value::Null);
1818        let mut params = get_arg(optional_args, 1, Value::Map({
1819    let mut m = indexmap::IndexMap::new();
1820    m
1821}));
1822        panic!("{}", crate::exchange_errors::not_supported(format!("{}{}", self.id.clone(), Value::Str(" fetchLeverages() is not supported yet".into()))));
1823
1824    Value::Null
1825} }
1826
1827    fn set_position_mode(&mut self, mut hedged: Value, optional_args: &[Value]) -> impl ::std::future::Future<Output = Value> + Send { async move {
1828        // async-virtual: try the derived exchange first
1829        if let Some(__v) = self.dispatch_to_derived("set_position_mode", { let mut __args: Vec<crate::Value> = Vec::new(); __args.push(hedged); __args.extend_from_slice(optional_args); __args }).await {
1830            if !matches!(__v, crate::Value::Null) { return __v; }
1831        }
1832
1833        let mut symbol = get_arg(optional_args, 0, Value::Null);
1834        let mut params = get_arg(optional_args, 1, Value::Map({
1835    let mut m = indexmap::IndexMap::new();
1836    m
1837}));
1838        panic!("{}", crate::exchange_errors::not_supported(format!("{}{}", self.id.clone(), Value::Str(" setPositionMode() is not supported yet".into()))));
1839
1840    Value::Null
1841} }
1842
1843    fn add_margin(&mut self, mut symbol: Value, mut amount: Value, optional_args: &[Value]) -> impl ::std::future::Future<Output = Value> + Send { async move {
1844        // async-virtual: try the derived exchange first
1845        if let Some(__v) = self.dispatch_to_derived("add_margin", { let mut __args: Vec<crate::Value> = Vec::new(); __args.push(symbol); __args.push(amount); __args.extend_from_slice(optional_args); __args }).await {
1846            if !matches!(__v, crate::Value::Null) { return __v; }
1847        }
1848
1849        let mut params = get_arg(optional_args, 0, Value::Map({
1850    let mut m = indexmap::IndexMap::new();
1851    m
1852}));
1853        panic!("{}", crate::exchange_errors::not_supported(format!("{}{}", self.id.clone(), Value::Str(" addMargin() is not supported yet".into()))));
1854
1855    Value::Null
1856} }
1857
1858    fn reduce_margin(&mut self, mut symbol: Value, mut amount: Value, optional_args: &[Value]) -> impl ::std::future::Future<Output = Value> + Send { async move {
1859        // async-virtual: try the derived exchange first
1860        if let Some(__v) = self.dispatch_to_derived("reduce_margin", { let mut __args: Vec<crate::Value> = Vec::new(); __args.push(symbol); __args.push(amount); __args.extend_from_slice(optional_args); __args }).await {
1861            if !matches!(__v, crate::Value::Null) { return __v; }
1862        }
1863
1864        let mut params = get_arg(optional_args, 0, Value::Map({
1865    let mut m = indexmap::IndexMap::new();
1866    m
1867}));
1868        panic!("{}", crate::exchange_errors::not_supported(format!("{}{}", self.id.clone(), Value::Str(" reduceMargin() is not supported yet".into()))));
1869
1870    Value::Null
1871} }
1872
1873    fn set_margin(&mut self, mut symbol: Value, mut amount: Value, optional_args: &[Value]) -> impl ::std::future::Future<Output = Value> + Send { async move {
1874        let mut params = get_arg(optional_args, 0, Value::Map({
1875    let mut m = indexmap::IndexMap::new();
1876    m
1877}));
1878        panic!("{}", crate::exchange_errors::not_supported(format!("{}{}", self.id.clone(), Value::Str(" setMargin() is not supported yet".into()))));
1879
1880    Value::Null
1881} }
1882
1883    fn fetch_long_short_ratio(&mut self, mut symbol: Value, optional_args: &[Value]) -> impl ::std::future::Future<Output = Value> + Send { async move {
1884        let mut timeframe = get_arg(optional_args, 0, Value::Null);
1885        let mut params = get_arg(optional_args, 1, Value::Map({
1886    let mut m = indexmap::IndexMap::new();
1887    m
1888}));
1889        panic!("{}", crate::exchange_errors::not_supported(format!("{}{}", self.id.clone(), Value::Str(" fetchLongShortRatio() is not supported yet".into()))));
1890
1891    Value::Null
1892} }
1893
1894    fn fetch_long_short_ratio_history(&mut self, optional_args: &[Value]) -> impl ::std::future::Future<Output = Value> + Send { async move {
1895        let mut symbol = get_arg(optional_args, 0, Value::Null);
1896        let mut timeframe = get_arg(optional_args, 1, Value::Null);
1897        let mut since = get_arg(optional_args, 2, Value::Null);
1898        let mut limit = get_arg(optional_args, 3, Value::Null);
1899        let mut params = get_arg(optional_args, 4, Value::Map({
1900    let mut m = indexmap::IndexMap::new();
1901    m
1902}));
1903        panic!("{}", crate::exchange_errors::not_supported(format!("{}{}", self.id.clone(), Value::Str(" fetchLongShortRatioHistory() is not supported yet".into()))));
1904
1905    Value::Null
1906} }
1907
1908    fn fetch_margin_adjustment_history(&mut self, optional_args: &[Value]) -> impl ::std::future::Future<Output = Value> + Send { async move {
1909        let mut symbol = get_arg(optional_args, 0, Value::Null);
1910        let mut type_var = get_arg(optional_args, 1, Value::Null);
1911        let mut since = get_arg(optional_args, 2, Value::Null);
1912        let mut limit = get_arg(optional_args, 3, Value::Null);
1913        let mut params = get_arg(optional_args, 4, Value::Map({
1914    let mut m = indexmap::IndexMap::new();
1915    m
1916}));
1917        panic!("{}", crate::exchange_errors::not_supported(format!("{}{}", self.id.clone(), Value::Str(" fetchMarginAdjustmentHistory() is not supported yet".into()))));
1918
1919    Value::Null
1920} }
1921
1922    fn set_margin_mode(&mut self, mut marginMode: Value, optional_args: &[Value]) -> impl ::std::future::Future<Output = Value> + Send { async move {
1923        // async-virtual: try the derived exchange first
1924        if let Some(__v) = self.dispatch_to_derived("set_margin_mode", { let mut __args: Vec<crate::Value> = Vec::new(); __args.push(marginMode); __args.extend_from_slice(optional_args); __args }).await {
1925            if !matches!(__v, crate::Value::Null) { return __v; }
1926        }
1927
1928        let mut symbol = get_arg(optional_args, 0, Value::Null);
1929        let mut params = get_arg(optional_args, 1, Value::Map({
1930    let mut m = indexmap::IndexMap::new();
1931    m
1932}));
1933        panic!("{}", crate::exchange_errors::not_supported(format!("{}{}", self.id.clone(), Value::Str(" setMarginMode() is not supported yet".into()))));
1934
1935    Value::Null
1936} }
1937
1938    fn fetch_deposit_addresses_by_network(&mut self, mut code: Value, optional_args: &[Value]) -> impl ::std::future::Future<Output = Value> + Send { async move {
1939        // async-virtual: try the derived exchange first
1940        if let Some(__v) = self.dispatch_to_derived("fetch_deposit_addresses_by_network", { let mut __args: Vec<crate::Value> = Vec::new(); __args.push(code); __args.extend_from_slice(optional_args); __args }).await {
1941            if !matches!(__v, crate::Value::Null) { return __v; }
1942        }
1943
1944        let mut params = get_arg(optional_args, 0, Value::Map({
1945    let mut m = indexmap::IndexMap::new();
1946    m
1947}));
1948        panic!("{}", crate::exchange_errors::not_supported(format!("{}{}", self.id.clone(), Value::Str(" fetchDepositAddressesByNetwork() is not supported yet".into()))));
1949
1950    Value::Null
1951} }
1952
1953    fn fetch_open_interest_history(&mut self, mut symbol: Value, optional_args: &[Value]) -> impl ::std::future::Future<Output = Value> + Send { async move {
1954        let mut timeframe = get_arg(optional_args, 0, Value::Str("1h".into()));
1955        let mut since = get_arg(optional_args, 1, Value::Null);
1956        let mut limit = get_arg(optional_args, 2, Value::Null);
1957        let mut params = get_arg(optional_args, 3, Value::Map({
1958    let mut m = indexmap::IndexMap::new();
1959    m
1960}));
1961        panic!("{}", crate::exchange_errors::not_supported(format!("{}{}", self.id.clone(), Value::Str(" fetchOpenInterestHistory() is not supported yet".into()))));
1962
1963    Value::Null
1964} }
1965
1966    fn fetch_open_interests(&mut self, optional_args: &[Value]) -> impl ::std::future::Future<Output = Value> + Send { async move {
1967        // async-virtual: try the derived exchange first
1968        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 {
1969            if !matches!(__v, crate::Value::Null) { return __v; }
1970        }
1971
1972        let mut symbols = get_arg(optional_args, 0, Value::Null);
1973        let mut params = get_arg(optional_args, 1, Value::Map({
1974    let mut m = indexmap::IndexMap::new();
1975    m
1976}));
1977        panic!("{}", crate::exchange_errors::not_supported(format!("{}{}", self.id.clone(), Value::Str(" fetchOpenInterests() is not supported yet".into()))));
1978
1979    Value::Null
1980} }
1981
1982    fn sign_in(&mut self, optional_args: &[Value]) -> impl ::std::future::Future<Output = Value> + Send { async move {
1983        // async-virtual: try the derived exchange first
1984        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 {
1985            if !matches!(__v, crate::Value::Null) { return __v; }
1986        }
1987
1988        let mut params = get_arg(optional_args, 0, Value::Map({
1989    let mut m = indexmap::IndexMap::new();
1990    m
1991}));
1992        panic!("{}", crate::exchange_errors::not_supported(format!("{}{}", self.id.clone(), Value::Str(" signIn() is not supported yet".into()))));
1993
1994    Value::Null
1995} }
1996
1997    fn fetch_payment_methods(&mut self, optional_args: &[Value]) -> impl ::std::future::Future<Output = Value> + Send { async move {
1998        let mut params = get_arg(optional_args, 0, Value::Map({
1999    let mut m = indexmap::IndexMap::new();
2000    m
2001}));
2002        panic!("{}", crate::exchange_errors::not_supported(format!("{}{}", self.id.clone(), Value::Str(" fetchPaymentMethods() is not supported yet".into()))));
2003
2004    Value::Null
2005} }
2006
2007    fn parse_to_int(&self, mut number: Value) -> Value {
2008        // Solve Common parseInt misuse ex: parseInt ((since / 1000).toString ())
2009        // using a number as parameter which is not valid in ts
2010        // numberToString is typed as nullable under strictNullChecks; cast to string
2011        // the cast is erased at transpile-time, so output matches every target language, rather than
2012        // branching to a bare `NaN` literal, which has no symbol in Go/Java/C#
2013        let mut stringifiedNumber: Value = self.number_to_string(number);
2014        let mut convertedNumber: Value = (match &stringifiedNumber { Value::Str(__parse_s) => __parse_s.trim().parse::<f64>().map(Value::Float).unwrap_or(Value::Null), Value::Float(__parse_f) => Value::Float(*__parse_f), Value::Int(__parse_n) => Value::Float(*__parse_n as f64), _ => Value::Null });
2015        return crate::runtime::parse_int(&convertedNumber);
2016
2017    Value::Null
2018}
2019
2020    fn parse_to_numeric(&self, mut number: Value) -> Value {
2021        let mut stringVersion: Value = self.number_to_string(number); // this will convert 1.0 and 1 to "1" and 1.1 to "1.1"
2022        // keep this in mind:
2023        // in JS:     1 === 1.0 is true
2024        // in Python: 1 == 1.0 is true
2025        // in PHP:    1 == 1.0 is true, but 1 === 1.0 is false.
2026        if Value::Int(stringVersion.as_str().and_then(|__s| __s.find(".")).map(|__i| __i as i64).unwrap_or(-1)).as_f64().unwrap_or(f64::NAN) >= ((0i64) as f64) {
2027            return (match &stringVersion { Value::Str(__parse_s) => __parse_s.trim().parse::<f64>().map(Value::Float).unwrap_or(Value::Null), Value::Float(__parse_f) => Value::Float(*__parse_f), Value::Int(__parse_n) => Value::Float(*__parse_n as f64), _ => Value::Null });
2028        }
2029        return (match &stringVersion { Value::Str(__parse_s) => __parse_s.trim().parse::<i64>().map(Value::Int).unwrap_or(Value::Null), Value::Int(__parse_n) => Value::Int(*__parse_n), Value::Float(__parse_f) => Value::Int(*__parse_f as i64), _ => Value::Null });
2030
2031    Value::Null
2032}
2033
2034    fn is_round_number(&self, mut value: Value) -> Value {
2035        // this method is similar to isInteger, but this is more loyal and does not check for types.
2036        // i.e. isRoundNumber(1.000) returns true, while isInteger(1.000) returns false
2037        let mut res: Value = self.parse_to_numeric((mod_val(&value, &Value::Int(1))));
2038        return Value::Bool(res.as_f64() == Some(0.0));
2039
2040    Value::Null
2041}
2042
2043    fn is_empty_string(&self, mut value: Value) -> Value {
2044        return Value::Bool(!(self.value_is_defined(value.clone()).as_bool() == Some(true)) || (value.as_str() == Some("")));
2045
2046    Value::Null
2047}
2048
2049    fn safe_number_omit_zero(&self, mut obj: Value, mut key: Value, optional_args: &[Value]) -> Value {
2050        let mut defaultValue = get_arg(optional_args, 0, Value::Null);
2051        let mut value: Value = self.safe_string(obj, key, &[]);
2052        let mut final_val: Value = self.parse_number(self.omit_zero(value), &[]);
2053        return (if (final_val == Value::Null) { defaultValue } else { final_val });
2054
2055    Value::Null
2056}
2057
2058    fn safe_integer_omit_zero(&self, mut obj: Value, mut key: Value, optional_args: &[Value]) -> Value {
2059        let mut defaultValue = get_arg(optional_args, 0, Value::Null);
2060        let mut timestamp: Value = self.safe_integer(obj, key, &[defaultValue]);
2061        if (timestamp == Value::Null) || (timestamp.as_f64() == Some(0.0)) {
2062            return Value::Null;
2063        }
2064        return timestamp;
2065
2066    Value::Null
2067}
2068
2069    fn after_construct(&mut self, optional_args: &[Value]) {
2070        let mut userConfig = get_arg(optional_args, 0, Value::Map({
2071    let mut m = indexmap::IndexMap::new();
2072    m
2073}));
2074        let __userConfig_empty = indexmap::IndexMap::new();
2075        let userConfig = userConfig.as_map().unwrap_or(&__userConfig_empty);
2076        // networksById: inverse of options.networks, explicit options.networksById entries win
2077        let mut networkIdsToCodesGenerated: Value = self.invert_flat_string_dictionary(self.safe_value_k(self.options.clone(), "networks", &[Value::Map({
2078            let mut m = indexmap::IndexMap::new();
2079            m
2080        })]));
2081        { let __be_tmp = self.extend(networkIdsToCodesGenerated, &[self.safe_value_k(self.options.clone(), "networksById", &[Value::Map({
2082    let mut m = indexmap::IndexMap::new();
2083    m
2084})])]); if let Value::Dict(__d) = &mut self.options { std::sync::Arc::make_mut(__d).insert("networksById".into(), __be_tmp); } }
2085        self.features_generator();
2086        self.has_autocorrect();
2087        // init predefined markets if any
2088        if (self.markets.clone() != Value::Null) {
2089            self.set_markets(self.markets.clone(), &[]);
2090        }
2091        // init the request rate limiter
2092        self.init_rest_rate_limiter();
2093        // sanbox mode
2094        let mut isSandbox: Value = self.safe_bool2(self.options.clone(), Value::Str("sandbox".into()), Value::Str("testnet".into()), &[Value::Bool(false)]);
2095        if (isSandbox.as_bool() == Some(true)) {
2096            self.set_sandbox_mode(isSandbox);
2097        }
2098        // compatibility for sandbox/testnet options in userConfig
2099        if matches!(((match userConfig.get("sandbox") { Some(Value::Bool(__b)) => Value::Bool(*__b), _ => Value::Bool(false) })), Value::Bool(true)) || matches!(((match userConfig.get("testnet") { Some(Value::Bool(__b)) => Value::Bool(*__b), _ => Value::Bool(false) })), Value::Bool(true)) {
2100            self.set_sandbox_mode(Value::Bool(true));
2101        }
2102}
2103
2104    fn has_autocorrect(&self) {
2105        let mut fallbacks: Value = Value::Map({
2106            let mut m = indexmap::IndexMap::new();
2107                m.insert("fetchL2OrderBook".to_string(), Value::Str("fetchOrderBook".into()));
2108                m.insert("createLimitOrder".to_string(), Value::Str("createOrder".into()));
2109                m.insert("createMarketOrder".to_string(), Value::Str("createOrder".into()));
2110                m.insert("createLimitOrderWs".to_string(), Value::Str("createOrderWs".into()));
2111                m.insert("createMarketOrderWs".to_string(), Value::Str("createOrderWs".into()));
2112            m
2113        });
2114        let mut targets: Value = object_keys(&fallbacks);
2115        {
2116                        let mut i: Value = Value::Int(0);
2117            let mut __for_first_81: bool = true;
2118            while { if !__for_first_81 { i = (match (&(i), &(Value::Int(1))) { (Value::Int(x), Value::Int(y)) => Value::Int(x + y), (Value::Int(x), Value::Float(y)) => Value::Float(*x as f64 + *y), (Value::Float(x), Value::Int(y)) => Value::Float(*x + *y as f64), (Value::Float(x), Value::Float(y)) => Value::Float(x + y), _ => Value::Null }); } __for_first_81 = false; i.as_f64().unwrap_or(f64::NAN) < ((targets.len() as i64) as f64) } {
2119            let mut target: Value = targets.as_array().and_then(|__arr| match &i { Value::Int(__n) => __arr.get(*__n as usize), Value::Str(__s) => __s.parse::<usize>().ok().and_then(|__n| __arr.get(__n)), _ => None }).cloned().unwrap_or(Value::Null);
2120            let mut source: Value = fallbacks.as_map().and_then(|__m| target.as_str().and_then(|__k| __m.get(__k))).cloned().unwrap_or(Value::Null);
2121            let mut sourceDefined: bool = (in_op(&self.has, &source)) && (get_value(&self.has, &source) != Value::Null);
2122            let mut targetDefined: bool = (in_op(&self.has, &target)) && (get_value(&self.has, &target) != Value::Null);
2123            if sourceDefined && !targetDefined {
2124                { let __be_tmp = get_value(&self.has, &source); if let Value::Dict(__d) = &mut self.has.clone() { std::sync::Arc::make_mut(__d).insert(crate::runtime::stringify_param(&target), __be_tmp); } }
2125            }
2126        }
2127        }
2128}
2129
2130    fn init_rest_rate_limiter(&mut self) {
2131        if (self.rateLimit.clone() == Value::Null) || ((self.id.clone() != Value::Null) && (self.rateLimit.as_f64() == Value::Int(-1).as_f64())) {
2132            panic!("{}", crate::exchange_errors::exchange_error(format!("{}{}", self.id.clone(), Value::Str(".rateLimit property is not configured".into()))));
2133        }
2134        let mut refillRate: Value = self.MAX_VALUE.clone();
2135        if self.rateLimit.as_f64().unwrap_or(f64::NAN) > ((0i64) as f64) {
2136            refillRate = (match ((Value::Int(1)).as_f64(), (self.rateLimit.clone()).as_f64()) { (Some(x), Some(y)) if y != 0.0 => Value::Float(x / y), _ => Value::Null });
2137        }
2138        let mut useLeaky: bool = (self.rollingWindowSize.as_f64() == Some(0.0)) || (self.rateLimiterAlgorithm.as_str() == Some("leakyBucket"));
2139        let mut algorithm: Value = (if useLeaky { Value::Str("leakyBucket".into()) } else { Value::Str("rollingWindow".into()) });
2140        let mut defaultBucket: Value = Value::Map({
2141            let mut m = indexmap::IndexMap::new();
2142                m.insert("delay".to_string(), Value::Float(0.001));
2143                m.insert("capacity".to_string(), Value::Int(1));
2144                m.insert("cost".to_string(), Value::Int(1));
2145                m.insert("refillRate".to_string(), refillRate);
2146                m.insert("algorithm".to_string(), algorithm);
2147                m.insert("windowSize".to_string(), self.rollingWindowSize.clone());
2148                m.insert("rateLimit".to_string(), self.rateLimit.clone());
2149            m
2150        });
2151        let mut existingBucket: Value = (if (self.tokenBucket.clone() == Value::Null) { Value::Map({
2152    let mut m = indexmap::IndexMap::new();
2153    m
2154}) } else { self.tokenBucket.clone() });
2155        { let __t = self.extend(defaultBucket, &[existingBucket]); self.tokenBucket = __t; }
2156        self.init_throttler();
2157}
2158
2159    fn features_generator(&mut self) {
2160        //
2161        // in the exchange-specific features can be something like this, where we support 'string' aliases too:
2162        //
2163        //     {
2164        //         'my' : {
2165        //             'createOrder' : {...},
2166        //         },
2167        //         'swap': {
2168        //             'linear': {
2169        //                 'extends': my',
2170        //             },
2171        //         },
2172        //     }
2173        //
2174        if (self.features.clone() == Value::Null) {
2175            return;
2176        }
2177        // reconstruct
2178        let mut initialFeatures: Value = self.features.clone();
2179        self.features = Value::Map({
2180            let mut m = indexmap::IndexMap::new();
2181            m
2182        });
2183        let mut unifiedMarketTypes: Value = Value::from(vec![Value::Str("spot".into()), Value::Str("swap".into()), Value::Str("future".into()), Value::Str("option".into())]);
2184        let mut subTypes: Value = Value::from(vec![Value::Str("linear".into()), Value::Str("inverse".into())]);
2185        {
2186                        let mut i: Value = Value::Int(0);
2187            let mut __for_first_83: bool = true;
2188            while { if !__for_first_83 { i = (match (&(i), &(Value::Int(1))) { (Value::Int(x), Value::Int(y)) => Value::Int(x + y), (Value::Int(x), Value::Float(y)) => Value::Float(*x as f64 + *y), (Value::Float(x), Value::Int(y)) => Value::Float(*x + *y as f64), (Value::Float(x), Value::Float(y)) => Value::Float(x + y), _ => Value::Null }); } __for_first_83 = false; i.as_f64().unwrap_or(f64::NAN) < ((unifiedMarketTypes.len() as i64) as f64) } {
2189            let mut marketType: Value = unifiedMarketTypes.as_array().and_then(|__arr| match &i { Value::Int(__n) => __arr.get(*__n as usize), Value::Str(__s) => __s.parse::<usize>().ok().and_then(|__n| __arr.get(__n)), _ => None }).cloned().unwrap_or(Value::Null);
2190            // if marketType is not filled for this exchange, don't add that in `features`
2191            if !(in_op(&initialFeatures, &marketType)) {
2192                if let Value::Dict(__d) = &mut self.features { std::sync::Arc::make_mut(__d).insert(crate::runtime::stringify_param(&marketType), Value::Null); }
2193            }  else {
2194                if (marketType.as_str() == Some("spot")) {
2195                    { let __be_tmp = self.features_mapper(initialFeatures.clone(), marketType.clone(), &[]); if let Value::Dict(__d) = &mut self.features { std::sync::Arc::make_mut(__d).insert(crate::runtime::stringify_param(&marketType), __be_tmp); } }
2196                }  else {
2197                    if let Value::Dict(__d) = &mut self.features { std::sync::Arc::make_mut(__d).insert(crate::runtime::stringify_param(&marketType), Value::Map({
2198    let mut m = indexmap::IndexMap::new();
2199    m
2200})); }
2201                    {
2202                                                let mut j: Value = Value::Int(0);
2203                        let mut __for_first_82: bool = true;
2204                        while { if !__for_first_82 { j = (match (&(j), &(Value::Int(1))) { (Value::Int(x), Value::Int(y)) => Value::Int(x + y), (Value::Int(x), Value::Float(y)) => Value::Float(*x as f64 + *y), (Value::Float(x), Value::Int(y)) => Value::Float(*x + *y as f64), (Value::Float(x), Value::Float(y)) => Value::Float(x + y), _ => Value::Null }); } __for_first_82 = false; j.as_f64().unwrap_or(f64::NAN) < ((subTypes.len() as i64) as f64) } {
2205                        let mut subType: Value = subTypes.as_array().and_then(|__arr| match &j { Value::Int(__n) => __arr.get(*__n as usize), Value::Str(__s) => __s.parse::<usize>().ok().and_then(|__n| __arr.get(__n)), _ => None }).cloned().unwrap_or(Value::Null);
2206                        { 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); };
2207                    }
2208                    }
2209                }
2210            }
2211        }
2212        }
2213}
2214
2215    fn features_mapper(&mut self, mut initialFeatures: Value, mut marketType: Value, optional_args: &[Value]) -> Value {
2216        let mut subType = get_arg(optional_args, 0, Value::Null);
2217        let mut featuresObj: Value = (if (subType != Value::Null) { get_value(&initialFeatures.as_map().and_then(|__m| marketType.as_str().and_then(|__k| __m.get(__k))).cloned().unwrap_or(Value::Null), &subType) } else { initialFeatures.as_map().and_then(|__m| marketType.as_str().and_then(|__k| __m.get(__k))).cloned().unwrap_or(Value::Null) });
2218        // if exchange does not have that market-type (eg. future>inverse)
2219        if (featuresObj == Value::Null) {
2220            return Value::Null;
2221        }
2222        let mut extendsStr: Value = self.safe_string_k(featuresObj.clone(), "extends", &[]);
2223        if (extendsStr != Value::Null) {
2224            featuresObj = self.omit(featuresObj.clone(), Value::Str("extends".into()), &[]);
2225            let mut extendObj: Value = self.features_mapper(initialFeatures, extendsStr, &[]);
2226            featuresObj = self.deep_extend(extendObj, &[featuresObj.clone()]);
2227        }
2228        //
2229        // ### corrections ###
2230        //
2231        // createOrder
2232        if (in_op(&featuresObj, &Value::Str("createOrder".into()))) {
2233            let mut value: Value = self.safe_dict_k(crate::value::get_value_k(&featuresObj, "createOrder"), "attachedStopLossTakeProfit", &[]);
2234            add_element_to_object(get_value_mut(&mut featuresObj, &Value::Str("createOrder".into())), &Value::Str("stopLoss".into()), value.clone());
2235            add_element_to_object(get_value_mut(&mut featuresObj, &Value::Str("createOrder".into())), &Value::Str("takeProfit".into()), value.clone());
2236            if (marketType.as_str() == Some("spot")) {
2237                // default 'hedged': false
2238                add_element_to_object(get_value_mut(&mut featuresObj, &Value::Str("createOrder".into())), &Value::Str("hedged".into()), Value::Bool(false));
2239                // default 'leverage': false
2240                if !(in_op(&crate::value::get_value_k(&featuresObj, "createOrder"), &Value::Str("leverage".into()))) {
2241                    add_element_to_object(get_value_mut(&mut featuresObj, &Value::Str("createOrder".into())), &Value::Str("leverage".into()), Value::Bool(false));
2242                }
2243            }
2244            // default 'GTC' to true
2245            if (self.safe_bool(crate::value::get_value_k(&crate::value::get_value_k(&featuresObj, "createOrder"), "timeInForce"), Value::Str("GTC".into()), &[]) == Value::Null) {
2246                add_element_to_object(get_value_mut(get_value_mut(&mut featuresObj, &Value::Str("createOrder".into())), &Value::Str("timeInForce".into())), &Value::Str("GTC".into()), Value::Bool(true));
2247            }
2248        }
2249        // other methods
2250        let mut keys: Value = object_keys(&featuresObj);
2251        {
2252                        let mut i: Value = Value::Int(0);
2253            let mut __for_first_84: bool = true;
2254            while { if !__for_first_84 { i = (match (&(i), &(Value::Int(1))) { (Value::Int(x), Value::Int(y)) => Value::Int(x + y), (Value::Int(x), Value::Float(y)) => Value::Float(*x as f64 + *y), (Value::Float(x), Value::Int(y)) => Value::Float(*x + *y as f64), (Value::Float(x), Value::Float(y)) => Value::Float(x + y), _ => Value::Null }); } __for_first_84 = false; i.as_f64().unwrap_or(f64::NAN) < ((keys.len() as i64) as f64) } {
2255            let mut key: Value = keys.as_array().and_then(|__arr| match &i { Value::Int(__n) => __arr.get(*__n as usize), Value::Str(__s) => __s.parse::<usize>().ok().and_then(|__n| __arr.get(__n)), _ => None }).cloned().unwrap_or(Value::Null);
2256            let mut featureBlock: Value = get_value(&featuresObj, &key);
2257            let mut featureBlock: Value = get_value(&featuresObj, &key);
2258            if !(self.in_array(key.clone(), Value::from(vec![Value::Str("sandbox".into())])).as_bool() == Some(true)) && (featureBlock != Value::Null) {
2259                // default "symbolRequired" to false to all methods (except `createOrder`)
2260                if !(in_op(&featureBlock, &Value::Str("symbolRequired".into()))) {
2261                    add_element_to_object(&mut featureBlock, &Value::Str("symbolRequired".into()), self.in_array(key, Value::from(vec![Value::Str("createOrder".into()), Value::Str("createOrders".into()), Value::Str("fetchOHLCV".into())])));
2262                }
2263            }
2264        }
2265        }
2266        return featuresObj;
2267
2268    Value::Null
2269}
2270
2271    fn feature_value(&self, mut symbol: Value, optional_args: &[Value]) -> Value {
2272        let mut methodName = get_arg(optional_args, 0, Value::Null);
2273        let mut paramName = get_arg(optional_args, 1, Value::Null);
2274        let mut defaultValue = get_arg(optional_args, 2, Value::Null);
2275        /*
2276         * @method
2277         * @name exchange#featureValue
2278         * @description this method is a very deterministic to help users to know what feature is supported by the exchange
2279         * @param {string} [symbol] unified symbol
2280         * @param {string} [methodName] view currently supported methods: https://docs.ccxt.com/README?id=features
2281         * @param {string} [paramName] unified param value, like: `triggerPrice`, `stopLoss.triggerPrice` (check docs for supported param names)
2282         * @param {object} [defaultValue] return default value if no result found
2283         * @returns {object} returns feature value
2284         */
2285        let mut market: Value = <Self as crate::exchange_generated::ExchangeBase>::market(self, symbol.clone());
2286        return self.feature_value_by_type(market.as_map().and_then(|__m| __m.get("type")).cloned().unwrap_or(Value::Null), market.as_map().and_then(|__m| __m.get("subType")).cloned().unwrap_or(Value::Null), &[methodName, paramName, defaultValue]);
2287
2288    Value::Null
2289}
2290
2291    fn feature_value_by_type(&self, mut marketType: Value, mut subType: Value, optional_args: &[Value]) -> Value {
2292        let mut methodName = get_arg(optional_args, 0, Value::Null);
2293        let mut paramName = get_arg(optional_args, 1, Value::Null);
2294        let mut defaultValue = get_arg(optional_args, 2, Value::Null);
2295        /*
2296         * @method
2297         * @name exchange#featureValueByType
2298         * @description this method is a very deterministic to help users to know what feature is supported by the exchange
2299         * @param {string} [marketType] supported only: "spot", "swap", "future"
2300         * @param {string} [subType] supported only: "linear", "inverse"
2301         * @param {string} [methodName] view currently supported methods: https://docs.ccxt.com/README?id=features
2302         * @param {string} [paramName] unified param value (check docs for supported param names)
2303         * @param {object} [defaultValue] return default value if no result found
2304         * @returns {object} returns feature value
2305         */
2306        // if exchange does not yet have features manually implemented
2307        if (self.features.clone() == Value::Null) {
2308            return defaultValue;
2309        }
2310        if (marketType == Value::Null) {
2311            return defaultValue;
2312        }
2313        // if marketType (e.g. 'option') does not exist in features
2314        if !(in_op(&self.features, &marketType)) {
2315            return defaultValue;
2316        }
2317        // if marketType dict undefined
2318        if (get_value(&self.features, &marketType) == Value::Null) {
2319            return defaultValue;
2320        }
2321        let mut methodsContainer: Value = get_value(&self.features, &marketType);
2322        if (subType == Value::Null) {
2323            if (marketType.as_str() != Some("spot")) {
2324                return defaultValue;
2325            }
2326        }  else {
2327            if !(in_op(&get_value(&self.features, &marketType), &subType)) {
2328                return defaultValue;
2329            }
2330            // if subType dict undefined
2331            if (get_value(&get_value(&self.features, &marketType), &subType) == Value::Null) {
2332                return defaultValue;
2333            }
2334            methodsContainer = get_value(&get_value(&self.features, &marketType), &subType);
2335        }
2336        // if user wanted only marketType and didn't provide methodName, eg: featureIsSupported('spot')
2337        if (methodName == Value::Null) {
2338            return (if (defaultValue != Value::Null) { defaultValue.clone() } else { methodsContainer.clone() });
2339        }
2340        if !(in_op(&methodsContainer, &methodName)) {
2341            return defaultValue;
2342        }
2343        let mut methodDict: Value = get_value(&methodsContainer, &methodName);
2344        let mut methodDict: Value = get_value(&methodsContainer, &methodName);
2345        if (methodDict == Value::Null) {
2346            return defaultValue;
2347        }
2348        // if user wanted only method and didn't provide `paramName`, eg: featureIsSupported('swap', 'linear', 'createOrder')
2349        if (paramName == Value::Null) {
2350            return (if (defaultValue != Value::Null) { defaultValue.clone() } else { methodDict.clone() });
2351        }
2352        let mut splited: Value = split(&paramName, &Value::Str(".".into())); // can be only parent key (`stopLoss`) or with child (`stopLoss.triggerPrice`)
2353        let mut parentKey: Value = splited.as_array().and_then(|__arr| __arr.get(0)).cloned().unwrap_or(Value::Null);
2354        let mut subKey: Value = self.safe_string(splited, Value::Int(1), &[]);
2355        if !(in_op(&methodDict, &parentKey)) {
2356            return defaultValue;
2357        }
2358        let mut dictionary: Value = self.safe_dict(methodDict.clone(), parentKey.clone(), &[]);
2359        if (dictionary == Value::Null) {
2360            return get_value(&methodDict, &parentKey);
2361        }  else {
2362            // return as is, when calling without subKey eg: featureValueByType('spot', undefined, 'createOrder', 'stopLoss')
2363            if (subKey == Value::Null) {
2364                return get_value(&methodDict, &parentKey);
2365            }
2366            // throw an exception for unsupported subKey
2367            if !(in_op(&get_value(&methodDict, &parentKey), &subKey)) {
2368                return defaultValue;
2369            }
2370            return get_value(&get_value(&methodDict, &parentKey), &subKey);
2371        }
2372
2373    Value::Null
2374}
2375
2376    fn orderbook_checksum_message(&self, mut symbol: Value) -> Value {
2377        if (symbol == Value::Null) {
2378            panic!("{}", crate::exchange_errors::arguments_required(format!("{}{}", self.id.clone(), Value::Str(" orderbookChecksumMessage() requires a symbol argument".into()))));
2379        }
2380        return Value::Str(format!("{}{}", Value::Str(format!("{}{}", symbol, Value::Str(" : ".into())).into()), 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".into())).into());
2381
2382    Value::Null
2383}
2384
2385    fn get_default_options(&self) -> Value {
2386        return Value::Map({
2387    let mut m = indexmap::IndexMap::new();
2388        m.insert("withdrawTagRequiredCurrencies".to_string(), Value::from(vec![Value::Str("XRP".into()), Value::Str("XLM".into()), Value::Str("EOS".into()), Value::Str("ATOM".into()), Value::Str("HBAR".into()), Value::Str("TON".into()), Value::Str("KAVA".into()), Value::Str("STX".into()), Value::Str("XEM".into()), Value::Str("IOST".into()), Value::Str("OSMO".into()), Value::Str("WAXP".into())]));
2389    m
2390});
2391
2392    Value::Null
2393}
2394
2395    fn safe_ledger_entry(&self, mut entry: Value, optional_args: &[Value]) -> Value {
2396        let mut currency = get_arg(optional_args, 0, Value::Null);
2397        let mut currencyResolved: Value = self.safe_currency(Value::Null, &[currency]);
2398        let mut direction: Value = self.safe_string_k(entry.clone(), "direction", &[]);
2399        let mut before: Value = self.safe_string_k(entry.clone(), "before", &[]);
2400        let mut after: Value = self.safe_string_k(entry.clone(), "after", &[]);
2401        let mut amount: Value = self.safe_string_k(entry.clone(), "amount", &[]);
2402        if (amount != Value::Null) {
2403            if (before == Value::Null) && (after != Value::Null) {
2404                before = crate::precise::Precise::stringSub(&after, &amount);
2405            }  else if (before != Value::Null) && (after == Value::Null) {
2406                after = crate::precise::Precise::stringAdd(&before, &amount);
2407            }
2408        }
2409        if (before != Value::Null) && (after != Value::Null) {
2410            if (direction == Value::Null) {
2411                if is_true(&crate::precise::Precise::stringGt(&before, &after)) {
2412                    direction = Value::Str("out".into());
2413                }
2414                if is_true(&crate::precise::Precise::stringGt(&after, &before)) {
2415                    direction = Value::Str("in".into());
2416                }
2417            }
2418        }
2419        let mut fee: Value = self.safe_value_k(entry.clone(), "fee", &[]);
2420        if (fee != Value::Null) {
2421            { let __be_tmp = self.safe_number_k(fee.clone(), "cost", &[]); add_element_to_object(&mut fee, &Value::Str("cost".into()), __be_tmp); };
2422        }
2423        let mut timestamp: Value = self.safe_integer_k(entry.clone(), "timestamp", &[]);
2424        let mut info: Value = self.safe_dict_k(entry.clone(), "info", &[Value::Map({
2425    let mut m = indexmap::IndexMap::new();
2426    m
2427})]);
2428        return Value::Map({
2429    let mut m = indexmap::IndexMap::new();
2430        m.insert("id".to_string(), self.safe_string_k(entry.clone(), "id", &[]));
2431        m.insert("timestamp".to_string(), timestamp.clone());
2432        m.insert("datetime".to_string(), self.iso8601(timestamp));
2433        m.insert("direction".to_string(), direction);
2434        m.insert("account".to_string(), self.safe_string_k(entry.clone(), "account", &[]));
2435        m.insert("referenceId".to_string(), self.safe_string_k(entry.clone(), "referenceId", &[]));
2436        m.insert("referenceAccount".to_string(), self.safe_string_k(entry.clone(), "referenceAccount", &[]));
2437        m.insert("type".to_string(), self.safe_string_k(entry.clone(), "type", &[]));
2438        m.insert("currency".to_string(), currencyResolved.as_map().and_then(|__m| __m.get("code")).cloned().unwrap_or(Value::Null));
2439        m.insert("amount".to_string(), self.parse_number(amount, &[]));
2440        m.insert("before".to_string(), self.parse_number(before, &[]));
2441        m.insert("after".to_string(), self.parse_number(after, &[]));
2442        m.insert("status".to_string(), self.safe_string_k(entry, "status", &[]));
2443        m.insert("fee".to_string(), fee);
2444        m.insert("info".to_string(), info);
2445    m
2446});
2447
2448    Value::Null
2449}
2450
2451    fn safe_currency_structure(&self, mut currency: Value) -> Value {
2452        // derive data from networks: deposit, withdraw, active, fee, limits, precision
2453        let mut networks: Value = self.safe_dict_k(currency.clone(), "networks", &[Value::Map({
2454    let mut m = indexmap::IndexMap::new();
2455    m
2456})]);
2457        let mut keys: Value = object_keys(&networks);
2458        let mut length: f64 = ((keys.len() as i64) as f64);
2459        if (length != 0.0) {
2460            {
2461                                let mut i: Value = Value::Int(0);
2462                let mut __for_first_85: bool = true;
2463                while { if !__for_first_85 { i = (match (&(i), &(Value::Int(1))) { (Value::Int(x), Value::Int(y)) => Value::Int(x + y), (Value::Int(x), Value::Float(y)) => Value::Float(*x as f64 + *y), (Value::Float(x), Value::Int(y)) => Value::Float(*x + *y as f64), (Value::Float(x), Value::Float(y)) => Value::Float(x + y), _ => Value::Null }); } __for_first_85 = false; i.as_f64().unwrap_or(f64::NAN) < length } {
2464                let mut key: Value = keys.as_array().and_then(|__arr| match &i { Value::Int(__n) => __arr.get(*__n as usize), Value::Str(__s) => __s.parse::<usize>().ok().and_then(|__n| __arr.get(__n)), _ => None }).cloned().unwrap_or(Value::Null);
2465                let mut network: Value = networks.as_map().and_then(|__m| key.as_str().and_then(|__k| __m.get(__k))).cloned().unwrap_or(Value::Null);
2466                let mut deposit: Value = self.safe_bool_k(network.clone(), "deposit", &[]);
2467                let mut currencyDeposit: Value = self.safe_bool_k(currency.clone(), "deposit", &[]);
2468                if (currencyDeposit == Value::Null) || (deposit.as_bool() == Some(true)) {
2469                    if let Value::Dict(__d) = &mut currency { std::sync::Arc::make_mut(__d).insert("deposit".into(), deposit); }
2470                }
2471                let mut withdraw: Value = self.safe_bool_k(network.clone(), "withdraw", &[]);
2472                let mut currencyWithdraw: Value = self.safe_bool_k(currency.clone(), "withdraw", &[]);
2473                if (currencyWithdraw == Value::Null) || (withdraw.as_bool() == Some(true)) {
2474                    if let Value::Dict(__d) = &mut currency { std::sync::Arc::make_mut(__d).insert("withdraw".into(), withdraw); }
2475                }
2476                // find lowest fee (which is more desired)
2477                let mut fee: Value = self.safe_string_k(network.clone(), "fee", &[]);
2478                let mut feeMain: Value = self.safe_string_k(currency.clone(), "fee", &[]);
2479                if (feeMain == Value::Null) || is_true(&crate::precise::Precise::stringLt(&fee, &feeMain)) {
2480                    if let Value::Dict(__d) = &mut currency { std::sync::Arc::make_mut(__d).insert("fee".into(), self.parse_number(fee.clone(), &[])); }
2481                }
2482                // find lowest precision (which is more desired)
2483                let mut precision: Value = self.safe_string_k(network.clone(), "precision", &[]);
2484                let mut precisionMain: Value = self.safe_string_k(currency.clone(), "precision", &[]);
2485                if (precisionMain == Value::Null) || is_true(&crate::precise::Precise::stringGt(&precision, &precisionMain)) {
2486                    if let Value::Dict(__d) = &mut currency { std::sync::Arc::make_mut(__d).insert("precision".into(), self.parse_number(precision.clone(), &[])); }
2487                }
2488                // limits
2489                let mut limits: Value = self.safe_dict_k(network, "limits", &[]);
2490                let mut limitsMain: Value = self.safe_dict_k(currency.clone(), "limits", &[]);
2491                if (limitsMain == Value::Null) {
2492                    if let Value::Dict(__d) = &mut currency { std::sync::Arc::make_mut(__d).insert("limits".into(), Value::Map({
2493    let mut m = indexmap::IndexMap::new();
2494    m
2495})); }
2496                }
2497                // deposits
2498                let mut limitsDeposit: Value = self.safe_dict_k(limits.clone(), "deposit", &[]);
2499                let mut limitsDepositMain: Value = self.safe_dict_k(limitsMain.clone(), "deposit", &[]);
2500                if (limitsDepositMain == Value::Null) {
2501                    add_element_to_object(get_value_mut(&mut currency, &Value::Str("limits".into())), &Value::Str("deposit".into()), Value::Map({
2502    let mut m = indexmap::IndexMap::new();
2503    m
2504}));
2505                }
2506                let mut limitsDepositMin: Value = self.safe_string_k(limitsDeposit.clone(), "min", &[]);
2507                let mut limitsDepositMax: Value = self.safe_string_k(limitsDeposit, "max", &[]);
2508                let mut limitsDepositMinMain: Value = self.safe_string_k(limitsDepositMain.clone(), "min", &[]);
2509                let mut limitsDepositMaxMain: Value = self.safe_string_k(limitsDepositMain, "max", &[]);
2510                // find min
2511                if (limitsDepositMinMain == Value::Null) || is_true(&crate::precise::Precise::stringLt(&limitsDepositMin, &limitsDepositMinMain)) {
2512                    add_element_to_object(get_value_mut(get_value_mut(&mut currency, &Value::Str("limits".into())), &Value::Str("deposit".into())), &Value::Str("min".into()), self.parse_number(limitsDepositMin, &[]));
2513                }
2514                // find max
2515                if (limitsDepositMaxMain == Value::Null) || is_true(&crate::precise::Precise::stringGt(&limitsDepositMax, &limitsDepositMaxMain)) {
2516                    add_element_to_object(get_value_mut(get_value_mut(&mut currency, &Value::Str("limits".into())), &Value::Str("deposit".into())), &Value::Str("max".into()), self.parse_number(limitsDepositMax, &[]));
2517                }
2518                // withdrawals
2519                let mut limitsWithdraw: Value = self.safe_dict_k(limits, "withdraw", &[]);
2520                let mut limitsWithdrawMain: Value = self.safe_dict_k(limitsMain, "withdraw", &[]);
2521                if (limitsWithdrawMain == Value::Null) {
2522                    add_element_to_object(get_value_mut(&mut currency, &Value::Str("limits".into())), &Value::Str("withdraw".into()), Value::Map({
2523    let mut m = indexmap::IndexMap::new();
2524    m
2525}));
2526                }
2527                let mut limitsWithdrawMin: Value = self.safe_string_k(limitsWithdraw.clone(), "min", &[]);
2528                let mut limitsWithdrawMax: Value = self.safe_string_k(limitsWithdraw, "max", &[]);
2529                let mut limitsWithdrawMinMain: Value = self.safe_string_k(limitsWithdrawMain.clone(), "min", &[]);
2530                let mut limitsWithdrawMaxMain: Value = self.safe_string_k(limitsWithdrawMain, "max", &[]);
2531                // find min
2532                if (limitsWithdrawMinMain == Value::Null) || is_true(&crate::precise::Precise::stringLt(&limitsWithdrawMin, &limitsWithdrawMinMain)) {
2533                    add_element_to_object(get_value_mut(get_value_mut(&mut currency, &Value::Str("limits".into())), &Value::Str("withdraw".into())), &Value::Str("min".into()), self.parse_number(limitsWithdrawMin, &[]));
2534                }
2535                // find max
2536                if (limitsWithdrawMaxMain == Value::Null) || is_true(&crate::precise::Precise::stringGt(&limitsWithdrawMax, &limitsWithdrawMaxMain)) {
2537                    add_element_to_object(get_value_mut(get_value_mut(&mut currency, &Value::Str("limits".into())), &Value::Str("withdraw".into())), &Value::Str("max".into()), self.parse_number(limitsWithdrawMax, &[]));
2538                }
2539            }
2540            }
2541        }
2542        return self.extend(Value::Map({
2543    let mut m = indexmap::IndexMap::new();
2544        m.insert("info".to_string(), Value::Null);
2545        m.insert("id".to_string(), Value::Null);
2546        m.insert("numericId".to_string(), Value::Null);
2547        m.insert("code".to_string(), Value::Null);
2548        m.insert("precision".to_string(), Value::Null);
2549        m.insert("type".to_string(), Value::Null);
2550        m.insert("name".to_string(), Value::Null);
2551        m.insert("active".to_string(), Value::Null);
2552        m.insert("deposit".to_string(), Value::Null);
2553        m.insert("withdraw".to_string(), Value::Null);
2554        m.insert("fee".to_string(), Value::Null);
2555        m.insert("fees".to_string(), Value::Map({
2556    let mut m = indexmap::IndexMap::new();
2557    m
2558}));
2559        m.insert("networks".to_string(), Value::Map({
2560    let mut m = indexmap::IndexMap::new();
2561    m
2562}));
2563        m.insert("limits".to_string(), Value::Map({
2564    let mut m = indexmap::IndexMap::new();
2565        m.insert("deposit".to_string(), Value::Map({
2566    let mut m = indexmap::IndexMap::new();
2567        m.insert("min".to_string(), Value::Null);
2568        m.insert("max".to_string(), Value::Null);
2569    m
2570}));
2571        m.insert("withdraw".to_string(), Value::Map({
2572    let mut m = indexmap::IndexMap::new();
2573        m.insert("min".to_string(), Value::Null);
2574        m.insert("max".to_string(), Value::Null);
2575    m
2576}));
2577    m
2578}));
2579    m
2580}), &[currency]);
2581
2582    Value::Null
2583}
2584
2585    fn safe_market_structure(&self, optional_args: &[Value]) -> Value {
2586        let mut market = get_arg(optional_args, 0, Value::Null);
2587        let mut cleanStructure: Value = Value::Map({
2588            let mut m = indexmap::IndexMap::new();
2589                m.insert("id".to_string(), Value::Null);
2590                m.insert("lowercaseId".to_string(), Value::Null);
2591                m.insert("symbol".to_string(), Value::Null);
2592                m.insert("base".to_string(), Value::Null);
2593                m.insert("quote".to_string(), Value::Null);
2594                m.insert("settle".to_string(), Value::Null);
2595                m.insert("baseId".to_string(), Value::Null);
2596                m.insert("quoteId".to_string(), Value::Null);
2597                m.insert("settleId".to_string(), Value::Null);
2598                m.insert("type".to_string(), Value::Null);
2599                m.insert("spot".to_string(), Value::Null);
2600                m.insert("margin".to_string(), Value::Null);
2601                m.insert("swap".to_string(), Value::Null);
2602                m.insert("future".to_string(), Value::Null);
2603                m.insert("option".to_string(), Value::Null);
2604                m.insert("index".to_string(), Value::Null);
2605                m.insert("active".to_string(), Value::Null);
2606                m.insert("contract".to_string(), Value::Null);
2607                m.insert("linear".to_string(), Value::Null);
2608                m.insert("inverse".to_string(), Value::Null);
2609                m.insert("subType".to_string(), Value::Null);
2610                m.insert("taker".to_string(), Value::Null);
2611                m.insert("maker".to_string(), Value::Null);
2612                m.insert("contractSize".to_string(), Value::Null);
2613                m.insert("expiry".to_string(), Value::Null);
2614                m.insert("expiryDatetime".to_string(), Value::Null);
2615                m.insert("strike".to_string(), Value::Null);
2616                m.insert("optionType".to_string(), Value::Null);
2617                m.insert("precision".to_string(), Value::Map({
2618    let mut m = indexmap::IndexMap::new();
2619        m.insert("amount".to_string(), Value::Null);
2620        m.insert("price".to_string(), Value::Null);
2621        m.insert("cost".to_string(), Value::Null);
2622        m.insert("base".to_string(), Value::Null);
2623        m.insert("quote".to_string(), Value::Null);
2624    m
2625}));
2626                m.insert("limits".to_string(), Value::Map({
2627    let mut m = indexmap::IndexMap::new();
2628        m.insert("leverage".to_string(), Value::Map({
2629    let mut m = indexmap::IndexMap::new();
2630        m.insert("min".to_string(), Value::Null);
2631        m.insert("max".to_string(), Value::Null);
2632    m
2633}));
2634        m.insert("amount".to_string(), Value::Map({
2635    let mut m = indexmap::IndexMap::new();
2636        m.insert("min".to_string(), Value::Null);
2637        m.insert("max".to_string(), Value::Null);
2638    m
2639}));
2640        m.insert("price".to_string(), Value::Map({
2641    let mut m = indexmap::IndexMap::new();
2642        m.insert("min".to_string(), Value::Null);
2643        m.insert("max".to_string(), Value::Null);
2644    m
2645}));
2646        m.insert("cost".to_string(), Value::Map({
2647    let mut m = indexmap::IndexMap::new();
2648        m.insert("min".to_string(), Value::Null);
2649        m.insert("max".to_string(), Value::Null);
2650    m
2651}));
2652    m
2653}));
2654                m.insert("marginModes".to_string(), Value::Map({
2655    let mut m = indexmap::IndexMap::new();
2656        m.insert("cross".to_string(), Value::Null);
2657        m.insert("isolated".to_string(), Value::Null);
2658    m
2659}));
2660                m.insert("created".to_string(), Value::Null);
2661                m.insert("info".to_string(), Value::Null);
2662            m
2663        });
2664        if (market != Value::Null) {
2665            let mut result: Value = self.extend(cleanStructure.clone(), &[market]);
2666            // set undefined swap/future/etc
2667            if is_equal(&result.as_map().and_then(|__m| __m.get("spot")).cloned().unwrap_or(Value::Null), &Value::Bool(true)) {
2668                if (result.as_map().and_then(|__m| __m.get("contract")).cloned().unwrap_or(Value::Null) == Value::Null) {
2669                    add_element_to_object(&mut result, &Value::Str("contract".into()), Value::Bool(false));
2670                }
2671                if (result.as_map().and_then(|__m| __m.get("swap")).cloned().unwrap_or(Value::Null) == Value::Null) {
2672                    add_element_to_object(&mut result, &Value::Str("swap".into()), Value::Bool(false));
2673                }
2674                if (result.as_map().and_then(|__m| __m.get("future")).cloned().unwrap_or(Value::Null) == Value::Null) {
2675                    add_element_to_object(&mut result, &Value::Str("future".into()), Value::Bool(false));
2676                }
2677                if (result.as_map().and_then(|__m| __m.get("option")).cloned().unwrap_or(Value::Null) == Value::Null) {
2678                    add_element_to_object(&mut result, &Value::Str("option".into()), Value::Bool(false));
2679                }
2680                if (result.as_map().and_then(|__m| __m.get("index")).cloned().unwrap_or(Value::Null) == Value::Null) {
2681                    add_element_to_object(&mut result, &Value::Str("index".into()), Value::Bool(false));
2682                }
2683            }
2684            return result;
2685        }
2686        return self.extend(cleanStructure, &[]);
2687
2688    Value::Null
2689}
2690
2691    fn set_markets(&mut self, mut markets: Value, optional_args: &[Value]) -> Value {
2692        let mut currencies = get_arg(optional_args, 0, Value::Null);
2693        let mut values: Value = Value::from(vec![]);
2694        { let __t = self.create_safe_dictionary(&[]); self.markets_by_id = __t; }
2695        // handle marketId conflicts
2696        // we insert spot markets first
2697        let mut marketValues: Value = self.sort_by(self.to_array(markets.clone()), Value::Str("spot".into()), &[Value::Bool(true), Value::Bool(true)]);
2698        {
2699                        let mut i: Value = Value::Int(0);
2700            let mut __for_first_87: bool = true;
2701            while { if !__for_first_87 { i = (match (&(i), &(Value::Int(1))) { (Value::Int(x), Value::Int(y)) => Value::Int(x + y), (Value::Int(x), Value::Float(y)) => Value::Float(*x as f64 + *y), (Value::Float(x), Value::Int(y)) => Value::Float(*x + *y as f64), (Value::Float(x), Value::Float(y)) => Value::Float(x + y), _ => Value::Null }); } __for_first_87 = false; i.as_f64().unwrap_or(f64::NAN) < ((marketValues.len() as i64) as f64) } {
2702            let mut value: Value = marketValues.as_array().and_then(|__arr| match &i { Value::Int(__n) => __arr.get(*__n as usize), Value::Str(__s) => __s.parse::<usize>().ok().and_then(|__n| __arr.get(__n)), _ => None }).cloned().unwrap_or(Value::Null);
2703            if (in_op(&self.markets_by_id, &crate::value::get_value_k(&value, "id"))) {
2704                let mut marketsByIdArray: Value = get_value(&self.markets_by_id, &crate::value::get_value_k(&value, "id"));
2705                append_to_array(&mut marketsByIdArray, value.clone());
2706                add_element_to_object(&mut self.markets_by_id, &crate::value::get_value_k(&value, "id"), marketsByIdArray);
2707            }  else {
2708                add_element_to_object(&mut self.markets_by_id, &crate::value::get_value_k(&value, "id"), Value::from(vec![value.clone()]));
2709            }
2710            // strip undefined-valued keys from the parsed market before deepExtend,
2711            // otherwise an explicit `taker: undefined` (from safeMarketStructure)
2712            // would clobber the fee defaults from this.fees['trading'] in the merge
2713            let mut valueDefined: Value = Value::Map({
2714                let mut m = indexmap::IndexMap::new();
2715                m
2716            });
2717            let mut valueKeys: Value = object_keys(&value);
2718            {
2719                                let mut j: Value = Value::Int(0);
2720                let mut __for_first_86: bool = true;
2721                while { if !__for_first_86 { j = (match (&(j), &(Value::Int(1))) { (Value::Int(x), Value::Int(y)) => Value::Int(x + y), (Value::Int(x), Value::Float(y)) => Value::Float(*x as f64 + *y), (Value::Float(x), Value::Int(y)) => Value::Float(*x + *y as f64), (Value::Float(x), Value::Float(y)) => Value::Float(x + y), _ => Value::Null }); } __for_first_86 = false; j.as_f64().unwrap_or(f64::NAN) < ((valueKeys.len() as i64) as f64) } {
2722                let mut valueKey: Value = valueKeys.as_array().and_then(|__arr| match &j { Value::Int(__n) => __arr.get(*__n as usize), Value::Str(__s) => __s.parse::<usize>().ok().and_then(|__n| __arr.get(__n)), _ => None }).cloned().unwrap_or(Value::Null);
2723                if (get_value(&value, &valueKey) != Value::Null) {
2724                    if let Value::Dict(__d) = &mut valueDefined { std::sync::Arc::make_mut(__d).insert(crate::runtime::stringify_param(&valueKey), get_value(&value, &valueKey)); }
2725                }
2726            }
2727            }
2728            let mut market: Value = self.deep_extend(self.safe_market_structure(&[]), &[Value::Map({
2729                let mut m = indexmap::IndexMap::new();
2730                    m.insert("precision".to_string(), self.precision.clone());
2731                    m.insert("limits".to_string(), self.limits.clone());
2732                m
2733            }), self.fees.as_map().and_then(|__m| __m.get("trading")).cloned().unwrap_or(Value::Null), valueDefined]);
2734            if is_equal(&market.as_map().and_then(|__m| __m.get("linear")).cloned().unwrap_or(Value::Null), &Value::Bool(true)) {
2735                add_element_to_object(&mut market, &Value::Str("subType".into()), Value::Str("linear".into()));
2736            }  else if is_equal(&market.as_map().and_then(|__m| __m.get("inverse")).cloned().unwrap_or(Value::Null), &Value::Bool(true)) {
2737                add_element_to_object(&mut market, &Value::Str("subType".into()), Value::Str("inverse".into()));
2738            }  else {
2739                add_element_to_object(&mut market, &Value::Str("subType".into()), Value::Null);
2740            }
2741            append_to_array(&mut values, market.clone());
2742        }
2743        }
2744        { let __t = self.map_to_safe_map(self.index_by(values.clone(), Value::Str("symbol".into()))); self.markets = __t; }
2745        let mut marketsSortedBySymbol: Value = self.keysort(self.markets.clone(), &[]);
2746        let mut marketsSortedById: Value = self.keysort(self.markets_by_id.clone(), &[]);
2747        self.symbols = object_keys(&marketsSortedBySymbol);
2748        self.ids = object_keys(&marketsSortedById);
2749        let mut numCurrencies: Value = Value::Int(0);
2750        if (currencies != Value::Null) {
2751            let mut keys: Value = object_keys(&currencies);
2752            numCurrencies = Value::Int(keys.len() as i64);
2753        }
2754        if numCurrencies.as_f64().unwrap_or(f64::NAN) > ((0i64) as f64) {
2755            // currencies is always undefined when called in constructor but not when called from loadMarkets
2756            { let __t = self.map_to_safe_map(self.deep_extend(self.currencies.clone(), &[currencies.clone()])); self.currencies = __t; }
2757        }  else {
2758            let mut baseCurrencies: Value = Value::from(vec![]);
2759            let mut quoteCurrencies: Value = Value::from(vec![]);
2760            {
2761                                let mut i: Value = Value::Int(0);
2762                let mut __for_first_88: bool = true;
2763                while { if !__for_first_88 { i = (match (&(i), &(Value::Int(1))) { (Value::Int(x), Value::Int(y)) => Value::Int(x + y), (Value::Int(x), Value::Float(y)) => Value::Float(*x as f64 + *y), (Value::Float(x), Value::Int(y)) => Value::Float(*x + *y as f64), (Value::Float(x), Value::Float(y)) => Value::Float(x + y), _ => Value::Null }); } __for_first_88 = false; i.as_f64().unwrap_or(f64::NAN) < ((values.len() as i64) as f64) } {
2764                let mut market: Value = values.as_array().and_then(|__arr| match &i { Value::Int(__n) => __arr.get(*__n as usize), Value::Str(__s) => __s.parse::<usize>().ok().and_then(|__n| __arr.get(__n)), _ => None }).cloned().unwrap_or(Value::Null);
2765                let mut defaultCurrencyPrecision: Value = (if (self.precisionMode.as_f64() == Value::Int(crate::runtime::DECIMAL_PLACES).as_f64()) { Value::Int(8) } else { self.parse_number(Value::Str("1e-8".into()), &[]) });
2766                let mut marketPrecision: Value = self.safe_dict_k(market.clone(), "precision", &[Value::Map({
2767    let mut m = indexmap::IndexMap::new();
2768    m
2769})]);
2770                if (matches!(&market, Value::Dict(__d) if __d.contains_key("base"))) {
2771                    let mut currency: Value = self.safe_currency_structure(Value::Map({
2772                        let mut m = indexmap::IndexMap::new();
2773                            m.insert("id".to_string(), self.safe_string2(market.clone(), Value::Str("baseId".into()), Value::Str("base".into()), &[]));
2774                            m.insert("numericId".to_string(), self.safe_integer_k(market.clone(), "baseNumericId", &[]));
2775                            m.insert("code".to_string(), self.safe_string_k(market.clone(), "base", &[]));
2776                            m.insert("precision".to_string(), self.safe_value2(marketPrecision.clone(), Value::Str("base".into()), Value::Str("amount".into()), &[defaultCurrencyPrecision.clone()]));
2777                        m
2778                    }));
2779                    append_to_array(&mut baseCurrencies, currency.clone());
2780                }
2781                if (matches!(&market, Value::Dict(__d) if __d.contains_key("quote"))) {
2782                    let mut currency: Value = self.safe_currency_structure(Value::Map({
2783                        let mut m = indexmap::IndexMap::new();
2784                            m.insert("id".to_string(), self.safe_string2(market.clone(), Value::Str("quoteId".into()), Value::Str("quote".into()), &[]));
2785                            m.insert("numericId".to_string(), self.safe_integer_k(market.clone(), "quoteNumericId", &[]));
2786                            m.insert("code".to_string(), self.safe_string_k(market.clone(), "quote", &[]));
2787                            m.insert("precision".to_string(), self.safe_value2(marketPrecision, Value::Str("quote".into()), Value::Str("price".into()), &[defaultCurrencyPrecision]));
2788                        m
2789                    }));
2790                    append_to_array(&mut quoteCurrencies, currency);
2791                }
2792            }
2793            }
2794            baseCurrencies = self.sort_by(baseCurrencies.clone(), Value::Str("code".into()), &[Value::Bool(false), Value::Str("".into())]);
2795            quoteCurrencies = self.sort_by(quoteCurrencies.clone(), Value::Str("code".into()), &[Value::Bool(false), Value::Str("".into())]);
2796            { let __t = self.map_to_safe_map(self.index_by(baseCurrencies.clone(), Value::Str("code".into()))); self.baseCurrencies = __t; }
2797            { let __t = self.map_to_safe_map(self.index_by(quoteCurrencies.clone(), Value::Str("code".into()))); self.quoteCurrencies = __t; }
2798            let mut allCurrencies: Value = self.array_concat(baseCurrencies, quoteCurrencies);
2799            let mut groupedCurrencies: Value = self.group_by(allCurrencies, Value::Str("code".into()), &[]);
2800            let mut codes: Value = object_keys(&groupedCurrencies);
2801            let mut resultingCurrencies: Value = Value::from(vec![]);
2802            {
2803                                let mut i: Value = Value::Int(0);
2804                let mut __for_first_90: bool = true;
2805                while { if !__for_first_90 { i = (match (&(i), &(Value::Int(1))) { (Value::Int(x), Value::Int(y)) => Value::Int(x + y), (Value::Int(x), Value::Float(y)) => Value::Float(*x as f64 + *y), (Value::Float(x), Value::Int(y)) => Value::Float(*x + *y as f64), (Value::Float(x), Value::Float(y)) => Value::Float(x + y), _ => Value::Null }); } __for_first_90 = false; i.as_f64().unwrap_or(f64::NAN) < ((codes.len() as i64) as f64) } {
2806                let mut code: Value = codes.as_array().and_then(|__arr| match &i { Value::Int(__n) => __arr.get(*__n as usize), Value::Str(__s) => __s.parse::<usize>().ok().and_then(|__n| __arr.get(__n)), _ => None }).cloned().unwrap_or(Value::Null);
2807                let mut groupedCurrenciesCode: Value = self.safe_list(groupedCurrencies.clone(), code, &[Value::from(vec![])]);
2808                let mut highestPrecisionCurrency: Value = self.safe_value(groupedCurrenciesCode.clone(), Value::Int(0), &[]);
2809                {
2810                                        let mut j: Value = Value::Int(1);
2811                    let mut __for_first_89: bool = true;
2812                    while { if !__for_first_89 { j = (match (&(j), &(Value::Int(1))) { (Value::Int(x), Value::Int(y)) => Value::Int(x + y), (Value::Int(x), Value::Float(y)) => Value::Float(*x as f64 + *y), (Value::Float(x), Value::Int(y)) => Value::Float(*x + *y as f64), (Value::Float(x), Value::Float(y)) => Value::Float(x + y), _ => Value::Null }); } __for_first_89 = false; j.as_f64().unwrap_or(f64::NAN) < ((groupedCurrenciesCode.len() as i64) as f64) } {
2813                    let mut currentCurrency: Value = get_value(&groupedCurrenciesCode, &j);
2814                    let mut currentCurrency: Value = get_value(&groupedCurrenciesCode, &j);
2815                    let mut currentPrecision: Value = self.safe_number_k(currentCurrency.clone(), "precision", &[]);
2816                    let mut highestPrecision: Value = self.safe_number_k(highestPrecisionCurrency.clone(), "precision", &[]);
2817                    if (currentPrecision == Value::Null) || (highestPrecision == Value::Null) {
2818                        continue;
2819                    }
2820                    if (self.precisionMode.as_f64() == Value::Int(crate::runtime::TICK_SIZE).as_f64()) {
2821                        if currentPrecision.as_f64().unwrap_or(f64::NAN) < highestPrecision.as_f64().unwrap_or(f64::NAN) {
2822                            highestPrecisionCurrency = currentCurrency.clone();
2823                        }
2824                    }  else if currentPrecision.as_f64().unwrap_or(f64::NAN) > highestPrecision.as_f64().unwrap_or(f64::NAN) {
2825                        highestPrecisionCurrency = currentCurrency;
2826                    }
2827                }
2828                }
2829                append_to_array(&mut resultingCurrencies, highestPrecisionCurrency);
2830            }
2831            }
2832            let mut sortedCurrencies: Value = self.sort_by(resultingCurrencies, Value::Str("code".into()), &[]);
2833            { let __t = self.map_to_safe_map(self.deep_extend(self.currencies.clone(), &[self.index_by(sortedCurrencies, Value::Str("code".into()))])); self.currencies = __t; }
2834        }
2835        { let __t = self.index_by_safe(self.currencies.clone(), Value::Str("id".into())); self.currencies_by_id = __t; }
2836        let mut currenciesSortedByCode: Value = self.keysort(self.currencies.clone(), &[]);
2837        self.codes = object_keys(&currenciesSortedByCode);
2838        if (self.markets.clone() == Value::Null) {
2839            panic!("{}", crate::exchange_errors::exchange_error(format!("{}{}", self.id.clone(), Value::Str(" setMarkets() markets not set".into()))));
2840        }
2841        return self.markets.clone();
2842
2843    Value::Null
2844}
2845
2846    fn set_markets_from_exchange(&mut self, mut sourceExchange: Value) -> Value {
2847        // Validate that both exchanges are of the same type
2848        if !is_equal(&self.id, &get_value(&sourceExchange, &Value::Str("id".into()))) {
2849            panic!("{}", crate::exchange_errors::arguments_required(format!("{}{}", add(&Value::Str(format!("{}{}", self.id.clone(), Value::Str(" shareMarkets() can only share markets with exchanges of the same type (got ".into())).into()), &crate::value::get_value_k(&sourceExchange, "id")), Value::Str(")".into()))));
2850        }
2851        // Validate that source exchange has loaded markets
2852        if (get_value(&sourceExchange, &Value::Str("markets".into())) == Value::Null) || (get_value(&sourceExchange, &Value::Str("markets".into())) == Value::Null) {
2853            panic!("{}", crate::exchange_errors::exchange_error("setMarketsFromExchange() source exchange must have loaded markets first. Can call by using loadMarkets function"));
2854        }
2855        // Set all market-related data
2856        self.markets = get_value(&sourceExchange, &Value::Str("markets".into()));
2857        self.markets_by_id = get_value(&sourceExchange, &Value::Str("markets_by_id".into()));
2858        self.symbols = get_value(&sourceExchange, &Value::Str("symbols".into()));
2859        self.ids = get_value(&sourceExchange, &Value::Str("ids".into()));
2860        self.currencies = get_value(&sourceExchange, &Value::Str("currencies".into()));
2861        self.currencies_by_id = get_value(&sourceExchange, &Value::Str("currencies_by_id".into()));
2862        self.baseCurrencies = get_value(&sourceExchange, &Value::Str("baseCurrencies".into()));
2863        self.quoteCurrencies = get_value(&sourceExchange, &Value::Str("quoteCurrencies".into()));
2864        self.codes = get_value(&sourceExchange, &Value::Str("codes".into()));
2865        // check marketHelperProps
2866        let mut sourceExchangeHelpers: Value = self.safe_list(get_value(&sourceExchange, &Value::Str("options".into())), Value::Str("marketHelperProps".into()), &[Value::from(vec![])]);
2867        {
2868                        let mut i: Value = Value::Int(0);
2869            let mut __for_first_91: bool = true;
2870            while { if !__for_first_91 { i = (match (&(i), &(Value::Int(1))) { (Value::Int(x), Value::Int(y)) => Value::Int(x + y), (Value::Int(x), Value::Float(y)) => Value::Float(*x as f64 + *y), (Value::Float(x), Value::Int(y)) => Value::Float(*x + *y as f64), (Value::Float(x), Value::Float(y)) => Value::Float(x + y), _ => Value::Null }); } __for_first_91 = false; i.as_f64().unwrap_or(f64::NAN) < ((sourceExchangeHelpers.len() as i64) as f64) } {
2871            let mut helper: Value = get_value(&sourceExchangeHelpers, &i);
2872            let mut helper: Value = get_value(&sourceExchangeHelpers, &i);
2873            if (get_value(&get_value(&sourceExchange, &Value::Str("options".into())), &helper) != Value::Null) {
2874                if let Value::Dict(__d) = &mut self.options { std::sync::Arc::make_mut(__d).insert(crate::runtime::stringify_param(&helper), get_value(&get_value(&sourceExchange, &Value::Str("options".into())), &helper)); }
2875            }
2876        }
2877        }
2878        return Value::Null;
2879
2880    Value::Null
2881}
2882
2883    fn get_describe_for_extended_ws_exchange(&self, mut currentRestInstance: Value, mut parentRestInstance: Value, mut wsBaseDescribe: Value) -> Value {
2884        let mut extendedRestDescribe: Value = self.deep_extend(parentRestInstance.describe(), &[currentRestInstance.describe()]);
2885        let mut superWithRestDescribe: Value = self.deep_extend(extendedRestDescribe, &[wsBaseDescribe]);
2886        return superWithRestDescribe;
2887
2888    Value::Null
2889}
2890
2891    fn safe_balance(&self, mut balance: Value) -> Value {
2892        let mut balances: Value = self.omit(balance.clone(), Value::from(vec![Value::Str("info".into()), Value::Str("timestamp".into()), Value::Str("datetime".into()), Value::Str("free".into()), Value::Str("used".into()), Value::Str("total".into())]), &[]);
2893        let mut codes: Value = object_keys(&balances);
2894        if let Value::Dict(__d) = &mut balance { std::sync::Arc::make_mut(__d).insert("free".into(), Value::Map({
2895    let mut m = indexmap::IndexMap::new();
2896    m
2897})); }
2898        if let Value::Dict(__d) = &mut balance { std::sync::Arc::make_mut(__d).insert("used".into(), Value::Map({
2899    let mut m = indexmap::IndexMap::new();
2900    m
2901})); }
2902        if let Value::Dict(__d) = &mut balance { std::sync::Arc::make_mut(__d).insert("total".into(), Value::Map({
2903    let mut m = indexmap::IndexMap::new();
2904    m
2905})); }
2906        let mut debtBalance: Value = Value::Map({
2907            let mut m = indexmap::IndexMap::new();
2908            m
2909        });
2910        {
2911                        let mut i: Value = Value::Int(0);
2912            let mut __for_first_92: bool = true;
2913            while { if !__for_first_92 { i = (match (&(i), &(Value::Int(1))) { (Value::Int(x), Value::Int(y)) => Value::Int(x + y), (Value::Int(x), Value::Float(y)) => Value::Float(*x as f64 + *y), (Value::Float(x), Value::Int(y)) => Value::Float(*x + *y as f64), (Value::Float(x), Value::Float(y)) => Value::Float(x + y), _ => Value::Null }); } __for_first_92 = false; i.as_f64().unwrap_or(f64::NAN) < ((codes.len() as i64) as f64) } {
2914            let mut code: Value = codes.as_array().and_then(|__arr| match &i { Value::Int(__n) => __arr.get(*__n as usize), Value::Str(__s) => __s.parse::<usize>().ok().and_then(|__n| __arr.get(__n)), _ => None }).cloned().unwrap_or(Value::Null);
2915            let mut total: Value = self.safe_string(balance.as_map().and_then(|__m| code.as_str().and_then(|__k| __m.get(__k))).cloned().unwrap_or(Value::Null), Value::Str("total".into()), &[]);
2916            let mut free: Value = self.safe_string(balance.as_map().and_then(|__m| code.as_str().and_then(|__k| __m.get(__k))).cloned().unwrap_or(Value::Null), Value::Str("free".into()), &[]);
2917            let mut used: Value = self.safe_string(balance.as_map().and_then(|__m| code.as_str().and_then(|__k| __m.get(__k))).cloned().unwrap_or(Value::Null), Value::Str("used".into()), &[]);
2918            let mut debt: Value = self.safe_string(balance.as_map().and_then(|__m| code.as_str().and_then(|__k| __m.get(__k))).cloned().unwrap_or(Value::Null), Value::Str("debt".into()), &[]);
2919            if (total == Value::Null) && (free != Value::Null) && (used != Value::Null) {
2920                total = crate::precise::Precise::stringAdd(&free, &used);
2921            }
2922            if (free == Value::Null) && (total != Value::Null) && (used != Value::Null) {
2923                free = crate::precise::Precise::stringSub(&total, &used);
2924            }
2925            if (used == Value::Null) && (total != Value::Null) && (free != Value::Null) {
2926                used = crate::precise::Precise::stringSub(&total, &free);
2927            }
2928            add_element_to_object(get_value_mut(&mut balance, &code), &Value::Str("free".into()), self.parse_number(free, &[]));
2929            add_element_to_object(get_value_mut(&mut balance, &code), &Value::Str("used".into()), self.parse_number(used, &[]));
2930            add_element_to_object(get_value_mut(&mut balance, &code), &Value::Str("total".into()), self.parse_number(total, &[]));
2931            { let __be_tmp = crate::value::get_value_k(&get_value(&balance, &code), "free"); add_element_to_object(get_value_mut(&mut balance, &Value::Str("free".into())), &code, __be_tmp); };
2932            { let __be_tmp = crate::value::get_value_k(&get_value(&balance, &code), "used"); add_element_to_object(get_value_mut(&mut balance, &Value::Str("used".into())), &code, __be_tmp); };
2933            { let __be_tmp = crate::value::get_value_k(&get_value(&balance, &code), "total"); add_element_to_object(get_value_mut(&mut balance, &Value::Str("total".into())), &code, __be_tmp); };
2934            if (debt != Value::Null) {
2935                add_element_to_object(get_value_mut(&mut balance, &code), &Value::Str("debt".into()), self.parse_number(debt, &[]));
2936                if let Value::Dict(__d) = &mut debtBalance { std::sync::Arc::make_mut(__d).insert(crate::runtime::stringify_param(&code), crate::value::get_value_k(&balance.as_map().and_then(|__m| code.as_str().and_then(|__k| __m.get(__k))).cloned().unwrap_or(Value::Null), "debt")); }
2937            }
2938        }
2939        }
2940        let mut debtBalanceArray: Value = object_keys(&debtBalance);
2941        let mut length: Value = Value::Int(debtBalanceArray.len() as i64);
2942        if (length != Value::Null) && (length.as_f64() != Some(0.0)) {
2943            if let Value::Dict(__d) = &mut balance { std::sync::Arc::make_mut(__d).insert("debt".into(), debtBalance); }
2944        }
2945        return balance;
2946
2947    Value::Null
2948}
2949
2950    fn safe_order(&self, mut order: Value, optional_args: &[Value]) -> Value {
2951        let mut market = get_arg(optional_args, 0, Value::Null);
2952        // parses numbers as strings
2953        // * it is important pass the trades as unparsed rawTrades
2954        let mut orderDict: Value = order.clone();
2955        if (order == Value::Null) {
2956            orderDict = Value::Map({
2957                let mut m = indexmap::IndexMap::new();
2958                m
2959            });
2960        }
2961        let mut amount: Value = self.omit_zero(self.safe_string_k(orderDict.clone(), "amount", &[]));
2962        let mut remaining: Value = self.safe_string_k(orderDict.clone(), "remaining", &[]);
2963        let mut filled: Value = self.safe_string_k(orderDict.clone(), "filled", &[]);
2964        let mut cost: Value = self.safe_string_k(orderDict.clone(), "cost", &[]);
2965        let mut average: Value = self.omit_zero(self.safe_string_k(orderDict.clone(), "average", &[]));
2966        let mut price: Value = self.omit_zero(self.safe_string_k(orderDict.clone(), "price", &[]));
2967        let mut lastTradeTimeTimestamp: Value = self.safe_integer_k(orderDict.clone(), "lastTradeTimestamp", &[]);
2968        let mut symbol: Value = self.safe_string_k(orderDict.clone(), "symbol", &[]);
2969        let mut side: Value = self.safe_string_k(orderDict.clone(), "side", &[]);
2970        let mut status: Value = self.safe_string_k(orderDict.clone(), "status", &[]);
2971        let mut parseFilled: bool = filled == Value::Null;
2972        let mut parseCost: bool = cost == Value::Null;
2973        let mut parseLastTradeTimeTimestamp: bool = lastTradeTimeTimestamp == Value::Null;
2974        let mut fee: Value = self.safe_value_k(orderDict.clone(), "fee", &[]);
2975        let mut parseFee: bool = fee == Value::Null;
2976        let mut parseFees: bool = self.safe_value_k(orderDict.clone(), "fees", &[]) == Value::Null;
2977        let mut parseSymbol: bool = symbol == Value::Null;
2978        let mut parseSide: bool = side == Value::Null;
2979        let mut shouldParseFees: bool = parseFee || parseFees;
2980        let mut fees: Value = self.safe_list_k(orderDict.clone(), "fees", &[Value::from(vec![])]);
2981        let mut trades: Value = Value::from(vec![]);
2982        let mut isTriggerOrSLTpOrder: bool = ((self.safe_string_k(orderDict.clone(), "triggerPrice", &[]) != Value::Null) || (self.safe_string_k(orderDict.clone(), "stopLossPrice", &[]) != Value::Null)) || (self.safe_string_k(orderDict.clone(), "takeProfitPrice", &[]) != Value::Null);
2983        if parseFilled || parseCost || shouldParseFees {
2984            let mut rawTrades: Value = self.safe_value_k(orderDict.clone(), "trades", &[trades.clone()]);
2985            // const oldNumber = this.number;
2986            // we parse trades as strings here!
2987            // i don't think this is needed anymore
2988            // (this as any).number = String;
2989            let mut firstTrade: Value = self.safe_value(rawTrades.clone(), Value::Int(0), &[]);
2990            // parse trades if they haven't already been parsed
2991            let mut tradesAreParsed: bool = (firstTrade != Value::Null) && (in_op(&firstTrade, &Value::Str("info".into()))) && (in_op(&firstTrade, &Value::Str("id".into())));
2992            if !tradesAreParsed {
2993                trades = self.parse_trades(rawTrades.clone(), &[market.clone()]);
2994            }  else {
2995                trades = rawTrades;
2996            }
2997            // this.number = oldNumber; why parse trades as strings if you read the value using `safeString` ?
2998            let mut tradesLength: Value = Value::Int(0);
2999            let mut isArray: bool = matches!(&trades, Value::Arr(_));
3000            if isArray {
3001                tradesLength = Value::Int(trades.len() as i64);
3002            }
3003            if isArray && (tradesLength.as_f64().unwrap_or(f64::NAN) > ((0i64) as f64)) {
3004                // move properties that are defined in trades up into the order
3005                if (orderDict.as_map().and_then(|__m| __m.get("symbol")).cloned().unwrap_or(Value::Null) == Value::Null) {
3006                    add_element_to_object(&mut orderDict, &Value::Str("symbol".into()), crate::value::get_value_k(&trades.as_array().and_then(|__arr| __arr.get(0)).cloned().unwrap_or(Value::Null), "symbol"));
3007                }
3008                if (orderDict.as_map().and_then(|__m| __m.get("side")).cloned().unwrap_or(Value::Null) == Value::Null) {
3009                    add_element_to_object(&mut orderDict, &Value::Str("side".into()), crate::value::get_value_k(&trades.as_array().and_then(|__arr| __arr.get(0)).cloned().unwrap_or(Value::Null), "side"));
3010                }
3011                if (orderDict.as_map().and_then(|__m| __m.get("type")).cloned().unwrap_or(Value::Null) == Value::Null) {
3012                    add_element_to_object(&mut orderDict, &Value::Str("type".into()), crate::value::get_value_k(&trades.as_array().and_then(|__arr| __arr.get(0)).cloned().unwrap_or(Value::Null), "type"));
3013                }
3014                if (orderDict.as_map().and_then(|__m| __m.get("id")).cloned().unwrap_or(Value::Null) == Value::Null) {
3015                    add_element_to_object(&mut orderDict, &Value::Str("id".into()), crate::value::get_value_k(&trades.as_array().and_then(|__arr| __arr.get(0)).cloned().unwrap_or(Value::Null), "order"));
3016                }
3017                if parseFilled {
3018                    filled = Value::Str("0".into());
3019                }
3020                if parseCost {
3021                    cost = Value::Str("0".into());
3022                }
3023                {
3024                                        let mut i: Value = Value::Int(0);
3025                    let mut __for_first_94: bool = true;
3026                    while { if !__for_first_94 { i = (match (&(i), &(Value::Int(1))) { (Value::Int(x), Value::Int(y)) => Value::Int(x + y), (Value::Int(x), Value::Float(y)) => Value::Float(*x as f64 + *y), (Value::Float(x), Value::Int(y)) => Value::Float(*x + *y as f64), (Value::Float(x), Value::Float(y)) => Value::Float(x + y), _ => Value::Null }); } __for_first_94 = false; i.as_f64().unwrap_or(f64::NAN) < ((trades.len() as i64) as f64) } {
3027                    let mut trade: Value = trades.as_array().and_then(|__arr| match &i { Value::Int(__n) => __arr.get(*__n as usize), Value::Str(__s) => __s.parse::<usize>().ok().and_then(|__n| __arr.get(__n)), _ => None }).cloned().unwrap_or(Value::Null);
3028                    let mut tradeAmount: Value = self.safe_string_k(trade.clone(), "amount", &[]);
3029                    if parseFilled && (tradeAmount != Value::Null) {
3030                        filled = crate::precise::Precise::stringAdd(&filled, &tradeAmount);
3031                    }
3032                    let mut tradeCost: Value = self.safe_string_k(trade.clone(), "cost", &[]);
3033                    if parseCost && (tradeCost != Value::Null) {
3034                        cost = crate::precise::Precise::stringAdd(&cost, &tradeCost);
3035                    }
3036                    if parseSymbol {
3037                        symbol = self.safe_string_k(trade.clone(), "symbol", &[]);
3038                    }
3039                    if parseSide {
3040                        side = self.safe_string_k(trade.clone(), "side", &[]);
3041                    }
3042                    let mut tradeTimestamp: Value = self.safe_value_k(trade.clone(), "timestamp", &[]);
3043                    if parseLastTradeTimeTimestamp && (tradeTimestamp != Value::Null) {
3044                        if (lastTradeTimeTimestamp == Value::Null) {
3045                            lastTradeTimeTimestamp = tradeTimestamp.clone();
3046                        }  else {
3047                            lastTradeTimeTimestamp = crate::runtime::Math::max(&lastTradeTimeTimestamp, &tradeTimestamp);
3048                        }
3049                    }
3050                    if shouldParseFees {
3051                        let mut tradeFees: Value = self.safe_value_k(trade.clone(), "fees", &[]);
3052                        if (tradeFees != Value::Null) {
3053                            {
3054                                                                let mut j: Value = Value::Int(0);
3055                                let mut __for_first_93: bool = true;
3056                                while { if !__for_first_93 { j = (match (&(j), &(Value::Int(1))) { (Value::Int(x), Value::Int(y)) => Value::Int(x + y), (Value::Int(x), Value::Float(y)) => Value::Float(*x as f64 + *y), (Value::Float(x), Value::Int(y)) => Value::Float(*x + *y as f64), (Value::Float(x), Value::Float(y)) => Value::Float(x + y), _ => Value::Null }); } __for_first_93 = false; j.as_f64().unwrap_or(f64::NAN) < get_array_length(&tradeFees).as_f64().unwrap_or(f64::NAN) } {
3057                                let mut tradeFee: Value = get_value(&tradeFees, &j);
3058                                let mut tradeFee: Value = get_value(&tradeFees, &j);
3059                                append_to_array(&mut fees, self.extend(Value::Map({
3060                                    let mut m = indexmap::IndexMap::new();
3061                                    m
3062                                }), &[tradeFee.clone()]));
3063                            }
3064                            }
3065                        }  else {
3066                            let mut tradeFee: Value = self.safe_value_k(trade, "fee", &[]);
3067                            if (tradeFee != Value::Null) {
3068                                append_to_array(&mut fees, self.extend(Value::Map({
3069                                    let mut m = indexmap::IndexMap::new();
3070                                    m
3071                                }), &[tradeFee.clone()]));
3072                            }
3073                        }
3074                    }
3075                }
3076                }
3077            }
3078        }
3079        if shouldParseFees {
3080            let mut reducedFees: Value = fees.clone();
3081            if is_true(&self.reduceFees) {
3082                reducedFees = self.reduce_fees_by_currency(fees);
3083            }
3084            if (reducedFees == Value::Null) {
3085                reducedFees = Value::from(vec![]);
3086            }
3087            let mut reducedLength: f64 = ((reducedFees.len() as i64) as f64);
3088            {
3089                                let mut i: Value = Value::Int(0);
3090                let mut __for_first_95: bool = true;
3091                while { if !__for_first_95 { i = (match (&(i), &(Value::Int(1))) { (Value::Int(x), Value::Int(y)) => Value::Int(x + y), (Value::Int(x), Value::Float(y)) => Value::Float(*x as f64 + *y), (Value::Float(x), Value::Int(y)) => Value::Float(*x + *y as f64), (Value::Float(x), Value::Float(y)) => Value::Float(x + y), _ => Value::Null }); } __for_first_95 = false; i.as_f64().unwrap_or(f64::NAN) < reducedLength } {
3092                { 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".into()), __be_tmp); };
3093                if (in_op(&reducedFees.as_array().and_then(|__arr| match &i { Value::Int(__n) => __arr.get(*__n as usize), Value::Str(__s) => __s.parse::<usize>().ok().and_then(|__n| __arr.get(__n)), _ => None }).cloned().unwrap_or(Value::Null), &Value::Str("rate".into()))) {
3094                    { 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".into()), __be_tmp); };
3095                }
3096            }
3097            }
3098            if !parseFee && (reducedLength == 0.0) {
3099                // copy fee to avoid modification by reference
3100                let mut feeCopy: Value = self.deep_extend(fee, &[]);
3101                { let __be_tmp = self.safe_number_k(feeCopy.clone(), "cost", &[]); add_element_to_object(&mut feeCopy, &Value::Str("cost".into()), __be_tmp); };
3102                if (in_op(&feeCopy, &Value::Str("rate".into()))) {
3103                    { let __be_tmp = self.safe_number_k(feeCopy.clone(), "rate", &[]); add_element_to_object(&mut feeCopy, &Value::Str("rate".into()), __be_tmp); };
3104                }
3105                append_to_array(&mut reducedFees, feeCopy);
3106            }
3107            add_element_to_object(&mut orderDict, &Value::Str("fees".into()), reducedFees.clone());
3108            if parseFee && (reducedLength == 1.0) {
3109                add_element_to_object(&mut orderDict, &Value::Str("fee".into()), reducedFees.as_array().and_then(|__arr| __arr.get(0)).cloned().unwrap_or(Value::Null));
3110            }
3111        }
3112        if (amount == Value::Null) {
3113            // ensure amount = filled + remaining
3114            if (filled != Value::Null) && (remaining != Value::Null) {
3115                amount = crate::precise::Precise::stringAdd(&filled, &remaining);
3116            }  else if (status.as_str() == Some("closed")) {
3117                amount = filled.clone();
3118            }
3119        }
3120        if (filled == Value::Null) {
3121            if (amount != Value::Null) && (remaining != Value::Null) {
3122                filled = crate::precise::Precise::stringSub(&amount, &remaining);
3123            }  else if (status.as_str() == Some("closed")) && (amount != Value::Null) {
3124                filled = amount.clone();
3125            }
3126        }
3127        if (remaining == Value::Null) {
3128            if (amount != Value::Null) && (filled != Value::Null) {
3129                remaining = crate::precise::Precise::stringSub(&amount, &filled);
3130            }  else if (status.as_str() == Some("closed")) {
3131                remaining = Value::Str("0".into());
3132            }
3133        }
3134        // ensure that the average field is calculated correctly
3135        let mut inverse: Value = self.safe_bool_k(market.clone(), "inverse", &[Value::Bool(false)]);
3136        let mut contractSize: Value = self.number_to_string(self.safe_value_k(market, "contractSize", &[Value::Int(1)]));
3137        // inverse
3138        // price = filled * contract size / cost
3139        //
3140        // linear
3141        // price = cost / (filled * contract size)
3142        if (average == Value::Null) {
3143            if (filled != Value::Null) && (cost != Value::Null) && is_true(&crate::precise::Precise::stringGt(&filled, &Value::Str("0".into()))) {
3144                let mut filledTimesContractSize: Value = crate::precise::Precise::stringMul(&filled, &contractSize);
3145                if (inverse.as_bool() == Some(true)) {
3146                    average = crate::precise::Precise::stringDiv(&filledTimesContractSize, &cost);
3147                }  else {
3148                    average = crate::precise::Precise::stringDiv(&cost, &filledTimesContractSize);
3149                }
3150            }
3151        }
3152        // similarly
3153        // inverse
3154        // cost = filled * contract size / price
3155        //
3156        // linear
3157        // cost = filled * contract size * price
3158        let mut costPriceExists: bool = (average != Value::Null) || (price != Value::Null);
3159        if parseCost && (filled != Value::Null) && costPriceExists {
3160            let mut multiplyPrice: Value = Value::Null;
3161            if (average == Value::Null) {
3162                multiplyPrice = price.clone();
3163            }  else {
3164                multiplyPrice = average.clone();
3165            }
3166            // contract trading
3167            let mut filledTimesContractSize: Value = crate::precise::Precise::stringMul(&filled, &contractSize);
3168            if (inverse.as_bool() == Some(true)) {
3169                cost = crate::precise::Precise::stringDiv(&filledTimesContractSize, &multiplyPrice);
3170            }  else {
3171                cost = crate::precise::Precise::stringMul(&filledTimesContractSize, &multiplyPrice);
3172            }
3173        }
3174        // support for market orders
3175        let mut orderType: Value = self.safe_value_k(orderDict.clone(), "type", &[]);
3176        let mut emptyPrice: bool = (price == Value::Null) || is_true(&crate::precise::Precise::stringEquals(&price, &Value::Str("0".into())));
3177        if emptyPrice && (orderType.as_str() == Some("market")) {
3178            price = average.clone();
3179        }
3180        {
3181                        let mut i: Value = Value::Int(0);
3182            let mut __for_first_97: bool = true;
3183            while { if !__for_first_97 { i = (match (&(i), &(Value::Int(1))) { (Value::Int(x), Value::Int(y)) => Value::Int(x + y), (Value::Int(x), Value::Float(y)) => Value::Float(*x as f64 + *y), (Value::Float(x), Value::Int(y)) => Value::Float(*x + *y as f64), (Value::Float(x), Value::Float(y)) => Value::Float(x + y), _ => Value::Null }); } __for_first_97 = false; i.as_f64().unwrap_or(f64::NAN) < ((trades.len() as i64) as f64) } {
3184            let mut entry: Value = get_value(&trades, &i);
3185            let mut entry: Value = get_value(&trades, &i);
3186            { let __be_tmp = self.safe_number_k(entry.clone(), "amount", &[]); add_element_to_object(&mut entry, &Value::Str("amount".into()), __be_tmp); };
3187            { let __be_tmp = self.safe_number_k(entry.clone(), "price", &[]); add_element_to_object(&mut entry, &Value::Str("price".into()), __be_tmp); };
3188            { let __be_tmp = self.safe_number_k(entry.clone(), "cost", &[]); add_element_to_object(&mut entry, &Value::Str("cost".into()), __be_tmp); };
3189            let mut tradeFee: Value = self.safe_dict_k(entry.clone(), "fee", &[Value::Map({
3190    let mut m = indexmap::IndexMap::new();
3191    m
3192})]);
3193            { let __be_tmp = self.safe_number_k(tradeFee.clone(), "cost", &[]); if let Value::Dict(__d) = &mut tradeFee { std::sync::Arc::make_mut(__d).insert("cost".into(), __be_tmp); } }
3194            if (matches!(&tradeFee, Value::Dict(__d) if __d.contains_key("rate"))) {
3195                { let __be_tmp = self.safe_number_k(tradeFee.clone(), "rate", &[]); if let Value::Dict(__d) = &mut tradeFee { std::sync::Arc::make_mut(__d).insert("rate".into(), __be_tmp); } }
3196            }
3197            let mut entryFees: Value = self.safe_list_k(entry.clone(), "fees", &[Value::from(vec![])]);
3198            {
3199                                let mut j: Value = Value::Int(0);
3200                let mut __for_first_96: bool = true;
3201                while { if !__for_first_96 { j = (match (&(j), &(Value::Int(1))) { (Value::Int(x), Value::Int(y)) => Value::Int(x + y), (Value::Int(x), Value::Float(y)) => Value::Float(*x as f64 + *y), (Value::Float(x), Value::Int(y)) => Value::Float(*x + *y as f64), (Value::Float(x), Value::Float(y)) => Value::Float(x + y), _ => Value::Null }); } __for_first_96 = false; j.as_f64().unwrap_or(f64::NAN) < ((entryFees.len() as i64) as f64) } {
3202                { 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".into()), __be_tmp); };
3203            }
3204            }
3205            add_element_to_object(&mut entry, &Value::Str("fees".into()), entryFees);
3206            add_element_to_object(&mut entry, &Value::Str("fee".into()), tradeFee);
3207        }
3208        }
3209        let mut timeInForce: Value = self.safe_string_k(orderDict.clone(), "timeInForce", &[]);
3210        let mut postOnly: Value = self.safe_value_k(orderDict.clone(), "postOnly", &[]);
3211        // timeInForceHandling
3212        if (timeInForce == Value::Null) {
3213            if !isTriggerOrSLTpOrder && (self.safe_string_k(orderDict.clone(), "type", &[]).as_str() == Some("market")) {
3214                timeInForce = Value::Str("IOC".into());
3215            }
3216            // allow postOnly override
3217            if is_equal(&postOnly, &Value::Bool(true)) {
3218                timeInForce = Value::Str("PO".into());
3219            }
3220        }  else if (postOnly == Value::Null) {
3221            // timeInForce is not undefined here
3222            postOnly = Value::Bool(timeInForce.as_str() == Some("PO"));
3223        }
3224        let mut timestamp: Value = self.safe_integer_k(orderDict.clone(), "timestamp", &[]);
3225        let mut lastUpdateTimestamp: Value = self.safe_integer_k(orderDict.clone(), "lastUpdateTimestamp", &[]);
3226        let mut datetime: Value = self.safe_string_k(orderDict.clone(), "datetime", &[]);
3227        if (datetime == Value::Null) {
3228            datetime = self.iso8601(timestamp.clone());
3229        }
3230        let mut triggerPrice: Value = self.parse_number(self.safe_string2(orderDict.clone(), Value::Str("triggerPrice".into()), Value::Str("stopPrice".into()), &[]), &[]);
3231        let mut takeProfitPrice: Value = self.parse_number(self.safe_string_k(orderDict.clone(), "takeProfitPrice", &[]), &[]);
3232        let mut stopLossPrice: Value = self.parse_number(self.safe_string_k(orderDict.clone(), "stopLossPrice", &[]), &[]);
3233        return self.extend(orderDict.clone(), &[Value::Map({
3234    let mut m = indexmap::IndexMap::new();
3235        m.insert("id".to_string(), self.safe_string_k(orderDict.clone(), "id", &[]));
3236        m.insert("clientOrderId".to_string(), self.safe_string_k(orderDict.clone(), "clientOrderId", &[]));
3237        m.insert("timestamp".to_string(), timestamp);
3238        m.insert("datetime".to_string(), datetime);
3239        m.insert("symbol".to_string(), symbol);
3240        m.insert("type".to_string(), self.safe_string_k(orderDict.clone(), "type", &[]));
3241        m.insert("side".to_string(), side);
3242        m.insert("lastTradeTimestamp".to_string(), lastTradeTimeTimestamp);
3243        m.insert("lastUpdateTimestamp".to_string(), lastUpdateTimestamp);
3244        m.insert("price".to_string(), self.parse_number(price, &[]));
3245        m.insert("amount".to_string(), self.parse_number(amount, &[]));
3246        m.insert("cost".to_string(), self.parse_number(cost, &[]));
3247        m.insert("average".to_string(), self.parse_number(average, &[]));
3248        m.insert("filled".to_string(), self.parse_number(filled, &[]));
3249        m.insert("remaining".to_string(), self.parse_number(remaining, &[]));
3250        m.insert("timeInForce".to_string(), timeInForce);
3251        m.insert("postOnly".to_string(), postOnly);
3252        m.insert("trades".to_string(), trades);
3253        m.insert("reduceOnly".to_string(), self.safe_value_k(orderDict.clone(), "reduceOnly", &[]));
3254        m.insert("stopPrice".to_string(), triggerPrice.clone());
3255        m.insert("triggerPrice".to_string(), triggerPrice);
3256        m.insert("takeProfitPrice".to_string(), takeProfitPrice);
3257        m.insert("stopLossPrice".to_string(), stopLossPrice);
3258        m.insert("status".to_string(), status);
3259        m.insert("fee".to_string(), self.safe_value_k(orderDict, "fee", &[]));
3260    m
3261})]);
3262
3263    Value::Null
3264}
3265
3266    fn parse_orders(&self, mut orders: Value, optional_args: &[Value]) -> Value {
3267        let mut market = get_arg(optional_args, 0, Value::Null);
3268        let mut since = get_arg(optional_args, 1, Value::Null);
3269        let mut limit = get_arg(optional_args, 2, Value::Null);
3270        let mut params = get_arg(optional_args, 3, Value::Map({
3271    let mut m = indexmap::IndexMap::new();
3272    m
3273}));
3274        //
3275        // the value of orders is either a dict or a list
3276        //
3277        // dict
3278        //
3279        //     {
3280        //         'id1': { ... },
3281        //         'id2': { ... },
3282        //         'id3': { ... },
3283        //         ...
3284        //     }
3285        //
3286        // list
3287        //
3288        //     [
3289        //         { 'id': 'id1', ... },
3290        //         { 'id': 'id2', ... },
3291        //         { 'id': 'id3', ... },
3292        //         ...
3293        //     ]
3294        //
3295        if (orders == Value::Null) {
3296            return Value::from(vec![]);
3297        }
3298        let mut results: Value = Value::from(vec![]);
3299        if (matches!(&orders, Value::Arr(_))) {
3300            {
3301                                let mut i: Value = Value::Int(0);
3302                let mut __for_first_98: bool = true;
3303                while { if !__for_first_98 { i = (match (&(i), &(Value::Int(1))) { (Value::Int(x), Value::Int(y)) => Value::Int(x + y), (Value::Int(x), Value::Float(y)) => Value::Float(*x as f64 + *y), (Value::Float(x), Value::Int(y)) => Value::Float(*x + *y as f64), (Value::Float(x), Value::Float(y)) => Value::Float(x + y), _ => Value::Null }); } __for_first_98 = false; i.as_f64().unwrap_or(f64::NAN) < ((orders.len() as i64) as f64) } {
3304                let mut parsed: Value = <Self as crate::exchange_generated::ExchangeBase>::parse_order(self, get_value(&orders, &i), &[market.clone()]); // don't inline this call
3305                let mut order: Value = self.extend(parsed, &[params.clone()]);
3306                append_to_array(&mut results, order.clone());
3307            }
3308            }
3309        }  else {
3310            let mut ids: Value = object_keys(&orders);
3311            {
3312                                let mut i: Value = Value::Int(0);
3313                let mut __for_first_99: bool = true;
3314                while { if !__for_first_99 { i = (match (&(i), &(Value::Int(1))) { (Value::Int(x), Value::Int(y)) => Value::Int(x + y), (Value::Int(x), Value::Float(y)) => Value::Float(*x as f64 + *y), (Value::Float(x), Value::Int(y)) => Value::Float(*x + *y as f64), (Value::Float(x), Value::Float(y)) => Value::Float(x + y), _ => Value::Null }); } __for_first_99 = false; i.as_f64().unwrap_or(f64::NAN) < ((ids.len() as i64) as f64) } {
3315                let mut id: Value = ids.as_array().and_then(|__arr| match &i { Value::Int(__n) => __arr.get(*__n as usize), Value::Str(__s) => __s.parse::<usize>().ok().and_then(|__n| __arr.get(__n)), _ => None }).cloned().unwrap_or(Value::Null);
3316                let mut idExtended: Value = self.extend(Value::Map({
3317                    let mut m = indexmap::IndexMap::new();
3318                        m.insert("id".to_string(), id.clone());
3319                    m
3320                }), &[get_value(&orders, &id)]);
3321                let mut parsedOrder: Value = <Self as crate::exchange_generated::ExchangeBase>::parse_order(self, idExtended, &[market.clone()]); // don't  inline these calls
3322                let mut order: Value = self.extend(parsedOrder, &[params.clone()]);
3323                append_to_array(&mut results, order);
3324            }
3325            }
3326        }
3327        results = self.sort_by(results.clone(), Value::Str("timestamp".into()), &[]);
3328        let mut symbol: Value = self.safe_string_k(market, "symbol", &[]);
3329        return self.filter_by_symbol_since_limit(results, &[symbol, since, limit]);
3330
3331    Value::Null
3332}
3333
3334    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 {
3335        let mut takerOrMaker = get_arg(optional_args, 0, Value::Str("taker".into()));
3336        let mut feeRate = get_arg(optional_args, 1, Value::Null);
3337        let mut params = get_arg(optional_args, 2, Value::Map({
3338    let mut m = indexmap::IndexMap::new();
3339    m
3340}));
3341        if (type_var.as_str() == Some("market")) && (takerOrMaker.as_str() == Some("maker")) {
3342            panic!("{}", crate::exchange_errors::arguments_required(format!("{}{}", self.id.clone(), 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.".into()))));
3343        }
3344        let mut markets: Value = self.markets.clone();
3345        if (markets == Value::Null) {
3346            panic!("{}", crate::exchange_errors::exchange_error(format!("{}{}", self.id.clone(), Value::Str(" markets not loaded".into()))));
3347        }
3348        let mut market: Value = get_value(&markets, &symbol);
3349        let mut market: Value = get_value(&markets, &symbol);
3350        let mut feeSide: Option<String> = self.safe_string_k(market.clone(), "feeSide", &[Value::Str("quote".into())]).as_str().map(str::to_owned);
3351        let mut useQuote: Value = Value::Null;
3352        if (feeSide.as_deref() == Some("get")) {
3353            // the fee is always in the currency you get
3354            useQuote = Value::Bool(side.as_str() == Some("sell"));
3355        }  else if (feeSide.as_deref() == Some("give")) {
3356            // the fee is always in the currency you give
3357            useQuote = Value::Bool(side.as_str() == Some("buy"));
3358        }  else {
3359            // the fee is always in feeSide currency
3360            useQuote = Value::Bool(feeSide.as_deref() == Some("quote"));
3361        }
3362        let mut cost: Value = self.number_to_string(amount);
3363        let mut key: Value = Value::Null;
3364        if useQuote.as_bool() == Some(true) {
3365            let mut priceString: Value = self.number_to_string(price);
3366            cost = crate::precise::Precise::stringMul(&cost, &priceString);
3367            key = Value::Str("quote".into());
3368        }  else {
3369            key = Value::Str("base".into());
3370        }
3371        // for derivatives, the fee is in 'settle' currency
3372        if !is_equal(&crate::value::get_value_k(&market, "spot"), &Value::Bool(true)) {
3373            key = Value::Str("settle".into());
3374        }
3375        // even if `takerOrMaker` argument was set to 'maker', for 'market' orders we should forcefully override it to 'taker'
3376        let mut takerOrMakerResolved: Value = (if (type_var.as_str() == Some("market")) { Value::Str("taker".into()) } else { takerOrMaker });
3377        let mut rate: Value = (if (feeRate != Value::Null) { self.number_to_string(feeRate) } else { self.safe_string(market.clone(), takerOrMakerResolved.clone(), &[]) });
3378        cost = crate::precise::Precise::stringMul(&cost, &rate);
3379        return Value::Map({
3380    let mut m = indexmap::IndexMap::new();
3381        m.insert("type".to_string(), takerOrMakerResolved);
3382        m.insert("currency".to_string(), get_value(&market, &key));
3383        m.insert("rate".to_string(), self.parse_number(rate, &[]));
3384        m.insert("cost".to_string(), self.parse_number(cost, &[]));
3385    m
3386});
3387
3388    Value::Null
3389}
3390
3391    fn calculate_fee(&self, mut symbol: Value, mut type_var: Value, mut side: Value, mut amount: Value, mut price: Value, optional_args: &[Value]) -> Value {
3392        let mut takerOrMaker = get_arg(optional_args, 0, Value::Str("taker".into()));
3393        let mut params = get_arg(optional_args, 1, Value::Map({
3394    let mut m = indexmap::IndexMap::new();
3395    m
3396}));
3397        return self.calculate_fee_with_rate(symbol, type_var, side, amount, price, &[takerOrMaker, Value::Null, params]);
3398
3399    Value::Null
3400}
3401
3402    fn safe_liquidation(&self, mut liquidation: Value, optional_args: &[Value]) -> Value {
3403        let mut market = get_arg(optional_args, 0, Value::Null);
3404        let __market_empty = indexmap::IndexMap::new();
3405        let market = market.as_map().unwrap_or(&__market_empty);
3406        let mut contracts: Value = self.safe_string_k(liquidation.clone(), "contracts", &[]);
3407        let mut contractSize: Value = (match market.get("contractSize") { Some(Value::Str(__s)) if !__s.is_empty() => Value::Str(__s.clone()), Some(Value::Int(__n)) => Value::Str(__n.to_string().into()), Some(Value::Float(__f)) => Value::Str(__f.to_string().into()), _ => Value::Null });
3408        let mut price: Value = self.safe_string_k(liquidation.clone(), "price", &[]);
3409        let mut baseValue: Value = self.safe_string_k(liquidation.clone(), "baseValue", &[]);
3410        let mut quoteValue: Value = self.safe_string_k(liquidation.clone(), "quoteValue", &[]);
3411        if (baseValue == Value::Null) && (contracts != Value::Null) && (contractSize != Value::Null) && (price != Value::Null) {
3412            baseValue = crate::precise::Precise::stringMul(&contracts, &contractSize);
3413        }
3414        if (quoteValue == Value::Null) && (baseValue != Value::Null) && (price != Value::Null) {
3415            quoteValue = crate::precise::Precise::stringMul(&baseValue, &price);
3416        }
3417        if let Value::Dict(__d) = &mut liquidation { std::sync::Arc::make_mut(__d).insert("contracts".into(), self.parse_number(contracts, &[])); }
3418        if let Value::Dict(__d) = &mut liquidation { std::sync::Arc::make_mut(__d).insert("contractSize".into(), self.parse_number(contractSize, &[])); }
3419        if let Value::Dict(__d) = &mut liquidation { std::sync::Arc::make_mut(__d).insert("price".into(), self.parse_number(price, &[])); }
3420        if let Value::Dict(__d) = &mut liquidation { std::sync::Arc::make_mut(__d).insert("baseValue".into(), self.parse_number(baseValue, &[])); }
3421        if let Value::Dict(__d) = &mut liquidation { std::sync::Arc::make_mut(__d).insert("quoteValue".into(), self.parse_number(quoteValue, &[])); }
3422        return liquidation;
3423
3424    Value::Null
3425}
3426
3427    fn safe_trade(&self, mut trade: Value, optional_args: &[Value]) -> Value {
3428        let mut market = get_arg(optional_args, 0, Value::Null);
3429        let __market_empty = indexmap::IndexMap::new();
3430        let market = market.as_map().unwrap_or(&__market_empty);
3431        let mut amount: Value = self.safe_string_k(trade.clone(), "amount", &[]);
3432        let mut price: Value = self.safe_string_k(trade.clone(), "price", &[]);
3433        let mut cost: Value = self.safe_string_k(trade.clone(), "cost", &[]);
3434        if (cost == Value::Null) {
3435            // contract trading
3436            let mut contractSize: Value = (match market.get("contractSize") { Some(Value::Str(__s)) if !__s.is_empty() => Value::Str(__s.clone()), Some(Value::Int(__n)) => Value::Str(__n.to_string().into()), Some(Value::Float(__f)) => Value::Str(__f.to_string().into()), _ => Value::Null });
3437            let mut multiplyPrice: Value = price.clone();
3438            if (contractSize != Value::Null) {
3439                let mut inverse: Value = (match market.get("inverse") { Some(Value::Bool(__b)) => Value::Bool(*__b), _ => Value::Bool(false) });
3440                if (inverse.as_bool() == Some(true)) {
3441                    multiplyPrice = crate::precise::Precise::stringDiv(&Value::Str("1".into()), &price);
3442                }
3443                multiplyPrice = crate::precise::Precise::stringMul(&multiplyPrice, &contractSize);
3444            }
3445            cost = crate::precise::Precise::stringMul(&multiplyPrice, &amount);
3446        }
3447        let mut resultFeeresultFeesVariable = self.parsed_fee_and_fees(trade.clone());
3448        let mut resultFee: Value = resultFeeresultFeesVariable.as_array().and_then(|__arr| __arr.get(0)).cloned().unwrap_or(Value::Null);
3449        let mut resultFees: Value = resultFeeresultFeesVariable.as_array().and_then(|__arr| __arr.get(1)).cloned().unwrap_or(Value::Null);
3450        if let Value::Dict(__d) = &mut trade { std::sync::Arc::make_mut(__d).insert("fee".into(), resultFee); }
3451        if let Value::Dict(__d) = &mut trade { std::sync::Arc::make_mut(__d).insert("fees".into(), resultFees); }
3452        if let Value::Dict(__d) = &mut trade { std::sync::Arc::make_mut(__d).insert("amount".into(), self.parse_number(amount, &[])); }
3453        if let Value::Dict(__d) = &mut trade { std::sync::Arc::make_mut(__d).insert("price".into(), self.parse_number(price, &[])); }
3454        if let Value::Dict(__d) = &mut trade { std::sync::Arc::make_mut(__d).insert("cost".into(), self.parse_number(cost, &[])); }
3455        return trade;
3456
3457    Value::Null
3458}
3459
3460    fn create_ccxt_trade_id(&self, optional_args: &[Value]) -> Value {
3461        let mut timestamp = get_arg(optional_args, 0, Value::Null);
3462        let mut side = get_arg(optional_args, 1, Value::Null);
3463        let mut amount = get_arg(optional_args, 2, Value::Null);
3464        let mut price = get_arg(optional_args, 3, Value::Null);
3465        let mut takerOrMaker = get_arg(optional_args, 4, Value::Null);
3466        // this approach is being used by multiple exchanges (mexc, woo, coinsbit, dydx, ...)
3467        let mut id: Value = Value::Null;
3468        if (timestamp != Value::Null) {
3469            id = self.number_to_string(timestamp);
3470            if (side != Value::Null) {
3471                id = Value::Str(format!("{}{}", id, Value::Str(format!("{}{}", Value::Str("-".into()), side).into())).into());
3472            }
3473            if (amount != Value::Null) {
3474                id = Value::Str(format!("{}{}", id, Value::Str(format!("{}{}", Value::Str("-".into()), self.number_to_string(amount)).into())).into());
3475            }
3476            if (price != Value::Null) {
3477                id = Value::Str(format!("{}{}", id, Value::Str(format!("{}{}", Value::Str("-".into()), self.number_to_string(price)).into())).into());
3478            }
3479            if (takerOrMaker != Value::Null) {
3480                id = Value::Str(format!("{}{}", id, Value::Str(format!("{}{}", Value::Str("-".into()), takerOrMaker).into())).into());
3481            }
3482        }
3483        return id;
3484
3485    Value::Null
3486}
3487
3488    fn parsed_fee_and_fees(&self, mut container: Value) -> Value {
3489        let mut fee: Value = self.safe_dict_k(container.clone(), "fee", &[]);
3490        let mut fees: Value = self.safe_list_k(container, "fees", &[]);
3491        let mut feeDefined: bool = fee != Value::Null;
3492        let mut feesDefined: bool = fees != Value::Null;
3493        // parsing only if at least one of them is defined
3494        let mut shouldParseFees: bool = feeDefined || feesDefined;
3495        if shouldParseFees {
3496            if feeDefined {
3497                fee = self.parse_fee_numeric(fee.clone());
3498            }
3499            if !feesDefined {
3500                // just set it directly, no further processing needed.
3501                fees = Value::from(vec![fee.clone()]);
3502            }
3503            // 'fees' were set, so reparse them
3504            let mut reducedFees: Value = fees.clone();
3505            if is_true(&self.reduceFees) {
3506                reducedFees = self.reduce_fees_by_currency(fees.clone());
3507            }
3508            if (reducedFees == Value::Null) {
3509                reducedFees = Value::from(vec![]);
3510            }
3511            let mut reducedLength: f64 = ((reducedFees.len() as i64) as f64);
3512            {
3513                                let mut i: Value = Value::Int(0);
3514                let mut __for_first_100: bool = true;
3515                while { if !__for_first_100 { i = (match (&(i), &(Value::Int(1))) { (Value::Int(x), Value::Int(y)) => Value::Int(x + y), (Value::Int(x), Value::Float(y)) => Value::Float(*x as f64 + *y), (Value::Float(x), Value::Int(y)) => Value::Float(*x + *y as f64), (Value::Float(x), Value::Float(y)) => Value::Float(x + y), _ => Value::Null }); } __for_first_100 = false; i.as_f64().unwrap_or(f64::NAN) < reducedLength } {
3516                { let __be_tmp = self.parse_fee_numeric(get_value(&reducedFees, &i)); add_element_to_object(&mut reducedFees, &i, __be_tmp); };
3517            }
3518            }
3519            fees = reducedFees.clone();
3520            if (reducedLength == 1.0) {
3521                fee = reducedFees.as_array().and_then(|__arr| __arr.get(0)).cloned().unwrap_or(Value::Null);
3522            }  else if (reducedLength == 0.0) {
3523                fee = Value::Null;
3524            }
3525        }
3526        // in case `fee & fees` are undefined, set `fees` as empty array
3527        if (fee == Value::Null) {
3528            fee = Value::Map({
3529                let mut m = indexmap::IndexMap::new();
3530                    m.insert("cost".to_string(), Value::Null);
3531                    m.insert("currency".to_string(), Value::Null);
3532                m
3533            });
3534        }
3535        if (fees == Value::Null) {
3536            fees = Value::from(vec![]);
3537        }
3538        return Value::from(vec![fee, fees]);
3539
3540    Value::Null
3541}
3542
3543    fn parse_fee_numeric(&self, mut fee: Value) -> Value {
3544        { let __be_tmp = self.safe_number_k(fee.clone(), "cost", &[]); add_element_to_object(&mut fee, &Value::Str("cost".into()), __be_tmp); }; // ensure numeric
3545        if (in_op(&fee, &Value::Str("rate".into()))) {
3546            { let __be_tmp = self.safe_number_k(fee.clone(), "rate", &[]); add_element_to_object(&mut fee, &Value::Str("rate".into()), __be_tmp); };
3547        }
3548        return fee;
3549
3550    Value::Null
3551}
3552
3553    fn find_nearest_ceiling(&self, mut arr: Value, mut providedValue: Value) -> Value {
3554        //  i.e. findNearestCeiling ([ 10, 30, 50],  23) returns 30
3555        let mut length: Value = Value::Int(arr.len() as i64);
3556        {
3557                        let mut i: Value = Value::Int(0);
3558            let mut __for_first_101: bool = true;
3559            while { if !__for_first_101 { i = (match (&(i), &(Value::Int(1))) { (Value::Int(x), Value::Int(y)) => Value::Int(x + y), (Value::Int(x), Value::Float(y)) => Value::Float(*x as f64 + *y), (Value::Float(x), Value::Int(y)) => Value::Float(*x + *y as f64), (Value::Float(x), Value::Float(y)) => Value::Float(x + y), _ => Value::Null }); } __for_first_101 = false; i.as_f64().unwrap_or(f64::NAN) < length.as_f64().unwrap_or(f64::NAN) } {
3560            let mut current: Value = arr.as_array().and_then(|__arr| match &i { Value::Int(__n) => __arr.get(*__n as usize), Value::Str(__s) => __s.parse::<usize>().ok().and_then(|__n| __arr.get(__n)), _ => None }).cloned().unwrap_or(Value::Null);
3561            if providedValue.as_f64().unwrap_or(f64::NAN) <= current.as_f64().unwrap_or(f64::NAN) {
3562                return current;
3563            }
3564        }
3565        }
3566        return get_value(&arr, &(match (&(length), &(Value::Int(1))) { (Value::Int(x), Value::Int(y)) => Value::Int(x - y), (Value::Int(x), Value::Float(y)) => Value::Float(*x as f64 - *y), (Value::Float(x), Value::Int(y)) => Value::Float(*x - *y as f64), (Value::Float(x), Value::Float(y)) => Value::Float(x - y), _ => Value::Null }));
3567
3568    Value::Null
3569}
3570
3571    fn add_key_in_array_items(&self, mut obj: Value, mut keyName: Value) -> Value {
3572        let mut result: Value = Value::from(vec![]);
3573        let mut keys: Value = object_keys(&obj);
3574        {
3575                        let mut i: Value = Value::Int(0);
3576            let mut __for_first_102: bool = true;
3577            while { if !__for_first_102 { i = (match (&(i), &(Value::Int(1))) { (Value::Int(x), Value::Int(y)) => Value::Int(x + y), (Value::Int(x), Value::Float(y)) => Value::Float(*x as f64 + *y), (Value::Float(x), Value::Int(y)) => Value::Float(*x + *y as f64), (Value::Float(x), Value::Float(y)) => Value::Float(x + y), _ => Value::Null }); } __for_first_102 = false; i.as_f64().unwrap_or(f64::NAN) < ((keys.len() as i64) as f64) } {
3578            let mut key: Value = keys.as_array().and_then(|__arr| match &i { Value::Int(__n) => __arr.get(*__n as usize), Value::Str(__s) => __s.parse::<usize>().ok().and_then(|__n| __arr.get(__n)), _ => None }).cloned().unwrap_or(Value::Null);
3579            let mut item: Value = get_value(&obj, &key);
3580            let mut item: Value = get_value(&obj, &key);
3581            if (item == Value::Null) {
3582                continue;
3583            }
3584            let mut itemWithKey: Value = self.extend(Value::Map({
3585                let mut m = indexmap::IndexMap::new();
3586                m
3587            }), &[item]);
3588            add_element_to_object(&mut itemWithKey, &keyName, key);
3589            append_to_array(&mut result, itemWithKey);
3590        }
3591        }
3592        return result;
3593
3594    Value::Null
3595}
3596
3597    fn invert_flat_string_dictionary(&self, mut dict: Value) -> Value {
3598        let mut reversed: Value = Value::Map({
3599            let mut m = indexmap::IndexMap::new();
3600            m
3601        });
3602        let mut keys: Value = object_keys(&dict);
3603        {
3604                        let mut i: Value = Value::Int(0);
3605            let mut __for_first_103: bool = true;
3606            while { if !__for_first_103 { i = (match (&(i), &(Value::Int(1))) { (Value::Int(x), Value::Int(y)) => Value::Int(x + y), (Value::Int(x), Value::Float(y)) => Value::Float(*x as f64 + *y), (Value::Float(x), Value::Int(y)) => Value::Float(*x + *y as f64), (Value::Float(x), Value::Float(y)) => Value::Float(x + y), _ => Value::Null }); } __for_first_103 = false; i.as_f64().unwrap_or(f64::NAN) < ((keys.len() as i64) as f64) } {
3607            let mut key: Value = keys.as_array().and_then(|__arr| match &i { Value::Int(__n) => __arr.get(*__n as usize), Value::Str(__s) => __s.parse::<usize>().ok().and_then(|__n| __arr.get(__n)), _ => None }).cloned().unwrap_or(Value::Null);
3608            let mut value: Value = get_value(&dict, &key);
3609            let mut value: Value = get_value(&dict, &key);
3610            if matches!(&value, Value::Str(_)) {
3611                if let Value::Dict(__d) = &mut reversed { std::sync::Arc::make_mut(__d).insert(crate::runtime::stringify_param(&value), key); }
3612            }
3613        }
3614        }
3615        return reversed;
3616
3617    Value::Null
3618}
3619
3620    fn string_to_base16(&self, mut str_val: Value) -> Value {
3621        return Value::Str(format!("{}{}", Value::Str("0x".into()), self.binary_to_base16(self.base64_to_binary(self.string_to_base64(str_val, &[]), &[]), &[])).into());
3622
3623    Value::Null
3624}
3625
3626    fn reduce_fees_by_currency(&self, mut fees: Value) -> Value {
3627        //
3628        // this function takes a list of fee structures having the following format
3629        //
3630        //     string = true
3631        //
3632        //     [
3633        //         { 'currency': 'BTC', 'cost': '0.1' },
3634        //         { 'currency': 'BTC', 'cost': '0.2'  },
3635        //         { 'currency': 'BTC', 'cost': '0.2', 'rate': '0.00123' },
3636        //         { 'currency': 'BTC', 'cost': '0.4', 'rate': '0.00123' },
3637        //         { 'currency': 'BTC', 'cost': '0.5', 'rate': '0.00456' },
3638        //         { 'currency': 'USDT', 'cost': '12.3456' },
3639        //     ]
3640        //
3641        //     string = false
3642        //
3643        //     [
3644        //         { 'currency': 'BTC', 'cost': 0.1 },
3645        //         { 'currency': 'BTC', 'cost': 0.2 },
3646        //         { 'currency': 'BTC', 'cost': 0.2, 'rate': 0.00123 },
3647        //         { 'currency': 'BTC', 'cost': 0.4, 'rate': 0.00123 },
3648        //         { 'currency': 'BTC', 'cost': 0.5, 'rate': 0.00456 },
3649        //         { 'currency': 'USDT', 'cost': 12.3456 },
3650        //     ]
3651        //
3652        // and returns a reduced fee list, where fees are summed per currency and rate (if any)
3653        //
3654        //     string = true
3655        //
3656        //     [
3657        //         { 'currency': 'BTC', 'cost': '0.4'  },
3658        //         { 'currency': 'BTC', 'cost': '0.6', 'rate': '0.00123' },
3659        //         { 'currency': 'BTC', 'cost': '0.5', 'rate': '0.00456' },
3660        //         { 'currency': 'USDT', 'cost': '12.3456' },
3661        //     ]
3662        //
3663        //     string  = false
3664        //
3665        //     [
3666        //         { 'currency': 'BTC', 'cost': 0.3  },
3667        //         { 'currency': 'BTC', 'cost': 0.6, 'rate': 0.00123 },
3668        //         { 'currency': 'BTC', 'cost': 0.5, 'rate': 0.00456 },
3669        //         { 'currency': 'USDT', 'cost': 12.3456 },
3670        //     ]
3671        //
3672        let mut reduced: Value = Value::Map({
3673            let mut m = indexmap::IndexMap::new();
3674            m
3675        });
3676        {
3677                        let mut i: Value = Value::Int(0);
3678            let mut __for_first_104: bool = true;
3679            while { if !__for_first_104 { i = (match (&(i), &(Value::Int(1))) { (Value::Int(x), Value::Int(y)) => Value::Int(x + y), (Value::Int(x), Value::Float(y)) => Value::Float(*x as f64 + *y), (Value::Float(x), Value::Int(y)) => Value::Float(*x + *y as f64), (Value::Float(x), Value::Float(y)) => Value::Float(x + y), _ => Value::Null }); } __for_first_104 = false; i.as_f64().unwrap_or(f64::NAN) < get_array_length(&fees).as_f64().unwrap_or(f64::NAN) } {
3680            let mut fee: Value = get_value(&fees, &i);
3681            let mut fee: Value = get_value(&fees, &i);
3682            let mut code: Value = self.safe_string_k(fee.clone(), "currency", &[]);
3683            let mut feeCurrencyCode: Value = (if (code != Value::Null) { code.clone() } else { to_string_val(&i) });
3684            if (feeCurrencyCode != Value::Null) {
3685                let mut rate: Value = self.safe_string_k(fee.clone(), "rate", &[]);
3686                let mut cost: Value = self.safe_string_k(fee, "cost", &[]);
3687                if (cost == Value::Null) {
3688                    continue;
3689                }
3690                if !(in_op(&reduced, &feeCurrencyCode)) {
3691                    if let Value::Dict(__d) = &mut reduced { std::sync::Arc::make_mut(__d).insert(crate::runtime::stringify_param(&feeCurrencyCode), Value::Map({
3692    let mut m = indexmap::IndexMap::new();
3693    m
3694})); }
3695                }
3696                let mut rateKey: Value = (if (rate == Value::Null) { Value::Str("".into()) } else { rate.clone() });
3697                if (in_op(&reduced.as_map().and_then(|__m| feeCurrencyCode.as_str().and_then(|__k| __m.get(__k))).cloned().unwrap_or(Value::Null), &rateKey)) {
3698                    { let __be_tmp = crate::precise::Precise::stringAdd(&crate::value::get_value_k(&get_value(&get_value(&reduced, &feeCurrencyCode), &rateKey), "cost"), &cost); add_element_to_object(get_value_mut(get_value_mut(&mut reduced, &feeCurrencyCode), &rateKey), &Value::Str("cost".into()), __be_tmp); };
3699                }  else {
3700                    add_element_to_object(get_value_mut(&mut reduced, &feeCurrencyCode), &rateKey, Value::Map({
3701    let mut m = indexmap::IndexMap::new();
3702        m.insert("currency".to_string(), code);
3703        m.insert("cost".to_string(), cost);
3704    m
3705}));
3706                    if (rate != Value::Null) {
3707                        add_element_to_object(get_value_mut(get_value_mut(&mut reduced, &feeCurrencyCode), &rateKey), &Value::Str("rate".into()), rate);
3708                    }
3709                }
3710            }
3711        }
3712        }
3713        let mut result: Value = Value::from(vec![]);
3714        let mut feeValues: Value = object_values(&reduced);
3715        {
3716                        let mut i: Value = Value::Int(0);
3717            let mut __for_first_105: bool = true;
3718            while { if !__for_first_105 { i = (match (&(i), &(Value::Int(1))) { (Value::Int(x), Value::Int(y)) => Value::Int(x + y), (Value::Int(x), Value::Float(y)) => Value::Float(*x as f64 + *y), (Value::Float(x), Value::Int(y)) => Value::Float(*x + *y as f64), (Value::Float(x), Value::Float(y)) => Value::Float(x + y), _ => Value::Null }); } __for_first_105 = false; i.as_f64().unwrap_or(f64::NAN) < ((feeValues.len() as i64) as f64) } {
3719            let mut reducedFeeValues: Value = object_values(&feeValues.as_array().and_then(|__arr| match &i { Value::Int(__n) => __arr.get(*__n as usize), Value::Str(__s) => __s.parse::<usize>().ok().and_then(|__n| __arr.get(__n)), _ => None }).cloned().unwrap_or(Value::Null));
3720            result = self.array_concat(result.clone(), reducedFeeValues);
3721        }
3722        }
3723        return result;
3724
3725    Value::Null
3726}
3727
3728    fn safe_ticker(&self, mut ticker: Value, optional_args: &[Value]) -> Value {
3729        let mut market = get_arg(optional_args, 0, Value::Null);
3730        let mut open: Value = self.omit_zero(self.safe_string_k(ticker.clone(), "open", &[]));
3731        let mut close: Value = self.omit_zero(self.safe_string2(ticker.clone(), Value::Str("close".into()), Value::Str("last".into()), &[]));
3732        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
3733        let mut percentage: Value = self.omit_zero(self.safe_string_k(ticker.clone(), "percentage", &[]));
3734        let mut average: Value = self.omit_zero(self.safe_string_k(ticker.clone(), "average", &[]));
3735        let mut vwap: Value = self.safe_string_k(ticker.clone(), "vwap", &[]);
3736        let mut baseVolume: Value = self.safe_string_k(ticker.clone(), "baseVolume", &[]);
3737        let mut quoteVolume: Value = self.safe_string_k(ticker.clone(), "quoteVolume", &[]);
3738        if (vwap == Value::Null) {
3739            vwap = crate::precise::Precise::stringDiv(&self.omit_zero(quoteVolume.clone()), &baseVolume);
3740        }
3741        // calculate open
3742        if (change != Value::Null) {
3743            if (close == Value::Null) && (average != Value::Null) {
3744                close = crate::precise::Precise::stringAdd(&average, &crate::precise::Precise::stringDiv(&change, &Value::Str("2".into())));
3745            }
3746            if (open == Value::Null) && (close != Value::Null) {
3747                open = crate::precise::Precise::stringSub(&close, &change);
3748            }
3749        }  else if (percentage != Value::Null) {
3750            if (close == Value::Null) && (average != Value::Null) {
3751                let mut openAddClose: Value = crate::precise::Precise::stringMul(&average, &Value::Str("2".into()));
3752                // openAddClose = open * (1 + (100 + percentage)/100)
3753                let mut denominator: Value = crate::precise::Precise::stringAdd(&Value::Str("2".into()), &crate::precise::Precise::stringDiv(&percentage, &Value::Str("100".into())));
3754                let mut calcOpen: Value = (if (open != Value::Null) { open.clone() } else { crate::precise::Precise::stringDiv(&openAddClose, &denominator) });
3755                close = crate::precise::Precise::stringMul(&calcOpen, &crate::precise::Precise::stringAdd(&Value::Str("1".into()), &crate::precise::Precise::stringDiv(&percentage, &Value::Str("100".into()))));
3756            }
3757            if (open == Value::Null) && (close != Value::Null) {
3758                open = crate::precise::Precise::stringDiv(&close, &crate::precise::Precise::stringAdd(&Value::Str("1".into()), &crate::precise::Precise::stringDiv(&percentage, &Value::Str("100".into()))));
3759            }
3760        }
3761        // change
3762        if (change == Value::Null) {
3763            if (close != Value::Null) && (open != Value::Null) {
3764                change = crate::precise::Precise::stringSub(&close, &open);
3765            }  else if (close != Value::Null) && (percentage != Value::Null) {
3766                change = crate::precise::Precise::stringMul(&crate::precise::Precise::stringDiv(&percentage, &Value::Str("100".into())), &crate::precise::Precise::stringDiv(&close, &Value::Str("100".into())));
3767            }  else if (open != Value::Null) && (percentage != Value::Null) {
3768                change = crate::precise::Precise::stringMul(&open, &crate::precise::Precise::stringDiv(&percentage, &Value::Str("100".into())));
3769            }
3770        }
3771        // calculate things according to "open" (similar can be done with "close")
3772        if (open != Value::Null) {
3773            // percentage (using change)
3774            if (percentage == Value::Null) && (change != Value::Null) {
3775                percentage = crate::precise::Precise::stringMul(&crate::precise::Precise::stringDiv(&change, &open), &Value::Str("100".into()));
3776            }
3777            // close (using change)
3778            if (close == Value::Null) && (change != Value::Null) {
3779                close = crate::precise::Precise::stringAdd(&open, &change);
3780            }
3781            // close (using average)
3782            if (close == Value::Null) && (average != Value::Null) {
3783                // average is the midpoint of open and close, so twice it is their sum
3784                close = crate::precise::Precise::stringSub(&crate::precise::Precise::stringMul(&average, &Value::Str("2".into())), &open);
3785            }
3786            // average
3787            if (average == Value::Null) && (close != Value::Null) {
3788                let mut precision: Value = Value::Int(18);
3789                if (market != Value::Null) && self.is_tick_precision().as_bool() == Some(true) {
3790                    let mut marketPrecision: Value = self.safe_dict_k(market, "precision", &[]);
3791                    let mut precisionPrice: Value = self.safe_string_k(marketPrecision, "price", &[]);
3792                    if (precisionPrice != Value::Null) {
3793                        precision = self.precision_from_string(precisionPrice);
3794                    }
3795                }
3796                average = crate::precise::Precise::stringDivPrec(&crate::precise::Precise::stringAdd(&open, &close), &Value::Str("2".into()), &precision);
3797            }
3798        }
3799        // timestamp and symbol operations don't belong in safeTicker
3800        // they should be done in the derived classes
3801        let mut closeParsed: Value = self.parse_number(self.omit_zero(close), &[]);
3802        return self.extend(ticker.clone(), &[Value::Map({
3803    let mut m = indexmap::IndexMap::new();
3804        m.insert("bid".to_string(), self.parse_number(self.omit_zero(self.safe_string_k(ticker.clone(), "bid", &[])), &[]));
3805        m.insert("bidVolume".to_string(), self.safe_number_k(ticker.clone(), "bidVolume", &[]));
3806        m.insert("ask".to_string(), self.parse_number(self.omit_zero(self.safe_string_k(ticker.clone(), "ask", &[])), &[]));
3807        m.insert("askVolume".to_string(), self.safe_number_k(ticker.clone(), "askVolume", &[]));
3808        m.insert("high".to_string(), self.parse_number(self.omit_zero(self.safe_string_k(ticker.clone(), "high", &[])), &[]));
3809        m.insert("low".to_string(), self.parse_number(self.omit_zero(self.safe_string_k(ticker.clone(), "low", &[])), &[]));
3810        m.insert("open".to_string(), self.parse_number(self.omit_zero(open), &[]));
3811        m.insert("close".to_string(), closeParsed.clone());
3812        m.insert("last".to_string(), closeParsed);
3813        m.insert("change".to_string(), self.parse_number(change, &[]));
3814        m.insert("percentage".to_string(), self.parse_number(percentage, &[]));
3815        m.insert("average".to_string(), self.parse_number(average, &[]));
3816        m.insert("vwap".to_string(), self.parse_number(vwap, &[]));
3817        m.insert("baseVolume".to_string(), self.parse_number(baseVolume, &[]));
3818        m.insert("quoteVolume".to_string(), self.parse_number(quoteVolume, &[]));
3819        m.insert("previousClose".to_string(), self.safe_number_k(ticker.clone(), "previousClose", &[]));
3820        m.insert("indexPrice".to_string(), self.safe_number_k(ticker.clone(), "indexPrice", &[]));
3821        m.insert("markPrice".to_string(), self.safe_number_k(ticker, "markPrice", &[]));
3822    m
3823})]);
3824
3825    Value::Null
3826}
3827
3828    fn fetch_borrow_rate(&mut self, mut code: Value, mut amount: Value, optional_args: &[Value]) -> impl ::std::future::Future<Output = Value> + Send { async move {
3829        let mut params = get_arg(optional_args, 0, Value::Map({
3830    let mut m = indexmap::IndexMap::new();
3831    m
3832}));
3833        panic!("{}", crate::exchange_errors::not_supported(format!("{}{}", self.id.clone(), Value::Str(" fetchBorrowRate is deprecated, please use fetchCrossBorrowRate or fetchIsolatedBorrowRate instead".into()))));
3834
3835    Value::Null
3836} }
3837
3838    fn repay_cross_margin(&mut self, mut code: Value, mut amount: Value, optional_args: &[Value]) -> impl ::std::future::Future<Output = Value> + Send { async move {
3839        // async-virtual: try the derived exchange first
3840        if let Some(__v) = self.dispatch_to_derived("repay_cross_margin", { let mut __args: Vec<crate::Value> = Vec::new(); __args.push(code); __args.push(amount); __args.extend_from_slice(optional_args); __args }).await {
3841            if !matches!(__v, crate::Value::Null) { return __v; }
3842        }
3843
3844        let mut params = get_arg(optional_args, 0, Value::Map({
3845    let mut m = indexmap::IndexMap::new();
3846    m
3847}));
3848        panic!("{}", crate::exchange_errors::not_supported(format!("{}{}", self.id.clone(), Value::Str(" repayCrossMargin is not support yet".into()))));
3849
3850    Value::Null
3851} }
3852
3853    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 {
3854        // async-virtual: try the derived exchange first
3855        if let Some(__v) = self.dispatch_to_derived("repay_isolated_margin", { let mut __args: Vec<crate::Value> = Vec::new(); __args.push(symbol); __args.push(code); __args.push(amount); __args.extend_from_slice(optional_args); __args }).await {
3856            if !matches!(__v, crate::Value::Null) { return __v; }
3857        }
3858
3859        let mut params = get_arg(optional_args, 0, Value::Map({
3860    let mut m = indexmap::IndexMap::new();
3861    m
3862}));
3863        panic!("{}", crate::exchange_errors::not_supported(format!("{}{}", self.id.clone(), Value::Str(" repayIsolatedMargin is not support yet".into()))));
3864
3865    Value::Null
3866} }
3867
3868    fn borrow_cross_margin(&mut self, mut code: Value, mut amount: Value, optional_args: &[Value]) -> impl ::std::future::Future<Output = Value> + Send { async move {
3869        // async-virtual: try the derived exchange first
3870        if let Some(__v) = self.dispatch_to_derived("borrow_cross_margin", { let mut __args: Vec<crate::Value> = Vec::new(); __args.push(code); __args.push(amount); __args.extend_from_slice(optional_args); __args }).await {
3871            if !matches!(__v, crate::Value::Null) { return __v; }
3872        }
3873
3874        let mut params = get_arg(optional_args, 0, Value::Map({
3875    let mut m = indexmap::IndexMap::new();
3876    m
3877}));
3878        panic!("{}", crate::exchange_errors::not_supported(format!("{}{}", self.id.clone(), Value::Str(" borrowCrossMargin is not support yet".into()))));
3879
3880    Value::Null
3881} }
3882
3883    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 {
3884        // async-virtual: try the derived exchange first
3885        if let Some(__v) = self.dispatch_to_derived("borrow_isolated_margin", { let mut __args: Vec<crate::Value> = Vec::new(); __args.push(symbol); __args.push(code); __args.push(amount); __args.extend_from_slice(optional_args); __args }).await {
3886            if !matches!(__v, crate::Value::Null) { return __v; }
3887        }
3888
3889        let mut params = get_arg(optional_args, 0, Value::Map({
3890    let mut m = indexmap::IndexMap::new();
3891    m
3892}));
3893        panic!("{}", crate::exchange_errors::not_supported(format!("{}{}", self.id.clone(), Value::Str(" borrowIsolatedMargin is not support yet".into()))));
3894
3895    Value::Null
3896} }
3897
3898    fn borrow_margin(&mut self, mut code: Value, mut amount: Value, optional_args: &[Value]) -> impl ::std::future::Future<Output = Value> + Send { async move {
3899        let mut symbol = get_arg(optional_args, 0, Value::Null);
3900        let mut params = get_arg(optional_args, 1, Value::Map({
3901    let mut m = indexmap::IndexMap::new();
3902    m
3903}));
3904        panic!("{}", crate::exchange_errors::not_supported(format!("{}{}", self.id.clone(), Value::Str(" borrowMargin is deprecated, please use borrowCrossMargin or borrowIsolatedMargin instead".into()))));
3905
3906    Value::Null
3907} }
3908
3909    fn repay_margin(&mut self, mut code: Value, mut amount: Value, optional_args: &[Value]) -> impl ::std::future::Future<Output = Value> + Send { async move {
3910        let mut symbol = get_arg(optional_args, 0, Value::Null);
3911        let mut params = get_arg(optional_args, 1, Value::Map({
3912    let mut m = indexmap::IndexMap::new();
3913    m
3914}));
3915        panic!("{}", crate::exchange_errors::not_supported(format!("{}{}", self.id.clone(), Value::Str(" repayMargin is deprecated, please use repayCrossMargin or repayIsolatedMargin instead".into()))));
3916
3917    Value::Null
3918} }
3919
3920    fn fetch_ohlcv(&mut self, mut symbol: Value, optional_args: &[Value]) -> impl ::std::future::Future<Output = Value> + Send { async move {
3921        // async-virtual: try the derived exchange first
3922        if let Some(__v) = self.dispatch_to_derived("fetch_ohlcv", { let mut __args: Vec<crate::Value> = Vec::new(); __args.push(symbol); __args.extend_from_slice(optional_args); __args }).await {
3923            if !matches!(__v, crate::Value::Null) { return __v; }
3924        }
3925
3926        let mut timeframe = get_arg(optional_args, 0, Value::Str("1m".into()));
3927        let mut since = get_arg(optional_args, 1, Value::Null);
3928        let mut limit = get_arg(optional_args, 2, Value::Null);
3929        let mut params = get_arg(optional_args, 3, Value::Map({
3930    let mut m = indexmap::IndexMap::new();
3931    m
3932}));
3933        let mut message: Value = Value::Str("".into());
3934        if (self.has.as_map().and_then(|__m| __m.get("fetchTrades")).cloned().unwrap_or(Value::Null) != Value::Null) && (self.has.as_map().and_then(|__m| __m.get("fetchTrades")).cloned().unwrap_or(Value::Null).as_bool() != Some(false)) {
3935            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".into());
3936        }
3937        panic!("{}", crate::exchange_errors::not_supported(format!("{}{}", Value::Str(format!("{}{}", self.id.clone(), Value::Str(" fetchOHLCV() is not supported yet".into())).into()), message)));
3938
3939    Value::Null
3940} }
3941
3942    fn fetch_spot_ohlcv(&mut self, mut symbol: Value, optional_args: &[Value]) -> impl ::std::future::Future<Output = Value> + Send { async move {
3943        let mut timeframe = get_arg(optional_args, 0, Value::Str("1m".into()));
3944        let mut since = get_arg(optional_args, 1, Value::Null);
3945        let mut limit = get_arg(optional_args, 2, Value::Null);
3946        let mut params = get_arg(optional_args, 3, Value::Map({
3947    let mut m = indexmap::IndexMap::new();
3948    m
3949}));
3950        panic!("{}", crate::exchange_errors::not_supported(format!("{}{}", self.id.clone(), Value::Str(" fetchSpotOHLCV() is not supported yet".into()))));
3951
3952    Value::Null
3953} }
3954
3955    fn fetch_contract_ohlcv(&mut self, mut symbol: Value, optional_args: &[Value]) -> impl ::std::future::Future<Output = Value> + Send { async move {
3956        let mut timeframe = get_arg(optional_args, 0, Value::Str("1m".into()));
3957        let mut since = get_arg(optional_args, 1, Value::Null);
3958        let mut limit = get_arg(optional_args, 2, Value::Null);
3959        let mut params = get_arg(optional_args, 3, Value::Map({
3960    let mut m = indexmap::IndexMap::new();
3961    m
3962}));
3963        panic!("{}", crate::exchange_errors::not_supported(format!("{}{}", self.id.clone(), Value::Str(" fetchContractOHLCV() is not supported yet".into()))));
3964
3965    Value::Null
3966} }
3967
3968    fn fetch_ohlcv_ws(&mut self, mut symbol: Value, optional_args: &[Value]) -> impl ::std::future::Future<Output = Value> + Send { async move {
3969        let mut timeframe = get_arg(optional_args, 0, Value::Str("1m".into()));
3970        let mut since = get_arg(optional_args, 1, Value::Null);
3971        let mut limit = get_arg(optional_args, 2, Value::Null);
3972        let mut params = get_arg(optional_args, 3, Value::Map({
3973    let mut m = indexmap::IndexMap::new();
3974    m
3975}));
3976        let mut message: Value = Value::Str("".into());
3977        if (self.has.as_map().and_then(|__m| __m.get("fetchTradesWs")).cloned().unwrap_or(Value::Null) != Value::Null) && (self.has.as_map().and_then(|__m| __m.get("fetchTradesWs")).cloned().unwrap_or(Value::Null).as_bool() != Some(false)) {
3978            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".into());
3979        }
3980        panic!("{}", crate::exchange_errors::not_supported(format!("{}{}", Value::Str(format!("{}{}", self.id.clone(), Value::Str(" fetchOHLCVWs() is not supported yet. Try using fetchOHLCV instead.".into())).into()), message)));
3981
3982    Value::Null
3983} }
3984
3985    fn watch_ohlcv(&mut self, mut symbol: Value, optional_args: &[Value]) -> impl ::std::future::Future<Output = Value> + Send { async move {
3986        let mut timeframe = get_arg(optional_args, 0, Value::Str("1m".into()));
3987        let mut since = get_arg(optional_args, 1, Value::Null);
3988        let mut limit = get_arg(optional_args, 2, Value::Null);
3989        let mut params = get_arg(optional_args, 3, Value::Map({
3990    let mut m = indexmap::IndexMap::new();
3991    m
3992}));
3993        panic!("{}", crate::exchange_errors::not_supported(format!("{}{}", self.id.clone(), Value::Str(" watchOHLCV() is not supported yet".into()))));
3994
3995    Value::Null
3996} }
3997
3998    fn convert_trading_view_to_ohlcv(&self, mut ohlcvs: Value, optional_args: &[Value]) -> Value {
3999        let mut timestamp = get_arg(optional_args, 0, Value::Str("t".into()));
4000        let mut open = get_arg(optional_args, 1, Value::Str("o".into()));
4001        let mut high = get_arg(optional_args, 2, Value::Str("h".into()));
4002        let mut low = get_arg(optional_args, 3, Value::Str("l".into()));
4003        let mut close = get_arg(optional_args, 4, Value::Str("c".into()));
4004        let mut volume = get_arg(optional_args, 5, Value::Str("v".into()));
4005        let mut ms = get_arg(optional_args, 6, Value::Bool(false));
4006        let mut result: Value = Value::from(vec![]);
4007        let mut timestamps: Value = self.safe_list(ohlcvs.clone(), timestamp, &[Value::from(vec![])]);
4008        let mut opens: Value = self.safe_list(ohlcvs.clone(), open, &[Value::from(vec![])]);
4009        let mut highs: Value = self.safe_list(ohlcvs.clone(), high, &[Value::from(vec![])]);
4010        let mut lows: Value = self.safe_list(ohlcvs.clone(), low, &[Value::from(vec![])]);
4011        let mut closes: Value = self.safe_list(ohlcvs.clone(), close, &[Value::from(vec![])]);
4012        let mut volumes: Value = self.safe_list(ohlcvs, volume, &[Value::from(vec![])]);
4013        {
4014                        let mut i: Value = Value::Int(0);
4015            let mut __for_first_106: bool = true;
4016            while { if !__for_first_106 { i = (match (&(i), &(Value::Int(1))) { (Value::Int(x), Value::Int(y)) => Value::Int(x + y), (Value::Int(x), Value::Float(y)) => Value::Float(*x as f64 + *y), (Value::Float(x), Value::Int(y)) => Value::Float(*x + *y as f64), (Value::Float(x), Value::Float(y)) => Value::Float(x + y), _ => Value::Null }); } __for_first_106 = false; i.as_f64().unwrap_or(f64::NAN) < ((timestamps.len() as i64) as f64) } {
4017            append_to_array(&mut result, Value::from(vec![(if is_true(&ms) { self.safe_integer(timestamps.clone(), i.clone(), &[]) } else { 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(), &[])]));
4018        }
4019        }
4020        return result;
4021
4022    Value::Null
4023}
4024
4025    fn convert_ohlcv_to_trading_view(&self, mut ohlcvs: Value, optional_args: &[Value]) -> Value {
4026        let mut timestamp = get_arg(optional_args, 0, Value::Str("t".into()));
4027        let mut open = get_arg(optional_args, 1, Value::Str("o".into()));
4028        let mut high = get_arg(optional_args, 2, Value::Str("h".into()));
4029        let mut low = get_arg(optional_args, 3, Value::Str("l".into()));
4030        let mut close = get_arg(optional_args, 4, Value::Str("c".into()));
4031        let mut volume = get_arg(optional_args, 5, Value::Str("v".into()));
4032        let mut ms = get_arg(optional_args, 6, Value::Bool(false));
4033        let mut result: Value = Value::Map({
4034            let mut m = indexmap::IndexMap::new();
4035            m
4036        });
4037        if let Value::Dict(__d) = &mut result { std::sync::Arc::make_mut(__d).insert(crate::runtime::stringify_param(&timestamp), Value::from(vec![])); }
4038        if let Value::Dict(__d) = &mut result { std::sync::Arc::make_mut(__d).insert(crate::runtime::stringify_param(&open), Value::from(vec![])); }
4039        if let Value::Dict(__d) = &mut result { std::sync::Arc::make_mut(__d).insert(crate::runtime::stringify_param(&high), Value::from(vec![])); }
4040        if let Value::Dict(__d) = &mut result { std::sync::Arc::make_mut(__d).insert(crate::runtime::stringify_param(&low), Value::from(vec![])); }
4041        if let Value::Dict(__d) = &mut result { std::sync::Arc::make_mut(__d).insert(crate::runtime::stringify_param(&close), Value::from(vec![])); }
4042        if let Value::Dict(__d) = &mut result { std::sync::Arc::make_mut(__d).insert(crate::runtime::stringify_param(&volume), Value::from(vec![])); }
4043        {
4044                        let mut i: Value = Value::Int(0);
4045            let mut __for_first_107: bool = true;
4046            while { if !__for_first_107 { i = (match (&(i), &(Value::Int(1))) { (Value::Int(x), Value::Int(y)) => Value::Int(x + y), (Value::Int(x), Value::Float(y)) => Value::Float(*x as f64 + *y), (Value::Float(x), Value::Int(y)) => Value::Float(*x + *y as f64), (Value::Float(x), Value::Float(y)) => Value::Float(x + y), _ => Value::Null }); } __for_first_107 = false; i.as_f64().unwrap_or(f64::NAN) < ((ohlcvs.len() as i64) as f64) } {
4047            let mut ts: Value = (if is_true(&ms) { ohlcvs.as_array().and_then(|__arr| match &i { Value::Int(__n) => __arr.get(*__n as usize), Value::Str(__s) => __s.parse::<usize>().ok().and_then(|__n| __arr.get(__n)), _ => None }).cloned().unwrap_or(Value::Null).as_array().and_then(|__arr| __arr.get(0)).cloned().unwrap_or(Value::Null) } else { self.parse_to_int((match ((ohlcvs.as_array().and_then(|__arr| match &i { Value::Int(__n) => __arr.get(*__n as usize), Value::Str(__s) => __s.parse::<usize>().ok().and_then(|__n| __arr.get(__n)), _ => None }).cloned().unwrap_or(Value::Null).as_array().and_then(|__arr| __arr.get(0)).cloned().unwrap_or(Value::Null)).as_f64(), (Value::Int(1000)).as_f64()) { (Some(x), Some(y)) if y != 0.0 => Value::Float(x / y), _ => Value::Null })) });
4048            let mut resultTimestamp: Value = get_value(&result, &timestamp);
4049            append_to_array(&mut resultTimestamp, ts);
4050            crate::set_value(&mut result, &timestamp, resultTimestamp);
4051            let mut resultOpen: Value = get_value(&result, &open);
4052            append_to_array(&mut resultOpen, ohlcvs.as_array().and_then(|__arr| match &i { Value::Int(__n) => __arr.get(*__n as usize), Value::Str(__s) => __s.parse::<usize>().ok().and_then(|__n| __arr.get(__n)), _ => None }).cloned().unwrap_or(Value::Null).as_array().and_then(|__arr| __arr.get(1)).cloned().unwrap_or(Value::Null));
4053            crate::set_value(&mut result, &open, resultOpen);
4054            let mut resultHigh: Value = get_value(&result, &high);
4055            append_to_array(&mut resultHigh, ohlcvs.as_array().and_then(|__arr| match &i { Value::Int(__n) => __arr.get(*__n as usize), Value::Str(__s) => __s.parse::<usize>().ok().and_then(|__n| __arr.get(__n)), _ => None }).cloned().unwrap_or(Value::Null).as_array().and_then(|__arr| __arr.get(2)).cloned().unwrap_or(Value::Null));
4056            crate::set_value(&mut result, &high, resultHigh);
4057            let mut resultLow: Value = get_value(&result, &low);
4058            append_to_array(&mut resultLow, ohlcvs.as_array().and_then(|__arr| match &i { Value::Int(__n) => __arr.get(*__n as usize), Value::Str(__s) => __s.parse::<usize>().ok().and_then(|__n| __arr.get(__n)), _ => None }).cloned().unwrap_or(Value::Null).as_array().and_then(|__arr| __arr.get(3)).cloned().unwrap_or(Value::Null));
4059            crate::set_value(&mut result, &low, resultLow);
4060            let mut resultClose: Value = get_value(&result, &close);
4061            append_to_array(&mut resultClose, ohlcvs.as_array().and_then(|__arr| match &i { Value::Int(__n) => __arr.get(*__n as usize), Value::Str(__s) => __s.parse::<usize>().ok().and_then(|__n| __arr.get(__n)), _ => None }).cloned().unwrap_or(Value::Null).as_array().and_then(|__arr| __arr.get(4)).cloned().unwrap_or(Value::Null));
4062            crate::set_value(&mut result, &close, resultClose);
4063            let mut resultVolume: Value = get_value(&result, &volume);
4064            append_to_array(&mut resultVolume, ohlcvs.as_array().and_then(|__arr| match &i { Value::Int(__n) => __arr.get(*__n as usize), Value::Str(__s) => __s.parse::<usize>().ok().and_then(|__n| __arr.get(__n)), _ => None }).cloned().unwrap_or(Value::Null).as_array().and_then(|__arr| __arr.get(5)).cloned().unwrap_or(Value::Null));
4065            crate::set_value(&mut result, &volume, resultVolume);
4066        }
4067        }
4068        return result;
4069
4070    Value::Null
4071}
4072
4073    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 {
4074        let mut startRegex = get_arg(optional_args, 0, Value::Null);
4075        let mut endRegex = get_arg(optional_args, 1, Value::Null);
4076        let mut errorMessage: Value = Value::Str("".into());
4077        let mut options: Value = self.safe_value(self.options.clone(), method, &[Value::Map({
4078            let mut m = indexmap::IndexMap::new();
4079            m
4080        })]);
4081        let mut muteOnFailure: Value = self.safe_bool_k(options.clone(), "webApiMuteFailure", &[Value::Bool(true)]);
4082        {
4083            // if it was not explicitly disabled, then don't fetch
4084            if !matches!(self.safe_bool_k(options.clone(), "webApiEnable", &[Value::Bool(true)]), Value::Bool(true)) {
4085                return Value::Null;
4086            }
4087            let mut maxRetries: Value = self.safe_integer_k(options, "webApiRetries", &[Value::Int(10)]);
4088            let mut response: Value = Value::Null;
4089            let mut retry: f64 = ((0i64) as f64);
4090            let mut shouldBreak: bool = false;
4091            while retry < maxRetries.as_f64().unwrap_or(f64::NAN) {
4092                {
4093                    response = self.call_dynamic_checked(endpointMethod.clone(), vec![(Value::Map({
4094                        let mut m = indexmap::IndexMap::new();
4095                        m
4096                    })).clone()]).await;
4097                    shouldBreak = true;
4098                    break;
4099                }
4100                if shouldBreak {
4101                    break;
4102                }
4103            }
4104            let mut content: Value = response;
4105            if (content == Value::Null) {
4106                panic!("{}", crate::exchange_errors::null_response(format!("{}{}", self.id.clone(), Value::Str(" fetchWebEndpoint() returned empty content".into()))));
4107            }
4108            if (startRegex != Value::Null) {
4109                let mut splitted_by_start: Value = split(&content, &startRegex);
4110                content = get_value(&splitted_by_start, &Value::Int(1)); // we need second part after start
4111            }
4112            if (content == Value::Null) {
4113                panic!("{}", crate::exchange_errors::null_response(format!("{}{}", self.id.clone(), Value::Str(" fetchWebEndpoint() returned empty content".into()))));
4114            }
4115            if (endRegex != Value::Null) {
4116                let mut splitted_by_end: Value = split(&content, &endRegex);
4117                content = get_value(&splitted_by_end, &Value::Int(0)); // we need first part after start
4118            }
4119            if (is_equal(&returnAsJson, &Value::Bool(true))) && (matches!(&content, Value::Str(_))) {
4120                let mut jsoned: Value = self.parse_json_value(trim(&content)); // content should be trimmed before json parsing
4121                if (jsoned != Value::Null) && (jsoned != Value::Null) {
4122                    return jsoned;
4123                }  else {
4124                    panic!("{}", crate::exchange_errors::bad_response("could not parse the response into json"));
4125                }
4126            }  else {
4127                return content;
4128            }
4129        }
4130        if (muteOnFailure.as_bool() == Some(true)) {
4131            return Value::Null;
4132        }  else {
4133            panic!("{}", crate::exchange_errors::bad_response(errorMessage));
4134        }
4135} }
4136
4137    fn market_ids(&self, optional_args: &[Value]) -> Value {
4138        let mut symbols = get_arg(optional_args, 0, Value::Null);
4139        /*
4140         * @param {string[]|undefined} symbols list of unified symbols
4141         * @returns {string[]|undefined} list of exchange-specific market ids
4142         * Overloads: non-null `string[]` input yields `string[]`; optional input yields `Strings`.
4143         */
4144        if (symbols == Value::Null) {
4145            return symbols;
4146        }
4147        let mut result: Value = Value::from(vec![]);
4148        {
4149                        let mut i: Value = Value::Int(0);
4150            let mut __for_first_108: bool = true;
4151            while { if !__for_first_108 { i = (match (&(i), &(Value::Int(1))) { (Value::Int(x), Value::Int(y)) => Value::Int(x + y), (Value::Int(x), Value::Float(y)) => Value::Float(*x as f64 + *y), (Value::Float(x), Value::Int(y)) => Value::Float(*x + *y as f64), (Value::Float(x), Value::Float(y)) => Value::Float(x + y), _ => Value::Null }); } __for_first_108 = false; i.as_f64().unwrap_or(f64::NAN) < ((symbols.len() as i64) as f64) } {
4152            let mut id: Value = self.market_id(symbols.as_array().and_then(|__arr| match &i { Value::Int(__n) => __arr.get(*__n as usize), Value::Str(__s) => __s.parse::<usize>().ok().and_then(|__n| __arr.get(__n)), _ => None }).cloned().unwrap_or(Value::Null));
4153            if (id != Value::Null) {
4154                append_to_array(&mut result, id);
4155            }
4156        }
4157        }
4158        return result;
4159
4160    Value::Null
4161}
4162
4163    fn currency_ids(&self, optional_args: &[Value]) -> Value {
4164        let mut codes = get_arg(optional_args, 0, Value::Null);
4165        if (codes == Value::Null) {
4166            return codes;
4167        }
4168        let mut result: Value = Value::from(vec![]);
4169        {
4170                        let mut i: Value = Value::Int(0);
4171            let mut __for_first_109: bool = true;
4172            while { if !__for_first_109 { i = (match (&(i), &(Value::Int(1))) { (Value::Int(x), Value::Int(y)) => Value::Int(x + y), (Value::Int(x), Value::Float(y)) => Value::Float(*x as f64 + *y), (Value::Float(x), Value::Int(y)) => Value::Float(*x + *y as f64), (Value::Float(x), Value::Float(y)) => Value::Float(x + y), _ => Value::Null }); } __for_first_109 = false; i.as_f64().unwrap_or(f64::NAN) < ((codes.len() as i64) as f64) } {
4173            let mut id: Value = self.currency_id(codes.as_array().and_then(|__arr| match &i { Value::Int(__n) => __arr.get(*__n as usize), Value::Str(__s) => __s.parse::<usize>().ok().and_then(|__n| __arr.get(__n)), _ => None }).cloned().unwrap_or(Value::Null));
4174            if (id != Value::Null) {
4175                append_to_array(&mut result, id);
4176            }
4177        }
4178        }
4179        return result;
4180
4181    Value::Null
4182}
4183
4184    fn markets_for_symbols(&self, optional_args: &[Value]) -> Value {
4185        let mut symbols = get_arg(optional_args, 0, Value::Null);
4186        if (symbols == Value::Null) {
4187            return Value::Null;
4188        }
4189        let mut result: Value = Value::from(vec![]);
4190        {
4191                        let mut i: Value = Value::Int(0);
4192            let mut __for_first_110: bool = true;
4193            while { if !__for_first_110 { i = (match (&(i), &(Value::Int(1))) { (Value::Int(x), Value::Int(y)) => Value::Int(x + y), (Value::Int(x), Value::Float(y)) => Value::Float(*x as f64 + *y), (Value::Float(x), Value::Int(y)) => Value::Float(*x + *y as f64), (Value::Float(x), Value::Float(y)) => Value::Float(x + y), _ => Value::Null }); } __for_first_110 = false; i.as_f64().unwrap_or(f64::NAN) < ((symbols.len() as i64) as f64) } {
4194            append_to_array(&mut result, <Self as crate::exchange_generated::ExchangeBase>::market(self, symbols.as_array().and_then(|__arr| match &i { Value::Int(__n) => __arr.get(*__n as usize), Value::Str(__s) => __s.parse::<usize>().ok().and_then(|__n| __arr.get(__n)), _ => None }).cloned().unwrap_or(Value::Null)));
4195        }
4196        }
4197        return result;
4198
4199    Value::Null
4200}
4201
4202// allowEmpty: false always returns string[] (throws on empty/undefined at runtime)
4203    fn market_symbols(&self, optional_args: &[Value]) -> Value {
4204        let mut symbols = get_arg(optional_args, 0, Value::Null);
4205        let mut type_var = get_arg(optional_args, 1, Value::Null);
4206        let mut allowEmpty = get_arg(optional_args, 2, Value::Bool(true));
4207        let mut sameTypeOnly = get_arg(optional_args, 3, Value::Bool(false));
4208        let mut sameSubTypeOnly = get_arg(optional_args, 4, Value::Bool(false));
4209        /*
4210         * @param {string[]|undefined} symbols list of unified symbols
4211         * @param {string|undefined} type filter by market type
4212         * @param {boolean} allowEmpty whether empty/undefined symbols is allowed
4213         * @param {boolean} sameTypeOnly require all markets to share type
4214         * @param {boolean} sameSubTypeOnly require all markets to share linear/inverse subType
4215         * @returns {string[]|undefined} validated unified symbols
4216         * Overloads: `allowEmpty: false` or non-null `string[]` input yields `string[]`; permissive form yields `Strings`.
4217         */
4218        if (symbols == Value::Null) {
4219            if !is_true(&allowEmpty) {
4220                panic!("{}", crate::exchange_errors::arguments_required(format!("{}{}", self.id.clone(), Value::Str(" empty list of symbols is not supported".into()))));
4221            }
4222            return symbols;
4223        }
4224        let mut symbolsLength: f64 = ((symbols.len() as i64) as f64);
4225        if (symbolsLength == 0.0) {
4226            if !is_true(&allowEmpty) {
4227                panic!("{}", crate::exchange_errors::arguments_required(format!("{}{}", self.id.clone(), Value::Str(" empty list of symbols is not supported".into()))));
4228            }
4229            return symbols;
4230        }
4231        let mut result: Value = Value::from(vec![]);
4232        let mut marketType: Value = Value::Null;
4233        let mut isLinearSubType: Value = Value::Null;
4234        {
4235                        let mut i: Value = Value::Int(0);
4236            let mut __for_first_111: bool = true;
4237            while { if !__for_first_111 { i = (match (&(i), &(Value::Int(1))) { (Value::Int(x), Value::Int(y)) => Value::Int(x + y), (Value::Int(x), Value::Float(y)) => Value::Float(*x as f64 + *y), (Value::Float(x), Value::Int(y)) => Value::Float(*x + *y as f64), (Value::Float(x), Value::Float(y)) => Value::Float(x + y), _ => Value::Null }); } __for_first_111 = false; i.as_f64().unwrap_or(f64::NAN) < ((symbols.len() as i64) as f64) } {
4238            let mut market: Value = <Self as crate::exchange_generated::ExchangeBase>::market(self, symbols.as_array().and_then(|__arr| match &i { Value::Int(__n) => __arr.get(*__n as usize), Value::Str(__s) => __s.parse::<usize>().ok().and_then(|__n| __arr.get(__n)), _ => None }).cloned().unwrap_or(Value::Null));
4239            if is_true(&sameTypeOnly) && (marketType != Value::Null) {
4240                if (market.as_map().and_then(|__m| __m.get("type")).cloned().unwrap_or(Value::Null).as_str() != marketType.as_str()) {
4241                    panic!("{}", crate::exchange_errors::bad_request(format!("{}{}", Value::Str(format!("{}{}", Value::Str(format!("{}{}", Value::Str(format!("{}{}", Value::Str(format!("{}{}", self.id.clone(), Value::Str(" symbols must be of the same type, either ".into())).into()), marketType).into()), Value::Str(" or ".into())).into()), market.as_map().and_then(|__m| __m.get("type")).cloned().unwrap_or(Value::Null)).into()), Value::Str(".".into()))));
4242                }
4243            }
4244            if is_true(&sameSubTypeOnly) && (isLinearSubType != Value::Null) {
4245                if (market.as_map().and_then(|__m| __m.get("linear")).cloned().unwrap_or(Value::Null).as_bool() != isLinearSubType.as_bool()) {
4246                    panic!("{}", crate::exchange_errors::bad_request(format!("{}{}", self.id.clone(), Value::Str(" symbols must be of the same subType, either linear or inverse.".into()))));
4247                }
4248            }
4249            if (type_var != Value::Null) && (market.as_map().and_then(|__m| __m.get("type")).cloned().unwrap_or(Value::Null).as_str() != type_var.as_str()) {
4250                panic!("{}", crate::exchange_errors::bad_request(format!("{}{}", Value::Str(format!("{}{}", Value::Str(format!("{}{}", self.id.clone(), Value::Str(" symbols must be of the same type ".into())).into()), type_var).into()), Value::Str(". If the type is incorrect you can change it in options or the params of the request".into()))));
4251            }
4252            marketType = self.safe_string_k(market.clone(), "type", &[]);
4253            if (market.as_map().and_then(|__m| __m.get("spot")).cloned().unwrap_or(Value::Null).as_bool() != Some(true)) {
4254                isLinearSubType = self.safe_bool_k(market.clone(), "linear", &[]);
4255            }
4256            let mut symbol: Value = self.safe_string_k(market, "symbol", &[symbols.as_array().and_then(|__arr| match &i { Value::Int(__n) => __arr.get(*__n as usize), Value::Str(__s) => __s.parse::<usize>().ok().and_then(|__n| __arr.get(__n)), _ => None }).cloned().unwrap_or(Value::Null)]);
4257            append_to_array(&mut result, symbol);
4258        }
4259        }
4260        return result;
4261
4262    Value::Null
4263}
4264
4265    fn market_codes(&self, optional_args: &[Value]) -> Value {
4266        let mut codes = get_arg(optional_args, 0, Value::Null);
4267        if (codes == Value::Null) {
4268            return codes;
4269        }
4270        let mut result: Value = Value::from(vec![]);
4271        {
4272                        let mut i: Value = Value::Int(0);
4273            let mut __for_first_112: bool = true;
4274            while { if !__for_first_112 { i = (match (&(i), &(Value::Int(1))) { (Value::Int(x), Value::Int(y)) => Value::Int(x + y), (Value::Int(x), Value::Float(y)) => Value::Float(*x as f64 + *y), (Value::Float(x), Value::Int(y)) => Value::Float(*x + *y as f64), (Value::Float(x), Value::Float(y)) => Value::Float(x + y), _ => Value::Null }); } __for_first_112 = false; i.as_f64().unwrap_or(f64::NAN) < ((codes.len() as i64) as f64) } {
4275            append_to_array(&mut result, self.common_currency_code(codes.as_array().and_then(|__arr| match &i { Value::Int(__n) => __arr.get(*__n as usize), Value::Str(__s) => __s.parse::<usize>().ok().and_then(|__n| __arr.get(__n)), _ => None }).cloned().unwrap_or(Value::Null)));
4276        }
4277        }
4278        return result;
4279
4280    Value::Null
4281}
4282
4283    fn parse_order_book_bids_asks(&self, mut bidasks: Value, optional_args: &[Value]) -> Value {
4284        let mut priceKey = get_arg(optional_args, 0, Value::Int(0));
4285        let mut amountKey = get_arg(optional_args, 1, Value::Int(1));
4286        let mut countOrIdKey = get_arg(optional_args, 2, Value::Int(2));
4287        let mut bidasksValue: Value = self.to_array(bidasks);
4288        let mut result: Value = Value::from(vec![]);
4289        {
4290                        let mut i: Value = Value::Int(0);
4291            let mut __for_first_113: bool = true;
4292            while { if !__for_first_113 { i = (match (&(i), &(Value::Int(1))) { (Value::Int(x), Value::Int(y)) => Value::Int(x + y), (Value::Int(x), Value::Float(y)) => Value::Float(*x as f64 + *y), (Value::Float(x), Value::Int(y)) => Value::Float(*x + *y as f64), (Value::Float(x), Value::Float(y)) => Value::Float(x + y), _ => Value::Null }); } __for_first_113 = false; i.as_f64().unwrap_or(f64::NAN) < get_array_length(&bidasksValue).as_f64().unwrap_or(f64::NAN) } {
4293            append_to_array(&mut result, self.parse_order_book_bid_ask(get_value(&bidasksValue, &i), &[priceKey.clone(), amountKey.clone(), countOrIdKey.clone()]));
4294        }
4295        }
4296        return result;
4297
4298    Value::Null
4299}
4300
4301    fn parse_order_book_bids_asks_l3(&self, mut bidasks: Value, optional_args: &[Value]) -> Value {
4302        let mut priceKey = get_arg(optional_args, 0, Value::Int(0));
4303        let mut amountKey = get_arg(optional_args, 1, Value::Int(1));
4304        let mut countOrIdKey = get_arg(optional_args, 2, Value::Int(2));
4305        let mut bidasksValue: Value = self.to_array(bidasks);
4306        let mut result: Value = Value::from(vec![]);
4307        {
4308                        let mut i: Value = Value::Int(0);
4309            let mut __for_first_114: bool = true;
4310            while { if !__for_first_114 { i = (match (&(i), &(Value::Int(1))) { (Value::Int(x), Value::Int(y)) => Value::Int(x + y), (Value::Int(x), Value::Float(y)) => Value::Float(*x as f64 + *y), (Value::Float(x), Value::Int(y)) => Value::Float(*x + *y as f64), (Value::Float(x), Value::Float(y)) => Value::Float(x + y), _ => Value::Null }); } __for_first_114 = false; i.as_f64().unwrap_or(f64::NAN) < get_array_length(&bidasksValue).as_f64().unwrap_or(f64::NAN) } {
4311            append_to_array(&mut result, self.parse_order_book_bid_ask_l3(get_value(&bidasksValue, &i), &[priceKey.clone(), amountKey.clone(), countOrIdKey.clone()]));
4312        }
4313        }
4314        return result;
4315
4316    Value::Null
4317}
4318
4319    fn filter_by_key(&self, mut objects: Value, mut key: Value, optional_args: &[Value]) -> Value {
4320        let mut value = get_arg(optional_args, 0, Value::Null);
4321        if (value == Value::Null) {
4322            return objects;
4323        }
4324        let mut result: Value = Value::from(vec![]);
4325        {
4326                        let mut i: Value = Value::Int(0);
4327            let mut __for_first_115: bool = true;
4328            while { if !__for_first_115 { i = (match (&(i), &(Value::Int(1))) { (Value::Int(x), Value::Int(y)) => Value::Int(x + y), (Value::Int(x), Value::Float(y)) => Value::Float(*x as f64 + *y), (Value::Float(x), Value::Int(y)) => Value::Float(*x + *y as f64), (Value::Float(x), Value::Float(y)) => Value::Float(x + y), _ => Value::Null }); } __for_first_115 = false; i.as_f64().unwrap_or(f64::NAN) < get_array_length(&objects).as_f64().unwrap_or(f64::NAN) } {
4329            let mut objectValue: Value = self.safe_string(get_value(&objects, &i), key.clone(), &[]);
4330            if (objectValue.as_str() == value.as_str()) {
4331                append_to_array(&mut result, get_value(&objects, &i));
4332            }
4333        }
4334        }
4335        return result;
4336
4337    Value::Null
4338}
4339
4340    fn filter_by_symbol(&self, mut objects: Value, optional_args: &[Value]) -> Value {
4341        let mut symbol = get_arg(optional_args, 0, Value::Null);
4342        return self.filter_by_key(objects, Value::Str("symbol".into()), &[symbol]);
4343
4344    Value::Null
4345}
4346
4347    fn parse_ohlcv(&self, mut ohlcv: Value, optional_args: &[Value]) -> Value {
4348        // virtual-dispatch (static: DerivedExchange::parse_ohlcv(self, ...))
4349        { 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; } }
4350
4351        let mut market = get_arg(optional_args, 0, Value::Null);
4352        if (matches!(&ohlcv, Value::Arr(_))) {
4353            return Value::from(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), &[])]);
4354        }
4355        return ohlcv;
4356
4357    Value::Null
4358}
4359
4360    fn safe_network(&self, mut network: Value) -> Value {
4361        let mut withdrawEnabled: Value = self.safe_bool_k(network.clone(), "withdraw", &[]);
4362        let mut depositEnabled: Value = self.safe_bool_k(network.clone(), "deposit", &[]);
4363        let mut limits: Value = self.safe_dict_k(network.clone(), "limits", &[]);
4364        let mut withdraw: Value = self.safe_dict_k(limits.clone(), "withdraw", &[]);
4365        let mut deposit: Value = self.safe_dict_k(limits, "deposit", &[]);
4366        let mut isEnabled: Value = withdrawEnabled.clone();
4367        if (withdrawEnabled.as_bool() == Some(true)) {
4368            isEnabled = depositEnabled.clone();
4369        }
4370        return Value::Map({
4371    let mut m = indexmap::IndexMap::new();
4372        m.insert("info".to_string(), crate::value::get_value_k(&network, "info"));
4373        m.insert("id".to_string(), self.safe_string_k(network.clone(), "id", &[]));
4374        m.insert("name".to_string(), self.safe_string_k(network.clone(), "name", &[]));
4375        m.insert("network".to_string(), self.safe_string_k(network.clone(), "network", &[]));
4376        m.insert("active".to_string(), self.safe_bool_k(network.clone(), "active", &[isEnabled]));
4377        m.insert("deposit".to_string(), depositEnabled);
4378        m.insert("withdraw".to_string(), withdrawEnabled);
4379        m.insert("fee".to_string(), self.safe_number_k(network.clone(), "fee", &[]));
4380        m.insert("precision".to_string(), self.safe_number_k(network, "precision", &[]));
4381        m.insert("limits".to_string(), Value::Map({
4382    let mut m = indexmap::IndexMap::new();
4383        m.insert("withdraw".to_string(), Value::Map({
4384    let mut m = indexmap::IndexMap::new();
4385        m.insert("min".to_string(), self.safe_number_k(withdraw.clone(), "min", &[]));
4386        m.insert("max".to_string(), self.safe_number_k(withdraw, "max", &[]));
4387    m
4388}));
4389        m.insert("deposit".to_string(), Value::Map({
4390    let mut m = indexmap::IndexMap::new();
4391        m.insert("min".to_string(), self.safe_number_k(deposit.clone(), "min", &[]));
4392        m.insert("max".to_string(), self.safe_number_k(deposit, "max", &[]));
4393    m
4394}));
4395    m
4396}));
4397    m
4398});
4399
4400    Value::Null
4401}
4402
4403    fn network_code_to_id(&self, mut networkCode: Value, optional_args: &[Value]) -> Value {
4404        let mut currencyCode = get_arg(optional_args, 0, Value::Null);
4405        /*
4406         * @ignore
4407         * @method
4408         * @name exchange#networkCodeToId
4409         * @description tries to convert the provided networkCode (a unified network code or one of its aliases) to a network id. In order to achieve this, derived class needs to have 'options->networks' defined.
4410         * @param {string} networkCode unified network code
4411         * @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
4412         * @returns {string|undefined} exchange-specific network id
4413         */
4414        if (networkCode == Value::Null) {
4415            return Value::Null;
4416        }
4417        let mut unifiedCode: Value = self.safe_string(self.networkAliases.clone(), networkCode.clone(), &[networkCode.clone()]);
4418        let mut networkIdsByCodes: Value = self.safe_dict_k(self.options.clone(), "networks", &[Value::Map({
4419    let mut m = indexmap::IndexMap::new();
4420    m
4421})]);
4422        let mut networkId: Value = self.safe_string(networkIdsByCodes.clone(), unifiedCode.clone(), &[]);
4423        if (networkId != Value::Null) {
4424            return networkId;
4425        }
4426        // options.networks may still be keyed by an alias of the unified code
4427        let mut aliases: Value = self.networkAliases.clone();
4428        let mut aliasKeys: Value = object_keys(&aliases);
4429        {
4430                        let mut i: Value = Value::Int(0);
4431            let mut __for_first_116: bool = true;
4432            while { if !__for_first_116 { i = (match (&(i), &(Value::Int(1))) { (Value::Int(x), Value::Int(y)) => Value::Int(x + y), (Value::Int(x), Value::Float(y)) => Value::Float(*x as f64 + *y), (Value::Float(x), Value::Int(y)) => Value::Float(*x + *y as f64), (Value::Float(x), Value::Float(y)) => Value::Float(x + y), _ => Value::Null }); } __for_first_116 = false; i.as_f64().unwrap_or(f64::NAN) < ((aliasKeys.len() as i64) as f64) } {
4433            let mut alias: Value = aliasKeys.as_array().and_then(|__arr| match &i { Value::Int(__n) => __arr.get(*__n as usize), Value::Str(__s) => __s.parse::<usize>().ok().and_then(|__n| __arr.get(__n)), _ => None }).cloned().unwrap_or(Value::Null);
4434            if (aliases.as_map().and_then(|__m| alias.as_str().and_then(|__k| __m.get(__k))).cloned().unwrap_or(Value::Null).as_str() == unifiedCode.as_str()) && (in_op(&networkIdsByCodes, &alias)) {
4435                return networkIdsByCodes.as_map().and_then(|__m| alias.as_str().and_then(|__k| __m.get(__k))).cloned().unwrap_or(Value::Null);
4436            }
4437        }
4438        }
4439        // fall back to scanning loaded currencies
4440        let mut currenciesToCheck: Value = Value::from(vec![]);
4441        if (currencyCode == Value::Null) {
4442            currenciesToCheck = object_keys(&self.currencies);
4443        }  else {
4444            currenciesToCheck = Value::from(vec![self.safe_dict(self.currencies.clone(), currencyCode, &[])]);
4445        }
4446        {
4447                        let mut i: Value = Value::Int(0);
4448            let mut __for_first_117: bool = true;
4449            while { if !__for_first_117 { i = (match (&(i), &(Value::Int(1))) { (Value::Int(x), Value::Int(y)) => Value::Int(x + y), (Value::Int(x), Value::Float(y)) => Value::Float(*x as f64 + *y), (Value::Float(x), Value::Int(y)) => Value::Float(*x + *y as f64), (Value::Float(x), Value::Float(y)) => Value::Float(x + y), _ => Value::Null }); } __for_first_117 = false; i.as_f64().unwrap_or(f64::NAN) < ((currenciesToCheck.len() as i64) as f64) } {
4450            let mut networks: Value = self.safe_dict(currenciesToCheck.as_array().and_then(|__arr| match &i { Value::Int(__n) => __arr.get(*__n as usize), Value::Str(__s) => __s.parse::<usize>().ok().and_then(|__n| __arr.get(__n)), _ => None }).cloned().unwrap_or(Value::Null), Value::Str("networks".into()), &[Value::Map({
4451    let mut m = indexmap::IndexMap::new();
4452    m
4453})]);
4454            if (in_op(&networks, &unifiedCode)) {
4455                return self.safe_string(networks.as_map().and_then(|__m| unifiedCode.as_str().and_then(|__k| __m.get(__k))).cloned().unwrap_or(Value::Null), Value::Str("id".into()), &[]);
4456            }
4457        }
4458        }
4459        return networkCode;
4460
4461    Value::Null
4462}
4463
4464    fn network_id_to_code(&self, optional_args: &[Value]) -> Value {
4465        let mut networkId = get_arg(optional_args, 0, Value::Null);
4466        let mut currencyCode = get_arg(optional_args, 1, Value::Null);
4467        /*
4468         * @ignore
4469         * @method
4470         * @name exchange#networkIdToCode
4471         * @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.
4472         * @param {string} networkId exchange specific network id/title, like: TRON, Trc-20, usdt-erc20, etc
4473         * @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
4474         * @returns {string|undefined} unified network code
4475         */
4476        if (networkId == Value::Null) {
4477            return Value::Null;
4478        }
4479        let mut networkCodesByIds: Value = self.safe_dict_k(self.options.clone(), "networksById", &[Value::Map({
4480    let mut m = indexmap::IndexMap::new();
4481    m
4482})]);
4483        let mut mappedCode: Value = self.safe_string(networkCodesByIds, networkId.clone(), &[]);
4484        let mut networkCode: Value = (if (mappedCode == Value::Null) { networkId } else { mappedCode });
4485        return self.safe_string(self.networkAliases.clone(), networkCode.clone(), &[networkCode.clone()]);
4486
4487    Value::Null
4488}
4489
4490    fn handle_network_code_and_params(&self, mut params: Value) -> Value {
4491        let mut networkCodeInParams: Value = self.safe_string2(params.clone(), Value::Str("networkCode".into()), Value::Str("network".into()), &[]);
4492        let mut paramsOmitted: Value = (if (networkCodeInParams != Value::Null) { self.omit(params.clone(), Value::from(vec![Value::Str("networkCode".into()), Value::Str("network".into())]), &[]) } else { params });
4493        return Value::from(vec![networkCodeInParams, paramsOmitted]);
4494
4495    Value::Null
4496}
4497
4498    fn select_network_key_from_networks(&self, mut currencyCode: Value, mut networkCode: Value, mut indexedNetworkEntries: Value, optional_args: &[Value]) -> Value {
4499        let mut isIndexedByUnifiedNetworkCode = get_arg(optional_args, 0, Value::Bool(false));
4500        // this method is used against raw & unparse network entries, which are just indexed by network id
4501        let mut chosenNetworkId: Value = Value::Null;
4502        let mut availableNetworkIds: Value = object_keys(&indexedNetworkEntries);
4503        let mut responseNetworksLength: f64 = ((availableNetworkIds.len() as i64) as f64);
4504        if (networkCode != Value::Null) {
4505            if (responseNetworksLength == 0.0) {
4506                panic!("{}", crate::exchange_errors::not_supported(format!("{}{}", Value::Str(format!("{}{}", Value::Str(format!("{}{}", Value::Str(format!("{}{}", self.id.clone(), Value::Str(" - ".into())).into()), networkCode).into()), Value::Str(" network did not return any result for ".into())).into()), currencyCode)));
4507            }  else {
4508                // if networkCode was provided by user, we should check it after response, as the referenced exchange doesn't support network-code during request
4509                let mut networkIdOrCode: Value = (if is_true(&isIndexedByUnifiedNetworkCode) { networkCode.clone() } else { self.network_code_to_id(networkCode.clone(), &[currencyCode.clone()]) });
4510                if (networkIdOrCode == Value::Null) {
4511                    panic!("{}", crate::exchange_errors::not_supported(format!("{}{}", Value::Str(format!("{}{}", Value::Str(format!("{}{}", Value::Str(format!("{}{}", self.id.clone(), Value::Str(" - ".into())).into()), networkCode).into()), Value::Str(" network was not found for ".into())).into()), currencyCode)));
4512                }
4513                if (in_op(&indexedNetworkEntries, &networkIdOrCode)) {
4514                    chosenNetworkId = networkIdOrCode.clone();
4515                }  else {
4516                    panic!("{}", crate::exchange_errors::not_supported(format!("{}{}", Value::Str(format!("{}{}", Value::Str(format!("{}{}", Value::Str(format!("{}{}", Value::Str(format!("{}{}", Value::Str(format!("{}{}", self.id.clone(), Value::Str(" - ".into())).into()), networkIdOrCode).into()), Value::Str(" network was not found for ".into())).into()), currencyCode).into()), Value::Str(", use one of ".into())).into()), join(&availableNetworkIds, &Value::Str(", ".into())))));
4517                }
4518            }
4519        }  else {
4520            if (responseNetworksLength == 0.0) {
4521                panic!("{}", crate::exchange_errors::not_supported(format!("{}{}", Value::Str(format!("{}{}", self.id.clone(), Value::Str(" - no networks were returned for ".into())).into()), currencyCode)));
4522            }  else {
4523                // 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
4524                let mut defaultNetworkCode: Value = self.safe_string(self.safe_dict_k(self.options.clone(), "defaultNetworks", &[Value::Map({
4525    let mut m = indexmap::IndexMap::new();
4526    m
4527})]), currencyCode.clone(), &[self.safe_string_k(self.options.clone(), "defaultNetwork", &[])]);
4528                let mut defaultNetworkId: Value = (if is_true(&isIndexedByUnifiedNetworkCode) { defaultNetworkCode.clone() } else { self.network_code_to_id(defaultNetworkCode, &[currencyCode]) });
4529                if (defaultNetworkId == Value::Null) {
4530                    panic!("{}", crate::exchange_errors::exchange_error(format!("{}{}", self.id.clone(), Value::Str(" selectNetworkKeyFromNetworks() missing defaultNetworkId".into()))));
4531                }
4532                if (in_op(&indexedNetworkEntries, &defaultNetworkId)) {
4533                    return defaultNetworkId;
4534                }
4535                panic!("{}", crate::exchange_errors::not_supported(format!("{}{}", Value::Str(format!("{}{}", self.id.clone(), Value::Str(" - can not determine the default network, please pass param[\"network\"] one from : ".into())).into()), join(&availableNetworkIds, &Value::Str(", ".into())))));
4536            }
4537        }
4538        return chosenNetworkId;
4539
4540    Value::Null
4541}
4542
4543    fn safe_number2(&self, mut dictionary: Value, mut key1: Value, mut key2: Value, optional_args: &[Value]) -> Value {
4544        let mut d = get_arg(optional_args, 0, Value::Null);
4545        let mut value: Value = self.safe_string2(dictionary, key1, key2, &[]);
4546        return self.parse_number(value, &[d]);
4547
4548    Value::Null
4549}
4550
4551    fn parse_order_book(&self, mut orderbook: Value, mut symbol: Value, optional_args: &[Value]) -> Value {
4552        // virtual-dispatch (static: DerivedExchange::parse_order_book(self, ...))
4553        { 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; } }
4554
4555        let mut timestamp = get_arg(optional_args, 0, Value::Null);
4556        let mut bidsKey = get_arg(optional_args, 1, Value::Str("bids".into()));
4557        let mut asksKey = get_arg(optional_args, 2, Value::Str("asks".into()));
4558        let mut priceKey = get_arg(optional_args, 3, Value::Int(0));
4559        let mut amountKey = get_arg(optional_args, 4, Value::Int(1));
4560        let mut countOrIdKey = get_arg(optional_args, 5, Value::Int(2));
4561        let mut bids: Value = self.parse_order_book_bids_asks(self.safe_value(orderbook.clone(), bidsKey, &[Value::from(vec![])]), &[priceKey.clone(), amountKey.clone(), countOrIdKey.clone()]);
4562        let mut asks: Value = self.parse_order_book_bids_asks(self.safe_value(orderbook, asksKey, &[Value::from(vec![])]), &[priceKey, amountKey, countOrIdKey]);
4563        return Value::Map({
4564    let mut m = indexmap::IndexMap::new();
4565        m.insert("symbol".to_string(), symbol);
4566        m.insert("bids".to_string(), self.sort_by(bids, Value::Int(0), &[Value::Bool(true)]));
4567        m.insert("asks".to_string(), self.sort_by(asks, Value::Int(0), &[]));
4568        m.insert("timestamp".to_string(), timestamp.clone());
4569        m.insert("datetime".to_string(), self.iso8601(timestamp));
4570        m.insert("nonce".to_string(), Value::Null);
4571    m
4572});
4573
4574    Value::Null
4575}
4576
4577    fn parse_order_book_l3(&self, mut orderbook: Value, mut symbol: Value, optional_args: &[Value]) -> Value {
4578        let mut timestamp = get_arg(optional_args, 0, Value::Null);
4579        let mut bidsKey = get_arg(optional_args, 1, Value::Str("bids".into()));
4580        let mut asksKey = get_arg(optional_args, 2, Value::Str("asks".into()));
4581        let mut priceKey = get_arg(optional_args, 3, Value::Int(0));
4582        let mut amountKey = get_arg(optional_args, 4, Value::Int(1));
4583        let mut countOrIdKey = get_arg(optional_args, 5, Value::Int(2));
4584        let mut bids: Value = self.parse_order_book_bids_asks_l3(self.safe_value(orderbook.clone(), bidsKey, &[Value::from(vec![])]), &[priceKey.clone(), amountKey.clone(), countOrIdKey.clone()]);
4585        let mut asks: Value = self.parse_order_book_bids_asks_l3(self.safe_value(orderbook, asksKey, &[Value::from(vec![])]), &[priceKey, amountKey, countOrIdKey]);
4586        return Value::Map({
4587    let mut m = indexmap::IndexMap::new();
4588        m.insert("symbol".to_string(), symbol);
4589        m.insert("bids".to_string(), self.sort_by(bids, Value::Int(0), &[Value::Bool(true)]));
4590        m.insert("asks".to_string(), self.sort_by(asks, Value::Int(0), &[]));
4591        m.insert("timestamp".to_string(), timestamp.clone());
4592        m.insert("datetime".to_string(), self.iso8601(timestamp));
4593        m.insert("nonce".to_string(), Value::Null);
4594    m
4595});
4596
4597    Value::Null
4598}
4599
4600    fn parse_ohlc_vs(&self, mut ohlcvs: Value, optional_args: &[Value]) -> Value {
4601        let mut market = get_arg(optional_args, 0, Value::Null);
4602        let mut timeframe = get_arg(optional_args, 1, Value::Str("1m".into()));
4603        let mut since = get_arg(optional_args, 2, Value::Null);
4604        let mut limit = get_arg(optional_args, 3, Value::Null);
4605        let mut tail = get_arg(optional_args, 4, Value::Bool(false));
4606        if (ohlcvs == Value::Null) {
4607            return Value::from(vec![]);
4608        }
4609        let mut results: Value = Value::from(vec![]);
4610        {
4611                        let mut i: Value = Value::Int(0);
4612            let mut __for_first_118: bool = true;
4613            while { if !__for_first_118 { i = (match (&(i), &(Value::Int(1))) { (Value::Int(x), Value::Int(y)) => Value::Int(x + y), (Value::Int(x), Value::Float(y)) => Value::Float(*x as f64 + *y), (Value::Float(x), Value::Int(y)) => Value::Float(*x + *y as f64), (Value::Float(x), Value::Float(y)) => Value::Float(x + y), _ => Value::Null }); } __for_first_118 = false; i.as_f64().unwrap_or(f64::NAN) < ((ohlcvs.len() as i64) as f64) } {
4614            append_to_array(&mut results, <Self as crate::exchange_generated::ExchangeBase>::parse_ohlcv(self, ohlcvs.as_array().and_then(|__arr| match &i { Value::Int(__n) => __arr.get(*__n as usize), Value::Str(__s) => __s.parse::<usize>().ok().and_then(|__n| __arr.get(__n)), _ => None }).cloned().unwrap_or(Value::Null), &[market.clone()]));
4615        }
4616        }
4617        let mut sorted: Value = self.sort_by(results, Value::Int(0), &[]);
4618        return self.filter_by_since_limit(sorted, &[since, limit, Value::Int(0), tail]);
4619
4620    Value::Null
4621}
4622
4623    fn parse_leverage_tiers(&self, mut response: Value, optional_args: &[Value]) -> Value {
4624        let mut symbols = get_arg(optional_args, 0, Value::Null);
4625        let mut marketIdKey = get_arg(optional_args, 1, Value::Null);
4626        // marketIdKey should only be undefined when response is a dictionary.
4627        let mut symbolsNormalized: Value = self.market_symbols(&[symbols]);
4628        let mut tiers: Value = Value::Map({
4629            let mut m = indexmap::IndexMap::new();
4630            m
4631        });
4632        let mut symbolsLength: Value = Value::Int(0);
4633        if (symbolsNormalized != Value::Null) {
4634            symbolsLength = Value::Int(symbolsNormalized.len() as i64);
4635        }
4636        let mut noSymbols: bool = (symbolsNormalized == Value::Null) || (symbolsLength.as_f64() == Some(0.0));
4637        if (matches!(&response, Value::Arr(_))) {
4638            {
4639                                let mut i: Value = Value::Int(0);
4640                let mut __for_first_119: bool = true;
4641                while { if !__for_first_119 { i = (match (&(i), &(Value::Int(1))) { (Value::Int(x), Value::Int(y)) => Value::Int(x + y), (Value::Int(x), Value::Float(y)) => Value::Float(*x as f64 + *y), (Value::Float(x), Value::Int(y)) => Value::Float(*x + *y as f64), (Value::Float(x), Value::Float(y)) => Value::Float(x + y), _ => Value::Null }); } __for_first_119 = false; i.as_f64().unwrap_or(f64::NAN) < ((response.len() as i64) as f64) } {
4642                let mut item: Value = response.as_array().and_then(|__arr| match &i { Value::Int(__n) => __arr.get(*__n as usize), Value::Str(__s) => __s.parse::<usize>().ok().and_then(|__n| __arr.get(__n)), _ => None }).cloned().unwrap_or(Value::Null);
4643                let mut id: Value = (if (marketIdKey == Value::Null) { Value::Null } else { self.safe_string(item.clone(), marketIdKey.clone(), &[]) });
4644                let mut market: Value = self.safe_market(&[id, Value::Null, Value::Null, Value::Str("swap".into())]);
4645                let mut symbol: Value = market.as_map().and_then(|__m| __m.get("symbol")).cloned().unwrap_or(Value::Null);
4646                let mut contract: Value = self.safe_bool_k(market.clone(), "contract", &[Value::Bool(false)]);
4647                if (contract.as_bool() == Some(true)) && (noSymbols || ((symbolsNormalized != Value::Null) && self.in_array(symbol.clone(), symbolsNormalized.clone()).as_bool() == Some(true))) {
4648                    if let Value::Dict(__d) = &mut tiers { std::sync::Arc::make_mut(__d).insert(crate::runtime::stringify_param(&symbol), <Self as crate::exchange_generated::ExchangeBase>::parse_market_leverage_tiers(self, item.clone(), &[market.clone()])); }
4649                }
4650            }
4651            }
4652        }  else {
4653            let mut keys: Value = object_keys(&response);
4654            {
4655                                let mut i: Value = Value::Int(0);
4656                let mut __for_first_120: bool = true;
4657                while { if !__for_first_120 { i = (match (&(i), &(Value::Int(1))) { (Value::Int(x), Value::Int(y)) => Value::Int(x + y), (Value::Int(x), Value::Float(y)) => Value::Float(*x as f64 + *y), (Value::Float(x), Value::Int(y)) => Value::Float(*x + *y as f64), (Value::Float(x), Value::Float(y)) => Value::Float(x + y), _ => Value::Null }); } __for_first_120 = false; i.as_f64().unwrap_or(f64::NAN) < ((keys.len() as i64) as f64) } {
4658                let mut marketId: Value = keys.as_array().and_then(|__arr| match &i { Value::Int(__n) => __arr.get(*__n as usize), Value::Str(__s) => __s.parse::<usize>().ok().and_then(|__n| __arr.get(__n)), _ => None }).cloned().unwrap_or(Value::Null);
4659                let mut item: Value = get_value(&response, &marketId);
4660                let mut item: Value = get_value(&response, &marketId);
4661                let mut market: Value = self.safe_market(&[marketId, Value::Null, Value::Null, Value::Str("swap".into())]);
4662                let mut symbol: Value = market.as_map().and_then(|__m| __m.get("symbol")).cloned().unwrap_or(Value::Null);
4663                let mut contract: Value = self.safe_bool_k(market.clone(), "contract", &[Value::Bool(false)]);
4664                if (contract.as_bool() == Some(true)) && (noSymbols || ((symbolsNormalized != Value::Null) && self.in_array(symbol.clone(), symbolsNormalized.clone()).as_bool() == Some(true))) {
4665                    if let Value::Dict(__d) = &mut tiers { std::sync::Arc::make_mut(__d).insert(crate::runtime::stringify_param(&symbol), <Self as crate::exchange_generated::ExchangeBase>::parse_market_leverage_tiers(self, item, &[market])); }
4666                }
4667            }
4668            }
4669        }
4670        return tiers;
4671
4672    Value::Null
4673}
4674
4675    fn load_trading_limits(&mut self, optional_args: &[Value]) -> impl ::std::future::Future<Output = Value> + Send { async move {
4676        let mut symbols = get_arg(optional_args, 0, Value::Null);
4677        let mut reload = get_arg(optional_args, 1, Value::Bool(false));
4678        let mut params = get_arg(optional_args, 2, Value::Map({
4679    let mut m = indexmap::IndexMap::new();
4680    m
4681}));
4682        if (self.has.as_map().and_then(|__m| __m.get("fetchTradingLimits")).cloned().unwrap_or(Value::Null) != Value::Null) && (self.has.as_map().and_then(|__m| __m.get("fetchTradingLimits")).cloned().unwrap_or(Value::Null).as_bool() != Some(false)) {
4683            if is_true(&reload) || !(matches!(&self.options, Value::Dict(__d) if __d.contains_key("limitsLoaded"))) {
4684                let mut response: Value = self.fetch_trading_limits(&[symbols.clone()]).await;
4685                let mut symbolsArray: Value = self.require_value(symbols, &[Value::Str("loadTradingLimits() requires a symbols argument".into())]);
4686                let mut markets: Value = self.markets.clone();
4687                if (markets == Value::Null) {
4688                    panic!("{}", crate::exchange_errors::exchange_error(format!("{}{}", self.id.clone(), Value::Str(" markets not loaded".into()))));
4689                }
4690                {
4691                                        let mut i: Value = Value::Int(0);
4692                    let mut __for_first_121: bool = true;
4693                    while { if !__for_first_121 { i = (match (&(i), &(Value::Int(1))) { (Value::Int(x), Value::Int(y)) => Value::Int(x + y), (Value::Int(x), Value::Float(y)) => Value::Float(*x as f64 + *y), (Value::Float(x), Value::Int(y)) => Value::Float(*x + *y as f64), (Value::Float(x), Value::Float(y)) => Value::Float(x + y), _ => Value::Null }); } __for_first_121 = false; i.as_f64().unwrap_or(f64::NAN) < get_array_length(&symbolsArray).as_f64().unwrap_or(f64::NAN) } {
4694                    let mut symbol: Value = get_value(&symbolsArray, &i);
4695                    let mut symbol: Value = get_value(&symbolsArray, &i);
4696                    { let __be_tmp = self.deep_extend(get_value(&markets, &symbol), &[get_value(&response, &symbol)]); add_element_to_object(&mut markets, &symbol, __be_tmp); };
4697                }
4698                }
4699                { let __be_tmp = self.milliseconds(); if let Value::Dict(__d) = &mut self.options { std::sync::Arc::make_mut(__d).insert("limitsLoaded".into(), __be_tmp); } }
4700            }
4701        }
4702        return self.markets.clone();
4703
4704    Value::Null
4705} }
4706
4707    fn safe_position(&self, mut position: Value) -> Value {
4708        // simplified version of: /pull/12765/
4709        // if contractSize is undefined get from market
4710        let mut contractSize: Value = self.safe_number_k(position.clone(), "contractSize", &[]);
4711        let mut symbol: Value = self.safe_string_k(position.clone(), "symbol", &[]);
4712        let mut market: Value = Value::Null;
4713        if (symbol != Value::Null) {
4714            market = self.safe_value(self.markets.clone(), symbol, &[]);
4715        }
4716        if (contractSize == Value::Null) && (market != Value::Null) {
4717            contractSize = self.safe_number_k(market.clone(), "contractSize", &[]);
4718            if let Value::Dict(__d) = &mut position { std::sync::Arc::make_mut(__d).insert("contractSize".into(), contractSize); }
4719        }
4720        let mut isInverse: bool = (market != Value::Null) && is_true(&self.safe_bool_k(market, "inverse", &[Value::Bool(false)]));
4721        let mut side: Option<String> = self.safe_string_k(position.clone(), "side", &[]).as_str().map(str::to_owned);
4722        let mut marginMode: Option<String> = self.safe_string_k(position.clone(), "marginMode", &[]).as_str().map(str::to_owned);
4723        let mut unrealizedPnlString: Value = self.safe_string_k(position.clone(), "unrealizedPnl", &[]);
4724        let mut initialMarginString: Value = self.safe_string_k(position.clone(), "initialMargin", &[]);
4725        let mut maintenanceMarginString: Value = self.safe_string_k(position.clone(), "maintenanceMargin", &[]);
4726        let mut collateralString: Value = self.safe_string_k(position.clone(), "collateral", &[]);
4727        let mut entryPriceString: Value = self.safe_string_k(position.clone(), "entryPrice", &[]);
4728        let mut liquidationPriceString: Value = self.safe_string_k(position.clone(), "liquidationPrice", &[]);
4729        let mut contractsString: Value = self.safe_string_k(position.clone(), "contracts", &[]);
4730        let mut contractSizeString: Value = self.safe_string_k(position.clone(), "contractSize", &[]);
4731        // margin is the amount held in the position (excludes unrealized pnl), collateral = margin + unrealizedPnl
4732        let mut marginString: Value = self.safe_string_k(position.clone(), "positionMargin", &[]);
4733        if (marginString == Value::Null) && (marginMode.as_deref() == Some("isolated")) && (collateralString != Value::Null) {
4734            let mut derivedMargin: Value = collateralString.clone();
4735            if (unrealizedPnlString != Value::Null) && !is_true(&crate::precise::Precise::stringEq(&collateralString, &initialMarginString)) {
4736                derivedMargin = crate::precise::Precise::stringSub(&collateralString, &unrealizedPnlString);
4737            }
4738            if is_true(&crate::precise::Precise::stringGt(&derivedMargin, &Value::Str("0".into()))) {
4739                marginString = derivedMargin.clone();
4740                if let Value::Dict(__d) = &mut position { std::sync::Arc::make_mut(__d).insert("positionMargin".into(), self.parse_number(derivedMargin, &[])); }
4741            }
4742        }
4743        if (marginString == Value::Null) {
4744            if let Value::Dict(__d) = &mut position { std::sync::Arc::make_mut(__d).insert("positionMargin".into(), Value::Null); }; // keep the unified key present across all exchanges
4745        }
4746        if (collateralString == Value::Null) && (marginString != Value::Null) && (unrealizedPnlString != Value::Null) {
4747            collateralString = crate::precise::Precise::stringAdd(&marginString, &unrealizedPnlString);
4748            if let Value::Dict(__d) = &mut position { std::sync::Arc::make_mut(__d).insert("collateral".into(), self.parse_number(collateralString.clone(), &[])); }
4749        }
4750        if (marginMode.as_deref() == Some("isolated")) {
4751            let mut entryMarginString: Value = marginString.clone();
4752            if (entryMarginString == Value::Null) && (collateralString == Value::Null) {
4753                entryMarginString = initialMarginString.clone();
4754            }
4755            let mut hasEntryMargin: bool = (entryMarginString != Value::Null) && is_true(&crate::precise::Precise::stringGt(&entryMarginString, &Value::Str("0".into())));
4756            let mut hasEntryPrice: bool = (entryPriceString != Value::Null) && is_true(&crate::precise::Precise::stringGt(&entryPriceString, &Value::Str("0".into())));
4757            let mut hasLiqPrice: bool = (liquidationPriceString != Value::Null) && is_true(&crate::precise::Precise::stringGt(&liquidationPriceString, &Value::Str("0".into())));
4758            let mut hasContracts: bool = (contractsString != Value::Null) && is_true(&crate::precise::Precise::stringGt(&contractsString, &Value::Str("0".into())));
4759            let mut hasContractSize: bool = (contractSizeString != Value::Null) && is_true(&crate::precise::Precise::stringGt(&contractSizeString, &Value::Str("0".into())));
4760            let mut hasMm: bool = (maintenanceMarginString != Value::Null) && is_true(&crate::precise::Precise::stringGt(&maintenanceMarginString, &Value::Str("0".into())));
4761            let mut priceDiff: Value = Value::Null;
4762            if hasEntryPrice && hasLiqPrice {
4763                if isInverse {
4764                    let mut invEntry: Value = crate::precise::Precise::stringDiv(&Value::Str("1".into()), &entryPriceString);
4765                    let mut invLiq: Value = crate::precise::Precise::stringDiv(&Value::Str("1".into()), &liquidationPriceString);
4766                    if (side.as_deref() == Some("long")) {
4767                        priceDiff = crate::precise::Precise::stringSub(&invLiq, &invEntry);
4768                    }  else if (side.as_deref() == Some("short")) {
4769                        priceDiff = crate::precise::Precise::stringSub(&invEntry, &invLiq);
4770                    }  else {
4771                        priceDiff = crate::precise::Precise::stringAbs(&crate::precise::Precise::stringSub(&invEntry, &invLiq));
4772                    }
4773                }  else {
4774                    if (side.as_deref() == Some("long")) {
4775                        priceDiff = crate::precise::Precise::stringSub(&entryPriceString, &liquidationPriceString);
4776                    }  else if (side.as_deref() == Some("short")) {
4777                        priceDiff = crate::precise::Precise::stringSub(&liquidationPriceString, &entryPriceString);
4778                    }  else {
4779                        priceDiff = crate::precise::Precise::stringAbs(&crate::precise::Precise::stringSub(&entryPriceString, &liquidationPriceString));
4780                    }
4781                }
4782            }
4783            let mut hasPriceDiff: bool = (priceDiff != Value::Null) && is_true(&crate::precise::Precise::stringGt(&priceDiff, &Value::Str("0".into())));
4784            if (maintenanceMarginString == Value::Null) && hasEntryMargin && hasPriceDiff && hasContracts && hasContractSize {
4785                let mut lossFromEntry: Value = crate::precise::Precise::stringMul(&priceDiff, &crate::precise::Precise::stringMul(&contractsString, &contractSizeString));
4786                let mut derivedMm: Value = crate::precise::Precise::stringSub(&entryMarginString, &lossFromEntry);
4787                if is_true(&crate::precise::Precise::stringGt(&derivedMm, &Value::Str("0".into()))) {
4788                    maintenanceMarginString = derivedMm.clone();
4789                    if let Value::Dict(__d) = &mut position { std::sync::Arc::make_mut(__d).insert("maintenanceMargin".into(), self.parse_number(derivedMm.clone(), &[])); }
4790                }
4791            }  else if (collateralString == Value::Null) && (initialMarginString == Value::Null) && hasMm && hasPriceDiff && hasContracts && hasContractSize {
4792                let mut lossFromEntry: Value = crate::precise::Precise::stringMul(&priceDiff, &crate::precise::Precise::stringMul(&contractsString, &contractSizeString));
4793                let mut derivedEntryMargin: Value = crate::precise::Precise::stringAdd(&maintenanceMarginString, &lossFromEntry);
4794                if is_true(&crate::precise::Precise::stringGt(&derivedEntryMargin, &Value::Str("0".into()))) {
4795                    initialMarginString = derivedEntryMargin.clone();
4796                    if let Value::Dict(__d) = &mut position { std::sync::Arc::make_mut(__d).insert("initialMargin".into(), self.parse_number(derivedEntryMargin.clone(), &[])); }
4797                    marginString = derivedEntryMargin.clone();
4798                    if let Value::Dict(__d) = &mut position { std::sync::Arc::make_mut(__d).insert("positionMargin".into(), self.parse_number(derivedEntryMargin.clone(), &[])); }
4799                    let mut derivedCollateral: Value = (if (unrealizedPnlString != Value::Null) { crate::precise::Precise::stringAdd(&derivedEntryMargin, &unrealizedPnlString) } else { derivedEntryMargin.clone() });
4800                    if is_true(&crate::precise::Precise::stringGt(&derivedCollateral, &Value::Str("0".into()))) {
4801                        collateralString = derivedCollateral.clone();
4802                        if let Value::Dict(__d) = &mut position { std::sync::Arc::make_mut(__d).insert("collateral".into(), self.parse_number(derivedCollateral, &[])); }
4803                    }
4804                }
4805            }  else if (liquidationPriceString == Value::Null) && hasEntryMargin && hasMm && hasEntryPrice && hasContracts && hasContractSize && ((side.as_deref() == Some("long")) || (side.as_deref() == Some("short"))) {
4806                let mut marginBuffer: Value = crate::precise::Precise::stringSub(&entryMarginString, &maintenanceMarginString);
4807                let mut totalSize: Value = crate::precise::Precise::stringMul(&contractsString, &contractSizeString);
4808                if is_true(&crate::precise::Precise::stringGt(&marginBuffer, &Value::Str("0".into()))) && is_true(&crate::precise::Precise::stringGt(&totalSize, &Value::Str("0".into()))) {
4809                    let mut bufferPerUnit: Value = crate::precise::Precise::stringDiv(&marginBuffer, &totalSize);
4810                    let mut derivedLp: Value = Value::Null;
4811                    if isInverse {
4812                        let mut invEntry: Value = crate::precise::Precise::stringDiv(&Value::Str("1".into()), &entryPriceString);
4813                        let mut invLp: Value = (if (side.as_deref() == Some("long")) { crate::precise::Precise::stringAdd(&invEntry, &bufferPerUnit) } else { crate::precise::Precise::stringSub(&invEntry, &bufferPerUnit) });
4814                        if is_true(&crate::precise::Precise::stringGt(&invLp, &Value::Str("0".into()))) {
4815                            derivedLp = crate::precise::Precise::stringDiv(&Value::Str("1".into()), &invLp);
4816                        }
4817                    }  else {
4818                        derivedLp = (if (side.as_deref() == Some("long")) { crate::precise::Precise::stringSub(&entryPriceString, &bufferPerUnit) } else { crate::precise::Precise::stringAdd(&entryPriceString, &bufferPerUnit) });
4819                    }
4820                    if (derivedLp != Value::Null) && is_true(&crate::precise::Precise::stringGt(&derivedLp, &Value::Str("0".into()))) {
4821                        liquidationPriceString = derivedLp.clone();
4822                        if let Value::Dict(__d) = &mut position { std::sync::Arc::make_mut(__d).insert("liquidationPrice".into(), self.parse_number(derivedLp, &[])); }
4823                    }
4824                }
4825            }  else if (entryPriceString == Value::Null) && hasEntryMargin && hasMm && hasLiqPrice && hasContracts && hasContractSize && ((side.as_deref() == Some("long")) || (side.as_deref() == Some("short"))) {
4826                let mut marginBuffer: Value = crate::precise::Precise::stringSub(&entryMarginString, &maintenanceMarginString);
4827                let mut totalSize: Value = crate::precise::Precise::stringMul(&contractsString, &contractSizeString);
4828                if is_true(&crate::precise::Precise::stringGt(&marginBuffer, &Value::Str("0".into()))) && is_true(&crate::precise::Precise::stringGt(&totalSize, &Value::Str("0".into()))) {
4829                    let mut bufferPerUnit: Value = crate::precise::Precise::stringDiv(&marginBuffer, &totalSize);
4830                    let mut derivedEp: Value = Value::Null;
4831                    if isInverse {
4832                        let mut invLp: Value = crate::precise::Precise::stringDiv(&Value::Str("1".into()), &liquidationPriceString);
4833                        let mut invEp: Value = (if (side.as_deref() == Some("long")) { crate::precise::Precise::stringSub(&invLp, &bufferPerUnit) } else { crate::precise::Precise::stringAdd(&invLp, &bufferPerUnit) });
4834                        if is_true(&crate::precise::Precise::stringGt(&invEp, &Value::Str("0".into()))) {
4835                            derivedEp = crate::precise::Precise::stringDiv(&Value::Str("1".into()), &invEp);
4836                        }
4837                    }  else {
4838                        derivedEp = (if (side.as_deref() == Some("long")) { crate::precise::Precise::stringAdd(&liquidationPriceString, &bufferPerUnit) } else { crate::precise::Precise::stringSub(&liquidationPriceString, &bufferPerUnit) });
4839                    }
4840                    if (derivedEp != Value::Null) && is_true(&crate::precise::Precise::stringGt(&derivedEp, &Value::Str("0".into()))) {
4841                        entryPriceString = derivedEp.clone();
4842                        if let Value::Dict(__d) = &mut position { std::sync::Arc::make_mut(__d).insert("entryPrice".into(), self.parse_number(derivedEp, &[])); }
4843                    }
4844                }
4845            }  else if (contractsString == Value::Null) && hasEntryMargin && hasMm && hasPriceDiff && hasContractSize {
4846                let mut marginBuffer: Value = crate::precise::Precise::stringSub(&entryMarginString, &maintenanceMarginString);
4847                let mut denom: Value = crate::precise::Precise::stringMul(&priceDiff, &contractSizeString);
4848                if is_true(&crate::precise::Precise::stringGt(&marginBuffer, &Value::Str("0".into()))) && is_true(&crate::precise::Precise::stringGt(&denom, &Value::Str("0".into()))) {
4849                    let mut derivedContracts: Value = crate::precise::Precise::stringDiv(&marginBuffer, &denom);
4850                    if is_true(&crate::precise::Precise::stringGt(&derivedContracts, &Value::Str("0".into()))) {
4851                        contractsString = derivedContracts.clone();
4852                        if let Value::Dict(__d) = &mut position { std::sync::Arc::make_mut(__d).insert("contracts".into(), self.parse_number(derivedContracts.clone(), &[])); }
4853                    }
4854                }
4855            }  else if (contractSizeString == Value::Null) && hasEntryMargin && hasMm && hasPriceDiff && hasContracts {
4856                let mut marginBuffer: Value = crate::precise::Precise::stringSub(&entryMarginString, &maintenanceMarginString);
4857                let mut denom: Value = crate::precise::Precise::stringMul(&priceDiff, &contractsString);
4858                if is_true(&crate::precise::Precise::stringGt(&marginBuffer, &Value::Str("0".into()))) && is_true(&crate::precise::Precise::stringGt(&denom, &Value::Str("0".into()))) {
4859                    let mut derivedContractSize: Value = crate::precise::Precise::stringDiv(&marginBuffer, &denom);
4860                    if is_true(&crate::precise::Precise::stringGt(&derivedContractSize, &Value::Str("0".into()))) {
4861                        contractSizeString = derivedContractSize.clone();
4862                        if let Value::Dict(__d) = &mut position { std::sync::Arc::make_mut(__d).insert("contractSize".into(), self.parse_number(derivedContractSize.clone(), &[])); }
4863                    }
4864                }
4865            }
4866        }
4867        //
4868        // POSITION-LOCAL DERIVATIONS (CROSS & ISOLATED)
4869        //
4870        let mut isZeroPosition: bool = (contractsString != Value::Null) && is_true(&crate::precise::Precise::stringEq(&contractsString, &Value::Str("0".into())));
4871        if !isZeroPosition {
4872            let mut notionalString: Value = self.safe_string_k(position.clone(), "notional", &[]);
4873            let mut markPriceString: Value = self.safe_string_k(position.clone(), "markPrice", &[]);
4874            let mut lastPriceString: Option<String> = self.safe_string_k(position.clone(), "lastPrice", &[]).as_str().map(str::to_owned);
4875            let mut hasContracts: bool = (contractsString != Value::Null) && is_true(&crate::precise::Precise::stringGt(&contractsString, &Value::Str("0".into())));
4876            let mut hasContractSize: bool = (contractSizeString != Value::Null) && is_true(&crate::precise::Precise::stringGt(&contractSizeString, &Value::Str("0".into())));
4877            let mut hasMarkPrice: bool = (markPriceString != Value::Null) && is_true(&crate::precise::Precise::stringGt(&markPriceString, &Value::Str("0".into())));
4878            let mut hasNotional: bool = (notionalString != Value::Null) && is_true(&crate::precise::Precise::stringGt(&notionalString, &Value::Str("0".into())));
4879            // 1. notional <-> markPrice / contracts / contractSize
4880            if (notionalString == Value::Null) && hasMarkPrice && hasContracts && hasContractSize {
4881                let mut totalSize: Value = crate::precise::Precise::stringMul(&contractsString, &contractSizeString);
4882                let mut derivedNotional: Value = (if isInverse { crate::precise::Precise::stringDiv(&totalSize, &markPriceString) } else { crate::precise::Precise::stringMul(&totalSize, &markPriceString) });
4883                if is_true(&crate::precise::Precise::stringGt(&derivedNotional, &Value::Str("0".into()))) {
4884                    notionalString = derivedNotional.clone();
4885                    if let Value::Dict(__d) = &mut position { std::sync::Arc::make_mut(__d).insert("notional".into(), self.parse_number(derivedNotional, &[])); }
4886                }
4887            }  else if (markPriceString == Value::Null) && (entryPriceString == Value::Null) && (lastPriceString.is_none()) && hasNotional && hasContracts && hasContractSize {
4888                let mut totalSize: Value = crate::precise::Precise::stringMul(&contractsString, &contractSizeString);
4889                let mut derivedMark: Value = (if isInverse { crate::precise::Precise::stringDiv(&totalSize, &notionalString) } else { crate::precise::Precise::stringDiv(&notionalString, &totalSize) });
4890                if is_true(&crate::precise::Precise::stringGt(&derivedMark, &Value::Str("0".into()))) {
4891                    markPriceString = derivedMark.clone();
4892                    if let Value::Dict(__d) = &mut position { std::sync::Arc::make_mut(__d).insert("markPrice".into(), self.parse_number(derivedMark, &[])); }
4893                }
4894            }  else if (contractsString == Value::Null) && hasNotional && hasMarkPrice && hasContractSize {
4895                let mut derivedContracts: Value = (if isInverse { crate::precise::Precise::stringDiv(&crate::precise::Precise::stringMul(&notionalString, &markPriceString), &contractSizeString) } else { crate::precise::Precise::stringDiv(&notionalString, &crate::precise::Precise::stringMul(&markPriceString, &contractSizeString)) });
4896                if is_true(&crate::precise::Precise::stringGt(&derivedContracts, &Value::Str("0".into()))) {
4897                    contractsString = derivedContracts.clone();
4898                    if let Value::Dict(__d) = &mut position { std::sync::Arc::make_mut(__d).insert("contracts".into(), self.parse_number(derivedContracts, &[])); }
4899                }
4900            }  else if (contractSizeString == Value::Null) && hasNotional && hasMarkPrice && hasContracts {
4901                let mut derivedContractSize: Value = (if isInverse { crate::precise::Precise::stringDiv(&crate::precise::Precise::stringMul(&notionalString, &markPriceString), &contractsString) } else { crate::precise::Precise::stringDiv(&notionalString, &crate::precise::Precise::stringMul(&markPriceString, &contractsString)) });
4902                if is_true(&crate::precise::Precise::stringGt(&derivedContractSize, &Value::Str("0".into()))) {
4903                    contractSizeString = derivedContractSize.clone();
4904                    if let Value::Dict(__d) = &mut position { std::sync::Arc::make_mut(__d).insert("contractSize".into(), self.parse_number(derivedContractSize, &[])); }
4905                }
4906            }
4907            // 2. unrealizedPnl from entryPrice, markPrice, contracts, contractSize, side
4908            if (unrealizedPnlString == Value::Null) && (entryPriceString != Value::Null) && (markPriceString != Value::Null) && (contractsString != Value::Null) && (contractSizeString != Value::Null) {
4909                if is_true(&crate::precise::Precise::stringGt(&entryPriceString, &Value::Str("0".into()))) && is_true(&crate::precise::Precise::stringGt(&markPriceString, &Value::Str("0".into()))) && is_true(&crate::precise::Precise::stringGt(&contractsString, &Value::Str("0".into()))) && is_true(&crate::precise::Precise::stringGt(&contractSizeString, &Value::Str("0".into()))) {
4910                    let mut totalSize: Value = crate::precise::Precise::stringMul(&contractsString, &contractSizeString);
4911                    let mut pnlDiff: Value = Value::Null;
4912                    if isInverse {
4913                        let mut invEntry: Value = crate::precise::Precise::stringDiv(&Value::Str("1".into()), &entryPriceString);
4914                        let mut invMark: Value = crate::precise::Precise::stringDiv(&Value::Str("1".into()), &markPriceString);
4915                        if (side.as_deref() == Some("long")) {
4916                            pnlDiff = crate::precise::Precise::stringSub(&invEntry, &invMark);
4917                        }  else if (side.as_deref() == Some("short")) {
4918                            pnlDiff = crate::precise::Precise::stringSub(&invMark, &invEntry);
4919                        }
4920                    }  else {
4921                        if (side.as_deref() == Some("long")) {
4922                            pnlDiff = crate::precise::Precise::stringSub(&markPriceString, &entryPriceString);
4923                        }  else if (side.as_deref() == Some("short")) {
4924                            pnlDiff = crate::precise::Precise::stringSub(&entryPriceString, &markPriceString);
4925                        }
4926                    }
4927                    if (pnlDiff != Value::Null) {
4928                        let mut candidateUpnl: Value = crate::precise::Precise::stringMul(&pnlDiff, &totalSize);
4929                        if is_true(&crate::precise::Precise::stringEq(&candidateUpnl, &Value::Str("0".into()))) || is_true(&crate::precise::Precise::stringGe(&crate::precise::Precise::stringAbs(&candidateUpnl), &Value::Str("0.000001".into()))) {
4930                            unrealizedPnlString = candidateUpnl.clone();
4931                            if let Value::Dict(__d) = &mut position { std::sync::Arc::make_mut(__d).insert("unrealizedPnl".into(), self.parse_number(unrealizedPnlString.clone(), &[])); }
4932                        }
4933                    }
4934                }
4935            }
4936            // 3. initialMargin <-> initialMarginPercentage <-> leverage / notional
4937            let mut hasValidNotional: bool = (notionalString != Value::Null) && is_true(&crate::precise::Precise::stringGt(&notionalString, &Value::Str("0".into())));
4938            let mut hasNegativeCollateral: bool = (collateralString != Value::Null) && is_true(&crate::precise::Precise::stringLt(&collateralString, &Value::Str("0".into())));
4939            let mut initialMarginPercentageString: Value = self.safe_string_k(position.clone(), "initialMarginPercentage", &[]);
4940            let mut leverageString: Value = self.safe_string_k(position.clone(), "leverage", &[]);
4941            let mut hasLeverage: bool = (leverageString != Value::Null) && is_true(&crate::precise::Precise::stringGt(&leverageString, &Value::Str("0".into())));
4942            let mut hasInitialMargin: bool = (initialMarginString != Value::Null) && is_true(&crate::precise::Precise::stringGt(&initialMarginString, &Value::Str("0".into())));
4943            let mut hadInitialMargin: bool = initialMarginString != Value::Null;
4944            if (initialMarginPercentageString == Value::Null) && !hasNegativeCollateral && (hasInitialMargin || !hadInitialMargin) {
4945                if hasInitialMargin && hasValidNotional {
4946                    initialMarginPercentageString = crate::precise::Precise::stringDiv(&initialMarginString, &notionalString);
4947                }  else if hasLeverage {
4948                    initialMarginPercentageString = crate::precise::Precise::stringDiv(&Value::Str("1".into()), &leverageString);
4949                }
4950                if (initialMarginPercentageString != Value::Null) && is_true(&crate::precise::Precise::stringGt(&initialMarginPercentageString, &Value::Str("0".into()))) {
4951                    if let Value::Dict(__d) = &mut position { std::sync::Arc::make_mut(__d).insert("initialMarginPercentage".into(), self.parse_number(initialMarginPercentageString.clone(), &[])); }
4952                }
4953            }
4954            let mut hasImp: bool = (initialMarginPercentageString != Value::Null) && is_true(&crate::precise::Precise::stringGt(&initialMarginPercentageString, &Value::Str("0".into())));
4955            if (initialMarginString == Value::Null) && !hasNegativeCollateral && hasValidNotional {
4956                if hasLeverage {
4957                    initialMarginString = crate::precise::Precise::stringDiv(&notionalString, &leverageString);
4958                }  else if hasImp {
4959                    initialMarginString = crate::precise::Precise::stringMul(&notionalString, &initialMarginPercentageString);
4960                }
4961                if (initialMarginString != Value::Null) && is_true(&crate::precise::Precise::stringGt(&initialMarginString, &Value::Str("0".into()))) {
4962                    if let Value::Dict(__d) = &mut position { std::sync::Arc::make_mut(__d).insert("initialMargin".into(), self.parse_number(initialMarginString.clone(), &[])); }
4963                }
4964            }
4965            if (leverageString == Value::Null) && !hadInitialMargin && hasImp {
4966                let mut derivedLeverage: Value = crate::precise::Precise::stringDiv(&Value::Str("1".into()), &initialMarginPercentageString);
4967                if is_true(&crate::precise::Precise::stringGt(&derivedLeverage, &Value::Str("0".into()))) && is_true(&crate::precise::Precise::stringLe(&derivedLeverage, &Value::Str("200".into()))) {
4968                    if let Value::Dict(__d) = &mut position { std::sync::Arc::make_mut(__d).insert("leverage".into(), self.parse_number(derivedLeverage, &[])); }
4969                }
4970            }
4971            // 4. maintenanceMargin <-> maintenanceMarginPercentage / notional
4972            let mut maintenanceMarginPercentageString: Value = self.safe_string_k(position.clone(), "maintenanceMarginPercentage", &[]);
4973            let mut hasValidMm: bool = (maintenanceMarginString != Value::Null) && is_true(&crate::precise::Precise::stringGt(&maintenanceMarginString, &Value::Str("0".into())));
4974            let mut hasValidMmp: bool = (maintenanceMarginPercentageString != Value::Null) && is_true(&crate::precise::Precise::stringGt(&maintenanceMarginPercentageString, &Value::Str("0".into())));
4975            if (maintenanceMarginString == Value::Null) && hasValidNotional && hasValidMmp {
4976                let mut derivedMm: Value = crate::precise::Precise::stringMul(&notionalString, &maintenanceMarginPercentageString);
4977                if is_true(&crate::precise::Precise::stringGt(&derivedMm, &Value::Str("0".into()))) {
4978                    maintenanceMarginString = derivedMm.clone();
4979                    if let Value::Dict(__d) = &mut position { std::sync::Arc::make_mut(__d).insert("maintenanceMargin".into(), self.parse_number(derivedMm, &[])); }
4980                }
4981            }  else if (maintenanceMarginPercentageString == Value::Null) && hasValidNotional && hasValidMm {
4982                let mut derivedMmp: Value = crate::precise::Precise::stringDiv(&maintenanceMarginString, &notionalString);
4983                if is_true(&crate::precise::Precise::stringGt(&derivedMmp, &Value::Str("0".into()))) {
4984                    maintenanceMarginPercentageString = derivedMmp.clone();
4985                    if let Value::Dict(__d) = &mut position { std::sync::Arc::make_mut(__d).insert("maintenanceMarginPercentage".into(), self.parse_number(derivedMmp, &[])); }
4986                }
4987            }
4988            // 5. marginRatio = maintenanceMargin / collateral
4989            let mut marginRatio: Value = self.safe_value_k(position.clone(), "marginRatio", &[]);
4990            if (marginRatio == Value::Null) && (maintenanceMarginString != Value::Null) && (collateralString != Value::Null) {
4991                if is_true(&crate::precise::Precise::stringGt(&maintenanceMarginString, &Value::Str("0".into()))) && is_true(&crate::precise::Precise::stringGt(&collateralString, &Value::Str("0".into()))) {
4992                    let mut derivedMarginRatio: Value = crate::precise::Precise::stringDivPrec(&maintenanceMarginString, &collateralString, &Value::Int(4));
4993                    if (derivedMarginRatio != Value::Null) && is_true(&crate::precise::Precise::stringGt(&derivedMarginRatio, &Value::Str("0".into()))) {
4994                        if let Value::Dict(__d) = &mut position { std::sync::Arc::make_mut(__d).insert("marginRatio".into(), self.parse_number(derivedMarginRatio, &[])); }
4995                    }
4996                }
4997            }
4998        }
4999        //
5000        // PERCENTAGE
5001        //
5002        let mut percentage: Value = self.safe_value_k(position.clone(), "percentage", &[]);
5003        if (percentage == Value::Null) && (unrealizedPnlString != Value::Null) && (initialMarginString != Value::Null) {
5004            // as it was done in all implementations ( aax, btcex, bybit, deribit, gate, kucoinfutures, phemex )
5005            let mut percentageString: Value = crate::precise::Precise::stringMul(&crate::precise::Precise::stringDivPrec(&unrealizedPnlString, &initialMarginString, &Value::Int(4)), &Value::Str("100".into()));
5006            if let Value::Dict(__d) = &mut position { std::sync::Arc::make_mut(__d).insert("percentage".into(), self.parse_number(percentageString, &[])); }
5007        }
5008        return position;
5009
5010    Value::Null
5011}
5012
5013    fn parse_positions(&self, mut positions: Value, optional_args: &[Value]) -> Value {
5014        let mut symbols = get_arg(optional_args, 0, Value::Null);
5015        let mut params = get_arg(optional_args, 1, Value::Map({
5016    let mut m = indexmap::IndexMap::new();
5017    m
5018}));
5019        let mut symbolsNormalized: Value = self.market_symbols(&[symbols]);
5020        let mut positionsArray: Value = self.to_array(positions);
5021        let mut result: Value = Value::from(vec![]);
5022        {
5023                        let mut i: Value = Value::Int(0);
5024            let mut __for_first_122: bool = true;
5025            while { if !__for_first_122 { i = (match (&(i), &(Value::Int(1))) { (Value::Int(x), Value::Int(y)) => Value::Int(x + y), (Value::Int(x), Value::Float(y)) => Value::Float(*x as f64 + *y), (Value::Float(x), Value::Int(y)) => Value::Float(*x + *y as f64), (Value::Float(x), Value::Float(y)) => Value::Float(x + y), _ => Value::Null }); } __for_first_122 = false; i.as_f64().unwrap_or(f64::NAN) < ((positionsArray.len() as i64) as f64) } {
5026            let mut position: Value = self.extend(<Self as crate::exchange_generated::ExchangeBase>::parse_position(self, positionsArray.as_array().and_then(|__arr| match &i { Value::Int(__n) => __arr.get(*__n as usize), Value::Str(__s) => __s.parse::<usize>().ok().and_then(|__n| __arr.get(__n)), _ => None }).cloned().unwrap_or(Value::Null), &[]), &[params.clone()]);
5027            append_to_array(&mut result, position);
5028        }
5029        }
5030        return self.filter_by_array_positions(result, Value::Str("symbol".into()), &[symbolsNormalized]);
5031
5032    Value::Null
5033}
5034
5035    fn parse_adl_rank(&self, mut info: Value, optional_args: &[Value]) -> Value {
5036        // virtual-dispatch (static: DerivedExchange::parse_adl_rank(self, ...))
5037        { 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; } }
5038
5039        let mut market = get_arg(optional_args, 0, Value::Null);
5040        if (info == Value::Null) {
5041            panic!("{}", crate::exchange_errors::not_supported(format!("{}{}", self.id.clone(), Value::Str(" parseADLRank() is not supported yet".into()))));
5042        }
5043        panic!("{}", crate::exchange_errors::not_supported(format!("{}{}", self.id.clone(), Value::Str(" parseADLRank() is not supported yet".into()))));
5044
5045    Value::Null
5046}
5047
5048    fn parse_adl_ranks(&self, mut ranks: Value, optional_args: &[Value]) -> Value {
5049        let mut symbols = get_arg(optional_args, 0, Value::Null);
5050        let mut params = get_arg(optional_args, 1, Value::Map({
5051    let mut m = indexmap::IndexMap::new();
5052    m
5053}));
5054        let mut symbolsNormalized: Value = self.market_symbols(&[symbols]);
5055        let mut ranksArray: Value = self.to_array(ranks);
5056        let mut result: Value = Value::from(vec![]);
5057        {
5058                        let mut i: Value = Value::Int(0);
5059            let mut __for_first_123: bool = true;
5060            while { if !__for_first_123 { i = (match (&(i), &(Value::Int(1))) { (Value::Int(x), Value::Int(y)) => Value::Int(x + y), (Value::Int(x), Value::Float(y)) => Value::Float(*x as f64 + *y), (Value::Float(x), Value::Int(y)) => Value::Float(*x + *y as f64), (Value::Float(x), Value::Float(y)) => Value::Float(x + y), _ => Value::Null }); } __for_first_123 = false; i.as_f64().unwrap_or(f64::NAN) < ((ranksArray.len() as i64) as f64) } {
5061            let mut rank: Value = self.extend(<Self as crate::exchange_generated::ExchangeBase>::parse_adl_rank(self, ranksArray.as_array().and_then(|__arr| match &i { Value::Int(__n) => __arr.get(*__n as usize), Value::Str(__s) => __s.parse::<usize>().ok().and_then(|__n| __arr.get(__n)), _ => None }).cloned().unwrap_or(Value::Null), &[]), &[params.clone()]);
5062            append_to_array(&mut result, rank);
5063        }
5064        }
5065        return self.filter_by_array_positions(result, Value::Str("symbol".into()), &[symbolsNormalized]);
5066
5067    Value::Null
5068}
5069
5070    fn parse_accounts(&self, mut accounts: Value, optional_args: &[Value]) -> Value {
5071        let mut params = get_arg(optional_args, 0, Value::Map({
5072    let mut m = indexmap::IndexMap::new();
5073    m
5074}));
5075        let mut accountsArray: Value = self.to_array(accounts);
5076        let mut result: Value = Value::from(vec![]);
5077        {
5078                        let mut i: Value = Value::Int(0);
5079            let mut __for_first_124: bool = true;
5080            while { if !__for_first_124 { i = (match (&(i), &(Value::Int(1))) { (Value::Int(x), Value::Int(y)) => Value::Int(x + y), (Value::Int(x), Value::Float(y)) => Value::Float(*x as f64 + *y), (Value::Float(x), Value::Int(y)) => Value::Float(*x + *y as f64), (Value::Float(x), Value::Float(y)) => Value::Float(x + y), _ => Value::Null }); } __for_first_124 = false; i.as_f64().unwrap_or(f64::NAN) < ((accountsArray.len() as i64) as f64) } {
5081            let mut account: Value = self.extend(<Self as crate::exchange_generated::ExchangeBase>::parse_account(self, accountsArray.as_array().and_then(|__arr| match &i { Value::Int(__n) => __arr.get(*__n as usize), Value::Str(__s) => __s.parse::<usize>().ok().and_then(|__n| __arr.get(__n)), _ => None }).cloned().unwrap_or(Value::Null)), &[params.clone()]);
5082            append_to_array(&mut result, account);
5083        }
5084        }
5085        return result;
5086
5087    Value::Null
5088}
5089
5090    fn parse_trades_helper(&self, mut isWs: Value, mut trades: Value, optional_args: &[Value]) -> Value {
5091        let mut market = get_arg(optional_args, 0, Value::Null);
5092        let mut since = get_arg(optional_args, 1, Value::Null);
5093        let mut limit = get_arg(optional_args, 2, Value::Null);
5094        let mut params = get_arg(optional_args, 3, Value::Map({
5095    let mut m = indexmap::IndexMap::new();
5096    m
5097}));
5098        let mut tradesArray: Value = self.to_array(trades);
5099        let mut result: Value = Value::from(vec![]);
5100        {
5101                        let mut i: Value = Value::Int(0);
5102            let mut __for_first_125: bool = true;
5103            while { if !__for_first_125 { i = (match (&(i), &(Value::Int(1))) { (Value::Int(x), Value::Int(y)) => Value::Int(x + y), (Value::Int(x), Value::Float(y)) => Value::Float(*x as f64 + *y), (Value::Float(x), Value::Int(y)) => Value::Float(*x + *y as f64), (Value::Float(x), Value::Float(y)) => Value::Float(x + y), _ => Value::Null }); } __for_first_125 = false; i.as_f64().unwrap_or(f64::NAN) < ((tradesArray.len() as i64) as f64) } {
5104            let mut parsed: Value = Value::Null;
5105            if is_true(&isWs) {
5106                parsed = self.parse_ws_trade(tradesArray.as_array().and_then(|__arr| match &i { Value::Int(__n) => __arr.get(*__n as usize), Value::Str(__s) => __s.parse::<usize>().ok().and_then(|__n| __arr.get(__n)), _ => None }).cloned().unwrap_or(Value::Null), &[market.clone()]);
5107            }  else {
5108                parsed = <Self as crate::exchange_generated::ExchangeBase>::parse_trade(self, tradesArray.as_array().and_then(|__arr| match &i { Value::Int(__n) => __arr.get(*__n as usize), Value::Str(__s) => __s.parse::<usize>().ok().and_then(|__n| __arr.get(__n)), _ => None }).cloned().unwrap_or(Value::Null), &[market.clone()]);
5109            }
5110            let mut trade: Value = self.extend(parsed, &[params.clone()]);
5111            append_to_array(&mut result, trade);
5112        }
5113        }
5114        result = self.sort_by2(result.clone(), Value::Str("timestamp".into()), Value::Str("id".into()), &[]);
5115        let mut symbol: Value = self.safe_string_k(market, "symbol", &[]);
5116        return self.filter_by_symbol_since_limit(result, &[symbol, since, limit]);
5117
5118    Value::Null
5119}
5120
5121    fn parse_trades(&self, mut trades: Value, optional_args: &[Value]) -> Value {
5122        let mut market = get_arg(optional_args, 0, Value::Null);
5123        let mut since = get_arg(optional_args, 1, Value::Null);
5124        let mut limit = get_arg(optional_args, 2, Value::Null);
5125        let mut params = get_arg(optional_args, 3, Value::Map({
5126    let mut m = indexmap::IndexMap::new();
5127    m
5128}));
5129        return self.parse_trades_helper(Value::Bool(false), trades, &[market, since, limit, params]);
5130
5131    Value::Null
5132}
5133
5134    fn parse_ws_trades(&self, mut trades: Value, optional_args: &[Value]) -> Value {
5135        let mut market = get_arg(optional_args, 0, Value::Null);
5136        let mut since = get_arg(optional_args, 1, Value::Null);
5137        let mut limit = get_arg(optional_args, 2, Value::Null);
5138        let mut params = get_arg(optional_args, 3, Value::Map({
5139    let mut m = indexmap::IndexMap::new();
5140    m
5141}));
5142        return self.parse_trades_helper(Value::Bool(true), trades, &[market, since, limit, params]);
5143
5144    Value::Null
5145}
5146
5147    fn parse_transactions(&self, mut transactions: Value, optional_args: &[Value]) -> Value {
5148        let mut currency = get_arg(optional_args, 0, Value::Null);
5149        let mut since = get_arg(optional_args, 1, Value::Null);
5150        let mut limit = get_arg(optional_args, 2, Value::Null);
5151        let mut params = get_arg(optional_args, 3, Value::Map({
5152    let mut m = indexmap::IndexMap::new();
5153    m
5154}));
5155        let mut transactionsArray: Value = self.to_array(transactions);
5156        let mut result: Value = Value::from(vec![]);
5157        {
5158                        let mut i: Value = Value::Int(0);
5159            let mut __for_first_126: bool = true;
5160            while { if !__for_first_126 { i = (match (&(i), &(Value::Int(1))) { (Value::Int(x), Value::Int(y)) => Value::Int(x + y), (Value::Int(x), Value::Float(y)) => Value::Float(*x as f64 + *y), (Value::Float(x), Value::Int(y)) => Value::Float(*x + *y as f64), (Value::Float(x), Value::Float(y)) => Value::Float(x + y), _ => Value::Null }); } __for_first_126 = false; i.as_f64().unwrap_or(f64::NAN) < ((transactionsArray.len() as i64) as f64) } {
5161            let mut transaction: Value = self.extend(<Self as crate::exchange_generated::ExchangeBase>::parse_transaction(self, transactionsArray.as_array().and_then(|__arr| match &i { Value::Int(__n) => __arr.get(*__n as usize), Value::Str(__s) => __s.parse::<usize>().ok().and_then(|__n| __arr.get(__n)), _ => None }).cloned().unwrap_or(Value::Null), &[currency.clone()]), &[params.clone()]);
5162            append_to_array(&mut result, transaction);
5163        }
5164        }
5165        result = self.sort_by(result.clone(), Value::Str("timestamp".into()), &[]);
5166        let mut code: Value = (if (currency != Value::Null) { currency.as_map().and_then(|__m| __m.get("code")).cloned().unwrap_or(Value::Null) } else { Value::Null });
5167        return self.filter_by_currency_since_limit(result, &[code, since, limit]);
5168
5169    Value::Null
5170}
5171
5172    fn parse_transfers(&self, mut transfers: Value, optional_args: &[Value]) -> Value {
5173        let mut currency = get_arg(optional_args, 0, Value::Null);
5174        let mut since = get_arg(optional_args, 1, Value::Null);
5175        let mut limit = get_arg(optional_args, 2, Value::Null);
5176        let mut params = get_arg(optional_args, 3, Value::Map({
5177    let mut m = indexmap::IndexMap::new();
5178    m
5179}));
5180        let mut transfersArray: Value = self.to_array(transfers);
5181        let mut result: Value = Value::from(vec![]);
5182        {
5183                        let mut i: Value = Value::Int(0);
5184            let mut __for_first_127: bool = true;
5185            while { if !__for_first_127 { i = (match (&(i), &(Value::Int(1))) { (Value::Int(x), Value::Int(y)) => Value::Int(x + y), (Value::Int(x), Value::Float(y)) => Value::Float(*x as f64 + *y), (Value::Float(x), Value::Int(y)) => Value::Float(*x + *y as f64), (Value::Float(x), Value::Float(y)) => Value::Float(x + y), _ => Value::Null }); } __for_first_127 = false; i.as_f64().unwrap_or(f64::NAN) < ((transfersArray.len() as i64) as f64) } {
5186            let mut transfer: Value = self.extend(<Self as crate::exchange_generated::ExchangeBase>::parse_transfer(self, transfersArray.as_array().and_then(|__arr| match &i { Value::Int(__n) => __arr.get(*__n as usize), Value::Str(__s) => __s.parse::<usize>().ok().and_then(|__n| __arr.get(__n)), _ => None }).cloned().unwrap_or(Value::Null), &[currency.clone()]), &[params.clone()]);
5187            append_to_array(&mut result, transfer);
5188        }
5189        }
5190        result = self.sort_by(result.clone(), Value::Str("timestamp".into()), &[]);
5191        let mut code: Value = (if (currency != Value::Null) { currency.as_map().and_then(|__m| __m.get("code")).cloned().unwrap_or(Value::Null) } else { Value::Null });
5192        return self.filter_by_currency_since_limit(result, &[code, since, limit]);
5193
5194    Value::Null
5195}
5196
5197    fn parse_ledger(&self, mut data: Value, optional_args: &[Value]) -> Value {
5198        let mut currency = get_arg(optional_args, 0, Value::Null);
5199        let mut since = get_arg(optional_args, 1, Value::Null);
5200        let mut limit = get_arg(optional_args, 2, Value::Null);
5201        let mut params = get_arg(optional_args, 3, Value::Map({
5202    let mut m = indexmap::IndexMap::new();
5203    m
5204}));
5205        let mut result: Value = Value::from(vec![]);
5206        let mut arrayData: Value = self.to_array(data);
5207        {
5208                        let mut i: Value = Value::Int(0);
5209            let mut __for_first_129: bool = true;
5210            while { if !__for_first_129 { i = (match (&(i), &(Value::Int(1))) { (Value::Int(x), Value::Int(y)) => Value::Int(x + y), (Value::Int(x), Value::Float(y)) => Value::Float(*x as f64 + *y), (Value::Float(x), Value::Int(y)) => Value::Float(*x + *y as f64), (Value::Float(x), Value::Float(y)) => Value::Float(x + y), _ => Value::Null }); } __for_first_129 = false; i.as_f64().unwrap_or(f64::NAN) < ((arrayData.len() as i64) as f64) } {
5211            let mut itemOrItems: Value = <Self as crate::exchange_generated::ExchangeBase>::parse_ledger_entry(self, arrayData.as_array().and_then(|__arr| match &i { Value::Int(__n) => __arr.get(*__n as usize), Value::Str(__s) => __s.parse::<usize>().ok().and_then(|__n| __arr.get(__n)), _ => None }).cloned().unwrap_or(Value::Null), &[currency.clone()]);
5212            if (matches!(&itemOrItems, Value::Arr(_))) {
5213                {
5214                                        let mut j: Value = Value::Int(0);
5215                    let mut __for_first_128: bool = true;
5216                    while { if !__for_first_128 { j = (match (&(j), &(Value::Int(1))) { (Value::Int(x), Value::Int(y)) => Value::Int(x + y), (Value::Int(x), Value::Float(y)) => Value::Float(*x as f64 + *y), (Value::Float(x), Value::Int(y)) => Value::Float(*x + *y as f64), (Value::Float(x), Value::Float(y)) => Value::Float(x + y), _ => Value::Null }); } __for_first_128 = false; j.as_f64().unwrap_or(f64::NAN) < get_array_length(&itemOrItems).as_f64().unwrap_or(f64::NAN) } {
5217                    append_to_array(&mut result, self.extend(get_value(&itemOrItems, &j), &[params.clone()]));
5218                }
5219                }
5220            }  else {
5221                append_to_array(&mut result, self.extend(itemOrItems, &[params.clone()]));
5222            }
5223        }
5224        }
5225        result = self.sort_by(result.clone(), Value::Str("timestamp".into()), &[]);
5226        let mut code: Value = (if (currency != Value::Null) { currency.as_map().and_then(|__m| __m.get("code")).cloned().unwrap_or(Value::Null) } else { Value::Null });
5227        return self.filter_by_currency_since_limit(result, &[code, since, limit]);
5228
5229    Value::Null
5230}
5231
5232    fn nonce(&self) -> Value {
5233        // virtual-dispatch (static: DerivedExchange::nonce(self, ...))
5234        { let __v = crate::exchange::DerivedExchange::nonce(self, ); if !matches!(__v, crate::Value::Null) { return __v; } }
5235
5236        return self.seconds();
5237
5238    Value::Null
5239}
5240
5241/*
5242 * @method
5243 * @ignore
5244 * @name Exchange#incrementingNonce
5245 * @description returns a strictly-increasing nonce for venues that reject duplicate nonces per signer; the unit is whatever nonce () returns — the base default is seconds, so a venue that does not override nonce () gets a second-resolution counter that drifts ahead of wall clock under load, while venues needing milliseconds override nonce () as hyperliquid does. The counter is per exchange instance, so it narrows the duplicate-nonce race but does not remove it across instances or processes.
5246 * @returns {int} a strictly-increasing nonce in the unit returned by nonce ()
5247 */
5248    fn incrementing_nonce(&mut self) -> Value {
5249        let mut currentNonce: Value = <Self as crate::exchange_generated::ExchangeBase>::nonce(self, );
5250        self.lock_last_nonce(&[]);
5251        let mut lastNonce: Value = self.safe_integer_k(self.options.clone(), "lastNonce", &[Value::Int(0)]);
5252        let mut result: Value = (if (currentNonce.as_f64().unwrap_or(f64::NAN) > lastNonce.as_f64().unwrap_or(f64::NAN)) { currentNonce } else { (match (&(lastNonce), &(Value::Int(1))) { (Value::Int(x), Value::Int(y)) => Value::Int(x + y), (Value::Int(x), Value::Float(y)) => Value::Float(*x as f64 + *y), (Value::Float(x), Value::Int(y)) => Value::Float(*x + *y as f64), (Value::Float(x), Value::Float(y)) => Value::Float(x + y), _ => Value::Null }) });
5253        if let Value::Dict(__d) = &mut self.options { std::sync::Arc::make_mut(__d).insert("lastNonce".into(), result.clone()); }
5254        self.unlock_last_nonce(&[]);
5255        return result;
5256
5257    Value::Null
5258}
5259
5260    fn set_headers(&self, mut headers: Value) -> Value {
5261        return headers;
5262
5263    Value::Null
5264}
5265
5266    fn currency_id(&self, mut code: Value) -> Value {
5267        if (code == Value::Null) {
5268            return code;
5269        }
5270        let mut currency: Value = self.safe_dict(self.currencies.clone(), code.clone(), &[]);
5271        if (currency == Value::Null) {
5272            currency = self.safe_currency(code.clone(), &[]);
5273        }
5274        if (currency != Value::Null) {
5275            return currency.as_map().and_then(|__m| __m.get("id")).cloned().unwrap_or(Value::Null);
5276        }
5277        return code;
5278
5279    Value::Null
5280}
5281
5282    fn market_id(&self, mut symbol: Value) -> Value {
5283        let mut market: Value = <Self as crate::exchange_generated::ExchangeBase>::market(self, symbol.clone());
5284        if (market != Value::Null) {
5285            return market.as_map().and_then(|__m| __m.get("id")).cloned().unwrap_or(Value::Null);
5286        }
5287        return symbol;
5288
5289    Value::Null
5290}
5291
5292    fn symbol(&self, mut symbol: Value) -> Value {
5293        if (symbol == Value::Null) {
5294            panic!("{}", crate::exchange_errors::arguments_required(format!("{}{}", self.id.clone(), Value::Str(" symbol() requires a symbol argument".into()))));
5295        }
5296        let mut market: Value = <Self as crate::exchange_generated::ExchangeBase>::market(self, symbol.clone());
5297        return self.safe_string_k(market, "symbol", &[symbol]);
5298
5299    Value::Null
5300}
5301
5302/* eslint-disable no-unused-vars */
5303/* eslint-enable no-unused-vars */
5304    fn handle_param_string(&self, mut params: Value, mut paramName: Value, optional_args: &[Value]) -> Value {
5305        let mut defaultValue = get_arg(optional_args, 0, Value::Null);
5306        let mut value: Value = self.safe_string(params.clone(), paramName.clone(), &[defaultValue]);
5307        let mut paramsOmitted: Value = (if (value != Value::Null) { self.omit(params.clone(), paramName, &[]) } else { params });
5308        return Value::from(vec![value, paramsOmitted]);
5309
5310    Value::Null
5311}
5312
5313/* eslint-disable no-unused-vars */
5314/* eslint-enable no-unused-vars */
5315    fn handle_param_string2(&self, mut params: Value, mut paramName1: Value, mut paramName2: Value, optional_args: &[Value]) -> Value {
5316        let mut defaultValue = get_arg(optional_args, 0, Value::Null);
5317        let mut value: Value = self.safe_string2(params.clone(), paramName1.clone(), paramName2.clone(), &[defaultValue]);
5318        let mut paramsOmitted: Value = (if (value != Value::Null) { self.omit(params.clone(), Value::from(vec![paramName1, paramName2]), &[]) } else { params });
5319        return Value::from(vec![value, paramsOmitted]);
5320
5321    Value::Null
5322}
5323
5324    fn handle_param_integer(&self, mut params: Value, mut paramName: Value, optional_args: &[Value]) -> Value {
5325        let mut defaultValue = get_arg(optional_args, 0, Value::Null);
5326        let mut value: Value = self.safe_integer(params.clone(), paramName.clone(), &[defaultValue]);
5327        let mut paramsOmitted: Value = (if (value != Value::Null) { self.omit(params.clone(), paramName, &[]) } else { params });
5328        return Value::from(vec![value, paramsOmitted]);
5329
5330    Value::Null
5331}
5332
5333    fn handle_param_integer2(&self, mut params: Value, mut paramName1: Value, mut paramName2: Value, optional_args: &[Value]) -> Value {
5334        let mut defaultValue = get_arg(optional_args, 0, Value::Null);
5335        let mut value: Value = self.safe_integer2(params.clone(), paramName1.clone(), paramName2.clone(), &[defaultValue]);
5336        let mut paramsOmitted: Value = (if (value != Value::Null) { self.omit(params.clone(), Value::from(vec![paramName1, paramName2]), &[]) } else { params });
5337        return Value::from(vec![value, paramsOmitted]);
5338
5339    Value::Null
5340}
5341
5342    fn handle_param_bool(&self, mut params: Value, mut paramName: Value, optional_args: &[Value]) -> Value {
5343        let mut defaultValue = get_arg(optional_args, 0, Value::Null);
5344        let mut value: Value = self.safe_bool(params.clone(), paramName.clone(), &[defaultValue]);
5345        let mut paramsOmitted: Value = (if (value != Value::Null) { self.omit(params.clone(), paramName, &[]) } else { params });
5346        return Value::from(vec![value, paramsOmitted]);
5347
5348    Value::Null
5349}
5350
5351    fn handle_param_bool2(&self, mut params: Value, mut paramName1: Value, mut paramName2: Value, optional_args: &[Value]) -> Value {
5352        let mut defaultValue = get_arg(optional_args, 0, Value::Null);
5353        let mut value: Value = self.safe_bool2(params.clone(), paramName1.clone(), paramName2.clone(), &[defaultValue]);
5354        let mut paramsOmitted: Value = (if (value != Value::Null) { self.omit(params.clone(), Value::from(vec![paramName1, paramName2]), &[]) } else { params });
5355        return Value::from(vec![value, paramsOmitted]);
5356
5357    Value::Null
5358}
5359
5360    fn resolve_path(&self, mut path: Value, mut params: Value) -> Value {
5361        return Value::from(vec![self.implode_params(path.clone(), params.clone()), self.omit(params, self.extract_params(path), &[])]);
5362
5363    Value::Null
5364}
5365
5366    fn get_list_from_object_values(&self, mut objects: Value, mut key: Value) -> Value {
5367        let mut newArray: Value = objects.clone();
5368        if !(matches!(&objects, Value::Arr(_))) {
5369            newArray = self.to_array(objects.clone());
5370        }
5371        let mut results: Value = Value::from(vec![]);
5372        {
5373                        let mut i: Value = Value::Int(0);
5374            let mut __for_first_130: bool = true;
5375            while { if !__for_first_130 { i = (match (&(i), &(Value::Int(1))) { (Value::Int(x), Value::Int(y)) => Value::Int(x + y), (Value::Int(x), Value::Float(y)) => Value::Float(*x as f64 + *y), (Value::Float(x), Value::Int(y)) => Value::Float(*x + *y as f64), (Value::Float(x), Value::Float(y)) => Value::Float(x + y), _ => Value::Null }); } __for_first_130 = false; i.as_f64().unwrap_or(f64::NAN) < get_array_length(&newArray).as_f64().unwrap_or(f64::NAN) } {
5376            append_to_array(&mut results, get_value(&get_value(&newArray, &i), &key));
5377        }
5378        }
5379        return results;
5380
5381    Value::Null
5382}
5383
5384    fn get_symbols_for_market_type(&self, optional_args: &[Value]) -> Value {
5385        let mut marketType = get_arg(optional_args, 0, Value::Null);
5386        let mut subType = get_arg(optional_args, 1, Value::Null);
5387        let mut symbolWithActiveStatus = get_arg(optional_args, 2, Value::Bool(true));
5388        let mut symbolWithUnknownStatus = get_arg(optional_args, 3, Value::Bool(true));
5389        let mut filteredMarkets: Value = self.markets.clone();
5390        if (marketType != Value::Null) {
5391            filteredMarkets = self.filter_by(filteredMarkets.clone(), Value::Str("type".into()), marketType, &[]);
5392        }
5393        if (subType != Value::Null) {
5394            self.check_required_argument(Value::Str("getSymbolsForMarketType".into()), subType.clone(), Value::Str("subType".into()), &[Value::from(vec![Value::Str("linear".into()), Value::Str("inverse".into()), Value::Str("quanto".into())])]);
5395            filteredMarkets = self.filter_by(filteredMarkets.clone(), Value::Str("subType".into()), subType, &[]);
5396        }
5397        let mut activeStatuses: Value = Value::from(vec![]);
5398        if is_true(&symbolWithActiveStatus) {
5399            append_to_array(&mut activeStatuses, Value::Bool(true));
5400        }
5401        if is_true(&symbolWithUnknownStatus) {
5402            append_to_array(&mut activeStatuses, Value::Null);
5403        }
5404        filteredMarkets = self.filter_by_array(filteredMarkets.clone(), Value::Str("active".into()), &[activeStatuses, Value::Bool(false)]);
5405        return self.get_list_from_object_values(filteredMarkets, Value::Str("symbol".into()));
5406
5407    Value::Null
5408}
5409
5410    fn filter_by_array(&self, mut objects: Value, mut key: Value, optional_args: &[Value]) -> Value {
5411        let mut values = get_arg(optional_args, 0, Value::Null);
5412        let mut indexed = get_arg(optional_args, 1, Value::Bool(true));
5413        let mut objectsValue: Value = self.to_array(objects);
5414        // return all of them if no values were passed
5415        if (values == Value::Null) || (values == Value::Null) || (is_equal(&values, &Value::Bool(false))) || (is_equal(&values, &Value::Int(0))) || (values.as_str() == Some("")) {
5416            // return indexed ? this.indexBy (objects, key) : objects;
5417            if is_true(&indexed) {
5418                return self.index_by(objectsValue.clone(), key.clone());
5419            }  else {
5420                return objectsValue;
5421            }
5422        }
5423        let mut results: Value = Value::from(vec![]);
5424        {
5425                        let mut i: Value = Value::Int(0);
5426            let mut __for_first_131: bool = true;
5427            while { if !__for_first_131 { i = (match (&(i), &(Value::Int(1))) { (Value::Int(x), Value::Int(y)) => Value::Int(x + y), (Value::Int(x), Value::Float(y)) => Value::Float(*x as f64 + *y), (Value::Float(x), Value::Int(y)) => Value::Float(*x + *y as f64), (Value::Float(x), Value::Float(y)) => Value::Float(x + y), _ => Value::Null }); } __for_first_131 = false; i.as_f64().unwrap_or(f64::NAN) < get_array_length(&objectsValue).as_f64().unwrap_or(f64::NAN) } {
5428            if self.in_array(get_value(&get_value(&objectsValue, &i), &key), values.clone()).as_bool() == Some(true) {
5429                append_to_array(&mut results, get_value(&objectsValue, &i));
5430            }
5431        }
5432        }
5433        // return indexed ? this.indexBy (results, key) : results;
5434        if is_true(&indexed) {
5435            return self.index_by(results.clone(), key);
5436        }
5437        return results;
5438
5439    Value::Null
5440}
5441
5442    fn filter_out_by_array(&self, mut objects: Value, mut key: Value, optional_args: &[Value]) -> Value {
5443        let mut values = get_arg(optional_args, 0, Value::Null);
5444        let mut indexed = get_arg(optional_args, 1, Value::Bool(true));
5445        let mut objectsValue: Value = self.to_array(objects);
5446        // return all of them if no values were passed
5447        if (values == Value::Null) || (values == Value::Null) || (is_equal(&values, &Value::Bool(false))) || (is_equal(&values, &Value::Int(0))) || (values.as_str() == Some("")) {
5448            // return indexed ? this.indexBy (objects, key) : objects;
5449            if is_true(&indexed) {
5450                return self.index_by(objectsValue.clone(), key.clone());
5451            }  else {
5452                return objectsValue;
5453            }
5454        }
5455        let mut results: Value = Value::from(vec![]);
5456        {
5457                        let mut i: Value = Value::Int(0);
5458            let mut __for_first_132: bool = true;
5459            while { if !__for_first_132 { i = (match (&(i), &(Value::Int(1))) { (Value::Int(x), Value::Int(y)) => Value::Int(x + y), (Value::Int(x), Value::Float(y)) => Value::Float(*x as f64 + *y), (Value::Float(x), Value::Int(y)) => Value::Float(*x + *y as f64), (Value::Float(x), Value::Float(y)) => Value::Float(x + y), _ => Value::Null }); } __for_first_132 = false; i.as_f64().unwrap_or(f64::NAN) < get_array_length(&objectsValue).as_f64().unwrap_or(f64::NAN) } {
5460            if !(self.in_array(get_value(&get_value(&objectsValue, &i), &key), values.clone()).as_bool() == Some(true)) {
5461                append_to_array(&mut results, get_value(&objectsValue, &i));
5462            }
5463        }
5464        }
5465        // return indexed ? this.indexBy (results, key) : results;
5466        if is_true(&indexed) {
5467            return self.index_by(results.clone(), key);
5468        }
5469        return results;
5470
5471    Value::Null
5472}
5473
5474    fn fetch2(&mut self, mut path: Value, optional_args: &[Value]) -> impl ::std::future::Future<Output = Value> + Send { async move {
5475        let mut api = get_arg(optional_args, 0, Value::from(vec![Value::Str("public".into())]));
5476        let mut method = get_arg(optional_args, 1, Value::Str("GET".into()));
5477        let mut params = get_arg(optional_args, 2, Value::Map({
5478    let mut m = indexmap::IndexMap::new();
5479    m
5480}));
5481        let mut config = get_arg(optional_args, 3, Value::Map({
5482    let mut m = indexmap::IndexMap::new();
5483    m
5484}));
5485        if is_true(&self.enableRateLimit) {
5486            let mut cost: Value = self.calculate_rate_limiter_cost(api.clone(), method.clone(), path.clone(), params.clone(), &[config]);
5487            self.throttle(&[cost]).await;
5488        }
5489        let mut retries: Value = Value::Int(0);
5490        // implicit endpoints may pass a list body as params: keep it an untyped box
5491        let mut requestParams: Value = params;
5492        let mut retriesMaxRetriesOnFailureparamsMaxRetriesOnFailureVariable = self.handle_option_integer_and_params(requestParams, path.clone(), Value::Str("maxRetriesOnFailure".into()), &[retries]);
5493        let mut retriesMaxRetriesOnFailure: Value = retriesMaxRetriesOnFailureparamsMaxRetriesOnFailureVariable.as_array().and_then(|__arr| __arr.get(0)).cloned().unwrap_or(Value::Null);
5494        let mut paramsMaxRetriesOnFailure: Value = retriesMaxRetriesOnFailureparamsMaxRetriesOnFailureVariable.as_array().and_then(|__arr| __arr.get(1)).cloned().unwrap_or(Value::Null);
5495        let mut retryDelay: Value = Value::Int(0);
5496        let mut retryDelayMaxRetriesOnFailureDelayparamsMaxRetriesOnFailureDelayVariable = self.handle_option_integer_and_params(paramsMaxRetriesOnFailure, path.clone(), Value::Str("maxRetriesOnFailureDelay".into()), &[retryDelay]);
5497        let mut retryDelayMaxRetriesOnFailureDelay: Value = retryDelayMaxRetriesOnFailureDelayparamsMaxRetriesOnFailureDelayVariable.as_array().and_then(|__arr| __arr.get(0)).cloned().unwrap_or(Value::Null);
5498        let mut paramsMaxRetriesOnFailureDelay: Value = retryDelayMaxRetriesOnFailureDelayparamsMaxRetriesOnFailureDelayVariable.as_array().and_then(|__arr| __arr.get(1)).cloned().unwrap_or(Value::Null);
5499        let mut fetchDataCacheEnabled: bool = self.fetchHistoryCacheSize.as_f64().unwrap_or(f64::NAN) > ((0i64) as f64);
5500        {
5501                        let mut i: Value = Value::Int(0);
5502            let mut __for_first_133: bool = true;
5503            while { if !__for_first_133 { i = (match (&(i), &(Value::Int(1))) { (Value::Int(x), Value::Int(y)) => Value::Int(x + y), (Value::Int(x), Value::Float(y)) => Value::Float(*x as f64 + *y), (Value::Float(x), Value::Int(y)) => Value::Float(*x + *y as f64), (Value::Float(x), Value::Float(y)) => Value::Float(x + y), _ => Value::Null }); } __for_first_133 = false; i.as_f64().unwrap_or(f64::NAN) < add(&retriesMaxRetriesOnFailure, &Value::Int(1)).as_f64().unwrap_or(f64::NAN) } {
5504            let mut fetchData: Value = Value::Null;
5505            if fetchDataCacheEnabled {
5506                fetchData = Value::Map({
5507                    let mut m = indexmap::IndexMap::new();
5508                        m.insert("request".to_string(), Value::Null);
5509                        m.insert("response".to_string(), Value::Map({
5510    let mut m = indexmap::IndexMap::new();
5511        m.insert("body".to_string(), Value::Null);
5512    m
5513}));
5514                        m.insert("error".to_string(), Value::Null);
5515                    m
5516                });
5517            }
5518            let _try_result = futures::FutureExt::catch_unwind(std::panic::AssertUnwindSafe(async {
5519                self.set_last_rest_request_timestamp();
5520                let mut request: Value = <Self as crate::exchange_generated::ExchangeBase>::sign(self, path.clone(), &[api.clone(), method.clone(), paramsMaxRetriesOnFailureDelay.clone()]);
5521                if (fetchData != Value::Null) {
5522                    add_element_to_object(&mut fetchData, &Value::Str("request".into()), request.clone());
5523                }
5524                self.set_last_request(request.clone());
5525                let mut response: Value = self.fetch(request.as_map().and_then(|__m| __m.get("url")).cloned().unwrap_or(Value::Null), &[request.as_map().and_then(|__m| __m.get("method")).cloned().unwrap_or(Value::Null), request.as_map().and_then(|__m| __m.get("headers")).cloned().unwrap_or(Value::Null), request.as_map().and_then(|__m| __m.get("body")).cloned().unwrap_or(Value::Null)]).await;
5526                if (fetchData != Value::Null) {
5527                    add_element_to_object(get_value_mut(&mut fetchData, &Value::Str("response".into())), &Value::Str("body".into()), response.clone());
5528                    self.add_fetch_cache(fetchData.clone());
5529                }
5530                return response;
5531             #[allow(unreachable_code)] { Value::Null }})).await;
5532match _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); 
5533                if (fetchData != Value::Null) {
5534                    add_element_to_object(&mut fetchData, &Value::Str("error".into()), e.clone());
5535                    self.add_fetch_cache(fetchData);
5536                }
5537                if is_instance(&e, &Value::Str("OperationFailed".into())) {
5538                    if i.as_f64().unwrap_or(f64::NAN) < retriesMaxRetriesOnFailure.as_f64().unwrap_or(f64::NAN) {
5539                        if is_true(&self.verbose) {
5540                            let mut index: Value = (match (&(i), &(Value::Int(1))) { (Value::Int(x), Value::Int(y)) => Value::Int(x + y), (Value::Int(x), Value::Float(y)) => Value::Float(*x as f64 + *y), (Value::Float(x), Value::Int(y)) => Value::Float(*x + *y as f64), (Value::Float(x), Value::Float(y)) => Value::Float(x + y), _ => Value::Null });
5541                            self.log(Value::Str(format!("{}{}", Value::Str(format!("{}{}", Value::Str(format!("{}{}", Value::Str(format!("{}{}", Value::Str(format!("{}{}", Value::Str(format!("{}{}", Value::Str("Request failed with the error: ".into()), to_string_val(&e)).into()), Value::Str(", retrying ".into())).into()), to_string_val(&index)).into()), Value::Str(" of ".into())).into()), to_string_val(&retriesMaxRetriesOnFailure)).into()), Value::Str("...".into())).into()));
5542                        }
5543                        if (retryDelayMaxRetriesOnFailureDelay != Value::Null) && (retryDelayMaxRetriesOnFailureDelay.as_f64() != Some(0.0)) {
5544                            self.sleep(retryDelayMaxRetriesOnFailureDelay.clone()).await;
5545                        }
5546                    }  else {
5547                        panic!("{}", e);
5548                    }
5549                }  else {
5550                    panic!("{}", e);
5551                }
5552             } }
5553        }
5554        }
5555        return Value::Null;
5556
5557    Value::Null
5558} }
5559
5560    fn request(&mut self, mut path: Value, optional_args: &[Value]) -> impl ::std::future::Future<Output = Value> + Send { async move {
5561        let mut api = get_arg(optional_args, 0, Value::from(vec![Value::Str("public".into())]));
5562        let mut method = get_arg(optional_args, 1, Value::Str("GET".into()));
5563        let mut params = get_arg(optional_args, 2, Value::Map({
5564    let mut m = indexmap::IndexMap::new();
5565    m
5566}));
5567        let mut config = get_arg(optional_args, 3, Value::Map({
5568    let mut m = indexmap::IndexMap::new();
5569    m
5570}));
5571        return self.fetch2(path, &[api, method, params, config]).await;
5572
5573    Value::Null
5574} }
5575
5576    fn load_accounts(&mut self, optional_args: &[Value]) -> impl ::std::future::Future<Output = Value> + Send { async move {
5577        let mut reload = get_arg(optional_args, 0, Value::Bool(false));
5578        let mut params = get_arg(optional_args, 1, Value::Map({
5579    let mut m = indexmap::IndexMap::new();
5580    m
5581}));
5582        if is_true(&reload) {
5583            { let __t = self.fetch_accounts(&[params.clone()]).await; self.accounts = __t; }
5584        }  else {
5585            if (self.accounts.clone() != Value::Null) {
5586                return self.accounts.clone();
5587            }  else {
5588                { let __t = self.fetch_accounts(&[params]).await; self.accounts = __t; }
5589            }
5590        }
5591        { let __t = self.index_by(self.accounts.clone(), Value::Str("id".into())); self.accountsById = __t; }
5592        return self.accounts.clone();
5593
5594    Value::Null
5595} }
5596
5597    fn build_ohlcvc(&self, mut trades: Value, optional_args: &[Value]) -> Value {
5598        let mut timeframe = get_arg(optional_args, 0, Value::Str("1m".into()));
5599        let mut since = get_arg(optional_args, 1, Value::Int(0));
5600        let mut limit = get_arg(optional_args, 2, Value::Int(2147483647));
5601        // given a sorted arrays of trades (recent last) and a timeframe builds an array of OHLCV candles
5602        // note, default limit value (2147483647) is max int32 value
5603        let mut ms: Value = (match (&(self.parse_timeframe(timeframe)), &(Value::Int(1000))) { (Value::Int(x), Value::Int(y)) => Value::Int(x * y), (Value::Int(x), Value::Float(y)) => Value::Float(*x as f64 * *y), (Value::Float(x), Value::Int(y)) => Value::Float(*x * *y as f64), (Value::Float(x), Value::Float(y)) => Value::Float(x * y), _ => Value::Null });
5604        let mut ohlcvs: Value = Value::from(vec![]);
5605        let mut i_timestamp: Value = Value::Int(0);
5606        // const open = 1;
5607        let mut i_high: Value = Value::Int(2);
5608        let mut i_low: Value = Value::Int(3);
5609        let mut i_close: Value = Value::Int(4);
5610        let mut i_volume: Value = Value::Int(5);
5611        let mut i_count: Value = Value::Int(6);
5612        let mut tradesLength: Value = Value::Int(trades.len() as i64);
5613        let mut oldest: Value = crate::runtime::Math::min(&tradesLength, &limit);
5614        let mut options: Value = self.safe_dict_k(self.options.clone(), "buildOHLCVC", &[Value::Map({
5615    let mut m = indexmap::IndexMap::new();
5616    m
5617})]);
5618        let mut skipZeroPrices: Value = self.safe_bool_k(options, "skipZeroPrices", &[Value::Bool(true)]);
5619        {
5620                        let mut i: Value = Value::Int(0);
5621            let mut __for_first_134: bool = true;
5622            while { if !__for_first_134 { i = (match (&(i), &(Value::Int(1))) { (Value::Int(x), Value::Int(y)) => Value::Int(x + y), (Value::Int(x), Value::Float(y)) => Value::Float(*x as f64 + *y), (Value::Float(x), Value::Int(y)) => Value::Float(*x + *y as f64), (Value::Float(x), Value::Float(y)) => Value::Float(x + y), _ => Value::Null }); } __for_first_134 = false; i.as_f64().unwrap_or(f64::NAN) < oldest.as_f64().unwrap_or(f64::NAN) } {
5623            let mut trade: Value = trades.as_array().and_then(|__arr| match &i { Value::Int(__n) => __arr.get(*__n as usize), Value::Str(__s) => __s.parse::<usize>().ok().and_then(|__n| __arr.get(__n)), _ => None }).cloned().unwrap_or(Value::Null);
5624            let mut ts: Value = trade.as_map().and_then(|__m| __m.get("timestamp")).cloned().unwrap_or(Value::Null);
5625            let mut price: Value = trade.as_map().and_then(|__m| __m.get("price")).cloned().unwrap_or(Value::Null);
5626            if (ts == Value::Null) || (price == Value::Null) {
5627                continue;
5628            }
5629            if ts.as_f64().unwrap_or(f64::NAN) < since.as_f64().unwrap_or(f64::NAN) {
5630                continue;
5631            }
5632            if (ts == Value::Null) {
5633                panic!("{}", crate::exchange_errors::exchange_error(format!("{}{}", self.id.clone(), Value::Str(" buildOHLCVC() missing ts".into()))));
5634            }
5635            let mut openingTime: Value = (match (&(math_floor(&(match ((ts).as_f64(), (ms).as_f64()) { (Some(x), Some(y)) if y != 0.0 => Value::Float(x / y), _ => Value::Null }))), &(ms)) { (Value::Int(x), Value::Int(y)) => Value::Int(x * y), (Value::Int(x), Value::Float(y)) => Value::Float(*x as f64 * *y), (Value::Float(x), Value::Int(y)) => Value::Float(*x * *y as f64), (Value::Float(x), Value::Float(y)) => Value::Float(x * y), _ => Value::Null }); // shift to the edge of m/h/d (but not M)
5636            if openingTime.as_f64().unwrap_or(f64::NAN) < since.as_f64().unwrap_or(f64::NAN) {
5637                continue;
5638            }
5639            let mut ohlcv_length: Value = Value::Int(ohlcvs.len() as i64);
5640            let mut candle: Value = (match (&(ohlcv_length), &(Value::Int(1))) { (Value::Int(x), Value::Int(y)) => Value::Int(x - y), (Value::Int(x), Value::Float(y)) => Value::Float(*x as f64 - *y), (Value::Float(x), Value::Int(y)) => Value::Float(*x - *y as f64), (Value::Float(x), Value::Float(y)) => Value::Float(x - y), _ => Value::Null });
5641            if (price == Value::Null) {
5642                panic!("{}", crate::exchange_errors::arguments_required(format!("{}{}", self.id.clone(), Value::Str(" buildOHLCVC() requires a price argument".into()))));
5643            }
5644            if (skipZeroPrices.as_bool() == Some(true)) && !(price.as_f64().unwrap_or(f64::NAN) > ((0i64) as f64)) && !(price.as_f64().unwrap_or(f64::NAN) < ((0i64) as f64)) {
5645                continue;
5646            }
5647            let mut isNewCandle: bool = candle.as_f64() == Value::Int(-1).as_f64();
5648            if !isNewCandle {
5649                let mut candleTimestamp: Value = get_value(&ohlcvs, &candle).as_array().and_then(|__arr| match &i_timestamp { Value::Int(__n) => __arr.get(*__n as usize), Value::Str(__s) => __s.parse::<usize>().ok().and_then(|__n| __arr.get(__n)), _ => None }).cloned().unwrap_or(Value::Null);
5650                if (candleTimestamp == Value::Null) {
5651                    panic!("{}", crate::exchange_errors::exchange_error(format!("{}{}", self.id.clone(), Value::Str(" buildOHLCVC() missing candle timestamp".into()))));
5652                }
5653                isNewCandle = openingTime.as_f64().unwrap_or(f64::NAN) >= (match (&(candleTimestamp), &(ms)) { (Value::Int(x), Value::Int(y)) => Value::Int(x + y), (Value::Int(x), Value::Float(y)) => Value::Float(*x as f64 + *y), (Value::Float(x), Value::Int(y)) => Value::Float(*x + *y as f64), (Value::Float(x), Value::Float(y)) => Value::Float(x + y), _ => Value::Null }).as_f64().unwrap_or(f64::NAN);
5654            }
5655            if isNewCandle {
5656                // moved to a new timeframe -> create a new candle from opening trade
5657                append_to_array(&mut ohlcvs, Value::from(vec![openingTime, price.clone(), price.clone(), price.clone(), price.clone(), trade.as_map().and_then(|__m| __m.get("amount")).cloned().unwrap_or(Value::Null), Value::Int(1)]));
5658            }  else {
5659                // still processing the same timeframe -> update opening trade
5660                let mut prevHigh: Value = get_value(&ohlcvs, &candle).as_array().and_then(|__arr| match &i_high { Value::Int(__n) => __arr.get(*__n as usize), Value::Str(__s) => __s.parse::<usize>().ok().and_then(|__n| __arr.get(__n)), _ => None }).cloned().unwrap_or(Value::Null);
5661                let mut prevLow: Value = get_value(&ohlcvs, &candle).as_array().and_then(|__arr| match &i_low { Value::Int(__n) => __arr.get(*__n as usize), Value::Str(__s) => __s.parse::<usize>().ok().and_then(|__n| __arr.get(__n)), _ => None }).cloned().unwrap_or(Value::Null);
5662                let mut prevHighValue: Value = (if (prevHigh == Value::Null) { price.clone() } else { prevHigh });
5663                let mut prevLowValue: Value = (if (prevLow == Value::Null) { price.clone() } else { prevLow });
5664                add_element_to_object(get_value_mut(&mut ohlcvs, &candle), &i_high, crate::runtime::Math::max(&prevHighValue, &price));
5665                add_element_to_object(get_value_mut(&mut ohlcvs, &candle), &i_low, crate::runtime::Math::min(&prevLowValue, &price));
5666                add_element_to_object(get_value_mut(&mut ohlcvs, &candle), &i_close, price);
5667                { let __be_tmp = self.sum(&[get_value(&get_value(&ohlcvs, &candle), &i_volume), trade.as_map().and_then(|__m| __m.get("amount")).cloned().unwrap_or(Value::Null)]); add_element_to_object(get_value_mut(&mut ohlcvs, &candle), &i_volume, __be_tmp); };
5668                { 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); };
5669            }
5670        }
5671        }
5672        return ohlcvs;
5673
5674    Value::Null
5675}
5676
5677    fn parse_trading_view_ohlcv(&self, mut ohlcvs: Value, optional_args: &[Value]) -> Value {
5678        let mut market = get_arg(optional_args, 0, Value::Null);
5679        let mut timeframe = get_arg(optional_args, 1, Value::Str("1m".into()));
5680        let mut since = get_arg(optional_args, 2, Value::Null);
5681        let mut limit = get_arg(optional_args, 3, Value::Null);
5682        let mut result: Value = self.convert_trading_view_to_ohlcv(ohlcvs, &[]);
5683        return self.parse_ohlc_vs(result, &[market, timeframe, since, limit]);
5684
5685    Value::Null
5686}
5687
5688    fn fetch_borrow_interest(&mut self, optional_args: &[Value]) -> impl ::std::future::Future<Output = Value> + Send { async move {
5689        let mut code = get_arg(optional_args, 0, Value::Null);
5690        let mut symbol = get_arg(optional_args, 1, Value::Null);
5691        let mut since = get_arg(optional_args, 2, Value::Null);
5692        let mut limit = get_arg(optional_args, 3, Value::Null);
5693        let mut params = get_arg(optional_args, 4, Value::Map({
5694    let mut m = indexmap::IndexMap::new();
5695    m
5696}));
5697        panic!("{}", crate::exchange_errors::not_supported(format!("{}{}", self.id.clone(), Value::Str(" fetchBorrowInterest() is not supported yet".into()))));
5698
5699    Value::Null
5700} }
5701
5702    fn fetch_ledger(&mut self, optional_args: &[Value]) -> impl ::std::future::Future<Output = Value> + Send { async move {
5703        // async-virtual: try the derived exchange first
5704        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 {
5705            if !matches!(__v, crate::Value::Null) { return __v; }
5706        }
5707
5708        let mut code = get_arg(optional_args, 0, Value::Null);
5709        let mut since = get_arg(optional_args, 1, Value::Null);
5710        let mut limit = get_arg(optional_args, 2, Value::Null);
5711        let mut params = get_arg(optional_args, 3, Value::Map({
5712    let mut m = indexmap::IndexMap::new();
5713    m
5714}));
5715        panic!("{}", crate::exchange_errors::not_supported(format!("{}{}", self.id.clone(), Value::Str(" fetchLedger() is not supported yet".into()))));
5716
5717    Value::Null
5718} }
5719
5720    fn fetch_ledger_entry(&mut self, mut id: Value, optional_args: &[Value]) -> impl ::std::future::Future<Output = Value> + Send { async move {
5721        let mut code = get_arg(optional_args, 0, Value::Null);
5722        let mut params = get_arg(optional_args, 1, Value::Map({
5723    let mut m = indexmap::IndexMap::new();
5724    m
5725}));
5726        panic!("{}", crate::exchange_errors::not_supported(format!("{}{}", self.id.clone(), Value::Str(" fetchLedgerEntry() is not supported yet".into()))));
5727
5728    Value::Null
5729} }
5730
5731    fn parse_order_book_bid_ask(&self, mut bidask: Value, optional_args: &[Value]) -> Value {
5732        let mut priceKey = get_arg(optional_args, 0, Value::Int(0));
5733        let mut amountKey = get_arg(optional_args, 1, Value::Int(1));
5734        let mut countOrIdKey = get_arg(optional_args, 2, Value::Int(2));
5735        let mut price: Value = self.safe_float(bidask.clone(), priceKey, &[]);
5736        let mut amount: Value = self.safe_float(bidask.clone(), amountKey, &[]);
5737        let mut countOrId: Value = self.safe_integer(bidask, countOrIdKey, &[]);
5738        let mut bidAsk: Value = Value::from(vec![price, amount]);
5739        if (countOrId != Value::Null) {
5740            append_to_array(&mut bidAsk, countOrId);
5741        }
5742        return bidAsk;
5743
5744    Value::Null
5745}
5746
5747    fn parse_order_book_bid_ask_l3(&self, mut bidask: Value, optional_args: &[Value]) -> Value {
5748        let mut priceKey = get_arg(optional_args, 0, Value::Int(0));
5749        let mut amountKey = get_arg(optional_args, 1, Value::Int(1));
5750        let mut countOrIdKey = get_arg(optional_args, 2, Value::Int(2));
5751        let mut price: Value = self.safe_float(bidask.clone(), priceKey, &[]);
5752        let mut amount: Value = self.safe_float(bidask.clone(), amountKey, &[]);
5753        let mut countOrId: Value = self.safe_string(bidask, countOrIdKey, &[]);
5754        let mut bidAsk: Value = Value::from(vec![price, amount]);
5755        if (countOrId != Value::Null) {
5756            append_to_array(&mut bidAsk, countOrId);
5757        }
5758        return bidAsk;
5759
5760    Value::Null
5761}
5762
5763    fn safe_currency(&self, mut currencyId: Value, optional_args: &[Value]) -> Value {
5764        let mut currency = get_arg(optional_args, 0, Value::Null);
5765        if (currencyId == Value::Null) && (currency != Value::Null) {
5766            return currency;
5767        }
5768        if (currencyId != Value::Null) && (self.currencies_by_id.clone() != Value::Null) && (in_op(&self.currencies_by_id, &currencyId)) && (get_value(&self.currencies_by_id, &currencyId) != Value::Null) {
5769            return get_value(&self.currencies_by_id, &currencyId);
5770        }
5771        let mut code: Value = currencyId.clone();
5772        if (currencyId != Value::Null) {
5773            code = self.common_currency_code(to_upper(&currencyId));
5774        }
5775        return self.safe_currency_structure(Value::Map({
5776    let mut m = indexmap::IndexMap::new();
5777        m.insert("id".to_string(), currencyId);
5778        m.insert("code".to_string(), code);
5779        m.insert("precision".to_string(), Value::Null);
5780    m
5781}));
5782
5783    Value::Null
5784}
5785
5786    fn safe_market(&self, optional_args: &[Value]) -> Value {
5787        let mut marketId = get_arg(optional_args, 0, Value::Null);
5788        let mut market = get_arg(optional_args, 1, Value::Null);
5789        let mut delimiter = get_arg(optional_args, 2, Value::Null);
5790        let mut marketType = get_arg(optional_args, 3, Value::Null);
5791        if (marketId != Value::Null) {
5792            if (self.markets_by_id.clone() != Value::Null) && (in_op(&self.markets_by_id, &marketId)) {
5793                let mut markets: Value = get_value(&self.markets_by_id, &marketId);
5794                let mut numMarkets: Value = get_array_length(&markets);
5795                if is_equal(&numMarkets, &Value::Int(1)) {
5796                    return get_value(&markets, &Value::Int(0));
5797                }  else {
5798                    if (marketType == Value::Null) && (market == Value::Null) {
5799                        panic!("{}", crate::exchange_errors::arguments_required(format!("{}{}", Value::Str(format!("{}{}", Value::Str(format!("{}{}", self.id.clone(), Value::Str(" safeMarket() requires a fourth argument for ".into())).into()), marketId).into()), Value::Str(" to disambiguate between different markets with the same market id".into()))));
5800                    }
5801                    let mut marketTypeResolved: Value = (if (marketType == Value::Null) { self.safe_string_k(market.clone(), "type", &[Value::Str("".into())]) } else { marketType });
5802                    {
5803                                                let mut i: Value = Value::Int(0);
5804                        let mut __for_first_135: bool = true;
5805                        while { if !__for_first_135 { i = (match (&(i), &(Value::Int(1))) { (Value::Int(x), Value::Int(y)) => Value::Int(x + y), (Value::Int(x), Value::Float(y)) => Value::Float(*x as f64 + *y), (Value::Float(x), Value::Int(y)) => Value::Float(*x + *y as f64), (Value::Float(x), Value::Float(y)) => Value::Float(x + y), _ => Value::Null }); } __for_first_135 = false; i.as_f64().unwrap_or(f64::NAN) < get_array_length(&markets).as_f64().unwrap_or(f64::NAN) } {
5806                        let mut currentMarket: Value = get_value(&markets, &i);
5807                        let mut currentMarket: Value = get_value(&markets, &i);
5808                        if is_equal(&get_value(&currentMarket, &marketTypeResolved), &Value::Bool(true)) {
5809                            return currentMarket;
5810                        }
5811                    }
5812                    }
5813                }
5814            }  else if (delimiter != Value::Null) && (delimiter.as_str() != Some("")) {
5815                let mut parts: Value = split(&marketId, &delimiter);
5816                let mut partsLength: f64 = ((parts.len() as i64) as f64);
5817                let mut result: Value = self.safe_market_structure(&[Value::Map({
5818    let mut m = indexmap::IndexMap::new();
5819        m.insert("symbol".to_string(), marketId.clone());
5820        m.insert("marketId".to_string(), marketId.clone());
5821    m
5822})]);
5823                if (result == Value::Null) {
5824                    panic!("{}", crate::exchange_errors::exchange_error(format!("{}{}", self.id.clone(), Value::Str(" safeMarket() failed to build market structure".into()))));
5825                }
5826                if (partsLength == 2.0) {
5827                    let mut baseId: Value = self.safe_string(parts.clone(), Value::Int(0), &[]);
5828                    let mut quoteId: Value = self.safe_string(parts, Value::Int(1), &[]);
5829                    let mut base: Value = self.safe_currency_code(baseId.clone(), &[]);
5830                    let mut quote: Value = self.safe_currency_code(quoteId.clone(), &[]);
5831                    if let Value::Dict(__d) = &mut result { std::sync::Arc::make_mut(__d).insert("baseId".into(), baseId); }
5832                    if let Value::Dict(__d) = &mut result { std::sync::Arc::make_mut(__d).insert("quoteId".into(), quoteId); }
5833                    if (base != Value::Null) {
5834                        if let Value::Dict(__d) = &mut result { std::sync::Arc::make_mut(__d).insert("base".into(), base.clone()); }
5835                    }
5836                    if (quote != Value::Null) {
5837                        if let Value::Dict(__d) = &mut result { std::sync::Arc::make_mut(__d).insert("quote".into(), quote.clone()); }
5838                    }
5839                    if (base != Value::Null) && (quote != Value::Null) {
5840                        add_element_to_object(&mut result, &Value::Str("symbol".into()), Value::Str(format!("{}{}", Value::Str(format!("{}{}", base, Value::Str("/".into())).into()), quote).into()));
5841                    }
5842                }
5843                return result;
5844            }
5845        }
5846        if (market != Value::Null) {
5847            return market;
5848        }
5849        let mut emptyMarket: Value = self.safe_market_structure(&[Value::Map({
5850    let mut m = indexmap::IndexMap::new();
5851        m.insert("symbol".to_string(), marketId.clone());
5852        m.insert("marketId".to_string(), marketId);
5853    m
5854})]);
5855        if (emptyMarket == Value::Null) {
5856            panic!("{}", crate::exchange_errors::exchange_error(format!("{}{}", self.id.clone(), Value::Str(" safeMarket() failed to build market structure".into()))));
5857        }
5858        return emptyMarket;
5859
5860    Value::Null
5861}
5862
5863    fn market_or_null(&self, optional_args: &[Value]) -> Value {
5864        let mut symbol = get_arg(optional_args, 0, Value::Null);
5865        if (symbol == Value::Null) {
5866            return Value::Null;
5867        }
5868        return <Self as crate::exchange_generated::ExchangeBase>::market(self, symbol);
5869
5870    Value::Null
5871}
5872
5873    fn check_required_credentials(&self, optional_args: &[Value]) -> Value {
5874        let mut error = get_arg(optional_args, 0, Value::Bool(true));
5875        /*
5876         * @ignore
5877         * @method
5878         * @param {boolean} error throw an error that a credential is required if true
5879         * @returns {boolean} true if all required credentials have been set, otherwise false or an error is thrown is param error=true
5880         */
5881        let mut keys: Value = object_keys(&self.requiredCredentials);
5882        {
5883                        let mut i: Value = Value::Int(0);
5884            let mut __for_first_136: bool = true;
5885            while { if !__for_first_136 { i = (match (&(i), &(Value::Int(1))) { (Value::Int(x), Value::Int(y)) => Value::Int(x + y), (Value::Int(x), Value::Float(y)) => Value::Float(*x as f64 + *y), (Value::Float(x), Value::Int(y)) => Value::Float(*x + *y as f64), (Value::Float(x), Value::Float(y)) => Value::Float(x + y), _ => Value::Null }); } __for_first_136 = false; i.as_f64().unwrap_or(f64::NAN) < ((keys.len() as i64) as f64) } {
5886            let mut key: Value = keys.as_array().and_then(|__arr| match &i { Value::Int(__n) => __arr.get(*__n as usize), Value::Str(__s) => __s.parse::<usize>().ok().and_then(|__n| __arr.get(__n)), _ => None }).cloned().unwrap_or(Value::Null);
5887            let mut credentialValue: Value = self.prop(&key);
5888            let mut credentialMissing: bool = (credentialValue == Value::Null) || (credentialValue == Value::Null) || (is_equal(&credentialValue, &Value::Bool(false))) || (credentialValue.as_str() == Some(""));
5889            if (get_value(&self.requiredCredentials, &key).as_bool() == Some(true)) && credentialMissing {
5890                if is_true(&error) {
5891                    panic!("{}", crate::exchange_errors::authentication_error(format!("{}{}", Value::Str(format!("{}{}", Value::Str(format!("{}{}", self.id.clone(), Value::Str(" requires \"".into())).into()), key).into()), Value::Str("\" credential".into()))));
5892                }  else {
5893                    return Value::Bool(false);
5894                }
5895            }
5896        }
5897        }
5898        return Value::Bool(true);
5899
5900    Value::Null
5901}
5902
5903    fn oath(&self) -> Value {
5904        if (self.twofa.clone() != Value::Null) {
5905            return totp(self.twofa.clone());
5906        }  else {
5907            panic!("{}", crate::exchange_errors::exchange_error(format!("{}{}", self.id.clone(), Value::Str(" exchange.twofa has not been set for 2FA Two-Factor Authentication".into()))));
5908        }
5909
5910    Value::Null
5911}
5912
5913    fn fetch_balance(&mut self, optional_args: &[Value]) -> impl ::std::future::Future<Output = Value> + Send { async move {
5914        // async-virtual: try the derived exchange first
5915        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 {
5916            if !matches!(__v, crate::Value::Null) { return __v; }
5917        }
5918
5919        let mut params = get_arg(optional_args, 0, Value::Map({
5920    let mut m = indexmap::IndexMap::new();
5921    m
5922}));
5923        panic!("{}", crate::exchange_errors::not_supported(format!("{}{}", self.id.clone(), Value::Str(" fetchBalance() is not supported yet".into()))));
5924
5925    Value::Null
5926} }
5927
5928    fn fetch_balance_ws(&mut self, optional_args: &[Value]) -> impl ::std::future::Future<Output = Value> + Send { async move {
5929        let mut params = get_arg(optional_args, 0, Value::Map({
5930    let mut m = indexmap::IndexMap::new();
5931    m
5932}));
5933        panic!("{}", crate::exchange_errors::not_supported(format!("{}{}", self.id.clone(), Value::Str(" fetchBalanceWs() is not supported yet".into()))));
5934
5935    Value::Null
5936} }
5937
5938    fn parse_balance(&self, mut response: Value) -> Value {
5939        // virtual-dispatch (static: DerivedExchange::parse_balance(self, ...))
5940        { let __v = crate::exchange::DerivedExchange::parse_balance(self, response); if !matches!(__v, crate::Value::Null) { return __v; } }
5941
5942        panic!("{}", crate::exchange_errors::not_supported(format!("{}{}", self.id.clone(), Value::Str(" parseBalance() is not supported yet".into()))));
5943
5944    Value::Null
5945}
5946
5947    fn watch_balance(&mut self, optional_args: &[Value]) -> impl ::std::future::Future<Output = Value> + Send { async move {
5948        let mut params = get_arg(optional_args, 0, Value::Map({
5949    let mut m = indexmap::IndexMap::new();
5950    m
5951}));
5952        panic!("{}", crate::exchange_errors::not_supported(format!("{}{}", self.id.clone(), Value::Str(" watchBalance() is not supported yet".into()))));
5953
5954    Value::Null
5955} }
5956
5957    fn fetch_partial_balance(&mut self, mut part: Value, optional_args: &[Value]) -> impl ::std::future::Future<Output = Value> + Send { async move {
5958        let mut params = get_arg(optional_args, 0, Value::Map({
5959    let mut m = indexmap::IndexMap::new();
5960    m
5961}));
5962        let mut balance: Value = self.fetch_balance(&[params]).await;
5963        return get_value(&balance, &part);
5964
5965    Value::Null
5966} }
5967
5968    fn fetch_free_balance(&mut self, optional_args: &[Value]) -> impl ::std::future::Future<Output = Value> + Send { async move {
5969        let mut params = get_arg(optional_args, 0, Value::Map({
5970    let mut m = indexmap::IndexMap::new();
5971    m
5972}));
5973        return self.fetch_partial_balance(Value::Str("free".into()), &[params]).await;
5974
5975    Value::Null
5976} }
5977
5978    fn fetch_used_balance(&mut self, optional_args: &[Value]) -> impl ::std::future::Future<Output = Value> + Send { async move {
5979        let mut params = get_arg(optional_args, 0, Value::Map({
5980    let mut m = indexmap::IndexMap::new();
5981    m
5982}));
5983        return self.fetch_partial_balance(Value::Str("used".into()), &[params]).await;
5984
5985    Value::Null
5986} }
5987
5988    fn fetch_total_balance(&mut self, optional_args: &[Value]) -> impl ::std::future::Future<Output = Value> + Send { async move {
5989        let mut params = get_arg(optional_args, 0, Value::Map({
5990    let mut m = indexmap::IndexMap::new();
5991    m
5992}));
5993        return self.fetch_partial_balance(Value::Str("total".into()), &[params]).await;
5994
5995    Value::Null
5996} }
5997
5998    fn fetch_status(&mut self, optional_args: &[Value]) -> impl ::std::future::Future<Output = Value> + Send { async move {
5999        // async-virtual: try the derived exchange first
6000        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 {
6001            if !matches!(__v, crate::Value::Null) { return __v; }
6002        }
6003
6004        let mut params = get_arg(optional_args, 0, Value::Map({
6005    let mut m = indexmap::IndexMap::new();
6006    m
6007}));
6008        panic!("{}", crate::exchange_errors::not_supported(format!("{}{}", self.id.clone(), Value::Str(" fetchStatus() is not supported yet".into()))));
6009
6010    Value::Null
6011} }
6012
6013    fn fetch_transaction_fee(&mut self, mut code: Value, optional_args: &[Value]) -> impl ::std::future::Future<Output = Value> + Send { async move {
6014        let mut params = get_arg(optional_args, 0, Value::Map({
6015    let mut m = indexmap::IndexMap::new();
6016    m
6017}));
6018        if (self.has.as_map().and_then(|__m| __m.get("fetchTransactionFees")).cloned().unwrap_or(Value::Null) == Value::Null) || (self.has.as_map().and_then(|__m| __m.get("fetchTransactionFees")).cloned().unwrap_or(Value::Null).as_bool() == Some(false)) {
6019            panic!("{}", crate::exchange_errors::not_supported(format!("{}{}", self.id.clone(), Value::Str(" fetchTransactionFee() is not supported yet".into()))));
6020        }
6021        return self.fetch_transaction_fees(&[Value::from(vec![code]), params]).await;
6022
6023    Value::Null
6024} }
6025
6026    fn fetch_transaction_fees(&mut self, optional_args: &[Value]) -> impl ::std::future::Future<Output = Value> + Send { async move {
6027        let mut codes = get_arg(optional_args, 0, Value::Null);
6028        let mut params = get_arg(optional_args, 1, Value::Map({
6029    let mut m = indexmap::IndexMap::new();
6030    m
6031}));
6032        panic!("{}", crate::exchange_errors::not_supported(format!("{}{}", self.id.clone(), Value::Str(" fetchTransactionFees() is not supported yet".into()))));
6033
6034    Value::Null
6035} }
6036
6037    fn fetch_deposit_withdraw_fees(&mut self, optional_args: &[Value]) -> impl ::std::future::Future<Output = Value> + Send { async move {
6038        // async-virtual: try the derived exchange first
6039        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 {
6040            if !matches!(__v, crate::Value::Null) { return __v; }
6041        }
6042
6043        let mut codes = get_arg(optional_args, 0, Value::Null);
6044        let mut params = get_arg(optional_args, 1, Value::Map({
6045    let mut m = indexmap::IndexMap::new();
6046    m
6047}));
6048        panic!("{}", crate::exchange_errors::not_supported(format!("{}{}", self.id.clone(), Value::Str(" fetchDepositWithdrawFees() is not supported yet".into()))));
6049
6050    Value::Null
6051} }
6052
6053    fn fetch_deposit_withdraw_fee(&mut self, mut code: Value, optional_args: &[Value]) -> impl ::std::future::Future<Output = Value> + Send { async move {
6054        // async-virtual: try the derived exchange first
6055        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 {
6056            if !matches!(__v, crate::Value::Null) { return __v; }
6057        }
6058
6059        let mut params = get_arg(optional_args, 0, Value::Map({
6060    let mut m = indexmap::IndexMap::new();
6061    m
6062}));
6063        if (self.has.as_map().and_then(|__m| __m.get("fetchDepositWithdrawFees")).cloned().unwrap_or(Value::Null) == Value::Null) || (self.has.as_map().and_then(|__m| __m.get("fetchDepositWithdrawFees")).cloned().unwrap_or(Value::Null).as_bool() == Some(false)) {
6064            panic!("{}", crate::exchange_errors::not_supported(format!("{}{}", self.id.clone(), Value::Str(" fetchDepositWithdrawFee() is not supported yet".into()))));
6065        }
6066        let mut fees: Value = self.fetch_deposit_withdraw_fees(&[Value::from(vec![code.clone()]), params]).await;
6067        return self.safe_value(fees, code, &[]);
6068
6069    Value::Null
6070} }
6071
6072    fn get_supported_mapping(&self, mut key: Value, optional_args: &[Value]) -> Value {
6073        let mut mapping = get_arg(optional_args, 0, Value::Map({
6074    let mut m = indexmap::IndexMap::new();
6075    m
6076}));
6077        if (key == Value::Null) {
6078            panic!("{}", crate::exchange_errors::arguments_required(format!("{}{}", self.id.clone(), Value::Str(" getSupportedMapping() requires a key argument".into()))));
6079        }
6080        if (in_op(&mapping, &key)) {
6081            return mapping.as_map().and_then(|__m| key.as_str().and_then(|__k| __m.get(__k))).cloned().unwrap_or(Value::Null);
6082        }  else {
6083            let mut keys: Value = object_keys(&mapping);
6084            panic!("{}", crate::exchange_errors::not_supported(format!("{}{}", Value::Str(format!("{}{}", Value::Str(format!("{}{}", Value::Str(format!("{}{}", Value::Str(format!("{}{}", self.id.clone(), Value::Str(" ".into())).into()), key).into()), Value::Str(" does not have a value in mapping".into())).into()), Value::Str(", must be one of ".into())).into()), join(&keys, &Value::Str(", ".into())))));
6085        }
6086
6087    Value::Null
6088}
6089
6090    fn fetch_cross_borrow_rate(&mut self, mut code: Value, optional_args: &[Value]) -> impl ::std::future::Future<Output = Value> + Send { async move {
6091        let mut params = get_arg(optional_args, 0, Value::Map({
6092    let mut m = indexmap::IndexMap::new();
6093    m
6094}));
6095        self.load_markets(&[]).await;
6096        if (self.has.as_map().and_then(|__m| __m.get("fetchBorrowRates")).cloned().unwrap_or(Value::Null) == Value::Null) || (self.has.as_map().and_then(|__m| __m.get("fetchBorrowRates")).cloned().unwrap_or(Value::Null).as_bool() == Some(false)) {
6097            panic!("{}", crate::exchange_errors::not_supported(format!("{}{}", self.id.clone(), Value::Str(" fetchCrossBorrowRate() is not supported yet".into()))));
6098        }
6099        let mut borrowRates: Value = self.fetch_cross_borrow_rates(&[params]).await;
6100        let mut rate: Value = self.safe_dict(borrowRates, code.clone(), &[]);
6101        if (rate == Value::Null) {
6102            panic!("{}", crate::exchange_errors::exchange_error(format!("{}{}", Value::Str(format!("{}{}", self.id.clone(), Value::Str(" fetchCrossBorrowRate() could not find the borrow rate for currency code ".into())).into()), code)));
6103        }
6104        return rate;
6105
6106    Value::Null
6107} }
6108
6109    fn fetch_isolated_borrow_rate(&mut self, mut symbol: Value, optional_args: &[Value]) -> impl ::std::future::Future<Output = Value> + Send { async move {
6110        let mut params = get_arg(optional_args, 0, Value::Map({
6111    let mut m = indexmap::IndexMap::new();
6112    m
6113}));
6114        self.load_markets(&[]).await;
6115        if (self.has.as_map().and_then(|__m| __m.get("fetchBorrowRates")).cloned().unwrap_or(Value::Null) == Value::Null) || (self.has.as_map().and_then(|__m| __m.get("fetchBorrowRates")).cloned().unwrap_or(Value::Null).as_bool() == Some(false)) {
6116            panic!("{}", crate::exchange_errors::not_supported(format!("{}{}", self.id.clone(), Value::Str(" fetchIsolatedBorrowRate() is not supported yet".into()))));
6117        }
6118        let mut borrowRates: Value = self.fetch_isolated_borrow_rates(&[params]).await;
6119        let mut rate: Value = self.safe_dict(borrowRates, symbol.clone(), &[]);
6120        if (rate == Value::Null) {
6121            panic!("{}", crate::exchange_errors::exchange_error(format!("{}{}", Value::Str(format!("{}{}", self.id.clone(), Value::Str(" fetchIsolatedBorrowRate() could not find the borrow rate for market symbol ".into())).into()), symbol)));
6122        }
6123        return rate;
6124
6125    Value::Null
6126} }
6127
6128/* eslint-disable no-unused-vars */
6129/* eslint-enable no-unused-vars */
6130    fn require_value(&self, mut value: Value, optional_args: &[Value]) -> Value {
6131        let mut message = get_arg(optional_args, 0, Value::Null);
6132        if (value == Value::Null) {
6133            let mut errorMessage: Value = (if (message != Value::Null) { message } else { Value::Str("value is required".into()) });
6134            panic!("{}", crate::exchange_errors::arguments_required(format!("{}{}", Value::Str(format!("{}{}", self.id.clone(), Value::Str(" ".into())).into()), errorMessage)));
6135        }
6136        return value;
6137
6138    Value::Null
6139}
6140
6141/* eslint-disable no-unused-vars */
6142/* eslint-enable no-unused-vars */
6143    fn handle_option_and_params(&self, mut params: Value, mut methodName: Value, mut optionName: Value, optional_args: &[Value]) -> Value {
6144        let mut defaultValue = get_arg(optional_args, 0, Value::Null);
6145        // This method can be used to obtain method specific properties, i.e: this.handleOptionAndParams (params, 'fetchPosition', 'marginMode', 'isolated')
6146        let mut defaultOptionName: Value = Value::Str(format!("{}{}", Value::Str("default".into()), self.capitalize(optionName.clone())).into()); // we also need to check the 'defaultXyzWhatever'
6147        // check if params contain the key
6148        let mut value: Value = self.safe_value2(params.clone(), optionName.clone(), defaultOptionName.clone(), &[]);
6149        if (value != Value::Null) {
6150            let mut paramsOmitted: Value = self.omit(params.clone(), Value::from(vec![optionName.clone(), defaultOptionName.clone()]), &[]);
6151            return Value::from(vec![value.clone(), paramsOmitted]);
6152        }  else {
6153            // handle routed methods like "watchTrades > watchTradesForSymbols" (or "watchTicker > watchTickers")
6154            let mut callerMethodNameparamsCallerMethodNameVariable = self.handle_param_string(params, Value::Str("callerMethodName".into()), &[methodName]);
6155            let mut callerMethodName: Value = callerMethodNameparamsCallerMethodNameVariable.as_array().and_then(|__arr| __arr.get(0)).cloned().unwrap_or(Value::Null);
6156            let mut paramsCallerMethodName: Value = callerMethodNameparamsCallerMethodNameVariable.as_array().and_then(|__arr| __arr.get(1)).cloned().unwrap_or(Value::Null);
6157            // check if exchange has properties for this method
6158            let mut exchangeWideMethodOptions: Value = self.safe_value(self.options.clone(), callerMethodName, &[]);
6159            if (exchangeWideMethodOptions != Value::Null) {
6160                // check if the option is defined inside this method's props
6161                value = self.safe_value2(exchangeWideMethodOptions, optionName.clone(), defaultOptionName.clone(), &[]);
6162            }
6163            if (value == Value::Null) {
6164                // if it's still undefined, check if global exchange-wide option exists
6165                value = self.safe_value2(self.options.clone(), optionName, defaultOptionName, &[]);
6166            }
6167            // if it's still undefined, use the default value
6168            value = (if (value != Value::Null) { value.clone() } else { defaultValue });
6169            return Value::from(vec![value, paramsCallerMethodName]);
6170        }
6171
6172    Value::Null
6173}
6174
6175/* eslint-disable no-unused-vars */
6176/* eslint-enable no-unused-vars */
6177    fn handle_option_and_params2(&self, mut params: Value, mut methodName1: Value, mut optionName1: Value, mut optionName2: Value, optional_args: &[Value]) -> Value {
6178        let mut defaultValue = get_arg(optional_args, 0, Value::Null);
6179        let mut valueparamsOption1Variable = self.handle_option_and_params(params, methodName1.clone(), optionName1, &[]);
6180        let mut value: Value = valueparamsOption1Variable.as_array().and_then(|__arr| __arr.get(0)).cloned().unwrap_or(Value::Null);
6181        let mut paramsOption1: Value = valueparamsOption1Variable.as_array().and_then(|__arr| __arr.get(1)).cloned().unwrap_or(Value::Null);
6182        if (value != Value::Null) {
6183            // omit optionName2 too from params
6184            let mut paramsOmitted: Value = self.omit(paramsOption1.clone(), optionName2.clone(), &[]);
6185            return Value::from(vec![value, paramsOmitted]);
6186        }
6187        return self.handle_option_and_params(paramsOption1, methodName1, optionName2, &[defaultValue]);
6188
6189    Value::Null
6190}
6191
6192/* eslint-disable no-unused-vars */
6193/* eslint-enable no-unused-vars */
6194    fn handle_option_string_and_params(&self, mut params: Value, mut methodName: Value, mut optionName: Value, optional_args: &[Value]) -> Value {
6195        let mut defaultValue = get_arg(optional_args, 0, Value::Null);
6196        // handleOptionAndParams read as a string; the statically typed ports throw on another type
6197        let mut valuenewParamsVariable = self.handle_option_and_params(params, methodName.clone(), optionName.clone(), &[defaultValue]);
6198        let mut value: Value = valuenewParamsVariable.as_array().and_then(|__arr| __arr.get(0)).cloned().unwrap_or(Value::Null);
6199        let mut newParams: Value = valuenewParamsVariable.as_array().and_then(|__arr| __arr.get(1)).cloned().unwrap_or(Value::Null);
6200        return Value::from(vec![self.check_option_string(methodName, optionName, value), newParams]);
6201
6202    Value::Null
6203}
6204
6205/* eslint-disable no-unused-vars */
6206/* eslint-enable no-unused-vars */
6207    fn handle_option_string_and_params2(&self, mut params: Value, mut methodName: Value, mut optionName1: Value, mut optionName2: Value, optional_args: &[Value]) -> Value {
6208        let mut defaultValue = get_arg(optional_args, 0, Value::Null);
6209        let mut valuenewParamsVariable = self.handle_option_and_params2(params, methodName.clone(), optionName1.clone(), optionName2, &[defaultValue]);
6210        let mut value: Value = valuenewParamsVariable.as_array().and_then(|__arr| __arr.get(0)).cloned().unwrap_or(Value::Null);
6211        let mut newParams: Value = valuenewParamsVariable.as_array().and_then(|__arr| __arr.get(1)).cloned().unwrap_or(Value::Null);
6212        return Value::from(vec![self.check_option_string(methodName, optionName1, value), newParams]);
6213
6214    Value::Null
6215}
6216
6217/* eslint-disable no-unused-vars */
6218/* eslint-enable no-unused-vars */
6219    fn handle_option_bool_and_params(&self, mut params: Value, mut methodName: Value, mut optionName: Value, optional_args: &[Value]) -> Value {
6220        let mut defaultValue = get_arg(optional_args, 0, Value::Null);
6221        // handleOptionAndParams read as a boolean; the statically typed ports throw on another type
6222        let mut valuenewParamsVariable = self.handle_option_and_params(params, methodName.clone(), optionName.clone(), &[defaultValue]);
6223        let mut value: Value = valuenewParamsVariable.as_array().and_then(|__arr| __arr.get(0)).cloned().unwrap_or(Value::Null);
6224        let mut newParams: Value = valuenewParamsVariable.as_array().and_then(|__arr| __arr.get(1)).cloned().unwrap_or(Value::Null);
6225        return Value::from(vec![self.check_option_bool(methodName, optionName, value), newParams]);
6226
6227    Value::Null
6228}
6229
6230/* eslint-disable no-unused-vars */
6231/* eslint-enable no-unused-vars */
6232    fn handle_option_bool_and_params2(&self, mut params: Value, mut methodName: Value, mut optionName1: Value, mut optionName2: Value, optional_args: &[Value]) -> Value {
6233        let mut defaultValue = get_arg(optional_args, 0, Value::Null);
6234        let mut valuenewParamsVariable = self.handle_option_and_params2(params, methodName.clone(), optionName1.clone(), optionName2, &[defaultValue]);
6235        let mut value: Value = valuenewParamsVariable.as_array().and_then(|__arr| __arr.get(0)).cloned().unwrap_or(Value::Null);
6236        let mut newParams: Value = valuenewParamsVariable.as_array().and_then(|__arr| __arr.get(1)).cloned().unwrap_or(Value::Null);
6237        return Value::from(vec![self.check_option_bool(methodName, optionName1, value), newParams]);
6238
6239    Value::Null
6240}
6241
6242/* eslint-disable no-unused-vars */
6243/* eslint-enable no-unused-vars */
6244    fn handle_option_integer_and_params(&self, mut params: Value, mut methodName: Value, mut optionName: Value, optional_args: &[Value]) -> Value {
6245        let mut defaultValue = get_arg(optional_args, 0, Value::Null);
6246        // handleOptionAndParams read as an integer; the statically typed ports throw on another type
6247        let mut valuenewParamsVariable = self.handle_option_and_params(params, methodName.clone(), optionName.clone(), &[defaultValue]);
6248        let mut value: Value = valuenewParamsVariable.as_array().and_then(|__arr| __arr.get(0)).cloned().unwrap_or(Value::Null);
6249        let mut newParams: Value = valuenewParamsVariable.as_array().and_then(|__arr| __arr.get(1)).cloned().unwrap_or(Value::Null);
6250        return Value::from(vec![self.check_option_integer(methodName, optionName, value), newParams]);
6251
6252    Value::Null
6253}
6254
6255/* eslint-disable no-unused-vars */
6256/* eslint-enable no-unused-vars */
6257    fn handle_option_integer_and_params2(&self, mut params: Value, mut methodName: Value, mut optionName1: Value, mut optionName2: Value, optional_args: &[Value]) -> Value {
6258        let mut defaultValue = get_arg(optional_args, 0, Value::Null);
6259        let mut valuenewParamsVariable = self.handle_option_and_params2(params, methodName.clone(), optionName1.clone(), optionName2, &[defaultValue]);
6260        let mut value: Value = valuenewParamsVariable.as_array().and_then(|__arr| __arr.get(0)).cloned().unwrap_or(Value::Null);
6261        let mut newParams: Value = valuenewParamsVariable.as_array().and_then(|__arr| __arr.get(1)).cloned().unwrap_or(Value::Null);
6262        return Value::from(vec![self.check_option_integer(methodName, optionName1, value), newParams]);
6263
6264    Value::Null
6265}
6266
6267    fn handle_option(&self, mut methodName: Value, mut optionName: Value, optional_args: &[Value]) -> Value {
6268        let mut defaultValue = get_arg(optional_args, 0, Value::Null);
6269        let mut res: Value = self.handle_option_and_params(Value::Map({
6270    let mut m = indexmap::IndexMap::new();
6271    m
6272}), methodName, optionName, &[defaultValue]);
6273        return self.safe_value(res, Value::Int(0), &[]);
6274
6275    Value::Null
6276}
6277
6278    fn handle_market_type_and_params(&self, mut methodName: Value, optional_args: &[Value]) -> Value {
6279        let mut market = get_arg(optional_args, 0, Value::Null);
6280        let mut params = get_arg(optional_args, 1, Value::Map({
6281    let mut m = indexmap::IndexMap::new();
6282    m
6283}));
6284        let mut defaultValue = get_arg(optional_args, 2, Value::Null);
6285        /*
6286         * @ignore
6287         * @method
6288         * @name exchange#handleMarketTypeAndParams
6289         * @param methodName the method calling handleMarketTypeAndParams
6290         * @param {Market} market
6291         * @param {object} params
6292         * @param {string} [params.type] type assigned by user
6293         * @param {string} [params.defaultType] same as params.type
6294         * @param {string} [defaultValue] assigned programatically in the method calling handleMarketTypeAndParams
6295         * @returns {[string, object]} the market type and params with type and defaultType omitted
6296         */
6297        // type from param
6298        let mut type_var: Value = self.safe_string2(params.clone(), Value::Str("defaultType".into()), Value::Str("type".into()), &[]);
6299        if (type_var != Value::Null) {
6300            let mut paramsOmitted: Value = self.omit(params.clone(), Value::from(vec![Value::Str("defaultType".into()), Value::Str("type".into())]), &[]);
6301            return Value::from(vec![type_var, paramsOmitted]);
6302        }
6303        // type from market
6304        if (market != Value::Null) {
6305            return Value::from(vec![market.as_map().and_then(|__m| __m.get("type")).cloned().unwrap_or(Value::Null), params.clone()]);
6306        }
6307        // type from default-argument
6308        if (defaultValue != Value::Null) {
6309            return Value::from(vec![defaultValue, params.clone()]);
6310        }
6311        let mut methodOptions: Value = self.safe_dict(self.options.clone(), methodName, &[]);
6312        if (methodOptions != Value::Null) {
6313            if matches!(&methodOptions, Value::Str(_)) {
6314                return Value::from(vec![methodOptions.clone(), params.clone()]);
6315            }  else {
6316                let mut typeFromMethod: Value = self.safe_string2(methodOptions, Value::Str("defaultType".into()), Value::Str("type".into()), &[]);
6317                if (typeFromMethod != Value::Null) {
6318                    return Value::from(vec![typeFromMethod, params.clone()]);
6319                }
6320            }
6321        }
6322        let mut defaultType: Value = self.safe_string2(self.options.clone(), Value::Str("defaultType".into()), Value::Str("type".into()), &[Value::Str("spot".into())]);
6323        return Value::from(vec![defaultType, params]);
6324
6325    Value::Null
6326}
6327
6328    fn handle_sub_type_and_params(&self, mut methodName: Value, optional_args: &[Value]) -> Value {
6329        let mut market = get_arg(optional_args, 0, Value::Null);
6330        let mut params = get_arg(optional_args, 1, Value::Map({
6331    let mut m = indexmap::IndexMap::new();
6332    m
6333}));
6334        let mut defaultValue = get_arg(optional_args, 2, Value::Null);
6335        let mut subType: Value = Value::Null;
6336        // if set in params, it takes precedence
6337        let mut subTypeInParams: Value = self.safe_string2(params.clone(), Value::Str("subType".into()), Value::Str("defaultSubType".into()), &[]);
6338        // avoid omitting if it's not present
6339        if (subTypeInParams != Value::Null) {
6340            if (subTypeInParams.as_str() == Some("linear")) || (subTypeInParams.as_str() == Some("inverse")) {
6341                subType = subTypeInParams;
6342            }
6343            let mut paramsOmitted: Value = self.omit(params.clone(), Value::from(vec![Value::Str("subType".into()), Value::Str("defaultSubType".into())]), &[]);
6344            return Value::from(vec![subType.clone(), paramsOmitted]);
6345        }  else {
6346            // at first, check from market object
6347            if (market != Value::Null) {
6348                if (market.as_map().and_then(|__m| __m.get("linear")).cloned().unwrap_or(Value::Null).as_bool() == Some(true)) {
6349                    subType = Value::Str("linear".into());
6350                }  else if (market.as_map().and_then(|__m| __m.get("inverse")).cloned().unwrap_or(Value::Null).as_bool() == Some(true)) {
6351                    subType = Value::Str("inverse".into());
6352                }
6353            }
6354            // if it was not defined in market object
6355            if (subType == Value::Null) {
6356                let mut values: Value = self.handle_option_and_params(Value::Map({
6357    let mut m = indexmap::IndexMap::new();
6358    m
6359}), methodName, Value::Str("subType".into()), &[defaultValue]); // no need to re-test params here
6360                subType = values.as_array().and_then(|__arr| __arr.get(0)).cloned().unwrap_or(Value::Null);
6361            }
6362        }
6363        return Value::from(vec![subType, params]);
6364
6365    Value::Null
6366}
6367
6368    fn handle_margin_mode_and_params(&self, mut methodName: Value, optional_args: &[Value]) -> Value {
6369        let mut params = get_arg(optional_args, 0, Value::Map({
6370    let mut m = indexmap::IndexMap::new();
6371    m
6372}));
6373        let mut defaultValue = get_arg(optional_args, 1, Value::Null);
6374        return self.handle_option_string_and_params(params, methodName, Value::Str("marginMode".into()), &[defaultValue]);
6375
6376    Value::Null
6377}
6378
6379    fn throw_exactly_matched_exception(&self, mut exact: Value, mut string: Value, mut message: Value) {
6380        if (string == Value::Null) {
6381            return;
6382        }
6383        if (in_op(&exact, &string)) {
6384            panic!("{}", crate::exchange_errors::create_error(&crate::runtime::stringify_param(&(get_value(&exact, &string))), &crate::runtime::stringify_param(&(message))));
6385        }
6386}
6387
6388    fn throw_broadly_matched_exception(&self, mut broad: Value, mut string: Value, mut message: Value) {
6389        let mut broadKey: Value = self.find_broadly_matched_key(broad.clone(), string);
6390        if (broadKey != Value::Null) {
6391            panic!("{}", crate::exchange_errors::create_error(&crate::runtime::stringify_param(&(get_value(&broad, &broadKey))), &crate::runtime::stringify_param(&(message))));
6392        }
6393}
6394
6395    fn find_broadly_matched_key(&self, mut broad: Value, mut string: Value) -> Value {
6396        // a helper for matching error strings exactly vs broadly
6397        let mut keys: Value = object_keys(&broad);
6398        {
6399                        let mut i: Value = Value::Int(0);
6400            let mut __for_first_137: bool = true;
6401            while { if !__for_first_137 { i = (match (&(i), &(Value::Int(1))) { (Value::Int(x), Value::Int(y)) => Value::Int(x + y), (Value::Int(x), Value::Float(y)) => Value::Float(*x as f64 + *y), (Value::Float(x), Value::Int(y)) => Value::Float(*x + *y as f64), (Value::Float(x), Value::Float(y)) => Value::Float(x + y), _ => Value::Null }); } __for_first_137 = false; i.as_f64().unwrap_or(f64::NAN) < ((keys.len() as i64) as f64) } {
6402            let mut key: Value = keys.as_array().and_then(|__arr| match &i { Value::Int(__n) => __arr.get(*__n as usize), Value::Str(__s) => __s.parse::<usize>().ok().and_then(|__n| __arr.get(__n)), _ => None }).cloned().unwrap_or(Value::Null);
6403            if (string != Value::Null) {
6404                if get_index_of(&string, &key).as_f64().unwrap_or(f64::NAN) >= ((0i64) as f64) {
6405                    return key;
6406                }
6407            }
6408        }
6409        }
6410        return Value::Null;
6411
6412    Value::Null
6413}
6414
6415    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 {
6416        // virtual-dispatch (static: DerivedExchange::handle_errors(self, ...))
6417        { let __v = crate::exchange::DerivedExchange::handle_errors(self, statusCode, statusText, url, method, responseHeaders, responseBody, response, requestHeaders, requestBody); if !matches!(__v, crate::Value::Null) { return __v; } }
6418
6419        return Value::Null;
6420
6421    Value::Null
6422}
6423
6424    fn calculate_rate_limiter_cost(&self, mut api: Value, mut method: Value, mut path: Value, mut params: Value, optional_args: &[Value]) -> Value {
6425        let mut config = get_arg(optional_args, 0, Value::Map({
6426    let mut m = indexmap::IndexMap::new();
6427    m
6428}));
6429        let __config_empty = indexmap::IndexMap::new();
6430        let config = config.as_map().unwrap_or(&__config_empty);
6431        return (match config.get("cost") { Some(__v) if !matches!(__v, Value::Null) && !matches!(__v, Value::Str(__s) if __s.is_empty()) => __v.clone(), _ => Value::Int(1) });
6432
6433    Value::Null
6434}
6435
6436    fn fetch_spot_tickers(&mut self, optional_args: &[Value]) -> impl ::std::future::Future<Output = Value> + Send { async move {
6437        let mut symbols = get_arg(optional_args, 0, Value::Null);
6438        let mut params = get_arg(optional_args, 1, Value::Map({
6439    let mut m = indexmap::IndexMap::new();
6440    m
6441}));
6442        panic!("{}", crate::exchange_errors::not_supported(format!("{}{}", self.id.clone(), Value::Str(" fetchSpotTickers() is not supported yet".into()))));
6443
6444    Value::Null
6445} }
6446
6447    fn fetch_contract_tickers(&mut self, optional_args: &[Value]) -> impl ::std::future::Future<Output = Value> + Send { async move {
6448        let mut symbols = get_arg(optional_args, 0, Value::Null);
6449        let mut params = get_arg(optional_args, 1, Value::Map({
6450    let mut m = indexmap::IndexMap::new();
6451    m
6452}));
6453        panic!("{}", crate::exchange_errors::not_supported(format!("{}{}", self.id.clone(), Value::Str(" fetchContractTickers() is not supported yet".into()))));
6454
6455    Value::Null
6456} }
6457
6458    fn fetch_order_books(&mut self, optional_args: &[Value]) -> impl ::std::future::Future<Output = Value> + Send { async move {
6459        let mut symbols = get_arg(optional_args, 0, Value::Null);
6460        let mut limit = get_arg(optional_args, 1, Value::Null);
6461        let mut params = get_arg(optional_args, 2, Value::Map({
6462    let mut m = indexmap::IndexMap::new();
6463    m
6464}));
6465        panic!("{}", crate::exchange_errors::not_supported(format!("{}{}", self.id.clone(), Value::Str(" fetchOrderBooks() is not supported yet".into()))));
6466
6467    Value::Null
6468} }
6469
6470    fn un_watch_tickers(&mut self, optional_args: &[Value]) -> impl ::std::future::Future<Output = Value> + Send { async move {
6471        let mut symbols = get_arg(optional_args, 0, Value::Null);
6472        let mut params = get_arg(optional_args, 1, Value::Map({
6473    let mut m = indexmap::IndexMap::new();
6474    m
6475}));
6476        panic!("{}", crate::exchange_errors::not_supported(format!("{}{}", self.id.clone(), Value::Str(" unWatchTickers() is not supported yet".into()))));
6477
6478    Value::Null
6479} }
6480
6481    fn un_watch_funding_rate(&mut self, mut symbol: Value, optional_args: &[Value]) -> impl ::std::future::Future<Output = Value> + Send { async move {
6482        let mut params = get_arg(optional_args, 0, Value::Map({
6483    let mut m = indexmap::IndexMap::new();
6484    m
6485}));
6486        panic!("{}", crate::exchange_errors::not_supported(format!("{}{}", self.id.clone(), Value::Str(" unWatchFundingRate() is not supported yet".into()))));
6487
6488    Value::Null
6489} }
6490
6491    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 {
6492        let mut params = get_arg(optional_args, 0, Value::Map({
6493    let mut m = indexmap::IndexMap::new();
6494    m
6495}));
6496        panic!("{}", crate::exchange_errors::not_supported(format!("{}{}", self.id.clone(), Value::Str(" createTwapOrder() is not supported yet".into()))));
6497
6498    Value::Null
6499} }
6500
6501    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 {
6502        let mut amount = get_arg(optional_args, 0, Value::Null);
6503        let mut params = get_arg(optional_args, 1, Value::Map({
6504    let mut m = indexmap::IndexMap::new();
6505    m
6506}));
6507        panic!("{}", crate::exchange_errors::not_supported(format!("{}{}", self.id.clone(), Value::Str(" createConvertTrade() is not supported yet".into()))));
6508
6509    Value::Null
6510} }
6511
6512    fn fetch_convert_trade(&mut self, mut id: Value, optional_args: &[Value]) -> impl ::std::future::Future<Output = Value> + Send { async move {
6513        let mut code = get_arg(optional_args, 0, Value::Null);
6514        let mut params = get_arg(optional_args, 1, Value::Map({
6515    let mut m = indexmap::IndexMap::new();
6516    m
6517}));
6518        panic!("{}", crate::exchange_errors::not_supported(format!("{}{}", self.id.clone(), Value::Str(" fetchConvertTrade() is not supported yet".into()))));
6519
6520    Value::Null
6521} }
6522
6523    fn fetch_convert_trade_history(&mut self, optional_args: &[Value]) -> impl ::std::future::Future<Output = Value> + Send { async move {
6524        let mut code = get_arg(optional_args, 0, Value::Null);
6525        let mut since = get_arg(optional_args, 1, Value::Null);
6526        let mut limit = get_arg(optional_args, 2, Value::Null);
6527        let mut params = get_arg(optional_args, 3, Value::Map({
6528    let mut m = indexmap::IndexMap::new();
6529    m
6530}));
6531        panic!("{}", crate::exchange_errors::not_supported(format!("{}{}", self.id.clone(), Value::Str(" fetchConvertTradeHistory() is not supported yet".into()))));
6532
6533    Value::Null
6534} }
6535
6536    fn fetch_position_mode(&mut self, optional_args: &[Value]) -> impl ::std::future::Future<Output = Value> + Send { async move {
6537        // async-virtual: try the derived exchange first
6538        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 {
6539            if !matches!(__v, crate::Value::Null) { return __v; }
6540        }
6541
6542        let mut symbol = get_arg(optional_args, 0, Value::Null);
6543        let mut params = get_arg(optional_args, 1, Value::Map({
6544    let mut m = indexmap::IndexMap::new();
6545    m
6546}));
6547        panic!("{}", crate::exchange_errors::not_supported(format!("{}{}", self.id.clone(), Value::Str(" fetchPositionMode() is not supported yet".into()))));
6548
6549    Value::Null
6550} }
6551
6552    fn fetch_adl_rank(&mut self, mut symbol: Value, optional_args: &[Value]) -> impl ::std::future::Future<Output = Value> + Send { async move {
6553        let mut params = get_arg(optional_args, 0, Value::Map({
6554    let mut m = indexmap::IndexMap::new();
6555    m
6556}));
6557        panic!("{}", crate::exchange_errors::not_supported(format!("{}{}", self.id.clone(), Value::Str(" fetchADLRank() is not supported yet".into()))));
6558
6559    Value::Null
6560} }
6561
6562    fn fetch_positions_adl_rank(&mut self, optional_args: &[Value]) -> impl ::std::future::Future<Output = Value> + Send { async move {
6563        // async-virtual: try the derived exchange first
6564        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 {
6565            if !matches!(__v, crate::Value::Null) { return __v; }
6566        }
6567
6568        let mut symbols = get_arg(optional_args, 0, Value::Null);
6569        let mut params = get_arg(optional_args, 1, Value::Map({
6570    let mut m = indexmap::IndexMap::new();
6571    m
6572}));
6573        panic!("{}", crate::exchange_errors::not_supported(format!("{}{}", self.id.clone(), Value::Str(" fetchPositionsADLRank() is not supported yet".into()))));
6574
6575    Value::Null
6576} }
6577
6578    fn fetch_position_adl_rank(&mut self, mut symbol: Value, optional_args: &[Value]) -> impl ::std::future::Future<Output = Value> + Send { async move {
6579        // async-virtual: try the derived exchange first
6580        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 {
6581            if !matches!(__v, crate::Value::Null) { return __v; }
6582        }
6583
6584        let mut params = get_arg(optional_args, 0, Value::Map({
6585    let mut m = indexmap::IndexMap::new();
6586    m
6587}));
6588        if (self.has.as_map().and_then(|__m| __m.get("fetchPositionsADLRank")).cloned().unwrap_or(Value::Null) != Value::Null) && (self.has.as_map().and_then(|__m| __m.get("fetchPositionsADLRank")).cloned().unwrap_or(Value::Null).as_bool() != Some(false)) {
6589            self.load_markets(&[]).await;
6590            let mut market: Value = <Self as crate::exchange_generated::ExchangeBase>::market(self, symbol);
6591            let mut symbolResolved: Value = market.as_map().and_then(|__m| __m.get("symbol")).cloned().unwrap_or(Value::Null);
6592            let mut ranks: Value = self.fetch_positions_adl_rank(&[Value::from(vec![symbolResolved.clone()]), params]).await;
6593            let mut rank: Value = self.safe_dict(ranks, Value::Int(0), &[]);
6594            if (rank == Value::Null) {
6595                panic!("{}", crate::exchange_errors::null_response(format!("{}{}", Value::Str(format!("{}{}", self.id.clone(), Value::Str(" fetchPositionsADLRank() could not find a rank for ".into())).into()), symbolResolved)));
6596            }  else {
6597                return rank;
6598            }
6599        }  else {
6600            panic!("{}", crate::exchange_errors::not_supported(format!("{}{}", self.id.clone(), Value::Str(" fetchPositionsADLRank() is not supported yet".into()))));
6601        }
6602
6603    Value::Null
6604} }
6605
6606    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 {
6607        let mut price = get_arg(optional_args, 0, Value::Null);
6608        let mut takeProfit = get_arg(optional_args, 1, Value::Null);
6609        let mut stopLoss = get_arg(optional_args, 2, Value::Null);
6610        let mut params = get_arg(optional_args, 3, Value::Map({
6611    let mut m = indexmap::IndexMap::new();
6612    m
6613}));
6614        if (takeProfit == Value::Null) && (stopLoss == Value::Null) {
6615            panic!("{}", crate::exchange_errors::arguments_required(format!("{}{}", self.id.clone(), Value::Str(" createOrderWithTakeProfitAndStopLoss() requires either a takeProfit or stopLoss argument".into()))));
6616        }
6617        if (takeProfit != Value::Null) {
6618            if let Value::Dict(__d) = &mut params { std::sync::Arc::make_mut(__d).insert("takeProfit".into(), Value::Map({
6619    let mut m = indexmap::IndexMap::new();
6620        m.insert("triggerPrice".to_string(), takeProfit);
6621    m
6622})); }
6623        }
6624        if (stopLoss != Value::Null) {
6625            if let Value::Dict(__d) = &mut params { std::sync::Arc::make_mut(__d).insert("stopLoss".into(), Value::Map({
6626    let mut m = indexmap::IndexMap::new();
6627        m.insert("triggerPrice".to_string(), stopLoss);
6628    m
6629})); }
6630        }
6631        let mut takeProfitType: Value = self.safe_string_k(params.clone(), "takeProfitType", &[]);
6632        let mut takeProfitPriceType: Value = self.safe_string_k(params.clone(), "takeProfitPriceType", &[]);
6633        let mut takeProfitLimitPrice: Value = self.safe_string_k(params.clone(), "takeProfitLimitPrice", &[]);
6634        let mut takeProfitAmount: Value = self.safe_string_k(params.clone(), "takeProfitAmount", &[]);
6635        let mut stopLossType: Value = self.safe_string_k(params.clone(), "stopLossType", &[]);
6636        let mut stopLossPriceType: Value = self.safe_string_k(params.clone(), "stopLossPriceType", &[]);
6637        let mut stopLossLimitPrice: Value = self.safe_string_k(params.clone(), "stopLossLimitPrice", &[]);
6638        let mut stopLossAmount: Value = self.safe_string_k(params.clone(), "stopLossAmount", &[]);
6639        if (takeProfitType != Value::Null) {
6640            add_element_to_object(get_value_mut(&mut params, &Value::Str("takeProfit".into())), &Value::Str("type".into()), takeProfitType);
6641        }
6642        if (takeProfitPriceType != Value::Null) {
6643            add_element_to_object(get_value_mut(&mut params, &Value::Str("takeProfit".into())), &Value::Str("priceType".into()), takeProfitPriceType);
6644        }
6645        if (takeProfitLimitPrice != Value::Null) {
6646            add_element_to_object(get_value_mut(&mut params, &Value::Str("takeProfit".into())), &Value::Str("price".into()), self.parse_to_numeric(takeProfitLimitPrice));
6647        }
6648        if (takeProfitAmount != Value::Null) {
6649            add_element_to_object(get_value_mut(&mut params, &Value::Str("takeProfit".into())), &Value::Str("amount".into()), self.parse_to_numeric(takeProfitAmount));
6650        }
6651        if (stopLossType != Value::Null) {
6652            add_element_to_object(get_value_mut(&mut params, &Value::Str("stopLoss".into())), &Value::Str("type".into()), stopLossType);
6653        }
6654        if (stopLossPriceType != Value::Null) {
6655            add_element_to_object(get_value_mut(&mut params, &Value::Str("stopLoss".into())), &Value::Str("priceType".into()), stopLossPriceType);
6656        }
6657        if (stopLossLimitPrice != Value::Null) {
6658            add_element_to_object(get_value_mut(&mut params, &Value::Str("stopLoss".into())), &Value::Str("price".into()), self.parse_to_numeric(stopLossLimitPrice));
6659        }
6660        if (stopLossAmount != Value::Null) {
6661            add_element_to_object(get_value_mut(&mut params, &Value::Str("stopLoss".into())), &Value::Str("amount".into()), self.parse_to_numeric(stopLossAmount));
6662        }
6663        let mut paramsOmitted: Value = self.omit(params, Value::from(vec![Value::Str("takeProfitType".into()), Value::Str("takeProfitPriceType".into()), Value::Str("takeProfitLimitPrice".into()), Value::Str("takeProfitAmount".into()), Value::Str("stopLossType".into()), Value::Str("stopLossPriceType".into()), Value::Str("stopLossLimitPrice".into()), Value::Str("stopLossAmount".into())]), &[]);
6664        return paramsOmitted;
6665
6666    Value::Null
6667}
6668
6669    fn create_spot_orders(&mut self, mut orders: Value, optional_args: &[Value]) -> impl ::std::future::Future<Output = Value> + Send { async move {
6670        let mut params = get_arg(optional_args, 0, Value::Map({
6671    let mut m = indexmap::IndexMap::new();
6672    m
6673}));
6674        panic!("{}", crate::exchange_errors::not_supported(format!("{}{}", self.id.clone(), Value::Str(" createSpotOrders() is not supported yet".into()))));
6675
6676    Value::Null
6677} }
6678
6679    fn create_contract_orders(&mut self, mut orders: Value, optional_args: &[Value]) -> impl ::std::future::Future<Output = Value> + Send { async move {
6680        let mut params = get_arg(optional_args, 0, Value::Map({
6681    let mut m = indexmap::IndexMap::new();
6682    m
6683}));
6684        panic!("{}", crate::exchange_errors::not_supported(format!("{}{}", self.id.clone(), Value::Str(" createContractOrders() is not supported yet".into()))));
6685
6686    Value::Null
6687} }
6688
6689    fn cancel_spot_order(&mut self, mut id: Value, optional_args: &[Value]) -> impl ::std::future::Future<Output = Value> + Send { async move {
6690        let mut symbol = get_arg(optional_args, 0, Value::Null);
6691        let mut params = get_arg(optional_args, 1, Value::Map({
6692    let mut m = indexmap::IndexMap::new();
6693    m
6694}));
6695        panic!("{}", crate::exchange_errors::not_supported(format!("{}{}", self.id.clone(), Value::Str(" cancelSpotOrder() is not supported yet".into()))));
6696
6697    Value::Null
6698} }
6699
6700    fn cancel_contract_order(&mut self, mut id: Value, optional_args: &[Value]) -> impl ::std::future::Future<Output = Value> + Send { async move {
6701        let mut symbol = get_arg(optional_args, 0, Value::Null);
6702        let mut params = get_arg(optional_args, 1, Value::Map({
6703    let mut m = indexmap::IndexMap::new();
6704    m
6705}));
6706        panic!("{}", crate::exchange_errors::not_supported(format!("{}{}", self.id.clone(), Value::Str(" cancelContractOrder() is not supported yet".into()))));
6707
6708    Value::Null
6709} }
6710
6711    fn cancel_all_spot_orders(&mut self, optional_args: &[Value]) -> impl ::std::future::Future<Output = Value> + Send { async move {
6712        let mut symbol = get_arg(optional_args, 0, Value::Null);
6713        let mut params = get_arg(optional_args, 1, Value::Map({
6714    let mut m = indexmap::IndexMap::new();
6715    m
6716}));
6717        panic!("{}", crate::exchange_errors::not_supported(format!("{}{}", self.id.clone(), Value::Str(" cancelAllSpotOrders() is not supported yet".into()))));
6718
6719    Value::Null
6720} }
6721
6722    fn cancel_all_contract_orders(&mut self, optional_args: &[Value]) -> impl ::std::future::Future<Output = Value> + Send { async move {
6723        let mut symbol = get_arg(optional_args, 0, Value::Null);
6724        let mut params = get_arg(optional_args, 1, Value::Map({
6725    let mut m = indexmap::IndexMap::new();
6726    m
6727}));
6728        panic!("{}", crate::exchange_errors::not_supported(format!("{}{}", self.id.clone(), Value::Str(" cancelAllContractOrders() is not supported yet".into()))));
6729
6730    Value::Null
6731} }
6732
6733    fn cancel_all_orders_after(&mut self, mut timeout: Value, optional_args: &[Value]) -> impl ::std::future::Future<Output = Value> + Send { async move {
6734        let mut params = get_arg(optional_args, 0, Value::Map({
6735    let mut m = indexmap::IndexMap::new();
6736    m
6737}));
6738        panic!("{}", crate::exchange_errors::not_supported(format!("{}{}", self.id.clone(), Value::Str(" cancelAllOrdersAfter() is not supported yet".into()))));
6739
6740    Value::Null
6741} }
6742
6743    fn cancel_orders_for_symbols(&mut self, mut orders: Value, optional_args: &[Value]) -> impl ::std::future::Future<Output = Value> + Send { async move {
6744        let mut params = get_arg(optional_args, 0, Value::Map({
6745    let mut m = indexmap::IndexMap::new();
6746    m
6747}));
6748        panic!("{}", crate::exchange_errors::not_supported(format!("{}{}", self.id.clone(), Value::Str(" cancelOrdersForSymbols() is not supported yet".into()))));
6749
6750    Value::Null
6751} }
6752
6753    fn fetch_my_liquidations(&mut self, optional_args: &[Value]) -> impl ::std::future::Future<Output = Value> + Send { async move {
6754        let mut symbol = get_arg(optional_args, 0, Value::Null);
6755        let mut since = get_arg(optional_args, 1, Value::Null);
6756        let mut limit = get_arg(optional_args, 2, Value::Null);
6757        let mut params = get_arg(optional_args, 3, Value::Map({
6758    let mut m = indexmap::IndexMap::new();
6759    m
6760}));
6761        panic!("{}", crate::exchange_errors::not_supported(format!("{}{}", self.id.clone(), Value::Str(" fetchMyLiquidations() is not supported yet".into()))));
6762
6763    Value::Null
6764} }
6765
6766    fn fetch_liquidations(&mut self, mut symbol: Value, optional_args: &[Value]) -> impl ::std::future::Future<Output = Value> + Send { async move {
6767        let mut since = get_arg(optional_args, 0, Value::Null);
6768        let mut limit = get_arg(optional_args, 1, Value::Null);
6769        let mut params = get_arg(optional_args, 2, Value::Map({
6770    let mut m = indexmap::IndexMap::new();
6771    m
6772}));
6773        panic!("{}", crate::exchange_errors::not_supported(format!("{}{}", self.id.clone(), Value::Str(" fetchLiquidations() is not supported yet".into()))));
6774
6775    Value::Null
6776} }
6777
6778    fn fetch_greeks(&mut self, mut symbol: Value, optional_args: &[Value]) -> impl ::std::future::Future<Output = Value> + Send { async move {
6779        let mut params = get_arg(optional_args, 0, Value::Map({
6780    let mut m = indexmap::IndexMap::new();
6781    m
6782}));
6783        panic!("{}", crate::exchange_errors::not_supported(format!("{}{}", self.id.clone(), Value::Str(" fetchGreeks() is not supported yet".into()))));
6784
6785    Value::Null
6786} }
6787
6788    fn fetch_all_greeks(&mut self, optional_args: &[Value]) -> impl ::std::future::Future<Output = Value> + Send { async move {
6789        let mut symbols = get_arg(optional_args, 0, Value::Null);
6790        let mut params = get_arg(optional_args, 1, Value::Map({
6791    let mut m = indexmap::IndexMap::new();
6792    m
6793}));
6794        panic!("{}", crate::exchange_errors::not_supported(format!("{}{}", self.id.clone(), Value::Str(" fetchAllGreeks() is not supported yet".into()))));
6795
6796    Value::Null
6797} }
6798
6799    fn fetch_option_chain(&mut self, mut code: Value, optional_args: &[Value]) -> impl ::std::future::Future<Output = Value> + Send { async move {
6800        let mut params = get_arg(optional_args, 0, Value::Map({
6801    let mut m = indexmap::IndexMap::new();
6802    m
6803}));
6804        panic!("{}", crate::exchange_errors::not_supported(format!("{}{}", self.id.clone(), Value::Str(" fetchOptionChain() is not supported yet".into()))));
6805
6806    Value::Null
6807} }
6808
6809    fn fetch_option(&mut self, mut symbol: Value, optional_args: &[Value]) -> impl ::std::future::Future<Output = Value> + Send { async move {
6810        let mut params = get_arg(optional_args, 0, Value::Map({
6811    let mut m = indexmap::IndexMap::new();
6812    m
6813}));
6814        panic!("{}", crate::exchange_errors::not_supported(format!("{}{}", self.id.clone(), Value::Str(" fetchOption() is not supported yet".into()))));
6815
6816    Value::Null
6817} }
6818
6819    fn fetch_convert_quote(&mut self, mut fromCode: Value, mut toCode: Value, optional_args: &[Value]) -> impl ::std::future::Future<Output = Value> + Send { async move {
6820        let mut amount = get_arg(optional_args, 0, Value::Null);
6821        let mut params = get_arg(optional_args, 1, Value::Map({
6822    let mut m = indexmap::IndexMap::new();
6823    m
6824}));
6825        panic!("{}", crate::exchange_errors::not_supported(format!("{}{}", self.id.clone(), Value::Str(" fetchConvertQuote() is not supported yet".into()))));
6826
6827    Value::Null
6828} }
6829
6830    fn fetch_deposits_withdrawals(&mut self, optional_args: &[Value]) -> impl ::std::future::Future<Output = Value> + Send { async move {
6831        // async-virtual: try the derived exchange first
6832        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 {
6833            if !matches!(__v, crate::Value::Null) { return __v; }
6834        }
6835
6836        let mut code = get_arg(optional_args, 0, Value::Null);
6837        let mut since = get_arg(optional_args, 1, Value::Null);
6838        let mut limit = get_arg(optional_args, 2, Value::Null);
6839        let mut params = get_arg(optional_args, 3, Value::Map({
6840    let mut m = indexmap::IndexMap::new();
6841    m
6842}));
6843        panic!("{}", crate::exchange_errors::not_supported(format!("{}{}", self.id.clone(), Value::Str(" fetchDepositsWithdrawals() is not supported yet".into()))));
6844
6845    Value::Null
6846} }
6847
6848    fn fetch_deposits(&mut self, optional_args: &[Value]) -> impl ::std::future::Future<Output = Value> + Send { async move {
6849        // async-virtual: try the derived exchange first
6850        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 {
6851            if !matches!(__v, crate::Value::Null) { return __v; }
6852        }
6853
6854        let mut code = get_arg(optional_args, 0, Value::Null);
6855        let mut since = get_arg(optional_args, 1, Value::Null);
6856        let mut limit = get_arg(optional_args, 2, Value::Null);
6857        let mut params = get_arg(optional_args, 3, Value::Map({
6858    let mut m = indexmap::IndexMap::new();
6859    m
6860}));
6861        panic!("{}", crate::exchange_errors::not_supported(format!("{}{}", self.id.clone(), Value::Str(" fetchDeposits() is not supported yet".into()))));
6862
6863    Value::Null
6864} }
6865
6866    fn fetch_withdrawals(&mut self, optional_args: &[Value]) -> impl ::std::future::Future<Output = Value> + Send { async move {
6867        // async-virtual: try the derived exchange first
6868        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 {
6869            if !matches!(__v, crate::Value::Null) { return __v; }
6870        }
6871
6872        let mut code = get_arg(optional_args, 0, Value::Null);
6873        let mut since = get_arg(optional_args, 1, Value::Null);
6874        let mut limit = get_arg(optional_args, 2, Value::Null);
6875        let mut params = get_arg(optional_args, 3, Value::Map({
6876    let mut m = indexmap::IndexMap::new();
6877    m
6878}));
6879        panic!("{}", crate::exchange_errors::not_supported(format!("{}{}", self.id.clone(), Value::Str(" fetchWithdrawals() is not supported yet".into()))));
6880
6881    Value::Null
6882} }
6883
6884    fn fetch_deposits_ws(&mut self, optional_args: &[Value]) -> impl ::std::future::Future<Output = Value> + Send { async move {
6885        let mut code = get_arg(optional_args, 0, Value::Null);
6886        let mut since = get_arg(optional_args, 1, Value::Null);
6887        let mut limit = get_arg(optional_args, 2, Value::Null);
6888        let mut params = get_arg(optional_args, 3, Value::Map({
6889    let mut m = indexmap::IndexMap::new();
6890    m
6891}));
6892        panic!("{}", crate::exchange_errors::not_supported(format!("{}{}", self.id.clone(), Value::Str(" fetchDepositsWs() is not supported yet".into()))));
6893
6894    Value::Null
6895} }
6896
6897    fn fetch_withdrawals_ws(&mut self, optional_args: &[Value]) -> impl ::std::future::Future<Output = Value> + Send { async move {
6898        let mut code = get_arg(optional_args, 0, Value::Null);
6899        let mut since = get_arg(optional_args, 1, Value::Null);
6900        let mut limit = get_arg(optional_args, 2, Value::Null);
6901        let mut params = get_arg(optional_args, 3, Value::Map({
6902    let mut m = indexmap::IndexMap::new();
6903    m
6904}));
6905        panic!("{}", crate::exchange_errors::not_supported(format!("{}{}", self.id.clone(), Value::Str(" fetchWithdrawalsWs() is not supported yet".into()))));
6906
6907    Value::Null
6908} }
6909
6910    fn fetch_funding_rate_history(&mut self, optional_args: &[Value]) -> impl ::std::future::Future<Output = Value> + Send { async move {
6911        // async-virtual: try the derived exchange first
6912        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 {
6913            if !matches!(__v, crate::Value::Null) { return __v; }
6914        }
6915
6916        let mut symbol = get_arg(optional_args, 0, Value::Null);
6917        let mut since = get_arg(optional_args, 1, Value::Null);
6918        let mut limit = get_arg(optional_args, 2, Value::Null);
6919        let mut params = get_arg(optional_args, 3, Value::Map({
6920    let mut m = indexmap::IndexMap::new();
6921    m
6922}));
6923        panic!("{}", crate::exchange_errors::not_supported(format!("{}{}", self.id.clone(), Value::Str(" fetchFundingRateHistory() is not supported yet".into()))));
6924
6925    Value::Null
6926} }
6927
6928    fn fetch_funding_history(&mut self, optional_args: &[Value]) -> impl ::std::future::Future<Output = Value> + Send { async move {
6929        let mut symbol = get_arg(optional_args, 0, Value::Null);
6930        let mut since = get_arg(optional_args, 1, Value::Null);
6931        let mut limit = get_arg(optional_args, 2, Value::Null);
6932        let mut params = get_arg(optional_args, 3, Value::Map({
6933    let mut m = indexmap::IndexMap::new();
6934    m
6935}));
6936        panic!("{}", crate::exchange_errors::not_supported(format!("{}{}", self.id.clone(), Value::Str(" fetchFundingHistory() is not supported yet".into()))));
6937
6938    Value::Null
6939} }
6940
6941    fn parse_last_price(&self, mut price: Value, optional_args: &[Value]) -> Value {
6942        // virtual-dispatch (static: DerivedExchange::parse_last_price(self, ...))
6943        { let __v = crate::exchange::DerivedExchange::parse_last_price(self, price, crate::runtime::get_arg(optional_args, 0, crate::Value::Null)); if !matches!(__v, crate::Value::Null) { return __v; } }
6944
6945        let mut market = get_arg(optional_args, 0, Value::Null);
6946        panic!("{}", crate::exchange_errors::not_supported(format!("{}{}", self.id.clone(), Value::Str(" parseLastPrice() is not supported yet".into()))));
6947
6948    Value::Null
6949}
6950
6951    fn fetch_deposit_address(&mut self, mut code: Value, optional_args: &[Value]) -> impl ::std::future::Future<Output = Value> + Send { async move {
6952        // async-virtual: try the derived exchange first
6953        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 {
6954            if !matches!(__v, crate::Value::Null) { return __v; }
6955        }
6956
6957        let mut params = get_arg(optional_args, 0, Value::Map({
6958    let mut m = indexmap::IndexMap::new();
6959    m
6960}));
6961        if (self.has.as_map().and_then(|__m| __m.get("fetchDepositAddresses")).cloned().unwrap_or(Value::Null) != Value::Null) && (self.has.as_map().and_then(|__m| __m.get("fetchDepositAddresses")).cloned().unwrap_or(Value::Null).as_bool() != Some(false)) {
6962            let mut depositAddresses: Value = self.fetch_deposit_addresses(&[Value::from(vec![code.clone()]), params.clone()]).await;
6963            let mut depositAddress: Value = self.safe_value(depositAddresses, code.clone(), &[]);
6964            if (depositAddress == Value::Null) {
6965                panic!("{}", crate::exchange_errors::invalid_address(format!("{}{}", Value::Str(format!("{}{}", Value::Str(format!("{}{}", self.id.clone(), Value::Str(" fetchDepositAddress() could not find a deposit address for ".into())).into()), code).into()), Value::Str(", make sure you have created a corresponding deposit address in your wallet on the exchange website".into()))));
6966            }  else {
6967                return depositAddress;
6968            }
6969        }  else if (self.has.as_map().and_then(|__m| __m.get("fetchDepositAddressesByNetwork")).cloned().unwrap_or(Value::Null) != Value::Null) && (self.has.as_map().and_then(|__m| __m.get("fetchDepositAddressesByNetwork")).cloned().unwrap_or(Value::Null).as_bool() != Some(false)) {
6970            let mut network: Value = self.safe_string_k(params.clone(), "network", &[]);
6971            let mut paramsOmitted: Value = self.omit(params, Value::Str("network".into()), &[]);
6972            let mut addressStructures: Value = self.fetch_deposit_addresses_by_network(code, &[paramsOmitted]).await;
6973            if (network != Value::Null) {
6974                return self.safe_dict(addressStructures.clone(), network, &[]);
6975            }  else {
6976                let mut keys: Value = object_keys(&addressStructures);
6977                let mut key: Value = keys.as_array().and_then(|__arr| __arr.get(0)).cloned().unwrap_or(Value::Null);
6978                return self.safe_dict(addressStructures, key, &[]);
6979            }
6980        }  else {
6981            panic!("{}", crate::exchange_errors::not_supported(format!("{}{}", self.id.clone(), Value::Str(" fetchDepositAddress() is not supported yet".into()))));
6982        }
6983
6984    Value::Null
6985} }
6986
6987    fn fetch_contract_deposit_address(&mut self, mut code: Value, optional_args: &[Value]) -> impl ::std::future::Future<Output = Value> + Send { async move {
6988        let mut params = get_arg(optional_args, 0, Value::Map({
6989    let mut m = indexmap::IndexMap::new();
6990    m
6991}));
6992        panic!("{}", crate::exchange_errors::not_supported(format!("{}{}", self.id.clone(), Value::Str(" fetchContractDepositAddress() is not supported yet".into()))));
6993
6994    Value::Null
6995} }
6996
6997    fn account(&self) -> Value {
6998        return Value::Map({
6999    let mut m = indexmap::IndexMap::new();
7000        m.insert("free".to_string(), Value::Null);
7001        m.insert("used".to_string(), Value::Null);
7002        m.insert("total".to_string(), Value::Null);
7003    m
7004});
7005
7006    Value::Null
7007}
7008
7009/*
7010 * @ignore
7011 * @method
7012 * @description merges a per-market (isolated margin) account into a flat code-keyed balance dict, summing string fields when the code recurs across markets
7013 * @param {object} result the code-keyed balance dict being built
7014 * @param {string} code unified currency code
7015 * @param {object} account a balance account with string free/used/total/debt
7016 * @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
7017 */
7018    fn merge_balance_account(&self, mut result: Value, mut code: Value, mut account: Value) -> Value {
7019        if !(in_op(&result, &code)) {
7020            if let Value::Dict(__d) = &mut result { std::sync::Arc::make_mut(__d).insert(crate::runtime::stringify_param(&code), account.clone()); }
7021            return result;
7022        }
7023        let mut fields: Value = Value::from(vec![Value::Str("free".into()), Value::Str("used".into()), Value::Str("total".into()), Value::Str("debt".into())]);
7024        {
7025                        let mut i: Value = Value::Int(0);
7026            let mut __for_first_138: bool = true;
7027            while { if !__for_first_138 { i = (match (&(i), &(Value::Int(1))) { (Value::Int(x), Value::Int(y)) => Value::Int(x + y), (Value::Int(x), Value::Float(y)) => Value::Float(*x as f64 + *y), (Value::Float(x), Value::Int(y)) => Value::Float(*x + *y as f64), (Value::Float(x), Value::Float(y)) => Value::Float(x + y), _ => Value::Null }); } __for_first_138 = false; i.as_f64().unwrap_or(f64::NAN) < ((fields.len() as i64) as f64) } {
7028            let mut field: Value = fields.as_array().and_then(|__arr| match &i { Value::Int(__n) => __arr.get(*__n as usize), Value::Str(__s) => __s.parse::<usize>().ok().and_then(|__n| __arr.get(__n)), _ => None }).cloned().unwrap_or(Value::Null);
7029            let mut current: Value = self.safe_string(result.as_map().and_then(|__m| code.as_str().and_then(|__k| __m.get(__k))).cloned().unwrap_or(Value::Null), field.clone(), &[]);
7030            let mut incoming: Value = self.safe_string(account.clone(), field.clone(), &[]);
7031            if (current == Value::Null) {
7032                add_element_to_object(get_value_mut(&mut result, &code), &field, incoming.clone());
7033            }  else if (incoming != Value::Null) {
7034                add_element_to_object(get_value_mut(&mut result, &code), &field, crate::precise::Precise::stringAdd(&current, &incoming));
7035            }
7036        }
7037        }
7038        return result;
7039
7040    Value::Null
7041}
7042
7043    fn common_currency_code(&self, mut code: Value) -> Value {
7044        if !is_true(&self.substituteCommonCurrencyCodes) {
7045            return code;
7046        }
7047        return self.safe_string(self.commonCurrencies.clone(), code.clone(), &[code.clone()]);
7048
7049    Value::Null
7050}
7051
7052    fn currency(&self, mut code: Value) -> Value {
7053        if (code == Value::Null) {
7054            panic!("{}", crate::exchange_errors::arguments_required(format!("{}{}", self.id.clone(), Value::Str(" currency() requires a code argument".into()))));
7055        }
7056        let mut keys: Value = object_keys(&self.currencies);
7057        let mut numCurrencies: f64 = ((keys.len() as i64) as f64);
7058        if (numCurrencies == 0.0) {
7059            panic!("{}", crate::exchange_errors::exchange_error(format!("{}{}", self.id.clone(), Value::Str(" currencies not loaded".into()))));
7060        }
7061        if matches!(&code, Value::Str(_)) {
7062            let mut currencies: Value = self.currencies.clone();
7063            let mut currenciesById: Value = self.currencies_by_id.clone();
7064            if (in_op(&currencies, &code)) {
7065                return currencies.as_map().and_then(|__m| code.as_str().and_then(|__k| __m.get(__k))).cloned().unwrap_or(Value::Null);
7066            }  else if (currenciesById != Value::Null) && (in_op(&currenciesById, &code)) {
7067                return currenciesById.as_map().and_then(|__m| code.as_str().and_then(|__k| __m.get(__k))).cloned().unwrap_or(Value::Null);
7068            }
7069        }
7070        panic!("{}", crate::exchange_errors::exchange_error(format!("{}{}", Value::Str(format!("{}{}", self.id.clone(), Value::Str(" does not have currency code ".into())).into()), code)));
7071
7072    Value::Null
7073}
7074
7075    fn market(&self, mut symbol: Value) -> Value {
7076        // virtual-dispatch (static: DerivedExchange::market(self, ...))
7077        { let __v = crate::exchange::DerivedExchange::market(self, symbol.clone()); if !matches!(__v, crate::Value::Null) { return __v; } }
7078        self.market_non_virtual(symbol)
7079    }
7080
7081    fn market_non_virtual(&self, mut symbol: Value) -> Value {
7082        if (symbol == Value::Null) {
7083            panic!("{}", crate::exchange_errors::arguments_required(format!("{}{}", self.id.clone(), Value::Str(" market() requires a symbol argument".into()))));
7084        }
7085        let mut markets: Value = self.markets.clone();
7086        if (markets == Value::Null) {
7087            panic!("{}", crate::exchange_errors::exchange_error(format!("{}{}", self.id.clone(), Value::Str(" markets not loaded".into()))));
7088        }
7089        let mut marketsById: Value = self.markets_by_id.clone();
7090        if (in_op(&markets, &symbol)) {
7091            return get_value(&markets, &symbol);
7092        }  else if (marketsById != Value::Null) && (in_op(&marketsById, &symbol)) {
7093            let mut marketsList: Value = get_value(&marketsById, &symbol);
7094            let mut marketsList: Value = get_value(&marketsById, &symbol);
7095            let mut defaultType: Value = self.safe_string2(self.options.clone(), Value::Str("defaultType".into()), Value::Str("defaultSubType".into()), &[Value::Str("spot".into())]);
7096            {
7097                                let mut i: Value = Value::Int(0);
7098                let mut __for_first_139: bool = true;
7099                while { if !__for_first_139 { i = (match (&(i), &(Value::Int(1))) { (Value::Int(x), Value::Int(y)) => Value::Int(x + y), (Value::Int(x), Value::Float(y)) => Value::Float(*x as f64 + *y), (Value::Float(x), Value::Int(y)) => Value::Float(*x + *y as f64), (Value::Float(x), Value::Float(y)) => Value::Float(x + y), _ => Value::Null }); } __for_first_139 = false; i.as_f64().unwrap_or(f64::NAN) < get_array_length(&marketsList).as_f64().unwrap_or(f64::NAN) } {
7100                let mut market: Value = get_value(&marketsList, &i);
7101                let mut market: Value = get_value(&marketsList, &i);
7102                if is_equal(&get_value(&market, &defaultType), &Value::Bool(true)) {
7103                    return market;
7104                }
7105            }
7106            }
7107            return get_value(&marketsList, &Value::Int(0));
7108        }  else if (ends_with(&symbol, &Value::Str("-C".into()))) || (ends_with(&symbol, &Value::Str("-P".into()))) || (starts_with(&symbol, &Value::Str("C-".into()))) || (starts_with(&symbol, &Value::Str("P-".into()))) {
7109            return <Self as crate::exchange_generated::ExchangeBase>::create_expired_option_market(self, symbol.clone());
7110        }
7111        panic!("{}", crate::exchange_errors::bad_symbol(format!("{}{}", Value::Str(format!("{}{}", self.id.clone(), Value::Str(" does not have market symbol ".into())).into()), symbol)));
7112
7113    Value::Null
7114}
7115
7116    fn create_expired_option_market(&self, mut symbol: Value) -> Value {
7117        // virtual-dispatch (static: DerivedExchange::create_expired_option_market(self, ...))
7118        { let __v = crate::exchange::DerivedExchange::create_expired_option_market(self, symbol); if !matches!(__v, crate::Value::Null) { return __v; } }
7119
7120        panic!("{}", crate::exchange_errors::not_supported(format!("{}{}", self.id.clone(), Value::Str(" createExpiredOptionMarket () is not supported yet".into()))));
7121
7122    Value::Null
7123}
7124
7125    fn is_leveraged_currency(&self, mut currencyCode: Value, optional_args: &[Value]) -> Value {
7126        let mut checkBaseCoin = get_arg(optional_args, 0, Value::Bool(false));
7127        let mut existingCurrencies = get_arg(optional_args, 1, Value::Null);
7128        let mut leverageSuffixes: Value = Value::from(vec![Value::Str("2L".into()), Value::Str("2S".into()), Value::Str("3L".into()), Value::Str("3S".into()), Value::Str("4L".into()), Value::Str("4S".into()), Value::Str("5L".into()), Value::Str("5S".into()), Value::Str("UP".into()), Value::Str("DOWN".into()), Value::Str("BULL".into()), Value::Str("BEAR".into())]);
7129        {
7130                        let mut i: Value = Value::Int(0);
7131            let mut __for_first_140: bool = true;
7132            while { if !__for_first_140 { i = (match (&(i), &(Value::Int(1))) { (Value::Int(x), Value::Int(y)) => Value::Int(x + y), (Value::Int(x), Value::Float(y)) => Value::Float(*x as f64 + *y), (Value::Float(x), Value::Int(y)) => Value::Float(*x + *y as f64), (Value::Float(x), Value::Float(y)) => Value::Float(x + y), _ => Value::Null }); } __for_first_140 = false; i.as_f64().unwrap_or(f64::NAN) < ((leverageSuffixes.len() as i64) as f64) } {
7133            let mut leverageSuffix: Value = leverageSuffixes.as_array().and_then(|__arr| match &i { Value::Int(__n) => __arr.get(*__n as usize), Value::Str(__s) => __s.parse::<usize>().ok().and_then(|__n| __arr.get(__n)), _ => None }).cloned().unwrap_or(Value::Null);
7134            let mut endsWithSuffix: bool = ends_with(&currencyCode, &leverageSuffix);
7135            if endsWithSuffix {
7136                if !is_true(&checkBaseCoin) {
7137                    return Value::Bool(true);
7138                }  else {
7139                    // check if base currency is inside dict
7140                    let mut baseCurrencyCode: Value = replace_str(&currencyCode, &leverageSuffix, &Value::Str("".into()));
7141                    if (existingCurrencies != Value::Null) && (in_op(&existingCurrencies, &baseCurrencyCode)) {
7142                        return Value::Bool(true);
7143                    }
7144                }
7145            }
7146        }
7147        }
7148        return Value::Bool(false);
7149
7150    Value::Null
7151}
7152
7153    fn cost_to_precision(&self, mut symbol: Value, mut cost: Value) -> Value {
7154        if (cost == Value::Null) {
7155            return Value::Null;
7156        }
7157        let mut market: Value = <Self as crate::exchange_generated::ExchangeBase>::market(self, symbol);
7158        return self.decimal_to_precision(cost, Value::Int(crate::runtime::TRUNCATE), self.safe_string2(market.as_map().and_then(|__m| __m.get("precision")).cloned().unwrap_or(Value::Null), Value::Str("cost".into()), Value::Str("price".into()), &[]), &[self.precisionMode.clone(), self.paddingMode.clone()]);
7159
7160    Value::Null
7161}
7162
7163    fn price_to_precision(&self, mut symbol: Value, mut price: Value) -> Value {
7164        if (price == Value::Null) {
7165            return Value::Null;
7166        }
7167        let mut market: Value = <Self as crate::exchange_generated::ExchangeBase>::market(self, symbol);
7168        let mut result: Value = self.decimal_to_precision(price, Value::Int(crate::runtime::ROUND), market.as_map().and_then(|__m| __m.get("precision")).cloned().unwrap_or(Value::Null).as_map().and_then(|__m| __m.get("price")).cloned().unwrap_or(Value::Null), &[self.precisionMode.clone(), self.paddingMode.clone()]);
7169        if (result.as_str() == Some("0")) {
7170            let mut pricePrecision: Value = self.number_to_string(market.as_map().and_then(|__m| __m.get("precision")).cloned().unwrap_or(Value::Null).as_map().and_then(|__m| __m.get("price")).cloned().unwrap_or(Value::Null));
7171            if (pricePrecision == Value::Null) {
7172                panic!("{}", crate::exchange_errors::bad_symbol(format!("{}{}", Value::Str(format!("{}{}", Value::Str(format!("{}{}", self.id.clone(), Value::Str(" priceToPrecision() market ".into())).into()), market.as_map().and_then(|__m| __m.get("symbol")).cloned().unwrap_or(Value::Null)).into()), Value::Str(" has no price precision".into()))));
7173            }
7174            panic!("{}", crate::exchange_errors::invalid_order(format!("{}{}", Value::Str(format!("{}{}", Value::Str(format!("{}{}", Value::Str(format!("{}{}", self.id.clone(), Value::Str(" price of ".into())).into()), market.as_map().and_then(|__m| __m.get("symbol")).cloned().unwrap_or(Value::Null)).into()), Value::Str(" must be greater than minimum price precision of ".into())).into()), pricePrecision)));
7175        }
7176        return result;
7177
7178    Value::Null
7179}
7180
7181    fn amount_to_precision(&self, mut symbol: Value, mut amount: Value) -> Value {
7182        if (amount == Value::Null) {
7183            return Value::Null;
7184        }
7185        let mut market: Value = <Self as crate::exchange_generated::ExchangeBase>::market(self, symbol);
7186        let mut result: Value = self.decimal_to_precision(amount, Value::Int(crate::runtime::TRUNCATE), market.as_map().and_then(|__m| __m.get("precision")).cloned().unwrap_or(Value::Null).as_map().and_then(|__m| __m.get("amount")).cloned().unwrap_or(Value::Null), &[self.precisionMode.clone(), self.paddingMode.clone()]);
7187        if (result.as_str() == Some("0")) {
7188            let mut amountPrecision: Value = self.number_to_string(market.as_map().and_then(|__m| __m.get("precision")).cloned().unwrap_or(Value::Null).as_map().and_then(|__m| __m.get("amount")).cloned().unwrap_or(Value::Null));
7189            if (amountPrecision == Value::Null) {
7190                panic!("{}", crate::exchange_errors::bad_symbol(format!("{}{}", Value::Str(format!("{}{}", Value::Str(format!("{}{}", self.id.clone(), Value::Str(" amountToPrecision() market ".into())).into()), market.as_map().and_then(|__m| __m.get("symbol")).cloned().unwrap_or(Value::Null)).into()), Value::Str(" has no amount precision".into()))));
7191            }
7192            panic!("{}", crate::exchange_errors::invalid_order(format!("{}{}", Value::Str(format!("{}{}", Value::Str(format!("{}{}", Value::Str(format!("{}{}", self.id.clone(), Value::Str(" amount of ".into())).into()), market.as_map().and_then(|__m| __m.get("symbol")).cloned().unwrap_or(Value::Null)).into()), Value::Str(" must be greater than minimum amount precision of ".into())).into()), amountPrecision)));
7193        }
7194        return result;
7195
7196    Value::Null
7197}
7198
7199    fn fee_to_precision(&self, mut symbol: Value, mut fee: Value) -> Value {
7200        if (fee == Value::Null) {
7201            return Value::Null;
7202        }
7203        let mut market: Value = <Self as crate::exchange_generated::ExchangeBase>::market(self, symbol);
7204        return self.decimal_to_precision(fee, Value::Int(crate::runtime::ROUND), market.as_map().and_then(|__m| __m.get("precision")).cloned().unwrap_or(Value::Null).as_map().and_then(|__m| __m.get("price")).cloned().unwrap_or(Value::Null), &[self.precisionMode.clone(), self.paddingMode.clone()]);
7205
7206    Value::Null
7207}
7208
7209    fn currency_to_precision(&self, mut code: Value, mut fee: Value, optional_args: &[Value]) -> Value {
7210        let mut networkCode = get_arg(optional_args, 0, Value::Null);
7211        if (code == Value::Null) {
7212            panic!("{}", crate::exchange_errors::arguments_required(format!("{}{}", self.id.clone(), Value::Str(" currencyToPrecision() requires a code argument".into()))));
7213        }
7214        let mut currency: Value = get_value(&self.currencies, &code);
7215        let mut precision: Value = self.safe_value_k(currency.clone(), "precision", &[]);
7216        if (networkCode != Value::Null) {
7217            let mut networks: Value = self.safe_dict_k(currency, "networks", &[Value::Map({
7218    let mut m = indexmap::IndexMap::new();
7219    m
7220})]);
7221            let mut networkItem: Value = self.safe_dict(networks, networkCode, &[Value::Map({
7222    let mut m = indexmap::IndexMap::new();
7223    m
7224})]);
7225            precision = self.safe_value_k(networkItem, "precision", &[precision.clone()]);
7226        }
7227        if (precision == Value::Null) {
7228            return self.force_string(fee.clone());
7229        }  else {
7230            let mut roundingMode: Value = self.safe_integer_k(self.options.clone(), "currencyToPrecisionRoundingMode", &[Value::Int(crate::runtime::ROUND)]);
7231            return self.decimal_to_precision(fee, roundingMode, precision, &[self.precisionMode.clone(), self.paddingMode.clone()]);
7232        }
7233
7234    Value::Null
7235}
7236
7237    fn force_string(&self, mut value: Value) -> Value {
7238        if !matches!(&value, Value::Str(_)) {
7239            return self.number_to_string(value.clone());
7240        }
7241        return value;
7242
7243    Value::Null
7244}
7245
7246    fn is_tick_precision(&self) -> Value {
7247        return Value::Bool(self.precisionMode.as_f64() == Value::Int(crate::runtime::TICK_SIZE).as_f64());
7248
7249    Value::Null
7250}
7251
7252    fn is_significant_precision(&self) -> Value {
7253        return Value::Bool(self.precisionMode.as_f64() == Value::Int(crate::runtime::SIGNIFICANT_DIGITS).as_f64());
7254
7255    Value::Null
7256}
7257
7258    fn safe_number(&self, mut obj: Value, mut key: Value, optional_args: &[Value]) -> Value {
7259        let mut defaultNumber = get_arg(optional_args, 0, Value::Null);
7260        let mut value: Value = self.safe_string(obj, key, &[]);
7261        return self.parse_number(value, &[defaultNumber]);
7262
7263    Value::Null
7264}
7265
7266    fn safe_number_n(&self, mut obj: Value, mut arr: Value, optional_args: &[Value]) -> Value {
7267        let mut defaultNumber = get_arg(optional_args, 0, Value::Null);
7268        let mut value: Value = self.safe_string_n(obj, arr, &[]);
7269        return self.parse_number(value, &[defaultNumber]);
7270
7271    Value::Null
7272}
7273
7274    fn parse_precision(&self, optional_args: &[Value]) -> Value {
7275        let mut precision = get_arg(optional_args, 0, Value::Null);
7276        /*
7277         * @ignore
7278         * @method
7279         * @param {string} precision The number of digits to the right of the decimal
7280         * @returns {string} a string number equal to 1e-precision
7281         */
7282        if (precision == Value::Null) {
7283            return Value::Null;
7284        }
7285        let mut precisionNumber: Value = (match &precision { Value::Str(__parse_s) => __parse_s.trim().parse::<i64>().map(Value::Int).unwrap_or(Value::Null), Value::Int(__parse_n) => Value::Int(*__parse_n), Value::Float(__parse_f) => Value::Int(*__parse_f as i64), _ => Value::Null });
7286        if (precisionNumber.as_f64() == Some(0.0)) {
7287            return Value::Str("1".into());
7288        }
7289        if precisionNumber.as_f64().unwrap_or(f64::NAN) > ((0i64) as f64) {
7290            let mut parsedPrecision: Value = Value::Str("0.".into());
7291            {
7292                                let mut i: Value = Value::Int(0);
7293                let mut __for_first_141: bool = true;
7294                while { if !__for_first_141 { i = (match (&(i), &(Value::Int(1))) { (Value::Int(x), Value::Int(y)) => Value::Int(x + y), (Value::Int(x), Value::Float(y)) => Value::Float(*x as f64 + *y), (Value::Float(x), Value::Int(y)) => Value::Float(*x + *y as f64), (Value::Float(x), Value::Float(y)) => Value::Float(x + y), _ => Value::Null }); } __for_first_141 = false; i.as_f64().unwrap_or(f64::NAN) < (match (&(precisionNumber), &(Value::Int(1))) { (Value::Int(x), Value::Int(y)) => Value::Int(x - y), (Value::Int(x), Value::Float(y)) => Value::Float(*x as f64 - *y), (Value::Float(x), Value::Int(y)) => Value::Float(*x - *y as f64), (Value::Float(x), Value::Float(y)) => Value::Float(x - y), _ => Value::Null }).as_f64().unwrap_or(f64::NAN) } {
7295                parsedPrecision = Value::Str(format!("{}{}", parsedPrecision, Value::Str("0".into())).into());
7296            }
7297            }
7298            return Value::Str(format!("{}{}", parsedPrecision, Value::Str("1".into())).into());
7299        }  else {
7300            let mut parsedPrecision: Value = Value::Str("1".into());
7301            {
7302                                let mut i: Value = Value::Int(0);
7303                let mut __for_first_142: bool = true;
7304                while { if !__for_first_142 { i = (match (&(i), &(Value::Int(1))) { (Value::Int(x), Value::Int(y)) => Value::Int(x + y), (Value::Int(x), Value::Float(y)) => Value::Float(*x as f64 + *y), (Value::Float(x), Value::Int(y)) => Value::Float(*x + *y as f64), (Value::Float(x), Value::Float(y)) => Value::Float(x + y), _ => Value::Null }); } __for_first_142 = false; i.as_f64().unwrap_or(f64::NAN) < (match (&((match (&(precisionNumber), &(Value::Int(-1))) { (Value::Int(x), Value::Int(y)) => Value::Int(x * y), (Value::Int(x), Value::Float(y)) => Value::Float(*x as f64 * *y), (Value::Float(x), Value::Int(y)) => Value::Float(*x * *y as f64), (Value::Float(x), Value::Float(y)) => Value::Float(x * y), _ => Value::Null })), &(Value::Int(1))) { (Value::Int(x), Value::Int(y)) => Value::Int(x - y), (Value::Int(x), Value::Float(y)) => Value::Float(*x as f64 - *y), (Value::Float(x), Value::Int(y)) => Value::Float(*x - *y as f64), (Value::Float(x), Value::Float(y)) => Value::Float(x - y), _ => Value::Null }).as_f64().unwrap_or(f64::NAN) } {
7305                parsedPrecision = Value::Str(format!("{}{}", parsedPrecision, Value::Str("0".into())).into());
7306            }
7307            }
7308            return Value::Str(format!("{}{}", parsedPrecision, Value::Str("0".into())).into());
7309        }
7310
7311    Value::Null
7312}
7313
7314    fn integer_precision_to_amount(&self, mut precision: Value) -> Value {
7315        /*
7316         * @ignore
7317         * @method
7318         * @description handles positive & negative numbers too. parsePrecision() does not handle negative numbers, but this method handles
7319         * @param {string} precision The number of digits to the right of the decimal
7320         * @returns {string} a string number equal to 1e-precision
7321         */
7322        if (precision == Value::Null) {
7323            return Value::Null;
7324        }
7325        if is_true(&crate::precise::Precise::stringGe(&precision, &Value::Str("0".into()))) {
7326            return self.parse_precision(&[precision.clone()]);
7327        }  else {
7328            let mut positivePrecisionString: Value = crate::precise::Precise::stringAbs(&precision);
7329            if (positivePrecisionString == Value::Null) {
7330                return Value::Null;
7331            }
7332            let mut positivePrecision: Value = (match &positivePrecisionString { Value::Str(__parse_s) => __parse_s.trim().parse::<i64>().map(Value::Int).unwrap_or(Value::Null), Value::Int(__parse_n) => Value::Int(*__parse_n), Value::Float(__parse_f) => Value::Int(*__parse_f as i64), _ => Value::Null });
7333            let mut parsedPrecision: Value = Value::Str("1".into());
7334            {
7335                                let mut i: Value = Value::Int(0);
7336                let mut __for_first_143: bool = true;
7337                while { if !__for_first_143 { i = (match (&(i), &(Value::Int(1))) { (Value::Int(x), Value::Int(y)) => Value::Int(x + y), (Value::Int(x), Value::Float(y)) => Value::Float(*x as f64 + *y), (Value::Float(x), Value::Int(y)) => Value::Float(*x + *y as f64), (Value::Float(x), Value::Float(y)) => Value::Float(x + y), _ => Value::Null }); } __for_first_143 = false; i.as_f64().unwrap_or(f64::NAN) < (match (&(positivePrecision), &(Value::Int(1))) { (Value::Int(x), Value::Int(y)) => Value::Int(x - y), (Value::Int(x), Value::Float(y)) => Value::Float(*x as f64 - *y), (Value::Float(x), Value::Int(y)) => Value::Float(*x - *y as f64), (Value::Float(x), Value::Float(y)) => Value::Float(x - y), _ => Value::Null }).as_f64().unwrap_or(f64::NAN) } {
7338                parsedPrecision = Value::Str(format!("{}{}", parsedPrecision, Value::Str("0".into())).into());
7339            }
7340            }
7341            return Value::Str(format!("{}{}", parsedPrecision, Value::Str("0".into())).into());
7342        }
7343}
7344
7345    fn load_time_difference(&mut self, optional_args: &[Value]) -> impl ::std::future::Future<Output = Value> + Send { async move {
7346        let mut params = get_arg(optional_args, 0, Value::Map({
7347    let mut m = indexmap::IndexMap::new();
7348    m
7349}));
7350        let mut serverTime: Value = self.fetch_time(&[params]).await;
7351        let mut after: Value = self.milliseconds();
7352        if (serverTime == Value::Null) {
7353            panic!("{}", crate::exchange_errors::exchange_error(format!("{}{}", self.id.clone(), Value::Str(" loadTimeDifference() missing serverTime".into()))));
7354        }
7355        if let Value::Dict(__d) = &mut self.options { std::sync::Arc::make_mut(__d).insert("timeDifference".into(), (match (&(after), &(serverTime)) { (Value::Int(x), Value::Int(y)) => Value::Int(x - y), (Value::Int(x), Value::Float(y)) => Value::Float(*x as f64 - *y), (Value::Float(x), Value::Int(y)) => Value::Float(*x - *y as f64), (Value::Float(x), Value::Float(y)) => Value::Float(x - y), _ => Value::Null })); }
7356        return self.options.as_map().and_then(|__m| __m.get("timeDifference")).cloned().unwrap_or(Value::Null);
7357
7358    Value::Null
7359} }
7360
7361    fn implode_hostname(&self, mut url: Value) -> Value {
7362        return self.implode_params(url, Value::Map({
7363    let mut m = indexmap::IndexMap::new();
7364        m.insert("hostname".to_string(), self.hostname.clone());
7365    m
7366}));
7367
7368    Value::Null
7369}
7370
7371    fn fetch_market_leverage_tiers(&mut self, mut symbol: Value, optional_args: &[Value]) -> impl ::std::future::Future<Output = Value> + Send { async move {
7372        // async-virtual: try the derived exchange first
7373        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 {
7374            if !matches!(__v, crate::Value::Null) { return __v; }
7375        }
7376
7377        let mut params = get_arg(optional_args, 0, Value::Map({
7378    let mut m = indexmap::IndexMap::new();
7379    m
7380}));
7381        if (self.has.as_map().and_then(|__m| __m.get("fetchLeverageTiers")).cloned().unwrap_or(Value::Null) != Value::Null) && (self.has.as_map().and_then(|__m| __m.get("fetchLeverageTiers")).cloned().unwrap_or(Value::Null).as_bool() != Some(false)) {
7382            let mut market: Value = <Self as crate::exchange_generated::ExchangeBase>::market(self, symbol.clone());
7383            if (market.as_map().and_then(|__m| __m.get("contract")).cloned().unwrap_or(Value::Null).as_bool() != Some(true)) {
7384                panic!("{}", crate::exchange_errors::bad_symbol(format!("{}{}", self.id.clone(), Value::Str(" fetchMarketLeverageTiers() supports contract markets only".into()))));
7385            }
7386            let mut tiers: Value = self.fetch_leverage_tiers(&[Value::from(vec![symbol.clone()])]).await;
7387            return self.safe_value(tiers, symbol, &[]);
7388        }  else {
7389            panic!("{}", crate::exchange_errors::not_supported(format!("{}{}", self.id.clone(), Value::Str(" fetchMarketLeverageTiers() is not supported yet".into()))));
7390        }
7391
7392    Value::Null
7393} }
7394
7395    fn create_sub_account(&mut self, mut name: Value, optional_args: &[Value]) -> impl ::std::future::Future<Output = Value> + Send { async move {
7396        let mut params = get_arg(optional_args, 0, Value::Map({
7397    let mut m = indexmap::IndexMap::new();
7398    m
7399}));
7400        panic!("{}", crate::exchange_errors::not_supported(format!("{}{}", self.id.clone(), Value::Str(" createSubAccount() is not supported yet".into()))));
7401
7402    Value::Null
7403} }
7404
7405    fn safe_currency_code(&self, mut currencyId: Value, optional_args: &[Value]) -> Value {
7406        let mut currency = get_arg(optional_args, 0, Value::Null);
7407        let mut currencyResolved: Value = self.safe_currency(currencyId, &[currency]);
7408        return currencyResolved.as_map().and_then(|__m| __m.get("code")).cloned().unwrap_or(Value::Null);
7409
7410    Value::Null
7411}
7412
7413    fn filter_by_symbol_since_limit(&self, mut array: Value, optional_args: &[Value]) -> Value {
7414        let mut symbol = get_arg(optional_args, 0, Value::Null);
7415        let mut since = get_arg(optional_args, 1, Value::Null);
7416        let mut limit = get_arg(optional_args, 2, Value::Null);
7417        let mut tail = get_arg(optional_args, 3, Value::Bool(false));
7418        return self.filter_by_value_since_limit(array, Value::Str("symbol".into()), &[symbol, since, limit, Value::Str("timestamp".into()), tail]);
7419
7420    Value::Null
7421}
7422
7423    fn filter_by_currency_since_limit(&self, mut array: Value, optional_args: &[Value]) -> Value {
7424        let mut code = get_arg(optional_args, 0, Value::Null);
7425        let mut since = get_arg(optional_args, 1, Value::Null);
7426        let mut limit = get_arg(optional_args, 2, Value::Null);
7427        let mut tail = get_arg(optional_args, 3, Value::Bool(false));
7428        return self.filter_by_value_since_limit(array, Value::Str("currency".into()), &[code, since, limit, Value::Str("timestamp".into()), tail]);
7429
7430    Value::Null
7431}
7432
7433    fn filter_by_symbols_since_limit(&self, mut array: Value, optional_args: &[Value]) -> Value {
7434        let mut symbols = get_arg(optional_args, 0, Value::Null);
7435        let mut since = get_arg(optional_args, 1, Value::Null);
7436        let mut limit = get_arg(optional_args, 2, Value::Null);
7437        let mut tail = get_arg(optional_args, 3, Value::Bool(false));
7438        let mut result: Value = self.filter_by_array(array, Value::Str("symbol".into()), &[symbols, Value::Bool(false)]);
7439        return self.filter_by_since_limit(result, &[since, limit, Value::Str("timestamp".into()), tail]);
7440
7441    Value::Null
7442}
7443
7444    fn parse_last_prices(&self, mut pricesData: Value, optional_args: &[Value]) -> Value {
7445        let mut symbols = get_arg(optional_args, 0, Value::Null);
7446        let mut params = get_arg(optional_args, 1, Value::Map({
7447    let mut m = indexmap::IndexMap::new();
7448    m
7449}));
7450        //
7451        // the value of tickers is either a dict or a list
7452        //
7453        // dict
7454        //
7455        //     {
7456        //         'marketId1': { ... },
7457        //         'marketId2': { ... },
7458        //         ...
7459        //     }
7460        //
7461        // list
7462        //
7463        //     [
7464        //         { 'market': 'marketId1', ... },
7465        //         { 'market': 'marketId2', ... },
7466        //         ...
7467        //     ]
7468        //
7469        let mut results: Value = Value::from(vec![]);
7470        if (matches!(&pricesData, Value::Arr(_))) {
7471            {
7472                                let mut i: Value = Value::Int(0);
7473                let mut __for_first_144: bool = true;
7474                while { if !__for_first_144 { i = (match (&(i), &(Value::Int(1))) { (Value::Int(x), Value::Int(y)) => Value::Int(x + y), (Value::Int(x), Value::Float(y)) => Value::Float(*x as f64 + *y), (Value::Float(x), Value::Int(y)) => Value::Float(*x + *y as f64), (Value::Float(x), Value::Float(y)) => Value::Float(x + y), _ => Value::Null }); } __for_first_144 = false; i.as_f64().unwrap_or(f64::NAN) < ((pricesData.len() as i64) as f64) } {
7475                let mut priceData: Value = self.extend(<Self as crate::exchange_generated::ExchangeBase>::parse_last_price(self, pricesData.as_array().and_then(|__arr| match &i { Value::Int(__n) => __arr.get(*__n as usize), Value::Str(__s) => __s.parse::<usize>().ok().and_then(|__n| __arr.get(__n)), _ => None }).cloned().unwrap_or(Value::Null), &[]), &[params.clone()]);
7476                append_to_array(&mut results, priceData.clone());
7477            }
7478            }
7479        }  else {
7480            let mut marketIds: Value = object_keys(&pricesData);
7481            {
7482                                let mut i: Value = Value::Int(0);
7483                let mut __for_first_145: bool = true;
7484                while { if !__for_first_145 { i = (match (&(i), &(Value::Int(1))) { (Value::Int(x), Value::Int(y)) => Value::Int(x + y), (Value::Int(x), Value::Float(y)) => Value::Float(*x as f64 + *y), (Value::Float(x), Value::Int(y)) => Value::Float(*x + *y as f64), (Value::Float(x), Value::Float(y)) => Value::Float(x + y), _ => Value::Null }); } __for_first_145 = false; i.as_f64().unwrap_or(f64::NAN) < ((marketIds.len() as i64) as f64) } {
7485                let mut marketId: Value = marketIds.as_array().and_then(|__arr| match &i { Value::Int(__n) => __arr.get(*__n as usize), Value::Str(__s) => __s.parse::<usize>().ok().and_then(|__n| __arr.get(__n)), _ => None }).cloned().unwrap_or(Value::Null);
7486                let mut market: Value = self.safe_market(&[marketId.clone()]);
7487                let mut priceData: Value = self.extend(<Self as crate::exchange_generated::ExchangeBase>::parse_last_price(self, get_value(&pricesData, &marketId), &[market]), &[params.clone()]);
7488                append_to_array(&mut results, priceData);
7489            }
7490            }
7491        }
7492        let mut symbolsNormalized: Value = self.market_symbols(&[symbols]);
7493        return self.filter_by_array(results, Value::Str("symbol".into()), &[symbolsNormalized]);
7494
7495    Value::Null
7496}
7497
7498    fn parse_tickers(&self, mut tickers: Value, optional_args: &[Value]) -> Value {
7499        let mut symbols = get_arg(optional_args, 0, Value::Null);
7500        let mut params = get_arg(optional_args, 1, Value::Map({
7501    let mut m = indexmap::IndexMap::new();
7502    m
7503}));
7504        //
7505        // the value of tickers is either a dict or a list
7506        //
7507        //
7508        // dict
7509        //
7510        //     {
7511        //         'marketId1': { ... },
7512        //         'marketId2': { ... },
7513        //         'marketId3': { ... },
7514        //         ...
7515        //     }
7516        //
7517        // list
7518        //
7519        //     [
7520        //         { 'market': 'marketId1', ... },
7521        //         { 'market': 'marketId2', ... },
7522        //         { 'market': 'marketId3', ... },
7523        //         ...
7524        //     ]
7525        //
7526        let mut results: Value = Value::from(vec![]);
7527        if (matches!(&tickers, Value::Arr(_))) {
7528            {
7529                                let mut i: Value = Value::Int(0);
7530                let mut __for_first_146: bool = true;
7531                while { if !__for_first_146 { i = (match (&(i), &(Value::Int(1))) { (Value::Int(x), Value::Int(y)) => Value::Int(x + y), (Value::Int(x), Value::Float(y)) => Value::Float(*x as f64 + *y), (Value::Float(x), Value::Int(y)) => Value::Float(*x + *y as f64), (Value::Float(x), Value::Float(y)) => Value::Float(x + y), _ => Value::Null }); } __for_first_146 = false; i.as_f64().unwrap_or(f64::NAN) < ((tickers.len() as i64) as f64) } {
7532                let mut parsedTicker: Value = <Self as crate::exchange_generated::ExchangeBase>::parse_ticker(self, tickers.as_array().and_then(|__arr| match &i { Value::Int(__n) => __arr.get(*__n as usize), Value::Str(__s) => __s.parse::<usize>().ok().and_then(|__n| __arr.get(__n)), _ => None }).cloned().unwrap_or(Value::Null), &[]);
7533                let mut ticker: Value = self.extend(parsedTicker, &[params.clone()]);
7534                append_to_array(&mut results, ticker.clone());
7535            }
7536            }
7537        }  else {
7538            let mut marketIds: Value = object_keys(&tickers);
7539            {
7540                                let mut i: Value = Value::Int(0);
7541                let mut __for_first_147: bool = true;
7542                while { if !__for_first_147 { i = (match (&(i), &(Value::Int(1))) { (Value::Int(x), Value::Int(y)) => Value::Int(x + y), (Value::Int(x), Value::Float(y)) => Value::Float(*x as f64 + *y), (Value::Float(x), Value::Int(y)) => Value::Float(*x + *y as f64), (Value::Float(x), Value::Float(y)) => Value::Float(x + y), _ => Value::Null }); } __for_first_147 = false; i.as_f64().unwrap_or(f64::NAN) < ((marketIds.len() as i64) as f64) } {
7543                let mut marketId: Value = marketIds.as_array().and_then(|__arr| match &i { Value::Int(__n) => __arr.get(*__n as usize), Value::Str(__s) => __s.parse::<usize>().ok().and_then(|__n| __arr.get(__n)), _ => None }).cloned().unwrap_or(Value::Null);
7544                let mut market: Value = self.safe_market(&[marketId.clone()]);
7545                let mut parsed: Value = <Self as crate::exchange_generated::ExchangeBase>::parse_ticker(self, get_value(&tickers, &marketId), &[market]);
7546                let mut ticker: Value = self.extend(parsed, &[params.clone()]);
7547                append_to_array(&mut results, ticker);
7548            }
7549            }
7550        }
7551        let mut symbolsNormalized: Value = self.market_symbols(&[symbols]);
7552        return self.filter_by_array_tickers(results, Value::Str("symbol".into()), &[symbolsNormalized]);
7553
7554    Value::Null
7555}
7556
7557    fn parse_deposit_addresses(&self, mut addresses: Value, optional_args: &[Value]) -> Value {
7558        let mut codes = get_arg(optional_args, 0, Value::Null);
7559        let mut indexed = get_arg(optional_args, 1, Value::Bool(true));
7560        let mut params = get_arg(optional_args, 2, Value::Map({
7561    let mut m = indexmap::IndexMap::new();
7562    m
7563}));
7564        let mut result: Value = Value::from(vec![]);
7565        {
7566                        let mut i: Value = Value::Int(0);
7567            let mut __for_first_148: bool = true;
7568            while { if !__for_first_148 { i = (match (&(i), &(Value::Int(1))) { (Value::Int(x), Value::Int(y)) => Value::Int(x + y), (Value::Int(x), Value::Float(y)) => Value::Float(*x as f64 + *y), (Value::Float(x), Value::Int(y)) => Value::Float(*x + *y as f64), (Value::Float(x), Value::Float(y)) => Value::Float(x + y), _ => Value::Null }); } __for_first_148 = false; i.as_f64().unwrap_or(f64::NAN) < get_array_length(&addresses).as_f64().unwrap_or(f64::NAN) } {
7569            let mut address: Value = self.extend(<Self as crate::exchange_generated::ExchangeBase>::parse_deposit_address(self, get_value(&addresses, &i), &[]), &[params.clone()]);
7570            append_to_array(&mut result, address);
7571        }
7572        }
7573        if (codes != Value::Null) {
7574            result = self.filter_by_array(result.clone(), Value::Str("currency".into()), &[codes, Value::Bool(false)]);
7575        }
7576        if is_true(&indexed) {
7577            result = self.filter_by_array(result.clone(), Value::Str("currency".into()), &[Value::Null, indexed.clone()]);
7578        }
7579        return result;
7580
7581    Value::Null
7582}
7583
7584    fn parse_borrow_interests(&self, mut response: Value, optional_args: &[Value]) -> Value {
7585        let mut market = get_arg(optional_args, 0, Value::Null);
7586        let mut interests: Value = Value::from(vec![]);
7587        {
7588                        let mut i: Value = Value::Int(0);
7589            let mut __for_first_149: bool = true;
7590            while { if !__for_first_149 { i = (match (&(i), &(Value::Int(1))) { (Value::Int(x), Value::Int(y)) => Value::Int(x + y), (Value::Int(x), Value::Float(y)) => Value::Float(*x as f64 + *y), (Value::Float(x), Value::Int(y)) => Value::Float(*x + *y as f64), (Value::Float(x), Value::Float(y)) => Value::Float(x + y), _ => Value::Null }); } __for_first_149 = false; i.as_f64().unwrap_or(f64::NAN) < get_array_length(&response).as_f64().unwrap_or(f64::NAN) } {
7591            let mut row: Value = get_value(&response, &i);
7592            let mut row: Value = get_value(&response, &i);
7593            append_to_array(&mut interests, <Self as crate::exchange_generated::ExchangeBase>::parse_borrow_interest(self, row, &[market.clone()]));
7594        }
7595        }
7596        return interests;
7597
7598    Value::Null
7599}
7600
7601    fn parse_borrow_rate(&self, mut info: Value, optional_args: &[Value]) -> Value {
7602        // virtual-dispatch (static: DerivedExchange::parse_borrow_rate(self, ...))
7603        { let __v = crate::exchange::DerivedExchange::parse_borrow_rate(self, info, crate::runtime::get_arg(optional_args, 0, crate::Value::Null)); if !matches!(__v, crate::Value::Null) { return __v; } }
7604
7605        let mut currency = get_arg(optional_args, 0, Value::Null);
7606        panic!("{}", crate::exchange_errors::not_supported(format!("{}{}", self.id.clone(), Value::Str(" parseBorrowRate() is not supported yet".into()))));
7607
7608    Value::Null
7609}
7610
7611    fn parse_borrow_rate_history(&self, mut response: Value, mut code: Value, mut since: Value, mut limit: Value) -> Value {
7612        let mut result: Value = Value::from(vec![]);
7613        {
7614                        let mut i: Value = Value::Int(0);
7615            let mut __for_first_150: bool = true;
7616            while { if !__for_first_150 { i = (match (&(i), &(Value::Int(1))) { (Value::Int(x), Value::Int(y)) => Value::Int(x + y), (Value::Int(x), Value::Float(y)) => Value::Float(*x as f64 + *y), (Value::Float(x), Value::Int(y)) => Value::Float(*x + *y as f64), (Value::Float(x), Value::Float(y)) => Value::Float(x + y), _ => Value::Null }); } __for_first_150 = false; i.as_f64().unwrap_or(f64::NAN) < get_array_length(&response).as_f64().unwrap_or(f64::NAN) } {
7617            let mut item: Value = get_value(&response, &i);
7618            let mut item: Value = get_value(&response, &i);
7619            let mut borrowRate: Value = <Self as crate::exchange_generated::ExchangeBase>::parse_borrow_rate(self, item, &[]);
7620            append_to_array(&mut result, borrowRate);
7621        }
7622        }
7623        let mut sorted: Value = self.sort_by(result, Value::Str("timestamp".into()), &[]);
7624        return self.filter_by_currency_since_limit(sorted, &[code, since, limit]);
7625
7626    Value::Null
7627}
7628
7629    fn parse_isolated_borrow_rates(&self, mut info: Value) -> Value {
7630        let mut result: Value = Value::Map({
7631            let mut m = indexmap::IndexMap::new();
7632            m
7633        });
7634        {
7635                        let mut i: Value = Value::Int(0);
7636            let mut __for_first_151: bool = true;
7637            while { if !__for_first_151 { i = (match (&(i), &(Value::Int(1))) { (Value::Int(x), Value::Int(y)) => Value::Int(x + y), (Value::Int(x), Value::Float(y)) => Value::Float(*x as f64 + *y), (Value::Float(x), Value::Int(y)) => Value::Float(*x + *y as f64), (Value::Float(x), Value::Float(y)) => Value::Float(x + y), _ => Value::Null }); } __for_first_151 = false; i.as_f64().unwrap_or(f64::NAN) < get_array_length(&info).as_f64().unwrap_or(f64::NAN) } {
7638            let mut item: Value = get_value(&info, &i);
7639            let mut item: Value = get_value(&info, &i);
7640            let mut borrowRate: Value = self.parse_isolated_borrow_rate(item, &[]);
7641            let mut symbol: Value = self.safe_string_k(borrowRate.clone(), "symbol", &[]);
7642            if let Value::Dict(__d) = &mut result { std::sync::Arc::make_mut(__d).insert(crate::runtime::stringify_param(&symbol), borrowRate); }
7643        }
7644        }
7645        return result;
7646
7647    Value::Null
7648}
7649
7650    fn parse_funding_rate_histories(&self, mut response: Value, optional_args: &[Value]) -> Value {
7651        let mut market = get_arg(optional_args, 0, Value::Null);
7652        let mut since = get_arg(optional_args, 1, Value::Null);
7653        let mut limit = get_arg(optional_args, 2, Value::Null);
7654        let mut rates: Value = Value::from(vec![]);
7655        {
7656                        let mut i: Value = Value::Int(0);
7657            let mut __for_first_152: bool = true;
7658            while { if !__for_first_152 { i = (match (&(i), &(Value::Int(1))) { (Value::Int(x), Value::Int(y)) => Value::Int(x + y), (Value::Int(x), Value::Float(y)) => Value::Float(*x as f64 + *y), (Value::Float(x), Value::Int(y)) => Value::Float(*x + *y as f64), (Value::Float(x), Value::Float(y)) => Value::Float(x + y), _ => Value::Null }); } __for_first_152 = false; i.as_f64().unwrap_or(f64::NAN) < get_array_length(&response).as_f64().unwrap_or(f64::NAN) } {
7659            let mut entry: Value = get_value(&response, &i);
7660            let mut entry: Value = get_value(&response, &i);
7661            append_to_array(&mut rates, <Self as crate::exchange_generated::ExchangeBase>::parse_funding_rate_history(self, entry, &[market.clone()]));
7662        }
7663        }
7664        let mut sorted: Value = self.sort_by(rates, Value::Str("timestamp".into()), &[]);
7665        let mut symbol: Value = (if (market == Value::Null) { Value::Null } else { market.as_map().and_then(|__m| __m.get("symbol")).cloned().unwrap_or(Value::Null) });
7666        return self.filter_by_symbol_since_limit(sorted, &[symbol, since, limit]);
7667
7668    Value::Null
7669}
7670
7671    fn safe_symbol(&self, mut marketId: Value, optional_args: &[Value]) -> Value {
7672        let mut market = get_arg(optional_args, 0, Value::Null);
7673        let mut delimiter = get_arg(optional_args, 1, Value::Null);
7674        let mut marketType = get_arg(optional_args, 2, Value::Null);
7675        let mut marketResolved: Value = self.safe_market(&[marketId, market, delimiter, marketType]);
7676        return marketResolved.as_map().and_then(|__m| __m.get("symbol")).cloned().unwrap_or(Value::Null);
7677
7678    Value::Null
7679}
7680
7681    fn parse_funding_rate(&self, mut contract: Value, optional_args: &[Value]) -> Value {
7682        // virtual-dispatch (static: DerivedExchange::parse_funding_rate(self, ...))
7683        { let __v = crate::exchange::DerivedExchange::parse_funding_rate(self, contract, crate::runtime::get_arg(optional_args, 0, crate::Value::Null)); if !matches!(__v, crate::Value::Null) { return __v; } }
7684
7685        let mut market = get_arg(optional_args, 0, Value::Null);
7686        panic!("{}", crate::exchange_errors::not_supported(format!("{}{}", self.id.clone(), Value::Str(" parseFundingRate() is not supported yet".into()))));
7687
7688    Value::Null
7689}
7690
7691    fn parse_funding_rates(&self, mut response: Value, optional_args: &[Value]) -> Value {
7692        let mut symbols = get_arg(optional_args, 0, Value::Null);
7693        let mut fundingRates: Value = Value::Map({
7694            let mut m = indexmap::IndexMap::new();
7695            m
7696        });
7697        {
7698                        let mut i: Value = Value::Int(0);
7699            let mut __for_first_153: bool = true;
7700            while { if !__for_first_153 { i = (match (&(i), &(Value::Int(1))) { (Value::Int(x), Value::Int(y)) => Value::Int(x + y), (Value::Int(x), Value::Float(y)) => Value::Float(*x as f64 + *y), (Value::Float(x), Value::Int(y)) => Value::Float(*x + *y as f64), (Value::Float(x), Value::Float(y)) => Value::Float(x + y), _ => Value::Null }); } __for_first_153 = false; i.as_f64().unwrap_or(f64::NAN) < get_array_length(&response).as_f64().unwrap_or(f64::NAN) } {
7701            let mut entry: Value = get_value(&response, &i);
7702            let mut entry: Value = get_value(&response, &i);
7703            let mut parsed: Value = <Self as crate::exchange_generated::ExchangeBase>::parse_funding_rate(self, entry, &[]);
7704            if (parsed.as_map().and_then(|__m| __m.get("symbol")).cloned().unwrap_or(Value::Null) != Value::Null) {
7705                add_element_to_object(&mut fundingRates, &parsed.as_map().and_then(|__m| __m.get("symbol")).cloned().unwrap_or(Value::Null), parsed.clone());
7706            }
7707        }
7708        }
7709        return self.index_by(self.filter_by_array(fundingRates, Value::Str("symbol".into()), &[symbols, Value::Bool(false)]), Value::Str("symbol".into()));
7710
7711    Value::Null
7712}
7713
7714    fn parse_long_short_ratio(&self, mut info: Value, optional_args: &[Value]) -> Value {
7715        let mut market = get_arg(optional_args, 0, Value::Null);
7716        panic!("{}", crate::exchange_errors::not_supported(format!("{}{}", self.id.clone(), Value::Str(" parseLongShortRatio() is not supported yet".into()))));
7717
7718    Value::Null
7719}
7720
7721    fn parse_long_short_ratio_history(&self, mut response: Value, optional_args: &[Value]) -> Value {
7722        let mut market = get_arg(optional_args, 0, Value::Null);
7723        let mut since = get_arg(optional_args, 1, Value::Null);
7724        let mut limit = get_arg(optional_args, 2, Value::Null);
7725        let mut rates: Value = Value::from(vec![]);
7726        {
7727                        let mut i: Value = Value::Int(0);
7728            let mut __for_first_154: bool = true;
7729            while { if !__for_first_154 { i = (match (&(i), &(Value::Int(1))) { (Value::Int(x), Value::Int(y)) => Value::Int(x + y), (Value::Int(x), Value::Float(y)) => Value::Float(*x as f64 + *y), (Value::Float(x), Value::Int(y)) => Value::Float(*x + *y as f64), (Value::Float(x), Value::Float(y)) => Value::Float(x + y), _ => Value::Null }); } __for_first_154 = false; i.as_f64().unwrap_or(f64::NAN) < get_array_length(&response).as_f64().unwrap_or(f64::NAN) } {
7730            let mut entry: Value = get_value(&response, &i);
7731            let mut entry: Value = get_value(&response, &i);
7732            append_to_array(&mut rates, self.parse_long_short_ratio(entry, &[market.clone()]));
7733        }
7734        }
7735        let mut sorted: Value = self.sort_by(rates, Value::Str("timestamp".into()), &[]);
7736        let mut symbol: Value = (if (market == Value::Null) { Value::Null } else { market.as_map().and_then(|__m| __m.get("symbol")).cloned().unwrap_or(Value::Null) });
7737        return self.filter_by_symbol_since_limit(sorted, &[symbol, since, limit]);
7738
7739    Value::Null
7740}
7741
7742    fn handle_trigger_prices_and_params(&self, mut symbol: Value, mut params: Value, optional_args: &[Value]) -> Value {
7743        let mut omitParams = get_arg(optional_args, 0, Value::Bool(true));
7744        //
7745        let mut triggerPrice: Value = self.safe_string2(params.clone(), Value::Str("triggerPrice".into()), Value::Str("stopPrice".into()), &[]);
7746        let mut triggerPriceStr: Value = Value::Null;
7747        let mut stopLossPrice: Value = self.safe_string_k(params.clone(), "stopLossPrice", &[]);
7748        let mut stopLossPriceStr: Value = Value::Null;
7749        let mut takeProfitPrice: Value = self.safe_string_k(params.clone(), "takeProfitPrice", &[]);
7750        let mut takeProfitPriceStr: Value = Value::Null;
7751        //
7752        let mut keysToOmit: Value = Value::from(vec![]);
7753        if (triggerPrice != Value::Null) {
7754            if is_true(&omitParams) {
7755                append_to_array(&mut keysToOmit, Value::Str("triggerPrice".into()));
7756                append_to_array(&mut keysToOmit, Value::Str("stopPrice".into()));
7757            }
7758            triggerPriceStr = self.price_to_precision(symbol.clone(), (match &triggerPrice { Value::Str(__parse_s) => __parse_s.trim().parse::<f64>().map(Value::Float).unwrap_or(Value::Null), Value::Float(__parse_f) => Value::Float(*__parse_f), Value::Int(__parse_n) => Value::Float(*__parse_n as f64), _ => Value::Null }));
7759        }
7760        if (stopLossPrice != Value::Null) {
7761            if is_true(&omitParams) {
7762                append_to_array(&mut keysToOmit, Value::Str("stopLossPrice".into()));
7763            }
7764            stopLossPriceStr = self.price_to_precision(symbol.clone(), (match &stopLossPrice { Value::Str(__parse_s) => __parse_s.trim().parse::<f64>().map(Value::Float).unwrap_or(Value::Null), Value::Float(__parse_f) => Value::Float(*__parse_f), Value::Int(__parse_n) => Value::Float(*__parse_n as f64), _ => Value::Null }));
7765        }
7766        if (takeProfitPrice != Value::Null) {
7767            if is_true(&omitParams) {
7768                append_to_array(&mut keysToOmit, Value::Str("takeProfitPrice".into()));
7769            }
7770            takeProfitPriceStr = self.price_to_precision(symbol, (match &takeProfitPrice { Value::Str(__parse_s) => __parse_s.trim().parse::<f64>().map(Value::Float).unwrap_or(Value::Null), Value::Float(__parse_f) => Value::Float(*__parse_f), Value::Int(__parse_n) => Value::Float(*__parse_n as f64), _ => Value::Null }));
7771        }
7772        let mut keysToOmitLength: f64 = ((keysToOmit.len() as i64) as f64);
7773        let mut paramsOmitted: Value = (if (keysToOmitLength > ((0i64) as f64)) { self.omit(params.clone(), keysToOmit, &[]) } else { params });
7774        return Value::from(vec![triggerPriceStr, stopLossPriceStr, takeProfitPriceStr, paramsOmitted]);
7775
7776    Value::Null
7777}
7778
7779    fn handle_trigger_direction_and_params(&self, mut params: Value, optional_args: &[Value]) -> Value {
7780        let mut exchangeSpecificKey = get_arg(optional_args, 0, Value::Null);
7781        let mut allowEmpty = get_arg(optional_args, 1, Value::Bool(false));
7782        /*
7783         * @ignore
7784         * @method
7785         * @returns {[string, object]} the trigger-direction value and omited params
7786         */
7787        let mut triggerDirection: Value = self.safe_string_k(params.clone(), "triggerDirection", &[]);
7788        let mut exchangeSpecificDefined: bool = (exchangeSpecificKey != Value::Null) && (in_op(&params, &exchangeSpecificKey));
7789        let mut paramsOmitted: Value = (if (triggerDirection != Value::Null) { self.omit(params.clone(), Value::Str("triggerDirection".into()), &[]) } else { params });
7790        // throw exception if:
7791        // A) if provided value is not unified (support old "up/down" strings too)
7792        // B) if exchange specific "trigger direction key" (eg. "stopPriceSide") was not provided
7793        if !(self.in_array(triggerDirection.clone(), Value::from(vec![Value::Str("ascending".into()), Value::Str("descending".into()), Value::Str("up".into()), Value::Str("down".into()), Value::Str("above".into()), Value::Str("below".into())])).as_bool() == Some(true)) && !exchangeSpecificDefined && !is_true(&allowEmpty) {
7794            panic!("{}", crate::exchange_errors::arguments_required(format!("{}{}", self.id.clone(), Value::Str(" createOrder() : trigger orders require params[\"triggerDirection\"] to be either \"ascending\" or \"descending\"".into()))));
7795        }
7796        // if old format was provided, overwrite to new
7797        if (triggerDirection.as_str() == Some("up")) || (triggerDirection.as_str() == Some("above")) {
7798            triggerDirection = Value::Str("ascending".into());
7799        }  else if (triggerDirection.as_str() == Some("down")) || (triggerDirection.as_str() == Some("below")) {
7800            triggerDirection = Value::Str("descending".into());
7801        }
7802        return Value::from(vec![triggerDirection, paramsOmitted]);
7803
7804    Value::Null
7805}
7806
7807    fn handle_trigger_and_params(&self, mut params: Value) -> Value {
7808        let mut isTrigger: Value = self.safe_bool2(params.clone(), Value::Str("trigger".into()), Value::Str("stop".into()), &[]);
7809        let mut paramsOmitted: Value = (if (isTrigger.as_bool() == Some(true)) { self.omit(params.clone(), Value::from(vec![Value::Str("trigger".into()), Value::Str("stop".into())]), &[]) } else { params });
7810        return Value::from(vec![isTrigger, paramsOmitted]);
7811
7812    Value::Null
7813}
7814
7815    fn is_trigger_order(&self, mut params: Value) -> Value {
7816        return self.handle_trigger_and_params(params);
7817
7818    Value::Null
7819}
7820
7821    fn is_post_only(&self, mut isMarketOrder: Value, mut exchangeSpecificParam: Value, optional_args: &[Value]) -> Value {
7822        let mut params = get_arg(optional_args, 0, Value::Map({
7823    let mut m = indexmap::IndexMap::new();
7824    m
7825}));
7826        /*
7827         * @ignore
7828         * @method
7829         * @param {string} type Order type
7830         * @param {boolean} exchangeSpecificParam exchange specific postOnly
7831         * @param {object} [params] exchange specific params
7832         * @returns {boolean} true if a post only order, false otherwise
7833         */
7834        let mut timeInForce: Value = self.safe_string_upper_k(params.clone(), "timeInForce", &[]);
7835        let mut postOnly: Value = self.safe_bool2(params, Value::Str("postOnly".into()), Value::Str("post_only".into()), &[Value::Bool(false)]);
7836        // we assume timeInForce is uppercase from safeStringUpper (params, 'timeInForce')
7837        let mut ioc: bool = timeInForce.as_str() == Some("IOC");
7838        let mut fok: bool = timeInForce.as_str() == Some("FOK");
7839        let mut timeInForcePostOnly: Value = Value::Bool(timeInForce.as_str() == Some("PO"));
7840        if (postOnly.as_bool() != Some(true)) {
7841            postOnly = timeInForcePostOnly;
7842        }
7843        if (postOnly.as_bool() != Some(true)) {
7844            postOnly = exchangeSpecificParam;
7845        }
7846        if (postOnly.as_bool() == Some(true)) {
7847            if ioc || fok {
7848                panic!("{}", crate::exchange_errors::invalid_order(format!("{}{}", Value::Str(format!("{}{}", self.id.clone(), Value::Str(" postOnly orders cannot have timeInForce equal to ".into())).into()), timeInForce)));
7849            }  else if is_true(&isMarketOrder) {
7850                panic!("{}", crate::exchange_errors::invalid_order(format!("{}{}", self.id.clone(), Value::Str(" market orders cannot be postOnly".into()))));
7851            }  else {
7852                return Value::Bool(true);
7853            }
7854        }  else {
7855            return Value::Bool(false);
7856        }
7857
7858    Value::Null
7859}
7860
7861    fn handle_post_only(&self, mut isMarketOrder: Value, mut exchangeSpecificPostOnlyOption: Value, optional_args: &[Value]) -> Value {
7862        let mut params = get_arg(optional_args, 0, Value::Map({
7863    let mut m = indexmap::IndexMap::new();
7864    m
7865}));
7866        /*
7867         * @ignore
7868         * @method
7869         * @param {string} type Order type
7870         * @param {boolean} exchangeSpecificBoolean exchange specific postOnly
7871         * @param {object} [params] exchange specific params
7872         * @returns {Array}
7873         */
7874        let mut timeInForce: Value = self.safe_string_upper_k(params.clone(), "timeInForce", &[]);
7875        let mut postOnly: Value = self.safe_bool_k(params.clone(), "postOnly", &[Value::Bool(false)]);
7876        let mut ioc: bool = timeInForce.as_str() == Some("IOC");
7877        let mut fok: bool = timeInForce.as_str() == Some("FOK");
7878        let mut po: Value = Value::Bool(timeInForce.as_str() == Some("PO"));
7879        if (postOnly.as_bool() != Some(true)) {
7880            postOnly = po.clone();
7881        }
7882        if (postOnly.as_bool() != Some(true)) {
7883            postOnly = exchangeSpecificPostOnlyOption;
7884        }
7885        if (postOnly.as_bool() == Some(true)) {
7886            if ioc || fok {
7887                panic!("{}", crate::exchange_errors::invalid_order(format!("{}{}", Value::Str(format!("{}{}", self.id.clone(), Value::Str(" postOnly orders cannot have timeInForce equal to ".into())).into()), timeInForce)));
7888            }  else if is_true(&isMarketOrder) {
7889                panic!("{}", crate::exchange_errors::invalid_order(format!("{}{}", self.id.clone(), Value::Str(" market orders cannot be postOnly".into()))));
7890            }  else {
7891                let mut keysToOmit: Value = Value::Null;
7892                if matches!(&po, Value::Bool(true)) {
7893                    keysToOmit = Value::from(vec![Value::Str("timeInForce".into()), Value::Str("postOnly".into())]);
7894                }  else {
7895                    keysToOmit = Value::from(vec![Value::Str("postOnly".into())]);
7896                }
7897                let mut paramsOmitted: Value = self.omit(params.clone(), keysToOmit, &[]);
7898                return Value::from(vec![Value::Bool(true), paramsOmitted]);
7899            }
7900        }
7901        return Value::from(vec![Value::Bool(false), params]);
7902
7903    Value::Null
7904}
7905
7906    fn fetch_last_prices(&mut self, optional_args: &[Value]) -> impl ::std::future::Future<Output = Value> + Send { async move {
7907        let mut symbols = get_arg(optional_args, 0, Value::Null);
7908        let mut params = get_arg(optional_args, 1, Value::Map({
7909    let mut m = indexmap::IndexMap::new();
7910    m
7911}));
7912        panic!("{}", crate::exchange_errors::not_supported(format!("{}{}", self.id.clone(), Value::Str(" fetchLastPrices() is not supported yet".into()))));
7913
7914    Value::Null
7915} }
7916
7917    fn fetch_trading_fees(&mut self, optional_args: &[Value]) -> impl ::std::future::Future<Output = Value> + Send { async move {
7918        // async-virtual: try the derived exchange first
7919        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 {
7920            if !matches!(__v, crate::Value::Null) { return __v; }
7921        }
7922
7923        let mut params = get_arg(optional_args, 0, Value::Map({
7924    let mut m = indexmap::IndexMap::new();
7925    m
7926}));
7927        panic!("{}", crate::exchange_errors::not_supported(format!("{}{}", self.id.clone(), Value::Str(" fetchTradingFees() is not supported yet".into()))));
7928
7929    Value::Null
7930} }
7931
7932    fn fetch_trading_fees_ws(&mut self, optional_args: &[Value]) -> impl ::std::future::Future<Output = Value> + Send { async move {
7933        let mut params = get_arg(optional_args, 0, Value::Map({
7934    let mut m = indexmap::IndexMap::new();
7935    m
7936}));
7937        panic!("{}", crate::exchange_errors::not_supported(format!("{}{}", self.id.clone(), Value::Str(" fetchTradingFeesWs() is not supported yet".into()))));
7938
7939    Value::Null
7940} }
7941
7942    fn fetch_convert_currencies(&mut self, optional_args: &[Value]) -> impl ::std::future::Future<Output = Value> + Send { async move {
7943        let mut params = get_arg(optional_args, 0, Value::Map({
7944    let mut m = indexmap::IndexMap::new();
7945    m
7946}));
7947        panic!("{}", crate::exchange_errors::not_supported(format!("{}{}", self.id.clone(), Value::Str(" fetchConvertCurrencies() is not supported yet".into()))));
7948
7949    Value::Null
7950} }
7951
7952    fn parse_open_interest(&self, mut interest: Value, optional_args: &[Value]) -> Value {
7953        // virtual-dispatch (static: DerivedExchange::parse_open_interest(self, ...))
7954        { let __v = crate::exchange::DerivedExchange::parse_open_interest(self, interest, crate::runtime::get_arg(optional_args, 0, crate::Value::Null)); if !matches!(__v, crate::Value::Null) { return __v; } }
7955
7956        let mut market = get_arg(optional_args, 0, Value::Null);
7957        panic!("{}", crate::exchange_errors::not_supported(format!("{}{}", self.id.clone(), Value::Str(" parseOpenInterest () is not supported yet".into()))));
7958
7959    Value::Null
7960}
7961
7962    fn parse_open_interests(&self, mut response: Value, optional_args: &[Value]) -> Value {
7963        let mut symbols = get_arg(optional_args, 0, Value::Null);
7964        let mut result: Value = Value::Map({
7965            let mut m = indexmap::IndexMap::new();
7966            m
7967        });
7968        {
7969                        let mut i: Value = Value::Int(0);
7970            let mut __for_first_155: bool = true;
7971            while { if !__for_first_155 { i = (match (&(i), &(Value::Int(1))) { (Value::Int(x), Value::Int(y)) => Value::Int(x + y), (Value::Int(x), Value::Float(y)) => Value::Float(*x as f64 + *y), (Value::Float(x), Value::Int(y)) => Value::Float(*x + *y as f64), (Value::Float(x), Value::Float(y)) => Value::Float(x + y), _ => Value::Null }); } __for_first_155 = false; i.as_f64().unwrap_or(f64::NAN) < get_array_length(&response).as_f64().unwrap_or(f64::NAN) } {
7972            let mut entry: Value = get_value(&response, &i);
7973            let mut entry: Value = get_value(&response, &i);
7974            let mut parsed: Value = <Self as crate::exchange_generated::ExchangeBase>::parse_open_interest(self, entry, &[]);
7975            if (parsed.as_map().and_then(|__m| __m.get("symbol")).cloned().unwrap_or(Value::Null) != Value::Null) {
7976                add_element_to_object(&mut result, &parsed.as_map().and_then(|__m| __m.get("symbol")).cloned().unwrap_or(Value::Null), parsed.clone());
7977            }
7978        }
7979        }
7980        return self.filter_by_array(result, Value::Str("symbol".into()), &[symbols]);
7981
7982    Value::Null
7983}
7984
7985    fn parse_open_interests_history(&self, mut response: Value, optional_args: &[Value]) -> Value {
7986        let mut market = get_arg(optional_args, 0, Value::Null);
7987        let mut since = get_arg(optional_args, 1, Value::Null);
7988        let mut limit = get_arg(optional_args, 2, Value::Null);
7989        let mut interests: Value = Value::from(vec![]);
7990        {
7991                        let mut i: Value = Value::Int(0);
7992            let mut __for_first_156: bool = true;
7993            while { if !__for_first_156 { i = (match (&(i), &(Value::Int(1))) { (Value::Int(x), Value::Int(y)) => Value::Int(x + y), (Value::Int(x), Value::Float(y)) => Value::Float(*x as f64 + *y), (Value::Float(x), Value::Int(y)) => Value::Float(*x + *y as f64), (Value::Float(x), Value::Float(y)) => Value::Float(x + y), _ => Value::Null }); } __for_first_156 = false; i.as_f64().unwrap_or(f64::NAN) < get_array_length(&response).as_f64().unwrap_or(f64::NAN) } {
7994            let mut entry: Value = get_value(&response, &i);
7995            let mut entry: Value = get_value(&response, &i);
7996            let mut interest: Value = <Self as crate::exchange_generated::ExchangeBase>::parse_open_interest(self, entry, &[market.clone()]);
7997            append_to_array(&mut interests, interest);
7998        }
7999        }
8000        let mut sorted: Value = self.sort_by(interests, Value::Str("timestamp".into()), &[]);
8001        let mut symbol: Value = self.safe_string_k(market, "symbol", &[]);
8002        return self.filter_by_symbol_since_limit(sorted, &[symbol, since, limit]);
8003
8004    Value::Null
8005}
8006
8007    fn fetch_funding_rate(&mut self, mut symbol: Value, optional_args: &[Value]) -> impl ::std::future::Future<Output = Value> + Send { async move {
8008        // async-virtual: try the derived exchange first
8009        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 {
8010            if !matches!(__v, crate::Value::Null) { return __v; }
8011        }
8012
8013        let mut params = get_arg(optional_args, 0, Value::Map({
8014    let mut m = indexmap::IndexMap::new();
8015    m
8016}));
8017        if (self.has.as_map().and_then(|__m| __m.get("fetchFundingRates")).cloned().unwrap_or(Value::Null) != Value::Null) && (self.has.as_map().and_then(|__m| __m.get("fetchFundingRates")).cloned().unwrap_or(Value::Null).as_bool() != Some(false)) {
8018            self.load_markets(&[]).await;
8019            let mut market: Value = <Self as crate::exchange_generated::ExchangeBase>::market(self, symbol);
8020            let mut symbolResolved: Value = market.as_map().and_then(|__m| __m.get("symbol")).cloned().unwrap_or(Value::Null);
8021            if (market.as_map().and_then(|__m| __m.get("contract")).cloned().unwrap_or(Value::Null).as_bool() != Some(true)) {
8022                panic!("{}", crate::exchange_errors::bad_symbol(format!("{}{}", self.id.clone(), Value::Str(" fetchFundingRate() supports contract markets only".into()))));
8023            }
8024            let mut rates: Value = self.fetch_funding_rates(&[Value::from(vec![symbolResolved.clone()]), params]).await;
8025            let mut rate: Value = self.safe_dict(rates, symbolResolved.clone(), &[]);
8026            if (rate == Value::Null) {
8027                panic!("{}", crate::exchange_errors::null_response(format!("{}{}", Value::Str(format!("{}{}", self.id.clone(), Value::Str(" fetchFundingRate () returned no data for ".into())).into()), symbolResolved)));
8028            }  else {
8029                return rate;
8030            }
8031        }  else {
8032            panic!("{}", crate::exchange_errors::not_supported(format!("{}{}", self.id.clone(), Value::Str(" fetchFundingRate () is not supported yet".into()))));
8033        }
8034
8035    Value::Null
8036} }
8037
8038    fn fetch_funding_interval(&mut self, mut symbol: Value, optional_args: &[Value]) -> impl ::std::future::Future<Output = Value> + Send { async move {
8039        // async-virtual: try the derived exchange first
8040        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 {
8041            if !matches!(__v, crate::Value::Null) { return __v; }
8042        }
8043
8044        let mut params = get_arg(optional_args, 0, Value::Map({
8045    let mut m = indexmap::IndexMap::new();
8046    m
8047}));
8048        if (self.has.as_map().and_then(|__m| __m.get("fetchFundingIntervals")).cloned().unwrap_or(Value::Null) != Value::Null) && (self.has.as_map().and_then(|__m| __m.get("fetchFundingIntervals")).cloned().unwrap_or(Value::Null).as_bool() != Some(false)) {
8049            self.load_markets(&[]).await;
8050            let mut market: Value = <Self as crate::exchange_generated::ExchangeBase>::market(self, symbol);
8051            let mut symbolResolved: Value = market.as_map().and_then(|__m| __m.get("symbol")).cloned().unwrap_or(Value::Null);
8052            if (market.as_map().and_then(|__m| __m.get("contract")).cloned().unwrap_or(Value::Null).as_bool() != Some(true)) {
8053                panic!("{}", crate::exchange_errors::bad_symbol(format!("{}{}", self.id.clone(), Value::Str(" fetchFundingInterval() supports contract markets only".into()))));
8054            }
8055            let mut rates: Value = self.fetch_funding_intervals(&[Value::from(vec![symbolResolved.clone()]), params]).await;
8056            let mut rate: Value = self.safe_dict(rates, symbolResolved.clone(), &[]);
8057            if (rate == Value::Null) {
8058                panic!("{}", crate::exchange_errors::null_response(format!("{}{}", Value::Str(format!("{}{}", self.id.clone(), Value::Str(" fetchFundingInterval() returned no data for ".into())).into()), symbolResolved)));
8059            }  else {
8060                return rate;
8061            }
8062        }  else {
8063            panic!("{}", crate::exchange_errors::not_supported(format!("{}{}", self.id.clone(), Value::Str(" fetchFundingInterval() is not supported yet".into()))));
8064        }
8065
8066    Value::Null
8067} }
8068
8069    fn fetch_mark_ohlcv(&mut self, mut symbol: Value, optional_args: &[Value]) -> impl ::std::future::Future<Output = Value> + Send { async move {
8070        let mut timeframe = get_arg(optional_args, 0, Value::Str("1m".into()));
8071        let mut since = get_arg(optional_args, 1, Value::Null);
8072        let mut limit = get_arg(optional_args, 2, Value::Null);
8073        let mut params = get_arg(optional_args, 3, Value::Map({
8074    let mut m = indexmap::IndexMap::new();
8075    m
8076}));
8077        /*
8078         * @method
8079         * @name exchange#fetchMarkOHLCV
8080         * @description fetches historical mark price candlestick data containing the open, high, low, and close price of a market
8081         * @param {string} symbol unified symbol of the market to fetch OHLCV data for
8082         * @param {string} timeframe the length of time each candle represents
8083         * @param {int} [since] timestamp in ms of the earliest candle to fetch
8084         * @param {int} [limit] the maximum amount of candles to fetch
8085         * @param {object} [params] extra parameters specific to the exchange API endpoint
8086         * @returns {float[][]} A list of candles ordered as timestamp, open, high, low, close, undefined
8087         */
8088        if (self.has.as_map().and_then(|__m| __m.get("fetchMarkOHLCV")).cloned().unwrap_or(Value::Null) != Value::Null) && (self.has.as_map().and_then(|__m| __m.get("fetchMarkOHLCV")).cloned().unwrap_or(Value::Null).as_bool() != Some(false)) {
8089            let mut request: Value = Value::Map({
8090                let mut m = indexmap::IndexMap::new();
8091                    m.insert("price".to_string(), Value::Str("mark".into()));
8092                m
8093            });
8094            return self.fetch_ohlcv(symbol, &[timeframe, since, limit, self.extend(request, &[params])]).await;
8095        }  else {
8096            panic!("{}", crate::exchange_errors::not_supported(format!("{}{}", self.id.clone(), Value::Str(" fetchMarkOHLCV () is not supported yet".into()))));
8097        }
8098} }
8099
8100    fn fetch_index_ohlcv(&mut self, mut symbol: Value, optional_args: &[Value]) -> impl ::std::future::Future<Output = Value> + Send { async move {
8101        let mut timeframe = get_arg(optional_args, 0, Value::Str("1m".into()));
8102        let mut since = get_arg(optional_args, 1, Value::Null);
8103        let mut limit = get_arg(optional_args, 2, Value::Null);
8104        let mut params = get_arg(optional_args, 3, Value::Map({
8105    let mut m = indexmap::IndexMap::new();
8106    m
8107}));
8108        /*
8109         * @method
8110         * @name exchange#fetchIndexOHLCV
8111         * @description fetches historical index price candlestick data containing the open, high, low, and close price of a market
8112         * @param {string} symbol unified symbol of the market to fetch OHLCV data for
8113         * @param {string} timeframe the length of time each candle represents
8114         * @param {int} [since] timestamp in ms of the earliest candle to fetch
8115         * @param {int} [limit] the maximum amount of candles to fetch
8116         * @param {object} [params] extra parameters specific to the exchange API endpoint
8117         * @returns {} A list of candles ordered as timestamp, open, high, low, close, undefined
8118         */
8119        if (self.has.as_map().and_then(|__m| __m.get("fetchIndexOHLCV")).cloned().unwrap_or(Value::Null) != Value::Null) && (self.has.as_map().and_then(|__m| __m.get("fetchIndexOHLCV")).cloned().unwrap_or(Value::Null).as_bool() != Some(false)) {
8120            let mut request: Value = Value::Map({
8121                let mut m = indexmap::IndexMap::new();
8122                    m.insert("price".to_string(), Value::Str("index".into()));
8123                m
8124            });
8125            return self.fetch_ohlcv(symbol, &[timeframe, since, limit, self.extend(request, &[params])]).await;
8126        }  else {
8127            panic!("{}", crate::exchange_errors::not_supported(format!("{}{}", self.id.clone(), Value::Str(" fetchIndexOHLCV () is not supported yet".into()))));
8128        }
8129} }
8130
8131    fn fetch_premium_index_ohlcv(&mut self, mut symbol: Value, optional_args: &[Value]) -> impl ::std::future::Future<Output = Value> + Send { async move {
8132        // async-virtual: try the derived exchange first
8133        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 {
8134            if !matches!(__v, crate::Value::Null) { return __v; }
8135        }
8136
8137        let mut timeframe = get_arg(optional_args, 0, Value::Str("1m".into()));
8138        let mut since = get_arg(optional_args, 1, Value::Null);
8139        let mut limit = get_arg(optional_args, 2, Value::Null);
8140        let mut params = get_arg(optional_args, 3, Value::Map({
8141    let mut m = indexmap::IndexMap::new();
8142    m
8143}));
8144        /*
8145         * @method
8146         * @name exchange#fetchPremiumIndexOHLCV
8147         * @description fetches historical premium index price candlestick data containing the open, high, low, and close price of a market
8148         * @param {string} symbol unified symbol of the market to fetch OHLCV data for
8149         * @param {string} timeframe the length of time each candle represents
8150         * @param {int} [since] timestamp in ms of the earliest candle to fetch
8151         * @param {int} [limit] the maximum amount of candles to fetch
8152         * @param {object} [params] extra parameters specific to the exchange API endpoint
8153         * @returns {float[][]} A list of candles ordered as timestamp, open, high, low, close, undefined
8154         */
8155        if (self.has.as_map().and_then(|__m| __m.get("fetchPremiumIndexOHLCV")).cloned().unwrap_or(Value::Null) != Value::Null) && (self.has.as_map().and_then(|__m| __m.get("fetchPremiumIndexOHLCV")).cloned().unwrap_or(Value::Null).as_bool() != Some(false)) {
8156            let mut request: Value = Value::Map({
8157                let mut m = indexmap::IndexMap::new();
8158                    m.insert("price".to_string(), Value::Str("premiumIndex".into()));
8159                m
8160            });
8161            return self.fetch_ohlcv(symbol, &[timeframe, since, limit, self.extend(request, &[params])]).await;
8162        }  else {
8163            panic!("{}", crate::exchange_errors::not_supported(format!("{}{}", self.id.clone(), Value::Str(" fetchPremiumIndexOHLCV () is not supported yet".into()))));
8164        }
8165} }
8166
8167    fn handle_time_in_force(&self, optional_args: &[Value]) -> Value {
8168        let mut params = get_arg(optional_args, 0, Value::Map({
8169    let mut m = indexmap::IndexMap::new();
8170    m
8171}));
8172        /*
8173         * @ignore
8174         * @method
8175         * Must add timeInForce to this.options to use this method
8176         * @returns {string} returns the exchange specific value for timeInForce
8177         */
8178        let mut timeInForce: Value = self.safe_string_upper_k(params, "timeInForce", &[]); // supported values GTC, IOC, PO
8179        if (timeInForce != Value::Null) {
8180            let mut exchangeValue: Value = self.safe_string(self.options.as_map().and_then(|__m| __m.get("timeInForce")).cloned().unwrap_or(Value::Null), timeInForce.clone(), &[]);
8181            if (exchangeValue == Value::Null) {
8182                panic!("{}", crate::exchange_errors::exchange_error(format!("{}{}", Value::Str(format!("{}{}", Value::Str(format!("{}{}", self.id.clone(), Value::Str(" does not support timeInForce \"".into())).into()), timeInForce).into()), Value::Str("\"".into()))));
8183            }
8184            return exchangeValue;
8185        }
8186        return Value::Null;
8187
8188    Value::Null
8189}
8190
8191    fn convert_type_to_account(&self, mut account: Value) -> Value {
8192        /*
8193         * @ignore
8194         * @method
8195         * Must add accountsByType to this.options to use this method
8196         * @param {string} account key for account name in this.options['accountsByType']
8197         * @returns the exchange specific account name or the isolated margin id for transfers
8198         */
8199        let mut accountsByType: Value = self.safe_dict_k(self.options.clone(), "accountsByType", &[Value::Map({
8200    let mut m = indexmap::IndexMap::new();
8201    m
8202})]);
8203        let mut lowercaseAccount: Value = to_lower(&account);
8204        if (in_op(&accountsByType, &lowercaseAccount)) {
8205            return get_value(&accountsByType, &lowercaseAccount);
8206        }
8207        let mut markets: Value = self.markets.clone();
8208        let mut marketsById: Value = self.markets_by_id.clone();
8209        if ((markets != Value::Null) && (in_op(&markets, &account))) || ((marketsById != Value::Null) && (in_op(&marketsById, &account))) {
8210            let mut market: Value = <Self as crate::exchange_generated::ExchangeBase>::market(self, account.clone());
8211            return market.as_map().and_then(|__m| __m.get("id")).cloned().unwrap_or(Value::Null);
8212        }  else {
8213            return account;
8214        }
8215
8216    Value::Null
8217}
8218
8219    fn check_required_argument(&self, mut methodName: Value, mut argument: Value, mut argumentName: Value, optional_args: &[Value]) {
8220        let mut options = get_arg(optional_args, 0, Value::from(vec![]));
8221        /*
8222         * @ignore
8223         * @method
8224         * @param {string} methodName the name of the method that the argument is being checked for
8225         * @param {string} argument the argument's actual value provided
8226         * @param {string} argumentName the name of the argument being checked (for logging purposes)
8227         * @param {string[]} options a list of options that the argument can be
8228         * @returns {undefined}
8229         */
8230        let mut optionsLength: f64 = ((options.len() as i64) as f64);
8231        if (argument == Value::Null) || ((optionsLength > ((0i64) as f64)) && (!(self.in_array(argument, options.clone()).as_bool() == Some(true)))) {
8232            let mut messageOptions: Value = join(&options, &Value::Str(", ".into()));
8233            let mut message: Value = Value::Str(format!("{}{}", Value::Str(format!("{}{}", Value::Str(format!("{}{}", Value::Str(format!("{}{}", Value::Str(format!("{}{}", self.id.clone(), Value::Str(" ".into())).into()), methodName).into()), Value::Str("() requires a ".into())).into()), argumentName).into()), Value::Str(" argument".into())).into());
8234            if (messageOptions.as_str() != Some("")) {
8235                message = Value::Str(format!("{}{}", message, Value::Str(format!("{}{}", Value::Str(format!("{}{}", Value::Str(format!("{}{}", Value::Str(", one of ".into()), Value::Str("(".into())).into()), messageOptions).into()), Value::Str(")".into())).into())).into());
8236            }
8237            panic!("{}", crate::exchange_errors::arguments_required(message));
8238        }
8239}
8240
8241    fn check_required_margin_argument(&self, mut methodName: Value, mut symbol: Value, mut marginMode: Value) {
8242        /*
8243         * @ignore
8244         * @method
8245         * @param {string} symbol unified symbol of the market
8246         * @param {string} methodName name of the method that requires a symbol
8247         * @param {string} marginMode is either 'isolated' or 'cross'
8248         */
8249        if (marginMode.as_str() == Some("isolated")) && (symbol == Value::Null) {
8250            panic!("{}", crate::exchange_errors::arguments_required(format!("{}{}", Value::Str(format!("{}{}", Value::Str(format!("{}{}", self.id.clone(), Value::Str(" ".into())).into()), methodName).into()), Value::Str("() requires a symbol argument for isolated margin".into()))));
8251        }  else if (marginMode.as_str() == Some("cross")) && (symbol != Value::Null) {
8252            panic!("{}", crate::exchange_errors::arguments_required(format!("{}{}", Value::Str(format!("{}{}", Value::Str(format!("{}{}", self.id.clone(), Value::Str(" ".into())).into()), methodName).into()), Value::Str("() cannot have a symbol argument for cross margin".into()))));
8253        }
8254}
8255
8256    fn parse_deposit_withdraw_fees(&self, mut response: Value, optional_args: &[Value]) -> Value {
8257        let mut codes = get_arg(optional_args, 0, Value::Null);
8258        let mut currencyIdKey = get_arg(optional_args, 1, Value::Null);
8259        /*
8260         * @ignore
8261         * @method
8262         * @param {object[]|object} response unparsed response from the exchange
8263         * @param {string[]|undefined} codes the unified currency codes to fetch transactions fees for, returns all currencies when undefined
8264         * @param {str} currencyIdKey *should only be undefined when response is a dictionary* the object key that corresponds to the currency id
8265         * @returns {object} objects with withdraw and deposit fees, indexed by currency codes
8266         */
8267        let mut depositWithdrawFees: Value = Value::Map({
8268            let mut m = indexmap::IndexMap::new();
8269            m
8270        });
8271        let mut isArray: bool = matches!(&response, Value::Arr(_));
8272        let mut responseKeys: Value = response.clone();
8273        if !isArray {
8274            responseKeys = object_keys(&response);
8275        }
8276        {
8277                        let mut i: Value = Value::Int(0);
8278            let mut __for_first_157: bool = true;
8279            while { if !__for_first_157 { i = (match (&(i), &(Value::Int(1))) { (Value::Int(x), Value::Int(y)) => Value::Int(x + y), (Value::Int(x), Value::Float(y)) => Value::Float(*x as f64 + *y), (Value::Float(x), Value::Int(y)) => Value::Float(*x + *y as f64), (Value::Float(x), Value::Float(y)) => Value::Float(x + y), _ => Value::Null }); } __for_first_157 = false; i.as_f64().unwrap_or(f64::NAN) < get_array_length(&responseKeys).as_f64().unwrap_or(f64::NAN) } {
8280            let mut entry: Value = get_value(&responseKeys, &i);
8281            let mut entry: Value = get_value(&responseKeys, &i);
8282            let mut dictionary: Value = (if isArray { entry.clone() } else { get_value(&response, &entry) });
8283            let mut currencyId: Value = entry;
8284            if isArray {
8285                currencyId = (if (currencyIdKey == Value::Null) { Value::Null } else { self.safe_string(dictionary.clone(), currencyIdKey.clone(), &[]) });
8286            }
8287            let mut currency: Value = self.safe_currency(currencyId, &[]);
8288            let mut code: Value = self.safe_string_k(currency.clone(), "code", &[]);
8289            if (codes == Value::Null) || self.in_array(code.clone(), codes.clone()).as_bool() == Some(true) {
8290                if let Value::Dict(__d) = &mut depositWithdrawFees { std::sync::Arc::make_mut(__d).insert(crate::runtime::stringify_param(&code), <Self as crate::exchange_generated::ExchangeBase>::parse_deposit_withdraw_fee(self, dictionary, &[currency])); }
8291            }
8292        }
8293        }
8294        return depositWithdrawFees;
8295
8296    Value::Null
8297}
8298
8299    fn parse_deposit_withdraw_fee(&self, mut fee: Value, optional_args: &[Value]) -> Value {
8300        // virtual-dispatch (static: DerivedExchange::parse_deposit_withdraw_fee(self, ...))
8301        { let __v = crate::exchange::DerivedExchange::parse_deposit_withdraw_fee(self, fee, crate::runtime::get_arg(optional_args, 0, crate::Value::Null)); if !matches!(__v, crate::Value::Null) { return __v; } }
8302
8303        let mut currency = get_arg(optional_args, 0, Value::Null);
8304        panic!("{}", crate::exchange_errors::not_supported(format!("{}{}", self.id.clone(), Value::Str(" parseDepositWithdrawFee() is not supported yet".into()))));
8305
8306    Value::Null
8307}
8308
8309    fn deposit_withdraw_fee(&self, mut info: Value) -> Value {
8310        return Value::Map({
8311    let mut m = indexmap::IndexMap::new();
8312        m.insert("info".to_string(), info);
8313        m.insert("withdraw".to_string(), Value::Map({
8314    let mut m = indexmap::IndexMap::new();
8315        m.insert("fee".to_string(), Value::Null);
8316        m.insert("percentage".to_string(), Value::Null);
8317    m
8318}));
8319        m.insert("deposit".to_string(), Value::Map({
8320    let mut m = indexmap::IndexMap::new();
8321        m.insert("fee".to_string(), Value::Null);
8322        m.insert("percentage".to_string(), Value::Null);
8323    m
8324}));
8325        m.insert("networks".to_string(), Value::Map({
8326    let mut m = indexmap::IndexMap::new();
8327    m
8328}));
8329    m
8330});
8331
8332    Value::Null
8333}
8334
8335    fn assign_default_deposit_withdraw_fees(&self, mut fee: Value, optional_args: &[Value]) -> Value {
8336        let mut currency = get_arg(optional_args, 0, Value::Null);
8337        let __currency_empty = indexmap::IndexMap::new();
8338        let currency = currency.as_map().unwrap_or(&__currency_empty);
8339        /*
8340         * @ignore
8341         * @method
8342         * @description Takes a depositWithdrawFee structure and assigns the default values for withdraw and deposit
8343         * @param {object} fee A deposit withdraw fee structure
8344         * @param {object} currency A currency structure, the response from this.currency ()
8345         * @returns {object} A deposit withdraw fee structure
8346         */
8347        let mut networkKeys: Value = object_keys(&crate::value::get_value_k(&fee, "networks"));
8348        let mut numNetworks: f64 = ((networkKeys.len() as i64) as f64);
8349        if (numNetworks == 1.0) {
8350            { let __be_tmp = crate::value::get_value_k(&get_value(&crate::value::get_value_k(&fee, "networks"), &networkKeys.as_array().and_then(|__arr| __arr.get(0)).cloned().unwrap_or(Value::Null)), "withdraw"); add_element_to_object(&mut fee, &Value::Str("withdraw".into()), __be_tmp); };
8351            { let __be_tmp = crate::value::get_value_k(&get_value(&crate::value::get_value_k(&fee, "networks"), &networkKeys.as_array().and_then(|__arr| __arr.get(0)).cloned().unwrap_or(Value::Null)), "deposit"); add_element_to_object(&mut fee, &Value::Str("deposit".into()), __be_tmp); };
8352            return fee;
8353        }
8354        let mut currencyCode: Value = (match currency.get("code") { Some(Value::Str(__s)) if !__s.is_empty() => Value::Str(__s.clone()), Some(Value::Int(__n)) => Value::Str(__n.to_string().into()), Some(Value::Float(__f)) => Value::Str(__f.to_string().into()), _ => Value::Null });
8355        {
8356                        let mut i: Value = Value::Int(0);
8357            let mut __for_first_158: bool = true;
8358            while { if !__for_first_158 { i = (match (&(i), &(Value::Int(1))) { (Value::Int(x), Value::Int(y)) => Value::Int(x + y), (Value::Int(x), Value::Float(y)) => Value::Float(*x as f64 + *y), (Value::Float(x), Value::Int(y)) => Value::Float(*x + *y as f64), (Value::Float(x), Value::Float(y)) => Value::Float(x + y), _ => Value::Null }); } __for_first_158 = false; i.as_f64().unwrap_or(f64::NAN) < numNetworks } {
8359            let mut network: Value = networkKeys.as_array().and_then(|__arr| match &i { Value::Int(__n) => __arr.get(*__n as usize), Value::Str(__s) => __s.parse::<usize>().ok().and_then(|__n| __arr.get(__n)), _ => None }).cloned().unwrap_or(Value::Null);
8360            if (network.as_str() == currencyCode.as_str()) {
8361                { let __be_tmp = crate::value::get_value_k(&get_value(&crate::value::get_value_k(&fee, "networks"), &networkKeys.as_array().and_then(|__arr| match &i { Value::Int(__n) => __arr.get(*__n as usize), Value::Str(__s) => __s.parse::<usize>().ok().and_then(|__n| __arr.get(__n)), _ => None }).cloned().unwrap_or(Value::Null)), "withdraw"); add_element_to_object(&mut fee, &Value::Str("withdraw".into()), __be_tmp); };
8362                { let __be_tmp = crate::value::get_value_k(&get_value(&crate::value::get_value_k(&fee, "networks"), &networkKeys.as_array().and_then(|__arr| match &i { Value::Int(__n) => __arr.get(*__n as usize), Value::Str(__s) => __s.parse::<usize>().ok().and_then(|__n| __arr.get(__n)), _ => None }).cloned().unwrap_or(Value::Null)), "deposit"); add_element_to_object(&mut fee, &Value::Str("deposit".into()), __be_tmp); };
8363            }
8364        }
8365        }
8366        return fee;
8367
8368    Value::Null
8369}
8370
8371    fn parse_income(&self, mut info: Value, optional_args: &[Value]) -> Value {
8372        // virtual-dispatch (static: DerivedExchange::parse_income(self, ...))
8373        { let __v = crate::exchange::DerivedExchange::parse_income(self, info, crate::runtime::get_arg(optional_args, 0, crate::Value::Null)); if !matches!(__v, crate::Value::Null) { return __v; } }
8374
8375        let mut market = get_arg(optional_args, 0, Value::Null);
8376        panic!("{}", crate::exchange_errors::not_supported(format!("{}{}", self.id.clone(), Value::Str(" parseIncome () is not supported yet".into()))));
8377
8378    Value::Null
8379}
8380
8381    fn parse_incomes(&self, mut incomes: Value, optional_args: &[Value]) -> Value {
8382        let mut market = get_arg(optional_args, 0, Value::Null);
8383        let mut since = get_arg(optional_args, 1, Value::Null);
8384        let mut limit = get_arg(optional_args, 2, Value::Null);
8385        /*
8386         * @ignore
8387         * @method
8388         * @description parses funding fee info from exchange response
8389         * @param {object[]} incomes each item describes once instance of currency being received or paid
8390         * @param {object} market ccxt market
8391         * @param {int} [since] when defined, the response items are filtered to only include items after this timestamp
8392         * @param {int} [limit] limits the number of items in the response
8393         * @returns {object[]} an array of [funding history structures]{@link https://docs.ccxt.com/?id=funding-history-structure}
8394         */
8395        let mut result: Value = Value::from(vec![]);
8396        {
8397                        let mut i: Value = Value::Int(0);
8398            let mut __for_first_159: bool = true;
8399            while { if !__for_first_159 { i = (match (&(i), &(Value::Int(1))) { (Value::Int(x), Value::Int(y)) => Value::Int(x + y), (Value::Int(x), Value::Float(y)) => Value::Float(*x as f64 + *y), (Value::Float(x), Value::Int(y)) => Value::Float(*x + *y as f64), (Value::Float(x), Value::Float(y)) => Value::Float(x + y), _ => Value::Null }); } __for_first_159 = false; i.as_f64().unwrap_or(f64::NAN) < get_array_length(&incomes).as_f64().unwrap_or(f64::NAN) } {
8400            let mut entry: Value = get_value(&incomes, &i);
8401            let mut entry: Value = get_value(&incomes, &i);
8402            let mut parsed: Value = <Self as crate::exchange_generated::ExchangeBase>::parse_income(self, entry, &[market.clone()]);
8403            append_to_array(&mut result, parsed);
8404        }
8405        }
8406        let mut sorted: Value = self.sort_by(result, Value::Str("timestamp".into()), &[]);
8407        let mut symbol: Value = self.safe_string_k(market, "symbol", &[]);
8408        return self.filter_by_symbol_since_limit(sorted, &[symbol, since, limit]);
8409
8410    Value::Null
8411}
8412
8413    fn get_market_from_symbols(&self, optional_args: &[Value]) -> Value {
8414        let mut symbols = get_arg(optional_args, 0, Value::Null);
8415        /*
8416         * @param {string[]|undefined} symbols list of unified symbols (first element selects the market)
8417         * @returns {MarketInterface|undefined} market structure for the first symbol, or undefined if symbols is undefined
8418         * Overloads: non-null `string[]` input yields `MarketInterface`; optional input yields `Market`.
8419         */
8420        if (symbols == Value::Null) {
8421            return Value::Null;
8422        }
8423        let mut firstMarket: Value = self.safe_string(symbols, Value::Int(0), &[]);
8424        if (firstMarket == Value::Null) {
8425            return Value::Null;
8426        }
8427        let mut market: Value = <Self as crate::exchange_generated::ExchangeBase>::market(self, firstMarket);
8428        return market;
8429
8430    Value::Null
8431}
8432
8433    fn parse_ws_ohlc_vs(&self, mut ohlcvs: Value, optional_args: &[Value]) -> Value {
8434        let mut market = get_arg(optional_args, 0, Value::Null);
8435        let mut timeframe = get_arg(optional_args, 1, Value::Str("1m".into()));
8436        let mut since = get_arg(optional_args, 2, Value::Null);
8437        let mut limit = get_arg(optional_args, 3, Value::Null);
8438        let mut results: Value = Value::from(vec![]);
8439        {
8440                        let mut i: Value = Value::Int(0);
8441            let mut __for_first_160: bool = true;
8442            while { if !__for_first_160 { i = (match (&(i), &(Value::Int(1))) { (Value::Int(x), Value::Int(y)) => Value::Int(x + y), (Value::Int(x), Value::Float(y)) => Value::Float(*x as f64 + *y), (Value::Float(x), Value::Int(y)) => Value::Float(*x + *y as f64), (Value::Float(x), Value::Float(y)) => Value::Float(x + y), _ => Value::Null }); } __for_first_160 = false; i.as_f64().unwrap_or(f64::NAN) < ((ohlcvs.len() as i64) as f64) } {
8443            append_to_array(&mut results, self.parse_ws_ohlcv(ohlcvs.as_array().and_then(|__arr| match &i { Value::Int(__n) => __arr.get(*__n as usize), Value::Str(__s) => __s.parse::<usize>().ok().and_then(|__n| __arr.get(__n)), _ => None }).cloned().unwrap_or(Value::Null), &[market.clone()]));
8444        }
8445        }
8446        return results;
8447
8448    Value::Null
8449}
8450
8451    fn fetch_transactions(&mut self, optional_args: &[Value]) -> impl ::std::future::Future<Output = Value> + Send { async move {
8452        let mut code = get_arg(optional_args, 0, Value::Null);
8453        let mut since = get_arg(optional_args, 1, Value::Null);
8454        let mut limit = get_arg(optional_args, 2, Value::Null);
8455        let mut params = get_arg(optional_args, 3, Value::Map({
8456    let mut m = indexmap::IndexMap::new();
8457    m
8458}));
8459        /*
8460         * @method
8461         * @name exchange#fetchTransactions
8462         * @deprecated
8463         * @description *DEPRECATED* use fetchDepositsWithdrawals instead
8464         * @param {string} code unified currency code for the currency of the deposit/withdrawals, default is undefined
8465         * @param {int} [since] timestamp in ms of the earliest deposit/withdrawal, default is undefined
8466         * @param {int} [limit] max number of deposit/withdrawals to return, default is undefined
8467         * @param {object} [params] extra parameters specific to the exchange API endpoint
8468         * @returns {object} a list of [transaction structures]{@link https://docs.ccxt.com/?id=transaction-structure}
8469         */
8470        if (self.has.as_map().and_then(|__m| __m.get("fetchDepositsWithdrawals")).cloned().unwrap_or(Value::Null) != Value::Null) && (self.has.as_map().and_then(|__m| __m.get("fetchDepositsWithdrawals")).cloned().unwrap_or(Value::Null).as_bool() != Some(false)) {
8471            return self.fetch_deposits_withdrawals(&[code, since, limit, params]).await;
8472        }  else {
8473            panic!("{}", crate::exchange_errors::not_supported(format!("{}{}", self.id.clone(), Value::Str(" fetchTransactions () is not supported yet".into()))));
8474        }
8475} }
8476
8477    fn filter_by_array_positions(&self, mut objects: Value, mut key: Value, optional_args: &[Value]) -> Value {
8478        let mut values = get_arg(optional_args, 0, Value::Null);
8479        return self.to_array(self.filter_by_array(objects, key, &[values, Value::Bool(false)]));
8480
8481    Value::Null
8482}
8483
8484    fn filter_by_array_tickers(&self, mut objects: Value, mut key: Value, optional_args: &[Value]) -> Value {
8485        let mut values = get_arg(optional_args, 0, Value::Null);
8486        return self.index_by(self.filter_by_array(objects, key.clone(), &[values, Value::Bool(false)]), key);
8487
8488    Value::Null
8489}
8490
8491    fn filter_by_array_adl_ranks(&self, mut objects: Value, mut key: Value, optional_args: &[Value]) -> Value {
8492        let mut values = get_arg(optional_args, 0, Value::Null);
8493        let mut indexed = get_arg(optional_args, 1, Value::Bool(true));
8494        return self.filter_by_array(objects, key, &[values, indexed]);
8495
8496    Value::Null
8497}
8498
8499    fn create_ohlcv_object(&self, mut symbol: Value, mut timeframe: Value, mut data: Value) -> Value {
8500        let mut res: Value = Value::Map({
8501            let mut m = indexmap::IndexMap::new();
8502            m
8503        });
8504        if let Value::Dict(__d) = &mut res { std::sync::Arc::make_mut(__d).insert(crate::runtime::stringify_param(&symbol), Value::Map({
8505    let mut m = indexmap::IndexMap::new();
8506    m
8507})); }
8508        add_element_to_object(get_value_mut(&mut res, &symbol), &timeframe, data);
8509        return res;
8510
8511    Value::Null
8512}
8513
8514    fn handle_max_entries_per_request_and_params(&self, mut method: Value, optional_args: &[Value]) -> Value {
8515        let mut maxEntriesPerRequest = get_arg(optional_args, 0, Value::Null);
8516        let mut params = get_arg(optional_args, 1, Value::Map({
8517    let mut m = indexmap::IndexMap::new();
8518    m
8519}));
8520        let mut newMaxEntriesPerRequestparamsMaxEntriesPerRequestVariable = self.handle_option_integer_and_params(params, method, Value::Str("maxEntriesPerRequest".into()), &[]);
8521        let mut newMaxEntriesPerRequest: Value = newMaxEntriesPerRequestparamsMaxEntriesPerRequestVariable.as_array().and_then(|__arr| __arr.get(0)).cloned().unwrap_or(Value::Null);
8522        let mut paramsMaxEntriesPerRequest: Value = newMaxEntriesPerRequestparamsMaxEntriesPerRequestVariable.as_array().and_then(|__arr| __arr.get(1)).cloned().unwrap_or(Value::Null);
8523        let mut maxEntriesPerRequestOption: Value = (if (newMaxEntriesPerRequest != Value::Null) { newMaxEntriesPerRequest } else { maxEntriesPerRequest });
8524        let mut maxEntriesPerRequestResolved: Value = (if (maxEntriesPerRequestOption == Value::Null) { Value::Int(1000) } else { maxEntriesPerRequestOption }); // default to 1000
8525        return Value::from(vec![maxEntriesPerRequestResolved, paramsMaxEntriesPerRequest]);
8526
8527    Value::Null
8528}
8529
8530    fn fetch_paginated_call_dynamic(&mut self, mut method: Value, optional_args: &[Value]) -> impl ::std::future::Future<Output = Value> + Send { async move {
8531        let mut symbol = get_arg(optional_args, 0, Value::Null);
8532        let mut since = get_arg(optional_args, 1, Value::Null);
8533        let mut limit = get_arg(optional_args, 2, Value::Null);
8534        let mut params = get_arg(optional_args, 3, Value::Map({
8535    let mut m = indexmap::IndexMap::new();
8536    m
8537}));
8538        let mut maxEntriesPerRequest = get_arg(optional_args, 4, Value::Null);
8539        let mut removeRepeated = get_arg(optional_args, 5, Value::Bool(true));
8540        let mut maxCalls: Value = Value::Int(10);
8541        let mut maxCallsPaginationCallsparamsPaginationCallsVariable = self.handle_option_integer_and_params(params, method.clone(), Value::Str("paginationCalls".into()), &[maxCalls]);
8542        let mut maxCallsPaginationCalls: Value = maxCallsPaginationCallsparamsPaginationCallsVariable.as_array().and_then(|__arr| __arr.get(0)).cloned().unwrap_or(Value::Null);
8543        let mut paramsPaginationCalls: Value = maxCallsPaginationCallsparamsPaginationCallsVariable.as_array().and_then(|__arr| __arr.get(1)).cloned().unwrap_or(Value::Null);
8544        let mut maxRetries: Value = Value::Int(3);
8545        let mut maxRetriesOptionparamsMaxRetriesVariable = self.handle_option_integer_and_params(paramsPaginationCalls, method.clone(), Value::Str("maxRetries".into()), &[maxRetries]);
8546        let mut maxRetriesOption: Value = maxRetriesOptionparamsMaxRetriesVariable.as_array().and_then(|__arr| __arr.get(0)).cloned().unwrap_or(Value::Null);
8547        let mut paramsMaxRetries: Value = maxRetriesOptionparamsMaxRetriesVariable.as_array().and_then(|__arr| __arr.get(1)).cloned().unwrap_or(Value::Null);
8548        let mut paginationDirectionparamsPaginationDirectionVariable = self.handle_option_and_params(paramsMaxRetries, method.clone(), Value::Str("paginationDirection".into()), &[Value::Str("backward".into())]);
8549        let mut paginationDirection: Value = paginationDirectionparamsPaginationDirectionVariable.as_array().and_then(|__arr| __arr.get(0)).cloned().unwrap_or(Value::Null);
8550        let mut paramsPaginationDirection: Value = paginationDirectionparamsPaginationDirectionVariable.as_array().and_then(|__arr| __arr.get(1)).cloned().unwrap_or(Value::Null);
8551        let mut paginationTimestamp: Value = Value::Null;
8552        let mut removeRepeatedOptionparamsRemoveRepeatedVariable = self.handle_option_and_params(paramsPaginationDirection, method.clone(), Value::Str("removeRepeated".into()), &[removeRepeated]);
8553        let mut removeRepeatedOption: Value = removeRepeatedOptionparamsRemoveRepeatedVariable.as_array().and_then(|__arr| __arr.get(0)).cloned().unwrap_or(Value::Null);
8554        let mut paramsRemoveRepeated: Value = removeRepeatedOptionparamsRemoveRepeatedVariable.as_array().and_then(|__arr| __arr.get(1)).cloned().unwrap_or(Value::Null);
8555        let mut calls: Value = Value::Int(0);
8556        let mut result: Value = Value::from(vec![]);
8557        let mut errors: Value = Value::Int(0);
8558        let mut until: Value = self.safe_integer_n(paramsRemoveRepeated.clone(), Value::from(vec![Value::Str("until".into()), Value::Str("untill".into()), Value::Str("till".into())]), &[]); // do not omit it from params here
8559        let mut maxEntriesPerRequestOptionparamsMaxEntriesPerRequestVariable = self.handle_max_entries_per_request_and_params(method.clone(), &[maxEntriesPerRequest, paramsRemoveRepeated]);
8560        let mut maxEntriesPerRequestOption: Value = maxEntriesPerRequestOptionparamsMaxEntriesPerRequestVariable.as_array().and_then(|__arr| __arr.get(0)).cloned().unwrap_or(Value::Null);
8561        let mut paramsMaxEntriesPerRequest: Value = maxEntriesPerRequestOptionparamsMaxEntriesPerRequestVariable.as_array().and_then(|__arr| __arr.get(1)).cloned().unwrap_or(Value::Null);
8562        if (paginationDirection.as_str() == Some("forward")) {
8563            if (since == Value::Null) {
8564                panic!("{}", crate::exchange_errors::arguments_required(format!("{}{}", self.id.clone(), Value::Str(" pagination requires a since argument when paginationDirection set to forward".into()))));
8565            }
8566            paginationTimestamp = since.clone();
8567        }
8568        while (calls.as_f64().unwrap_or(f64::NAN) < maxCallsPaginationCalls.as_f64().unwrap_or(f64::NAN)) {
8569            calls = (match (&(calls), &(Value::Int(1))) { (Value::Int(x), Value::Int(y)) => Value::Int(x + y), (Value::Int(x), Value::Float(y)) => Value::Float(*x as f64 + *y), (Value::Float(x), Value::Int(y)) => Value::Float(*x + *y as f64), (Value::Float(x), Value::Float(y)) => Value::Float(x + y), _ => Value::Null });
8570            {
8571                if (paginationDirection.as_str() == Some("backward")) {
8572                    // do it backwards, starting from the last
8573                    // UNTIL filtering is required in order to work
8574                    if (paginationTimestamp != Value::Null) {
8575                        add_element_to_object(&mut paramsMaxEntriesPerRequest, &Value::Str("until".into()), (match (&(paginationTimestamp), &(Value::Int(1))) { (Value::Int(x), Value::Int(y)) => Value::Int(x - y), (Value::Int(x), Value::Float(y)) => Value::Float(*x as f64 - *y), (Value::Float(x), Value::Int(y)) => Value::Float(*x - *y as f64), (Value::Float(x), Value::Float(y)) => Value::Float(x - y), _ => Value::Null }));
8576                    }
8577                    let mut response: Value = self.call_dynamic_checked(method.clone(), vec![(symbol).clone(), (Value::Null).clone(), (maxEntriesPerRequestOption).clone(), (paramsMaxEntriesPerRequest).clone()]).await;
8578                    let mut responseLength: Value = get_array_length(&response);
8579                    if is_true(&self.verbose) {
8580                        let mut backwardMessage: Value = Value::Str(format!("{}{}", Value::Str(format!("{}{}", Value::Str(format!("{}{}", Value::Str(format!("{}{}", Value::Str(format!("{}{}", Value::Str("Dynamic pagination call ".into()), self.number_to_string(calls.clone())).into()), Value::Str(" method ".into())).into()), method).into()), Value::Str(" response length ".into())).into()), self.number_to_string(responseLength.clone())).into());
8581                        if (paginationTimestamp != Value::Null) {
8582                            backwardMessage = Value::Str(format!("{}{}", backwardMessage, Value::Str(format!("{}{}", Value::Str(" timestamp ".into()), self.number_to_string(paginationTimestamp.clone())).into())).into());
8583                        }
8584                        self.log(backwardMessage);
8585                    }
8586                    if (responseLength.as_f64() == Some(0.0)) {
8587                        break;
8588                    }
8589                    errors = Value::Int(0);
8590                    result = self.array_concat(result.clone(), response.clone());
8591                    let mut firstElement: Value = self.safe_value(response.clone(), Value::Int(0), &[]);
8592                    paginationTimestamp = self.safe_integer2(firstElement, Value::Str("timestamp".into()), Value::Int(0), &[]);
8593                    if (paginationTimestamp == Value::Null) {
8594                        break;
8595                    }
8596                    if (since != Value::Null) && (paginationTimestamp.as_f64().unwrap_or(f64::NAN) <= since.as_f64().unwrap_or(f64::NAN)) {
8597                        break;
8598                    }
8599                }  else {
8600                    // do it forwards, starting from the since
8601                    let mut response: Value = self.call_dynamic_checked(method.clone(), vec![(symbol).clone(), (paginationTimestamp).clone(), (maxEntriesPerRequestOption).clone(), (paramsMaxEntriesPerRequest).clone()]).await;
8602                    let mut responseLength: Value = get_array_length(&response);
8603                    if is_true(&self.verbose) {
8604                        let mut forwardMessage: Value = Value::Str(format!("{}{}", Value::Str(format!("{}{}", Value::Str(format!("{}{}", Value::Str(format!("{}{}", Value::Str(format!("{}{}", Value::Str("Dynamic pagination call ".into()), self.number_to_string(calls.clone())).into()), Value::Str(" method ".into())).into()), method).into()), Value::Str(" response length ".into())).into()), self.number_to_string(responseLength.clone())).into());
8605                        if (paginationTimestamp != Value::Null) {
8606                            forwardMessage = Value::Str(format!("{}{}", forwardMessage, Value::Str(format!("{}{}", Value::Str(" timestamp ".into()), self.number_to_string(paginationTimestamp.clone())).into())).into());
8607                        }
8608                        self.log(forwardMessage);
8609                    }
8610                    if (responseLength.as_f64() == Some(0.0)) {
8611                        break;
8612                    }
8613                    errors = Value::Int(0);
8614                    result = self.array_concat(result.clone(), response.clone());
8615                    let mut last: Value = self.safe_value(response, (match (&(responseLength), &(Value::Int(1))) { (Value::Int(x), Value::Int(y)) => Value::Int(x - y), (Value::Int(x), Value::Float(y)) => Value::Float(*x as f64 - *y), (Value::Float(x), Value::Int(y)) => Value::Float(*x - *y as f64), (Value::Float(x), Value::Float(y)) => Value::Float(x - y), _ => Value::Null }), &[]);
8616                    let mut lastTimestamp: Value = self.safe_integer_k(last, "timestamp", &[Value::Int(0)]);
8617                    if (lastTimestamp == Value::Null) {
8618                        break;
8619                    }
8620                    let mut nextPaginationTimestamp: Value = (match (&(lastTimestamp), &(Value::Int(1))) { (Value::Int(x), Value::Int(y)) => Value::Int(x + y), (Value::Int(x), Value::Float(y)) => Value::Float(*x as f64 + *y), (Value::Float(x), Value::Int(y)) => Value::Float(*x + *y as f64), (Value::Float(x), Value::Float(y)) => Value::Float(x + y), _ => Value::Null });
8621                    paginationTimestamp = nextPaginationTimestamp.clone();
8622                    if (until != Value::Null) && (nextPaginationTimestamp.as_f64().unwrap_or(f64::NAN) >= until.as_f64().unwrap_or(f64::NAN)) {
8623                        break;
8624                    }
8625                }
8626            }
8627        }
8628        let mut uniqueResults: Value = result.clone();
8629        if is_true(&removeRepeatedOption) {
8630            uniqueResults = self.remove_repeated_elements_from_array(result, &[]);
8631        }
8632        let mut key: Value = (if (method.as_str() == Some("fetchOHLCV")) { Value::Int(0) } else { Value::Str("timestamp".into()) });
8633        let mut sortedRes: Value = self.sort_by(uniqueResults, key.clone(), &[]);
8634        return self.filter_by_since_limit(sortedRes, &[since, limit, key]);
8635
8636    Value::Null
8637} }
8638
8639    fn safe_deterministic_call(&mut self, mut method: Value, optional_args: &[Value]) -> impl ::std::future::Future<Output = Value> + Send { async move {
8640        let mut symbol = get_arg(optional_args, 0, Value::Null);
8641        let mut since = get_arg(optional_args, 1, Value::Null);
8642        let mut limit = get_arg(optional_args, 2, Value::Null);
8643        let mut timeframe = get_arg(optional_args, 3, Value::Null);
8644        let mut params = get_arg(optional_args, 4, Value::Map({
8645    let mut m = indexmap::IndexMap::new();
8646    m
8647}));
8648        let mut maxRetries: Value = Value::Int(3);
8649        let mut maxRetriesOptionparamsMaxRetriesVariable = self.handle_option_integer_and_params(params, method.clone(), Value::Str("maxRetries".into()), &[maxRetries]);
8650        let mut maxRetriesOption: Value = maxRetriesOptionparamsMaxRetriesVariable.as_array().and_then(|__arr| __arr.get(0)).cloned().unwrap_or(Value::Null);
8651        let mut paramsMaxRetries: Value = maxRetriesOptionparamsMaxRetriesVariable.as_array().and_then(|__arr| __arr.get(1)).cloned().unwrap_or(Value::Null);
8652        let mut errors: Value = Value::Int(0);
8653        while is_less_than_or_equal(&errors, &maxRetriesOption) {
8654            let _try_result = futures::FutureExt::catch_unwind(std::panic::AssertUnwindSafe(async {
8655                if ((timeframe != Value::Null) && (timeframe.as_str() != Some(""))) && (method.as_str() != Some("fetchFundingRateHistory")) {
8656                    return self.call_dynamic_checked(method.clone(), vec![(symbol).clone(), (timeframe).clone(), (since).clone(), (limit).clone(), (paramsMaxRetries).clone()]).await;
8657                }  else {
8658                    return self.call_dynamic_checked(method.clone(), vec![(symbol).clone(), (since).clone(), (limit).clone(), (paramsMaxRetries).clone()]).await;
8659                }
8660             #[allow(unreachable_code)] { Value::Null }})).await;
8661match _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); 
8662                if matches!(&e, Value::Str(__s) if __s.contains("[RateLimitExceeded]")) {
8663                    panic!("{}", e);
8664                }
8665                errors = (match (&(errors), &(Value::Int(1))) { (Value::Int(x), Value::Int(y)) => Value::Int(x + y), (Value::Int(x), Value::Float(y)) => Value::Float(*x as f64 + *y), (Value::Float(x), Value::Int(y)) => Value::Float(*x + *y as f64), (Value::Float(x), Value::Float(y)) => Value::Float(x + y), _ => Value::Null });
8666                if errors.as_f64().unwrap_or(f64::NAN) > maxRetriesOption.as_f64().unwrap_or(f64::NAN) {
8667                    panic!("{}", e);
8668                }
8669             } }
8670        }
8671        return Value::from(vec![]);
8672
8673    Value::Null
8674} }
8675
8676    fn fetch_paginated_call_deterministic(&mut self, mut method: Value, optional_args: &[Value]) -> impl ::std::future::Future<Output = Value> + Send { async move {
8677        let mut symbol = get_arg(optional_args, 0, Value::Null);
8678        let mut since = get_arg(optional_args, 1, Value::Null);
8679        let mut limit = get_arg(optional_args, 2, Value::Null);
8680        let mut timeframe = get_arg(optional_args, 3, Value::Null);
8681        let mut params = get_arg(optional_args, 4, Value::Map({
8682    let mut m = indexmap::IndexMap::new();
8683    m
8684}));
8685        let mut maxEntriesPerRequest = get_arg(optional_args, 5, Value::Null);
8686        let mut maxCalls: Value = Value::Int(10);
8687        let mut maxCallsPaginationCallsparamsPaginationCallsVariable = self.handle_option_integer_and_params(params, method.clone(), Value::Str("paginationCalls".into()), &[maxCalls]);
8688        let mut maxCallsPaginationCalls: Value = maxCallsPaginationCallsparamsPaginationCallsVariable.as_array().and_then(|__arr| __arr.get(0)).cloned().unwrap_or(Value::Null);
8689        let mut paramsPaginationCalls: Value = maxCallsPaginationCallsparamsPaginationCallsVariable.as_array().and_then(|__arr| __arr.get(1)).cloned().unwrap_or(Value::Null);
8690        let mut maxEntriesPerRequestOptionparamsMaxEntriesPerRequestVariable = self.handle_max_entries_per_request_and_params(method.clone(), &[maxEntriesPerRequest, paramsPaginationCalls]);
8691        let mut maxEntriesPerRequestOption: Value = maxEntriesPerRequestOptionparamsMaxEntriesPerRequestVariable.as_array().and_then(|__arr| __arr.get(0)).cloned().unwrap_or(Value::Null);
8692        let mut paramsMaxEntriesPerRequest: Value = maxEntriesPerRequestOptionparamsMaxEntriesPerRequestVariable.as_array().and_then(|__arr| __arr.get(1)).cloned().unwrap_or(Value::Null);
8693        // paginationDirection is only relevant to fetchPaginatedCallDynamic/Cursor; deterministic
8694        // pagination always walks forward internally, so strip it here to avoid leaking an
8695        // unrecognized param into the underlying exchange request (e.g. binance -1104 errors)
8696        let mut paramsOmitted: Value = self.omit(paramsMaxEntriesPerRequest, Value::Str("paginationDirection".into()), &[]);
8697        let mut current: Value = self.milliseconds();
8698        let mut tasks: Value = Value::from(vec![]);
8699        let mut time: Value = (match (&(self.parse_timeframe(timeframe.clone())), &(Value::Int(1000))) { (Value::Int(x), Value::Int(y)) => Value::Int(x * y), (Value::Int(x), Value::Float(y)) => Value::Float(*x as f64 * *y), (Value::Float(x), Value::Int(y)) => Value::Float(*x * *y as f64), (Value::Float(x), Value::Float(y)) => Value::Float(x * y), _ => Value::Null });
8700        let mut maxEntriesPerRequestValue: Value = self.require_value(maxEntriesPerRequestOption, &[Value::Str("fetchPaginatedCallDeterministic() maxEntriesPerRequest is required".into())]);
8701        let mut step: Value = multiply(&time, &maxEntriesPerRequestValue);
8702        let mut until: Value = self.safe_integer2(paramsOmitted.clone(), Value::Str("until".into()), Value::Str("till".into()), &[]); // do not omit it here
8703        let mut currentSince: Value = (match (&((match (&(current), &((multiply(&maxCallsPaginationCalls, &step)))) { (Value::Int(x), Value::Int(y)) => Value::Int(x - y), (Value::Int(x), Value::Float(y)) => Value::Float(*x as f64 - *y), (Value::Float(x), Value::Int(y)) => Value::Float(*x - *y as f64), (Value::Float(x), Value::Float(y)) => Value::Float(x - y), _ => Value::Null })), &(Value::Int(1))) { (Value::Int(x), Value::Int(y)) => Value::Int(x - y), (Value::Int(x), Value::Float(y)) => Value::Float(*x as f64 - *y), (Value::Float(x), Value::Int(y)) => Value::Float(*x - *y as f64), (Value::Float(x), Value::Float(y)) => Value::Float(x - y), _ => Value::Null });
8704        if (since != Value::Null) {
8705            if (until != Value::Null) {
8706                // the recent-window floor below would jump past a fully-historical [ since, until ]
8707                // range and return an empty result - requiredCalls is validated against maxCalls
8708                // further down, so anchoring at since directly is safe here,
8709                // see https://github.com/ccxt/ccxt/issues/26252
8710                currentSince = since.clone();
8711            }  else {
8712                currentSince = crate::runtime::Math::max(&currentSince, &since);
8713            }
8714        }  else {
8715            currentSince = crate::runtime::Math::max(&currentSince, &Value::Int(1241440531000)); // avoid timestamps older than 2009
8716        }
8717        if (until != Value::Null) {
8718            if (since == Value::Null) {
8719                panic!("{}", crate::exchange_errors::arguments_required(format!("{}{}", self.id.clone(), Value::Str(" fetchPaginatedCallDeterministic() requires a since argument when until is set".into()))));
8720            }
8721            let mut requiredCalls: Value = math_ceil(&(match ((((match (&(until), &(since)) { (Value::Int(x), Value::Int(y)) => Value::Int(x - y), (Value::Int(x), Value::Float(y)) => Value::Float(*x as f64 - *y), (Value::Float(x), Value::Int(y)) => Value::Float(*x - *y as f64), (Value::Float(x), Value::Float(y)) => Value::Float(x - y), _ => Value::Null }))).as_f64(), (step).as_f64()) { (Some(x), Some(y)) if y != 0.0 => Value::Float(x / y), _ => Value::Null }));
8722            if requiredCalls.as_f64().unwrap_or(f64::NAN) > maxCallsPaginationCalls.as_f64().unwrap_or(f64::NAN) {
8723                panic!("{}", crate::exchange_errors::bad_request(format!("{}{}", Value::Str(format!("{}{}", Value::Str(format!("{}{}", Value::Str(format!("{}{}", self.id.clone(), 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 ".into())).into()), to_string_val(&maxCallsPaginationCalls)).into()), Value::Str(" required calls is ".into())).into()), to_string_val(&requiredCalls))));
8724            }
8725        }
8726        {
8727                        let mut i: Value = Value::Int(0);
8728            let mut __for_first_161: bool = true;
8729            while { if !__for_first_161 { i = (match (&(i), &(Value::Int(1))) { (Value::Int(x), Value::Int(y)) => Value::Int(x + y), (Value::Int(x), Value::Float(y)) => Value::Float(*x as f64 + *y), (Value::Float(x), Value::Int(y)) => Value::Float(*x + *y as f64), (Value::Float(x), Value::Float(y)) => Value::Float(x + y), _ => Value::Null }); } __for_first_161 = false; i.as_f64().unwrap_or(f64::NAN) < maxCallsPaginationCalls.as_f64().unwrap_or(f64::NAN) } {
8730            if (until != Value::Null) && (currentSince.as_f64().unwrap_or(f64::NAN) >= until.as_f64().unwrap_or(f64::NAN)) {
8731                break;
8732            }
8733            if currentSince.as_f64().unwrap_or(f64::NAN) >= current.as_f64().unwrap_or(f64::NAN) {
8734                break;
8735            }
8736            append_to_array(&mut tasks, self.safe_deterministic_call(method.clone(), &[symbol.clone(), currentSince.clone(), maxEntriesPerRequestValue.clone(), timeframe.clone(), paramsOmitted.clone()]).await);
8737            currentSince = (match (&((match (&(currentSince), &(step)) { (Value::Int(x), Value::Int(y)) => Value::Int(x + y), (Value::Int(x), Value::Float(y)) => Value::Float(*x as f64 + *y), (Value::Float(x), Value::Int(y)) => Value::Float(*x + *y as f64), (Value::Float(x), Value::Float(y)) => Value::Float(x + y), _ => Value::Null })), &(Value::Int(1))) { (Value::Int(x), Value::Int(y)) => Value::Int(x - y), (Value::Int(x), Value::Float(y)) => Value::Float(*x as f64 - *y), (Value::Float(x), Value::Int(y)) => Value::Float(*x - *y as f64), (Value::Float(x), Value::Float(y)) => Value::Float(x - y), _ => Value::Null });
8738        }
8739        }
8740        let mut results: Value = promise_all(&tasks).await;
8741        let mut result: Value = Value::from(vec![]);
8742        {
8743                        let mut i: Value = Value::Int(0);
8744            let mut __for_first_162: bool = true;
8745            while { if !__for_first_162 { i = (match (&(i), &(Value::Int(1))) { (Value::Int(x), Value::Int(y)) => Value::Int(x + y), (Value::Int(x), Value::Float(y)) => Value::Float(*x as f64 + *y), (Value::Float(x), Value::Int(y)) => Value::Float(*x + *y as f64), (Value::Float(x), Value::Float(y)) => Value::Float(x + y), _ => Value::Null }); } __for_first_162 = false; i.as_f64().unwrap_or(f64::NAN) < ((results.len() as i64) as f64) } {
8746            result = self.array_concat(result.clone(), results.as_array().and_then(|__arr| match &i { Value::Int(__n) => __arr.get(*__n as usize), Value::Str(__s) => __s.parse::<usize>().ok().and_then(|__n| __arr.get(__n)), _ => None }).cloned().unwrap_or(Value::Null));
8747        }
8748        }
8749        let mut uniqueResults: Value = self.remove_repeated_elements_from_array(result, &[]);
8750        let mut key: Value = (if (method.as_str() == Some("fetchOHLCV")) { Value::Int(0) } else { Value::Str("timestamp".into()) });
8751        return self.filter_by_since_limit(uniqueResults, &[since, limit, key]);
8752
8753    Value::Null
8754} }
8755
8756// the 'symbol' slot is forwarded to `this[method]` untouched and is only compared against
8757// undefined here, so fetchPositions/fetchPositionsHistory legitimately pass a symbol list
8758    fn fetch_paginated_call_cursor(&mut self, mut method: Value, optional_args: &[Value]) -> impl ::std::future::Future<Output = Value> + Send { async move {
8759        let mut symbol = get_arg(optional_args, 0, Value::Null);
8760        let mut since = get_arg(optional_args, 1, Value::Null);
8761        let mut limit = get_arg(optional_args, 2, Value::Null);
8762        let mut params = get_arg(optional_args, 3, Value::Map({
8763    let mut m = indexmap::IndexMap::new();
8764    m
8765}));
8766        let mut cursorReceived = get_arg(optional_args, 4, Value::Null);
8767        let mut cursorSent = get_arg(optional_args, 5, Value::Null);
8768        let mut cursorIncrement = get_arg(optional_args, 6, Value::Null);
8769        let mut maxEntriesPerRequest = get_arg(optional_args, 7, Value::Null);
8770        let mut maxCalls: Value = Value::Int(10);
8771        let mut maxCallsPaginationCallsparamsPaginationCallsVariable = self.handle_option_integer_and_params(params, method.clone(), Value::Str("paginationCalls".into()), &[maxCalls]);
8772        let mut maxCallsPaginationCalls: Value = maxCallsPaginationCallsparamsPaginationCallsVariable.as_array().and_then(|__arr| __arr.get(0)).cloned().unwrap_or(Value::Null);
8773        let mut paramsPaginationCalls: Value = maxCallsPaginationCallsparamsPaginationCallsVariable.as_array().and_then(|__arr| __arr.get(1)).cloned().unwrap_or(Value::Null);
8774        let mut maxRetries: Value = Value::Int(3);
8775        let mut maxRetriesOptionparamsMaxRetriesVariable = self.handle_option_integer_and_params(paramsPaginationCalls, method.clone(), Value::Str("maxRetries".into()), &[maxRetries]);
8776        let mut maxRetriesOption: Value = maxRetriesOptionparamsMaxRetriesVariable.as_array().and_then(|__arr| __arr.get(0)).cloned().unwrap_or(Value::Null);
8777        let mut paramsMaxRetries: Value = maxRetriesOptionparamsMaxRetriesVariable.as_array().and_then(|__arr| __arr.get(1)).cloned().unwrap_or(Value::Null);
8778        let mut maxEntriesPerRequestOptionparamsMaxEntriesPerRequestVariable = self.handle_max_entries_per_request_and_params(method.clone(), &[maxEntriesPerRequest, paramsMaxRetries]);
8779        let mut maxEntriesPerRequestOption: Value = maxEntriesPerRequestOptionparamsMaxEntriesPerRequestVariable.as_array().and_then(|__arr| __arr.get(0)).cloned().unwrap_or(Value::Null);
8780        let mut paramsMaxEntriesPerRequest: Value = maxEntriesPerRequestOptionparamsMaxEntriesPerRequestVariable.as_array().and_then(|__arr| __arr.get(1)).cloned().unwrap_or(Value::Null);
8781        let mut cursorValue: Value = Value::Null;
8782        let mut i: Value = Value::Int(0);
8783        let mut errors: Value = Value::Int(0);
8784        let mut result: Value = Value::from(vec![]);
8785        let mut timeframe: Value = self.safe_string_k(paramsMaxEntriesPerRequest.clone(), "timeframe", &[]);
8786        let mut paramsOmitted: Value = self.omit(paramsMaxEntriesPerRequest, Value::Str("timeframe".into()), &[]); // reading the timeframe from the method arguments to avoid changing the signature
8787        while i.as_f64().unwrap_or(f64::NAN) < maxCallsPaginationCalls.as_f64().unwrap_or(f64::NAN) {
8788            {
8789                if (cursorValue != Value::Null) {
8790                    if (cursorIncrement != Value::Null) {
8791                        cursorValue = (match (&(self.parse_to_int(cursorValue.clone())), &(cursorIncrement)) { (Value::Int(x), Value::Int(y)) => Value::Int(x + y), (Value::Int(x), Value::Float(y)) => Value::Float(*x as f64 + *y), (Value::Float(x), Value::Int(y)) => Value::Float(*x + *y as f64), (Value::Float(x), Value::Float(y)) => Value::Float(x + y), _ => Value::Null });
8792                    }
8793                    add_element_to_object(&mut paramsOmitted, &cursorSent, cursorValue.clone());
8794                }
8795                let mut response: Value = Value::Null;
8796                if (method.as_str() == Some("fetchAccounts")) {
8797                    response = self.call_dynamic_checked(method.clone(), vec![(paramsOmitted).clone()]).await;
8798                }  else if (method.as_str() == Some("getLeverageTiersPaginated")) || (method.as_str() == Some("fetchPositions")) {
8799                    response = self.call_dynamic_checked(method.clone(), vec![(symbol).clone(), (paramsOmitted).clone()]).await;
8800                }  else if (method.as_str() == Some("fetchOpenInterestHistory")) {
8801                    if !matches!(&symbol, Value::Str(_)) {
8802                        panic!("{}", crate::exchange_errors::arguments_required(format!("{}{}", self.id.clone(), Value::Str(" fetchPaginatedCallCursor() requires a symbol argument".into()))));
8803                    }
8804                    if (timeframe == Value::Null) {
8805                        panic!("{}", crate::exchange_errors::arguments_required(format!("{}{}", self.id.clone(), Value::Str(" fetchPaginatedCallCursor() requires a timeframe argument".into()))));
8806                    }
8807                    response = self.call_dynamic_checked(method.clone(), vec![(symbol).clone(), (timeframe).clone(), (since).clone(), (maxEntriesPerRequestOption).clone(), (paramsOmitted).clone()]).await;
8808                }  else {
8809                    response = self.call_dynamic_checked(method.clone(), vec![(symbol).clone(), (since).clone(), (maxEntriesPerRequestOption).clone(), (paramsOmitted).clone()]).await;
8810                }
8811                errors = Value::Int(0);
8812                if (response == Value::Null) {
8813                    panic!("{}", crate::exchange_errors::null_response(format!("{}{}", self.id.clone(), Value::Str(" fetchPaginatedCallCursor() returned empty response".into()))));
8814                }
8815                let mut responseLength: Value = Value::Int(response.len() as i64);
8816                if is_true(&self.verbose) {
8817                    let mut cursorString: Value = (if (cursorValue == Value::Null) { Value::Str("".into()) } else { cursorValue.clone() });
8818                    let mut iteration: Value = ((match (&(i), &(Value::Int(1))) { (Value::Int(x), Value::Int(y)) => Value::Int(x + y), (Value::Int(x), Value::Float(y)) => Value::Float(*x as f64 + *y), (Value::Float(x), Value::Int(y)) => Value::Float(*x + *y as f64), (Value::Float(x), Value::Float(y)) => Value::Float(x + y), _ => Value::Null }));
8819                    let mut cursorMessage: Value = add(&Value::Str(format!("{}{}", Value::Str(format!("{}{}", Value::Str(format!("{}{}", Value::Str(format!("{}{}", Value::Str(format!("{}{}", Value::Str(format!("{}{}", Value::Str("Cursor pagination call ".into()), to_string_val(&iteration)).into()), Value::Str(" method ".into())).into()), method).into()), Value::Str(" response length ".into())).into()), to_string_val(&responseLength)).into()), Value::Str(" cursor ".into())).into()), &cursorString);
8820                    self.log(cursorMessage);
8821                }
8822                if (responseLength.as_f64() == Some(0.0)) {
8823                    break;
8824                }
8825                if (response != Value::Null) {
8826                    result = self.array_concat(result.clone(), response.clone());
8827                }
8828                let mut last: Value = self.safe_dict(response.clone(), (match (&(responseLength), &(Value::Int(1))) { (Value::Int(x), Value::Int(y)) => Value::Int(x - y), (Value::Int(x), Value::Float(y)) => Value::Float(*x as f64 - *y), (Value::Float(x), Value::Int(y)) => Value::Float(*x - *y as f64), (Value::Float(x), Value::Float(y)) => Value::Float(x - y), _ => Value::Null }), &[]);
8829                // cursorValue = this.safeValue (last['info'], cursorReceived);
8830                cursorValue = Value::Null; // search for the cursor
8831                {
8832                                        let mut j: Value = Value::Int(0);
8833                    let mut __for_first_163: bool = true;
8834                    while { if !__for_first_163 { j = (match (&(j), &(Value::Int(1))) { (Value::Int(x), Value::Int(y)) => Value::Int(x + y), (Value::Int(x), Value::Float(y)) => Value::Float(*x as f64 + *y), (Value::Float(x), Value::Int(y)) => Value::Float(*x + *y as f64), (Value::Float(x), Value::Float(y)) => Value::Float(x + y), _ => Value::Null }); } __for_first_163 = false; j.as_f64().unwrap_or(f64::NAN) < responseLength.as_f64().unwrap_or(f64::NAN) } {
8835                    let mut index: Value = (match (&((match (&(responseLength), &(j)) { (Value::Int(x), Value::Int(y)) => Value::Int(x - y), (Value::Int(x), Value::Float(y)) => Value::Float(*x as f64 - *y), (Value::Float(x), Value::Int(y)) => Value::Float(*x - *y as f64), (Value::Float(x), Value::Float(y)) => Value::Float(x - y), _ => Value::Null })), &(Value::Int(1))) { (Value::Int(x), Value::Int(y)) => Value::Int(x - y), (Value::Int(x), Value::Float(y)) => Value::Float(*x as f64 - *y), (Value::Float(x), Value::Int(y)) => Value::Float(*x - *y as f64), (Value::Float(x), Value::Float(y)) => Value::Float(x - y), _ => Value::Null });
8836                    let mut entry: Value = self.safe_dict(response.clone(), index, &[]);
8837                    let mut info: Value = self.safe_dict_k(entry, "info", &[]);
8838                    let mut cursor: Value = (if (cursorReceived == Value::Null) { Value::Null } else { self.safe_value(info, cursorReceived.clone(), &[]) });
8839                    if (cursor != Value::Null) {
8840                        cursorValue = cursor;
8841                        break;
8842                    }
8843                }
8844                }
8845                if (cursorValue == Value::Null) {
8846                    break;
8847                }
8848                let mut lastTimestamp: Value = self.safe_integer_k(last, "timestamp", &[]);
8849                if (since == Value::Null) {
8850                    panic!("{}", crate::exchange_errors::arguments_required(format!("{}{}", self.id.clone(), Value::Str(" fetchPaginatedCallCursor() requires a since argument".into()))));
8851                }
8852                if (lastTimestamp != Value::Null) && lastTimestamp.as_f64().unwrap_or(f64::NAN) < since.as_f64().unwrap_or(f64::NAN) {
8853                    break;
8854                }
8855            }
8856            i = (match (&(i), &(Value::Int(1))) { (Value::Int(x), Value::Int(y)) => Value::Int(x + y), (Value::Int(x), Value::Float(y)) => Value::Float(*x as f64 + *y), (Value::Float(x), Value::Int(y)) => Value::Float(*x + *y as f64), (Value::Float(x), Value::Float(y)) => Value::Float(x + y), _ => Value::Null });
8857        }
8858        let mut sorted: Value = self.sort_cursor_paginated_result(result);
8859        let mut key: Value = (if (method.as_str() == Some("fetchOHLCV")) { Value::Int(0) } else { Value::Str("timestamp".into()) });
8860        return self.filter_by_since_limit(sorted, &[since, limit, key]);
8861
8862    Value::Null
8863} }
8864
8865    fn fetch_paginated_call_incremental(&mut self, mut method: Value, optional_args: &[Value]) -> impl ::std::future::Future<Output = Value> + Send { async move {
8866        let mut symbol = get_arg(optional_args, 0, Value::Null);
8867        let mut since = get_arg(optional_args, 1, Value::Null);
8868        let mut limit = get_arg(optional_args, 2, Value::Null);
8869        let mut params = get_arg(optional_args, 3, Value::Map({
8870    let mut m = indexmap::IndexMap::new();
8871    m
8872}));
8873        let mut pageKey = get_arg(optional_args, 4, Value::Null);
8874        let mut maxEntriesPerRequest = get_arg(optional_args, 5, Value::Null);
8875        let mut maxCalls: Value = Value::Int(10);
8876        let mut maxCallsPaginationCallsparamsPaginationCallsVariable = self.handle_option_integer_and_params(params, method.clone(), Value::Str("paginationCalls".into()), &[maxCalls]);
8877        let mut maxCallsPaginationCalls: Value = maxCallsPaginationCallsparamsPaginationCallsVariable.as_array().and_then(|__arr| __arr.get(0)).cloned().unwrap_or(Value::Null);
8878        let mut paramsPaginationCalls: Value = maxCallsPaginationCallsparamsPaginationCallsVariable.as_array().and_then(|__arr| __arr.get(1)).cloned().unwrap_or(Value::Null);
8879        let mut maxRetries: Value = Value::Int(3);
8880        let mut maxRetriesOptionparamsMaxRetriesVariable = self.handle_option_integer_and_params(paramsPaginationCalls, method.clone(), Value::Str("maxRetries".into()), &[maxRetries]);
8881        let mut maxRetriesOption: Value = maxRetriesOptionparamsMaxRetriesVariable.as_array().and_then(|__arr| __arr.get(0)).cloned().unwrap_or(Value::Null);
8882        let mut paramsMaxRetries: Value = maxRetriesOptionparamsMaxRetriesVariable.as_array().and_then(|__arr| __arr.get(1)).cloned().unwrap_or(Value::Null);
8883        let mut maxEntriesPerRequestOptionparamsMaxEntriesPerRequestVariable = self.handle_max_entries_per_request_and_params(method.clone(), &[maxEntriesPerRequest, paramsMaxRetries]);
8884        let mut maxEntriesPerRequestOption: Value = maxEntriesPerRequestOptionparamsMaxEntriesPerRequestVariable.as_array().and_then(|__arr| __arr.get(0)).cloned().unwrap_or(Value::Null);
8885        let mut paramsMaxEntriesPerRequest: Value = maxEntriesPerRequestOptionparamsMaxEntriesPerRequestVariable.as_array().and_then(|__arr| __arr.get(1)).cloned().unwrap_or(Value::Null);
8886        let mut i: Value = Value::Int(0);
8887        let mut errors: Value = Value::Int(0);
8888        let mut result: Value = Value::from(vec![]);
8889        while i.as_f64().unwrap_or(f64::NAN) < maxCallsPaginationCalls.as_f64().unwrap_or(f64::NAN) {
8890            {
8891                add_element_to_object(&mut paramsMaxEntriesPerRequest, &pageKey, (match (&(i), &(Value::Int(1))) { (Value::Int(x), Value::Int(y)) => Value::Int(x + y), (Value::Int(x), Value::Float(y)) => Value::Float(*x as f64 + *y), (Value::Float(x), Value::Int(y)) => Value::Float(*x + *y as f64), (Value::Float(x), Value::Float(y)) => Value::Float(x + y), _ => Value::Null }));
8892                let mut response: Value = self.call_dynamic_checked(method.clone(), vec![(symbol).clone(), (since).clone(), (maxEntriesPerRequestOption).clone(), (paramsMaxEntriesPerRequest).clone()]).await;
8893                errors = Value::Int(0);
8894                let mut responseLength: Value = get_array_length(&response);
8895                if is_true(&self.verbose) {
8896                    let mut iteration: Value = to_string_val(&((match (&(i), &(Value::Int(1))) { (Value::Int(x), Value::Int(y)) => Value::Int(x + y), (Value::Int(x), Value::Float(y)) => Value::Float(*x as f64 + *y), (Value::Float(x), Value::Int(y)) => Value::Float(*x + *y as f64), (Value::Float(x), Value::Float(y)) => Value::Float(x + y), _ => Value::Null })));
8897                    let mut incrementalMessage: Value = Value::Str(format!("{}{}", Value::Str(format!("{}{}", Value::Str(format!("{}{}", Value::Str(format!("{}{}", Value::Str(format!("{}{}", Value::Str("Incremental pagination call ".into()), iteration).into()), Value::Str(" method ".into())).into()), method).into()), Value::Str(" response length ".into())).into()), to_string_val(&responseLength)).into());
8898                    self.log(incrementalMessage);
8899                }
8900                if (responseLength.as_f64() == Some(0.0)) {
8901                    break;
8902                }
8903                result = self.array_concat(result.clone(), response);
8904            }
8905            i = (match (&(i), &(Value::Int(1))) { (Value::Int(x), Value::Int(y)) => Value::Int(x + y), (Value::Int(x), Value::Float(y)) => Value::Float(*x as f64 + *y), (Value::Float(x), Value::Int(y)) => Value::Float(*x + *y as f64), (Value::Float(x), Value::Float(y)) => Value::Float(x + y), _ => Value::Null });
8906        }
8907        let mut sorted: Value = self.sort_cursor_paginated_result(result);
8908        let mut key: Value = (if (method.as_str() == Some("fetchOHLCV")) { Value::Int(0) } else { Value::Str("timestamp".into()) });
8909        return self.filter_by_since_limit(sorted, &[since, limit, key]);
8910
8911    Value::Null
8912} }
8913
8914    fn sort_cursor_paginated_result(&self, mut result: Value) -> Value {
8915        let mut first: Value = self.safe_value(result.clone(), Value::Int(0), &[]);
8916        if (first != Value::Null) {
8917            if (in_op(&first, &Value::Str("timestamp".into()))) {
8918                return self.sort_by(result.clone(), Value::Str("timestamp".into()), &[Value::Bool(true)]);
8919            }
8920            if (in_op(&first, &Value::Str("id".into()))) {
8921                return self.sort_by(result.clone(), Value::Str("id".into()), &[Value::Bool(true)]);
8922            }
8923        }
8924        return result;
8925
8926    Value::Null
8927}
8928
8929    fn remove_repeated_elements_from_array(&self, mut input: Value, optional_args: &[Value]) -> Value {
8930        let mut fallbackToTimestamp = get_arg(optional_args, 0, Value::Bool(true));
8931        let mut uniqueDic: Value = Value::Map({
8932            let mut m = indexmap::IndexMap::new();
8933            m
8934        });
8935        let mut uniqueResult: Value = Value::from(vec![]);
8936        {
8937                        let mut i: Value = Value::Int(0);
8938            let mut __for_first_164: bool = true;
8939            while { if !__for_first_164 { i = (match (&(i), &(Value::Int(1))) { (Value::Int(x), Value::Int(y)) => Value::Int(x + y), (Value::Int(x), Value::Float(y)) => Value::Float(*x as f64 + *y), (Value::Float(x), Value::Int(y)) => Value::Float(*x + *y as f64), (Value::Float(x), Value::Float(y)) => Value::Float(x + y), _ => Value::Null }); } __for_first_164 = false; i.as_f64().unwrap_or(f64::NAN) < get_array_length(&input).as_f64().unwrap_or(f64::NAN) } {
8940            let mut entry: Value = get_value(&input, &i);
8941            let mut entry: Value = get_value(&input, &i);
8942            let mut uniqValue: Value = (if is_true(&fallbackToTimestamp) { self.safe_string_n(entry.clone(), Value::from(vec![Value::Str("id".into()), Value::Str("timestamp".into()), Value::Int(0)]), &[]) } else { self.safe_string_k(entry.clone(), "id", &[]) });
8943            if (uniqValue != Value::Null) && !(in_op(&uniqueDic, &uniqValue)) {
8944                if let Value::Dict(__d) = &mut uniqueDic { std::sync::Arc::make_mut(__d).insert(crate::runtime::stringify_param(&uniqValue), Value::Int(1)); }
8945                append_to_array(&mut uniqueResult, entry);
8946            }
8947        }
8948        }
8949        let mut valuesLength: f64 = ((uniqueResult.len() as i64) as f64);
8950        if valuesLength > ((0i64) as f64) {
8951            return uniqueResult;
8952        }
8953        return input;
8954
8955    Value::Null
8956}
8957
8958    fn remove_repeated_trades_from_array(&self, mut input: Value) -> Value {
8959        let mut uniqueResult: Value = Value::Map({
8960            let mut m = indexmap::IndexMap::new();
8961            m
8962        });
8963        {
8964                        let mut i: Value = Value::Int(0);
8965            let mut __for_first_165: bool = true;
8966            while { if !__for_first_165 { i = (match (&(i), &(Value::Int(1))) { (Value::Int(x), Value::Int(y)) => Value::Int(x + y), (Value::Int(x), Value::Float(y)) => Value::Float(*x as f64 + *y), (Value::Float(x), Value::Int(y)) => Value::Float(*x + *y as f64), (Value::Float(x), Value::Float(y)) => Value::Float(x + y), _ => Value::Null }); } __for_first_165 = false; i.as_f64().unwrap_or(f64::NAN) < get_array_length(&input).as_f64().unwrap_or(f64::NAN) } {
8967            let mut entry: Value = get_value(&input, &i);
8968            let mut entry: Value = get_value(&input, &i);
8969            let mut id: Value = self.safe_string_k(entry.clone(), "id", &[]);
8970            if (id == Value::Null) {
8971                let mut price: Value = self.safe_string_k(entry.clone(), "price", &[]);
8972                let mut amount: Value = self.safe_string_k(entry.clone(), "amount", &[]);
8973                let mut timestamp: Value = self.safe_string_k(entry.clone(), "timestamp", &[]);
8974                let mut side: Value = self.safe_string_k(entry.clone(), "side", &[]);
8975                // unique trade identifier
8976                if (timestamp == Value::Null) {
8977                    panic!("{}", crate::exchange_errors::exchange_error(format!("{}{}", self.id.clone(), Value::Str(" removeRepeatedTradesFromArray() missing timestamp".into()))));
8978                }
8979                // optional parts are appended only when present, separators keep positions distinct
8980                id = Value::Str(format!("{}{}", Value::Str(format!("{}{}", Value::Str("t_".into()), to_string_val(&timestamp)).into()), Value::Str("_".into())).into());
8981                if (side != Value::Null) {
8982                    id = Value::Str(format!("{}{}", id, side).into());
8983                }
8984                id = Value::Str(format!("{}{}", id, Value::Str("_".into())).into());
8985                if (price != Value::Null) {
8986                    id = Value::Str(format!("{}{}", id, price).into());
8987                }
8988                id = Value::Str(format!("{}{}", id, Value::Str("_".into())).into());
8989                if (amount != Value::Null) {
8990                    id = Value::Str(format!("{}{}", id, amount).into());
8991                }
8992            }
8993            if (id != Value::Null) && !(in_op(&uniqueResult, &id)) {
8994                if let Value::Dict(__d) = &mut uniqueResult { std::sync::Arc::make_mut(__d).insert(crate::runtime::stringify_param(&id), entry); }
8995            }
8996        }
8997        }
8998        let mut values: Value = object_values(&uniqueResult);
8999        return values;
9000
9001    Value::Null
9002}
9003
9004    fn remove_keys_from_dict(&self, mut dict: Value, mut removeKeys: Value) -> Value {
9005        let mut keys: Value = object_keys(&dict);
9006        let mut newDict: Value = Value::Map({
9007            let mut m = indexmap::IndexMap::new();
9008            m
9009        });
9010        {
9011                        let mut i: Value = Value::Int(0);
9012            let mut __for_first_166: bool = true;
9013            while { if !__for_first_166 { i = (match (&(i), &(Value::Int(1))) { (Value::Int(x), Value::Int(y)) => Value::Int(x + y), (Value::Int(x), Value::Float(y)) => Value::Float(*x as f64 + *y), (Value::Float(x), Value::Int(y)) => Value::Float(*x + *y as f64), (Value::Float(x), Value::Float(y)) => Value::Float(x + y), _ => Value::Null }); } __for_first_166 = false; i.as_f64().unwrap_or(f64::NAN) < ((keys.len() as i64) as f64) } {
9014            let mut key: Value = keys.as_array().and_then(|__arr| match &i { Value::Int(__n) => __arr.get(*__n as usize), Value::Str(__s) => __s.parse::<usize>().ok().and_then(|__n| __arr.get(__n)), _ => None }).cloned().unwrap_or(Value::Null);
9015            if !(self.in_array(key.clone(), removeKeys.clone()).as_bool() == Some(true)) {
9016                if let Value::Dict(__d) = &mut newDict { std::sync::Arc::make_mut(__d).insert(crate::runtime::stringify_param(&key), dict.as_map().and_then(|__m| key.as_str().and_then(|__k| __m.get(__k))).cloned().unwrap_or(Value::Null)); }
9017            }
9018        }
9019        }
9020        return newDict;
9021
9022    Value::Null
9023}
9024
9025    fn handle_until_option(&self, mut key: Value, mut request: Value, mut params: Value, optional_args: &[Value]) -> Value {
9026        let mut multiplier = get_arg(optional_args, 0, Value::Int(1));
9027        let mut until: Value = self.safe_integer2(params.clone(), Value::Str("until".into()), Value::Str("till".into()), &[]);
9028        if (until != Value::Null) {
9029            if let Value::Dict(__d) = &mut request { std::sync::Arc::make_mut(__d).insert(crate::runtime::stringify_param(&key), self.parse_to_int((match (&(until), &(multiplier)) { (Value::Int(x), Value::Int(y)) => Value::Int(x * y), (Value::Int(x), Value::Float(y)) => Value::Float(*x as f64 * *y), (Value::Float(x), Value::Int(y)) => Value::Float(*x * *y as f64), (Value::Float(x), Value::Float(y)) => Value::Float(x * y), _ => Value::Null }))); }
9030        }
9031        let mut paramsOmitted: Value = (if (until != Value::Null) { self.omit(params.clone(), Value::from(vec![Value::Str("until".into()), Value::Str("till".into())]), &[]) } else { params });
9032        return Value::from(vec![request, paramsOmitted]);
9033
9034    Value::Null
9035}
9036
9037    fn safe_open_interest(&self, mut interest: Value, optional_args: &[Value]) -> Value {
9038        let mut market = get_arg(optional_args, 0, Value::Null);
9039        let mut symbol: Value = self.safe_string_k(interest.clone(), "symbol", &[]);
9040        if (symbol == Value::Null) {
9041            symbol = self.safe_string_k(market, "symbol", &[]);
9042        }
9043        return self.extend(interest.clone(), &[Value::Map({
9044    let mut m = indexmap::IndexMap::new();
9045        m.insert("symbol".to_string(), symbol);
9046        m.insert("baseVolume".to_string(), self.safe_number_k(interest.clone(), "baseVolume", &[]));
9047        m.insert("quoteVolume".to_string(), self.safe_number_k(interest.clone(), "quoteVolume", &[]));
9048        m.insert("openInterestAmount".to_string(), self.safe_number_k(interest.clone(), "openInterestAmount", &[]));
9049        m.insert("openInterestValue".to_string(), self.safe_number_k(interest.clone(), "openInterestValue", &[]));
9050        m.insert("timestamp".to_string(), self.safe_integer_k(interest.clone(), "timestamp", &[]));
9051        m.insert("datetime".to_string(), self.safe_string_k(interest.clone(), "datetime", &[]));
9052        m.insert("info".to_string(), self.safe_value_k(interest, "info", &[]));
9053    m
9054})]);
9055
9056    Value::Null
9057}
9058
9059    fn parse_liquidation(&self, mut liquidation: Value, optional_args: &[Value]) -> Value {
9060        // virtual-dispatch (static: DerivedExchange::parse_liquidation(self, ...))
9061        { let __v = crate::exchange::DerivedExchange::parse_liquidation(self, liquidation, crate::runtime::get_arg(optional_args, 0, crate::Value::Null)); if !matches!(__v, crate::Value::Null) { return __v; } }
9062
9063        let mut market = get_arg(optional_args, 0, Value::Null);
9064        panic!("{}", crate::exchange_errors::not_supported(format!("{}{}", self.id.clone(), Value::Str(" parseLiquidation () is not supported yet".into()))));
9065
9066    Value::Null
9067}
9068
9069    fn parse_liquidations(&self, mut liquidations: Value, optional_args: &[Value]) -> Value {
9070        let mut market = get_arg(optional_args, 0, Value::Null);
9071        let mut since = get_arg(optional_args, 1, Value::Null);
9072        let mut limit = get_arg(optional_args, 2, Value::Null);
9073        /*
9074         * @ignore
9075         * @method
9076         * @description parses liquidation info from the exchange response
9077         * @param {object[]} liquidations each item describes an instance of a liquidation event
9078         * @param {object} market ccxt market
9079         * @param {int} [since] when defined, the response items are filtered to only include items after this timestamp
9080         * @param {int} [limit] limits the number of items in the response
9081         * @returns {object[]} an array of [liquidation structures]{@link https://docs.ccxt.com/?id=liquidation-structure}
9082         */
9083        let mut result: Value = Value::from(vec![]);
9084        {
9085                        let mut i: Value = Value::Int(0);
9086            let mut __for_first_167: bool = true;
9087            while { if !__for_first_167 { i = (match (&(i), &(Value::Int(1))) { (Value::Int(x), Value::Int(y)) => Value::Int(x + y), (Value::Int(x), Value::Float(y)) => Value::Float(*x as f64 + *y), (Value::Float(x), Value::Int(y)) => Value::Float(*x + *y as f64), (Value::Float(x), Value::Float(y)) => Value::Float(x + y), _ => Value::Null }); } __for_first_167 = false; i.as_f64().unwrap_or(f64::NAN) < ((liquidations.len() as i64) as f64) } {
9088            let mut entry: Value = liquidations.as_array().and_then(|__arr| match &i { Value::Int(__n) => __arr.get(*__n as usize), Value::Str(__s) => __s.parse::<usize>().ok().and_then(|__n| __arr.get(__n)), _ => None }).cloned().unwrap_or(Value::Null);
9089            let mut parsed: Value = <Self as crate::exchange_generated::ExchangeBase>::parse_liquidation(self, entry, &[market.clone()]);
9090            append_to_array(&mut result, parsed);
9091        }
9092        }
9093        let mut sorted: Value = self.sort_by(result, Value::Str("timestamp".into()), &[]);
9094        let mut symbol: Value = self.safe_string_k(market, "symbol", &[]);
9095        return self.filter_by_symbol_since_limit(sorted, &[symbol, since, limit]);
9096
9097    Value::Null
9098}
9099
9100    fn parse_greeks(&self, mut greeks: Value, optional_args: &[Value]) -> Value {
9101        // virtual-dispatch (static: DerivedExchange::parse_greeks(self, ...))
9102        { let __v = crate::exchange::DerivedExchange::parse_greeks(self, greeks, crate::runtime::get_arg(optional_args, 0, crate::Value::Null)); if !matches!(__v, crate::Value::Null) { return __v; } }
9103
9104        let mut market = get_arg(optional_args, 0, Value::Null);
9105        panic!("{}", crate::exchange_errors::not_supported(format!("{}{}", self.id.clone(), Value::Str(" parseGreeks () is not supported yet".into()))));
9106
9107    Value::Null
9108}
9109
9110    fn parse_all_greeks(&self, mut greeks: Value, optional_args: &[Value]) -> Value {
9111        let mut symbols = get_arg(optional_args, 0, Value::Null);
9112        let mut params = get_arg(optional_args, 1, Value::Map({
9113    let mut m = indexmap::IndexMap::new();
9114    m
9115}));
9116        //
9117        // the value of greeks is either a dict or a list
9118        //
9119        let mut results: Value = Value::from(vec![]);
9120        if (matches!(&greeks, Value::Arr(_))) {
9121            {
9122                                let mut i: Value = Value::Int(0);
9123                let mut __for_first_168: bool = true;
9124                while { if !__for_first_168 { i = (match (&(i), &(Value::Int(1))) { (Value::Int(x), Value::Int(y)) => Value::Int(x + y), (Value::Int(x), Value::Float(y)) => Value::Float(*x as f64 + *y), (Value::Float(x), Value::Int(y)) => Value::Float(*x + *y as f64), (Value::Float(x), Value::Float(y)) => Value::Float(x + y), _ => Value::Null }); } __for_first_168 = false; i.as_f64().unwrap_or(f64::NAN) < ((greeks.len() as i64) as f64) } {
9125                let mut parsedTicker: Value = <Self as crate::exchange_generated::ExchangeBase>::parse_greeks(self, greeks.as_array().and_then(|__arr| match &i { Value::Int(__n) => __arr.get(*__n as usize), Value::Str(__s) => __s.parse::<usize>().ok().and_then(|__n| __arr.get(__n)), _ => None }).cloned().unwrap_or(Value::Null), &[]);
9126                let mut greek: Value = self.extend(parsedTicker, &[params.clone()]);
9127                append_to_array(&mut results, greek.clone());
9128            }
9129            }
9130        }  else {
9131            let mut marketIds: Value = object_keys(&greeks);
9132            {
9133                                let mut i: Value = Value::Int(0);
9134                let mut __for_first_169: bool = true;
9135                while { if !__for_first_169 { i = (match (&(i), &(Value::Int(1))) { (Value::Int(x), Value::Int(y)) => Value::Int(x + y), (Value::Int(x), Value::Float(y)) => Value::Float(*x as f64 + *y), (Value::Float(x), Value::Int(y)) => Value::Float(*x + *y as f64), (Value::Float(x), Value::Float(y)) => Value::Float(x + y), _ => Value::Null }); } __for_first_169 = false; i.as_f64().unwrap_or(f64::NAN) < ((marketIds.len() as i64) as f64) } {
9136                let mut marketId: Value = marketIds.as_array().and_then(|__arr| match &i { Value::Int(__n) => __arr.get(*__n as usize), Value::Str(__s) => __s.parse::<usize>().ok().and_then(|__n| __arr.get(__n)), _ => None }).cloned().unwrap_or(Value::Null);
9137                let mut market: Value = self.safe_market(&[marketId.clone()]);
9138                let mut parsed: Value = <Self as crate::exchange_generated::ExchangeBase>::parse_greeks(self, get_value(&greeks, &marketId), &[market]);
9139                let mut greek: Value = self.extend(parsed, &[params.clone()]);
9140                append_to_array(&mut results, greek);
9141            }
9142            }
9143        }
9144        let mut symbolsNormalized: Value = self.market_symbols(&[symbols]);
9145        return self.filter_by_array(results, Value::Str("symbol".into()), &[symbolsNormalized]);
9146
9147    Value::Null
9148}
9149
9150    fn parse_option(&self, mut chain: Value, optional_args: &[Value]) -> Value {
9151        let mut currency = get_arg(optional_args, 0, Value::Null);
9152        let mut market = get_arg(optional_args, 1, Value::Null);
9153        panic!("{}", crate::exchange_errors::not_supported(format!("{}{}", self.id.clone(), Value::Str(" parseOption () is not supported yet".into()))));
9154
9155    Value::Null
9156}
9157
9158    fn parse_option_chain(&self, mut response: Value, optional_args: &[Value]) -> Value {
9159        let mut currencyKey = get_arg(optional_args, 0, Value::Null);
9160        let mut symbolKey = get_arg(optional_args, 1, Value::Null);
9161        let mut optionStructures: Value = Value::Map({
9162            let mut m = indexmap::IndexMap::new();
9163            m
9164        });
9165        {
9166                        let mut i: Value = Value::Int(0);
9167            let mut __for_first_170: bool = true;
9168            while { if !__for_first_170 { i = (match (&(i), &(Value::Int(1))) { (Value::Int(x), Value::Int(y)) => Value::Int(x + y), (Value::Int(x), Value::Float(y)) => Value::Float(*x as f64 + *y), (Value::Float(x), Value::Int(y)) => Value::Float(*x + *y as f64), (Value::Float(x), Value::Float(y)) => Value::Float(x + y), _ => Value::Null }); } __for_first_170 = false; i.as_f64().unwrap_or(f64::NAN) < ((response.len() as i64) as f64) } {
9169            let mut info: Value = response.as_array().and_then(|__arr| match &i { Value::Int(__n) => __arr.get(*__n as usize), Value::Str(__s) => __s.parse::<usize>().ok().and_then(|__n| __arr.get(__n)), _ => None }).cloned().unwrap_or(Value::Null);
9170            let mut currencyId: Value = (if (currencyKey == Value::Null) { Value::Null } else { self.safe_string(info.clone(), currencyKey.clone(), &[]) });
9171            let mut currency: Value = self.safe_currency(currencyId, &[]);
9172            let mut marketId: Value = (if (symbolKey == Value::Null) { Value::Null } else { self.safe_string(info.clone(), symbolKey.clone(), &[]) });
9173            let mut market: Value = self.safe_market(&[marketId, Value::Null, Value::Null, Value::Str("option".into())]);
9174            add_element_to_object(&mut optionStructures, &market.as_map().and_then(|__m| __m.get("symbol")).cloned().unwrap_or(Value::Null), self.parse_option(info, &[currency, market.clone()]));
9175        }
9176        }
9177        return optionStructures;
9178
9179    Value::Null
9180}
9181
9182    fn parse_margin_modes(&self, mut response: Value, optional_args: &[Value]) -> Value {
9183        let mut symbols = get_arg(optional_args, 0, Value::Null);
9184        let mut symbolKey = get_arg(optional_args, 1, Value::Null);
9185        let mut marketType = get_arg(optional_args, 2, Value::Null);
9186        let mut marginModeStructures: Value = Value::Map({
9187            let mut m = indexmap::IndexMap::new();
9188            m
9189        });
9190        let mut marketTypeResolved: Value = (if (marketType == Value::Null) { Value::Str("swap".into()) } else { marketType }); // default to swap
9191        {
9192                        let mut i: Value = Value::Int(0);
9193            let mut __for_first_171: bool = true;
9194            while { if !__for_first_171 { i = (match (&(i), &(Value::Int(1))) { (Value::Int(x), Value::Int(y)) => Value::Int(x + y), (Value::Int(x), Value::Float(y)) => Value::Float(*x as f64 + *y), (Value::Float(x), Value::Int(y)) => Value::Float(*x + *y as f64), (Value::Float(x), Value::Float(y)) => Value::Float(x + y), _ => Value::Null }); } __for_first_171 = false; i.as_f64().unwrap_or(f64::NAN) < ((response.len() as i64) as f64) } {
9195            let mut info: Value = response.as_array().and_then(|__arr| match &i { Value::Int(__n) => __arr.get(*__n as usize), Value::Str(__s) => __s.parse::<usize>().ok().and_then(|__n| __arr.get(__n)), _ => None }).cloned().unwrap_or(Value::Null);
9196            let mut marketId: Value = (if (symbolKey == Value::Null) { Value::Null } else { self.safe_string(info.clone(), symbolKey.clone(), &[]) });
9197            let mut market: Value = self.safe_market(&[marketId, Value::Null, Value::Null, marketTypeResolved.clone()]);
9198            if (symbols == Value::Null) || self.in_array(market.as_map().and_then(|__m| __m.get("symbol")).cloned().unwrap_or(Value::Null), symbols.clone()).as_bool() == Some(true) {
9199                add_element_to_object(&mut marginModeStructures, &market.as_map().and_then(|__m| __m.get("symbol")).cloned().unwrap_or(Value::Null), <Self as crate::exchange_generated::ExchangeBase>::parse_margin_mode(self, info, &[market.clone()]));
9200            }
9201        }
9202        }
9203        return marginModeStructures;
9204
9205    Value::Null
9206}
9207
9208    fn parse_margin_mode(&self, mut marginMode: Value, optional_args: &[Value]) -> Value {
9209        // virtual-dispatch (static: DerivedExchange::parse_margin_mode(self, ...))
9210        { let __v = crate::exchange::DerivedExchange::parse_margin_mode(self, marginMode, crate::runtime::get_arg(optional_args, 0, crate::Value::Null)); if !matches!(__v, crate::Value::Null) { return __v; } }
9211
9212        let mut market = get_arg(optional_args, 0, Value::Null);
9213        panic!("{}", crate::exchange_errors::not_supported(format!("{}{}", self.id.clone(), Value::Str(" parseMarginMode () is not supported yet".into()))));
9214
9215    Value::Null
9216}
9217
9218    fn parse_leverages(&self, mut response: Value, optional_args: &[Value]) -> Value {
9219        let mut symbols = get_arg(optional_args, 0, Value::Null);
9220        let mut symbolKey = get_arg(optional_args, 1, Value::Null);
9221        let mut marketType = get_arg(optional_args, 2, Value::Null);
9222        let mut leverageStructures: Value = Value::Map({
9223            let mut m = indexmap::IndexMap::new();
9224            m
9225        });
9226        let mut marketTypeResolved: Value = (if (marketType == Value::Null) { Value::Str("swap".into()) } else { marketType }); // default to swap
9227        {
9228                        let mut i: Value = Value::Int(0);
9229            let mut __for_first_172: bool = true;
9230            while { if !__for_first_172 { i = (match (&(i), &(Value::Int(1))) { (Value::Int(x), Value::Int(y)) => Value::Int(x + y), (Value::Int(x), Value::Float(y)) => Value::Float(*x as f64 + *y), (Value::Float(x), Value::Int(y)) => Value::Float(*x + *y as f64), (Value::Float(x), Value::Float(y)) => Value::Float(x + y), _ => Value::Null }); } __for_first_172 = false; i.as_f64().unwrap_or(f64::NAN) < ((response.len() as i64) as f64) } {
9231            let mut info: Value = response.as_array().and_then(|__arr| match &i { Value::Int(__n) => __arr.get(*__n as usize), Value::Str(__s) => __s.parse::<usize>().ok().and_then(|__n| __arr.get(__n)), _ => None }).cloned().unwrap_or(Value::Null);
9232            let mut marketId: Value = (if (symbolKey == Value::Null) { Value::Null } else { self.safe_string(info.clone(), symbolKey.clone(), &[]) });
9233            let mut market: Value = self.safe_market(&[marketId, Value::Null, Value::Null, marketTypeResolved.clone()]);
9234            if (symbols == Value::Null) || self.in_array(market.as_map().and_then(|__m| __m.get("symbol")).cloned().unwrap_or(Value::Null), symbols.clone()).as_bool() == Some(true) {
9235                add_element_to_object(&mut leverageStructures, &market.as_map().and_then(|__m| __m.get("symbol")).cloned().unwrap_or(Value::Null), <Self as crate::exchange_generated::ExchangeBase>::parse_leverage(self, info, &[market.clone()]));
9236            }
9237        }
9238        }
9239        return leverageStructures;
9240
9241    Value::Null
9242}
9243
9244    fn parse_leverage(&self, mut leverage: Value, optional_args: &[Value]) -> Value {
9245        // virtual-dispatch (static: DerivedExchange::parse_leverage(self, ...))
9246        { let __v = crate::exchange::DerivedExchange::parse_leverage(self, leverage, crate::runtime::get_arg(optional_args, 0, crate::Value::Null)); if !matches!(__v, crate::Value::Null) { return __v; } }
9247
9248        let mut market = get_arg(optional_args, 0, Value::Null);
9249        panic!("{}", crate::exchange_errors::not_supported(format!("{}{}", self.id.clone(), Value::Str(" parseLeverage () is not supported yet".into()))));
9250
9251    Value::Null
9252}
9253
9254    fn parse_conversions(&self, mut conversions: Value, optional_args: &[Value]) -> Value {
9255        let mut code = get_arg(optional_args, 0, Value::Null);
9256        let mut fromCurrencyKey = get_arg(optional_args, 1, Value::Null);
9257        let mut toCurrencyKey = get_arg(optional_args, 2, Value::Null);
9258        let mut since = get_arg(optional_args, 3, Value::Null);
9259        let mut limit = get_arg(optional_args, 4, Value::Null);
9260        let mut params = get_arg(optional_args, 5, Value::Map({
9261    let mut m = indexmap::IndexMap::new();
9262    m
9263}));
9264        let mut conversionsArray: Value = self.to_array(conversions);
9265        let mut result: Value = Value::from(vec![]);
9266        let mut fromCurrency: Value = Value::Null;
9267        let mut toCurrency: Value = Value::Null;
9268        {
9269                        let mut i: Value = Value::Int(0);
9270            let mut __for_first_173: bool = true;
9271            while { if !__for_first_173 { i = (match (&(i), &(Value::Int(1))) { (Value::Int(x), Value::Int(y)) => Value::Int(x + y), (Value::Int(x), Value::Float(y)) => Value::Float(*x as f64 + *y), (Value::Float(x), Value::Int(y)) => Value::Float(*x + *y as f64), (Value::Float(x), Value::Float(y)) => Value::Float(x + y), _ => Value::Null }); } __for_first_173 = false; i.as_f64().unwrap_or(f64::NAN) < ((conversionsArray.len() as i64) as f64) } {
9272            let mut entry: Value = conversionsArray.as_array().and_then(|__arr| match &i { Value::Int(__n) => __arr.get(*__n as usize), Value::Str(__s) => __s.parse::<usize>().ok().and_then(|__n| __arr.get(__n)), _ => None }).cloned().unwrap_or(Value::Null);
9273            let mut fromId: Value = (if (fromCurrencyKey == Value::Null) { Value::Null } else { self.safe_string(entry.clone(), fromCurrencyKey.clone(), &[]) });
9274            let mut toId: Value = (if (toCurrencyKey == Value::Null) { Value::Null } else { self.safe_string(entry.clone(), toCurrencyKey.clone(), &[]) });
9275            if (fromId != Value::Null) {
9276                fromCurrency = self.safe_currency(fromId, &[]);
9277            }
9278            if (toId != Value::Null) {
9279                toCurrency = self.safe_currency(toId, &[]);
9280            }
9281            let mut conversion: Value = self.extend(<Self as crate::exchange_generated::ExchangeBase>::parse_conversion(self, entry, &[fromCurrency.clone(), toCurrency.clone()]), &[params.clone()]);
9282            append_to_array(&mut result, conversion);
9283        }
9284        }
9285        let mut sorted: Value = self.sort_by(result, Value::Str("timestamp".into()), &[]);
9286        if (code == Value::Null) {
9287            return self.filter_by_since_limit(sorted.clone(), &[since.clone(), limit.clone()]);
9288        }
9289        let mut currency: Value = self.safe_currency(code, &[]);
9290        if (currency == Value::Null) {
9291            panic!("{}", crate::exchange_errors::exchange_error(format!("{}{}", self.id.clone(), Value::Str(" parseConversions() could not resolve currency".into()))));
9292        }
9293        let mut currencyCode: Value = currency.as_map().and_then(|__m| __m.get("code")).cloned().unwrap_or(Value::Null);
9294        let mut fromConversion: Value = self.filter_by(sorted.clone(), Value::Str("fromCurrency".into()), currencyCode.clone(), &[]);
9295        let mut toConversion: Value = self.filter_by(sorted, Value::Str("toCurrency".into()), currencyCode, &[]);
9296        let mut both: Value = self.array_concat(fromConversion, toConversion);
9297        return self.filter_by_since_limit(both, &[since, limit]);
9298
9299    Value::Null
9300}
9301
9302    fn parse_conversion(&self, mut conversion: Value, optional_args: &[Value]) -> Value {
9303        // virtual-dispatch (static: DerivedExchange::parse_conversion(self, ...))
9304        { 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; } }
9305
9306        let mut fromCurrency = get_arg(optional_args, 0, Value::Null);
9307        let mut toCurrency = get_arg(optional_args, 1, Value::Null);
9308        if (conversion == Value::Null) {
9309            panic!("{}", crate::exchange_errors::not_supported(format!("{}{}", self.id.clone(), Value::Str(" parseConversion () is not supported yet".into()))));
9310        }
9311        panic!("{}", crate::exchange_errors::not_supported(format!("{}{}", self.id.clone(), Value::Str(" parseConversion () is not supported yet".into()))));
9312
9313    Value::Null
9314}
9315
9316    fn convert_expire_date(&self, mut date: Value) -> Value {
9317        if (date == Value::Null) {
9318            return Value::Null;
9319        }
9320        // parse YYMMDD to datetime string
9321        let mut year: Value = date.as_str().map(|__s| { let __c: Vec<char> = __s.chars().collect(); let __l = __c.len() as i64; let __i = __l.min(0); let __j = __l.min(2); if __i <= __j { __c[__i as usize..__j as usize].iter().collect::<String>() } else { String::new() } }).map(|__s| Value::Str(__s.into())).unwrap_or(Value::Null);
9322        let mut month: Value = date.as_str().map(|__s| { let __c: Vec<char> = __s.chars().collect(); let __l = __c.len() as i64; let __i = __l.min(2); let __j = __l.min(4); if __i <= __j { __c[__i as usize..__j as usize].iter().collect::<String>() } else { String::new() } }).map(|__s| Value::Str(__s.into())).unwrap_or(Value::Null);
9323        let mut day: Value = date.as_str().map(|__s| { let __c: Vec<char> = __s.chars().collect(); let __l = __c.len() as i64; let __i = __l.min(4); let __j = __l.min(6); if __i <= __j { __c[__i as usize..__j as usize].iter().collect::<String>() } else { String::new() } }).map(|__s| Value::Str(__s.into())).unwrap_or(Value::Null);
9324        // the milliseconds are spelled out because every caller writes the result into
9325        // expiryDatetime, which types.ts documents in the ISO 8601 form with them
9326        let mut reconstructedDate: Value = Value::Str(format!("{}{}", Value::Str(format!("{}{}", Value::Str(format!("{}{}", Value::Str(format!("{}{}", Value::Str(format!("{}{}", Value::Str(format!("{}{}", Value::Str("20".into()), year).into()), Value::Str("-".into())).into()), month).into()), Value::Str("-".into())).into()), day).into()), Value::Str("T00:00:00.000Z".into())).into());
9327        return reconstructedDate;
9328
9329    Value::Null
9330}
9331
9332    fn convert_expire_date_to_market_id_date(&self, mut date: Value) -> Value {
9333        if (date == Value::Null) {
9334            return Value::Null;
9335        }
9336        // parse 240119 to 19JAN24
9337        let mut year: Value = date.as_str().map(|__s| { let __c: Vec<char> = __s.chars().collect(); let __l = __c.len() as i64; let __i = __l.min(0); let __j = __l.min(2); if __i <= __j { __c[__i as usize..__j as usize].iter().collect::<String>() } else { String::new() } }).map(|__s| Value::Str(__s.into())).unwrap_or(Value::Null);
9338        let mut monthRaw: Value = date.as_str().map(|__s| { let __c: Vec<char> = __s.chars().collect(); let __l = __c.len() as i64; let __i = __l.min(2); let __j = __l.min(4); if __i <= __j { __c[__i as usize..__j as usize].iter().collect::<String>() } else { String::new() } }).map(|__s| Value::Str(__s.into())).unwrap_or(Value::Null);
9339        let mut month: Value = Value::Null;
9340        let mut day: Value = date.as_str().map(|__s| { let __c: Vec<char> = __s.chars().collect(); let __l = __c.len() as i64; let __i = __l.min(4); let __j = __l.min(6); if __i <= __j { __c[__i as usize..__j as usize].iter().collect::<String>() } else { String::new() } }).map(|__s| Value::Str(__s.into())).unwrap_or(Value::Null);
9341        if (monthRaw.as_str() == Some("01")) {
9342            month = Value::Str("JAN".into());
9343        }  else if (monthRaw.as_str() == Some("02")) {
9344            month = Value::Str("FEB".into());
9345        }  else if (monthRaw.as_str() == Some("03")) {
9346            month = Value::Str("MAR".into());
9347        }  else if (monthRaw.as_str() == Some("04")) {
9348            month = Value::Str("APR".into());
9349        }  else if (monthRaw.as_str() == Some("05")) {
9350            month = Value::Str("MAY".into());
9351        }  else if (monthRaw.as_str() == Some("06")) {
9352            month = Value::Str("JUN".into());
9353        }  else if (monthRaw.as_str() == Some("07")) {
9354            month = Value::Str("JUL".into());
9355        }  else if (monthRaw.as_str() == Some("08")) {
9356            month = Value::Str("AUG".into());
9357        }  else if (monthRaw.as_str() == Some("09")) {
9358            month = Value::Str("SEP".into());
9359        }  else if (monthRaw.as_str() == Some("10")) {
9360            month = Value::Str("OCT".into());
9361        }  else if (monthRaw.as_str() == Some("11")) {
9362            month = Value::Str("NOV".into());
9363        }  else if (monthRaw.as_str() == Some("12")) {
9364            month = Value::Str("DEC".into());
9365        }
9366        if (month == Value::Null) {
9367            panic!("{}", crate::exchange_errors::bad_symbol(format!("{}{}", Value::Str(format!("{}{}", self.id.clone(), Value::Str(" invalid expiry date ".into())).into()), date)));
9368        }
9369        let mut reconstructedDate: Value = Value::Str(format!("{}{}", Value::Str(format!("{}{}", day, month).into()), year).into());
9370        return reconstructedDate;
9371
9372    Value::Null
9373}
9374
9375    fn convert_market_id_expire_date(&self, mut date: Value) -> Value {
9376        if (date == Value::Null) {
9377            return Value::Null;
9378        }
9379        // parse 03JAN24 to 240103.
9380        let mut monthMappping: Value = Value::Map({
9381            let mut m = indexmap::IndexMap::new();
9382                m.insert("JAN".to_string(), Value::Str("01".into()));
9383                m.insert("FEB".to_string(), Value::Str("02".into()));
9384                m.insert("MAR".to_string(), Value::Str("03".into()));
9385                m.insert("APR".to_string(), Value::Str("04".into()));
9386                m.insert("MAY".to_string(), Value::Str("05".into()));
9387                m.insert("JUN".to_string(), Value::Str("06".into()));
9388                m.insert("JUL".to_string(), Value::Str("07".into()));
9389                m.insert("AUG".to_string(), Value::Str("08".into()));
9390                m.insert("SEP".to_string(), Value::Str("09".into()));
9391                m.insert("OCT".to_string(), Value::Str("10".into()));
9392                m.insert("NOV".to_string(), Value::Str("11".into()));
9393                m.insert("DEC".to_string(), Value::Str("12".into()));
9394            m
9395        });
9396        // if exchange omits first zero and provides i.e. '3JAN24' instead of '03JAN24'
9397        let mut datePadded: Value = date.clone();
9398        if (Value::Int(date.len() as i64).as_f64() == Some(6.0)) {
9399            datePadded = Value::Str(format!("{}{}", Value::Str("0".into()), date).into());
9400        }
9401        let mut year: Value = datePadded.as_str().map(|__s| { let __c: Vec<char> = __s.chars().collect(); let __l = __c.len() as i64; let __i = __l.min(0); let __j = __l.min(2); if __i <= __j { __c[__i as usize..__j as usize].iter().collect::<String>() } else { String::new() } }).map(|__s| Value::Str(__s.into())).unwrap_or(Value::Null);
9402        let mut monthName: Value = datePadded.as_str().map(|__s| { let __c: Vec<char> = __s.chars().collect(); let __l = __c.len() as i64; let __i = __l.min(2); let __j = __l.min(5); if __i <= __j { __c[__i as usize..__j as usize].iter().collect::<String>() } else { String::new() } }).map(|__s| Value::Str(__s.into())).unwrap_or(Value::Null);
9403        let mut month: Value = self.safe_string(monthMappping, monthName, &[]);
9404        let mut day: Value = datePadded.as_str().map(|__s| { let __c: Vec<char> = __s.chars().collect(); let __l = __c.len() as i64; let __i = __l.min(5); let __j = __l.min(7); if __i <= __j { __c[__i as usize..__j as usize].iter().collect::<String>() } else { String::new() } }).map(|__s| Value::Str(__s.into())).unwrap_or(Value::Null);
9405        if (month == Value::Null) {
9406            panic!("{}", crate::exchange_errors::bad_symbol(format!("{}{}", Value::Str(format!("{}{}", self.id.clone(), Value::Str(" invalid expiry date ".into())).into()), date)));
9407        }
9408        let mut reconstructedDate: Value = Value::Str(format!("{}{}", Value::Str(format!("{}{}", day, month).into()), year).into());
9409        return reconstructedDate;
9410
9411    Value::Null
9412}
9413
9414    fn load_markets_and_sign_in(&mut self) -> impl ::std::future::Future<Output = Value> + Send { async move {
9415        promise_all(&Value::from(vec![self.load_markets(&[]).await, self.sign_in(&[]).await])).await;
9416
9417    Value::Null
9418} }
9419
9420    fn parse_margin_modification(&self, mut data: Value, optional_args: &[Value]) -> Value {
9421        // virtual-dispatch (static: DerivedExchange::parse_margin_modification(self, ...))
9422        { 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; } }
9423
9424        let mut market = get_arg(optional_args, 0, Value::Null);
9425        if (data == Value::Null) {
9426            panic!("{}", crate::exchange_errors::not_supported(format!("{}{}", self.id.clone(), Value::Str(" parseMarginModification() is not supported yet".into()))));
9427        }
9428        panic!("{}", crate::exchange_errors::not_supported(format!("{}{}", self.id.clone(), Value::Str(" parseMarginModification() is not supported yet".into()))));
9429
9430    Value::Null
9431}
9432
9433    fn parse_margin_modifications(&self, mut response: Value, optional_args: &[Value]) -> Value {
9434        let mut symbols = get_arg(optional_args, 0, Value::Null);
9435        let mut symbolKey = get_arg(optional_args, 1, Value::Null);
9436        let mut marketType = get_arg(optional_args, 2, Value::Null);
9437        let mut marginModifications: Value = Value::from(vec![]);
9438        if (response == Value::Null) {
9439            return marginModifications;
9440        }
9441        {
9442                        let mut i: Value = Value::Int(0);
9443            let mut __for_first_174: bool = true;
9444            while { if !__for_first_174 { i = (match (&(i), &(Value::Int(1))) { (Value::Int(x), Value::Int(y)) => Value::Int(x + y), (Value::Int(x), Value::Float(y)) => Value::Float(*x as f64 + *y), (Value::Float(x), Value::Int(y)) => Value::Float(*x + *y as f64), (Value::Float(x), Value::Float(y)) => Value::Float(x + y), _ => Value::Null }); } __for_first_174 = false; i.as_f64().unwrap_or(f64::NAN) < ((response.len() as i64) as f64) } {
9445            let mut info: Value = response.as_array().and_then(|__arr| match &i { Value::Int(__n) => __arr.get(*__n as usize), Value::Str(__s) => __s.parse::<usize>().ok().and_then(|__n| __arr.get(__n)), _ => None }).cloned().unwrap_or(Value::Null);
9446            let mut marketId: Value = (if (symbolKey == Value::Null) { Value::Null } else { self.safe_string(info.clone(), symbolKey.clone(), &[]) });
9447            let mut market: Value = self.safe_market(&[marketId, Value::Null, Value::Null, marketType.clone()]);
9448            if (symbols == Value::Null) || self.in_array(market.as_map().and_then(|__m| __m.get("symbol")).cloned().unwrap_or(Value::Null), symbols.clone()).as_bool() == Some(true) {
9449                append_to_array(&mut marginModifications, <Self as crate::exchange_generated::ExchangeBase>::parse_margin_modification(self, info, &[market]));
9450            }
9451        }
9452        }
9453        return marginModifications;
9454
9455    Value::Null
9456}
9457
9458    fn fetch_transfer(&mut self, mut id: Value, optional_args: &[Value]) -> impl ::std::future::Future<Output = Value> + Send { async move {
9459        let mut code = get_arg(optional_args, 0, Value::Null);
9460        let mut params = get_arg(optional_args, 1, Value::Map({
9461    let mut m = indexmap::IndexMap::new();
9462    m
9463}));
9464        panic!("{}", crate::exchange_errors::not_supported(format!("{}{}", self.id.clone(), Value::Str(" fetchTransfer () is not supported yet".into()))));
9465
9466    Value::Null
9467} }
9468
9469    fn fetch_transfers(&mut self, optional_args: &[Value]) -> impl ::std::future::Future<Output = Value> + Send { async move {
9470        let mut code = get_arg(optional_args, 0, Value::Null);
9471        let mut since = get_arg(optional_args, 1, Value::Null);
9472        let mut limit = get_arg(optional_args, 2, Value::Null);
9473        let mut params = get_arg(optional_args, 3, Value::Map({
9474    let mut m = indexmap::IndexMap::new();
9475    m
9476}));
9477        panic!("{}", crate::exchange_errors::not_supported(format!("{}{}", self.id.clone(), Value::Str(" fetchTransfers () is not supported yet".into()))));
9478
9479    Value::Null
9480} }
9481
9482    fn un_watch_ohlcv(&mut self, mut symbol: Value, optional_args: &[Value]) -> impl ::std::future::Future<Output = Value> + Send { async move {
9483        let mut timeframe = get_arg(optional_args, 0, Value::Str("1m".into()));
9484        let mut params = get_arg(optional_args, 1, Value::Map({
9485    let mut m = indexmap::IndexMap::new();
9486    m
9487}));
9488        panic!("{}", crate::exchange_errors::not_supported(format!("{}{}", self.id.clone(), Value::Str(" unWatchOHLCV () is not supported yet".into()))));
9489
9490    Value::Null
9491} }
9492
9493    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 {
9494        let mut params = get_arg(optional_args, 0, Value::Map({
9495    let mut m = indexmap::IndexMap::new();
9496    m
9497}));
9498        panic!("{}", crate::exchange_errors::not_supported(format!("{}{}", self.id.clone(), Value::Str(" withdrawWs () is not supported yet".into()))));
9499
9500    Value::Null
9501} }
9502
9503    fn un_watch_my_trades(&mut self, optional_args: &[Value]) -> impl ::std::future::Future<Output = Value> + Send { async move {
9504        let mut symbol = get_arg(optional_args, 0, Value::Null);
9505        let mut params = get_arg(optional_args, 1, Value::Map({
9506    let mut m = indexmap::IndexMap::new();
9507    m
9508}));
9509        panic!("{}", crate::exchange_errors::not_supported(format!("{}{}", self.id.clone(), Value::Str(" unWatchMyTrades () is not supported yet".into()))));
9510
9511    Value::Null
9512} }
9513
9514    fn fetch_orders_by_status_ws(&mut self, mut status: Value, optional_args: &[Value]) -> impl ::std::future::Future<Output = Value> + Send { async move {
9515        let mut symbol = get_arg(optional_args, 0, Value::Null);
9516        let mut since = get_arg(optional_args, 1, Value::Null);
9517        let mut limit = get_arg(optional_args, 2, Value::Null);
9518        let mut params = get_arg(optional_args, 3, Value::Map({
9519    let mut m = indexmap::IndexMap::new();
9520    m
9521}));
9522        panic!("{}", crate::exchange_errors::not_supported(format!("{}{}", self.id.clone(), Value::Str(" fetchOrdersByStatusWs () is not supported yet".into()))));
9523
9524    Value::Null
9525} }
9526
9527    fn un_watch_bids_asks(&mut self, optional_args: &[Value]) -> impl ::std::future::Future<Output = Value> + Send { async move {
9528        let mut symbols = get_arg(optional_args, 0, Value::Null);
9529        let mut params = get_arg(optional_args, 1, Value::Map({
9530    let mut m = indexmap::IndexMap::new();
9531    m
9532}));
9533        panic!("{}", crate::exchange_errors::not_supported(format!("{}{}", self.id.clone(), Value::Str(" unWatchBidsAsks () is not supported yet".into()))));
9534
9535    Value::Null
9536} }
9537
9538    fn clean_unsubscription(&self, mut client: Value, mut subHash: Value, mut unsubHash: Value, optional_args: &[Value]) {
9539        let mut subHashIsPrefix = get_arg(optional_args, 0, Value::Bool(false));
9540        if (unsubHash != Value::Null) && (in_op(&get_value(&client, &Value::Str("subscriptions".into())), &unsubHash)) {
9541            remove(&mut get_value(&client, &Value::Str("subscriptions".into())), &unsubHash);
9542        }
9543        if !is_true(&subHashIsPrefix) {
9544            if (subHash != Value::Null) && (in_op(&get_value(&client, &Value::Str("subscriptions".into())), &subHash)) {
9545                remove(&mut get_value(&client, &Value::Str("subscriptions".into())), &subHash);
9546            }
9547            if (subHash != Value::Null) && (in_op(&get_value(&client, &Value::Str("futures".into())), &subHash)) {
9548                let mut error = crate::exchange_errors::unsubscribe_error(format!("{}{}", Value::Str(format!("{}{}", self.id.clone(), Value::Str(" ".into())).into()), subHash));
9549                client.reject(&[Value::from(error.clone()), subHash.clone()]);
9550            }
9551        }  else {
9552            let mut clientSubscriptions: Value = object_keys(&get_value(&client, &Value::Str("subscriptions".into())));
9553            {
9554                                let mut i: Value = Value::Int(0);
9555                let mut __for_first_175: bool = true;
9556                while { if !__for_first_175 { i = (match (&(i), &(Value::Int(1))) { (Value::Int(x), Value::Int(y)) => Value::Int(x + y), (Value::Int(x), Value::Float(y)) => Value::Float(*x as f64 + *y), (Value::Float(x), Value::Int(y)) => Value::Float(*x + *y as f64), (Value::Float(x), Value::Float(y)) => Value::Float(x + y), _ => Value::Null }); } __for_first_175 = false; i.as_f64().unwrap_or(f64::NAN) < ((clientSubscriptions.len() as i64) as f64) } {
9557                let mut sub: Value = clientSubscriptions.as_array().and_then(|__arr| match &i { Value::Int(__n) => __arr.get(*__n as usize), Value::Str(__s) => __s.parse::<usize>().ok().and_then(|__n| __arr.get(__n)), _ => None }).cloned().unwrap_or(Value::Null);
9558                if (sub != Value::Null) && (subHash != Value::Null) && (starts_with(&sub, &subHash)) {
9559                    remove(&mut get_value(&client, &Value::Str("subscriptions".into())), &sub);
9560                }
9561            }
9562            }
9563            let mut clientFutures: Value = object_keys(&get_value(&client, &Value::Str("futures".into())));
9564            {
9565                                let mut i: Value = Value::Int(0);
9566                let mut __for_first_176: bool = true;
9567                while { if !__for_first_176 { i = (match (&(i), &(Value::Int(1))) { (Value::Int(x), Value::Int(y)) => Value::Int(x + y), (Value::Int(x), Value::Float(y)) => Value::Float(*x as f64 + *y), (Value::Float(x), Value::Int(y)) => Value::Float(*x + *y as f64), (Value::Float(x), Value::Float(y)) => Value::Float(x + y), _ => Value::Null }); } __for_first_176 = false; i.as_f64().unwrap_or(f64::NAN) < ((clientFutures.len() as i64) as f64) } {
9568                let mut future: Value = clientFutures.as_array().and_then(|__arr| match &i { Value::Int(__n) => __arr.get(*__n as usize), Value::Str(__s) => __s.parse::<usize>().ok().and_then(|__n| __arr.get(__n)), _ => None }).cloned().unwrap_or(Value::Null);
9569                if (future != Value::Null) && (subHash != Value::Null) && (starts_with(&future, &subHash)) {
9570                    let mut error = crate::exchange_errors::unsubscribe_error(format!("{}{}", Value::Str(format!("{}{}", self.id.clone(), Value::Str(" ".into())).into()), future));
9571                    client.reject(&[Value::from(error), future.clone()]);
9572                }
9573            }
9574            }
9575        }
9576        client.resolve(&[Value::Bool(true), unsubHash]);
9577}
9578
9579    fn clean_cache(&mut self, mut subscription: Value) {
9580        let __subscription_empty = indexmap::IndexMap::new();
9581        let subscription = subscription.as_map().unwrap_or(&__subscription_empty);
9582        let mut topic: Option<String> = (match subscription.get("topic") { Some(Value::Str(__s)) if !__s.is_empty() => Value::Str(__s.clone()), Some(Value::Int(__n)) => Value::Str(__n.to_string().into()), Some(Value::Float(__f)) => Value::Str(__f.to_string().into()), _ => Value::Null }).as_str().map(str::to_owned);
9583        let mut symbols: Value = (match subscription.get("symbols") { Some(__v) if matches!(__v, Value::Arr(_)) => __v.clone(), _ => Value::from(vec![]) });
9584        let mut symbolsLength: f64 = ((symbols.len() as i64) as f64);
9585        if (topic.as_deref() == Some("ohlcv")) {
9586            let mut symbolsAndTimeframes: Value = (match subscription.get("symbolsAndTimeframes") { Some(__v) if matches!(__v, Value::Arr(_)) => __v.clone(), _ => Value::from(vec![]) });
9587            {
9588                                let mut i: Value = Value::Int(0);
9589                let mut __for_first_177: bool = true;
9590                while { if !__for_first_177 { i = (match (&(i), &(Value::Int(1))) { (Value::Int(x), Value::Int(y)) => Value::Int(x + y), (Value::Int(x), Value::Float(y)) => Value::Float(*x as f64 + *y), (Value::Float(x), Value::Int(y)) => Value::Float(*x + *y as f64), (Value::Float(x), Value::Float(y)) => Value::Float(x + y), _ => Value::Null }); } __for_first_177 = false; i.as_f64().unwrap_or(f64::NAN) < ((symbolsAndTimeframes.len() as i64) as f64) } {
9591                let mut symbolAndTimeFrame: Value = get_value(&symbolsAndTimeframes, &i);
9592                let mut symbolAndTimeFrame: Value = get_value(&symbolsAndTimeframes, &i);
9593                let mut symbol: Value = self.safe_string(symbolAndTimeFrame.clone(), Value::Int(0), &[]);
9594                let mut timeframe: Value = self.safe_string(symbolAndTimeFrame, Value::Int(1), &[]);
9595                if (symbol == Value::Null) {
9596                    panic!("{}", crate::exchange_errors::arguments_required(format!("{}{}", self.id.clone(), Value::Str(" cleanCache() requires a symbol argument".into()))));
9597                }
9598                if (timeframe == Value::Null) {
9599                    panic!("{}", crate::exchange_errors::arguments_required(format!("{}{}", self.id.clone(), Value::Str(" cleanCache() requires a timeframe argument".into()))));
9600                }
9601                if (self.ohlcvs.clone() != Value::Null) && (in_op(&self.ohlcvs, &symbol)) {
9602                    if (in_op(&get_value(&self.ohlcvs, &symbol), &timeframe)) {
9603                        remove(&mut get_value(&self.ohlcvs, &symbol), &timeframe);
9604                    }
9605                }
9606            }
9607            }
9608        }  else if symbolsLength > ((0i64) as f64) {
9609            {
9610                                let mut i: Value = Value::Int(0);
9611                let mut __for_first_178: bool = true;
9612                while { if !__for_first_178 { i = (match (&(i), &(Value::Int(1))) { (Value::Int(x), Value::Int(y)) => Value::Int(x + y), (Value::Int(x), Value::Float(y)) => Value::Float(*x as f64 + *y), (Value::Float(x), Value::Int(y)) => Value::Float(*x + *y as f64), (Value::Float(x), Value::Float(y)) => Value::Float(x + y), _ => Value::Null }); } __for_first_178 = false; i.as_f64().unwrap_or(f64::NAN) < ((symbols.len() as i64) as f64) } {
9613                let mut symbol: Value = get_value(&symbols, &i);
9614                let mut symbol: Value = get_value(&symbols, &i);
9615                if (topic.as_deref() == Some("trades")) {
9616                    if (in_op(&self.trades, &symbol)) {
9617                        remove(&mut self.trades.clone(), &symbol);
9618                    }
9619                }  else if (topic.as_deref() == Some("orderbook")) {
9620                    if (in_op(&self.orderbooks, &symbol)) {
9621                        remove(&mut self.orderbooks.clone(), &symbol);
9622                    }
9623                }  else if (topic.as_deref() == Some("ticker")) {
9624                    if (in_op(&self.tickers, &symbol)) {
9625                        remove(&mut self.tickers.clone(), &symbol);
9626                    }
9627                }  else if (topic.as_deref() == Some("bidsasks")) {
9628                    if (in_op(&self.bidsasks, &symbol)) {
9629                        remove(&mut self.bidsasks.clone(), &symbol);
9630                    }
9631                }
9632            }
9633            }
9634        }  else {
9635            if (topic.as_deref() == Some("myTrades")) && (self.myTrades.clone() != Value::Null) {
9636                self.myTrades = Value::Null;
9637            }  else if (topic.as_deref() == Some("orders")) && (self.orders.clone() != Value::Null) {
9638                self.orders = Value::Null;
9639            }  else if (topic.as_deref() == Some("positions")) && (self.positions.clone() != Value::Null) {
9640                self.positions = Value::Null;
9641                let mut clients: Value = object_values(&self.clients);
9642                {
9643                                        let mut i: Value = Value::Int(0);
9644                    let mut __for_first_179: bool = true;
9645                    while { if !__for_first_179 { i = (match (&(i), &(Value::Int(1))) { (Value::Int(x), Value::Int(y)) => Value::Int(x + y), (Value::Int(x), Value::Float(y)) => Value::Float(*x as f64 + *y), (Value::Float(x), Value::Int(y)) => Value::Float(*x + *y as f64), (Value::Float(x), Value::Float(y)) => Value::Float(x + y), _ => Value::Null }); } __for_first_179 = false; i.as_f64().unwrap_or(f64::NAN) < ((clients.len() as i64) as f64) } {
9646                    let mut client: Value = clients.as_array().and_then(|__arr| match &i { Value::Int(__n) => __arr.get(*__n as usize), Value::Str(__s) => __s.parse::<usize>().ok().and_then(|__n| __arr.get(__n)), _ => None }).cloned().unwrap_or(Value::Null);
9647                    let mut futures: Value = get_value(&client, &Value::Str("futures".into()));
9648                    if (futures != Value::Null) && (matches!(&futures, Value::Dict(__d) if __d.contains_key("fetchPositionsSnapshot"))) {
9649                        remove(&mut futures, &Value::Str("fetchPositionsSnapshot".into()));
9650                    }
9651                }
9652                }
9653            }  else if ((topic.as_deref() == Some("ticker")) || (topic.as_deref() == Some("markPrice"))) && (self.tickers.clone() != Value::Null) {
9654                let mut tickerSymbols: Value = object_keys(&self.tickers);
9655                {
9656                                        let mut i: Value = Value::Int(0);
9657                    let mut __for_first_180: bool = true;
9658                    while { if !__for_first_180 { i = (match (&(i), &(Value::Int(1))) { (Value::Int(x), Value::Int(y)) => Value::Int(x + y), (Value::Int(x), Value::Float(y)) => Value::Float(*x as f64 + *y), (Value::Float(x), Value::Int(y)) => Value::Float(*x + *y as f64), (Value::Float(x), Value::Float(y)) => Value::Float(x + y), _ => Value::Null }); } __for_first_180 = false; i.as_f64().unwrap_or(f64::NAN) < ((tickerSymbols.len() as i64) as f64) } {
9659                    let mut tickerSymbol: Value = tickerSymbols.as_array().and_then(|__arr| match &i { Value::Int(__n) => __arr.get(*__n as usize), Value::Str(__s) => __s.parse::<usize>().ok().and_then(|__n| __arr.get(__n)), _ => None }).cloned().unwrap_or(Value::Null);
9660                    if (in_op(&self.tickers, &tickerSymbol)) {
9661                        remove(&mut self.tickers.clone(), &tickerSymbol);
9662                    }
9663                }
9664                }
9665            }  else if (topic.as_deref() == Some("bidsasks")) && (self.bidsasks.clone() != Value::Null) {
9666                let mut bidsaskSymbols: Value = object_keys(&self.bidsasks);
9667                {
9668                                        let mut i: Value = Value::Int(0);
9669                    let mut __for_first_181: bool = true;
9670                    while { if !__for_first_181 { i = (match (&(i), &(Value::Int(1))) { (Value::Int(x), Value::Int(y)) => Value::Int(x + y), (Value::Int(x), Value::Float(y)) => Value::Float(*x as f64 + *y), (Value::Float(x), Value::Int(y)) => Value::Float(*x + *y as f64), (Value::Float(x), Value::Float(y)) => Value::Float(x + y), _ => Value::Null }); } __for_first_181 = false; i.as_f64().unwrap_or(f64::NAN) < ((bidsaskSymbols.len() as i64) as f64) } {
9671                    let mut bidsaskSymbol: Value = bidsaskSymbols.as_array().and_then(|__arr| match &i { Value::Int(__n) => __arr.get(*__n as usize), Value::Str(__s) => __s.parse::<usize>().ok().and_then(|__n| __arr.get(__n)), _ => None }).cloned().unwrap_or(Value::Null);
9672                    if (in_op(&self.bidsasks, &bidsaskSymbol)) {
9673                        remove(&mut self.bidsasks.clone(), &bidsaskSymbol);
9674                    }
9675                }
9676                }
9677            }
9678        }
9679}
9680
9681    fn timeframe_from_milliseconds(&self, mut ms: Value) -> Value {
9682        if ms.as_f64().unwrap_or(f64::NAN) <= ((0i64) as f64) {
9683            return Value::Str("".into());
9684        }
9685        let mut second: Value = Value::Int(1000);
9686        let mut minute: Value = (match (&(Value::Int(60)), &(second)) { (Value::Int(x), Value::Int(y)) => Value::Int(x * y), (Value::Int(x), Value::Float(y)) => Value::Float(*x as f64 * *y), (Value::Float(x), Value::Int(y)) => Value::Float(*x * *y as f64), (Value::Float(x), Value::Float(y)) => Value::Float(x * y), _ => Value::Null });
9687        let mut hour: Value = (match (&(Value::Int(60)), &(minute)) { (Value::Int(x), Value::Int(y)) => Value::Int(x * y), (Value::Int(x), Value::Float(y)) => Value::Float(*x as f64 * *y), (Value::Float(x), Value::Int(y)) => Value::Float(*x * *y as f64), (Value::Float(x), Value::Float(y)) => Value::Float(x * y), _ => Value::Null });
9688        let mut day: Value = (match (&(Value::Int(24)), &(hour)) { (Value::Int(x), Value::Int(y)) => Value::Int(x * y), (Value::Int(x), Value::Float(y)) => Value::Float(*x as f64 * *y), (Value::Float(x), Value::Int(y)) => Value::Float(*x * *y as f64), (Value::Float(x), Value::Float(y)) => Value::Float(x * y), _ => Value::Null });
9689        let mut week: Value = (match (&(Value::Int(7)), &(day)) { (Value::Int(x), Value::Int(y)) => Value::Int(x * y), (Value::Int(x), Value::Float(y)) => Value::Float(*x as f64 * *y), (Value::Float(x), Value::Int(y)) => Value::Float(*x * *y as f64), (Value::Float(x), Value::Float(y)) => Value::Float(x * y), _ => Value::Null });
9690        if (mod_val(&ms, &week).as_f64() == Some(0.0)) {
9691            return add(&((match ((ms).as_f64(), (week).as_f64()) { (Some(x), Some(y)) if y != 0.0 => Value::Float(x / y), _ => Value::Null })), &Value::Str("w".into()));
9692        }
9693        if (mod_val(&ms, &day).as_f64() == Some(0.0)) {
9694            return add(&((match ((ms).as_f64(), (day).as_f64()) { (Some(x), Some(y)) if y != 0.0 => Value::Float(x / y), _ => Value::Null })), &Value::Str("d".into()));
9695        }
9696        if (mod_val(&ms, &hour).as_f64() == Some(0.0)) {
9697            return add(&((match ((ms).as_f64(), (hour).as_f64()) { (Some(x), Some(y)) if y != 0.0 => Value::Float(x / y), _ => Value::Null })), &Value::Str("h".into()));
9698        }
9699        if (mod_val(&ms, &minute).as_f64() == Some(0.0)) {
9700            return add(&((match ((ms).as_f64(), (minute).as_f64()) { (Some(x), Some(y)) if y != 0.0 => Value::Float(x / y), _ => Value::Null })), &Value::Str("m".into()));
9701        }
9702        if (mod_val(&ms, &second).as_f64() == Some(0.0)) {
9703            return add(&((match ((ms).as_f64(), (second).as_f64()) { (Some(x), Some(y)) if y != 0.0 => Value::Float(x / y), _ => Value::Null })), &Value::Str("s".into()));
9704        }
9705        return Value::Str("".into());
9706
9707    Value::Null
9708}
9709
9710    fn is_uta_enabled(&mut self, optional_args: &[Value]) -> impl ::std::future::Future<Output = Value> + Send { async move {
9711        let mut params = get_arg(optional_args, 0, Value::Map({
9712    let mut m = indexmap::IndexMap::new();
9713    m
9714}));
9715        return Value::Bool(false);
9716
9717    Value::Null
9718} }
9719    fn close_position(&mut self, mut symbol: Value, optional_args: &[Value]) -> impl ::std::future::Future<Output = Value> + Send { async move {
9720        let mut side = get_arg(optional_args, 0, Value::Null);
9721        let mut params = get_arg(optional_args, 1, Value::Map({
9722    let mut m = indexmap::IndexMap::new();
9723    m
9724}));
9725        panic!("{}", crate::exchange_errors::not_supported(format!("{}{}", self.id.clone(), Value::Str(" closePosition() is not supported yet".into()))));
9726
9727    Value::Null
9728} }
9729
9730    fn close_all_positions(&mut self, optional_args: &[Value]) -> impl ::std::future::Future<Output = Value> + Send { async move {
9731        let mut params = get_arg(optional_args, 0, Value::Map({
9732    let mut m = indexmap::IndexMap::new();
9733    m
9734}));
9735        panic!("{}", crate::exchange_errors::not_supported(format!("{}{}", self.id.clone(), Value::Str(" closeAllPositions() is not supported yet".into()))));
9736
9737    Value::Null
9738} }
9739
9740    fn edit_orders(&mut self, mut orders: Value, optional_args: &[Value]) -> impl ::std::future::Future<Output = Value> + Send { async move {
9741        let mut params = get_arg(optional_args, 0, Value::Map({
9742    let mut m = indexmap::IndexMap::new();
9743    m
9744}));
9745        panic!("{}", crate::exchange_errors::not_supported(format!("{}{}", self.id.clone(), Value::Str(" editOrders() is not supported yet".into()))));
9746
9747    Value::Null
9748} }
9749
9750    fn fetch_canceled_and_closed_orders(&mut self, optional_args: &[Value]) -> impl ::std::future::Future<Output = Value> + Send { async move {
9751        let mut symbol = get_arg(optional_args, 0, Value::Null);
9752        let mut since = get_arg(optional_args, 1, Value::Null);
9753        let mut limit = get_arg(optional_args, 2, Value::Null);
9754        let mut params = get_arg(optional_args, 3, Value::Map({
9755    let mut m = indexmap::IndexMap::new();
9756    m
9757}));
9758        panic!("{}", crate::exchange_errors::not_supported(format!("{}{}", self.id.clone(), Value::Str(" fetchCanceledAndClosedOrders() is not supported yet".into()))));
9759
9760    Value::Null
9761} }
9762
9763    fn fetch_position_history(&mut self, mut symbol: Value, optional_args: &[Value]) -> impl ::std::future::Future<Output = Value> + Send { async move {
9764        // async-virtual: try the derived exchange first
9765        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 {
9766            if !matches!(__v, crate::Value::Null) { return __v; }
9767        }
9768
9769        let mut since = get_arg(optional_args, 0, Value::Null);
9770        let mut limit = get_arg(optional_args, 1, Value::Null);
9771        let mut params = get_arg(optional_args, 2, Value::Map({
9772    let mut m = indexmap::IndexMap::new();
9773    m
9774}));
9775        /*
9776         * @method
9777         * @name exchange#fetchPositionHistory
9778         * @description fetches the history of margin added or reduced from contract isolated positions
9779         * @param {string} [symbol] unified market symbol
9780         * @param {int} [since] timestamp in ms of the position
9781         * @param {int} [limit] the maximum amount of candles to fetch, default=1000
9782         * @param {object} params extra parameters specific to the exchange api endpoint
9783         * @returns {object[]} a list of [position structures]{@link https://docs.ccxt.com/?id=position-structure}
9784         */
9785        if (self.has.as_map().and_then(|__m| __m.get("fetchPositionsHistory")).cloned().unwrap_or(Value::Null) != Value::Null) && (self.has.as_map().and_then(|__m| __m.get("fetchPositionsHistory")).cloned().unwrap_or(Value::Null).as_bool() != Some(false)) {
9786            let mut positions: Value = self.fetch_positions_history(&[Value::from(vec![symbol]), since, limit, params]).await;
9787            return positions;
9788        }  else {
9789            panic!("{}", crate::exchange_errors::not_supported(format!("{}{}", self.id.clone(), Value::Str(" fetchPositionHistory () is not supported yet".into()))));
9790        }
9791} }
9792
9793    fn fetch_positions_history(&mut self, optional_args: &[Value]) -> impl ::std::future::Future<Output = Value> + Send { async move {
9794        // async-virtual: try the derived exchange first
9795        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 {
9796            if !matches!(__v, crate::Value::Null) { return __v; }
9797        }
9798
9799        let mut symbols = get_arg(optional_args, 0, Value::Null);
9800        let mut since = get_arg(optional_args, 1, Value::Null);
9801        let mut limit = get_arg(optional_args, 2, Value::Null);
9802        let mut params = get_arg(optional_args, 3, Value::Map({
9803    let mut m = indexmap::IndexMap::new();
9804    m
9805}));
9806        panic!("{}", crate::exchange_errors::not_supported(format!("{}{}", self.id.clone(), Value::Str(" fetchPositionsHistory () is not supported yet".into()))));
9807
9808    Value::Null
9809} }
9810
9811    fn fetch_positions_risk(&mut self, optional_args: &[Value]) -> impl ::std::future::Future<Output = Value> + Send { async move {
9812        let mut symbols = get_arg(optional_args, 0, Value::Null);
9813        let mut params = get_arg(optional_args, 1, Value::Map({
9814    let mut m = indexmap::IndexMap::new();
9815    m
9816}));
9817        panic!("{}", crate::exchange_errors::not_supported(format!("{}{}", self.id.clone(), Value::Str(" fetchPositionsRisk() is not supported yet".into()))));
9818
9819    Value::Null
9820} }
9821
9822    fn fetch_positions_for_symbol(&mut self, mut symbol: Value, optional_args: &[Value]) -> impl ::std::future::Future<Output = Value> + Send { async move {
9823        let mut params = get_arg(optional_args, 0, Value::Map({
9824    let mut m = indexmap::IndexMap::new();
9825    m
9826}));
9827        panic!("{}", crate::exchange_errors::not_supported(format!("{}{}", self.id.clone(), Value::Str(" fetchPositionsForSymbol() is not supported yet".into()))));
9828
9829    Value::Null
9830} }
9831
9832    fn fetch_positions_for_symbol_ws(&mut self, mut symbol: Value, optional_args: &[Value]) -> impl ::std::future::Future<Output = Value> + Send { async move {
9833        let mut params = get_arg(optional_args, 0, Value::Map({
9834    let mut m = indexmap::IndexMap::new();
9835    m
9836}));
9837        panic!("{}", crate::exchange_errors::not_supported(format!("{}{}", self.id.clone(), Value::Str(" fetchPositionsForSymbol() is not supported yet".into()))));
9838
9839    Value::Null
9840} }
9841
9842    fn watch_position(&mut self, optional_args: &[Value]) -> impl ::std::future::Future<Output = Value> + Send { async move {
9843        let mut symbol = get_arg(optional_args, 0, Value::Null);
9844        let mut params = get_arg(optional_args, 1, Value::Map({
9845    let mut m = indexmap::IndexMap::new();
9846    m
9847}));
9848        panic!("{}", crate::exchange_errors::not_supported(format!("{}{}", self.id.clone(), Value::Str(" watchPosition() is not supported yet".into()))));
9849
9850    Value::Null
9851} }
9852
9853    fn watch_my_trades_for_symbols(&mut self, mut symbols: Value, optional_args: &[Value]) -> impl ::std::future::Future<Output = Value> + Send { async move {
9854        let mut since = get_arg(optional_args, 0, Value::Null);
9855        let mut limit = get_arg(optional_args, 1, Value::Null);
9856        let mut params = get_arg(optional_args, 2, Value::Map({
9857    let mut m = indexmap::IndexMap::new();
9858    m
9859}));
9860        panic!("{}", crate::exchange_errors::not_supported(format!("{}{}", self.id.clone(), Value::Str(" watchMyTradesForSymbols() is not supported yet".into()))));
9861
9862    Value::Null
9863} }
9864
9865    fn watch_trades_for_symbols(&mut self, mut symbols: Value, optional_args: &[Value]) -> impl ::std::future::Future<Output = Value> + Send { async move {
9866        let mut since = get_arg(optional_args, 0, Value::Null);
9867        let mut limit = get_arg(optional_args, 1, Value::Null);
9868        let mut params = get_arg(optional_args, 2, Value::Map({
9869    let mut m = indexmap::IndexMap::new();
9870    m
9871}));
9872        panic!("{}", crate::exchange_errors::not_supported(format!("{}{}", self.id.clone(), Value::Str(" watchTradesForSymbols() is not supported yet".into()))));
9873
9874    Value::Null
9875} }
9876
9877    fn fetch_bids_asks(&mut self, optional_args: &[Value]) -> impl ::std::future::Future<Output = Value> + Send { async move {
9878        let mut symbols = get_arg(optional_args, 0, Value::Null);
9879        let mut params = get_arg(optional_args, 1, Value::Map({
9880    let mut m = indexmap::IndexMap::new();
9881    m
9882}));
9883        panic!("{}", crate::exchange_errors::not_supported(format!("{}{}", self.id.clone(), Value::Str(" fetchBidsAsks() is not supported yet".into()))));
9884
9885    Value::Null
9886} }
9887
9888    fn fetch_mark_price(&mut self, mut symbol: Value, optional_args: &[Value]) -> impl ::std::future::Future<Output = Value> + Send { async move {
9889        let mut params = get_arg(optional_args, 0, Value::Map({
9890    let mut m = indexmap::IndexMap::new();
9891    m
9892}));
9893        if (self.has.as_map().and_then(|__m| __m.get("fetchMarkPrices")).cloned().unwrap_or(Value::Null) != Value::Null) && (self.has.as_map().and_then(|__m| __m.get("fetchMarkPrices")).cloned().unwrap_or(Value::Null).as_bool() != Some(false)) {
9894            self.load_markets(&[]).await;
9895            let mut market: Value = <Self as crate::exchange_generated::ExchangeBase>::market(self, symbol);
9896            let mut symbolResolved: Value = market.as_map().and_then(|__m| __m.get("symbol")).cloned().unwrap_or(Value::Null);
9897            let mut tickers: Value = self.fetch_mark_prices(&[Value::from(vec![symbolResolved.clone()]), params]).await;
9898            let mut ticker: Value = self.safe_dict(tickers, symbolResolved.clone(), &[]);
9899            if (ticker == Value::Null) {
9900                panic!("{}", crate::exchange_errors::null_response(format!("{}{}", Value::Str(format!("{}{}", self.id.clone(), Value::Str(" fetchMarkPrices() could not find a ticker for ".into())).into()), symbolResolved)));
9901            }  else {
9902                return ticker;
9903            }
9904        }  else {
9905            panic!("{}", crate::exchange_errors::not_supported(format!("{}{}", self.id.clone(), Value::Str(" fetchMarkPrices() is not supported yet".into()))));
9906        }
9907
9908    Value::Null
9909} }
9910
9911    fn fetch_mark_prices(&mut self, optional_args: &[Value]) -> impl ::std::future::Future<Output = Value> + Send { async move {
9912        let mut symbols = get_arg(optional_args, 0, Value::Null);
9913        let mut params = get_arg(optional_args, 1, Value::Map({
9914    let mut m = indexmap::IndexMap::new();
9915    m
9916}));
9917        panic!("{}", crate::exchange_errors::not_supported(format!("{}{}", self.id.clone(), Value::Str(" fetchMarkPrices() is not supported yet".into()))));
9918
9919    Value::Null
9920} }
9921
9922    fn watch_bids_asks(&mut self, optional_args: &[Value]) -> impl ::std::future::Future<Output = Value> + Send { async move {
9923        let mut symbols = get_arg(optional_args, 0, Value::Null);
9924        let mut params = get_arg(optional_args, 1, Value::Map({
9925    let mut m = indexmap::IndexMap::new();
9926    m
9927}));
9928        panic!("{}", crate::exchange_errors::not_supported(format!("{}{}", self.id.clone(), Value::Str(" watchBidsAsks() is not supported yet".into()))));
9929
9930    Value::Null
9931} }
9932
9933    fn watch_mark_price(&mut self, mut symbol: Value, optional_args: &[Value]) -> impl ::std::future::Future<Output = Value> + Send { async move {
9934        let mut params = get_arg(optional_args, 0, Value::Map({
9935    let mut m = indexmap::IndexMap::new();
9936    m
9937}));
9938        panic!("{}", crate::exchange_errors::not_supported(format!("{}{}", self.id.clone(), Value::Str(" watchMarkPrice () is not supported yet".into()))));
9939
9940    Value::Null
9941} }
9942
9943    fn watch_mark_prices(&mut self, optional_args: &[Value]) -> impl ::std::future::Future<Output = Value> + Send { async move {
9944        let mut symbols = get_arg(optional_args, 0, Value::Null);
9945        let mut params = get_arg(optional_args, 1, Value::Map({
9946    let mut m = indexmap::IndexMap::new();
9947    m
9948}));
9949        panic!("{}", crate::exchange_errors::not_supported(format!("{}{}", self.id.clone(), Value::Str(" watchMarkPrices () is not supported yet".into()))));
9950
9951    Value::Null
9952} }
9953
9954    fn fetch_l3_order_book(&mut self, mut symbol: Value, optional_args: &[Value]) -> impl ::std::future::Future<Output = Value> + Send { async move {
9955        let mut limit = get_arg(optional_args, 0, Value::Null);
9956        let mut params = get_arg(optional_args, 1, Value::Map({
9957    let mut m = indexmap::IndexMap::new();
9958    m
9959}));
9960        panic!("{}", crate::exchange_errors::bad_request(format!("{}{}", self.id.clone(), Value::Str(" fetchL3OrderBook() is not supported yet".into()))));
9961
9962    Value::Null
9963} }
9964
9965    fn watch_order_book_for_symbols(&mut self, mut symbols: Value, optional_args: &[Value]) -> impl ::std::future::Future<Output = Value> + Send { async move {
9966        let mut limit = get_arg(optional_args, 0, Value::Null);
9967        let mut params = get_arg(optional_args, 1, Value::Map({
9968    let mut m = indexmap::IndexMap::new();
9969    m
9970}));
9971        panic!("{}", crate::exchange_errors::not_supported(format!("{}{}", self.id.clone(), Value::Str(" watchOrderBookForSymbols() is not supported yet".into()))));
9972
9973    Value::Null
9974} }
9975
9976    fn watch_orders_for_symbols(&mut self, mut symbols: Value, optional_args: &[Value]) -> impl ::std::future::Future<Output = Value> + Send { async move {
9977        let mut since = get_arg(optional_args, 0, Value::Null);
9978        let mut limit = get_arg(optional_args, 1, Value::Null);
9979        let mut params = get_arg(optional_args, 2, Value::Map({
9980    let mut m = indexmap::IndexMap::new();
9981    m
9982}));
9983        panic!("{}", crate::exchange_errors::not_supported(format!("{}{}", self.id.clone(), Value::Str(" watchOrdersForSymbols() is not supported yet".into()))));
9984
9985    Value::Null
9986} }
9987
9988    fn cancel_all_orders_ws(&mut self, optional_args: &[Value]) -> impl ::std::future::Future<Output = Value> + Send { async move {
9989        let mut symbol = get_arg(optional_args, 0, Value::Null);
9990        let mut params = get_arg(optional_args, 1, Value::Map({
9991    let mut m = indexmap::IndexMap::new();
9992    m
9993}));
9994        panic!("{}", crate::exchange_errors::not_supported(format!("{}{}", self.id.clone(), Value::Str(" cancelAllOrdersWs() is not supported yet".into()))));
9995
9996    Value::Null
9997} }
9998
9999    fn cancel_order_ws(&mut self, mut id: Value, optional_args: &[Value]) -> impl ::std::future::Future<Output = Value> + Send { async move {
10000        let mut symbol = get_arg(optional_args, 0, Value::Null);
10001        let mut params = get_arg(optional_args, 1, Value::Map({
10002    let mut m = indexmap::IndexMap::new();
10003    m
10004}));
10005        panic!("{}", crate::exchange_errors::not_supported(format!("{}{}", self.id.clone(), Value::Str(" cancelOrderWs() is not supported yet".into()))));
10006
10007    Value::Null
10008} }
10009
10010    fn cancel_orders_ws(&mut self, mut ids: Value, optional_args: &[Value]) -> impl ::std::future::Future<Output = Value> + Send { async move {
10011        let mut symbol = get_arg(optional_args, 0, Value::Null);
10012        let mut params = get_arg(optional_args, 1, Value::Map({
10013    let mut m = indexmap::IndexMap::new();
10014    m
10015}));
10016        panic!("{}", crate::exchange_errors::not_supported(format!("{}{}", self.id.clone(), Value::Str(" cancelOrdersWs() is not supported yet".into()))));
10017
10018    Value::Null
10019} }
10020
10021    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 {
10022        let mut params = get_arg(optional_args, 0, Value::Map({
10023    let mut m = indexmap::IndexMap::new();
10024    m
10025}));
10026        return self.create_order_ws(symbol, Value::Str("limit".into()), Value::Str("buy".into()), amount, &[price, params]).await;
10027
10028    Value::Null
10029} }
10030
10031    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 {
10032        let mut params = get_arg(optional_args, 0, Value::Map({
10033    let mut m = indexmap::IndexMap::new();
10034    m
10035}));
10036        return self.create_order_ws(symbol, Value::Str("limit".into()), side, amount, &[price, params]).await;
10037
10038    Value::Null
10039} }
10040
10041    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 {
10042        let mut params = get_arg(optional_args, 0, Value::Map({
10043    let mut m = indexmap::IndexMap::new();
10044    m
10045}));
10046        return self.create_order_ws(symbol, Value::Str("limit".into()), Value::Str("sell".into()), amount, &[price, params]).await;
10047
10048    Value::Null
10049} }
10050
10051    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 {
10052        let mut params = get_arg(optional_args, 0, Value::Map({
10053    let mut m = indexmap::IndexMap::new();
10054    m
10055}));
10056        return self.create_order_ws(symbol, Value::Str("market".into()), Value::Str("buy".into()), amount, &[Value::Null, params]).await;
10057
10058    Value::Null
10059} }
10060
10061    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 {
10062        let mut params = get_arg(optional_args, 0, Value::Map({
10063    let mut m = indexmap::IndexMap::new();
10064    m
10065}));
10066        /*
10067         * @method
10068         * @name createMarketOrderWithCostWs
10069         * @description create a market order by providing the symbol, side and cost
10070         * @param {string} symbol unified symbol of the market to create an order in
10071         * @param {string} side 'buy' or 'sell'
10072         * @param {float} cost how much you want to trade in units of the quote currency
10073         * @param {object} [params] extra parameters specific to the exchange API endpoint
10074         * @returns {object} an [order structure]{@link https://docs.ccxt.com/?id=order-structure}
10075         */
10076        if ((self.has.as_map().and_then(|__m| __m.get("createMarketOrderWithCostWs")).cloned().unwrap_or(Value::Null) != Value::Null) && (self.has.as_map().and_then(|__m| __m.get("createMarketOrderWithCostWs")).cloned().unwrap_or(Value::Null).as_bool() != Some(false))) || (((self.has.as_map().and_then(|__m| __m.get("createMarketBuyOrderWithCostWs")).cloned().unwrap_or(Value::Null) != Value::Null) && (self.has.as_map().and_then(|__m| __m.get("createMarketBuyOrderWithCostWs")).cloned().unwrap_or(Value::Null).as_bool() != Some(false))) && ((self.has.as_map().and_then(|__m| __m.get("createMarketSellOrderWithCostWs")).cloned().unwrap_or(Value::Null) != Value::Null) && (self.has.as_map().and_then(|__m| __m.get("createMarketSellOrderWithCostWs")).cloned().unwrap_or(Value::Null).as_bool() != Some(false)))) {
10077            return self.create_order_ws(symbol, Value::Str("market".into()), side, cost, &[Value::Int(1), params]).await;
10078        }
10079        panic!("{}", crate::exchange_errors::not_supported(format!("{}{}", self.id.clone(), Value::Str(" createMarketOrderWithCostWs() is not supported yet".into()))));
10080
10081    Value::Null
10082} }
10083
10084    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 {
10085        let mut price = get_arg(optional_args, 0, Value::Null);
10086        let mut params = get_arg(optional_args, 1, Value::Map({
10087    let mut m = indexmap::IndexMap::new();
10088    m
10089}));
10090        return self.create_order_ws(symbol, Value::Str("market".into()), side, amount, &[price, params]).await;
10091
10092    Value::Null
10093} }
10094
10095    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 {
10096        let mut params = get_arg(optional_args, 0, Value::Map({
10097    let mut m = indexmap::IndexMap::new();
10098    m
10099}));
10100        return self.create_order_ws(symbol, Value::Str("market".into()), Value::Str("sell".into()), amount, &[Value::Null, params]).await;
10101
10102    Value::Null
10103} }
10104
10105    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 {
10106        let mut price = get_arg(optional_args, 0, Value::Null);
10107        let mut takeProfit = get_arg(optional_args, 1, Value::Null);
10108        let mut stopLoss = get_arg(optional_args, 2, Value::Null);
10109        let mut params = get_arg(optional_args, 3, Value::Map({
10110    let mut m = indexmap::IndexMap::new();
10111    m
10112}));
10113        /*
10114         * @method
10115         * @name createOrderWithTakeProfitAndStopLossWs
10116         * @description create an order with a stop loss or take profit attached (type 3)
10117         * @param {string} symbol unified symbol of the market to create an order in
10118         * @param {string} type 'market' or 'limit'
10119         * @param {string} side 'buy' or 'sell'
10120         * @param {float} amount how much you want to trade in units of the base currency or the number of contracts
10121         * @param {float} [price] the price to fulfill the order, in units of the quote currency, ignored in market orders
10122         * @param {float} [takeProfit] the take profit price, in units of the quote currency
10123         * @param {float} [stopLoss] the stop loss price, in units of the quote currency
10124         * @param {object} [params] extra parameters specific to the exchange API endpoint
10125         * @param {string} [params.takeProfitType] *not available on all exchanges* 'limit' or 'market'
10126         * @param {string} [params.stopLossType] *not available on all exchanges* 'limit' or 'market'
10127         * @param {string} [params.takeProfitPriceType] *not available on all exchanges* 'last', 'mark' or 'index'
10128         * @param {string} [params.stopLossPriceType] *not available on all exchanges* 'last', 'mark' or 'index'
10129         * @param {float} [params.takeProfitLimitPrice] *not available on all exchanges* limit price for a limit take profit order
10130         * @param {float} [params.stopLossLimitPrice] *not available on all exchanges* stop loss for a limit stop loss order
10131         * @param {float} [params.takeProfitAmount] *not available on all exchanges* the amount for a take profit
10132         * @param {float} [params.stopLossAmount] *not available on all exchanges* the amount for a stop loss
10133         * @returns {object} an [order structure]{@link https://docs.ccxt.com/?id=order-structure}
10134         */
10135        let mut paramsValue: Value = 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()]);
10136        if (self.has.as_map().and_then(|__m| __m.get("createOrderWithTakeProfitAndStopLossWs")).cloned().unwrap_or(Value::Null) != Value::Null) && (self.has.as_map().and_then(|__m| __m.get("createOrderWithTakeProfitAndStopLossWs")).cloned().unwrap_or(Value::Null).as_bool() != Some(false)) {
10137            return self.create_order_ws(symbol, type_var, side, amount, &[price, paramsValue]).await;
10138        }
10139        panic!("{}", crate::exchange_errors::not_supported(format!("{}{}", self.id.clone(), Value::Str(" createOrderWithTakeProfitAndStopLossWs() is not supported yet".into()))));
10140
10141    Value::Null
10142} }
10143
10144    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 {
10145        let mut price = get_arg(optional_args, 0, Value::Null);
10146        let mut params = get_arg(optional_args, 1, Value::Map({
10147    let mut m = indexmap::IndexMap::new();
10148    m
10149}));
10150        panic!("{}", crate::exchange_errors::not_supported(format!("{}{}", self.id.clone(), Value::Str(" createOrderWs() is not supported yet".into()))));
10151
10152    Value::Null
10153} }
10154
10155    fn create_orders_ws(&mut self, mut orders: Value, optional_args: &[Value]) -> impl ::std::future::Future<Output = Value> + Send { async move {
10156        let mut params = get_arg(optional_args, 0, Value::Map({
10157    let mut m = indexmap::IndexMap::new();
10158    m
10159}));
10160        panic!("{}", crate::exchange_errors::not_supported(format!("{}{}", self.id.clone(), Value::Str(" createOrdersWs () is not supported yet".into()))));
10161
10162    Value::Null
10163} }
10164
10165    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 {
10166        let mut price = get_arg(optional_args, 0, Value::Null);
10167        let mut params = get_arg(optional_args, 1, Value::Map({
10168    let mut m = indexmap::IndexMap::new();
10169    m
10170}));
10171        if (self.has.as_map().and_then(|__m| __m.get("createPostOnlyOrderWs")).cloned().unwrap_or(Value::Null) == Value::Null) || (self.has.as_map().and_then(|__m| __m.get("createPostOnlyOrderWs")).cloned().unwrap_or(Value::Null).as_bool() == Some(false)) {
10172            panic!("{}", crate::exchange_errors::not_supported(format!("{}{}", self.id.clone(), Value::Str(" createPostOnlyOrderWs() is not supported yet".into()))));
10173        }
10174        let mut query: Value = self.extend(params, &[Value::Map({
10175            let mut m = indexmap::IndexMap::new();
10176                m.insert("postOnly".to_string(), Value::Bool(true));
10177            m
10178        })]);
10179        return self.create_order_ws(symbol, type_var, side, amount, &[price, query]).await;
10180
10181    Value::Null
10182} }
10183
10184    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 {
10185        let mut price = get_arg(optional_args, 0, Value::Null);
10186        let mut params = get_arg(optional_args, 1, Value::Map({
10187    let mut m = indexmap::IndexMap::new();
10188    m
10189}));
10190        if (self.has.as_map().and_then(|__m| __m.get("createReduceOnlyOrderWs")).cloned().unwrap_or(Value::Null) == Value::Null) || (self.has.as_map().and_then(|__m| __m.get("createReduceOnlyOrderWs")).cloned().unwrap_or(Value::Null).as_bool() == Some(false)) {
10191            panic!("{}", crate::exchange_errors::not_supported(format!("{}{}", self.id.clone(), Value::Str(" createReduceOnlyOrderWs() is not supported yet".into()))));
10192        }
10193        let mut query: Value = self.extend(params, &[Value::Map({
10194            let mut m = indexmap::IndexMap::new();
10195                m.insert("reduceOnly".to_string(), Value::Bool(true));
10196            m
10197        })]);
10198        return self.create_order_ws(symbol, type_var, side, amount, &[price, query]).await;
10199
10200    Value::Null
10201} }
10202
10203    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 {
10204        let mut params = get_arg(optional_args, 0, Value::Map({
10205    let mut m = indexmap::IndexMap::new();
10206    m
10207}));
10208        if (self.has.as_map().and_then(|__m| __m.get("createStopLimitOrderWs")).cloned().unwrap_or(Value::Null) == Value::Null) || (self.has.as_map().and_then(|__m| __m.get("createStopLimitOrderWs")).cloned().unwrap_or(Value::Null).as_bool() == Some(false)) {
10209            panic!("{}", crate::exchange_errors::not_supported(format!("{}{}", self.id.clone(), Value::Str(" createStopLimitOrderWs() is not supported yet".into()))));
10210        }
10211        let mut query: Value = self.extend(params, &[Value::Map({
10212            let mut m = indexmap::IndexMap::new();
10213                m.insert("stopPrice".to_string(), triggerPrice);
10214            m
10215        })]);
10216        return self.create_order_ws(symbol, Value::Str("limit".into()), side, amount, &[price, query]).await;
10217
10218    Value::Null
10219} }
10220
10221    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 {
10222        let mut price = get_arg(optional_args, 0, Value::Null);
10223        let mut stopLossPrice = get_arg(optional_args, 1, Value::Null);
10224        let mut params = get_arg(optional_args, 2, Value::Map({
10225    let mut m = indexmap::IndexMap::new();
10226    m
10227}));
10228        /*
10229         * @method
10230         * @name createStopLossOrderWs
10231         * @description create a trigger stop loss order (type 2)
10232         * @param {string} symbol unified symbol of the market to create an order in
10233         * @param {string} type 'market' or 'limit'
10234         * @param {string} side 'buy' or 'sell'
10235         * @param {float} amount how much you want to trade in units of the base currency or the number of contracts
10236         * @param {float} [price] the price to fulfill the order, in units of the quote currency, ignored in market orders
10237         * @param {float} stopLossPrice the price to trigger the stop loss order, in units of the quote currency
10238         * @param {object} [params] extra parameters specific to the exchange API endpoint
10239         * @returns {object} an [order structure]{@link https://docs.ccxt.com/?id=order-structure}
10240         */
10241        if (stopLossPrice == Value::Null) {
10242            panic!("{}", crate::exchange_errors::arguments_required(format!("{}{}", self.id.clone(), Value::Str(" createStopLossOrderWs() requires a stopLossPrice argument".into()))));
10243        }
10244        let mut paramsExtended: Value = self.extend(params, &[Value::Map({
10245            let mut m = indexmap::IndexMap::new();
10246                m.insert("stopLossPrice".to_string(), stopLossPrice);
10247            m
10248        })]);
10249        if (self.has.as_map().and_then(|__m| __m.get("createStopLossOrderWs")).cloned().unwrap_or(Value::Null) != Value::Null) && (self.has.as_map().and_then(|__m| __m.get("createStopLossOrderWs")).cloned().unwrap_or(Value::Null).as_bool() != Some(false)) {
10250            return self.create_order_ws(symbol, type_var, side, amount, &[price, paramsExtended]).await;
10251        }
10252        panic!("{}", crate::exchange_errors::not_supported(format!("{}{}", self.id.clone(), Value::Str(" createStopLossOrderWs() is not supported yet".into()))));
10253
10254    Value::Null
10255} }
10256
10257    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 {
10258        let mut params = get_arg(optional_args, 0, Value::Map({
10259    let mut m = indexmap::IndexMap::new();
10260    m
10261}));
10262        if (self.has.as_map().and_then(|__m| __m.get("createStopMarketOrderWs")).cloned().unwrap_or(Value::Null) == Value::Null) || (self.has.as_map().and_then(|__m| __m.get("createStopMarketOrderWs")).cloned().unwrap_or(Value::Null).as_bool() == Some(false)) {
10263            panic!("{}", crate::exchange_errors::not_supported(format!("{}{}", self.id.clone(), Value::Str(" createStopMarketOrderWs() is not supported yet".into()))));
10264        }
10265        let mut query: Value = self.extend(params, &[Value::Map({
10266            let mut m = indexmap::IndexMap::new();
10267                m.insert("stopPrice".to_string(), triggerPrice);
10268            m
10269        })]);
10270        return self.create_order_ws(symbol, Value::Str("market".into()), side, amount, &[Value::Null, query]).await;
10271
10272    Value::Null
10273} }
10274
10275    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 {
10276        let mut price = get_arg(optional_args, 0, Value::Null);
10277        let mut triggerPrice = get_arg(optional_args, 1, Value::Null);
10278        let mut params = get_arg(optional_args, 2, Value::Map({
10279    let mut m = indexmap::IndexMap::new();
10280    m
10281}));
10282        if (self.has.as_map().and_then(|__m| __m.get("createStopOrderWs")).cloned().unwrap_or(Value::Null) == Value::Null) || (self.has.as_map().and_then(|__m| __m.get("createStopOrderWs")).cloned().unwrap_or(Value::Null).as_bool() == Some(false)) {
10283            panic!("{}", crate::exchange_errors::not_supported(format!("{}{}", self.id.clone(), Value::Str(" createStopOrderWs() is not supported yet".into()))));
10284        }
10285        if (triggerPrice == Value::Null) {
10286            panic!("{}", crate::exchange_errors::arguments_required(format!("{}{}", self.id.clone(), Value::Str(" createStopOrderWs() requires a stopPrice argument".into()))));
10287        }
10288        let mut query: Value = self.extend(params, &[Value::Map({
10289            let mut m = indexmap::IndexMap::new();
10290                m.insert("stopPrice".to_string(), triggerPrice);
10291            m
10292        })]);
10293        return self.create_order_ws(symbol, type_var, side, amount, &[price, query]).await;
10294
10295    Value::Null
10296} }
10297
10298    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 {
10299        let mut price = get_arg(optional_args, 0, Value::Null);
10300        let mut takeProfitPrice = get_arg(optional_args, 1, Value::Null);
10301        let mut params = get_arg(optional_args, 2, Value::Map({
10302    let mut m = indexmap::IndexMap::new();
10303    m
10304}));
10305        /*
10306         * @method
10307         * @name createTakeProfitOrderWs
10308         * @description create a trigger take profit order (type 2)
10309         * @param {string} symbol unified symbol of the market to create an order in
10310         * @param {string} type 'market' or 'limit'
10311         * @param {string} side 'buy' or 'sell'
10312         * @param {float} amount how much you want to trade in units of the base currency or the number of contracts
10313         * @param {float} [price] the price to fulfill the order, in units of the quote currency, ignored in market orders
10314         * @param {float} takeProfitPrice the price to trigger the take profit order, in units of the quote currency
10315         * @param {object} [params] extra parameters specific to the exchange API endpoint
10316         * @returns {object} an [order structure]{@link https://docs.ccxt.com/?id=order-structure}
10317         */
10318        if (takeProfitPrice == Value::Null) {
10319            panic!("{}", crate::exchange_errors::arguments_required(format!("{}{}", self.id.clone(), Value::Str(" createTakeProfitOrderWs() requires a takeProfitPrice argument".into()))));
10320        }
10321        let mut paramsExtended: Value = self.extend(params, &[Value::Map({
10322            let mut m = indexmap::IndexMap::new();
10323                m.insert("takeProfitPrice".to_string(), takeProfitPrice);
10324            m
10325        })]);
10326        if (self.has.as_map().and_then(|__m| __m.get("createTakeProfitOrderWs")).cloned().unwrap_or(Value::Null) != Value::Null) && (self.has.as_map().and_then(|__m| __m.get("createTakeProfitOrderWs")).cloned().unwrap_or(Value::Null).as_bool() != Some(false)) {
10327            return self.create_order_ws(symbol, type_var, side, amount, &[price, paramsExtended]).await;
10328        }
10329        panic!("{}", crate::exchange_errors::not_supported(format!("{}{}", self.id.clone(), Value::Str(" createTakeProfitOrderWs() is not supported yet".into()))));
10330
10331    Value::Null
10332} }
10333
10334    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 {
10335        let mut price = get_arg(optional_args, 0, Value::Null);
10336        let mut trailingAmount = get_arg(optional_args, 1, Value::Null);
10337        let mut trailingTriggerPrice = get_arg(optional_args, 2, Value::Null);
10338        let mut params = get_arg(optional_args, 3, Value::Map({
10339    let mut m = indexmap::IndexMap::new();
10340    m
10341}));
10342        /*
10343         * @method
10344         * @name createTrailingAmountOrderWs
10345         * @description create a trailing order by providing the symbol, type, side, amount, price and trailingAmount
10346         * @param {string} symbol unified symbol of the market to create an order in
10347         * @param {string} type 'market' or 'limit'
10348         * @param {string} side 'buy' or 'sell'
10349         * @param {float} amount how much you want to trade in units of the base currency, or number of contracts
10350         * @param {float} [price] the price for the order to be filled at, in units of the quote currency, ignored in market orders
10351         * @param {float} trailingAmount the quote amount to trail away from the current market price
10352         * @param {float} [trailingTriggerPrice] the price to activate a trailing order, default uses the price argument
10353         * @param {object} [params] extra parameters specific to the exchange API endpoint
10354         * @returns {object} an [order structure]{@link https://docs.ccxt.com/?id=order-structure}
10355         */
10356        if (trailingAmount == Value::Null) {
10357            panic!("{}", crate::exchange_errors::arguments_required(format!("{}{}", self.id.clone(), Value::Str(" createTrailingAmountOrderWs() requires a trailingAmount argument".into()))));
10358        }
10359        if let Value::Dict(__d) = &mut params { std::sync::Arc::make_mut(__d).insert("trailingAmount".into(), trailingAmount); }
10360        if (trailingTriggerPrice != Value::Null) {
10361            if let Value::Dict(__d) = &mut params { std::sync::Arc::make_mut(__d).insert("trailingTriggerPrice".into(), trailingTriggerPrice); }
10362        }
10363        if (self.has.as_map().and_then(|__m| __m.get("createTrailingAmountOrderWs")).cloned().unwrap_or(Value::Null) != Value::Null) && (self.has.as_map().and_then(|__m| __m.get("createTrailingAmountOrderWs")).cloned().unwrap_or(Value::Null).as_bool() != Some(false)) {
10364            return self.create_order_ws(symbol, type_var, side, amount, &[price, params]).await;
10365        }
10366        panic!("{}", crate::exchange_errors::not_supported(format!("{}{}", self.id.clone(), Value::Str(" createTrailingAmountOrderWs() is not supported yet".into()))));
10367
10368    Value::Null
10369} }
10370
10371    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 {
10372        let mut price = get_arg(optional_args, 0, Value::Null);
10373        let mut trailingPercent = get_arg(optional_args, 1, Value::Null);
10374        let mut trailingTriggerPrice = get_arg(optional_args, 2, Value::Null);
10375        let mut params = get_arg(optional_args, 3, Value::Map({
10376    let mut m = indexmap::IndexMap::new();
10377    m
10378}));
10379        /*
10380         * @method
10381         * @name createTrailingPercentOrderWs
10382         * @description create a trailing order by providing the symbol, type, side, amount, price and trailingPercent
10383         * @param {string} symbol unified symbol of the market to create an order in
10384         * @param {string} type 'market' or 'limit'
10385         * @param {string} side 'buy' or 'sell'
10386         * @param {float} amount how much you want to trade in units of the base currency, or number of contracts
10387         * @param {float} [price] the price for the order to be filled at, in units of the quote currency, ignored in market orders
10388         * @param {float} trailingPercent the percent to trail away from the current market price
10389         * @param {float} [trailingTriggerPrice] the price to activate a trailing order, default uses the price argument
10390         * @param {object} [params] extra parameters specific to the exchange API endpoint
10391         * @returns {object} an [order structure]{@link https://docs.ccxt.com/?id=order-structure}
10392         */
10393        if (trailingPercent == Value::Null) {
10394            panic!("{}", crate::exchange_errors::arguments_required(format!("{}{}", self.id.clone(), Value::Str(" createTrailingPercentOrderWs() requires a trailingPercent argument".into()))));
10395        }
10396        if let Value::Dict(__d) = &mut params { std::sync::Arc::make_mut(__d).insert("trailingPercent".into(), trailingPercent); }
10397        if (trailingTriggerPrice != Value::Null) {
10398            if let Value::Dict(__d) = &mut params { std::sync::Arc::make_mut(__d).insert("trailingTriggerPrice".into(), trailingTriggerPrice); }
10399        }
10400        if (self.has.as_map().and_then(|__m| __m.get("createTrailingPercentOrderWs")).cloned().unwrap_or(Value::Null) != Value::Null) && (self.has.as_map().and_then(|__m| __m.get("createTrailingPercentOrderWs")).cloned().unwrap_or(Value::Null).as_bool() != Some(false)) {
10401            return self.create_order_ws(symbol, type_var, side, amount, &[price, params]).await;
10402        }
10403        panic!("{}", crate::exchange_errors::not_supported(format!("{}{}", self.id.clone(), Value::Str(" createTrailingPercentOrderWs() is not supported yet".into()))));
10404
10405    Value::Null
10406} }
10407
10408    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 {
10409        let mut price = get_arg(optional_args, 0, Value::Null);
10410        let mut triggerPrice = get_arg(optional_args, 1, Value::Null);
10411        let mut params = get_arg(optional_args, 2, Value::Map({
10412    let mut m = indexmap::IndexMap::new();
10413    m
10414}));
10415        /*
10416         * @method
10417         * @name createTriggerOrderWs
10418         * @description create a trigger stop order (type 1)
10419         * @param {string} symbol unified symbol of the market to create an order in
10420         * @param {string} type 'market' or 'limit'
10421         * @param {string} side 'buy' or 'sell'
10422         * @param {float} amount how much you want to trade in units of the base currency or the number of contracts
10423         * @param {float} [price] the price to fulfill the order, in units of the quote currency, ignored in market orders
10424         * @param {float} triggerPrice the price to trigger the stop order, in units of the quote currency
10425         * @param {object} [params] extra parameters specific to the exchange API endpoint
10426         * @returns {object} an [order structure]{@link https://docs.ccxt.com/?id=order-structure}
10427         */
10428        if (triggerPrice == Value::Null) {
10429            panic!("{}", crate::exchange_errors::arguments_required(format!("{}{}", self.id.clone(), Value::Str(" createTriggerOrderWs() requires a triggerPrice argument".into()))));
10430        }
10431        let mut paramsExtended: Value = self.extend(params, &[Value::Map({
10432            let mut m = indexmap::IndexMap::new();
10433                m.insert("triggerPrice".to_string(), triggerPrice);
10434            m
10435        })]);
10436        if (self.has.as_map().and_then(|__m| __m.get("createTriggerOrderWs")).cloned().unwrap_or(Value::Null) != Value::Null) && (self.has.as_map().and_then(|__m| __m.get("createTriggerOrderWs")).cloned().unwrap_or(Value::Null).as_bool() != Some(false)) {
10437            return self.create_order_ws(symbol, type_var, side, amount, &[price, paramsExtended]).await;
10438        }
10439        panic!("{}", crate::exchange_errors::not_supported(format!("{}{}", self.id.clone(), Value::Str(" createTriggerOrderWs() is not supported yet".into()))));
10440
10441    Value::Null
10442} }
10443
10444    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 {
10445        let mut amount = get_arg(optional_args, 0, Value::Null);
10446        let mut price = get_arg(optional_args, 1, Value::Null);
10447        let mut params = get_arg(optional_args, 2, Value::Map({
10448    let mut m = indexmap::IndexMap::new();
10449    m
10450}));
10451        self.cancel_order_ws(id, &[symbol.clone()]).await;
10452        return self.create_order_ws(symbol, type_var, side, amount, &[price, params]).await;
10453
10454    Value::Null
10455} }
10456
10457    fn fetch_closed_orders_ws(&mut self, optional_args: &[Value]) -> impl ::std::future::Future<Output = Value> + Send { async move {
10458        let mut symbol = get_arg(optional_args, 0, Value::Null);
10459        let mut since = get_arg(optional_args, 1, Value::Null);
10460        let mut limit = get_arg(optional_args, 2, Value::Null);
10461        let mut params = get_arg(optional_args, 3, Value::Map({
10462    let mut m = indexmap::IndexMap::new();
10463    m
10464}));
10465        if (self.has.as_map().and_then(|__m| __m.get("fetchOrdersWs")).cloned().unwrap_or(Value::Null) != Value::Null) && (self.has.as_map().and_then(|__m| __m.get("fetchOrdersWs")).cloned().unwrap_or(Value::Null).as_bool() != Some(false)) {
10466            let mut orders: Value = self.fetch_orders_ws(&[symbol, since, limit, params]).await;
10467            return self.filter_by(orders, Value::Str("status".into()), Value::Str("closed".into()), &[]);
10468        }
10469        panic!("{}", crate::exchange_errors::not_supported(format!("{}{}", self.id.clone(), Value::Str(" fetchClosedOrdersWs() is not supported yet".into()))));
10470
10471    Value::Null
10472} }
10473
10474    fn fetch_my_trades_ws(&mut self, optional_args: &[Value]) -> impl ::std::future::Future<Output = Value> + Send { async move {
10475        let mut symbol = get_arg(optional_args, 0, Value::Null);
10476        let mut since = get_arg(optional_args, 1, Value::Null);
10477        let mut limit = get_arg(optional_args, 2, Value::Null);
10478        let mut params = get_arg(optional_args, 3, Value::Map({
10479    let mut m = indexmap::IndexMap::new();
10480    m
10481}));
10482        panic!("{}", crate::exchange_errors::not_supported(format!("{}{}", self.id.clone(), Value::Str(" fetchMyTradesWs() is not supported yet".into()))));
10483
10484    Value::Null
10485} }
10486
10487    fn fetch_open_orders_ws(&mut self, optional_args: &[Value]) -> impl ::std::future::Future<Output = Value> + Send { async move {
10488        let mut symbol = get_arg(optional_args, 0, Value::Null);
10489        let mut since = get_arg(optional_args, 1, Value::Null);
10490        let mut limit = get_arg(optional_args, 2, Value::Null);
10491        let mut params = get_arg(optional_args, 3, Value::Map({
10492    let mut m = indexmap::IndexMap::new();
10493    m
10494}));
10495        if (self.has.as_map().and_then(|__m| __m.get("fetchOrdersWs")).cloned().unwrap_or(Value::Null) != Value::Null) && (self.has.as_map().and_then(|__m| __m.get("fetchOrdersWs")).cloned().unwrap_or(Value::Null).as_bool() != Some(false)) {
10496            let mut orders: Value = self.fetch_orders_ws(&[symbol, since, limit, params]).await;
10497            return self.filter_by(orders, Value::Str("status".into()), Value::Str("open".into()), &[]);
10498        }
10499        panic!("{}", crate::exchange_errors::not_supported(format!("{}{}", self.id.clone(), Value::Str(" fetchOpenOrdersWs() is not supported yet".into()))));
10500
10501    Value::Null
10502} }
10503
10504    fn fetch_order_book_ws(&mut self, mut symbol: Value, optional_args: &[Value]) -> impl ::std::future::Future<Output = Value> + Send { async move {
10505        let mut limit = get_arg(optional_args, 0, Value::Null);
10506        let mut params = get_arg(optional_args, 1, Value::Map({
10507    let mut m = indexmap::IndexMap::new();
10508    m
10509}));
10510        panic!("{}", crate::exchange_errors::not_supported(format!("{}{}", self.id.clone(), Value::Str(" fetchOrderBookWs() is not supported yet".into()))));
10511
10512    Value::Null
10513} }
10514
10515    fn fetch_order_ws(&mut self, mut id: Value, optional_args: &[Value]) -> impl ::std::future::Future<Output = Value> + Send { async move {
10516        let mut symbol = get_arg(optional_args, 0, Value::Null);
10517        let mut params = get_arg(optional_args, 1, Value::Map({
10518    let mut m = indexmap::IndexMap::new();
10519    m
10520}));
10521        panic!("{}", crate::exchange_errors::not_supported(format!("{}{}", self.id.clone(), Value::Str(" fetchOrderWs() is not supported yet".into()))));
10522
10523    Value::Null
10524} }
10525
10526    fn fetch_orders_ws(&mut self, optional_args: &[Value]) -> impl ::std::future::Future<Output = Value> + Send { async move {
10527        let mut symbol = get_arg(optional_args, 0, Value::Null);
10528        let mut since = get_arg(optional_args, 1, Value::Null);
10529        let mut limit = get_arg(optional_args, 2, Value::Null);
10530        let mut params = get_arg(optional_args, 3, Value::Map({
10531    let mut m = indexmap::IndexMap::new();
10532    m
10533}));
10534        panic!("{}", crate::exchange_errors::not_supported(format!("{}{}", self.id.clone(), Value::Str(" fetchOrdersWs() is not supported yet".into()))));
10535
10536    Value::Null
10537} }
10538
10539    fn fetch_position_ws(&mut self, mut symbol: Value, optional_args: &[Value]) -> impl ::std::future::Future<Output = Value> + Send { async move {
10540        let mut params = get_arg(optional_args, 0, Value::Map({
10541    let mut m = indexmap::IndexMap::new();
10542    m
10543}));
10544        panic!("{}", crate::exchange_errors::not_supported(format!("{}{}", self.id.clone(), Value::Str(" fetchPositionWs() is not supported yet".into()))));
10545
10546    Value::Null
10547} }
10548
10549    fn fetch_positions_ws(&mut self, optional_args: &[Value]) -> impl ::std::future::Future<Output = Value> + Send { async move {
10550        let mut symbols = get_arg(optional_args, 0, Value::Null);
10551        let mut params = get_arg(optional_args, 1, Value::Map({
10552    let mut m = indexmap::IndexMap::new();
10553    m
10554}));
10555        panic!("{}", crate::exchange_errors::not_supported(format!("{}{}", self.id.clone(), Value::Str(" fetchPositions() is not supported yet".into()))));
10556
10557    Value::Null
10558} }
10559
10560    fn fetch_ticker_ws(&mut self, mut symbol: Value, optional_args: &[Value]) -> impl ::std::future::Future<Output = Value> + Send { async move {
10561        let mut params = get_arg(optional_args, 0, Value::Map({
10562    let mut m = indexmap::IndexMap::new();
10563    m
10564}));
10565        if (self.has.as_map().and_then(|__m| __m.get("fetchTickersWs")).cloned().unwrap_or(Value::Null) != Value::Null) && (self.has.as_map().and_then(|__m| __m.get("fetchTickersWs")).cloned().unwrap_or(Value::Null).as_bool() != Some(false)) {
10566            self.load_markets(&[]).await;
10567            let mut market: Value = <Self as crate::exchange_generated::ExchangeBase>::market(self, symbol);
10568            let mut symbolResolved: Value = market.as_map().and_then(|__m| __m.get("symbol")).cloned().unwrap_or(Value::Null);
10569            let mut tickers: Value = self.fetch_tickers_ws(&[Value::from(vec![symbolResolved.clone()]), params]).await;
10570            let mut ticker: Value = self.safe_dict(tickers, symbolResolved.clone(), &[]);
10571            if (ticker == Value::Null) {
10572                panic!("{}", crate::exchange_errors::null_response(format!("{}{}", Value::Str(format!("{}{}", self.id.clone(), Value::Str(" fetchTickerWs() could not find a ticker for ".into())).into()), symbolResolved)));
10573            }  else {
10574                return ticker;
10575            }
10576        }  else {
10577            panic!("{}", crate::exchange_errors::not_supported(format!("{}{}", self.id.clone(), Value::Str(" fetchTickerWs() is not supported yet".into()))));
10578        }
10579
10580    Value::Null
10581} }
10582
10583    fn fetch_tickers_ws(&mut self, optional_args: &[Value]) -> impl ::std::future::Future<Output = Value> + Send { async move {
10584        let mut symbols = get_arg(optional_args, 0, Value::Null);
10585        let mut params = get_arg(optional_args, 1, Value::Map({
10586    let mut m = indexmap::IndexMap::new();
10587    m
10588}));
10589        panic!("{}", crate::exchange_errors::not_supported(format!("{}{}", self.id.clone(), Value::Str(" fetchTickersWs() is not supported yet".into()))));
10590
10591    Value::Null
10592} }
10593
10594    fn fetch_trades_ws(&mut self, mut symbol: Value, optional_args: &[Value]) -> impl ::std::future::Future<Output = Value> + Send { async move {
10595        let mut since = get_arg(optional_args, 0, Value::Null);
10596        let mut limit = get_arg(optional_args, 1, Value::Null);
10597        let mut params = get_arg(optional_args, 2, Value::Map({
10598    let mut m = indexmap::IndexMap::new();
10599    m
10600}));
10601        panic!("{}", crate::exchange_errors::not_supported(format!("{}{}", self.id.clone(), Value::Str(" fetchTradesWs() is not supported yet".into()))));
10602
10603    Value::Null
10604} }
10605
10606
10607    fn fetch_trades(&mut self, mut symbol: Value, optional_args: &[Value]) -> impl ::std::future::Future<Output = Value> + Send { async move {
10608        // async-virtual: try the derived exchange first
10609        if let Some(__v) = self.dispatch_to_derived("fetch_trades", { let mut __args: Vec<crate::Value> = Vec::new(); __args.push(symbol); __args.extend_from_slice(optional_args); __args }).await {
10610            if !matches!(__v, crate::Value::Null) { return __v; }
10611        }
10612
10613        let mut since = get_arg(optional_args, 0, Value::Null);
10614        let mut limit = get_arg(optional_args, 1, Value::Null);
10615        let mut params = get_arg(optional_args, 2, Value::Map({
10616    let mut m = indexmap::IndexMap::new();
10617    m
10618}));
10619        panic!("{}", crate::exchange_errors::not_supported(format!("{}{}", self.id.clone(), Value::Str(" fetchTrades() is not supported yet".into()))));
10620
10621    Value::Null
10622} }
10623
10624    fn watch_trades(&mut self, mut symbol: Value, optional_args: &[Value]) -> impl ::std::future::Future<Output = Value> + Send { async move {
10625        let mut since = get_arg(optional_args, 0, Value::Null);
10626        let mut limit = get_arg(optional_args, 1, Value::Null);
10627        let mut params = get_arg(optional_args, 2, Value::Map({
10628    let mut m = indexmap::IndexMap::new();
10629    m
10630}));
10631        panic!("{}", crate::exchange_errors::not_supported(format!("{}{}", self.id.clone(), Value::Str(" watchTrades() is not supported yet".into()))));
10632
10633    Value::Null
10634} }
10635
10636    fn fetch_order_book(&mut self, mut symbol: Value, optional_args: &[Value]) -> impl ::std::future::Future<Output = Value> + Send { async move {
10637        // async-virtual: try the derived exchange first
10638        if let Some(__v) = self.dispatch_to_derived("fetch_order_book", { let mut __args: Vec<crate::Value> = Vec::new(); __args.push(symbol); __args.extend_from_slice(optional_args); __args }).await {
10639            if !matches!(__v, crate::Value::Null) { return __v; }
10640        }
10641
10642        let mut limit = get_arg(optional_args, 0, Value::Null);
10643        let mut params = get_arg(optional_args, 1, Value::Map({
10644    let mut m = indexmap::IndexMap::new();
10645    m
10646}));
10647        panic!("{}", crate::exchange_errors::not_supported(format!("{}{}", self.id.clone(), Value::Str(" fetchOrderBook() is not supported yet".into()))));
10648
10649    Value::Null
10650} }
10651
10652    fn fetch_rest_order_book_safe(&mut self, mut symbol: Value, optional_args: &[Value]) -> impl ::std::future::Future<Output = Value> + Send { async move {
10653        let mut limit = get_arg(optional_args, 0, Value::Null);
10654        let mut params = get_arg(optional_args, 1, Value::Map({
10655    let mut m = indexmap::IndexMap::new();
10656    m
10657}));
10658        let mut fetchSnapshotMaxRetries: Value = self.handle_option(Value::Str("watchOrderBook".into()), Value::Str("maxRetries".into()), &[Value::Int(3)]);
10659        {
10660                        let mut i: Value = Value::Int(0);
10661            let mut __for_first_182: bool = true;
10662            while { if !__for_first_182 { i = (match (&(i), &(Value::Int(1))) { (Value::Int(x), Value::Int(y)) => Value::Int(x + y), (Value::Int(x), Value::Float(y)) => Value::Float(*x as f64 + *y), (Value::Float(x), Value::Int(y)) => Value::Float(*x + *y as f64), (Value::Float(x), Value::Float(y)) => Value::Float(x + y), _ => Value::Null }); } __for_first_182 = false; i.as_f64().unwrap_or(f64::NAN) < fetchSnapshotMaxRetries.as_f64().unwrap_or(f64::NAN) } {
10663            let _try_result = futures::FutureExt::catch_unwind(std::panic::AssertUnwindSafe(async {
10664                let mut orderBook: Value = self.fetch_order_book(symbol.clone(), &[limit.clone(), params.clone()]).await;
10665                return orderBook;
10666             #[allow(unreachable_code)] { Value::Null }})).await;
10667match _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); 
10668                if is_equal(&((match (&(i), &(Value::Int(1))) { (Value::Int(x), Value::Int(y)) => Value::Int(x + y), (Value::Int(x), Value::Float(y)) => Value::Float(*x as f64 + *y), (Value::Float(x), Value::Int(y)) => Value::Float(*x + *y as f64), (Value::Float(x), Value::Float(y)) => Value::Float(x + y), _ => Value::Null })), &fetchSnapshotMaxRetries) {
10669                    panic!("{}", e);
10670                }
10671             } }
10672        }
10673        }
10674        return Value::Null;
10675
10676    Value::Null
10677} }
10678
10679    fn watch_order_book(&mut self, mut symbol: Value, optional_args: &[Value]) -> impl ::std::future::Future<Output = Value> + Send { async move {
10680        let mut limit = get_arg(optional_args, 0, Value::Null);
10681        let mut params = get_arg(optional_args, 1, Value::Map({
10682    let mut m = indexmap::IndexMap::new();
10683    m
10684}));
10685        panic!("{}", crate::exchange_errors::not_supported(format!("{}{}", self.id.clone(), Value::Str(" watchOrderBook() is not supported yet".into()))));
10686
10687    Value::Null
10688} }
10689
10690    fn fetch_open_interest(&mut self, mut symbol: Value, optional_args: &[Value]) -> impl ::std::future::Future<Output = Value> + Send { async move {
10691        // async-virtual: try the derived exchange first
10692        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 {
10693            if !matches!(__v, crate::Value::Null) { return __v; }
10694        }
10695
10696        let mut params = get_arg(optional_args, 0, Value::Map({
10697    let mut m = indexmap::IndexMap::new();
10698    m
10699}));
10700        if (self.has.as_map().and_then(|__m| __m.get("fetchOpenInterests")).cloned().unwrap_or(Value::Null) != Value::Null) && (self.has.as_map().and_then(|__m| __m.get("fetchOpenInterests")).cloned().unwrap_or(Value::Null).as_bool() != Some(false)) {
10701            let mut openInterests: Value = self.fetch_open_interests(&[Value::from(vec![symbol.clone()]), params]).await;
10702            let mut openInterest: Value = self.safe_dict(openInterests, symbol, &[]);
10703            return openInterest;
10704        }  else {
10705            panic!("{}", crate::exchange_errors::not_supported(format!("{}{}", self.id.clone(), Value::Str(" fetchOpenInterest() is not supported yet".into()))));
10706        }
10707
10708    Value::Null
10709} }
10710
10711    fn fetch_l2_order_book(&mut self, mut symbol: Value, optional_args: &[Value]) -> impl ::std::future::Future<Output = Value> + Send { async move {
10712        let mut limit = get_arg(optional_args, 0, Value::Null);
10713        let mut params = get_arg(optional_args, 1, Value::Map({
10714    let mut m = indexmap::IndexMap::new();
10715    m
10716}));
10717        let mut orderbook: Value = self.fetch_order_book(symbol, &[limit, params]).await;
10718        return self.extend(orderbook.clone(), &[Value::Map({
10719    let mut m = indexmap::IndexMap::new();
10720        m.insert("asks".to_string(), self.sort_by(self.aggregate(orderbook.as_map().and_then(|__m| __m.get("asks")).cloned().unwrap_or(Value::Null)), Value::Int(0), &[]));
10721        m.insert("bids".to_string(), self.sort_by(self.aggregate(orderbook.as_map().and_then(|__m| __m.get("bids")).cloned().unwrap_or(Value::Null)), Value::Int(0), &[Value::Bool(true)]));
10722    m
10723})]);
10724
10725    Value::Null
10726} }
10727
10728    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 {
10729        let mut price = get_arg(optional_args, 0, Value::Null);
10730        let mut params = get_arg(optional_args, 1, Value::Map({
10731    let mut m = indexmap::IndexMap::new();
10732    m
10733}));
10734        return self.edit_limit_order(id, symbol, Value::Str("buy".into()), amount, &[price, params]).await;
10735
10736    Value::Null
10737} }
10738
10739    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 {
10740        let mut price = get_arg(optional_args, 0, Value::Null);
10741        let mut params = get_arg(optional_args, 1, Value::Map({
10742    let mut m = indexmap::IndexMap::new();
10743    m
10744}));
10745        return self.edit_limit_order(id, symbol, Value::Str("sell".into()), amount, &[price, params]).await;
10746
10747    Value::Null
10748} }
10749
10750    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 {
10751        let mut price = get_arg(optional_args, 0, Value::Null);
10752        let mut params = get_arg(optional_args, 1, Value::Map({
10753    let mut m = indexmap::IndexMap::new();
10754    m
10755}));
10756        return self.edit_order(id, symbol, Value::Str("limit".into()), side, &[amount, price, params]).await;
10757
10758    Value::Null
10759} }
10760
10761    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 {
10762        // async-virtual: try the derived exchange first
10763        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 {
10764            if !matches!(__v, crate::Value::Null) { return __v; }
10765        }
10766
10767        let mut amount = get_arg(optional_args, 0, Value::Null);
10768        let mut price = get_arg(optional_args, 1, Value::Null);
10769        let mut params = get_arg(optional_args, 2, Value::Map({
10770    let mut m = indexmap::IndexMap::new();
10771    m
10772}));
10773        self.cancel_order(id, &[symbol.clone()]).await;
10774        return self.create_order(symbol, type_var, side, amount, &[price, params]).await;
10775
10776    Value::Null
10777} }
10778
10779    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 {
10780        let mut amount = get_arg(optional_args, 0, Value::Null);
10781        let mut price = get_arg(optional_args, 1, Value::Null);
10782        let mut params = get_arg(optional_args, 2, Value::Map({
10783    let mut m = indexmap::IndexMap::new();
10784    m
10785}));
10786        let mut extendedParams: Value = self.extend(params, &[Value::Map({
10787            let mut m = indexmap::IndexMap::new();
10788                m.insert("clientOrderId".to_string(), clientOrderId);
10789            m
10790        })]);
10791        return self.edit_order(Value::Str("".into()), symbol, type_var, side, &[amount, price, extendedParams]).await;
10792
10793    Value::Null
10794} }
10795
10796    fn fetch_position(&mut self, mut symbol: Value, optional_args: &[Value]) -> impl ::std::future::Future<Output = Value> + Send { async move {
10797        // async-virtual: try the derived exchange first
10798        if let Some(__v) = self.dispatch_to_derived("fetch_position", { let mut __args: Vec<crate::Value> = Vec::new(); __args.push(symbol); __args.extend_from_slice(optional_args); __args }).await {
10799            if !matches!(__v, crate::Value::Null) { return __v; }
10800        }
10801
10802        let mut params = get_arg(optional_args, 0, Value::Map({
10803    let mut m = indexmap::IndexMap::new();
10804    m
10805}));
10806        panic!("{}", crate::exchange_errors::not_supported(format!("{}{}", self.id.clone(), Value::Str(" fetchPosition() is not supported yet".into()))));
10807
10808    Value::Null
10809} }
10810
10811    fn watch_positions(&mut self, optional_args: &[Value]) -> impl ::std::future::Future<Output = Value> + Send { async move {
10812        let mut symbols = get_arg(optional_args, 0, Value::Null);
10813        let mut since = get_arg(optional_args, 1, Value::Null);
10814        let mut limit = get_arg(optional_args, 2, Value::Null);
10815        let mut params = get_arg(optional_args, 3, Value::Map({
10816    let mut m = indexmap::IndexMap::new();
10817    m
10818}));
10819        panic!("{}", crate::exchange_errors::not_supported(format!("{}{}", self.id.clone(), Value::Str(" watchPositions() is not supported yet".into()))));
10820
10821    Value::Null
10822} }
10823
10824    fn watch_position_for_symbols(&mut self, optional_args: &[Value]) -> impl ::std::future::Future<Output = Value> + Send { async move {
10825        let mut symbols = get_arg(optional_args, 0, Value::Null);
10826        let mut since = get_arg(optional_args, 1, Value::Null);
10827        let mut limit = get_arg(optional_args, 2, Value::Null);
10828        let mut params = get_arg(optional_args, 3, Value::Map({
10829    let mut m = indexmap::IndexMap::new();
10830    m
10831}));
10832        return self.watch_positions(&[symbols, since, limit, params]).await;
10833
10834    Value::Null
10835} }
10836
10837    fn fetch_positions(&mut self, optional_args: &[Value]) -> impl ::std::future::Future<Output = Value> + Send { async move {
10838        // async-virtual: try the derived exchange first
10839        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 {
10840            if !matches!(__v, crate::Value::Null) { return __v; }
10841        }
10842
10843        let mut symbols = get_arg(optional_args, 0, Value::Null);
10844        let mut params = get_arg(optional_args, 1, Value::Map({
10845    let mut m = indexmap::IndexMap::new();
10846    m
10847}));
10848        panic!("{}", crate::exchange_errors::not_supported(format!("{}{}", self.id.clone(), Value::Str(" fetchPositions() is not supported yet".into()))));
10849
10850    Value::Null
10851} }
10852
10853    fn fetch_ticker(&mut self, mut symbol: Value, optional_args: &[Value]) -> impl ::std::future::Future<Output = Value> + Send { async move {
10854        // async-virtual: try the derived exchange first
10855        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 {
10856            if !matches!(__v, crate::Value::Null) { return __v; }
10857        }
10858
10859        let mut params = get_arg(optional_args, 0, Value::Map({
10860    let mut m = indexmap::IndexMap::new();
10861    m
10862}));
10863        if (self.has.as_map().and_then(|__m| __m.get("fetchTickers")).cloned().unwrap_or(Value::Null) != Value::Null) && (self.has.as_map().and_then(|__m| __m.get("fetchTickers")).cloned().unwrap_or(Value::Null).as_bool() != Some(false)) {
10864            self.load_markets(&[]).await;
10865            let mut market: Value = <Self as crate::exchange_generated::ExchangeBase>::market(self, symbol);
10866            let mut symbolResolved: Value = market.as_map().and_then(|__m| __m.get("symbol")).cloned().unwrap_or(Value::Null);
10867            let mut tickers: Value = self.fetch_tickers(&[Value::from(vec![symbolResolved.clone()]), params]).await;
10868            let mut ticker: Value = self.safe_dict(tickers, symbolResolved.clone(), &[]);
10869            if (ticker == Value::Null) {
10870                panic!("{}", crate::exchange_errors::null_response(format!("{}{}", Value::Str(format!("{}{}", self.id.clone(), Value::Str(" fetchTickers() could not find a ticker for ".into())).into()), symbolResolved)));
10871            }  else {
10872                return ticker;
10873            }
10874        }  else {
10875            panic!("{}", crate::exchange_errors::not_supported(format!("{}{}", self.id.clone(), Value::Str(" fetchTicker() is not supported yet".into()))));
10876        }
10877
10878    Value::Null
10879} }
10880
10881    fn watch_ticker(&mut self, mut symbol: Value, optional_args: &[Value]) -> impl ::std::future::Future<Output = Value> + Send { async move {
10882        let mut params = get_arg(optional_args, 0, Value::Map({
10883    let mut m = indexmap::IndexMap::new();
10884    m
10885}));
10886        panic!("{}", crate::exchange_errors::not_supported(format!("{}{}", self.id.clone(), Value::Str(" watchTicker() is not supported yet".into()))));
10887
10888    Value::Null
10889} }
10890
10891    fn fetch_tickers(&mut self, optional_args: &[Value]) -> impl ::std::future::Future<Output = Value> + Send { async move {
10892        // async-virtual: try the derived exchange first
10893        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 {
10894            if !matches!(__v, crate::Value::Null) { return __v; }
10895        }
10896
10897        let mut symbols = get_arg(optional_args, 0, Value::Null);
10898        let mut params = get_arg(optional_args, 1, Value::Map({
10899    let mut m = indexmap::IndexMap::new();
10900    m
10901}));
10902        panic!("{}", crate::exchange_errors::not_supported(format!("{}{}", self.id.clone(), Value::Str(" fetchTickers() is not supported yet".into()))));
10903
10904    Value::Null
10905} }
10906
10907    fn watch_tickers(&mut self, optional_args: &[Value]) -> impl ::std::future::Future<Output = Value> + Send { async move {
10908        let mut symbols = get_arg(optional_args, 0, Value::Null);
10909        let mut params = get_arg(optional_args, 1, Value::Map({
10910    let mut m = indexmap::IndexMap::new();
10911    m
10912}));
10913        panic!("{}", crate::exchange_errors::not_supported(format!("{}{}", self.id.clone(), Value::Str(" watchTickers() is not supported yet".into()))));
10914
10915    Value::Null
10916} }
10917
10918    fn fetch_order(&mut self, mut id: Value, optional_args: &[Value]) -> impl ::std::future::Future<Output = Value> + Send { async move {
10919        // async-virtual: try the derived exchange first
10920        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 {
10921            if !matches!(__v, crate::Value::Null) { return __v; }
10922        }
10923
10924        let mut symbol = get_arg(optional_args, 0, Value::Null);
10925        let mut params = get_arg(optional_args, 1, Value::Map({
10926    let mut m = indexmap::IndexMap::new();
10927    m
10928}));
10929        panic!("{}", crate::exchange_errors::not_supported(format!("{}{}", self.id.clone(), Value::Str(" fetchOrder() is not supported yet".into()))));
10930
10931    Value::Null
10932} }
10933
10934/*
10935 * @method
10936 * @name fetchOrderWithClientOrderId
10937 * @description create a market order by providing the symbol, side and cost
10938 * @param {string} clientOrderId client order Id
10939 * @param {string} symbol unified symbol of the market to create an order in
10940 * @param {object} [params] extra parameters specific to the exchange API endpoint
10941 * @returns {object} an [order structure]{@link https://docs.ccxt.com/?id=order-structure}
10942 */
10943    fn fetch_order_with_client_order_id(&mut self, mut clientOrderId: Value, optional_args: &[Value]) -> impl ::std::future::Future<Output = Value> + Send { async move {
10944        let mut symbol = get_arg(optional_args, 0, Value::Null);
10945        let mut params = get_arg(optional_args, 1, Value::Map({
10946    let mut m = indexmap::IndexMap::new();
10947    m
10948}));
10949        let mut extendedParams: Value = self.extend(params, &[Value::Map({
10950            let mut m = indexmap::IndexMap::new();
10951                m.insert("clientOrderId".to_string(), clientOrderId);
10952            m
10953        })]);
10954        return self.fetch_order(Value::Str("".into()), &[symbol, extendedParams]).await;
10955
10956    Value::Null
10957} }
10958
10959    fn fetch_order_status(&mut self, mut id: Value, optional_args: &[Value]) -> impl ::std::future::Future<Output = Value> + Send { async move {
10960        let mut symbol = get_arg(optional_args, 0, Value::Null);
10961        let mut params = get_arg(optional_args, 1, Value::Map({
10962    let mut m = indexmap::IndexMap::new();
10963    m
10964}));
10965        // TODO: TypeScript: change method signature by replacing
10966        // Promise<string> with Promise<Order['status']>.
10967        let mut order: Value = self.fetch_order(id, &[symbol, params]).await;
10968        return order.as_map().and_then(|__m| __m.get("status")).cloned().unwrap_or(Value::Null);
10969
10970    Value::Null
10971} }
10972
10973    fn fetch_unified_order(&mut self, mut order: Value, optional_args: &[Value]) -> impl ::std::future::Future<Output = Value> + Send { async move {
10974        let mut params = get_arg(optional_args, 0, Value::Map({
10975    let mut m = indexmap::IndexMap::new();
10976    m
10977}));
10978        return self.fetch_order(self.safe_string_k(order.clone(), "id", &[]), &[self.safe_string_k(order, "symbol", &[]), params]).await;
10979
10980    Value::Null
10981} }
10982
10983    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 {
10984        // async-virtual: try the derived exchange first
10985        if let Some(__v) = self.dispatch_to_derived("create_order", { let mut __args: Vec<crate::Value> = Vec::new(); __args.push(symbol); __args.push(type_var); __args.push(side); __args.push(amount); __args.extend_from_slice(optional_args); __args }).await {
10986            if !matches!(__v, crate::Value::Null) { return __v; }
10987        }
10988
10989        let mut price = get_arg(optional_args, 0, Value::Null);
10990        let mut params = get_arg(optional_args, 1, Value::Map({
10991    let mut m = indexmap::IndexMap::new();
10992    m
10993}));
10994        panic!("{}", crate::exchange_errors::not_supported(format!("{}{}", self.id.clone(), Value::Str(" createOrder() is not supported yet".into()))));
10995
10996    Value::Null
10997} }
10998
10999    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 {
11000        let mut price = get_arg(optional_args, 0, Value::Null);
11001        let mut trailingAmount = get_arg(optional_args, 1, Value::Null);
11002        let mut trailingTriggerPrice = get_arg(optional_args, 2, Value::Null);
11003        let mut params = get_arg(optional_args, 3, Value::Map({
11004    let mut m = indexmap::IndexMap::new();
11005    m
11006}));
11007        /*
11008         * @method
11009         * @name createTrailingAmountOrder
11010         * @description create a trailing order by providing the symbol, type, side, amount, price and trailingAmount
11011         * @param {string} symbol unified symbol of the market to create an order in
11012         * @param {string} type 'market' or 'limit'
11013         * @param {string} side 'buy' or 'sell'
11014         * @param {float} amount how much you want to trade in units of the base currency, or number of contracts
11015         * @param {float} [price] the price for the order to be filled at, in units of the quote currency, ignored in market orders
11016         * @param {float} trailingAmount the quote amount to trail away from the current market price
11017         * @param {float} [trailingTriggerPrice] the price to activate a trailing order, default uses the price argument
11018         * @param {object} [params] extra parameters specific to the exchange API endpoint
11019         * @returns {object} an [order structure]{@link https://docs.ccxt.com/?id=order-structure}
11020         */
11021        if (trailingAmount == Value::Null) {
11022            panic!("{}", crate::exchange_errors::arguments_required(format!("{}{}", self.id.clone(), Value::Str(" createTrailingAmountOrder() requires a trailingAmount argument".into()))));
11023        }
11024        if let Value::Dict(__d) = &mut params { std::sync::Arc::make_mut(__d).insert("trailingAmount".into(), trailingAmount); }
11025        if (trailingTriggerPrice != Value::Null) {
11026            if let Value::Dict(__d) = &mut params { std::sync::Arc::make_mut(__d).insert("trailingTriggerPrice".into(), trailingTriggerPrice); }
11027        }
11028        if (self.has.as_map().and_then(|__m| __m.get("createTrailingAmountOrder")).cloned().unwrap_or(Value::Null) != Value::Null) && (self.has.as_map().and_then(|__m| __m.get("createTrailingAmountOrder")).cloned().unwrap_or(Value::Null).as_bool() != Some(false)) {
11029            return self.create_order(symbol, type_var, side, amount, &[price, params]).await;
11030        }
11031        panic!("{}", crate::exchange_errors::not_supported(format!("{}{}", self.id.clone(), Value::Str(" createTrailingAmountOrder() is not supported yet".into()))));
11032
11033    Value::Null
11034} }
11035
11036    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 {
11037        let mut price = get_arg(optional_args, 0, Value::Null);
11038        let mut trailingPercent = get_arg(optional_args, 1, Value::Null);
11039        let mut trailingTriggerPrice = get_arg(optional_args, 2, Value::Null);
11040        let mut params = get_arg(optional_args, 3, Value::Map({
11041    let mut m = indexmap::IndexMap::new();
11042    m
11043}));
11044        /*
11045         * @method
11046         * @name createTrailingPercentOrder
11047         * @description create a trailing order by providing the symbol, type, side, amount, price and trailingPercent
11048         * @param {string} symbol unified symbol of the market to create an order in
11049         * @param {string} type 'market' or 'limit'
11050         * @param {string} side 'buy' or 'sell'
11051         * @param {float} amount how much you want to trade in units of the base currency, or number of contracts
11052         * @param {float} [price] the price for the order to be filled at, in units of the quote currency, ignored in market orders
11053         * @param {float} trailingPercent the percent to trail away from the current market price
11054         * @param {float} [trailingTriggerPrice] the price to activate a trailing order, default uses the price argument
11055         * @param {object} [params] extra parameters specific to the exchange API endpoint
11056         * @returns {object} an [order structure]{@link https://docs.ccxt.com/?id=order-structure}
11057         */
11058        if (trailingPercent == Value::Null) {
11059            panic!("{}", crate::exchange_errors::arguments_required(format!("{}{}", self.id.clone(), Value::Str(" createTrailingPercentOrder() requires a trailingPercent argument".into()))));
11060        }
11061        if let Value::Dict(__d) = &mut params { std::sync::Arc::make_mut(__d).insert("trailingPercent".into(), trailingPercent); }
11062        if (trailingTriggerPrice != Value::Null) {
11063            if let Value::Dict(__d) = &mut params { std::sync::Arc::make_mut(__d).insert("trailingTriggerPrice".into(), trailingTriggerPrice); }
11064        }
11065        if (self.has.as_map().and_then(|__m| __m.get("createTrailingPercentOrder")).cloned().unwrap_or(Value::Null) != Value::Null) && (self.has.as_map().and_then(|__m| __m.get("createTrailingPercentOrder")).cloned().unwrap_or(Value::Null).as_bool() != Some(false)) {
11066            return self.create_order(symbol, type_var, side, amount, &[price, params]).await;
11067        }
11068        panic!("{}", crate::exchange_errors::not_supported(format!("{}{}", self.id.clone(), Value::Str(" createTrailingPercentOrder() is not supported yet".into()))));
11069
11070    Value::Null
11071} }
11072
11073    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 {
11074        let mut params = get_arg(optional_args, 0, Value::Map({
11075    let mut m = indexmap::IndexMap::new();
11076    m
11077}));
11078        /*
11079         * @method
11080         * @name createMarketOrderWithCost
11081         * @description create a market order by providing the symbol, side and cost
11082         * @param {string} symbol unified symbol of the market to create an order in
11083         * @param {string} side 'buy' or 'sell'
11084         * @param {float} cost how much you want to trade in units of the quote currency
11085         * @param {object} [params] extra parameters specific to the exchange API endpoint
11086         * @returns {object} an [order structure]{@link https://docs.ccxt.com/?id=order-structure}
11087         */
11088        if ((self.has.as_map().and_then(|__m| __m.get("createMarketOrderWithCost")).cloned().unwrap_or(Value::Null) != Value::Null) && (self.has.as_map().and_then(|__m| __m.get("createMarketOrderWithCost")).cloned().unwrap_or(Value::Null).as_bool() != Some(false))) || (((self.has.as_map().and_then(|__m| __m.get("createMarketBuyOrderWithCost")).cloned().unwrap_or(Value::Null) != Value::Null) && (self.has.as_map().and_then(|__m| __m.get("createMarketBuyOrderWithCost")).cloned().unwrap_or(Value::Null).as_bool() != Some(false))) && ((self.has.as_map().and_then(|__m| __m.get("createMarketSellOrderWithCost")).cloned().unwrap_or(Value::Null) != Value::Null) && (self.has.as_map().and_then(|__m| __m.get("createMarketSellOrderWithCost")).cloned().unwrap_or(Value::Null).as_bool() != Some(false)))) {
11089            return self.create_order(symbol, Value::Str("market".into()), side, cost, &[Value::Int(1), params]).await;
11090        }
11091        panic!("{}", crate::exchange_errors::not_supported(format!("{}{}", self.id.clone(), Value::Str(" createMarketOrderWithCost() is not supported yet".into()))));
11092
11093    Value::Null
11094} }
11095
11096    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 {
11097        let mut params = get_arg(optional_args, 0, Value::Map({
11098    let mut m = indexmap::IndexMap::new();
11099    m
11100}));
11101        /*
11102         * @method
11103         * @name createMarketBuyOrderWithCost
11104         * @description create a market buy order by providing the symbol and cost
11105         * @param {string} symbol unified symbol of the market to create an order in
11106         * @param {float} cost how much you want to trade in units of the quote currency
11107         * @param {object} [params] extra parameters specific to the exchange API endpoint
11108         * @returns {object} an [order structure]{@link https://docs.ccxt.com/?id=order-structure}
11109         */
11110        if (is_equal(&self.options.as_map().and_then(|__m| __m.get("createMarketBuyOrderRequiresPrice")).cloned().unwrap_or(Value::Null), &Value::Bool(true))) || ((self.has.as_map().and_then(|__m| __m.get("createMarketBuyOrderWithCost")).cloned().unwrap_or(Value::Null) != Value::Null) && (self.has.as_map().and_then(|__m| __m.get("createMarketBuyOrderWithCost")).cloned().unwrap_or(Value::Null).as_bool() != Some(false))) {
11111            return self.create_order(symbol, Value::Str("market".into()), Value::Str("buy".into()), cost, &[Value::Int(1), params]).await;
11112        }
11113        panic!("{}", crate::exchange_errors::not_supported(format!("{}{}", self.id.clone(), Value::Str(" createMarketBuyOrderWithCost() is not supported yet".into()))));
11114
11115    Value::Null
11116} }
11117
11118    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 {
11119        let mut params = get_arg(optional_args, 0, Value::Map({
11120    let mut m = indexmap::IndexMap::new();
11121    m
11122}));
11123        /*
11124         * @method
11125         * @name createMarketSellOrderWithCost
11126         * @description create a market sell order by providing the symbol and cost
11127         * @param {string} symbol unified symbol of the market to create an order in
11128         * @param {float} cost how much you want to trade in units of the quote currency
11129         * @param {object} [params] extra parameters specific to the exchange API endpoint
11130         * @returns {object} an [order structure]{@link https://docs.ccxt.com/?id=order-structure}
11131         */
11132        if (is_equal(&self.options.as_map().and_then(|__m| __m.get("createMarketSellOrderRequiresPrice")).cloned().unwrap_or(Value::Null), &Value::Bool(true))) || ((self.has.as_map().and_then(|__m| __m.get("createMarketSellOrderWithCost")).cloned().unwrap_or(Value::Null) != Value::Null) && (self.has.as_map().and_then(|__m| __m.get("createMarketSellOrderWithCost")).cloned().unwrap_or(Value::Null).as_bool() != Some(false))) {
11133            return self.create_order(symbol, Value::Str("market".into()), Value::Str("sell".into()), cost, &[Value::Int(1), params]).await;
11134        }
11135        panic!("{}", crate::exchange_errors::not_supported(format!("{}{}", self.id.clone(), Value::Str(" createMarketSellOrderWithCost() is not supported yet".into()))));
11136
11137    Value::Null
11138} }
11139
11140    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 {
11141        let mut price = get_arg(optional_args, 0, Value::Null);
11142        let mut triggerPrice = get_arg(optional_args, 1, Value::Null);
11143        let mut params = get_arg(optional_args, 2, Value::Map({
11144    let mut m = indexmap::IndexMap::new();
11145    m
11146}));
11147        /*
11148         * @method
11149         * @name createTriggerOrder
11150         * @description create a trigger stop order (type 1)
11151         * @param {string} symbol unified symbol of the market to create an order in
11152         * @param {string} type 'market' or 'limit'
11153         * @param {string} side 'buy' or 'sell'
11154         * @param {float} amount how much you want to trade in units of the base currency or the number of contracts
11155         * @param {float} [price] the price to fulfill the order, in units of the quote currency, ignored in market orders
11156         * @param {float} triggerPrice the price to trigger the stop order, in units of the quote currency
11157         * @param {object} [params] extra parameters specific to the exchange API endpoint
11158         * @returns {object} an [order structure]{@link https://docs.ccxt.com/?id=order-structure}
11159         */
11160        if (triggerPrice == Value::Null) {
11161            panic!("{}", crate::exchange_errors::arguments_required(format!("{}{}", self.id.clone(), Value::Str(" createTriggerOrder() requires a triggerPrice argument".into()))));
11162        }
11163        let mut paramsExtended: Value = self.extend(params, &[Value::Map({
11164            let mut m = indexmap::IndexMap::new();
11165                m.insert("triggerPrice".to_string(), triggerPrice);
11166            m
11167        })]);
11168        if (self.has.as_map().and_then(|__m| __m.get("createTriggerOrder")).cloned().unwrap_or(Value::Null) != Value::Null) && (self.has.as_map().and_then(|__m| __m.get("createTriggerOrder")).cloned().unwrap_or(Value::Null).as_bool() != Some(false)) {
11169            return self.create_order(symbol, type_var, side, amount, &[price, paramsExtended]).await;
11170        }
11171        panic!("{}", crate::exchange_errors::not_supported(format!("{}{}", self.id.clone(), Value::Str(" createTriggerOrder() is not supported yet".into()))));
11172
11173    Value::Null
11174} }
11175
11176    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 {
11177        let mut price = get_arg(optional_args, 0, Value::Null);
11178        let mut stopLossPrice = get_arg(optional_args, 1, Value::Null);
11179        let mut params = get_arg(optional_args, 2, Value::Map({
11180    let mut m = indexmap::IndexMap::new();
11181    m
11182}));
11183        /*
11184         * @method
11185         * @name createStopLossOrder
11186         * @description create a trigger stop loss order (type 2)
11187         * @param {string} symbol unified symbol of the market to create an order in
11188         * @param {string} type 'market' or 'limit'
11189         * @param {string} side 'buy' or 'sell'
11190         * @param {float} amount how much you want to trade in units of the base currency or the number of contracts
11191         * @param {float} [price] the price to fulfill the order, in units of the quote currency, ignored in market orders
11192         * @param {float} stopLossPrice the price to trigger the stop loss order, in units of the quote currency
11193         * @param {object} [params] extra parameters specific to the exchange API endpoint
11194         * @returns {object} an [order structure]{@link https://docs.ccxt.com/?id=order-structure}
11195         */
11196        if (stopLossPrice == Value::Null) {
11197            panic!("{}", crate::exchange_errors::arguments_required(format!("{}{}", self.id.clone(), Value::Str(" createStopLossOrder() requires a stopLossPrice argument".into()))));
11198        }
11199        let mut paramsExtended: Value = self.extend(params, &[Value::Map({
11200            let mut m = indexmap::IndexMap::new();
11201                m.insert("stopLossPrice".to_string(), stopLossPrice);
11202            m
11203        })]);
11204        if (self.has.as_map().and_then(|__m| __m.get("createStopLossOrder")).cloned().unwrap_or(Value::Null) != Value::Null) && (self.has.as_map().and_then(|__m| __m.get("createStopLossOrder")).cloned().unwrap_or(Value::Null).as_bool() != Some(false)) {
11205            return self.create_order(symbol, type_var, side, amount, &[price, paramsExtended]).await;
11206        }
11207        panic!("{}", crate::exchange_errors::not_supported(format!("{}{}", self.id.clone(), Value::Str(" createStopLossOrder() is not supported yet".into()))));
11208
11209    Value::Null
11210} }
11211
11212    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 {
11213        let mut price = get_arg(optional_args, 0, Value::Null);
11214        let mut takeProfitPrice = get_arg(optional_args, 1, Value::Null);
11215        let mut params = get_arg(optional_args, 2, Value::Map({
11216    let mut m = indexmap::IndexMap::new();
11217    m
11218}));
11219        /*
11220         * @method
11221         * @name createTakeProfitOrder
11222         * @description create a trigger take profit order (type 2)
11223         * @param {string} symbol unified symbol of the market to create an order in
11224         * @param {string} type 'market' or 'limit'
11225         * @param {string} side 'buy' or 'sell'
11226         * @param {float} amount how much you want to trade in units of the base currency or the number of contracts
11227         * @param {float} [price] the price to fulfill the order, in units of the quote currency, ignored in market orders
11228         * @param {float} takeProfitPrice the price to trigger the take profit order, in units of the quote currency
11229         * @param {object} [params] extra parameters specific to the exchange API endpoint
11230         * @returns {object} an [order structure]{@link https://docs.ccxt.com/?id=order-structure}
11231         */
11232        if (takeProfitPrice == Value::Null) {
11233            panic!("{}", crate::exchange_errors::arguments_required(format!("{}{}", self.id.clone(), Value::Str(" createTakeProfitOrder() requires a takeProfitPrice argument".into()))));
11234        }
11235        let mut paramsExtended: Value = self.extend(params, &[Value::Map({
11236            let mut m = indexmap::IndexMap::new();
11237                m.insert("takeProfitPrice".to_string(), takeProfitPrice);
11238            m
11239        })]);
11240        if (self.has.as_map().and_then(|__m| __m.get("createTakeProfitOrder")).cloned().unwrap_or(Value::Null) != Value::Null) && (self.has.as_map().and_then(|__m| __m.get("createTakeProfitOrder")).cloned().unwrap_or(Value::Null).as_bool() != Some(false)) {
11241            return self.create_order(symbol, type_var, side, amount, &[price, paramsExtended]).await;
11242        }
11243        panic!("{}", crate::exchange_errors::not_supported(format!("{}{}", self.id.clone(), Value::Str(" createTakeProfitOrder() is not supported yet".into()))));
11244
11245    Value::Null
11246} }
11247
11248    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 {
11249        let mut price = get_arg(optional_args, 0, Value::Null);
11250        let mut takeProfit = get_arg(optional_args, 1, Value::Null);
11251        let mut stopLoss = get_arg(optional_args, 2, Value::Null);
11252        let mut params = get_arg(optional_args, 3, Value::Map({
11253    let mut m = indexmap::IndexMap::new();
11254    m
11255}));
11256        /*
11257         * @method
11258         * @name createOrderWithTakeProfitAndStopLoss
11259         * @description create an order with a stop loss or take profit attached (type 3)
11260         * @param {string} symbol unified symbol of the market to create an order in
11261         * @param {string} type 'market' or 'limit'
11262         * @param {string} side 'buy' or 'sell'
11263         * @param {float} amount how much you want to trade in units of the base currency or the number of contracts
11264         * @param {float} [price] the price to fulfill the order, in units of the quote currency, ignored in market orders
11265         * @param {float} [takeProfit] the take profit price, in units of the quote currency
11266         * @param {float} [stopLoss] the stop loss price, in units of the quote currency
11267         * @param {object} [params] extra parameters specific to the exchange API endpoint
11268         * @param {string} [params.takeProfitType] *not available on all exchanges* 'limit' or 'market'
11269         * @param {string} [params.stopLossType] *not available on all exchanges* 'limit' or 'market'
11270         * @param {string} [params.takeProfitPriceType] *not available on all exchanges* 'last', 'mark' or 'index'
11271         * @param {string} [params.stopLossPriceType] *not available on all exchanges* 'last', 'mark' or 'index'
11272         * @param {float} [params.takeProfitLimitPrice] *not available on all exchanges* limit price for a limit take profit order
11273         * @param {float} [params.stopLossLimitPrice] *not available on all exchanges* stop loss for a limit stop loss order
11274         * @param {float} [params.takeProfitAmount] *not available on all exchanges* the amount for a take profit
11275         * @param {float} [params.stopLossAmount] *not available on all exchanges* the amount for a stop loss
11276         * @returns {object} an [order structure]{@link https://docs.ccxt.com/?id=order-structure}
11277         */
11278        let mut paramsValue: Value = 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()]);
11279        if (self.has.as_map().and_then(|__m| __m.get("createOrderWithTakeProfitAndStopLoss")).cloned().unwrap_or(Value::Null) != Value::Null) && (self.has.as_map().and_then(|__m| __m.get("createOrderWithTakeProfitAndStopLoss")).cloned().unwrap_or(Value::Null).as_bool() != Some(false)) {
11280            return self.create_order(symbol, type_var, side, amount, &[price, paramsValue]).await;
11281        }
11282        panic!("{}", crate::exchange_errors::not_supported(format!("{}{}", self.id.clone(), Value::Str(" createOrderWithTakeProfitAndStopLoss() is not supported yet".into()))));
11283
11284    Value::Null
11285} }
11286
11287    fn create_orders(&mut self, mut orders: Value, optional_args: &[Value]) -> impl ::std::future::Future<Output = Value> + Send { async move {
11288        // async-virtual: try the derived exchange first
11289        if let Some(__v) = self.dispatch_to_derived("create_orders", { let mut __args: Vec<crate::Value> = Vec::new(); __args.push(orders); __args.extend_from_slice(optional_args); __args }).await {
11290            if !matches!(__v, crate::Value::Null) { return __v; }
11291        }
11292
11293        let mut params = get_arg(optional_args, 0, Value::Map({
11294    let mut m = indexmap::IndexMap::new();
11295    m
11296}));
11297        panic!("{}", crate::exchange_errors::not_supported(format!("{}{}", self.id.clone(), Value::Str(" createOrders() is not supported yet".into()))));
11298
11299    Value::Null
11300} }
11301
11302    fn cancel_order(&mut self, mut id: Value, optional_args: &[Value]) -> impl ::std::future::Future<Output = Value> + Send { async move {
11303        // async-virtual: try the derived exchange first
11304        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 {
11305            if !matches!(__v, crate::Value::Null) { return __v; }
11306        }
11307
11308        let mut symbol = get_arg(optional_args, 0, Value::Null);
11309        let mut params = get_arg(optional_args, 1, Value::Map({
11310    let mut m = indexmap::IndexMap::new();
11311    m
11312}));
11313        panic!("{}", crate::exchange_errors::not_supported(format!("{}{}", self.id.clone(), Value::Str(" cancelOrder() is not supported yet".into()))));
11314
11315    Value::Null
11316} }
11317
11318/*
11319 * @method
11320 * @name cancelOrderWithClientOrderId
11321 * @description create a market order by providing the symbol, side and cost
11322 * @param {string} clientOrderId client order Id
11323 * @param {string} symbol unified symbol of the market to create an order in
11324 * @param {object} [params] extra parameters specific to the exchange API endpoint
11325 * @returns {object} an [order structure]{@link https://docs.ccxt.com/?id=order-structure}
11326 */
11327    fn cancel_order_with_client_order_id(&mut self, mut clientOrderId: Value, optional_args: &[Value]) -> impl ::std::future::Future<Output = Value> + Send { async move {
11328        let mut symbol = get_arg(optional_args, 0, Value::Null);
11329        let mut params = get_arg(optional_args, 1, Value::Map({
11330    let mut m = indexmap::IndexMap::new();
11331    m
11332}));
11333        let mut extendedParams: Value = self.extend(params, &[Value::Map({
11334            let mut m = indexmap::IndexMap::new();
11335                m.insert("clientOrderId".to_string(), clientOrderId);
11336            m
11337        })]);
11338        return self.cancel_order(Value::Str("".into()), &[symbol, extendedParams]).await;
11339
11340    Value::Null
11341} }
11342
11343    fn cancel_orders(&mut self, mut ids: Value, optional_args: &[Value]) -> impl ::std::future::Future<Output = Value> + Send { async move {
11344        // async-virtual: try the derived exchange first
11345        if let Some(__v) = self.dispatch_to_derived("cancel_orders", { let mut __args: Vec<crate::Value> = Vec::new(); __args.push(ids); __args.extend_from_slice(optional_args); __args }).await {
11346            if !matches!(__v, crate::Value::Null) { return __v; }
11347        }
11348
11349        let mut symbol = get_arg(optional_args, 0, Value::Null);
11350        let mut params = get_arg(optional_args, 1, Value::Map({
11351    let mut m = indexmap::IndexMap::new();
11352    m
11353}));
11354        panic!("{}", crate::exchange_errors::not_supported(format!("{}{}", self.id.clone(), Value::Str(" cancelOrders() is not supported yet".into()))));
11355
11356    Value::Null
11357} }
11358
11359/*
11360 * @method
11361 * @name cancelOrdersWithClientOrderIds
11362 * @description create a market order by providing the symbol, side and cost
11363 * @param {string[]} clientOrderIds client order Ids
11364 * @param {string} symbol unified symbol of the market to create an order in
11365 * @param {object} [params] extra parameters specific to the exchange API endpoint
11366 * @returns {object} an [order structure]{@link https://docs.ccxt.com/?id=order-structure}
11367 */
11368    fn cancel_orders_with_client_order_ids(&mut self, mut clientOrderIds: Value, optional_args: &[Value]) -> impl ::std::future::Future<Output = Value> + Send { async move {
11369        let mut symbol = get_arg(optional_args, 0, Value::Null);
11370        let mut params = get_arg(optional_args, 1, Value::Map({
11371    let mut m = indexmap::IndexMap::new();
11372    m
11373}));
11374        let mut extendedParams: Value = self.extend(params, &[Value::Map({
11375            let mut m = indexmap::IndexMap::new();
11376                m.insert("clientOrderIds".to_string(), clientOrderIds);
11377            m
11378        })]);
11379        return self.cancel_orders(Value::from(vec![]), &[symbol, extendedParams]).await;
11380
11381    Value::Null
11382} }
11383
11384    fn cancel_all_orders(&mut self, optional_args: &[Value]) -> impl ::std::future::Future<Output = Value> + Send { async move {
11385        // async-virtual: try the derived exchange first
11386        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 {
11387            if !matches!(__v, crate::Value::Null) { return __v; }
11388        }
11389
11390        let mut symbol = get_arg(optional_args, 0, Value::Null);
11391        let mut params = get_arg(optional_args, 1, Value::Map({
11392    let mut m = indexmap::IndexMap::new();
11393    m
11394}));
11395        panic!("{}", crate::exchange_errors::not_supported(format!("{}{}", self.id.clone(), Value::Str(" cancelAllOrders() is not supported yet".into()))));
11396
11397    Value::Null
11398} }
11399
11400    fn cancel_unified_order(&mut self, mut order: Value, optional_args: &[Value]) -> impl ::std::future::Future<Output = Value> + Send { async move {
11401        let mut params = get_arg(optional_args, 0, Value::Map({
11402    let mut m = indexmap::IndexMap::new();
11403    m
11404}));
11405        return self.cancel_order(self.safe_string_k(order.clone(), "id", &[]), &[self.safe_string_k(order, "symbol", &[]), params]).await;
11406
11407    Value::Null
11408} }
11409
11410    fn fetch_orders(&mut self, optional_args: &[Value]) -> impl ::std::future::Future<Output = Value> + Send { async move {
11411        // async-virtual: try the derived exchange first
11412        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 {
11413            if !matches!(__v, crate::Value::Null) { return __v; }
11414        }
11415
11416        let mut symbol = get_arg(optional_args, 0, Value::Null);
11417        let mut since = get_arg(optional_args, 1, Value::Null);
11418        let mut limit = get_arg(optional_args, 2, Value::Null);
11419        let mut params = get_arg(optional_args, 3, Value::Map({
11420    let mut m = indexmap::IndexMap::new();
11421    m
11422}));
11423        if ((self.has.as_map().and_then(|__m| __m.get("fetchOpenOrders")).cloned().unwrap_or(Value::Null) != Value::Null) && (self.has.as_map().and_then(|__m| __m.get("fetchOpenOrders")).cloned().unwrap_or(Value::Null).as_bool() != Some(false))) && ((self.has.as_map().and_then(|__m| __m.get("fetchClosedOrders")).cloned().unwrap_or(Value::Null) != Value::Null) && (self.has.as_map().and_then(|__m| __m.get("fetchClosedOrders")).cloned().unwrap_or(Value::Null).as_bool() != Some(false))) {
11424            panic!("{}", crate::exchange_errors::not_supported(format!("{}{}", self.id.clone(), Value::Str(" fetchOrders() is not supported yet, consider using fetchOpenOrders() and fetchClosedOrders() instead".into()))));
11425        }
11426        panic!("{}", crate::exchange_errors::not_supported(format!("{}{}", self.id.clone(), Value::Str(" fetchOrders() is not supported yet".into()))));
11427
11428    Value::Null
11429} }
11430
11431    fn fetch_order_trades(&mut self, mut id: Value, optional_args: &[Value]) -> impl ::std::future::Future<Output = Value> + Send { async move {
11432        let mut symbol = get_arg(optional_args, 0, Value::Null);
11433        let mut since = get_arg(optional_args, 1, Value::Null);
11434        let mut limit = get_arg(optional_args, 2, Value::Null);
11435        let mut params = get_arg(optional_args, 3, Value::Map({
11436    let mut m = indexmap::IndexMap::new();
11437    m
11438}));
11439        panic!("{}", crate::exchange_errors::not_supported(format!("{}{}", self.id.clone(), Value::Str(" fetchOrderTrades() is not supported yet".into()))));
11440
11441    Value::Null
11442} }
11443
11444    fn watch_orders(&mut self, optional_args: &[Value]) -> impl ::std::future::Future<Output = Value> + Send { async move {
11445        let mut symbol = get_arg(optional_args, 0, Value::Null);
11446        let mut since = get_arg(optional_args, 1, Value::Null);
11447        let mut limit = get_arg(optional_args, 2, Value::Null);
11448        let mut params = get_arg(optional_args, 3, Value::Map({
11449    let mut m = indexmap::IndexMap::new();
11450    m
11451}));
11452        panic!("{}", crate::exchange_errors::not_supported(format!("{}{}", self.id.clone(), Value::Str(" watchOrders() is not supported yet".into()))));
11453
11454    Value::Null
11455} }
11456
11457    fn fetch_open_orders(&mut self, optional_args: &[Value]) -> impl ::std::future::Future<Output = Value> + Send { async move {
11458        // async-virtual: try the derived exchange first
11459        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 {
11460            if !matches!(__v, crate::Value::Null) { return __v; }
11461        }
11462
11463        let mut symbol = get_arg(optional_args, 0, Value::Null);
11464        let mut since = get_arg(optional_args, 1, Value::Null);
11465        let mut limit = get_arg(optional_args, 2, Value::Null);
11466        let mut params = get_arg(optional_args, 3, Value::Map({
11467    let mut m = indexmap::IndexMap::new();
11468    m
11469}));
11470        if (self.has.as_map().and_then(|__m| __m.get("fetchOrders")).cloned().unwrap_or(Value::Null) != Value::Null) && (self.has.as_map().and_then(|__m| __m.get("fetchOrders")).cloned().unwrap_or(Value::Null).as_bool() != Some(false)) {
11471            let mut orders: Value = self.fetch_orders(&[symbol, since, limit, params]).await;
11472            return self.filter_by(orders, Value::Str("status".into()), Value::Str("open".into()), &[]);
11473        }
11474        panic!("{}", crate::exchange_errors::not_supported(format!("{}{}", self.id.clone(), Value::Str(" fetchOpenOrders() is not supported yet".into()))));
11475
11476    Value::Null
11477} }
11478
11479    fn fetch_closed_orders(&mut self, optional_args: &[Value]) -> impl ::std::future::Future<Output = Value> + Send { async move {
11480        // async-virtual: try the derived exchange first
11481        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 {
11482            if !matches!(__v, crate::Value::Null) { return __v; }
11483        }
11484
11485        let mut symbol = get_arg(optional_args, 0, Value::Null);
11486        let mut since = get_arg(optional_args, 1, Value::Null);
11487        let mut limit = get_arg(optional_args, 2, Value::Null);
11488        let mut params = get_arg(optional_args, 3, Value::Map({
11489    let mut m = indexmap::IndexMap::new();
11490    m
11491}));
11492        if (self.has.as_map().and_then(|__m| __m.get("fetchOrders")).cloned().unwrap_or(Value::Null) != Value::Null) && (self.has.as_map().and_then(|__m| __m.get("fetchOrders")).cloned().unwrap_or(Value::Null).as_bool() != Some(false)) {
11493            let mut orders: Value = self.fetch_orders(&[symbol, since, limit, params]).await;
11494            return self.filter_by(orders, Value::Str("status".into()), Value::Str("closed".into()), &[]);
11495        }
11496        panic!("{}", crate::exchange_errors::not_supported(format!("{}{}", self.id.clone(), Value::Str(" fetchClosedOrders() is not supported yet".into()))));
11497
11498    Value::Null
11499} }
11500
11501    fn fetch_canceled_orders(&mut self, optional_args: &[Value]) -> impl ::std::future::Future<Output = Value> + Send { async move {
11502        let mut symbol = get_arg(optional_args, 0, Value::Null);
11503        let mut since = get_arg(optional_args, 1, Value::Null);
11504        let mut limit = get_arg(optional_args, 2, Value::Null);
11505        let mut params = get_arg(optional_args, 3, Value::Map({
11506    let mut m = indexmap::IndexMap::new();
11507    m
11508}));
11509        panic!("{}", crate::exchange_errors::not_supported(format!("{}{}", self.id.clone(), Value::Str(" fetchCanceledOrders() is not supported yet".into()))));
11510
11511    Value::Null
11512} }
11513
11514    fn fetch_my_trades(&mut self, optional_args: &[Value]) -> impl ::std::future::Future<Output = Value> + Send { async move {
11515        // async-virtual: try the derived exchange first
11516        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 {
11517            if !matches!(__v, crate::Value::Null) { return __v; }
11518        }
11519
11520        let mut symbol = get_arg(optional_args, 0, Value::Null);
11521        let mut since = get_arg(optional_args, 1, Value::Null);
11522        let mut limit = get_arg(optional_args, 2, Value::Null);
11523        let mut params = get_arg(optional_args, 3, Value::Map({
11524    let mut m = indexmap::IndexMap::new();
11525    m
11526}));
11527        panic!("{}", crate::exchange_errors::not_supported(format!("{}{}", self.id.clone(), Value::Str(" fetchMyTrades() is not supported yet".into()))));
11528
11529    Value::Null
11530} }
11531
11532    fn watch_my_trades(&mut self, optional_args: &[Value]) -> impl ::std::future::Future<Output = Value> + Send { async move {
11533        let mut symbol = get_arg(optional_args, 0, Value::Null);
11534        let mut since = get_arg(optional_args, 1, Value::Null);
11535        let mut limit = get_arg(optional_args, 2, Value::Null);
11536        let mut params = get_arg(optional_args, 3, Value::Map({
11537    let mut m = indexmap::IndexMap::new();
11538    m
11539}));
11540        panic!("{}", crate::exchange_errors::not_supported(format!("{}{}", self.id.clone(), Value::Str(" watchMyTrades() is not supported yet".into()))));
11541
11542    Value::Null
11543} }
11544
11545    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 {
11546        let mut params = get_arg(optional_args, 0, Value::Map({
11547    let mut m = indexmap::IndexMap::new();
11548    m
11549}));
11550        return self.create_order(symbol, Value::Str("limit".into()), side, amount, &[price, params]).await;
11551
11552    Value::Null
11553} }
11554
11555    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 {
11556        let mut price = get_arg(optional_args, 0, Value::Null);
11557        let mut params = get_arg(optional_args, 1, Value::Map({
11558    let mut m = indexmap::IndexMap::new();
11559    m
11560}));
11561        return self.create_order(symbol, Value::Str("market".into()), side, amount, &[price, params]).await;
11562
11563    Value::Null
11564} }
11565
11566    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 {
11567        let mut params = get_arg(optional_args, 0, Value::Map({
11568    let mut m = indexmap::IndexMap::new();
11569    m
11570}));
11571        return self.create_order(symbol, Value::Str("limit".into()), Value::Str("buy".into()), amount, &[price, params]).await;
11572
11573    Value::Null
11574} }
11575
11576    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 {
11577        let mut params = get_arg(optional_args, 0, Value::Map({
11578    let mut m = indexmap::IndexMap::new();
11579    m
11580}));
11581        return self.create_order(symbol, Value::Str("limit".into()), Value::Str("sell".into()), amount, &[price, params]).await;
11582
11583    Value::Null
11584} }
11585
11586    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 {
11587        let mut params = get_arg(optional_args, 0, Value::Map({
11588    let mut m = indexmap::IndexMap::new();
11589    m
11590}));
11591        return self.create_order(symbol, Value::Str("market".into()), Value::Str("buy".into()), amount, &[Value::Null, params]).await;
11592
11593    Value::Null
11594} }
11595
11596    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 {
11597        let mut params = get_arg(optional_args, 0, Value::Map({
11598    let mut m = indexmap::IndexMap::new();
11599    m
11600}));
11601        return self.create_order(symbol, Value::Str("market".into()), Value::Str("sell".into()), amount, &[Value::Null, params]).await;
11602
11603    Value::Null
11604} }
11605
11606    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 {
11607        let mut price = get_arg(optional_args, 0, Value::Null);
11608        let mut params = get_arg(optional_args, 1, Value::Map({
11609    let mut m = indexmap::IndexMap::new();
11610    m
11611}));
11612        if (self.has.as_map().and_then(|__m| __m.get("createPostOnlyOrder")).cloned().unwrap_or(Value::Null) == Value::Null) || (self.has.as_map().and_then(|__m| __m.get("createPostOnlyOrder")).cloned().unwrap_or(Value::Null).as_bool() == Some(false)) {
11613            panic!("{}", crate::exchange_errors::not_supported(format!("{}{}", self.id.clone(), Value::Str(" createPostOnlyOrder() is not supported yet".into()))));
11614        }
11615        let mut query: Value = self.extend(params, &[Value::Map({
11616            let mut m = indexmap::IndexMap::new();
11617                m.insert("postOnly".to_string(), Value::Bool(true));
11618            m
11619        })]);
11620        return self.create_order(symbol, type_var, side, amount, &[price, query]).await;
11621
11622    Value::Null
11623} }
11624
11625    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 {
11626        let mut price = get_arg(optional_args, 0, Value::Null);
11627        let mut params = get_arg(optional_args, 1, Value::Map({
11628    let mut m = indexmap::IndexMap::new();
11629    m
11630}));
11631        if (self.has.as_map().and_then(|__m| __m.get("createReduceOnlyOrder")).cloned().unwrap_or(Value::Null) == Value::Null) || (self.has.as_map().and_then(|__m| __m.get("createReduceOnlyOrder")).cloned().unwrap_or(Value::Null).as_bool() == Some(false)) {
11632            panic!("{}", crate::exchange_errors::not_supported(format!("{}{}", self.id.clone(), Value::Str(" createReduceOnlyOrder() is not supported yet".into()))));
11633        }
11634        let mut query: Value = self.extend(params, &[Value::Map({
11635            let mut m = indexmap::IndexMap::new();
11636                m.insert("reduceOnly".to_string(), Value::Bool(true));
11637            m
11638        })]);
11639        return self.create_order(symbol, type_var, side, amount, &[price, query]).await;
11640
11641    Value::Null
11642} }
11643
11644    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 {
11645        let mut price = get_arg(optional_args, 0, Value::Null);
11646        let mut triggerPrice = get_arg(optional_args, 1, Value::Null);
11647        let mut params = get_arg(optional_args, 2, Value::Map({
11648    let mut m = indexmap::IndexMap::new();
11649    m
11650}));
11651        if (self.has.as_map().and_then(|__m| __m.get("createStopOrder")).cloned().unwrap_or(Value::Null) == Value::Null) || (self.has.as_map().and_then(|__m| __m.get("createStopOrder")).cloned().unwrap_or(Value::Null).as_bool() == Some(false)) {
11652            panic!("{}", crate::exchange_errors::not_supported(format!("{}{}", self.id.clone(), Value::Str(" createStopOrder() is not supported yet".into()))));
11653        }
11654        if (triggerPrice == Value::Null) {
11655            panic!("{}", crate::exchange_errors::arguments_required(format!("{}{}", self.id.clone(), Value::Str(" create_stop_order() requires a stopPrice argument".into()))));
11656        }
11657        let mut query: Value = self.extend(params, &[Value::Map({
11658            let mut m = indexmap::IndexMap::new();
11659                m.insert("stopPrice".to_string(), triggerPrice);
11660            m
11661        })]);
11662        return self.create_order(symbol, type_var, side, amount, &[price, query]).await;
11663
11664    Value::Null
11665} }
11666
11667    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 {
11668        let mut params = get_arg(optional_args, 0, Value::Map({
11669    let mut m = indexmap::IndexMap::new();
11670    m
11671}));
11672        if (self.has.as_map().and_then(|__m| __m.get("createStopLimitOrder")).cloned().unwrap_or(Value::Null) == Value::Null) || (self.has.as_map().and_then(|__m| __m.get("createStopLimitOrder")).cloned().unwrap_or(Value::Null).as_bool() == Some(false)) {
11673            panic!("{}", crate::exchange_errors::not_supported(format!("{}{}", self.id.clone(), Value::Str(" createStopLimitOrder() is not supported yet".into()))));
11674        }
11675        let mut query: Value = self.extend(params, &[Value::Map({
11676            let mut m = indexmap::IndexMap::new();
11677                m.insert("stopPrice".to_string(), triggerPrice);
11678            m
11679        })]);
11680        return self.create_order(symbol, Value::Str("limit".into()), side, amount, &[price, query]).await;
11681
11682    Value::Null
11683} }
11684
11685    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 {
11686        let mut params = get_arg(optional_args, 0, Value::Map({
11687    let mut m = indexmap::IndexMap::new();
11688    m
11689}));
11690        if (self.has.as_map().and_then(|__m| __m.get("createStopMarketOrder")).cloned().unwrap_or(Value::Null) == Value::Null) || (self.has.as_map().and_then(|__m| __m.get("createStopMarketOrder")).cloned().unwrap_or(Value::Null).as_bool() == Some(false)) {
11691            panic!("{}", crate::exchange_errors::not_supported(format!("{}{}", self.id.clone(), Value::Str(" createStopMarketOrder() is not supported yet".into()))));
11692        }
11693        let mut query: Value = self.extend(params, &[Value::Map({
11694            let mut m = indexmap::IndexMap::new();
11695                m.insert("stopPrice".to_string(), triggerPrice);
11696            m
11697        })]);
11698        return self.create_order(symbol, Value::Str("market".into()), side, amount, &[Value::Null, query]).await;
11699
11700    Value::Null
11701} }
11702
11703    fn fetch_trading_fee(&mut self, mut symbol: Value, optional_args: &[Value]) -> impl ::std::future::Future<Output = Value> + Send { async move {
11704        // async-virtual: try the derived exchange first
11705        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 {
11706            if !matches!(__v, crate::Value::Null) { return __v; }
11707        }
11708
11709        let mut params = get_arg(optional_args, 0, Value::Map({
11710    let mut m = indexmap::IndexMap::new();
11711    m
11712}));
11713        if (self.has.as_map().and_then(|__m| __m.get("fetchTradingFees")).cloned().unwrap_or(Value::Null) == Value::Null) || (self.has.as_map().and_then(|__m| __m.get("fetchTradingFees")).cloned().unwrap_or(Value::Null).as_bool() == Some(false)) {
11714            panic!("{}", crate::exchange_errors::not_supported(format!("{}{}", self.id.clone(), Value::Str(" fetchTradingFee() is not supported yet".into()))));
11715        }
11716        let mut fees: Value = self.fetch_trading_fees(&[params]).await;
11717        let mut fee: Value = self.safe_dict(fees, symbol, &[]);
11718        return fee;
11719
11720    Value::Null
11721} }
11722    /// Base-method fall-through for a core's `call_dynamic`.
11723    fn call_dynamic_base<'a>(&'a mut self, method: &'a str, args: Vec<crate::Value>)
11724        -> std::pin::Pin<Box<dyn std::future::Future<Output = crate::Value> + Send + 'a>>
11725    {
11726        Box::pin(async move {
11727            match method {
11728            "account" => self.account(),
11729            "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)),
11730            "add_margin" => self.add_margin(args.get(0).cloned().unwrap_or(crate::Value::Null), args.get(1).cloned().unwrap_or(crate::Value::Null), &args[2.min(args.len())..]).await,
11731            "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)),
11732            "arrays_concat" => self.arrays_concat(args.get(0).cloned().unwrap_or(crate::Value::Null)),
11733            "assign_default_deposit_withdraw_fees" => self.assign_default_deposit_withdraw_fees(args.get(0).cloned().unwrap_or(crate::Value::Null), &args[1.min(args.len())..]),
11734            "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[2.min(args.len())..]).await,
11735            "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[3.min(args.len())..]).await,
11736            "borrow_margin" => self.borrow_margin(args.get(0).cloned().unwrap_or(crate::Value::Null), args.get(1).cloned().unwrap_or(crate::Value::Null), &args[2.min(args.len())..]).await,
11737            "build_ohlcvc" => self.build_ohlcvc(args.get(0).cloned().unwrap_or(crate::Value::Null), &args[1.min(args.len())..]),
11738            "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[5.min(args.len())..]),
11739            "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[5.min(args.len())..]),
11740            "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[4.min(args.len())..]),
11741            "call_method" => self.call_method(args.get(0).cloned().unwrap_or(crate::Value::Null), &args[1.min(args.len())..]).await,
11742            "cancel_all_contract_orders" => self.cancel_all_contract_orders(&args[..]).await,
11743            "cancel_all_orders" => self.cancel_all_orders(&args[..]).await,
11744            "cancel_all_orders_after" => self.cancel_all_orders_after(args.get(0).cloned().unwrap_or(crate::Value::Null), &args[1.min(args.len())..]).await,
11745            "cancel_all_orders_ws" => self.cancel_all_orders_ws(&args[..]).await,
11746            "cancel_all_spot_orders" => self.cancel_all_spot_orders(&args[..]).await,
11747            "cancel_contract_order" => self.cancel_contract_order(args.get(0).cloned().unwrap_or(crate::Value::Null), &args[1.min(args.len())..]).await,
11748            "cancel_order" => self.cancel_order(args.get(0).cloned().unwrap_or(crate::Value::Null), &args[1.min(args.len())..]).await,
11749            "cancel_order_with_client_order_id" => self.cancel_order_with_client_order_id(args.get(0).cloned().unwrap_or(crate::Value::Null), &args[1.min(args.len())..]).await,
11750            "cancel_order_ws" => self.cancel_order_ws(args.get(0).cloned().unwrap_or(crate::Value::Null), &args[1.min(args.len())..]).await,
11751            "cancel_orders" => self.cancel_orders(args.get(0).cloned().unwrap_or(crate::Value::Null), &args[1.min(args.len())..]).await,
11752            "cancel_orders_for_symbols" => self.cancel_orders_for_symbols(args.get(0).cloned().unwrap_or(crate::Value::Null), &args[1.min(args.len())..]).await,
11753            "cancel_orders_with_client_order_ids" => self.cancel_orders_with_client_order_ids(args.get(0).cloned().unwrap_or(crate::Value::Null), &args[1.min(args.len())..]).await,
11754            "cancel_orders_ws" => self.cancel_orders_ws(args.get(0).cloned().unwrap_or(crate::Value::Null), &args[1.min(args.len())..]).await,
11755            "cancel_spot_order" => self.cancel_spot_order(args.get(0).cloned().unwrap_or(crate::Value::Null), &args[1.min(args.len())..]).await,
11756            "cancel_unified_order" => self.cancel_unified_order(args.get(0).cloned().unwrap_or(crate::Value::Null), &args[1.min(args.len())..]).await,
11757            "check_address" => self.check_address(&args[..]),
11758            "check_proxy_settings" => self.check_proxy_settings(&args[..]),
11759            "check_proxy_url_settings" => self.check_proxy_url_settings(&args[..]),
11760            "check_required_credentials" => self.check_required_credentials(&args[..]),
11761            "check_ws_proxy_settings" => self.check_ws_proxy_settings(),
11762            "close_all_positions" => self.close_all_positions(&args[..]).await,
11763            "close_position" => self.close_position(args.get(0).cloned().unwrap_or(crate::Value::Null), &args[1.min(args.len())..]).await,
11764            "common_currency_code" => self.common_currency_code(args.get(0).cloned().unwrap_or(crate::Value::Null)),
11765            "convert_expire_date" => self.convert_expire_date(args.get(0).cloned().unwrap_or(crate::Value::Null)),
11766            "convert_expire_date_to_market_id_date" => self.convert_expire_date_to_market_id_date(args.get(0).cloned().unwrap_or(crate::Value::Null)),
11767            "convert_market_id_expire_date" => self.convert_market_id_expire_date(args.get(0).cloned().unwrap_or(crate::Value::Null)),
11768            "convert_ohlcv_to_trading_view" => self.convert_ohlcv_to_trading_view(args.get(0).cloned().unwrap_or(crate::Value::Null), &args[1.min(args.len())..]),
11769            "convert_trading_view_to_ohlcv" => self.convert_trading_view_to_ohlcv(args.get(0).cloned().unwrap_or(crate::Value::Null), &args[1.min(args.len())..]),
11770            "convert_type_to_account" => self.convert_type_to_account(args.get(0).cloned().unwrap_or(crate::Value::Null)),
11771            "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)),
11772            "create_ccxt_trade_id" => self.create_ccxt_trade_id(&args[..]),
11773            "create_contract_orders" => self.create_contract_orders(args.get(0).cloned().unwrap_or(crate::Value::Null), &args[1.min(args.len())..]).await,
11774            "create_convert_trade" => self.create_convert_trade(args.get(0).cloned().unwrap_or(crate::Value::Null), args.get(1).cloned().unwrap_or(crate::Value::Null), args.get(2).cloned().unwrap_or(crate::Value::Null), &args[3.min(args.len())..]).await,
11775            "create_deposit_address" => self.create_deposit_address(args.get(0).cloned().unwrap_or(crate::Value::Null), &args[1.min(args.len())..]).await,
11776            "create_expired_option_market" => <Self as crate::exchange_generated::ExchangeBase>::create_expired_option_market(self, args.get(0).cloned().unwrap_or(crate::Value::Null)),
11777            "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[3.min(args.len())..]).await,
11778            "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[3.min(args.len())..]).await,
11779            "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[4.min(args.len())..]).await,
11780            "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[4.min(args.len())..]).await,
11781            "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[3.min(args.len())..]).await,
11782            "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[3.min(args.len())..]).await,
11783            "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[2.min(args.len())..]).await,
11784            "create_market_buy_order_with_cost" => self.create_market_buy_order_with_cost(args.get(0).cloned().unwrap_or(crate::Value::Null), args.get(1).cloned().unwrap_or(crate::Value::Null), &args[2.min(args.len())..]).await,
11785            "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[2.min(args.len())..]).await,
11786            "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[3.min(args.len())..]).await,
11787            "create_market_order_with_cost" => self.create_market_order_with_cost(args.get(0).cloned().unwrap_or(crate::Value::Null), args.get(1).cloned().unwrap_or(crate::Value::Null), args.get(2).cloned().unwrap_or(crate::Value::Null), &args[3.min(args.len())..]).await,
11788            "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[3.min(args.len())..]).await,
11789            "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[3.min(args.len())..]).await,
11790            "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[2.min(args.len())..]).await,
11791            "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[2.min(args.len())..]).await,
11792            "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[2.min(args.len())..]).await,
11793            "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)),
11794            "create_order" => self.create_order(args.get(0).cloned().unwrap_or(crate::Value::Null), args.get(1).cloned().unwrap_or(crate::Value::Null), args.get(2).cloned().unwrap_or(crate::Value::Null), args.get(3).cloned().unwrap_or(crate::Value::Null), &args[4.min(args.len())..]).await,
11795            "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[4.min(args.len())..]).await,
11796            "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[4.min(args.len())..]).await,
11797            "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[4.min(args.len())..]).await,
11798            "create_orders" => self.create_orders(args.get(0).cloned().unwrap_or(crate::Value::Null), &args[1.min(args.len())..]).await,
11799            "create_orders_ws" => self.create_orders_ws(args.get(0).cloned().unwrap_or(crate::Value::Null), &args[1.min(args.len())..]).await,
11800            "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[4.min(args.len())..]).await,
11801            "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[4.min(args.len())..]).await,
11802            "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[4.min(args.len())..]).await,
11803            "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[4.min(args.len())..]).await,
11804            "create_spot_orders" => self.create_spot_orders(args.get(0).cloned().unwrap_or(crate::Value::Null), &args[1.min(args.len())..]).await,
11805            "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[5.min(args.len())..]).await,
11806            "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[5.min(args.len())..]).await,
11807            "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[4.min(args.len())..]).await,
11808            "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[4.min(args.len())..]).await,
11809            "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[4.min(args.len())..]).await,
11810            "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[4.min(args.len())..]).await,
11811            "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[4.min(args.len())..]).await,
11812            "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[4.min(args.len())..]).await,
11813            "create_sub_account" => self.create_sub_account(args.get(0).cloned().unwrap_or(crate::Value::Null), &args[1.min(args.len())..]).await,
11814            "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[4.min(args.len())..]).await,
11815            "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[4.min(args.len())..]).await,
11816            "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[4.min(args.len())..]).await,
11817            "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[4.min(args.len())..]).await,
11818            "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[4.min(args.len())..]).await,
11819            "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[4.min(args.len())..]).await,
11820            "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[4.min(args.len())..]).await,
11821            "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[4.min(args.len())..]).await,
11822            "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[4.min(args.len())..]).await,
11823            "currency" => self.currency(args.get(0).cloned().unwrap_or(crate::Value::Null)),
11824            "currency_id" => self.currency_id(args.get(0).cloned().unwrap_or(crate::Value::Null)),
11825            "currency_ids" => self.currency_ids(&args[..]),
11826            "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[2.min(args.len())..]),
11827            "deposit_withdraw_fee" => self.deposit_withdraw_fee(args.get(0).cloned().unwrap_or(crate::Value::Null)),
11828            "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[3.min(args.len())..]).await,
11829            "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[4.min(args.len())..]).await,
11830            "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[3.min(args.len())..]).await,
11831            "edit_order" => self.edit_order(args.get(0).cloned().unwrap_or(crate::Value::Null), args.get(1).cloned().unwrap_or(crate::Value::Null), args.get(2).cloned().unwrap_or(crate::Value::Null), args.get(3).cloned().unwrap_or(crate::Value::Null), &args[4.min(args.len())..]).await,
11832            "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[4.min(args.len())..]).await,
11833            "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[4.min(args.len())..]).await,
11834            "edit_orders" => self.edit_orders(args.get(0).cloned().unwrap_or(crate::Value::Null), &args[1.min(args.len())..]).await,
11835            "feature_value" => self.feature_value(args.get(0).cloned().unwrap_or(crate::Value::Null), &args[1.min(args.len())..]),
11836            "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[2.min(args.len())..]),
11837            "features_mapper" => self.features_mapper(args.get(0).cloned().unwrap_or(crate::Value::Null), args.get(1).cloned().unwrap_or(crate::Value::Null), &args[2.min(args.len())..]),
11838            "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)),
11839            "fetch" => self.fetch(args.get(0).cloned().unwrap_or(crate::Value::Null), &args[1.min(args.len())..]).await,
11840            "fetch2" => self.fetch2(args.get(0).cloned().unwrap_or(crate::Value::Null), &args[1.min(args.len())..]).await,
11841            "fetch_accounts" => self.fetch_accounts(&args[..]).await,
11842            "fetch_adl_rank" => self.fetch_adl_rank(args.get(0).cloned().unwrap_or(crate::Value::Null), &args[1.min(args.len())..]).await,
11843            "fetch_all_greeks" => self.fetch_all_greeks(&args[..]).await,
11844            "fetch_balance" => self.fetch_balance(&args[..]).await,
11845            "fetch_balance_ws" => self.fetch_balance_ws(&args[..]).await,
11846            "fetch_bids_asks" => self.fetch_bids_asks(&args[..]).await,
11847            "fetch_borrow_interest" => self.fetch_borrow_interest(&args[..]).await,
11848            "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[2.min(args.len())..]).await,
11849            "fetch_canceled_and_closed_orders" => self.fetch_canceled_and_closed_orders(&args[..]).await,
11850            "fetch_canceled_orders" => self.fetch_canceled_orders(&args[..]).await,
11851            "fetch_closed_orders" => self.fetch_closed_orders(&args[..]).await,
11852            "fetch_closed_orders_ws" => self.fetch_closed_orders_ws(&args[..]).await,
11853            "fetch_contract_deposit_address" => self.fetch_contract_deposit_address(args.get(0).cloned().unwrap_or(crate::Value::Null), &args[1.min(args.len())..]).await,
11854            "fetch_contract_ohlcv" => self.fetch_contract_ohlcv(args.get(0).cloned().unwrap_or(crate::Value::Null), &args[1.min(args.len())..]).await,
11855            "fetch_contract_tickers" => self.fetch_contract_tickers(&args[..]).await,
11856            "fetch_convert_currencies" => self.fetch_convert_currencies(&args[..]).await,
11857            "fetch_convert_quote" => self.fetch_convert_quote(args.get(0).cloned().unwrap_or(crate::Value::Null), args.get(1).cloned().unwrap_or(crate::Value::Null), &args[2.min(args.len())..]).await,
11858            "fetch_convert_trade" => self.fetch_convert_trade(args.get(0).cloned().unwrap_or(crate::Value::Null), &args[1.min(args.len())..]).await,
11859            "fetch_convert_trade_history" => self.fetch_convert_trade_history(&args[..]).await,
11860            "fetch_cross_borrow_rate" => self.fetch_cross_borrow_rate(args.get(0).cloned().unwrap_or(crate::Value::Null), &args[1.min(args.len())..]).await,
11861            "fetch_cross_borrow_rates" => self.fetch_cross_borrow_rates(&args[..]).await,
11862            "fetch_deposit_address" => self.fetch_deposit_address(args.get(0).cloned().unwrap_or(crate::Value::Null), &args[1.min(args.len())..]).await,
11863            "fetch_deposit_addresses" => self.fetch_deposit_addresses(&args[..]).await,
11864            "fetch_deposit_addresses_by_network" => self.fetch_deposit_addresses_by_network(args.get(0).cloned().unwrap_or(crate::Value::Null), &args[1.min(args.len())..]).await,
11865            "fetch_deposit_withdraw_fee" => self.fetch_deposit_withdraw_fee(args.get(0).cloned().unwrap_or(crate::Value::Null), &args[1.min(args.len())..]).await,
11866            "fetch_deposit_withdraw_fees" => self.fetch_deposit_withdraw_fees(&args[..]).await,
11867            "fetch_deposits" => self.fetch_deposits(&args[..]).await,
11868            "fetch_deposits_withdrawals" => self.fetch_deposits_withdrawals(&args[..]).await,
11869            "fetch_deposits_ws" => self.fetch_deposits_ws(&args[..]).await,
11870            "fetch_free_balance" => self.fetch_free_balance(&args[..]).await,
11871            "fetch_funding_history" => self.fetch_funding_history(&args[..]).await,
11872            "fetch_funding_interval" => self.fetch_funding_interval(args.get(0).cloned().unwrap_or(crate::Value::Null), &args[1.min(args.len())..]).await,
11873            "fetch_funding_intervals" => self.fetch_funding_intervals(&args[..]).await,
11874            "fetch_funding_rate" => self.fetch_funding_rate(args.get(0).cloned().unwrap_or(crate::Value::Null), &args[1.min(args.len())..]).await,
11875            "fetch_funding_rate_history" => self.fetch_funding_rate_history(&args[..]).await,
11876            "fetch_funding_rates" => self.fetch_funding_rates(&args[..]).await,
11877            "fetch_greeks" => self.fetch_greeks(args.get(0).cloned().unwrap_or(crate::Value::Null), &args[1.min(args.len())..]).await,
11878            "fetch_index_ohlcv" => self.fetch_index_ohlcv(args.get(0).cloned().unwrap_or(crate::Value::Null), &args[1.min(args.len())..]).await,
11879            "fetch_isolated_borrow_rate" => self.fetch_isolated_borrow_rate(args.get(0).cloned().unwrap_or(crate::Value::Null), &args[1.min(args.len())..]).await,
11880            "fetch_isolated_borrow_rates" => self.fetch_isolated_borrow_rates(&args[..]).await,
11881            "fetch_l2_order_book" => self.fetch_l2_order_book(args.get(0).cloned().unwrap_or(crate::Value::Null), &args[1.min(args.len())..]).await,
11882            "fetch_l3_order_book" => self.fetch_l3_order_book(args.get(0).cloned().unwrap_or(crate::Value::Null), &args[1.min(args.len())..]).await,
11883            "fetch_last_prices" => self.fetch_last_prices(&args[..]).await,
11884            "fetch_ledger" => self.fetch_ledger(&args[..]).await,
11885            "fetch_ledger_entry" => self.fetch_ledger_entry(args.get(0).cloned().unwrap_or(crate::Value::Null), &args[1.min(args.len())..]).await,
11886            "fetch_leverage" => self.fetch_leverage(args.get(0).cloned().unwrap_or(crate::Value::Null), &args[1.min(args.len())..]).await,
11887            "fetch_leverage_tiers" => self.fetch_leverage_tiers(&args[..]).await,
11888            "fetch_leverages" => self.fetch_leverages(&args[..]).await,
11889            "fetch_liquidations" => self.fetch_liquidations(args.get(0).cloned().unwrap_or(crate::Value::Null), &args[1.min(args.len())..]).await,
11890            "fetch_long_short_ratio" => self.fetch_long_short_ratio(args.get(0).cloned().unwrap_or(crate::Value::Null), &args[1.min(args.len())..]).await,
11891            "fetch_long_short_ratio_history" => self.fetch_long_short_ratio_history(&args[..]).await,
11892            "fetch_margin_adjustment_history" => self.fetch_margin_adjustment_history(&args[..]).await,
11893            "fetch_margin_mode" => self.fetch_margin_mode(args.get(0).cloned().unwrap_or(crate::Value::Null), &args[1.min(args.len())..]).await,
11894            "fetch_margin_modes" => self.fetch_margin_modes(&args[..]).await,
11895            "fetch_mark_ohlcv" => self.fetch_mark_ohlcv(args.get(0).cloned().unwrap_or(crate::Value::Null), &args[1.min(args.len())..]).await,
11896            "fetch_mark_price" => self.fetch_mark_price(args.get(0).cloned().unwrap_or(crate::Value::Null), &args[1.min(args.len())..]).await,
11897            "fetch_mark_prices" => self.fetch_mark_prices(&args[..]).await,
11898            "fetch_market_leverage_tiers" => self.fetch_market_leverage_tiers(args.get(0).cloned().unwrap_or(crate::Value::Null), &args[1.min(args.len())..]).await,
11899            "fetch_my_liquidations" => self.fetch_my_liquidations(&args[..]).await,
11900            "fetch_my_trades" => self.fetch_my_trades(&args[..]).await,
11901            "fetch_my_trades_ws" => self.fetch_my_trades_ws(&args[..]).await,
11902            "fetch_ohlcv" => self.fetch_ohlcv(args.get(0).cloned().unwrap_or(crate::Value::Null), &args[1.min(args.len())..]).await,
11903            "fetch_ohlcv_ws" => self.fetch_ohlcv_ws(args.get(0).cloned().unwrap_or(crate::Value::Null), &args[1.min(args.len())..]).await,
11904            "fetch_open_interest" => self.fetch_open_interest(args.get(0).cloned().unwrap_or(crate::Value::Null), &args[1.min(args.len())..]).await,
11905            "fetch_open_interest_history" => self.fetch_open_interest_history(args.get(0).cloned().unwrap_or(crate::Value::Null), &args[1.min(args.len())..]).await,
11906            "fetch_open_interests" => self.fetch_open_interests(&args[..]).await,
11907            "fetch_open_orders" => self.fetch_open_orders(&args[..]).await,
11908            "fetch_open_orders_ws" => self.fetch_open_orders_ws(&args[..]).await,
11909            "fetch_option" => self.fetch_option(args.get(0).cloned().unwrap_or(crate::Value::Null), &args[1.min(args.len())..]).await,
11910            "fetch_option_chain" => self.fetch_option_chain(args.get(0).cloned().unwrap_or(crate::Value::Null), &args[1.min(args.len())..]).await,
11911            "fetch_order" => self.fetch_order(args.get(0).cloned().unwrap_or(crate::Value::Null), &args[1.min(args.len())..]).await,
11912            "fetch_order_book" => self.fetch_order_book(args.get(0).cloned().unwrap_or(crate::Value::Null), &args[1.min(args.len())..]).await,
11913            "fetch_order_book_ws" => self.fetch_order_book_ws(args.get(0).cloned().unwrap_or(crate::Value::Null), &args[1.min(args.len())..]).await,
11914            "fetch_order_books" => self.fetch_order_books(&args[..]).await,
11915            "fetch_order_status" => self.fetch_order_status(args.get(0).cloned().unwrap_or(crate::Value::Null), &args[1.min(args.len())..]).await,
11916            "fetch_order_trades" => self.fetch_order_trades(args.get(0).cloned().unwrap_or(crate::Value::Null), &args[1.min(args.len())..]).await,
11917            "fetch_order_with_client_order_id" => self.fetch_order_with_client_order_id(args.get(0).cloned().unwrap_or(crate::Value::Null), &args[1.min(args.len())..]).await,
11918            "fetch_order_ws" => self.fetch_order_ws(args.get(0).cloned().unwrap_or(crate::Value::Null), &args[1.min(args.len())..]).await,
11919            "fetch_orders" => self.fetch_orders(&args[..]).await,
11920            "fetch_orders_by_status_ws" => self.fetch_orders_by_status_ws(args.get(0).cloned().unwrap_or(crate::Value::Null), &args[1.min(args.len())..]).await,
11921            "fetch_orders_ws" => self.fetch_orders_ws(&args[..]).await,
11922            "fetch_paginated_call_cursor" => self.fetch_paginated_call_cursor(args.get(0).cloned().unwrap_or(crate::Value::Null), &args[1.min(args.len())..]).await,
11923            "fetch_paginated_call_deterministic" => self.fetch_paginated_call_deterministic(args.get(0).cloned().unwrap_or(crate::Value::Null), &args[1.min(args.len())..]).await,
11924            "fetch_paginated_call_dynamic" => self.fetch_paginated_call_dynamic(args.get(0).cloned().unwrap_or(crate::Value::Null), &args[1.min(args.len())..]).await,
11925            "fetch_paginated_call_incremental" => self.fetch_paginated_call_incremental(args.get(0).cloned().unwrap_or(crate::Value::Null), &args[1.min(args.len())..]).await,
11926            "fetch_partial_balance" => self.fetch_partial_balance(args.get(0).cloned().unwrap_or(crate::Value::Null), &args[1.min(args.len())..]).await,
11927            "fetch_payment_methods" => self.fetch_payment_methods(&args[..]).await,
11928            "fetch_position" => self.fetch_position(args.get(0).cloned().unwrap_or(crate::Value::Null), &args[1.min(args.len())..]).await,
11929            "fetch_position_adl_rank" => self.fetch_position_adl_rank(args.get(0).cloned().unwrap_or(crate::Value::Null), &args[1.min(args.len())..]).await,
11930            "fetch_position_history" => self.fetch_position_history(args.get(0).cloned().unwrap_or(crate::Value::Null), &args[1.min(args.len())..]).await,
11931            "fetch_position_mode" => self.fetch_position_mode(&args[..]).await,
11932            "fetch_position_ws" => self.fetch_position_ws(args.get(0).cloned().unwrap_or(crate::Value::Null), &args[1.min(args.len())..]).await,
11933            "fetch_positions" => self.fetch_positions(&args[..]).await,
11934            "fetch_positions_adl_rank" => self.fetch_positions_adl_rank(&args[..]).await,
11935            "fetch_positions_for_symbol" => self.fetch_positions_for_symbol(args.get(0).cloned().unwrap_or(crate::Value::Null), &args[1.min(args.len())..]).await,
11936            "fetch_positions_for_symbol_ws" => self.fetch_positions_for_symbol_ws(args.get(0).cloned().unwrap_or(crate::Value::Null), &args[1.min(args.len())..]).await,
11937            "fetch_positions_history" => self.fetch_positions_history(&args[..]).await,
11938            "fetch_positions_risk" => self.fetch_positions_risk(&args[..]).await,
11939            "fetch_positions_ws" => self.fetch_positions_ws(&args[..]).await,
11940            "fetch_premium_index_ohlcv" => self.fetch_premium_index_ohlcv(args.get(0).cloned().unwrap_or(crate::Value::Null), &args[1.min(args.len())..]).await,
11941            "fetch_rest_order_book_safe" => self.fetch_rest_order_book_safe(args.get(0).cloned().unwrap_or(crate::Value::Null), &args[1.min(args.len())..]).await,
11942            "fetch_spot_ohlcv" => self.fetch_spot_ohlcv(args.get(0).cloned().unwrap_or(crate::Value::Null), &args[1.min(args.len())..]).await,
11943            "fetch_spot_tickers" => self.fetch_spot_tickers(&args[..]).await,
11944            "fetch_status" => self.fetch_status(&args[..]).await,
11945            "fetch_ticker" => self.fetch_ticker(args.get(0).cloned().unwrap_or(crate::Value::Null), &args[1.min(args.len())..]).await,
11946            "fetch_ticker_ws" => self.fetch_ticker_ws(args.get(0).cloned().unwrap_or(crate::Value::Null), &args[1.min(args.len())..]).await,
11947            "fetch_tickers" => self.fetch_tickers(&args[..]).await,
11948            "fetch_tickers_ws" => self.fetch_tickers_ws(&args[..]).await,
11949            "fetch_time" => self.fetch_time(&args[..]).await,
11950            "fetch_total_balance" => self.fetch_total_balance(&args[..]).await,
11951            "fetch_trades" => self.fetch_trades(args.get(0).cloned().unwrap_or(crate::Value::Null), &args[1.min(args.len())..]).await,
11952            "fetch_trades_ws" => self.fetch_trades_ws(args.get(0).cloned().unwrap_or(crate::Value::Null), &args[1.min(args.len())..]).await,
11953            "fetch_trading_fee" => self.fetch_trading_fee(args.get(0).cloned().unwrap_or(crate::Value::Null), &args[1.min(args.len())..]).await,
11954            "fetch_trading_fees" => self.fetch_trading_fees(&args[..]).await,
11955            "fetch_trading_fees_ws" => self.fetch_trading_fees_ws(&args[..]).await,
11956            "fetch_trading_limits" => self.fetch_trading_limits(&args[..]).await,
11957            "fetch_transaction_fee" => self.fetch_transaction_fee(args.get(0).cloned().unwrap_or(crate::Value::Null), &args[1.min(args.len())..]).await,
11958            "fetch_transaction_fees" => self.fetch_transaction_fees(&args[..]).await,
11959            "fetch_transactions" => self.fetch_transactions(&args[..]).await,
11960            "fetch_transfer" => self.fetch_transfer(args.get(0).cloned().unwrap_or(crate::Value::Null), &args[1.min(args.len())..]).await,
11961            "fetch_transfers" => self.fetch_transfers(&args[..]).await,
11962            "fetch_unified_order" => self.fetch_unified_order(args.get(0).cloned().unwrap_or(crate::Value::Null), &args[1.min(args.len())..]).await,
11963            "fetch_used_balance" => self.fetch_used_balance(&args[..]).await,
11964            "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[3.min(args.len())..]).await,
11965            "fetch_withdrawals" => self.fetch_withdrawals(&args[..]).await,
11966            "fetch_withdrawals_ws" => self.fetch_withdrawals_ws(&args[..]).await,
11967            "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[2.min(args.len())..]),
11968            "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[2.min(args.len())..]),
11969            "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[2.min(args.len())..]),
11970            "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[2.min(args.len())..]),
11971            "filter_by_currency_since_limit" => self.filter_by_currency_since_limit(args.get(0).cloned().unwrap_or(crate::Value::Null), &args[1.min(args.len())..]),
11972            "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[2.min(args.len())..]),
11973            "filter_by_limit" => self.filter_by_limit(args.get(0).cloned().unwrap_or(crate::Value::Null), &args[1.min(args.len())..]),
11974            "filter_by_since_limit" => self.filter_by_since_limit(args.get(0).cloned().unwrap_or(crate::Value::Null), &args[1.min(args.len())..]),
11975            "filter_by_symbol" => self.filter_by_symbol(args.get(0).cloned().unwrap_or(crate::Value::Null), &args[1.min(args.len())..]),
11976            "filter_by_symbol_since_limit" => self.filter_by_symbol_since_limit(args.get(0).cloned().unwrap_or(crate::Value::Null), &args[1.min(args.len())..]),
11977            "filter_by_symbols_since_limit" => self.filter_by_symbols_since_limit(args.get(0).cloned().unwrap_or(crate::Value::Null), &args[1.min(args.len())..]),
11978            "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[2.min(args.len())..]),
11979            "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[2.min(args.len())..]),
11980            "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)),
11981            "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)),
11982            "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)),
11983            "find_timeframe" => self.find_timeframe(args.get(0).cloned().unwrap_or(crate::Value::Null), &args[1.min(args.len())..]),
11984            "force_string" => self.force_string(args.get(0).cloned().unwrap_or(crate::Value::Null)),
11985            "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)),
11986            "get_default_options" => self.get_default_options(),
11987            "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)),
11988            "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)),
11989            "get_market_from_symbols" => self.get_market_from_symbols(&args[..]),
11990            "get_supported_mapping" => self.get_supported_mapping(args.get(0).cloned().unwrap_or(crate::Value::Null), &args[1.min(args.len())..]),
11991            "get_symbols_for_market_type" => self.get_symbols_for_market_type(&args[..]),
11992            "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)),
11993            "handle_margin_mode_and_params" => self.handle_margin_mode_and_params(args.get(0).cloned().unwrap_or(crate::Value::Null), &args[1.min(args.len())..]),
11994            "handle_market_type_and_params" => self.handle_market_type_and_params(args.get(0).cloned().unwrap_or(crate::Value::Null), &args[1.min(args.len())..]),
11995            "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[1.min(args.len())..]),
11996            "handle_network_code_and_params" => self.handle_network_code_and_params(args.get(0).cloned().unwrap_or(crate::Value::Null)),
11997            "handle_option" => self.handle_option(args.get(0).cloned().unwrap_or(crate::Value::Null), args.get(1).cloned().unwrap_or(crate::Value::Null), &args[2.min(args.len())..]),
11998            "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[3.min(args.len())..]),
11999            "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[4.min(args.len())..]),
12000            "handle_option_bool_and_params" => self.handle_option_bool_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[3.min(args.len())..]),
12001            "handle_option_bool_and_params2" => self.handle_option_bool_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[4.min(args.len())..]),
12002            "handle_option_integer_and_params" => self.handle_option_integer_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[3.min(args.len())..]),
12003            "handle_option_integer_and_params2" => self.handle_option_integer_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[4.min(args.len())..]),
12004            "handle_option_string_and_params" => self.handle_option_string_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[3.min(args.len())..]),
12005            "handle_option_string_and_params2" => self.handle_option_string_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[4.min(args.len())..]),
12006            "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[2.min(args.len())..]),
12007            "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[3.min(args.len())..]),
12008            "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[2.min(args.len())..]),
12009            "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[3.min(args.len())..]),
12010            "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[2.min(args.len())..]),
12011            "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[3.min(args.len())..]),
12012            "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[2.min(args.len())..]),
12013            "handle_sub_type_and_params" => self.handle_sub_type_and_params(args.get(0).cloned().unwrap_or(crate::Value::Null), &args[1.min(args.len())..]),
12014            "handle_time_in_force" => self.handle_time_in_force(&args[..]),
12015            "handle_trigger_and_params" => self.handle_trigger_and_params(args.get(0).cloned().unwrap_or(crate::Value::Null)),
12016            "handle_trigger_direction_and_params" => self.handle_trigger_direction_and_params(args.get(0).cloned().unwrap_or(crate::Value::Null), &args[1.min(args.len())..]),
12017            "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[2.min(args.len())..]),
12018            "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[3.min(args.len())..]),
12019            "implode_hostname" => self.implode_hostname(args.get(0).cloned().unwrap_or(crate::Value::Null)),
12020            "incrementing_nonce" => self.incrementing_nonce(),
12021            "integer_precision_to_amount" => self.integer_precision_to_amount(args.get(0).cloned().unwrap_or(crate::Value::Null)),
12022            "invert_flat_string_dictionary" => self.invert_flat_string_dictionary(args.get(0).cloned().unwrap_or(crate::Value::Null)),
12023            "is_empty_string" => self.is_empty_string(args.get(0).cloned().unwrap_or(crate::Value::Null)),
12024            "is_leveraged_currency" => self.is_leveraged_currency(args.get(0).cloned().unwrap_or(crate::Value::Null), &args[1.min(args.len())..]),
12025            "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[2.min(args.len())..]),
12026            "is_round_number" => self.is_round_number(args.get(0).cloned().unwrap_or(crate::Value::Null)),
12027            "is_significant_precision" => self.is_significant_precision(),
12028            "is_tick_precision" => self.is_tick_precision(),
12029            "is_trigger_order" => self.is_trigger_order(args.get(0).cloned().unwrap_or(crate::Value::Null)),
12030            "is_uta_enabled" => self.is_uta_enabled(&args[..]).await,
12031            "load_accounts" => self.load_accounts(&args[..]).await,
12032            "load_markets" => self.load_markets(&args[..]).await,
12033            "load_markets_and_sign_in" => self.load_markets_and_sign_in().await,
12034            "load_time_difference" => self.load_time_difference(&args[..]).await,
12035            "load_trading_limits" => self.load_trading_limits(&args[..]).await,
12036            "market" => <Self as crate::exchange_generated::ExchangeBase>::market(self, args.get(0).cloned().unwrap_or(crate::Value::Null)),
12037            "market_codes" => self.market_codes(&args[..]),
12038            "market_id" => self.market_id(args.get(0).cloned().unwrap_or(crate::Value::Null)),
12039            "market_ids" => self.market_ids(&args[..]),
12040            "market_non_virtual" => self.market_non_virtual(args.get(0).cloned().unwrap_or(crate::Value::Null)),
12041            "market_or_null" => self.market_or_null(&args[..]),
12042            "market_symbols" => self.market_symbols(&args[..]),
12043            "markets_for_symbols" => self.markets_for_symbols(&args[..]),
12044            "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)),
12045            "network_code_to_id" => self.network_code_to_id(args.get(0).cloned().unwrap_or(crate::Value::Null), &args[1.min(args.len())..]),
12046            "network_id_to_code" => self.network_id_to_code(&args[..]),
12047            "nonce" => <Self as crate::exchange_generated::ExchangeBase>::nonce(self),
12048            "oath" => self.oath(),
12049            "orderbook_checksum_message" => self.orderbook_checksum_message(args.get(0).cloned().unwrap_or(crate::Value::Null)),
12050            "parse_account" => <Self as crate::exchange_generated::ExchangeBase>::parse_account(self, args.get(0).cloned().unwrap_or(crate::Value::Null)),
12051            "parse_accounts" => self.parse_accounts(args.get(0).cloned().unwrap_or(crate::Value::Null), &args[1.min(args.len())..]),
12052            "parse_adl_rank" => <Self as crate::exchange_generated::ExchangeBase>::parse_adl_rank(self, args.get(0).cloned().unwrap_or(crate::Value::Null), &args[1.min(args.len())..]),
12053            "parse_adl_ranks" => self.parse_adl_ranks(args.get(0).cloned().unwrap_or(crate::Value::Null), &args[1.min(args.len())..]),
12054            "parse_all_greeks" => self.parse_all_greeks(args.get(0).cloned().unwrap_or(crate::Value::Null), &args[1.min(args.len())..]),
12055            "parse_balance" => <Self as crate::exchange_generated::ExchangeBase>::parse_balance(self, args.get(0).cloned().unwrap_or(crate::Value::Null)),
12056            "parse_borrow_interest" => <Self as crate::exchange_generated::ExchangeBase>::parse_borrow_interest(self, args.get(0).cloned().unwrap_or(crate::Value::Null), &args[1.min(args.len())..]),
12057            "parse_borrow_interests" => self.parse_borrow_interests(args.get(0).cloned().unwrap_or(crate::Value::Null), &args[1.min(args.len())..]),
12058            "parse_borrow_rate" => <Self as crate::exchange_generated::ExchangeBase>::parse_borrow_rate(self, args.get(0).cloned().unwrap_or(crate::Value::Null), &args[1.min(args.len())..]),
12059            "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)),
12060            "parse_conversion" => <Self as crate::exchange_generated::ExchangeBase>::parse_conversion(self, args.get(0).cloned().unwrap_or(crate::Value::Null), &args[1.min(args.len())..]),
12061            "parse_conversions" => self.parse_conversions(args.get(0).cloned().unwrap_or(crate::Value::Null), &args[1.min(args.len())..]),
12062            "parse_currencies" => self.parse_currencies(args.get(0).cloned().unwrap_or(crate::Value::Null)),
12063            "parse_currency" => <Self as crate::exchange_generated::ExchangeBase>::parse_currency(self, args.get(0).cloned().unwrap_or(crate::Value::Null)),
12064            "parse_deposit_address" => <Self as crate::exchange_generated::ExchangeBase>::parse_deposit_address(self, args.get(0).cloned().unwrap_or(crate::Value::Null), &args[1.min(args.len())..]),
12065            "parse_deposit_addresses" => self.parse_deposit_addresses(args.get(0).cloned().unwrap_or(crate::Value::Null), &args[1.min(args.len())..]),
12066            "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[1.min(args.len())..]),
12067            "parse_deposit_withdraw_fees" => self.parse_deposit_withdraw_fees(args.get(0).cloned().unwrap_or(crate::Value::Null), &args[1.min(args.len())..]),
12068            "parse_fee_numeric" => self.parse_fee_numeric(args.get(0).cloned().unwrap_or(crate::Value::Null)),
12069            "parse_funding_rate" => <Self as crate::exchange_generated::ExchangeBase>::parse_funding_rate(self, args.get(0).cloned().unwrap_or(crate::Value::Null), &args[1.min(args.len())..]),
12070            "parse_funding_rate_histories" => self.parse_funding_rate_histories(args.get(0).cloned().unwrap_or(crate::Value::Null), &args[1.min(args.len())..]),
12071            "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[1.min(args.len())..]),
12072            "parse_funding_rates" => self.parse_funding_rates(args.get(0).cloned().unwrap_or(crate::Value::Null), &args[1.min(args.len())..]),
12073            "parse_greeks" => <Self as crate::exchange_generated::ExchangeBase>::parse_greeks(self, args.get(0).cloned().unwrap_or(crate::Value::Null), &args[1.min(args.len())..]),
12074            "parse_income" => <Self as crate::exchange_generated::ExchangeBase>::parse_income(self, args.get(0).cloned().unwrap_or(crate::Value::Null), &args[1.min(args.len())..]),
12075            "parse_incomes" => self.parse_incomes(args.get(0).cloned().unwrap_or(crate::Value::Null), &args[1.min(args.len())..]),
12076            "parse_isolated_borrow_rate" => self.parse_isolated_borrow_rate(args.get(0).cloned().unwrap_or(crate::Value::Null), &args[1.min(args.len())..]),
12077            "parse_isolated_borrow_rates" => self.parse_isolated_borrow_rates(args.get(0).cloned().unwrap_or(crate::Value::Null)),
12078            "parse_last_price" => <Self as crate::exchange_generated::ExchangeBase>::parse_last_price(self, args.get(0).cloned().unwrap_or(crate::Value::Null), &args[1.min(args.len())..]),
12079            "parse_last_prices" => self.parse_last_prices(args.get(0).cloned().unwrap_or(crate::Value::Null), &args[1.min(args.len())..]),
12080            "parse_ledger" => self.parse_ledger(args.get(0).cloned().unwrap_or(crate::Value::Null), &args[1.min(args.len())..]),
12081            "parse_ledger_entry" => <Self as crate::exchange_generated::ExchangeBase>::parse_ledger_entry(self, args.get(0).cloned().unwrap_or(crate::Value::Null), &args[1.min(args.len())..]),
12082            "parse_leverage" => <Self as crate::exchange_generated::ExchangeBase>::parse_leverage(self, args.get(0).cloned().unwrap_or(crate::Value::Null), &args[1.min(args.len())..]),
12083            "parse_leverage_tiers" => self.parse_leverage_tiers(args.get(0).cloned().unwrap_or(crate::Value::Null), &args[1.min(args.len())..]),
12084            "parse_leverages" => self.parse_leverages(args.get(0).cloned().unwrap_or(crate::Value::Null), &args[1.min(args.len())..]),
12085            "parse_liquidation" => <Self as crate::exchange_generated::ExchangeBase>::parse_liquidation(self, args.get(0).cloned().unwrap_or(crate::Value::Null), &args[1.min(args.len())..]),
12086            "parse_liquidations" => self.parse_liquidations(args.get(0).cloned().unwrap_or(crate::Value::Null), &args[1.min(args.len())..]),
12087            "parse_long_short_ratio" => self.parse_long_short_ratio(args.get(0).cloned().unwrap_or(crate::Value::Null), &args[1.min(args.len())..]),
12088            "parse_long_short_ratio_history" => self.parse_long_short_ratio_history(args.get(0).cloned().unwrap_or(crate::Value::Null), &args[1.min(args.len())..]),
12089            "parse_margin_mode" => <Self as crate::exchange_generated::ExchangeBase>::parse_margin_mode(self, args.get(0).cloned().unwrap_or(crate::Value::Null), &args[1.min(args.len())..]),
12090            "parse_margin_modes" => self.parse_margin_modes(args.get(0).cloned().unwrap_or(crate::Value::Null), &args[1.min(args.len())..]),
12091            "parse_margin_modification" => <Self as crate::exchange_generated::ExchangeBase>::parse_margin_modification(self, args.get(0).cloned().unwrap_or(crate::Value::Null), &args[1.min(args.len())..]),
12092            "parse_margin_modifications" => self.parse_margin_modifications(args.get(0).cloned().unwrap_or(crate::Value::Null), &args[1.min(args.len())..]),
12093            "parse_market" => <Self as crate::exchange_generated::ExchangeBase>::parse_market(self, args.get(0).cloned().unwrap_or(crate::Value::Null)),
12094            "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[1.min(args.len())..]),
12095            "parse_markets" => self.parse_markets(args.get(0).cloned().unwrap_or(crate::Value::Null)),
12096            "parse_ohlc_vs" => self.parse_ohlc_vs(args.get(0).cloned().unwrap_or(crate::Value::Null), &args[1.min(args.len())..]),
12097            "parse_ohlcv" => <Self as crate::exchange_generated::ExchangeBase>::parse_ohlcv(self, args.get(0).cloned().unwrap_or(crate::Value::Null), &args[1.min(args.len())..]),
12098            "parse_open_interest" => <Self as crate::exchange_generated::ExchangeBase>::parse_open_interest(self, args.get(0).cloned().unwrap_or(crate::Value::Null), &args[1.min(args.len())..]),
12099            "parse_open_interests" => self.parse_open_interests(args.get(0).cloned().unwrap_or(crate::Value::Null), &args[1.min(args.len())..]),
12100            "parse_open_interests_history" => self.parse_open_interests_history(args.get(0).cloned().unwrap_or(crate::Value::Null), &args[1.min(args.len())..]),
12101            "parse_option" => self.parse_option(args.get(0).cloned().unwrap_or(crate::Value::Null), &args[1.min(args.len())..]),
12102            "parse_option_chain" => self.parse_option_chain(args.get(0).cloned().unwrap_or(crate::Value::Null), &args[1.min(args.len())..]),
12103            "parse_order" => <Self as crate::exchange_generated::ExchangeBase>::parse_order(self, args.get(0).cloned().unwrap_or(crate::Value::Null), &args[1.min(args.len())..]),
12104            "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[2.min(args.len())..]),
12105            "parse_order_book_bid_ask" => self.parse_order_book_bid_ask(args.get(0).cloned().unwrap_or(crate::Value::Null), &args[1.min(args.len())..]),
12106            "parse_order_book_bid_ask_l3" => self.parse_order_book_bid_ask_l3(args.get(0).cloned().unwrap_or(crate::Value::Null), &args[1.min(args.len())..]),
12107            "parse_order_book_bids_asks" => self.parse_order_book_bids_asks(args.get(0).cloned().unwrap_or(crate::Value::Null), &args[1.min(args.len())..]),
12108            "parse_order_book_bids_asks_l3" => self.parse_order_book_bids_asks_l3(args.get(0).cloned().unwrap_or(crate::Value::Null), &args[1.min(args.len())..]),
12109            "parse_order_book_l3" => self.parse_order_book_l3(args.get(0).cloned().unwrap_or(crate::Value::Null), args.get(1).cloned().unwrap_or(crate::Value::Null), &args[2.min(args.len())..]),
12110            "parse_orders" => self.parse_orders(args.get(0).cloned().unwrap_or(crate::Value::Null), &args[1.min(args.len())..]),
12111            "parse_position" => <Self as crate::exchange_generated::ExchangeBase>::parse_position(self, args.get(0).cloned().unwrap_or(crate::Value::Null), &args[1.min(args.len())..]),
12112            "parse_positions" => self.parse_positions(args.get(0).cloned().unwrap_or(crate::Value::Null), &args[1.min(args.len())..]),
12113            "parse_precision" => self.parse_precision(&args[..]),
12114            "parse_ticker" => <Self as crate::exchange_generated::ExchangeBase>::parse_ticker(self, args.get(0).cloned().unwrap_or(crate::Value::Null), &args[1.min(args.len())..]),
12115            "parse_tickers" => self.parse_tickers(args.get(0).cloned().unwrap_or(crate::Value::Null), &args[1.min(args.len())..]),
12116            "parse_to_int" => self.parse_to_int(args.get(0).cloned().unwrap_or(crate::Value::Null)),
12117            "parse_to_numeric" => self.parse_to_numeric(args.get(0).cloned().unwrap_or(crate::Value::Null)),
12118            "parse_trade" => <Self as crate::exchange_generated::ExchangeBase>::parse_trade(self, args.get(0).cloned().unwrap_or(crate::Value::Null), &args[1.min(args.len())..]),
12119            "parse_trades" => self.parse_trades(args.get(0).cloned().unwrap_or(crate::Value::Null), &args[1.min(args.len())..]),
12120            "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[2.min(args.len())..]),
12121            "parse_trading_view_ohlcv" => self.parse_trading_view_ohlcv(args.get(0).cloned().unwrap_or(crate::Value::Null), &args[1.min(args.len())..]),
12122            "parse_transaction" => <Self as crate::exchange_generated::ExchangeBase>::parse_transaction(self, args.get(0).cloned().unwrap_or(crate::Value::Null), &args[1.min(args.len())..]),
12123            "parse_transactions" => self.parse_transactions(args.get(0).cloned().unwrap_or(crate::Value::Null), &args[1.min(args.len())..]),
12124            "parse_transfer" => <Self as crate::exchange_generated::ExchangeBase>::parse_transfer(self, args.get(0).cloned().unwrap_or(crate::Value::Null), &args[1.min(args.len())..]),
12125            "parse_transfers" => self.parse_transfers(args.get(0).cloned().unwrap_or(crate::Value::Null), &args[1.min(args.len())..]),
12126            "parse_ws_ohlc_vs" => self.parse_ws_ohlc_vs(args.get(0).cloned().unwrap_or(crate::Value::Null), &args[1.min(args.len())..]),
12127            "parse_ws_ohlcv" => self.parse_ws_ohlcv(args.get(0).cloned().unwrap_or(crate::Value::Null), &args[1.min(args.len())..]),
12128            "parse_ws_order" => self.parse_ws_order(args.get(0).cloned().unwrap_or(crate::Value::Null), &args[1.min(args.len())..]),
12129            "parse_ws_order_trade" => self.parse_ws_order_trade(args.get(0).cloned().unwrap_or(crate::Value::Null), &args[1.min(args.len())..]),
12130            "parse_ws_trade" => self.parse_ws_trade(args.get(0).cloned().unwrap_or(crate::Value::Null), &args[1.min(args.len())..]),
12131            "parse_ws_trades" => self.parse_ws_trades(args.get(0).cloned().unwrap_or(crate::Value::Null), &args[1.min(args.len())..]),
12132            "parsed_fee_and_fees" => self.parsed_fee_and_fees(args.get(0).cloned().unwrap_or(crate::Value::Null)),
12133            "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)),
12134            "reduce_fees_by_currency" => self.reduce_fees_by_currency(args.get(0).cloned().unwrap_or(crate::Value::Null)),
12135            "reduce_margin" => self.reduce_margin(args.get(0).cloned().unwrap_or(crate::Value::Null), args.get(1).cloned().unwrap_or(crate::Value::Null), &args[2.min(args.len())..]).await,
12136            "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)),
12137            "remove_repeated_elements_from_array" => self.remove_repeated_elements_from_array(args.get(0).cloned().unwrap_or(crate::Value::Null), &args[1.min(args.len())..]),
12138            "remove_repeated_trades_from_array" => self.remove_repeated_trades_from_array(args.get(0).cloned().unwrap_or(crate::Value::Null)),
12139            "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[2.min(args.len())..]).await,
12140            "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[3.min(args.len())..]).await,
12141            "repay_margin" => self.repay_margin(args.get(0).cloned().unwrap_or(crate::Value::Null), args.get(1).cloned().unwrap_or(crate::Value::Null), &args[2.min(args.len())..]).await,
12142            "request" => self.request(args.get(0).cloned().unwrap_or(crate::Value::Null), &args[1.min(args.len())..]).await,
12143            "require_value" => self.require_value(args.get(0).cloned().unwrap_or(crate::Value::Null), &args[1.min(args.len())..]),
12144            "resolve_path" => self.resolve_path(args.get(0).cloned().unwrap_or(crate::Value::Null), args.get(1).cloned().unwrap_or(crate::Value::Null)),
12145            "safe_balance" => self.safe_balance(args.get(0).cloned().unwrap_or(crate::Value::Null)),
12146            "safe_bool" => self.safe_bool(args.get(0).cloned().unwrap_or(crate::Value::Null), args.get(1).cloned().unwrap_or(crate::Value::Null), &args[2.min(args.len())..]),
12147            "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[3.min(args.len())..]),
12148            "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[2.min(args.len())..]),
12149            "safe_currency" => self.safe_currency(args.get(0).cloned().unwrap_or(crate::Value::Null), &args[1.min(args.len())..]),
12150            "safe_currency_code" => self.safe_currency_code(args.get(0).cloned().unwrap_or(crate::Value::Null), &args[1.min(args.len())..]),
12151            "safe_currency_structure" => self.safe_currency_structure(args.get(0).cloned().unwrap_or(crate::Value::Null)),
12152            "safe_deterministic_call" => self.safe_deterministic_call(args.get(0).cloned().unwrap_or(crate::Value::Null), &args[1.min(args.len())..]).await,
12153            "safe_dict" => self.safe_dict(args.get(0).cloned().unwrap_or(crate::Value::Null), args.get(1).cloned().unwrap_or(crate::Value::Null), &args[2.min(args.len())..]),
12154            "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[3.min(args.len())..]),
12155            "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[2.min(args.len())..]),
12156            "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[2.min(args.len())..]),
12157            "safe_ledger_entry" => self.safe_ledger_entry(args.get(0).cloned().unwrap_or(crate::Value::Null), &args[1.min(args.len())..]),
12158            "safe_liquidation" => self.safe_liquidation(args.get(0).cloned().unwrap_or(crate::Value::Null), &args[1.min(args.len())..]),
12159            "safe_list" => self.safe_list(args.get(0).cloned().unwrap_or(crate::Value::Null), args.get(1).cloned().unwrap_or(crate::Value::Null), &args[2.min(args.len())..]),
12160            "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[3.min(args.len())..]),
12161            "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[2.min(args.len())..]),
12162            "safe_market" => self.safe_market(&args[..]),
12163            "safe_market_structure" => self.safe_market_structure(&args[..]),
12164            "safe_network" => self.safe_network(args.get(0).cloned().unwrap_or(crate::Value::Null)),
12165            "safe_number" => self.safe_number(args.get(0).cloned().unwrap_or(crate::Value::Null), args.get(1).cloned().unwrap_or(crate::Value::Null), &args[2.min(args.len())..]),
12166            "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[3.min(args.len())..]),
12167            "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[2.min(args.len())..]),
12168            "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[2.min(args.len())..]),
12169            "safe_open_interest" => self.safe_open_interest(args.get(0).cloned().unwrap_or(crate::Value::Null), &args[1.min(args.len())..]),
12170            "safe_order" => self.safe_order(args.get(0).cloned().unwrap_or(crate::Value::Null), &args[1.min(args.len())..]),
12171            "safe_position" => self.safe_position(args.get(0).cloned().unwrap_or(crate::Value::Null)),
12172            "safe_symbol" => self.safe_symbol(args.get(0).cloned().unwrap_or(crate::Value::Null), &args[1.min(args.len())..]),
12173            "safe_ticker" => self.safe_ticker(args.get(0).cloned().unwrap_or(crate::Value::Null), &args[1.min(args.len())..]),
12174            "safe_trade" => self.safe_trade(args.get(0).cloned().unwrap_or(crate::Value::Null), &args[1.min(args.len())..]),
12175            "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[3.min(args.len())..]),
12176            "set_headers" => self.set_headers(args.get(0).cloned().unwrap_or(crate::Value::Null)),
12177            "set_leverage" => self.set_leverage(args.get(0).cloned().unwrap_or(crate::Value::Null), &args[1.min(args.len())..]).await,
12178            "set_margin" => self.set_margin(args.get(0).cloned().unwrap_or(crate::Value::Null), args.get(1).cloned().unwrap_or(crate::Value::Null), &args[2.min(args.len())..]).await,
12179            "set_margin_mode" => self.set_margin_mode(args.get(0).cloned().unwrap_or(crate::Value::Null), &args[1.min(args.len())..]).await,
12180            "set_markets" => self.set_markets(args.get(0).cloned().unwrap_or(crate::Value::Null), &args[1.min(args.len())..]),
12181            "set_markets_from_exchange" => self.set_markets_from_exchange(args.get(0).cloned().unwrap_or(crate::Value::Null)),
12182            "set_position_mode" => self.set_position_mode(args.get(0).cloned().unwrap_or(crate::Value::Null), &args[1.min(args.len())..]).await,
12183            "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[4.min(args.len())..]),
12184            "sign" => <Self as crate::exchange_generated::ExchangeBase>::sign(self, args.get(0).cloned().unwrap_or(crate::Value::Null), &args[1.min(args.len())..]),
12185            "sign_in" => self.sign_in(&args[..]).await,
12186            "sort_cursor_paginated_result" => self.sort_cursor_paginated_result(args.get(0).cloned().unwrap_or(crate::Value::Null)),
12187            "string_to_base16" => self.string_to_base16(args.get(0).cloned().unwrap_or(crate::Value::Null)),
12188            "symbol" => self.symbol(args.get(0).cloned().unwrap_or(crate::Value::Null)),
12189            "timeframe_from_milliseconds" => self.timeframe_from_milliseconds(args.get(0).cloned().unwrap_or(crate::Value::Null)),
12190            "transfer" => self.transfer(args.get(0).cloned().unwrap_or(crate::Value::Null), args.get(1).cloned().unwrap_or(crate::Value::Null), args.get(2).cloned().unwrap_or(crate::Value::Null), args.get(3).cloned().unwrap_or(crate::Value::Null), &args[4.min(args.len())..]).await,
12191            "un_watch_bids_asks" => self.un_watch_bids_asks(&args[..]).await,
12192            "un_watch_funding_rate" => self.un_watch_funding_rate(args.get(0).cloned().unwrap_or(crate::Value::Null), &args[1.min(args.len())..]).await,
12193            "un_watch_funding_rates" => self.un_watch_funding_rates(&args[..]).await,
12194            "un_watch_mark_price" => self.un_watch_mark_price(args.get(0).cloned().unwrap_or(crate::Value::Null), &args[1.min(args.len())..]).await,
12195            "un_watch_mark_prices" => self.un_watch_mark_prices(&args[..]).await,
12196            "un_watch_my_trades" => self.un_watch_my_trades(&args[..]).await,
12197            "un_watch_ohlcv" => self.un_watch_ohlcv(args.get(0).cloned().unwrap_or(crate::Value::Null), &args[1.min(args.len())..]).await,
12198            "un_watch_ohlcv_for_symbols" => self.un_watch_ohlcv_for_symbols(args.get(0).cloned().unwrap_or(crate::Value::Null), &args[1.min(args.len())..]).await,
12199            "un_watch_order_book" => self.un_watch_order_book(args.get(0).cloned().unwrap_or(crate::Value::Null), &args[1.min(args.len())..]).await,
12200            "un_watch_order_book_for_symbols" => self.un_watch_order_book_for_symbols(args.get(0).cloned().unwrap_or(crate::Value::Null), &args[1.min(args.len())..]).await,
12201            "un_watch_orders" => self.un_watch_orders(&args[..]).await,
12202            "un_watch_positions" => self.un_watch_positions(&args[..]).await,
12203            "un_watch_ticker" => self.un_watch_ticker(args.get(0).cloned().unwrap_or(crate::Value::Null), &args[1.min(args.len())..]).await,
12204            "un_watch_tickers" => self.un_watch_tickers(&args[..]).await,
12205            "un_watch_trades" => self.un_watch_trades(args.get(0).cloned().unwrap_or(crate::Value::Null), &args[1.min(args.len())..]).await,
12206            "un_watch_trades_for_symbols" => self.un_watch_trades_for_symbols(args.get(0).cloned().unwrap_or(crate::Value::Null), &args[1.min(args.len())..]).await,
12207            "url_encoder_for_proxy_url" => self.url_encoder_for_proxy_url(args.get(0).cloned().unwrap_or(crate::Value::Null)),
12208            "watch_balance" => self.watch_balance(&args[..]).await,
12209            "watch_bids_asks" => self.watch_bids_asks(&args[..]).await,
12210            "watch_funding_rate" => self.watch_funding_rate(args.get(0).cloned().unwrap_or(crate::Value::Null), &args[1.min(args.len())..]).await,
12211            "watch_funding_rates" => self.watch_funding_rates(&args[..]).await,
12212            "watch_funding_rates_for_symbols" => self.watch_funding_rates_for_symbols(args.get(0).cloned().unwrap_or(crate::Value::Null), &args[1.min(args.len())..]).await,
12213            "watch_liquidations" => self.watch_liquidations(args.get(0).cloned().unwrap_or(crate::Value::Null), &args[1.min(args.len())..]).await,
12214            "watch_liquidations_for_symbols" => self.watch_liquidations_for_symbols(args.get(0).cloned().unwrap_or(crate::Value::Null), &args[1.min(args.len())..]).await,
12215            "watch_mark_price" => self.watch_mark_price(args.get(0).cloned().unwrap_or(crate::Value::Null), &args[1.min(args.len())..]).await,
12216            "watch_mark_prices" => self.watch_mark_prices(&args[..]).await,
12217            "watch_my_liquidations" => self.watch_my_liquidations(args.get(0).cloned().unwrap_or(crate::Value::Null), &args[1.min(args.len())..]).await,
12218            "watch_my_liquidations_for_symbols" => self.watch_my_liquidations_for_symbols(args.get(0).cloned().unwrap_or(crate::Value::Null), &args[1.min(args.len())..]).await,
12219            "watch_my_trades" => self.watch_my_trades(&args[..]).await,
12220            "watch_my_trades_for_symbols" => self.watch_my_trades_for_symbols(args.get(0).cloned().unwrap_or(crate::Value::Null), &args[1.min(args.len())..]).await,
12221            "watch_ohlcv" => self.watch_ohlcv(args.get(0).cloned().unwrap_or(crate::Value::Null), &args[1.min(args.len())..]).await,
12222            "watch_ohlcv_for_symbols" => self.watch_ohlcv_for_symbols(args.get(0).cloned().unwrap_or(crate::Value::Null), &args[1.min(args.len())..]).await,
12223            "watch_order_book" => self.watch_order_book(args.get(0).cloned().unwrap_or(crate::Value::Null), &args[1.min(args.len())..]).await,
12224            "watch_order_book_for_symbols" => self.watch_order_book_for_symbols(args.get(0).cloned().unwrap_or(crate::Value::Null), &args[1.min(args.len())..]).await,
12225            "watch_orders" => self.watch_orders(&args[..]).await,
12226            "watch_orders_for_symbols" => self.watch_orders_for_symbols(args.get(0).cloned().unwrap_or(crate::Value::Null), &args[1.min(args.len())..]).await,
12227            "watch_position" => self.watch_position(&args[..]).await,
12228            "watch_position_for_symbols" => self.watch_position_for_symbols(&args[..]).await,
12229            "watch_positions" => self.watch_positions(&args[..]).await,
12230            "watch_ticker" => self.watch_ticker(args.get(0).cloned().unwrap_or(crate::Value::Null), &args[1.min(args.len())..]).await,
12231            "watch_tickers" => self.watch_tickers(&args[..]).await,
12232            "watch_trades" => self.watch_trades(args.get(0).cloned().unwrap_or(crate::Value::Null), &args[1.min(args.len())..]).await,
12233            "watch_trades_for_symbols" => self.watch_trades_for_symbols(args.get(0).cloned().unwrap_or(crate::Value::Null), &args[1.min(args.len())..]).await,
12234            "withdraw" => self.withdraw(args.get(0).cloned().unwrap_or(crate::Value::Null), args.get(1).cloned().unwrap_or(crate::Value::Null), args.get(2).cloned().unwrap_or(crate::Value::Null), &args[3.min(args.len())..]).await,
12235            "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[3.min(args.len())..]).await,
12236                // Implicit-API endpoints (`publicGetX`) exist only as inherent
12237                // methods on the venue's `<id>_api.rs`, which no name-based
12238                // dispatch arm covers — a static-request test named after one
12239                // (bingx's accountV1PrivateGetAccountApiRestrictions) otherwise
12240                // computes a null url. Route them the way those wrappers do.
12241                // Guarded on the api block so a genuinely unknown name still
12242                // returns Null rather than panicking inside call_method.
12243                //
12244                // Returning Null keeps an optional probe cheap, but a dynamic
12245                // re-entry (`fetchPaginatedCall*` / `fetchWebEndpoint`, which
12246                // reach here via `method_name_to_snake_case`) must not silently
12247                // see an empty page — so record the miss for
12248                // `crate::exchange::call_dynamic_required` to raise on.
12249                _ => {
12250                    if self.internals.implicit_api.is_empty() {
12251                        self.build_implicit_api();
12252                    }
12253                    if self.internals.implicit_api.contains_key(method) {
12254                        self.call_method(crate::Value::Str(method.to_string().into()), &args[..]).await
12255                    } else {
12256                        self.internals.dynamic_dispatch_miss = Some(method.to_string());
12257                        crate::Value::Null
12258                    }
12259                }
12260            }
12261        })
12262    }
12263}