1#![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 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 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 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()));
395 m.insert("418".to_string(), Value::Str("DDoSProtection".into()));
396 m.insert("429".to_string(), Value::Str("RateLimitExceeded".into()));
397 m.insert("404".to_string(), Value::Str("ExchangeNotAvailable".into()));
398 m.insert("409".to_string(), Value::Str("ExchangeNotAvailable".into()));
399 m.insert("410".to_string(), Value::Str("ExchangeNotAvailable".into()));
400 m.insert("451".to_string(), Value::Str("ExchangeNotAvailable".into()));
401 m.insert("500".to_string(), Value::Str("ExchangeNotAvailable".into()));
402 m.insert("501".to_string(), Value::Str("ExchangeNotAvailable".into()));
403 m.insert("502".to_string(), Value::Str("ExchangeNotAvailable".into()));
404 m.insert("520".to_string(), Value::Str("ExchangeNotAvailable".into()));
405 m.insert("521".to_string(), Value::Str("ExchangeNotAvailable".into()));
406 m.insert("522".to_string(), Value::Str("ExchangeNotAvailable".into()));
407 m.insert("525".to_string(), Value::Str("ExchangeNotAvailable".into()));
408 m.insert("526".to_string(), Value::Str("ExchangeNotAvailable".into()));
409 m.insert("400".to_string(), Value::Str("ExchangeNotAvailable".into()));
410 m.insert("403".to_string(), Value::Str("ExchangeNotAvailable".into()));
411 m.insert("405".to_string(), Value::Str("ExchangeNotAvailable".into()));
412 m.insert("503".to_string(), Value::Str("ExchangeNotAvailable".into()));
413 m.insert("530".to_string(), Value::Str("ExchangeNotAvailable".into()));
414 m.insert("408".to_string(), Value::Str("RequestTimeout".into()));
415 m.insert("504".to_string(), Value::Str("RequestTimeout".into()));
416 m.insert("401".to_string(), Value::Str("AuthenticationError".into()));
417 m.insert("407".to_string(), Value::Str("AuthenticationError".into()));
418 m.insert("511".to_string(), Value::Str("AuthenticationError".into()));
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 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 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 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 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 let mut value: Value = self.safe_value_n(dictionaryOrList, keys, &[defaultValue.clone()]);
558 if (value == Value::Null) {
559 return defaultValue;
560 }
561 if self.is_dictionary(value.clone()).as_bool() == Some(true) {
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 let mut value: Value = self.safe_value(dictionaryOrList, key, &[defaultValue.clone()]);
578 if (value == Value::Null) {
579 return defaultValue;
580 }
581 if self.is_dictionary(value.clone()).as_bool() == Some(true) {
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 let mut value: Value = self.safe_value(dictionaryOrList.clone(), key1, &[]);
598 if self.is_dictionary(value.clone()).as_bool() == Some(true) {
599 return value;
600 }
601 let mut value2: Value = self.safe_value(dictionaryOrList, key2, &[]);
602 if self.is_dictionary(value2.clone()).as_bool() == Some(true) {
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 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 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 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 let mut k: Value = key.clone();
678 if (k != Value::Null) {
679 if let Value::Dict(__d) = &mut dict { std::sync::Arc::make_mut(__d).insert(crate::runtime::stringify_param(&k), value); }
680 }
681}
682
683 fn handle_deltas(&self, mut bookside: Value, mut deltas: Value) {
684 {
685 let mut i: i64 = 0;
686 let mut __for_first_71: bool = true;
687 while { if !__for_first_71 { i += 1; } __for_first_71 = false; i < (deltas.len() as i64) } {
688 self.handle_delta(bookside.clone(), self.safe_value(deltas.clone(), Value::Int(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: i64 = 0;
700 let mut __for_first_72: bool = true;
701 while { if !__for_first_72 { i += 1; } __for_first_72 = false; i < (deltas.len() as i64) } {
702 self.handle_book_delta(orderbook.clone(), self.safe_value(deltas.clone(), Value::Int(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: i64 = 0;
717 let mut __for_first_73: bool = true;
718 while { if !__for_first_73 { i += 1; } __for_first_73 = false; i < (deltas.len() as i64) } {
719 let mut bidAsk: Value = self.parse_order_book_bid_ask(self.safe_value(deltas.clone(), Value::Int(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 __arraysOfArrays_empty = Vec::new();
733 let arraysOfArrays = arraysOfArrays.as_array().unwrap_or(&__arraysOfArrays_empty);
734 let mut result: Value = Value::from(vec![]);
735 {
736 let mut i: Value = Value::Int(0);
737 let mut __for_first_74: bool = true;
738 while { if !__for_first_74 { if let Value::Int(n) = &mut i { *n += 1; } } __for_first_74 = false; i.as_f64().unwrap_or(f64::NAN) < ((arraysOfArrays.len() as i64) as f64) } {
739 result = self.array_concat(result.clone(), arraysOfArrays.get((i).as_i64().unwrap_or(-1) as usize).cloned().unwrap_or(Value::Null));
740 }
741 }
742 return result;
743
744 Value::Null
745}
746
747 fn find_timeframe(&self, mut timeframe: Value, optional_args: &[Value]) -> Value {
748 let mut timeframes = get_arg(optional_args, 0, Value::Null);
749 let mut timeframesResolved: Value = (if (timeframes == Value::Null) { self.timeframes.clone() } else { timeframes });
750 let mut keys: Vec<Value> = object_keys(&timeframesResolved).as_array().cloned().unwrap_or_default();
751 {
752 let mut i: i64 = 0;
753 let mut __for_first_75: bool = true;
754 while { if !__for_first_75 { i += 1; } __for_first_75 = false; i < (keys.len() as i64) } {
755 let mut key: Value = keys.get(i as usize).cloned().unwrap_or(Value::Null);
756 if is_equal(&(if let (Some(__m), Some(__k)) = (timeframesResolved.as_map(), key.as_str()) { __m.get(__k).cloned().unwrap_or(Value::Null) } else { Value::Null }), &timeframe) {
757 return key;
758 }
759 }
760 }
761 return Value::Null;
762
763 Value::Null
764}
765
766 fn check_proxy_url_settings(&self, optional_args: &[Value]) -> Value {
767 let mut url = get_arg(optional_args, 0, Value::Null);
768 let mut method = get_arg(optional_args, 1, Value::Null);
769 let mut headers = get_arg(optional_args, 2, Value::Null);
770 let mut body = get_arg(optional_args, 3, Value::Null);
771 let mut usedProxies: Vec<Value> = Vec::new();
772 let mut proxyUrl: Value = Value::Null;
773 if (self.proxyUrl.clone() != Value::Null) {
774 usedProxies.push(Value::Str("proxyUrl".into()));
775 proxyUrl = self.proxyUrl.clone();
776 }
777 if (self.proxy_url.clone() != Value::Null) {
778 usedProxies.push(Value::Str("proxy_url".into()));
779 proxyUrl = self.proxy_url.clone();
780 }
781 if (self.proxyUrlCallback.clone() != Value::Null) {
782 usedProxies.push(Value::Str("proxyUrlCallback".into()));
783 proxyUrl = self.proxy_url_callback_fn(url.clone(), method.clone(), headers.clone(), body.clone());
784 }
785 if (self.proxy_url_callback.clone() != Value::Null) {
786 usedProxies.push(Value::Str("proxy_url_callback".into()));
787 proxyUrl = self.proxy_url_callback_fn(url.clone(), method.clone(), headers.clone(), body.clone());
788 }
789 if (self.proxy.clone() != Value::Null) {
791 usedProxies.push(Value::Str("proxy".into()));
792 if is_function(&self.proxy) {
793 proxyUrl = self.proxy_fn(url, method, headers, body);
794 } else {
795 proxyUrl = self.proxy.clone();
796 }
797 }
798 let mut length: f64 = ((usedProxies.len() as i64) as f64);
799 if length > ((1i64) as f64) {
800 let mut joinedProxyNames: Value = Value::Str(usedProxies.iter().map(|__v| __v.to_string()).collect::<Vec<String>>().join(",").into());
801 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()))));
802 }
803 return proxyUrl;
804
805 Value::Null
806}
807
808 fn url_encoder_for_proxy_url(&self, mut targetUrl: Value) -> Value {
809 let mut includesQuery: bool = targetUrl.as_str().unwrap_or("").contains("?");
811 let mut finalUrl: Value = (if includesQuery { self.encode_uri_component(targetUrl.clone()) } else { targetUrl });
812 return finalUrl;
813
814 Value::Null
815}
816
817 fn check_proxy_settings(&self, optional_args: &[Value]) -> Value {
818 let mut url = get_arg(optional_args, 0, Value::Null);
819 let mut method = get_arg(optional_args, 1, Value::Null);
820 let mut headers = get_arg(optional_args, 2, Value::Null);
821 let mut body = get_arg(optional_args, 3, Value::Null);
822 let mut usedProxies: Vec<Value> = Vec::new();
823 let mut httpProxy: Value = Value::Null;
824 let mut httpsProxy: Value = Value::Null;
825 let mut socksProxy: Value = Value::Null;
826 let mut isHttpProxyDefined: Value = self.value_is_defined(self.httpProxy.clone());
828 let mut isHttp_proxy_defined: Value = self.value_is_defined(self.http_proxy.clone());
829 if isHttpProxyDefined.as_bool() == Some(true) || isHttp_proxy_defined.as_bool() == Some(true) {
830 usedProxies.push(Value::Str("httpProxy".into()));
831 httpProxy = (if isHttpProxyDefined.as_bool() == Some(true) { self.httpProxy.clone() } else { self.http_proxy.clone() });
832 }
833 let mut ishttpProxyCallbackDefined: Value = self.value_is_defined(self.httpProxyCallback.clone());
834 let mut ishttp_proxy_callback_defined: Value = self.value_is_defined(self.http_proxy_callback.clone());
835 if ishttpProxyCallbackDefined.as_bool() == Some(true) || ishttp_proxy_callback_defined.as_bool() == Some(true) {
836 usedProxies.push(Value::Str("httpProxyCallback".into()));
837 httpProxy = (if ishttpProxyCallbackDefined.as_bool() == Some(true) { 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()) });
838 }
839 let mut isHttpsProxyDefined: Value = self.value_is_defined(self.httpsProxy.clone());
841 let mut isHttps_proxy_defined: Value = self.value_is_defined(self.https_proxy.clone());
842 if isHttpsProxyDefined.as_bool() == Some(true) || isHttps_proxy_defined.as_bool() == Some(true) {
843 usedProxies.push(Value::Str("httpsProxy".into()));
844 httpsProxy = (if isHttpsProxyDefined.as_bool() == Some(true) { self.httpsProxy.clone() } else { self.https_proxy.clone() });
845 }
846 let mut ishttpsProxyCallbackDefined: Value = self.value_is_defined(self.httpsProxyCallback.clone());
847 let mut ishttps_proxy_callback_defined: Value = self.value_is_defined(self.https_proxy_callback.clone());
848 if ishttpsProxyCallbackDefined.as_bool() == Some(true) || ishttps_proxy_callback_defined.as_bool() == Some(true) {
849 usedProxies.push(Value::Str("httpsProxyCallback".into()));
850 httpsProxy = (if ishttpsProxyCallbackDefined.as_bool() == Some(true) { 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()) });
851 }
852 let mut isSocksProxyDefined: Value = self.value_is_defined(self.socksProxy.clone());
854 let mut isSocks_proxy_defined: Value = self.value_is_defined(self.socks_proxy.clone());
855 if isSocksProxyDefined.as_bool() == Some(true) || isSocks_proxy_defined.as_bool() == Some(true) {
856 usedProxies.push(Value::Str("socksProxy".into()));
857 socksProxy = (if isSocksProxyDefined.as_bool() == Some(true) { self.socksProxy.clone() } else { self.socks_proxy.clone() });
858 }
859 let mut issocksProxyCallbackDefined: Value = self.value_is_defined(self.socksProxyCallback.clone());
860 let mut issocks_proxy_callback_defined: Value = self.value_is_defined(self.socks_proxy_callback.clone());
861 if issocksProxyCallbackDefined.as_bool() == Some(true) || issocks_proxy_callback_defined.as_bool() == Some(true) {
862 usedProxies.push(Value::Str("socksProxyCallback".into()));
863 socksProxy = (if issocksProxyCallbackDefined.as_bool() == Some(true) { self.socks_proxy_callback_fn(url.clone(), method.clone(), headers.clone(), body.clone()) } else { self.socks_proxy_callback_fn(url, method, headers, body) });
864 }
865 let mut length: f64 = ((usedProxies.len() as i64) as f64);
867 if length > ((1i64) as f64) {
868 let mut joinedProxyNames: Value = Value::Str(usedProxies.iter().map(|__v| __v.to_string()).collect::<Vec<String>>().join(",").into());
869 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()),
870 Value::Str("), please use only one from: httpProxy, httpsProxy, httpProxyCallback, httpsProxyCallback, socksProxy, socksProxyCallback".into()))));
871 }
872 return Value::from(vec![httpProxy, httpsProxy, socksProxy]);
873
874 Value::Null
875}
876
877 fn check_ws_proxy_settings(&self) -> Value {
878 let mut usedProxies: Vec<Value> = Vec::new();
879 let mut wsProxy: Value = Value::Null;
880 let mut wssProxy: Value = Value::Null;
881 let mut wsSocksProxy: Value = Value::Null;
882 let mut isWsProxyDefined: Value = self.value_is_defined(self.wsProxy.clone());
884 let mut is_ws_proxy_defined: Value = self.value_is_defined(self.ws_proxy.clone());
885 if isWsProxyDefined.as_bool() == Some(true) || is_ws_proxy_defined.as_bool() == Some(true) {
886 usedProxies.push(Value::Str("wsProxy".into()));
887 wsProxy = (if isWsProxyDefined.as_bool() == Some(true) { self.wsProxy.clone() } else { self.ws_proxy.clone() });
888 }
889 let mut isWssProxyDefined: Value = self.value_is_defined(self.wssProxy.clone());
891 let mut is_wss_proxy_defined: Value = self.value_is_defined(self.wss_proxy.clone());
892 if isWssProxyDefined.as_bool() == Some(true) || is_wss_proxy_defined.as_bool() == Some(true) {
893 usedProxies.push(Value::Str("wssProxy".into()));
894 wssProxy = (if isWssProxyDefined.as_bool() == Some(true) { self.wssProxy.clone() } else { self.wss_proxy.clone() });
895 }
896 let mut isWsSocksProxyDefined: Value = self.value_is_defined(self.wsSocksProxy.clone());
898 let mut is_ws_socks_proxy_defined: Value = self.value_is_defined(self.ws_socks_proxy.clone());
899 if isWsSocksProxyDefined.as_bool() == Some(true) || is_ws_socks_proxy_defined.as_bool() == Some(true) {
900 usedProxies.push(Value::Str("wsSocksProxy".into()));
901 wsSocksProxy = (if isWsSocksProxyDefined.as_bool() == Some(true) { self.wsSocksProxy.clone() } else { self.ws_socks_proxy.clone() });
902 }
903 let mut length: f64 = ((usedProxies.len() as i64) as f64);
905 if length > ((1i64) as f64) {
906 let mut joinedProxyNames: Value = Value::Str(usedProxies.iter().map(|__v| __v.to_string()).collect::<Vec<String>>().join(",").into());
907 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()))));
908 }
909 return Value::from(vec![wsProxy, wssProxy, wsSocksProxy]);
910
911 Value::Null
912}
913
914 fn check_conflicting_proxies(&self, mut proxyAgentSet: Value, mut proxyUrlSet: Value) {
915 let mut proxyAgentIsSet: bool = (proxyAgentSet != Value::Null) && (proxyAgentSet != Value::Null) && (proxyAgentSet.as_str() != Some(""));
916 let mut proxyUrlIsSet: bool = (proxyUrlSet != Value::Null) && (proxyUrlSet != Value::Null) && (proxyUrlSet.as_str() != Some(""));
917 if proxyAgentIsSet && proxyUrlIsSet {
918 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()))));
919 }
920}
921
922 fn check_address(&self, optional_args: &[Value]) -> Value {
923 let mut address = get_arg(optional_args, 0, Value::Null);
924 let mut code = get_arg(optional_args, 1, Value::Null);
925 let mut tag = get_arg(optional_args, 2, Value::Null);
926 if (address == Value::Null) {
927 panic!("{}", crate::exchange_errors::invalid_address(format!("{}{}", self.id.clone(), Value::Str(" address is undefined".into()))));
928 }
929 let mut uniqChars: Value = (self.unique(self.string_to_chars_array(address.clone())));
931 let mut length: f64 = ((uniqChars.len() as i64) as f64); if (length == 1.0) || ((address.len() as i64) as f64) < self.minFundingAddressLength.as_f64().unwrap_or(f64::NAN) || address.as_str().unwrap_or("").contains(" ") {
933 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()), Value::Str(format!("{}", self.minFundingAddressLength.clone()).into())).into()),
934 Value::Str(" characters: \"".into())).into()), Value::Str(format!("{}", address).into())).into()), Value::Str("\"".into()))));
935 }
936 if (code != Value::Null) {
937 let mut tagRequiredCurrencies: Value = self.safe_list_k(self.options.clone(), "withdrawTagRequiredCurrencies", &[Value::from(vec![])]);
938 if self.in_array(code.clone(), tagRequiredCurrencies).as_bool() == Some(true) {
939 if (tag == Value::Null) {
940 panic!("{}", crate::exchange_errors::arguments_required(format!("{}{}", Value::Str(format!("{}{}", self.id.clone(), Value::Str(" withdraw() requires params[\"tag\"] for ".into())).into()), code)));
941 }
942 }
943 }
944 return address;
945
946 Value::Null
947}
948
949 fn find_message_hashes(&self, mut client: Value, mut element: Value) -> Value {
950 let mut result: Vec<Value> = Vec::new();
951 let mut messageHashes: Vec<Value> = Value::Array(get_value(&client, &Value::Str("futures".into())).as_map().map(|__m| __m.keys().map(|__k| Value::Str(__k.clone().into())).collect()).unwrap_or_default()).as_array().cloned().unwrap_or_default();
952 {
953 let mut i: i64 = 0;
954 let mut __for_first_76: bool = true;
955 while { if !__for_first_76 { i += 1; } __for_first_76 = false; i < (messageHashes.len() as i64) } {
956 let mut messageHash: Value = messageHashes.get(i as usize).cloned().unwrap_or(Value::Null);
957 if Value::Int(messageHash.as_str().zip(element.as_str()).and_then(|(__s, __n)| __s.find(__n)).map(|__i| __i as i64).unwrap_or(-1)).as_f64().unwrap_or(f64::NAN) >= ((0i64) as f64) {
958 result.push(messageHash);
959 }
960 }
961 }
962 return Value::from(result);
963
964 Value::Null
965}
966
967 fn filter_by_limit(&self, mut array: Value, optional_args: &[Value]) -> Value {
968 let mut limit = get_arg(optional_args, 0, Value::Null);
969 let mut key = get_arg(optional_args, 1, Value::Str("timestamp".into()));
970 let mut fromStart = get_arg(optional_args, 2, Value::Bool(false));
971 if (limit != Value::Null) && (limit != Value::Null) {
972 let mut arrayLength: Value = Value::Int(array.len() as i64);
973 if arrayLength.as_f64().unwrap_or(f64::NAN) > ((0i64) as f64) {
974 let mut ascending: bool = true;
975 if (in_op(&array.as_array().and_then(|__arr| __arr.get(0)).cloned().unwrap_or(Value::Null), &key)) {
976 let mut first: Value = self.safe_float(array.as_array().and_then(|__arr| __arr.get(0)).cloned().unwrap_or(Value::Null), key.clone(), &[]);
977 let mut last: Value = self.safe_float(array.as_array().and_then(|__arr| match &((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),
978 Value::Float(y)) => Value::Float(x - y), _ => Value::Null })) { Value::Int(__n) if *__n >= 0 => __arr.get(*__n as usize), _ => None }).cloned().unwrap_or(Value::Null), key.clone(), &[]);
979 if (first != Value::Null) && (last != Value::Null) {
980 ascending = last.as_f64().unwrap_or(f64::NAN) >= first.as_f64().unwrap_or(f64::NAN); }
982 }
983 if fromStart.as_bool() == Some(true) {
984 let mut limitResolved: Value = (if (limit.as_f64().unwrap_or(f64::NAN) > arrayLength.as_f64().unwrap_or(f64::NAN)) { arrayLength } else { limit.clone() });
985 if ascending {
986 return self.array_slice(array.clone(), Value::Int(0), &[limitResolved.clone()]);
987 }
988 return self.array_slice(array.clone(), (match &(limitResolved) { Value::Int(x) => Value::Int(-x), Value::Float(x) => Value::Float(-x), _ => Value::Null }), &[]);
989 }
990 if ascending {
991 return self.array_slice(array.clone(), (match &(limit) { Value::Int(x) => Value::Int(-x), Value::Float(x) => Value::Float(-x), _ => Value::Null }), &[]);
992 }
993 return self.array_slice(array.clone(), Value::Int(0), &[limit]);
994 }
995 }
996 return array;
997
998 Value::Null
999}
1000
1001 fn filter_by_since_limit(&self, mut array: Value, optional_args: &[Value]) -> Value {
1002 let mut since = get_arg(optional_args, 0, Value::Null);
1003 let mut limit = get_arg(optional_args, 1, Value::Null);
1004 let mut key = get_arg(optional_args, 2, Value::Str("timestamp".into()));
1005 let mut tail = get_arg(optional_args, 3, Value::Bool(false));
1006 if (array == Value::Null) {
1007 return Value::from(vec![]);
1008 }
1009 let mut sinceIsDefined: bool = (since != Value::Null) && (since != Value::Null);
1010 let mut parsedArray: Value = self.to_array(array);
1011 let mut result: Value = parsedArray.clone();
1012 if sinceIsDefined {
1013 result = Value::from(vec![]);
1014 {
1015 let mut i: i64 = 0;
1016 let mut __for_first_77: bool = true;
1017 while { if !__for_first_77 { i += 1; } __for_first_77 = false; i < (parsedArray.len() as i64) } {
1018 let mut entry: Value = parsedArray.as_array().map(Vec::as_slice).unwrap_or_default().get(i as usize).cloned().unwrap_or(Value::Null);
1019 let mut value: Value = self.safe_integer(entry.clone(), key.clone(), &[]);
1020 if (value != Value::Null) && (value.as_f64() != Some(0.0)) && (value.as_f64().unwrap_or(f64::NAN) >= since.as_f64().unwrap_or(f64::NAN)) {
1021 if let Value::Arr(__a) = &mut result { std::sync::Arc::make_mut(__a).push(entry); }
1022 }
1023 }
1024 }
1025 }
1026 if tail.as_bool() == Some(true) && (limit != Value::Null) {
1027 return self.array_slice(result.clone(), (match &(limit) { Value::Int(x) => Value::Int(-x), Value::Float(x) => Value::Float(-x), _ => Value::Null }), &[]);
1028 }
1029 let mut shouldFilterFromStart: Value = Value::Bool(!is_true(&tail) && sinceIsDefined);
1032 return self.filter_by_limit(result, &[limit, key, shouldFilterFromStart]);
1033
1034 Value::Null
1035}
1036
1037 fn filter_by_value_since_limit(&self, mut array: Value, mut field: Value, optional_args: &[Value]) -> Value {
1038 let mut value = get_arg(optional_args, 0, Value::Null);
1039 let mut since = get_arg(optional_args, 1, Value::Null);
1040 let mut limit = get_arg(optional_args, 2, Value::Null);
1041 let mut key = get_arg(optional_args, 3, Value::Str("timestamp".into()));
1042 let mut tail = get_arg(optional_args, 4, Value::Bool(false));
1043 let mut valueIsDefined: Value = self.value_is_defined(value.clone());
1044 let mut sinceIsDefined: bool = (since != Value::Null) && (since != Value::Null);
1045 let mut parsedArray: Value = self.to_array(array);
1046 let mut result: Value = parsedArray.clone();
1047 if valueIsDefined.as_bool() == Some(true) || sinceIsDefined {
1049 result = Value::from(vec![]);
1050 {
1051 let mut i: i64 = 0;
1052 let mut __for_first_78: bool = true;
1053 while { if !__for_first_78 { i += 1; } __for_first_78 = false; i < (parsedArray.len() as i64) } {
1054 let mut entry: Value = parsedArray.as_array().map(Vec::as_slice).unwrap_or_default().get(i as usize).cloned().unwrap_or(Value::Null);
1055 let mut entryFiledEqualValue: bool = is_equal(&self.safe_value(entry.clone(), field.clone(), &[]), &value);
1058 let mut firstCondition: bool = !(valueIsDefined.as_bool() == Some(true)) || entryFiledEqualValue;
1059 let mut entryKeyValue: Value = self.safe_integer(entry.clone(), key.clone(), &[]);
1060 let mut entryKeyGESince: bool = (entryKeyValue != Value::Null) && (entryKeyValue.as_f64() != Some(0.0)) && (since != Value::Null) && (entryKeyValue.as_f64().unwrap_or(f64::NAN) >= since.as_f64().unwrap_or(f64::NAN));
1061 let mut secondCondition: bool = !(sinceIsDefined) || entryKeyGESince;
1062 if firstCondition && secondCondition {
1063 if let Value::Arr(__a) = &mut result { std::sync::Arc::make_mut(__a).push(entry); }
1064 }
1065 }
1066 }
1067 }
1068 if tail.as_bool() == Some(true) && (limit != Value::Null) {
1069 return self.array_slice(result.clone(), (match &(limit) { Value::Int(x) => Value::Int(-x), Value::Float(x) => Value::Float(-x), _ => Value::Null }), &[]);
1070 }
1071 return self.filter_by_limit(result, &[limit, key, Value::Bool(sinceIsDefined)]);
1072
1073 Value::Null
1074}
1075
1076fn set_sandbox_mode(&mut self, mut enabled: Value) {
1083 if enabled.as_bool() == Some(true) {
1084 if (matches!(&self.urls, Value::Dict(__d) if __d.contains_key("test"))) {
1085 if matches!(&self.urls.as_map().and_then(|__m| __m.get("api")).cloned().unwrap_or(Value::Null), Value::Str(_)) {
1086 { let __be_tmp = crate::value::get_value_k(&self.urls, "api"); if let Value::Dict(__d) = &mut self.urls { std::sync::Arc::make_mut(__d).insert("apiBackup".into(), __be_tmp); } }
1087 { let __be_tmp = crate::value::get_value_k(&self.urls, "test"); if let Value::Dict(__d) = &mut self.urls { std::sync::Arc::make_mut(__d).insert("api".into(), __be_tmp); } }
1088 } else {
1089 { let __be_tmp = self.clone_value(crate::value::get_value_k(&self.urls, "api")); if let Value::Dict(__d) = &mut self.urls { std::sync::Arc::make_mut(__d).insert("apiBackup".into(), __be_tmp); } }
1090 { let __be_tmp = self.clone_value(crate::value::get_value_k(&self.urls, "test")); if let Value::Dict(__d) = &mut self.urls { std::sync::Arc::make_mut(__d).insert("api".into(), __be_tmp); } }
1091 }
1092 } else {
1093 panic!("{}", crate::exchange_errors::not_supported(format!("{}{}", self.id.clone(), Value::Str(" does not have a sandbox URL".into()))));
1094 }
1095 self.isSandboxModeEnabled = Value::Bool(true);
1097 } else if (matches!(&self.urls, Value::Dict(__d) if __d.contains_key("apiBackup"))) {
1098 if matches!(&self.urls.as_map().and_then(|__m| __m.get("api")).cloned().unwrap_or(Value::Null), Value::Str(_)) {
1099 { let __be_tmp = crate::value::get_value_k(&self.urls, "apiBackup"); if let Value::Dict(__d) = &mut self.urls { std::sync::Arc::make_mut(__d).insert("api".into(), __be_tmp); } }
1100 } else {
1101 { let __be_tmp = self.clone_value(crate::value::get_value_k(&self.urls, "apiBackup")); if let Value::Dict(__d) = &mut self.urls { std::sync::Arc::make_mut(__d).insert("api".into(), __be_tmp); } }
1102 }
1103 let mut newUrls: Value = self.omit(self.urls.clone(), Value::Str("apiBackup".into()), &[]);
1104 self.urls = newUrls;
1105 self.isSandboxModeEnabled = Value::Bool(false);
1107 }
1108}
1109
1110fn enable_demo_trading(&mut self, mut enable: Value) {
1117 if self.isSandboxModeEnabled.as_bool() == Some(true) {
1118 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()))));
1119 }
1120 if enable.as_bool() == Some(true) {
1121 { let __be_tmp = crate::value::get_value_k(&self.urls, "api"); if let Value::Dict(__d) = &mut self.urls { std::sync::Arc::make_mut(__d).insert("apiBackupDemoTrading".into(), __be_tmp); } }
1122 { let __be_tmp = crate::value::get_value_k(&self.urls, "demo"); if let Value::Dict(__d) = &mut self.urls { std::sync::Arc::make_mut(__d).insert("api".into(), __be_tmp); } }
1123 } else if (matches!(&self.urls, Value::Dict(__d) if __d.contains_key("apiBackupDemoTrading"))) {
1124 { let __be_tmp = crate::value::get_value_k(&self.urls, "apiBackupDemoTrading"); if let Value::Dict(__d) = &mut self.urls { std::sync::Arc::make_mut(__d).insert("api".into(), __be_tmp); } }
1125 let mut newUrls: Value = self.omit(self.urls.clone(), Value::Str("apiBackupDemoTrading".into()), &[]);
1126 self.urls = newUrls;
1127 }
1128 if let Value::Dict(__d) = &mut self.options { std::sync::Arc::make_mut(__d).insert("enableDemoTrading".into(), enable); }
1129}
1130
1131 fn sign(&self, mut path: Value, optional_args: &[Value]) -> Value {
1132 { 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),
1134 crate::runtime::get_arg(optional_args, 4, crate::Value::Null)); if !matches!(__v, crate::Value::Null) { return __v; } }
1135
1136 let mut api = get_arg(optional_args, 0, Value::from(vec![Value::Str("public".into())]));
1137 let mut method = get_arg(optional_args, 1, Value::Str("GET".into()));
1138 let mut params = get_arg(optional_args, 2, Value::Map({
1139 let mut m = indexmap::IndexMap::new();
1140 m
1141}));
1142 return Value::Map({
1143 let mut m = indexmap::IndexMap::new();
1144 m.insert("url".to_string(), Value::Null);
1145 m.insert("method".to_string(), Value::Null);
1146 m.insert("headers".to_string(), Value::Null);
1147 m.insert("body".to_string(), Value::Null);
1148 m
1149});
1150
1151 Value::Null
1152}
1153
1154 fn fetch_accounts(&mut self, optional_args: &[Value]) -> impl ::std::future::Future<Output = Value> + Send { async move {
1155 let mut params = get_arg(optional_args, 0, Value::Map({
1156 let mut m = indexmap::IndexMap::new();
1157 m
1158}));
1159 panic!("{}", crate::exchange_errors::not_supported(format!("{}{}", self.id.clone(), Value::Str(" fetchAccounts() is not supported yet".into()))));
1160
1161 Value::Null
1162} }
1163
1164 fn watch_liquidations(&mut self, mut symbol: Value, optional_args: &[Value]) -> impl ::std::future::Future<Output = Value> + Send { async move {
1165 let mut since = get_arg(optional_args, 0, Value::Null);
1166 let mut limit = get_arg(optional_args, 1, Value::Null);
1167 let mut params = get_arg(optional_args, 2, Value::Map({
1168 let mut m = indexmap::IndexMap::new();
1169 m
1170}));
1171 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)) {
1172 return self.watch_liquidations_for_symbols(Value::from(vec![symbol]), &[since, limit, params]).await;
1173 }
1174 panic!("{}", crate::exchange_errors::not_supported(format!("{}{}", self.id.clone(), Value::Str(" watchLiquidations() is not supported yet".into()))));
1175
1176 Value::Null
1177} }
1178
1179 fn watch_liquidations_for_symbols(&mut self, mut symbols: Value, optional_args: &[Value]) -> impl ::std::future::Future<Output = Value> + Send { async move {
1180 let mut since = get_arg(optional_args, 0, Value::Null);
1181 let mut limit = get_arg(optional_args, 1, Value::Null);
1182 let mut params = get_arg(optional_args, 2, Value::Map({
1183 let mut m = indexmap::IndexMap::new();
1184 m
1185}));
1186 panic!("{}", crate::exchange_errors::not_supported(format!("{}{}", self.id.clone(), Value::Str(" watchLiquidationsForSymbols() is not supported yet".into()))));
1187
1188 Value::Null
1189} }
1190
1191 fn watch_my_liquidations(&mut self, mut symbol: Value, optional_args: &[Value]) -> impl ::std::future::Future<Output = Value> + Send { async move {
1192 let mut since = get_arg(optional_args, 0, Value::Null);
1193 let mut limit = get_arg(optional_args, 1, Value::Null);
1194 let mut params = get_arg(optional_args, 2, Value::Map({
1195 let mut m = indexmap::IndexMap::new();
1196 m
1197}));
1198 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)) {
1199 return self.watch_my_liquidations_for_symbols(Value::from(vec![symbol]), &[since, limit, params]).await;
1200 }
1201 panic!("{}", crate::exchange_errors::not_supported(format!("{}{}", self.id.clone(), Value::Str(" watchMyLiquidations() is not supported yet".into()))));
1202
1203 Value::Null
1204} }
1205
1206 fn watch_my_liquidations_for_symbols(&mut self, mut symbols: Value, optional_args: &[Value]) -> impl ::std::future::Future<Output = Value> + Send { async move {
1207 let mut since = get_arg(optional_args, 0, Value::Null);
1208 let mut limit = get_arg(optional_args, 1, Value::Null);
1209 let mut params = get_arg(optional_args, 2, Value::Map({
1210 let mut m = indexmap::IndexMap::new();
1211 m
1212}));
1213 panic!("{}", crate::exchange_errors::not_supported(format!("{}{}", self.id.clone(), Value::Str(" watchMyLiquidationsForSymbols() is not supported yet".into()))));
1214
1215 Value::Null
1216} }
1217
1218 fn un_watch_orders(&mut self, optional_args: &[Value]) -> impl ::std::future::Future<Output = Value> + Send { async move {
1219 let mut symbol = get_arg(optional_args, 0, Value::Null);
1220 let mut params = get_arg(optional_args, 1, Value::Map({
1221 let mut m = indexmap::IndexMap::new();
1222 m
1223}));
1224 panic!("{}", crate::exchange_errors::not_supported(format!("{}{}", self.id.clone(), Value::Str(" unWatchOrders() is not supported yet".into()))));
1225
1226 Value::Null
1227} }
1228
1229 fn un_watch_trades(&mut self, mut symbol: Value, optional_args: &[Value]) -> impl ::std::future::Future<Output = Value> + Send { async move {
1230 let mut params = get_arg(optional_args, 0, Value::Map({
1231 let mut m = indexmap::IndexMap::new();
1232 m
1233}));
1234 panic!("{}", crate::exchange_errors::not_supported(format!("{}{}", self.id.clone(), Value::Str(" unWatchTrades() is not supported yet".into()))));
1235
1236 Value::Null
1237} }
1238
1239 fn un_watch_trades_for_symbols(&mut self, mut symbols: Value, optional_args: &[Value]) -> impl ::std::future::Future<Output = Value> + Send { async move {
1240 let mut params = get_arg(optional_args, 0, Value::Map({
1241 let mut m = indexmap::IndexMap::new();
1242 m
1243}));
1244 panic!("{}", crate::exchange_errors::not_supported(format!("{}{}", self.id.clone(), Value::Str(" unWatchTradesForSymbols() is not supported yet".into()))));
1245
1246 Value::Null
1247} }
1248
1249 fn watch_ohlcv_for_symbols(&mut self, mut symbolsAndTimeframes: Value, optional_args: &[Value]) -> impl ::std::future::Future<Output = Value> + Send { async move {
1250 let mut since = get_arg(optional_args, 0, Value::Null);
1251 let mut limit = get_arg(optional_args, 1, Value::Null);
1252 let mut params = get_arg(optional_args, 2, Value::Map({
1253 let mut m = indexmap::IndexMap::new();
1254 m
1255}));
1256 panic!("{}", crate::exchange_errors::not_supported(format!("{}{}", self.id.clone(), Value::Str(" watchOHLCVForSymbols() is not supported yet".into()))));
1257
1258 Value::Null
1259} }
1260
1261 fn un_watch_ohlcv_for_symbols(&mut self, mut symbolsAndTimeframes: Value, optional_args: &[Value]) -> impl ::std::future::Future<Output = Value> + Send { async move {
1262 let mut params = get_arg(optional_args, 0, Value::Map({
1263 let mut m = indexmap::IndexMap::new();
1264 m
1265}));
1266 panic!("{}", crate::exchange_errors::not_supported(format!("{}{}", self.id.clone(), Value::Str(" unWatchOHLCVForSymbols() is not supported yet".into()))));
1267
1268 Value::Null
1269} }
1270
1271 fn un_watch_order_book_for_symbols(&mut self, mut symbols: Value, optional_args: &[Value]) -> impl ::std::future::Future<Output = Value> + Send { async move {
1272 let mut params = get_arg(optional_args, 0, Value::Map({
1273 let mut m = indexmap::IndexMap::new();
1274 m
1275}));
1276 panic!("{}", crate::exchange_errors::not_supported(format!("{}{}", self.id.clone(), Value::Str(" unWatchOrderBookForSymbols() is not supported yet".into()))));
1277
1278 Value::Null
1279} }
1280
1281 fn un_watch_positions(&mut self, optional_args: &[Value]) -> impl ::std::future::Future<Output = Value> + Send { async move {
1282 let mut symbols = get_arg(optional_args, 0, Value::Null);
1283 let mut params = get_arg(optional_args, 1, Value::Map({
1284 let mut m = indexmap::IndexMap::new();
1285 m
1286}));
1287 panic!("{}", crate::exchange_errors::not_supported(format!("{}{}", self.id.clone(), Value::Str(" unWatchPositions() is not supported yet".into()))));
1288
1289 Value::Null
1290} }
1291
1292 fn un_watch_ticker(&mut self, mut symbol: Value, optional_args: &[Value]) -> impl ::std::future::Future<Output = Value> + Send { async move {
1293 let mut params = get_arg(optional_args, 0, Value::Map({
1294 let mut m = indexmap::IndexMap::new();
1295 m
1296}));
1297 panic!("{}", crate::exchange_errors::not_supported(format!("{}{}", self.id.clone(), Value::Str(" unWatchTicker() is not supported yet".into()))));
1298
1299 Value::Null
1300} }
1301
1302 fn un_watch_mark_price(&mut self, mut symbol: Value, optional_args: &[Value]) -> impl ::std::future::Future<Output = Value> + Send { async move {
1303 let mut params = get_arg(optional_args, 0, Value::Map({
1304 let mut m = indexmap::IndexMap::new();
1305 m
1306}));
1307 panic!("{}", crate::exchange_errors::not_supported(format!("{}{}", self.id.clone(), Value::Str(" unWatchMarkPrice() is not supported yet".into()))));
1308
1309 Value::Null
1310} }
1311
1312 fn un_watch_mark_prices(&mut self, optional_args: &[Value]) -> impl ::std::future::Future<Output = Value> + Send { async move {
1313 let mut symbols = get_arg(optional_args, 0, Value::Null);
1314 let mut params = get_arg(optional_args, 1, Value::Map({
1315 let mut m = indexmap::IndexMap::new();
1316 m
1317}));
1318 panic!("{}", crate::exchange_errors::not_supported(format!("{}{}", self.id.clone(), Value::Str(" unWatchMarkPrices() is not supported yet".into()))));
1319
1320 Value::Null
1321} }
1322
1323 fn fetch_deposit_addresses(&mut self, optional_args: &[Value]) -> impl ::std::future::Future<Output = Value> + Send { async move {
1324 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 {
1326 if !matches!(__v, crate::Value::Null) { return __v; }
1327 }
1328
1329 let mut codes = get_arg(optional_args, 0, Value::Null);
1330 let mut params = get_arg(optional_args, 1, Value::Map({
1331 let mut m = indexmap::IndexMap::new();
1332 m
1333}));
1334 panic!("{}", crate::exchange_errors::not_supported(format!("{}{}", self.id.clone(), Value::Str(" fetchDepositAddresses() is not supported yet".into()))));
1335
1336 Value::Null
1337} }
1338
1339 fn fetch_margin_mode(&mut self, mut symbol: Value, optional_args: &[Value]) -> impl ::std::future::Future<Output = Value> + Send { async move {
1340 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 {
1342 if !matches!(__v, crate::Value::Null) { return __v; }
1343 }
1344
1345 let mut params = get_arg(optional_args, 0, Value::Map({
1346 let mut m = indexmap::IndexMap::new();
1347 m
1348}));
1349 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)) {
1350 let mut marginModes: Value = self.fetch_margin_modes(&[Value::from(vec![symbol.clone()]), params]).await;
1351 let mut marginMode: Value = self.safe_dict(marginModes, symbol, &[]);
1352 return marginMode;
1353 } else {
1354 panic!("{}", crate::exchange_errors::not_supported(format!("{}{}", self.id.clone(), Value::Str(" fetchMarginMode() is not supported yet".into()))));
1355 }
1356
1357 Value::Null
1358} }
1359
1360 fn fetch_margin_modes(&mut self, optional_args: &[Value]) -> impl ::std::future::Future<Output = Value> + Send { async move {
1361 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 {
1363 if !matches!(__v, crate::Value::Null) { return __v; }
1364 }
1365
1366 let mut symbols = get_arg(optional_args, 0, Value::Null);
1367 let mut params = get_arg(optional_args, 1, Value::Map({
1368 let mut m = indexmap::IndexMap::new();
1369 m
1370}));
1371 panic!("{}", crate::exchange_errors::not_supported(format!("{}{}", self.id.clone(), Value::Str(" fetchMarginModes () is not supported yet".into()))));
1372
1373 Value::Null
1374} }
1375
1376 fn un_watch_order_book(&mut self, mut symbol: Value, optional_args: &[Value]) -> impl ::std::future::Future<Output = Value> + Send { async move {
1377 let mut params = get_arg(optional_args, 0, Value::Map({
1378 let mut m = indexmap::IndexMap::new();
1379 m
1380}));
1381 panic!("{}", crate::exchange_errors::not_supported(format!("{}{}", self.id.clone(), Value::Str(" unWatchOrderBook() is not supported yet".into()))));
1382
1383 Value::Null
1384} }
1385
1386 fn fetch_time(&mut self, optional_args: &[Value]) -> impl ::std::future::Future<Output = Value> + Send { async move {
1387 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 {
1389 if !matches!(__v, crate::Value::Null) { return __v; }
1390 }
1391
1392 let mut params = get_arg(optional_args, 0, Value::Map({
1393 let mut m = indexmap::IndexMap::new();
1394 m
1395}));
1396 panic!("{}", crate::exchange_errors::not_supported(format!("{}{}", self.id.clone(), Value::Str(" fetchTime() is not supported yet".into()))));
1397
1398 Value::Null
1399} }
1400
1401 fn fetch_trading_limits(&mut self, optional_args: &[Value]) -> impl ::std::future::Future<Output = Value> + Send { async move {
1402 let mut symbols = get_arg(optional_args, 0, Value::Null);
1403 let mut params = get_arg(optional_args, 1, Value::Map({
1404 let mut m = indexmap::IndexMap::new();
1405 m
1406}));
1407 panic!("{}", crate::exchange_errors::not_supported(format!("{}{}", self.id.clone(), Value::Str(" fetchTradingLimits() is not supported yet".into()))));
1408
1409 Value::Null
1410} }
1411
1412 fn parse_currency(&self, mut rawCurrency: Value) -> Value {
1413 { let __v = crate::exchange::DerivedExchange::parse_currency(self, rawCurrency); if !matches!(__v, crate::Value::Null) { return __v; } }
1415
1416 panic!("{}", crate::exchange_errors::not_supported(format!("{}{}", self.id.clone(), Value::Str(" parseCurrency() is not supported yet".into()))));
1417
1418 Value::Null
1419}
1420
1421 fn parse_currencies(&self, mut rawCurrencies: Value) -> Value {
1422 let mut result: indexmap::IndexMap<String, Value> = ({
1423 let mut m = indexmap::IndexMap::new();
1424 m
1425 });
1426 let mut arr: Value = self.to_array(rawCurrencies);
1427 {
1428 let mut i: i64 = 0;
1429 let mut __for_first_79: bool = true;
1430 while { if !__for_first_79 { i += 1; } __for_first_79 = false; i < (arr.len() as i64) } {
1431 let mut parsed: Value = <Self as crate::exchange_generated::ExchangeBase>::parse_currency(self, arr.as_array().map(Vec::as_slice).unwrap_or_default().get(i as usize).cloned().unwrap_or(Value::Null));
1432 if (parsed == Value::Null) {
1433 continue;
1434 }
1435 let mut code: Value = parsed.as_map().and_then(|__m| __m.get("code")).cloned().unwrap_or(Value::Null);
1436 result.insert(crate::runtime::stringify_param(&code), parsed);
1437 }
1438 }
1439 return Value::Map(result);
1440
1441 Value::Null
1442}
1443
1444 fn parse_market(&self, mut market: Value) -> Value {
1445 { let __v = crate::exchange::DerivedExchange::parse_market(self, market); if !matches!(__v, crate::Value::Null) { return __v; } }
1447
1448 panic!("{}", crate::exchange_errors::not_supported(format!("{}{}", self.id.clone(), Value::Str(" parseMarket() is not supported yet".into()))));
1449
1450 Value::Null
1451}
1452
1453 fn parse_markets(&self, mut markets: Value) -> Value {
1454 let mut result: Vec<Value> = Vec::new();
1455 {
1456 let mut i: Value = Value::Int(0);
1457 let mut __for_first_80: bool = true;
1458 while { if !__for_first_80 { if let Value::Int(n) = &mut i { *n += 1; } } __for_first_80 = false; i.as_f64().unwrap_or(f64::NAN) < get_array_length(&markets).as_f64().unwrap_or(f64::NAN) } {
1459 let mut market: Value = <Self as crate::exchange_generated::ExchangeBase>::parse_market(self, get_value(&markets, &i));
1460 if (market != Value::Null) {
1462 result.push(market);
1463 }
1464 }
1465 }
1466 return Value::from(result);
1467
1468 Value::Null
1469}
1470
1471 fn parse_ticker(&self, mut ticker: Value, optional_args: &[Value]) -> Value {
1472 { 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; } }
1474
1475 let mut market = get_arg(optional_args, 0, Value::Null);
1476 panic!("{}", crate::exchange_errors::not_supported(format!("{}{}", self.id.clone(), Value::Str(" parseTicker() is not supported yet".into()))));
1477
1478 Value::Null
1479}
1480
1481 fn parse_deposit_address(&self, mut depositAddress: Value, optional_args: &[Value]) -> Value {
1482 { 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; } }
1484
1485 let mut currency = get_arg(optional_args, 0, Value::Null);
1486 panic!("{}", crate::exchange_errors::not_supported(format!("{}{}", self.id.clone(), Value::Str(" parseDepositAddress() is not supported yet".into()))));
1487
1488 Value::Null
1489}
1490
1491 fn parse_trade(&self, mut trade: Value, optional_args: &[Value]) -> Value {
1492 { 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; } }
1494
1495 let mut market = get_arg(optional_args, 0, Value::Null);
1496 panic!("{}", crate::exchange_errors::not_supported(format!("{}{}", self.id.clone(), Value::Str(" parseTrade() is not supported yet".into()))));
1497
1498 Value::Null
1499}
1500
1501 fn parse_transaction(&self, mut transaction: Value, optional_args: &[Value]) -> Value {
1502 { 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; } }
1504
1505 let mut currency = get_arg(optional_args, 0, Value::Null);
1506 panic!("{}", crate::exchange_errors::not_supported(format!("{}{}", self.id.clone(), Value::Str(" parseTransaction() is not supported yet".into()))));
1507
1508 Value::Null
1509}
1510
1511 fn parse_transfer(&self, mut transfer: Value, optional_args: &[Value]) -> Value {
1512 { 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; } }
1514
1515 let mut currency = get_arg(optional_args, 0, Value::Null);
1516 if (transfer == Value::Null) {
1517 panic!("{}", crate::exchange_errors::not_supported(format!("{}{}", self.id.clone(), Value::Str(" parseTransfer() is not supported yet".into()))));
1518 }
1519 panic!("{}", crate::exchange_errors::not_supported(format!("{}{}", self.id.clone(), Value::Str(" parseTransfer() is not supported yet".into()))));
1520
1521 Value::Null
1522}
1523
1524 fn parse_account(&self, mut account: Value) -> Value {
1525 { let __v = crate::exchange::DerivedExchange::parse_account(self, account); if !matches!(__v, crate::Value::Null) { return __v; } }
1527
1528 panic!("{}", crate::exchange_errors::not_supported(format!("{}{}", self.id.clone(), Value::Str(" parseAccount() is not supported yet".into()))));
1529
1530 Value::Null
1531}
1532
1533 fn parse_ledger_entry(&self, mut item: Value, optional_args: &[Value]) -> Value {
1534 { 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; } }
1536
1537 let mut currency = get_arg(optional_args, 0, Value::Null);
1538 panic!("{}", crate::exchange_errors::not_supported(format!("{}{}", self.id.clone(), Value::Str(" parseLedgerEntry() is not supported yet".into()))));
1539
1540 Value::Null
1541}
1542
1543 fn parse_order(&self, mut order: Value, optional_args: &[Value]) -> Value {
1544 { 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; } }
1546
1547 let mut market = get_arg(optional_args, 0, Value::Null);
1548 panic!("{}", crate::exchange_errors::not_supported(format!("{}{}", self.id.clone(), Value::Str(" parseOrder() is not supported yet".into()))));
1549
1550 Value::Null
1551}
1552
1553 fn fetch_cross_borrow_rates(&mut self, optional_args: &[Value]) -> impl ::std::future::Future<Output = Value> + Send { async move {
1554 let mut params = get_arg(optional_args, 0, Value::Map({
1555 let mut m = indexmap::IndexMap::new();
1556 m
1557}));
1558 panic!("{}", crate::exchange_errors::not_supported(format!("{}{}", self.id.clone(), Value::Str(" fetchCrossBorrowRates() is not supported yet".into()))));
1559
1560 Value::Null
1561} }
1562
1563 fn fetch_isolated_borrow_rates(&mut self, optional_args: &[Value]) -> impl ::std::future::Future<Output = Value> + Send { async move {
1564 let mut params = get_arg(optional_args, 0, Value::Map({
1565 let mut m = indexmap::IndexMap::new();
1566 m
1567}));
1568 panic!("{}", crate::exchange_errors::not_supported(format!("{}{}", self.id.clone(), Value::Str(" fetchIsolatedBorrowRates() is not supported yet".into()))));
1569
1570 Value::Null
1571} }
1572
1573 fn parse_market_leverage_tiers(&self, mut info: Value, optional_args: &[Value]) -> Value {
1574 { 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; } }
1576
1577 let mut market = get_arg(optional_args, 0, Value::Null);
1578 panic!("{}", crate::exchange_errors::not_supported(format!("{}{}", self.id.clone(), Value::Str(" parseMarketLeverageTiers() is not supported yet".into()))));
1579
1580 Value::Null
1581}
1582
1583 fn fetch_leverage_tiers(&mut self, optional_args: &[Value]) -> impl ::std::future::Future<Output = Value> + Send { async move {
1584 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 {
1586 if !matches!(__v, crate::Value::Null) { return __v; }
1587 }
1588
1589 let mut symbols = get_arg(optional_args, 0, Value::Null);
1590 let mut params = get_arg(optional_args, 1, Value::Map({
1591 let mut m = indexmap::IndexMap::new();
1592 m
1593}));
1594 panic!("{}", crate::exchange_errors::not_supported(format!("{}{}", self.id.clone(), Value::Str(" fetchLeverageTiers() is not supported yet".into()))));
1595
1596 Value::Null
1597} }
1598
1599 fn parse_position(&self, mut position: Value, optional_args: &[Value]) -> Value {
1600 { 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; } }
1602
1603 let mut market = get_arg(optional_args, 0, Value::Null);
1604 panic!("{}", crate::exchange_errors::not_supported(format!("{}{}", self.id.clone(), Value::Str(" parsePosition() is not supported yet".into()))));
1605
1606 Value::Null
1607}
1608
1609 fn parse_funding_rate_history(&self, mut info: Value, optional_args: &[Value]) -> Value {
1610 { 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; } }
1612
1613 let mut market = get_arg(optional_args, 0, Value::Null);
1614 panic!("{}", crate::exchange_errors::not_supported(format!("{}{}", self.id.clone(), Value::Str(" parseFundingRateHistory() is not supported yet".into()))));
1615
1616 Value::Null
1617}
1618
1619 fn parse_borrow_interest(&self, mut info: Value, optional_args: &[Value]) -> Value {
1620 { 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; } }
1622
1623 let mut market = get_arg(optional_args, 0, Value::Null);
1624 panic!("{}", crate::exchange_errors::not_supported(format!("{}{}", self.id.clone(), Value::Str(" parseBorrowInterest() is not supported yet".into()))));
1625
1626 Value::Null
1627}
1628
1629 fn parse_isolated_borrow_rate(&self, mut info: Value, optional_args: &[Value]) -> Value {
1630 let mut market = get_arg(optional_args, 0, Value::Null);
1631 panic!("{}", crate::exchange_errors::not_supported(format!("{}{}", self.id.clone(), Value::Str(" parseIsolatedBorrowRate() is not supported yet".into()))));
1632
1633 Value::Null
1634}
1635
1636 fn parse_ws_trade(&self, mut trade: Value, optional_args: &[Value]) -> Value {
1637 let mut market = get_arg(optional_args, 0, Value::Null);
1638 panic!("{}", crate::exchange_errors::not_supported(format!("{}{}", self.id.clone(), Value::Str(" parseWsTrade() is not supported yet".into()))));
1639
1640 Value::Null
1641}
1642
1643 fn parse_ws_order(&self, mut order: Value, optional_args: &[Value]) -> Value {
1644 let mut market = get_arg(optional_args, 0, Value::Null);
1645 panic!("{}", crate::exchange_errors::not_supported(format!("{}{}", self.id.clone(), Value::Str(" parseWsOrder() is not supported yet".into()))));
1646
1647 Value::Null
1648}
1649
1650 fn parse_ws_order_trade(&self, mut trade: Value, optional_args: &[Value]) -> Value {
1651 let mut market = get_arg(optional_args, 0, Value::Null);
1652 panic!("{}", crate::exchange_errors::not_supported(format!("{}{}", self.id.clone(), Value::Str(" parseWsOrderTrade() is not supported yet".into()))));
1653
1654 Value::Null
1655}
1656
1657 fn parse_ws_ohlcv(&self, mut ohlcv: Value, optional_args: &[Value]) -> Value {
1658 let mut market = get_arg(optional_args, 0, Value::Null);
1659 return <Self as crate::exchange_generated::ExchangeBase>::parse_ohlcv(self, ohlcv, &[market]);
1660
1661 Value::Null
1662}
1663
1664 fn fetch_funding_rates(&mut self, optional_args: &[Value]) -> impl ::std::future::Future<Output = Value> + Send { async move {
1665 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 {
1667 if !matches!(__v, crate::Value::Null) { return __v; }
1668 }
1669
1670 let mut symbols = get_arg(optional_args, 0, Value::Null);
1671 let mut params = get_arg(optional_args, 1, Value::Map({
1672 let mut m = indexmap::IndexMap::new();
1673 m
1674}));
1675 panic!("{}", crate::exchange_errors::not_supported(format!("{}{}", self.id.clone(), Value::Str(" fetchFundingRates() is not supported yet".into()))));
1676
1677 Value::Null
1678} }
1679
1680 fn fetch_funding_intervals(&mut self, optional_args: &[Value]) -> impl ::std::future::Future<Output = Value> + Send { async move {
1681 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 {
1683 if !matches!(__v, crate::Value::Null) { return __v; }
1684 }
1685
1686 let mut symbols = get_arg(optional_args, 0, Value::Null);
1687 let mut params = get_arg(optional_args, 1, Value::Map({
1688 let mut m = indexmap::IndexMap::new();
1689 m
1690}));
1691 panic!("{}", crate::exchange_errors::not_supported(format!("{}{}", self.id.clone(), Value::Str(" fetchFundingIntervals() is not supported yet".into()))));
1692
1693 Value::Null
1694} }
1695
1696 fn watch_funding_rate(&mut self, mut symbol: Value, optional_args: &[Value]) -> impl ::std::future::Future<Output = Value> + Send { async move {
1697 let mut params = get_arg(optional_args, 0, Value::Map({
1698 let mut m = indexmap::IndexMap::new();
1699 m
1700}));
1701 panic!("{}", crate::exchange_errors::not_supported(format!("{}{}", self.id.clone(), Value::Str(" watchFundingRate() is not supported yet".into()))));
1702
1703 Value::Null
1704} }
1705
1706 fn watch_funding_rates(&mut self, optional_args: &[Value]) -> impl ::std::future::Future<Output = Value> + Send { async move {
1707 let mut symbols = get_arg(optional_args, 0, Value::Null);
1708 let mut params = get_arg(optional_args, 1, Value::Map({
1709 let mut m = indexmap::IndexMap::new();
1710 m
1711}));
1712 panic!("{}", crate::exchange_errors::not_supported(format!("{}{}", self.id.clone(), Value::Str(" watchFundingRates() is not supported yet".into()))));
1713
1714 Value::Null
1715} }
1716
1717 fn un_watch_funding_rates(&mut self, optional_args: &[Value]) -> impl ::std::future::Future<Output = Value> + Send { async move {
1718 let mut symbols = get_arg(optional_args, 0, Value::Null);
1719 let mut params = get_arg(optional_args, 1, Value::Map({
1720 let mut m = indexmap::IndexMap::new();
1721 m
1722}));
1723 panic!("{}", crate::exchange_errors::not_supported(format!("{}{}", self.id.clone(), Value::Str(" unWatchFundingRates() is not supported yet".into()))));
1724
1725 Value::Null
1726} }
1727
1728 fn watch_funding_rates_for_symbols(&mut self, mut symbols: Value, optional_args: &[Value]) -> impl ::std::future::Future<Output = Value> + Send { async move {
1729 let mut params = get_arg(optional_args, 0, Value::Map({
1730 let mut m = indexmap::IndexMap::new();
1731 m
1732}));
1733 return self.watch_funding_rates(&[symbols, params]).await;
1734
1735 Value::Null
1736} }
1737
1738 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 {
1739 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 {
1741 if !matches!(__v, crate::Value::Null) { return __v; }
1742 }
1743
1744 let mut params = get_arg(optional_args, 0, Value::Map({
1745 let mut m = indexmap::IndexMap::new();
1746 m
1747}));
1748 panic!("{}", crate::exchange_errors::not_supported(format!("{}{}", self.id.clone(), Value::Str(" transfer() is not supported yet".into()))));
1749
1750 Value::Null
1751} }
1752
1753 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 {
1754 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 {
1756 if !matches!(__v, crate::Value::Null) { return __v; }
1757 }
1758
1759 let mut params = get_arg(optional_args, 0, Value::Map({
1760 let mut m = indexmap::IndexMap::new();
1761 m
1762}));
1763 panic!("{}", crate::exchange_errors::not_supported(format!("{}{}", self.id.clone(), Value::Str(" withdraw() is not supported yet".into()))));
1764
1765 Value::Null
1766} }
1767
1768 fn create_deposit_address(&mut self, mut code: Value, optional_args: &[Value]) -> impl ::std::future::Future<Output = Value> + Send { async move {
1769 let mut params = get_arg(optional_args, 0, Value::Map({
1770 let mut m = indexmap::IndexMap::new();
1771 m
1772}));
1773 panic!("{}", crate::exchange_errors::not_supported(format!("{}{}", self.id.clone(), Value::Str(" createDepositAddress() is not supported yet".into()))));
1774
1775 Value::Null
1776} }
1777
1778 fn set_leverage(&mut self, mut leverage: Value, optional_args: &[Value]) -> impl ::std::future::Future<Output = Value> + Send { async move {
1779 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 {
1781 if !matches!(__v, crate::Value::Null) { return __v; }
1782 }
1783
1784 let mut symbol = get_arg(optional_args, 0, Value::Null);
1785 let mut params = get_arg(optional_args, 1, Value::Map({
1786 let mut m = indexmap::IndexMap::new();
1787 m
1788}));
1789 panic!("{}", crate::exchange_errors::not_supported(format!("{}{}", self.id.clone(), Value::Str(" setLeverage() is not supported yet".into()))));
1790
1791 Value::Null
1792} }
1793
1794 fn fetch_leverage(&mut self, mut symbol: Value, optional_args: &[Value]) -> impl ::std::future::Future<Output = Value> + Send { async move {
1795 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 {
1797 if !matches!(__v, crate::Value::Null) { return __v; }
1798 }
1799
1800 let mut params = get_arg(optional_args, 0, Value::Map({
1801 let mut m = indexmap::IndexMap::new();
1802 m
1803}));
1804 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)) {
1805 let mut leverages: Value = self.fetch_leverages(&[Value::from(vec![symbol.clone()]), params]).await;
1806 let mut leverage: Value = self.safe_dict(leverages, symbol, &[]);
1807 return leverage;
1808 } else {
1809 panic!("{}", crate::exchange_errors::not_supported(format!("{}{}", self.id.clone(), Value::Str(" fetchLeverage() is not supported yet".into()))));
1810 }
1811
1812 Value::Null
1813} }
1814
1815 fn fetch_leverages(&mut self, optional_args: &[Value]) -> impl ::std::future::Future<Output = Value> + Send { async move {
1816 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 {
1818 if !matches!(__v, crate::Value::Null) { return __v; }
1819 }
1820
1821 let mut symbols = get_arg(optional_args, 0, Value::Null);
1822 let mut params = get_arg(optional_args, 1, Value::Map({
1823 let mut m = indexmap::IndexMap::new();
1824 m
1825}));
1826 panic!("{}", crate::exchange_errors::not_supported(format!("{}{}", self.id.clone(), Value::Str(" fetchLeverages() is not supported yet".into()))));
1827
1828 Value::Null
1829} }
1830
1831 fn set_position_mode(&mut self, mut hedged: Value, optional_args: &[Value]) -> impl ::std::future::Future<Output = Value> + Send { async move {
1832 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 {
1834 if !matches!(__v, crate::Value::Null) { return __v; }
1835 }
1836
1837 let mut symbol = get_arg(optional_args, 0, Value::Null);
1838 let mut params = get_arg(optional_args, 1, Value::Map({
1839 let mut m = indexmap::IndexMap::new();
1840 m
1841}));
1842 panic!("{}", crate::exchange_errors::not_supported(format!("{}{}", self.id.clone(), Value::Str(" setPositionMode() is not supported yet".into()))));
1843
1844 Value::Null
1845} }
1846
1847 fn add_margin(&mut self, mut symbol: Value, mut amount: Value, optional_args: &[Value]) -> impl ::std::future::Future<Output = Value> + Send { async move {
1848 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 {
1850 if !matches!(__v, crate::Value::Null) { return __v; }
1851 }
1852
1853 let mut params = get_arg(optional_args, 0, Value::Map({
1854 let mut m = indexmap::IndexMap::new();
1855 m
1856}));
1857 panic!("{}", crate::exchange_errors::not_supported(format!("{}{}", self.id.clone(), Value::Str(" addMargin() is not supported yet".into()))));
1858
1859 Value::Null
1860} }
1861
1862 fn reduce_margin(&mut self, mut symbol: Value, mut amount: Value, optional_args: &[Value]) -> impl ::std::future::Future<Output = Value> + Send { async move {
1863 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 {
1865 if !matches!(__v, crate::Value::Null) { return __v; }
1866 }
1867
1868 let mut params = get_arg(optional_args, 0, Value::Map({
1869 let mut m = indexmap::IndexMap::new();
1870 m
1871}));
1872 panic!("{}", crate::exchange_errors::not_supported(format!("{}{}", self.id.clone(), Value::Str(" reduceMargin() is not supported yet".into()))));
1873
1874 Value::Null
1875} }
1876
1877 fn set_margin(&mut self, mut symbol: Value, mut amount: Value, optional_args: &[Value]) -> impl ::std::future::Future<Output = Value> + Send { async move {
1878 let mut params = get_arg(optional_args, 0, Value::Map({
1879 let mut m = indexmap::IndexMap::new();
1880 m
1881}));
1882 panic!("{}", crate::exchange_errors::not_supported(format!("{}{}", self.id.clone(), Value::Str(" setMargin() is not supported yet".into()))));
1883
1884 Value::Null
1885} }
1886
1887 fn fetch_long_short_ratio(&mut self, mut symbol: Value, optional_args: &[Value]) -> impl ::std::future::Future<Output = Value> + Send { async move {
1888 let mut timeframe = get_arg(optional_args, 0, Value::Null);
1889 let mut params = get_arg(optional_args, 1, Value::Map({
1890 let mut m = indexmap::IndexMap::new();
1891 m
1892}));
1893 panic!("{}", crate::exchange_errors::not_supported(format!("{}{}", self.id.clone(), Value::Str(" fetchLongShortRatio() is not supported yet".into()))));
1894
1895 Value::Null
1896} }
1897
1898 fn fetch_long_short_ratio_history(&mut self, optional_args: &[Value]) -> impl ::std::future::Future<Output = Value> + Send { async move {
1899 let mut symbol = get_arg(optional_args, 0, Value::Null);
1900 let mut timeframe = get_arg(optional_args, 1, Value::Null);
1901 let mut since = get_arg(optional_args, 2, Value::Null);
1902 let mut limit = get_arg(optional_args, 3, Value::Null);
1903 let mut params = get_arg(optional_args, 4, Value::Map({
1904 let mut m = indexmap::IndexMap::new();
1905 m
1906}));
1907 panic!("{}", crate::exchange_errors::not_supported(format!("{}{}", self.id.clone(), Value::Str(" fetchLongShortRatioHistory() is not supported yet".into()))));
1908
1909 Value::Null
1910} }
1911
1912 fn fetch_margin_adjustment_history(&mut self, optional_args: &[Value]) -> impl ::std::future::Future<Output = Value> + Send { async move {
1913 let mut symbol = get_arg(optional_args, 0, Value::Null);
1914 let mut type_var = get_arg(optional_args, 1, Value::Null);
1915 let mut since = get_arg(optional_args, 2, Value::Null);
1916 let mut limit = get_arg(optional_args, 3, Value::Null);
1917 let mut params = get_arg(optional_args, 4, Value::Map({
1918 let mut m = indexmap::IndexMap::new();
1919 m
1920}));
1921 panic!("{}", crate::exchange_errors::not_supported(format!("{}{}", self.id.clone(), Value::Str(" fetchMarginAdjustmentHistory() is not supported yet".into()))));
1922
1923 Value::Null
1924} }
1925
1926 fn set_margin_mode(&mut self, mut marginMode: Value, optional_args: &[Value]) -> impl ::std::future::Future<Output = Value> + Send { async move {
1927 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 {
1929 if !matches!(__v, crate::Value::Null) { return __v; }
1930 }
1931
1932 let mut symbol = get_arg(optional_args, 0, Value::Null);
1933 let mut params = get_arg(optional_args, 1, Value::Map({
1934 let mut m = indexmap::IndexMap::new();
1935 m
1936}));
1937 panic!("{}", crate::exchange_errors::not_supported(format!("{}{}", self.id.clone(), Value::Str(" setMarginMode() is not supported yet".into()))));
1938
1939 Value::Null
1940} }
1941
1942 fn fetch_deposit_addresses_by_network(&mut self, mut code: Value, optional_args: &[Value]) -> impl ::std::future::Future<Output = Value> + Send { async move {
1943 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 {
1945 if !matches!(__v, crate::Value::Null) { return __v; }
1946 }
1947
1948 let mut params = get_arg(optional_args, 0, Value::Map({
1949 let mut m = indexmap::IndexMap::new();
1950 m
1951}));
1952 panic!("{}", crate::exchange_errors::not_supported(format!("{}{}", self.id.clone(), Value::Str(" fetchDepositAddressesByNetwork() is not supported yet".into()))));
1953
1954 Value::Null
1955} }
1956
1957 fn fetch_open_interest_history(&mut self, mut symbol: Value, optional_args: &[Value]) -> impl ::std::future::Future<Output = Value> + Send { async move {
1958 let mut timeframe = get_arg(optional_args, 0, Value::Str("1h".into()));
1959 let mut since = get_arg(optional_args, 1, Value::Null);
1960 let mut limit = get_arg(optional_args, 2, Value::Null);
1961 let mut params = get_arg(optional_args, 3, Value::Map({
1962 let mut m = indexmap::IndexMap::new();
1963 m
1964}));
1965 panic!("{}", crate::exchange_errors::not_supported(format!("{}{}", self.id.clone(), Value::Str(" fetchOpenInterestHistory() is not supported yet".into()))));
1966
1967 Value::Null
1968} }
1969
1970 fn fetch_open_interests(&mut self, optional_args: &[Value]) -> impl ::std::future::Future<Output = Value> + Send { async move {
1971 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 {
1973 if !matches!(__v, crate::Value::Null) { return __v; }
1974 }
1975
1976 let mut symbols = get_arg(optional_args, 0, Value::Null);
1977 let mut params = get_arg(optional_args, 1, Value::Map({
1978 let mut m = indexmap::IndexMap::new();
1979 m
1980}));
1981 panic!("{}", crate::exchange_errors::not_supported(format!("{}{}", self.id.clone(), Value::Str(" fetchOpenInterests() is not supported yet".into()))));
1982
1983 Value::Null
1984} }
1985
1986 fn sign_in(&mut self, optional_args: &[Value]) -> impl ::std::future::Future<Output = Value> + Send { async move {
1987 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 {
1989 if !matches!(__v, crate::Value::Null) { return __v; }
1990 }
1991
1992 let mut params = get_arg(optional_args, 0, Value::Map({
1993 let mut m = indexmap::IndexMap::new();
1994 m
1995}));
1996 panic!("{}", crate::exchange_errors::not_supported(format!("{}{}", self.id.clone(), Value::Str(" signIn() is not supported yet".into()))));
1997
1998 Value::Null
1999} }
2000
2001 fn fetch_payment_methods(&mut self, optional_args: &[Value]) -> impl ::std::future::Future<Output = Value> + Send { async move {
2002 let mut params = get_arg(optional_args, 0, Value::Map({
2003 let mut m = indexmap::IndexMap::new();
2004 m
2005}));
2006 panic!("{}", crate::exchange_errors::not_supported(format!("{}{}", self.id.clone(), Value::Str(" fetchPaymentMethods() is not supported yet".into()))));
2007
2008 Value::Null
2009} }
2010
2011 fn parse_to_int(&self, mut number: Value) -> Value {
2012 let mut stringifiedNumber: Value = self.number_to_string(number);
2018 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 });
2019 return crate::runtime::parse_int(&convertedNumber);
2020
2021 Value::Null
2022}
2023
2024 fn parse_to_numeric(&self, mut number: Value) -> Value {
2025 let mut stringVersion: Value = self.number_to_string(number); if stringVersion.as_str().unwrap_or("").contains(".") {
2031 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 });
2032 }
2033 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 });
2034
2035 Value::Null
2036}
2037
2038 fn is_round_number(&self, mut value: Value) -> Value {
2039 let mut res: Value = self.parse_to_numeric(((match (&(value), &(Value::Int(1))) { (Value::Int(x), Value::Int(y)) if *y != 0 => Value::Int(x % y), (Value::Int(x), Value::Float(y)) if *y != 0.0 => Value::Float(*x as f64 % *y), (Value::Float(x), Value::Int(y)) if *y != 0 => Value::Float(*x % *y as f64), (Value::Float(x),
2042 Value::Float(y)) if *y != 0.0 => Value::Float(x % y), _ => Value::Null })));
2043 return Value::Bool(res.as_f64() == Some(0.0));
2044
2045 Value::Null
2046}
2047
2048 fn is_empty_string(&self, mut value: Value) -> Value {
2049 return Value::Bool(!(self.value_is_defined(value.clone()).as_bool() == Some(true)) || (value.as_str() == Some("")));
2050
2051 Value::Null
2052}
2053
2054 fn safe_number_omit_zero(&self, mut obj: Value, mut key: Value, optional_args: &[Value]) -> Value {
2055 let mut defaultValue = get_arg(optional_args, 0, Value::Null);
2056 let mut value: Option<String> = self.safe_string_opt(obj, key, &[]);
2057 let mut final_val: Value = self.parse_number(self.omit_zero(value.map(Value::from).unwrap_or(Value::Null)), &[]);
2058 return (if (final_val == Value::Null) { defaultValue } else { final_val });
2059
2060 Value::Null
2061}
2062
2063 fn safe_integer_omit_zero(&self, mut obj: Value, mut key: Value, optional_args: &[Value]) -> Value {
2064 let mut defaultValue = get_arg(optional_args, 0, Value::Null);
2065 let mut timestamp: Value = self.safe_integer(obj, key, &[defaultValue]);
2066 if (timestamp == Value::Null) || (timestamp.as_f64() == Some(0.0)) {
2067 return Value::Null;
2068 }
2069 return timestamp;
2070
2071 Value::Null
2072}
2073
2074 fn after_construct(&mut self, optional_args: &[Value]) {
2075 let mut userConfig = get_arg(optional_args, 0, Value::Map({
2076 let mut m = indexmap::IndexMap::new();
2077 m
2078}));
2079 let __userConfig_empty = indexmap::IndexMap::new();
2080 let userConfig = userConfig.as_map().unwrap_or(&__userConfig_empty);
2081 let mut networkIdsToCodesGenerated: Value = self.invert_flat_string_dictionary(self.safe_value_k(self.options.clone(), "networks", &[Value::Map({
2083 let mut m = indexmap::IndexMap::new();
2084 m
2085 })]));
2086 { let __be_tmp = self.extend(networkIdsToCodesGenerated, &[self.safe_value_k(self.options.clone(), "networksById", &[Value::Map({
2087 let mut m = indexmap::IndexMap::new();
2088 m
2089})])]); if let Value::Dict(__d) = &mut self.options { std::sync::Arc::make_mut(__d).insert("networksById".into(), __be_tmp); } }
2090 self.features_generator();
2091 self.has_autocorrect();
2092 if (self.markets.clone() != Value::Null) {
2094 self.set_markets(self.markets.clone(), &[]);
2095 }
2096 self.init_rest_rate_limiter();
2098 let mut isSandbox: bool = self.safe_bool2_opt(self.options.clone(), Value::Str("sandbox".into()), Value::Str("testnet".into()), &[Value::Bool(false)]).unwrap_or(false);
2100 if isSandbox {
2101 self.set_sandbox_mode(Value::Bool(true));
2102 }
2103 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)) {
2105 self.set_sandbox_mode(Value::Bool(true));
2106 }
2107}
2108
2109 fn has_autocorrect(&self) {
2110 let mut fallbacks: indexmap::IndexMap<String, Value> = ({
2111 let mut m = indexmap::IndexMap::new();
2112 m.insert("fetchL2OrderBook".to_string(), Value::Str("fetchOrderBook".into()));
2113 m.insert("createLimitOrder".to_string(), Value::Str("createOrder".into()));
2114 m.insert("createMarketOrder".to_string(), Value::Str("createOrder".into()));
2115 m.insert("createLimitOrderWs".to_string(), Value::Str("createOrderWs".into()));
2116 m.insert("createMarketOrderWs".to_string(), Value::Str("createOrderWs".into()));
2117 m
2118 });
2119 let mut targets: Vec<Value> = Value::Array(fallbacks.keys().map(|__k| Value::Str(__k.clone().into())).collect()).as_array().cloned().unwrap_or_default();
2120 {
2121 let mut i: i64 = 0;
2122 let mut __for_first_81: bool = true;
2123 while { if !__for_first_81 { i += 1; } __for_first_81 = false; i < (targets.len() as i64) } {
2124 let mut target: Value = targets.get(i as usize).cloned().unwrap_or(Value::Null);
2125 let mut source: Value = fallbacks.get(target.as_str().unwrap_or("")).cloned().unwrap_or(Value::Null);
2126 let mut sourceDefined: bool = (matches!((&self.has, &source), (Value::Dict(__d), Value::Str(__k)) if __d.contains_key(__k.as_ref()))) && ((if let (Some(__m), Some(__k)) = (self.has.as_map(), source.as_str()) { __m.get(__k).cloned().unwrap_or(Value::Null) } else { Value::Null }) != Value::Null);
2127 let mut targetDefined: bool = (matches!((&self.has, &target), (Value::Dict(__d), Value::Str(__k)) if __d.contains_key(__k.as_ref()))) && ((if let (Some(__m), Some(__k)) = (self.has.as_map(), target.as_str()) { __m.get(__k).cloned().unwrap_or(Value::Null) } else { Value::Null }) != Value::Null);
2128 if sourceDefined && !targetDefined {
2129 { let __be_tmp = (if let (Some(__m), Some(__k)) = (self.has.as_map(), source.as_str()) { __m.get(__k).cloned().unwrap_or(Value::Null) } else { Value::Null }); if let Value::Dict(__d) = &mut self.has.clone() { std::sync::Arc::make_mut(__d).insert(crate::runtime::stringify_param(&target), __be_tmp); } }
2130 }
2131 }
2132 }
2133}
2134
2135 fn init_rest_rate_limiter(&mut self) {
2136 if (self.rateLimit.clone() == Value::Null) || ((self.id.clone() != Value::Null) && (self.rateLimit.as_f64() == Value::Int(-1).as_f64())) {
2137 panic!("{}", crate::exchange_errors::exchange_error(format!("{}{}", self.id.clone(), Value::Str(".rateLimit property is not configured".into()))));
2138 }
2139 let mut refillRate: Value = self.MAX_VALUE.clone();
2140 if self.rateLimit.as_f64().unwrap_or(f64::NAN) > ((0i64) as f64) {
2141 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 });
2142 }
2143 let mut useLeaky: bool = (self.rollingWindowSize.as_f64() == Some(0.0)) || (self.rateLimiterAlgorithm.as_str() == Some("leakyBucket"));
2144 let mut algorithm: Value = (if useLeaky { Value::Str("leakyBucket".into()) } else { Value::Str("rollingWindow".into()) });
2145 let mut defaultBucket: indexmap::IndexMap<String, Value> = ({
2146 let mut m = indexmap::IndexMap::new();
2147 m.insert("delay".to_string(), Value::Float(0.001));
2148 m.insert("capacity".to_string(), Value::Int(1));
2149 m.insert("cost".to_string(), Value::Int(1));
2150 m.insert("refillRate".to_string(), refillRate);
2151 m.insert("algorithm".to_string(), algorithm);
2152 m.insert("windowSize".to_string(), self.rollingWindowSize.clone());
2153 m.insert("rateLimit".to_string(), self.rateLimit.clone());
2154 m
2155 });
2156 let mut existingBucket: Value = (if (self.tokenBucket.clone() == Value::Null) { Value::Map({
2157 let mut m = indexmap::IndexMap::new();
2158 m
2159}) } else { self.tokenBucket.clone() });
2160 { let __t = self.extend(Value::Map(defaultBucket), &[existingBucket]); self.tokenBucket = __t; }
2161 self.init_throttler();
2162}
2163
2164 fn features_generator(&mut self) {
2165 if (self.features.clone() == Value::Null) {
2180 return;
2181 }
2182 let mut initialFeatures: Value = self.features.clone();
2184 self.features = Value::Map({
2185 let mut m = indexmap::IndexMap::new();
2186 m
2187 });
2188 let mut unifiedMarketTypes: Value = Value::from(vec![Value::Str("spot".into()), Value::Str("swap".into()), Value::Str("future".into()), Value::Str("option".into())]);
2189 let mut subTypes: Value = Value::from(vec![Value::Str("linear".into()), Value::Str("inverse".into())]);
2190 {
2191 let mut i: i64 = 0;
2192 let mut __for_first_83: bool = true;
2193 while { if !__for_first_83 { i += 1; } __for_first_83 = false; i < (unifiedMarketTypes.len() as i64) } {
2194 let mut marketType: Value = unifiedMarketTypes.as_array().map(Vec::as_slice).unwrap_or_default().get(i as usize).cloned().unwrap_or(Value::Null);
2195 if !(matches!((&initialFeatures, &marketType), (Value::Dict(__d), Value::Str(__k)) if __d.contains_key(__k.as_ref()))) {
2197 if let Value::Dict(__d) = &mut self.features { std::sync::Arc::make_mut(__d).insert(crate::runtime::stringify_param(&marketType), Value::Null); }
2198 } else {
2199 if (marketType.as_str() == Some("spot")) {
2200 { 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); } }
2201 } else {
2202 if let Value::Dict(__d) = &mut self.features { std::sync::Arc::make_mut(__d).insert(crate::runtime::stringify_param(&marketType), Value::Map({
2203 let mut m = indexmap::IndexMap::new();
2204 m
2205})); }
2206 {
2207 let mut j: i64 = 0;
2208 let mut __for_first_82: bool = true;
2209 while { if !__for_first_82 { j += 1; } __for_first_82 = false; j < (subTypes.len() as i64) } {
2210 let mut subType: Value = subTypes.as_array().map(Vec::as_slice).unwrap_or_default().get(j as usize).cloned().unwrap_or(Value::Null);
2211 { 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); };
2212 }
2213 }
2214 }
2215 }
2216 }
2217 }
2218}
2219
2220 fn features_mapper(&mut self, mut initialFeatures: Value, mut marketType: Value, optional_args: &[Value]) -> Value {
2221 let mut subType = get_arg(optional_args, 0, Value::Null);
2222 let mut featuresObj: Value = (if (subType != Value::Null) { get_value(&(if let (Some(__m), Some(__k)) = (initialFeatures.as_map(), marketType.as_str()) { __m.get(__k).cloned().unwrap_or(Value::Null) } else { Value::Null }), &subType) } else { (if let (Some(__m), Some(__k)) = (initialFeatures.as_map(),
2223 marketType.as_str()) { __m.get(__k).cloned().unwrap_or(Value::Null) } else { Value::Null }) });
2224 if (featuresObj == Value::Null) {
2226 return Value::Null;
2227 }
2228 let mut extendsStr: Option<String> = self.safe_string_k_opt(featuresObj.clone(), "extends", &[]);
2229 if (extendsStr.is_some()) {
2230 featuresObj = self.omit(featuresObj.clone(), Value::Str("extends".into()), &[]);
2231 let mut extendObj: Value = self.features_mapper(initialFeatures, extendsStr.clone().map(Value::from).unwrap_or(Value::Null), &[]);
2232 featuresObj = self.deep_extend(extendObj, &[featuresObj.clone()]);
2233 }
2234 if (in_op(&featuresObj, &Value::Str("createOrder".into()))) {
2239 let mut value: Value = self.safe_dict_k(crate::value::get_value_k(&featuresObj, "createOrder"), "attachedStopLossTakeProfit", &[]);
2240 add_element_to_object(get_value_mut(&mut featuresObj, &Value::Str("createOrder".into())), &Value::Str("stopLoss".into()), value.clone());
2241 add_element_to_object(get_value_mut(&mut featuresObj, &Value::Str("createOrder".into())), &Value::Str("takeProfit".into()), value.clone());
2242 if (marketType.as_str() == Some("spot")) {
2243 add_element_to_object(get_value_mut(&mut featuresObj, &Value::Str("createOrder".into())), &Value::Str("hedged".into()), Value::Bool(false));
2245 if !(in_op(&crate::value::get_value_k(&featuresObj, "createOrder"), &Value::Str("leverage".into()))) {
2247 add_element_to_object(get_value_mut(&mut featuresObj, &Value::Str("createOrder".into())), &Value::Str("leverage".into()), Value::Bool(false));
2248 }
2249 }
2250 if (self.safe_bool(crate::value::get_value_k(&crate::value::get_value_k(&featuresObj, "createOrder"), "timeInForce"), Value::Str("GTC".into()), &[]) == Value::Null) {
2252 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));
2253 }
2254 }
2255 let mut keys: Vec<Value> = object_keys(&featuresObj).as_array().cloned().unwrap_or_default();
2257 {
2258 let mut i: i64 = 0;
2259 let mut __for_first_84: bool = true;
2260 while { if !__for_first_84 { i += 1; } __for_first_84 = false; i < (keys.len() as i64) } {
2261 let mut key: Value = keys.get(i as usize).cloned().unwrap_or(Value::Null);
2262 let mut featureBlock: Value = get_value(&featuresObj, &key);
2263 if !(self.in_array(key.clone(), Value::from(vec![Value::Str("sandbox".into())])).as_bool() == Some(true)) && (featureBlock != Value::Null) {
2264 if !(in_op(&featureBlock, &Value::Str("symbolRequired".into()))) {
2266 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())])));
2267 }
2268 }
2269 }
2270 }
2271 return featuresObj;
2272
2273 Value::Null
2274}
2275
2276 fn feature_value(&self, mut symbol: Value, optional_args: &[Value]) -> Value {
2277 let mut methodName = get_arg(optional_args, 0, Value::Null);
2278 let mut paramName = get_arg(optional_args, 1, Value::Null);
2279 let mut defaultValue = get_arg(optional_args, 2, Value::Null);
2280 let mut market: indexmap::IndexMap<String, Value> = <Self as crate::exchange_generated::ExchangeBase>::market(self, symbol.clone()).as_map().cloned().unwrap_or_default();
2291 return self.feature_value_by_type(market.get("type").cloned().unwrap_or(Value::Null), market.get("subType").cloned().unwrap_or(Value::Null), &[methodName, paramName, defaultValue]);
2292
2293 Value::Null
2294}
2295
2296 fn feature_value_by_type(&self, mut marketType: Value, mut subType: Value, optional_args: &[Value]) -> Value {
2297 let mut methodName = get_arg(optional_args, 0, Value::Null);
2298 let mut paramName = get_arg(optional_args, 1, Value::Null);
2299 let mut defaultValue = get_arg(optional_args, 2, Value::Null);
2300 if (self.features.clone() == Value::Null) {
2313 return defaultValue;
2314 }
2315 if (marketType == Value::Null) {
2316 return defaultValue;
2317 }
2318 if !(matches!((&self.features, &marketType), (Value::Dict(__d), Value::Str(__k)) if __d.contains_key(__k.as_ref()))) {
2320 return defaultValue;
2321 }
2322 let mut methodsContainer: Value = (if let (Some(__m), Some(__k)) = (self.features.as_map(), marketType.as_str()) { __m.get(__k).cloned().unwrap_or(Value::Null) } else { Value::Null });
2323 if (methodsContainer == Value::Null) {
2325 return defaultValue;
2326 }
2327 if (subType == Value::Null) {
2328 if (marketType.as_str() != Some("spot")) {
2329 return defaultValue;
2330 }
2331 } else {
2332 if !(matches!((&methodsContainer, &subType), (Value::Dict(__d), Value::Str(__k)) if __d.contains_key(__k.as_ref()))) {
2333 return defaultValue;
2334 }
2335 methodsContainer = get_value(&methodsContainer, &subType);
2336 if (methodsContainer == Value::Null) {
2338 return defaultValue;
2339 }
2340 }
2341 if (methodName == Value::Null) {
2343 return (if (defaultValue != Value::Null) { defaultValue.clone() } else { methodsContainer.clone() });
2344 }
2345 if !(matches!((&methodsContainer, &methodName), (Value::Dict(__d), Value::Str(__k)) if __d.contains_key(__k.as_ref()))) {
2346 return defaultValue;
2347 }
2348 let mut methodDict: Value = get_value(&methodsContainer, &methodName);
2349 if (methodDict == Value::Null) {
2350 return defaultValue;
2351 }
2352 if (paramName == Value::Null) {
2354 return (if (defaultValue != Value::Null) { defaultValue.clone() } else { methodDict.clone() });
2355 }
2356 let mut splited: Value = Value::Array(if let Some(__s) = paramName.as_str() { __s.split(".").map(Value::from).collect() } else { Vec::new() }); let mut parentKey: Value = splited.as_array().and_then(|__arr| __arr.get(0)).cloned().unwrap_or(Value::Null);
2358 let mut subKey: Option<String> = self.safe_string_opt(splited, Value::Int(1), &[]);
2359 if !(matches!((&methodDict, &parentKey), (Value::Dict(__d), Value::Str(__k)) if __d.contains_key(__k.as_ref()))) {
2360 return defaultValue;
2361 }
2362 let mut dictionary: Value = self.safe_dict(methodDict.clone(), parentKey.clone(), &[]);
2363 if (dictionary == Value::Null) {
2364 return (if let (Some(__m), Some(__k)) = (methodDict.as_map(), parentKey.as_str()) { __m.get(__k).cloned().unwrap_or(Value::Null) } else { Value::Null });
2365 } else {
2366 if (subKey.is_none()) {
2368 return (if let (Some(__m), Some(__k)) = (methodDict.as_map(), parentKey.as_str()) { __m.get(__k).cloned().unwrap_or(Value::Null) } else { Value::Null });
2369 }
2370 if !(in_op(&(if let (Some(__m), Some(__k)) = (methodDict.as_map(), parentKey.as_str()) { __m.get(__k).cloned().unwrap_or(Value::Null) } else { Value::Null }), &subKey.clone().map(Value::from).unwrap_or(Value::Null))) {
2372 return defaultValue;
2373 }
2374 return get_value(&(if let (Some(__m), Some(__k)) = (methodDict.as_map(), parentKey.as_str()) { __m.get(__k).cloned().unwrap_or(Value::Null) } else { Value::Null }), &subKey.clone().map(Value::from).unwrap_or(Value::Null));
2375 }
2376
2377 Value::Null
2378}
2379
2380 fn orderbook_checksum_message(&self, mut symbol: Value) -> Value {
2381 if (symbol == Value::Null) {
2382 panic!("{}", crate::exchange_errors::arguments_required(format!("{}{}", self.id.clone(), Value::Str(" orderbookChecksumMessage() requires a symbol argument".into()))));
2383 }
2384 return Value::Str(format!("{}{}", symbol, 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());
2385
2386 Value::Null
2387}
2388
2389 fn get_default_options(&self) -> Value {
2390 return Value::Map({
2391 let mut m = indexmap::IndexMap::new();
2392 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())]));
2393 m
2394});
2395
2396 Value::Null
2397}
2398
2399 fn safe_ledger_entry(&self, mut entry: Value, optional_args: &[Value]) -> Value {
2400 let mut currency = get_arg(optional_args, 0, Value::Null);
2401 let mut currencyResolved: indexmap::IndexMap<String, Value> = self.safe_currency(Value::Null, &[currency]).as_map().cloned().unwrap_or_default();
2402 let mut direction: Value = self.safe_string_k(entry.clone(), "direction", &[]);
2403 let mut before: Value = self.safe_string_k(entry.clone(), "before", &[]);
2404 let mut after: Value = self.safe_string_k(entry.clone(), "after", &[]);
2405 let mut amount: Option<String> = self.safe_string_k_opt(entry.clone(), "amount", &[]);
2406 if (amount.is_some()) {
2407 if (before == Value::Null) && (after != Value::Null) {
2408 before = crate::precise::Precise::stringSub(&after, &amount.clone().map(Value::from).unwrap_or(Value::Null));
2409 } else if (before != Value::Null) && (after == Value::Null) {
2410 after = crate::precise::Precise::stringAdd(&before, &amount.clone().map(Value::from).unwrap_or(Value::Null));
2411 }
2412 }
2413 if (before != Value::Null) && (after != Value::Null) {
2414 if (direction == Value::Null) {
2415 if crate::precise::Precise::stringGt(&before, &after).as_bool() == Some(true) {
2416 direction = Value::Str("out".into());
2417 }
2418 if crate::precise::Precise::stringGt(&after, &before).as_bool() == Some(true) {
2419 direction = Value::Str("in".into());
2420 }
2421 }
2422 }
2423 let mut fee: Value = self.safe_value_k(entry.clone(), "fee", &[]);
2424 if (fee != Value::Null) {
2425 { let __be_tmp = self.safe_number_k(fee.clone(), "cost", &[]); add_element_to_object(&mut fee, &Value::Str("cost".into()), __be_tmp); };
2426 }
2427 let mut timestamp: Option<i64> = self.safe_integer_k(entry.clone(), "timestamp", &[]).as_i64();
2428 let mut info: Value = self.safe_dict_k(entry.clone(), "info", &[Value::Map({
2429 let mut m = indexmap::IndexMap::new();
2430 m
2431})]);
2432 return Value::Map({
2433 let mut m = indexmap::IndexMap::new();
2434 m.insert("id".to_string(), self.safe_string_k(entry.clone(), "id", &[]));
2435 m.insert("timestamp".to_string(), Value::from(timestamp));
2436 m.insert("datetime".to_string(), self.iso8601(Value::from(timestamp)));
2437 m.insert("direction".to_string(), direction);
2438 m.insert("account".to_string(), self.safe_string_k(entry.clone(), "account", &[]));
2439 m.insert("referenceId".to_string(), self.safe_string_k(entry.clone(), "referenceId", &[]));
2440 m.insert("referenceAccount".to_string(), self.safe_string_k(entry.clone(), "referenceAccount", &[]));
2441 m.insert("type".to_string(), self.safe_string_k(entry.clone(), "type", &[]));
2442 m.insert("currency".to_string(), currencyResolved.get("code").cloned().unwrap_or(Value::Null));
2443 m.insert("amount".to_string(), self.parse_number(amount.map(Value::from).unwrap_or(Value::Null), &[]));
2444 m.insert("before".to_string(), self.parse_number(before, &[]));
2445 m.insert("after".to_string(), self.parse_number(after, &[]));
2446 m.insert("status".to_string(), self.safe_string_k(entry, "status", &[]));
2447 m.insert("fee".to_string(), fee);
2448 m.insert("info".to_string(), info);
2449 m
2450});
2451
2452 Value::Null
2453}
2454
2455 fn safe_currency_structure(&self, mut currency: Value) -> Value {
2456 let mut networks: Value = self.safe_dict_k(currency.clone(), "networks", &[Value::Map({
2458 let mut m = indexmap::IndexMap::new();
2459 m
2460})]);
2461 let mut keys: Vec<Value> = Value::Array(networks.as_map().map(|__m| __m.keys().map(|__k| Value::Str(__k.clone().into())).collect()).unwrap_or_default()).as_array().cloned().unwrap_or_default();
2462 let mut length: f64 = ((keys.len() as i64) as f64);
2463 if (length != 0.0) {
2464 {
2465 let mut i: Value = Value::Int(0);
2466 let mut __for_first_85: bool = true;
2467 while { if !__for_first_85 { if let Value::Int(n) = &mut i { *n += 1; } } __for_first_85 = false; i.as_f64().unwrap_or(f64::NAN) < length } {
2468 let mut key: Value = keys.get(i.as_i64().unwrap_or(-1) as usize).cloned().unwrap_or(Value::Null);
2469 let mut network: Value = self.safe_dict(networks.clone(), key, &[Value::Map({
2470 let mut m = indexmap::IndexMap::new();
2471 m
2472})]);
2473 let mut deposit: Option<bool> = self.safe_bool_k_opt(network.clone(), "deposit", &[]);
2474 let mut currencyDeposit: Option<bool> = self.safe_bool_k_opt(currency.clone(), "deposit", &[]);
2475 if (currencyDeposit.is_none()) || (deposit == Some(true)) {
2476 if let Value::Dict(__d) = &mut currency { std::sync::Arc::make_mut(__d).insert("deposit".into(), deposit.map(Value::Bool).unwrap_or(Value::Null)); }
2477 }
2478 let mut withdraw: Option<bool> = self.safe_bool_k_opt(network.clone(), "withdraw", &[]);
2479 let mut currencyWithdraw: Option<bool> = self.safe_bool_k_opt(currency.clone(), "withdraw", &[]);
2480 if (currencyWithdraw.is_none()) || (withdraw == Some(true)) {
2481 if let Value::Dict(__d) = &mut currency { std::sync::Arc::make_mut(__d).insert("withdraw".into(), withdraw.map(Value::Bool).unwrap_or(Value::Null)); }
2482 }
2483 let mut fee: Option<String> = self.safe_string_k_opt(network.clone(), "fee", &[]);
2485 let mut feeMain: Option<String> = self.safe_string_k_opt(currency.clone(), "fee", &[]);
2486 if (feeMain.is_none()) || crate::precise::Precise::stringLt(&fee.clone().map(Value::from).unwrap_or(Value::Null), &feeMain.clone().map(Value::from).unwrap_or(Value::Null)).as_bool() == Some(true) {
2487 if let Value::Dict(__d) = &mut currency { std::sync::Arc::make_mut(__d).insert("fee".into(), self.parse_number(fee.map(Value::from).unwrap_or(Value::Null), &[])); }
2488 }
2489 let mut precision: Option<String> = self.safe_string_k_opt(network.clone(), "precision", &[]);
2491 let mut precisionMain: Option<String> = self.safe_string_k_opt(currency.clone(), "precision", &[]);
2492 if (precisionMain.is_none()) || crate::precise::Precise::stringGt(&precision.clone().map(Value::from).unwrap_or(Value::Null), &precisionMain.clone().map(Value::from).unwrap_or(Value::Null)).as_bool() == Some(true) {
2493 if let Value::Dict(__d) = &mut currency { std::sync::Arc::make_mut(__d).insert("precision".into(), self.parse_number(precision.map(Value::from).unwrap_or(Value::Null), &[])); }
2494 }
2495 let mut limits: Value = self.safe_dict_k(network, "limits", &[]);
2497 let mut limitsMain: Value = self.safe_dict_k(currency.clone(), "limits", &[Value::Map({
2498 let mut m = indexmap::IndexMap::new();
2499 m
2500})]);
2501 let mut limitsDeposit: Value = self.safe_dict_k(limits.clone(), "deposit", &[]);
2503 let mut limitsDepositMain: Value = self.safe_dict_k(limitsMain.clone(), "deposit", &[Value::Map({
2504 let mut m = indexmap::IndexMap::new();
2505 m
2506})]);
2507 let mut limitsDepositNew: indexmap::IndexMap<String, Value> = ({
2508 let mut m = indexmap::IndexMap::new();
2509 m
2510 });
2511 let mut limitsDepositMin: Option<String> = self.safe_string_k_opt(limitsDeposit.clone(), "min", &[]);
2512 let mut limitsDepositMax: Option<String> = self.safe_string_k_opt(limitsDeposit, "max", &[]);
2513 let mut limitsDepositMinMain: Option<String> = self.safe_string_k_opt(limitsDepositMain.clone(), "min", &[]);
2514 let mut limitsDepositMaxMain: Option<String> = self.safe_string_k_opt(limitsDepositMain.clone(), "max", &[]);
2515 if (limitsDepositMinMain.is_none()) || crate::precise::Precise::stringLt(&limitsDepositMin.clone().map(Value::from).unwrap_or(Value::Null), &limitsDepositMinMain.clone().map(Value::from).unwrap_or(Value::Null)).as_bool() == Some(true) {
2517 limitsDepositNew.insert("min".into(), self.parse_number(limitsDepositMin.map(Value::from).unwrap_or(Value::Null), &[]));
2518 }
2519 if (limitsDepositMaxMain.is_none()) || crate::precise::Precise::stringGt(&limitsDepositMax.clone().map(Value::from).unwrap_or(Value::Null), &limitsDepositMaxMain.clone().map(Value::from).unwrap_or(Value::Null)).as_bool() == Some(true) {
2521 limitsDepositNew.insert("max".into(), self.parse_number(limitsDepositMax.map(Value::from).unwrap_or(Value::Null), &[]));
2522 }
2523 let mut limitsWithdraw: Value = self.safe_dict_k(limits, "withdraw", &[]);
2525 let mut limitsWithdrawMain: Value = self.safe_dict_k(limitsMain.clone(), "withdraw", &[Value::Map({
2526 let mut m = indexmap::IndexMap::new();
2527 m
2528})]);
2529 let mut limitsWithdrawNew: indexmap::IndexMap<String, Value> = ({
2530 let mut m = indexmap::IndexMap::new();
2531 m
2532 });
2533 let mut limitsWithdrawMin: Option<String> = self.safe_string_k_opt(limitsWithdraw.clone(), "min", &[]);
2534 let mut limitsWithdrawMax: Option<String> = self.safe_string_k_opt(limitsWithdraw, "max", &[]);
2535 let mut limitsWithdrawMinMain: Option<String> = self.safe_string_k_opt(limitsWithdrawMain.clone(), "min", &[]);
2536 let mut limitsWithdrawMaxMain: Option<String> = self.safe_string_k_opt(limitsWithdrawMain.clone(), "max", &[]);
2537 if (limitsWithdrawMinMain.is_none()) || crate::precise::Precise::stringLt(&limitsWithdrawMin.clone().map(Value::from).unwrap_or(Value::Null), &limitsWithdrawMinMain.clone().map(Value::from).unwrap_or(Value::Null)).as_bool() == Some(true) {
2539 limitsWithdrawNew.insert("min".into(), self.parse_number(limitsWithdrawMin.map(Value::from).unwrap_or(Value::Null), &[]));
2540 }
2541 if (limitsWithdrawMaxMain.is_none()) || crate::precise::Precise::stringGt(&limitsWithdrawMax.clone().map(Value::from).unwrap_or(Value::Null), &limitsWithdrawMaxMain.clone().map(Value::from).unwrap_or(Value::Null)).as_bool() == Some(true) {
2543 limitsWithdrawNew.insert("max".into(), self.parse_number(limitsWithdrawMax.map(Value::from).unwrap_or(Value::Null), &[]));
2544 }
2545 if let Value::Dict(__d) = &mut currency { std::sync::Arc::make_mut(__d).insert("limits".into(), self.extend(limitsMain, &[Value::Map({
2546 let mut m = indexmap::IndexMap::new();
2547 m.insert("deposit".to_string(), self.extend(limitsDepositMain, &[Value::Map(limitsDepositNew)]));
2548 m.insert("withdraw".to_string(), self.extend(limitsWithdrawMain, &[Value::Map(limitsWithdrawNew)]));
2549 m
2550})])); }
2551 }
2552 }
2553 }
2554 return self.extend(Value::Map({
2555 let mut m = indexmap::IndexMap::new();
2556 m.insert("info".to_string(), Value::Null);
2557 m.insert("id".to_string(), Value::Null);
2558 m.insert("numericId".to_string(), Value::Null);
2559 m.insert("code".to_string(), Value::Null);
2560 m.insert("precision".to_string(), Value::Null);
2561 m.insert("type".to_string(), Value::Null);
2562 m.insert("name".to_string(), Value::Null);
2563 m.insert("active".to_string(), Value::Null);
2564 m.insert("deposit".to_string(), Value::Null);
2565 m.insert("withdraw".to_string(), Value::Null);
2566 m.insert("fee".to_string(), Value::Null);
2567 m.insert("fees".to_string(), Value::Map({
2568 let mut m = indexmap::IndexMap::new();
2569 m
2570}));
2571 m.insert("networks".to_string(), Value::Map({
2572 let mut m = indexmap::IndexMap::new();
2573 m
2574}));
2575 m.insert("limits".to_string(), Value::Map({
2576 let mut m = indexmap::IndexMap::new();
2577 m.insert("deposit".to_string(), Value::Map({
2578 let mut m = indexmap::IndexMap::new();
2579 m.insert("min".to_string(), Value::Null);
2580 m.insert("max".to_string(), Value::Null);
2581 m
2582}));
2583 m.insert("withdraw".to_string(), Value::Map({
2584 let mut m = indexmap::IndexMap::new();
2585 m.insert("min".to_string(), Value::Null);
2586 m.insert("max".to_string(), Value::Null);
2587 m
2588}));
2589 m
2590}));
2591 m
2592}), &[currency]);
2593
2594 Value::Null
2595}
2596
2597 fn safe_market_structure(&self, optional_args: &[Value]) -> Value {
2598 let mut market = get_arg(optional_args, 0, Value::Null);
2599 let mut cleanStructure: indexmap::IndexMap<String, Value> = ({
2600 let mut m = indexmap::IndexMap::new();
2601 m.insert("id".to_string(), Value::Null);
2602 m.insert("lowercaseId".to_string(), Value::Null);
2603 m.insert("symbol".to_string(), Value::Null);
2604 m.insert("base".to_string(), Value::Null);
2605 m.insert("quote".to_string(), Value::Null);
2606 m.insert("settle".to_string(), Value::Null);
2607 m.insert("baseId".to_string(), Value::Null);
2608 m.insert("quoteId".to_string(), Value::Null);
2609 m.insert("settleId".to_string(), Value::Null);
2610 m.insert("type".to_string(), Value::Null);
2611 m.insert("spot".to_string(), Value::Bool(false));
2612 m.insert("margin".to_string(), Value::Null);
2613 m.insert("swap".to_string(), Value::Bool(false));
2614 m.insert("future".to_string(), Value::Bool(false));
2615 m.insert("option".to_string(), Value::Bool(false));
2616 m.insert("index".to_string(), Value::Null);
2617 m.insert("active".to_string(), Value::Null);
2618 m.insert("contract".to_string(), Value::Bool(false));
2619 m.insert("linear".to_string(), Value::Null);
2620 m.insert("inverse".to_string(), Value::Null);
2621 m.insert("subType".to_string(), Value::Null);
2622 m.insert("taker".to_string(), Value::Null);
2623 m.insert("maker".to_string(), Value::Null);
2624 m.insert("contractSize".to_string(), Value::Null);
2625 m.insert("expiry".to_string(), Value::Null);
2626 m.insert("expiryDatetime".to_string(), Value::Null);
2627 m.insert("strike".to_string(), Value::Null);
2628 m.insert("optionType".to_string(), Value::Null);
2629 m.insert("precision".to_string(), Value::Map({
2630 let mut m = indexmap::IndexMap::new();
2631 m.insert("amount".to_string(), Value::Null);
2632 m.insert("price".to_string(), Value::Null);
2633 m.insert("cost".to_string(), Value::Null);
2634 m.insert("base".to_string(), Value::Null);
2635 m.insert("quote".to_string(), Value::Null);
2636 m
2637}));
2638 m.insert("limits".to_string(), Value::Map({
2639 let mut m = indexmap::IndexMap::new();
2640 m.insert("leverage".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("amount".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.insert("price".to_string(), Value::Map({
2653 let mut m = indexmap::IndexMap::new();
2654 m.insert("min".to_string(), Value::Null);
2655 m.insert("max".to_string(), Value::Null);
2656 m
2657}));
2658 m.insert("cost".to_string(), Value::Map({
2659 let mut m = indexmap::IndexMap::new();
2660 m.insert("min".to_string(), Value::Null);
2661 m.insert("max".to_string(), Value::Null);
2662 m
2663}));
2664 m
2665}));
2666 m.insert("marginModes".to_string(), Value::Map({
2667 let mut m = indexmap::IndexMap::new();
2668 m.insert("cross".to_string(), Value::Null);
2669 m.insert("isolated".to_string(), Value::Null);
2670 m
2671}));
2672 m.insert("created".to_string(), Value::Null);
2673 m.insert("info".to_string(), Value::Null);
2674 m
2675 });
2676 if (market != Value::Null) {
2677 let mut result: Value = self.extend(Value::Map(cleanStructure.clone()), &[market]);
2678 if matches!(self.safe_bool_k(result.clone(), "spot", &[Value::Bool(false)]), Value::Bool(true)) {
2680 if (result.as_map().and_then(|__m| __m.get("contract")).cloned().unwrap_or(Value::Null) == Value::Null) {
2681 if let Value::Dict(__d) = &mut result { std::sync::Arc::make_mut(__d).insert("contract".into(), Value::Bool(false)); }
2682 }
2683 if (result.as_map().and_then(|__m| __m.get("swap")).cloned().unwrap_or(Value::Null) == Value::Null) {
2684 if let Value::Dict(__d) = &mut result { std::sync::Arc::make_mut(__d).insert("swap".into(), Value::Bool(false)); }
2685 }
2686 if (result.as_map().and_then(|__m| __m.get("future")).cloned().unwrap_or(Value::Null) == Value::Null) {
2687 if let Value::Dict(__d) = &mut result { std::sync::Arc::make_mut(__d).insert("future".into(), Value::Bool(false)); }
2688 }
2689 if (result.as_map().and_then(|__m| __m.get("option")).cloned().unwrap_or(Value::Null) == Value::Null) {
2690 if let Value::Dict(__d) = &mut result { std::sync::Arc::make_mut(__d).insert("option".into(), Value::Bool(false)); }
2691 }
2692 if (result.as_map().and_then(|__m| __m.get("index")).cloned().unwrap_or(Value::Null) == Value::Null) {
2693 if let Value::Dict(__d) = &mut result { std::sync::Arc::make_mut(__d).insert("index".into(), Value::Bool(false)); }
2694 }
2695 }
2696 return result;
2697 }
2698 return self.extend(Value::Map(cleanStructure), &[]);
2699
2700 Value::Null
2701}
2702
2703 fn set_markets(&mut self, mut markets: Value, optional_args: &[Value]) -> Value {
2704 let mut currencies = get_arg(optional_args, 0, Value::Null);
2705 let mut values: Vec<Value> = Vec::new();
2706 let mut marketsById: Value = Value::Map({
2708 let mut m = indexmap::IndexMap::new();
2709 m
2710 });
2711 let mut marketValues: Value = self.sort_by(self.to_array(markets.clone()), Value::Str("spot".into()), &[Value::Bool(true), Value::Bool(true)]);
2714 {
2715 let mut i: i64 = 0;
2716 let mut __for_first_87: bool = true;
2717 while { if !__for_first_87 { i += 1; } __for_first_87 = false; i < (marketValues.len() as i64) } {
2718 let mut value: Value = self.safe_dict(marketValues.clone(), Value::Int(i), &[Value::Map({
2719 let mut m = indexmap::IndexMap::new();
2720 m
2721})]);
2722 if (marketsById.as_map().is_some_and(|__m| value.as_map().and_then(|__m| __m.get("id")).cloned().unwrap_or(Value::Null).as_str().is_some_and(|__k| __m.contains_key(__k)))) {
2723 let mut marketsByIdArray: Value = marketsById.as_map().and_then(|__m| value.as_map().and_then(|__m| __m.get("id")).cloned().unwrap_or(Value::Null).as_str().and_then(|__k| __m.get(__k))).cloned().unwrap_or(Value::Null);
2724 if let Value::Arr(__a) = &mut marketsByIdArray { std::sync::Arc::make_mut(__a).push(value.clone()); };
2725 add_element_to_object(&mut marketsById, &value.as_map().and_then(|__m| __m.get("id")).cloned().unwrap_or(Value::Null), marketsByIdArray);
2726 } else {
2727 add_element_to_object(&mut marketsById, &value.as_map().and_then(|__m| __m.get("id")).cloned().unwrap_or(Value::Null), Value::from(vec![value.clone()]));
2728 }
2729 let mut valueDefined: indexmap::IndexMap<String, Value> = ({
2733 let mut m = indexmap::IndexMap::new();
2734 m
2735 });
2736 let mut valueKeys: Vec<Value> = Value::Array(value.as_map().map(|__m| __m.keys().map(|__k| Value::Str(__k.clone().into())).collect()).unwrap_or_default()).as_array().cloned().unwrap_or_default();
2737 {
2738 let mut j: i64 = 0;
2739 let mut __for_first_86: bool = true;
2740 while { if !__for_first_86 { j += 1; } __for_first_86 = false; j < (valueKeys.len() as i64) } {
2741 let mut valueKey: Value = valueKeys.get(j as usize).cloned().unwrap_or(Value::Null);
2742 if ((if let (Some(__m), Some(__k)) = (value.as_map(), valueKey.as_str()) { __m.get(__k).cloned().unwrap_or(Value::Null) } else { Value::Null }) != Value::Null) {
2743 valueDefined.insert(crate::runtime::stringify_param(&valueKey), (if let (Some(__m), Some(__k)) = (value.as_map(), valueKey.as_str()) { __m.get(__k).cloned().unwrap_or(Value::Null) } else { Value::Null }));
2744 }
2745 }
2746 }
2747 let mut market: Value = self.deep_extend(self.safe_market_structure(&[]), &[Value::Map({
2748 let mut m = indexmap::IndexMap::new();
2749 m.insert("precision".to_string(), self.precision.clone());
2750 m.insert("limits".to_string(), self.limits.clone());
2751 m
2752 }), self.fees.as_map().and_then(|__m| __m.get("trading")).cloned().unwrap_or(Value::Null), Value::Map(valueDefined)]);
2753 if matches!(self.safe_bool_k(market.clone(), "linear", &[Value::Bool(false)]), Value::Bool(true)) {
2754 add_element_to_object(&mut market, &Value::Str("subType".into()), Value::Str("linear".into()));
2755 } else if matches!(self.safe_bool_k(market.clone(), "inverse", &[Value::Bool(false)]), Value::Bool(true)) {
2756 add_element_to_object(&mut market, &Value::Str("subType".into()), Value::Str("inverse".into()));
2757 } else {
2758 add_element_to_object(&mut market, &Value::Str("subType".into()), Value::Null);
2759 }
2760 values.push(market.clone());
2761 }
2762 }
2763 { let __t = self.map_to_safe_map(self.index_by(Value::from(values.clone()), Value::Str("symbol".into()))); self.markets = __t; }
2764 { let __t = self.map_to_safe_map(marketsById); self.markets_by_id = __t; }
2765 let mut marketsSortedBySymbol: indexmap::IndexMap<String, Value> = self.keysort(self.markets.clone(), &[]).as_map().cloned().unwrap_or_default();
2766 let mut marketsSortedById: indexmap::IndexMap<String, Value> = self.keysort(self.markets_by_id.clone(), &[]).as_map().cloned().unwrap_or_default();
2767 self.symbols = Value::Array(marketsSortedBySymbol.keys().map(|__k| Value::Str(__k.clone().into())).collect());
2768 self.ids = Value::Array(marketsSortedById.keys().map(|__k| Value::Str(__k.clone().into())).collect());
2769 let mut numCurrencies: i64 = 0;
2770 if (currencies != Value::Null) {
2771 let mut keys: Vec<Value> = object_keys(¤cies).as_array().cloned().unwrap_or_default();
2772 numCurrencies = keys.len() as i64;
2773 }
2774 if (numCurrencies as f64) > ((0i64) as f64) {
2775 { let __t = self.map_to_safe_map(self.deep_extend(self.currencies.clone(), &[currencies.clone()])); self.currencies = __t; }
2777 } else {
2778 let mut baseCurrencies: Value = Value::from(vec![]);
2779 let mut quoteCurrencies: Value = Value::from(vec![]);
2780 {
2781 let mut i: Value = Value::Int(0);
2782 let mut __for_first_88: bool = true;
2783 while { if !__for_first_88 { if let Value::Int(n) = &mut i { *n += 1; } } __for_first_88 = false; i.as_f64().unwrap_or(f64::NAN) < ((values.len() as i64) as f64) } {
2784 let mut market: Value = values.get((i).as_i64().unwrap_or(-1) as usize).cloned().unwrap_or(Value::Null);
2785 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()), &[]) });
2786 let mut marketPrecision: Value = self.safe_dict_k(market.clone(), "precision", &[Value::Map({
2787 let mut m = indexmap::IndexMap::new();
2788 m
2789})]);
2790 if (matches!(&market, Value::Dict(__d) if __d.contains_key("base"))) {
2791 let mut currency: Value = self.safe_currency_structure(Value::Map({
2792 let mut m = indexmap::IndexMap::new();
2793 m.insert("id".to_string(), self.safe_string2(market.clone(), Value::Str("baseId".into()), Value::Str("base".into()), &[]));
2794 m.insert("numericId".to_string(), self.safe_integer_k(market.clone(), "baseNumericId", &[]));
2795 m.insert("code".to_string(), self.safe_string_k(market.clone(), "base", &[]));
2796 m.insert("precision".to_string(), self.safe_value2(marketPrecision.clone(), Value::Str("base".into()), Value::Str("amount".into()), &[defaultCurrencyPrecision.clone()]));
2797 m
2798 }));
2799 if let Value::Arr(__a) = &mut baseCurrencies { std::sync::Arc::make_mut(__a).push(currency.clone()); }
2800 }
2801 if (matches!(&market, Value::Dict(__d) if __d.contains_key("quote"))) {
2802 let mut currency: Value = self.safe_currency_structure(Value::Map({
2803 let mut m = indexmap::IndexMap::new();
2804 m.insert("id".to_string(), self.safe_string2(market.clone(), Value::Str("quoteId".into()), Value::Str("quote".into()), &[]));
2805 m.insert("numericId".to_string(), self.safe_integer_k(market.clone(), "quoteNumericId", &[]));
2806 m.insert("code".to_string(), self.safe_string_k(market.clone(), "quote", &[]));
2807 m.insert("precision".to_string(), self.safe_value2(marketPrecision, Value::Str("quote".into()), Value::Str("price".into()), &[defaultCurrencyPrecision]));
2808 m
2809 }));
2810 if let Value::Arr(__a) = &mut quoteCurrencies { std::sync::Arc::make_mut(__a).push(currency); }
2811 }
2812 }
2813 }
2814 baseCurrencies = self.sort_by(baseCurrencies.clone(), Value::Str("code".into()), &[Value::Bool(false), Value::Str("".into())]);
2815 quoteCurrencies = self.sort_by(quoteCurrencies.clone(), Value::Str("code".into()), &[Value::Bool(false), Value::Str("".into())]);
2816 { let __t = self.map_to_safe_map(self.index_by(baseCurrencies.clone(), Value::Str("code".into()))); self.baseCurrencies = __t; }
2817 { let __t = self.map_to_safe_map(self.index_by(quoteCurrencies.clone(), Value::Str("code".into()))); self.quoteCurrencies = __t; }
2818 let mut groupedCurrencies: Value = self.group_by(self.array_concat(baseCurrencies, quoteCurrencies), Value::Str("code".into()), &[]);
2819 let mut codes: Vec<Value> = object_keys(&groupedCurrencies).as_array().cloned().unwrap_or_default();
2820 let mut resultingCurrencies: Vec<Value> = Vec::new();
2821 {
2822 let mut i: i64 = 0;
2823 let mut __for_first_90: bool = true;
2824 while { if !__for_first_90 { i += 1; } __for_first_90 = false; i < (codes.len() as i64) } {
2825 let mut code: Value = codes.get(i as usize).cloned().unwrap_or(Value::Null);
2826 let mut groupedCurrenciesCode: Value = self.safe_list(groupedCurrencies.clone(), code, &[Value::from(vec![])]);
2827 let mut highestPrecisionCurrency: Value = self.safe_value(groupedCurrenciesCode.clone(), Value::Int(0), &[]);
2828 {
2829 let mut j: Value = Value::Int(1);
2830 let mut __for_first_89: bool = true;
2831 while { if !__for_first_89 { if let Value::Int(n) = &mut j { *n += 1; } } __for_first_89 = false; j.as_f64().unwrap_or(f64::NAN) < ((groupedCurrenciesCode.len() as i64) as f64) } {
2832 let mut currentCurrency: Value = get_value(&groupedCurrenciesCode, &j);
2833 let mut currentPrecision: Value = self.safe_number_k(currentCurrency.clone(), "precision", &[]);
2834 let mut highestPrecision: Value = self.safe_number_k(highestPrecisionCurrency.clone(), "precision", &[]);
2835 if (currentPrecision == Value::Null) || (highestPrecision == Value::Null) {
2836 continue;
2837 }
2838 if (self.precisionMode.as_f64() == Value::Int(crate::runtime::TICK_SIZE).as_f64()) {
2839 if highestPrecision.as_f64().unwrap_or(f64::NAN) > currentPrecision.as_f64().unwrap_or(f64::NAN) {
2840 highestPrecisionCurrency = currentCurrency.clone();
2841 }
2842 } else if currentPrecision.as_f64().unwrap_or(f64::NAN) > highestPrecision.as_f64().unwrap_or(f64::NAN) {
2843 highestPrecisionCurrency = currentCurrency;
2844 }
2845 }
2846 }
2847 resultingCurrencies.push(highestPrecisionCurrency);
2848 }
2849 }
2850 { let __t = self.map_to_safe_map(self.deep_extend(self.currencies.clone(), &[self.index_by(self.sort_by(Value::from(resultingCurrencies), Value::Str("code".into()), &[]), Value::Str("code".into()))])); self.currencies = __t; }
2851 }
2852 { let __t = self.index_by_safe(self.currencies.clone(), Value::Str("id".into())); self.currencies_by_id = __t; }
2853 let mut currenciesSortedByCode: indexmap::IndexMap<String, Value> = self.keysort(self.currencies.clone(), &[]).as_map().cloned().unwrap_or_default();
2854 self.codes = Value::Array(currenciesSortedByCode.keys().map(|__k| Value::Str(__k.clone().into())).collect());
2855 if (self.markets.clone() == Value::Null) {
2856 panic!("{}", crate::exchange_errors::exchange_error(format!("{}{}", self.id.clone(), Value::Str(" setMarkets() markets not set".into()))));
2857 }
2858 return self.markets.clone();
2859
2860 Value::Null
2861}
2862
2863 fn set_markets_from_exchange(&mut self, mut sourceExchange: Value) -> Value {
2864 if !is_equal(&self.id, &get_value(&sourceExchange, &Value::Str("id".into()))) {
2866 panic!("{}", crate::exchange_errors::arguments_required(format!("{}{}", Value::Str(format!("{}{}", 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")).into()), Value::Str(")".into()))));
2867 }
2868 if (get_value(&sourceExchange, &Value::Str("markets".into())) == Value::Null) || (get_value(&sourceExchange, &Value::Str("markets".into())) == Value::Null) {
2870 panic!("{}", crate::exchange_errors::exchange_error("setMarketsFromExchange() source exchange must have loaded markets first. Can call by using loadMarkets function"));
2871 }
2872 self.markets = get_value(&sourceExchange, &Value::Str("markets".into()));
2874 self.markets_by_id = get_value(&sourceExchange, &Value::Str("markets_by_id".into()));
2875 self.symbols = get_value(&sourceExchange, &Value::Str("symbols".into()));
2876 self.ids = get_value(&sourceExchange, &Value::Str("ids".into()));
2877 self.currencies = get_value(&sourceExchange, &Value::Str("currencies".into()));
2878 self.currencies_by_id = get_value(&sourceExchange, &Value::Str("currencies_by_id".into()));
2879 self.baseCurrencies = get_value(&sourceExchange, &Value::Str("baseCurrencies".into()));
2880 self.quoteCurrencies = get_value(&sourceExchange, &Value::Str("quoteCurrencies".into()));
2881 self.codes = get_value(&sourceExchange, &Value::Str("codes".into()));
2882 let mut sourceExchangeHelpers: Vec<Value> = self.safe_list(get_value(&sourceExchange, &Value::Str("options".into())), Value::Str("marketHelperProps".into()), &[Value::from(vec![])]).as_array().cloned().unwrap_or_default();
2884 {
2885 let mut i: i64 = 0;
2886 let mut __for_first_91: bool = true;
2887 while { if !__for_first_91 { i += 1; } __for_first_91 = false; i < (sourceExchangeHelpers.len() as i64) } {
2888 let mut helper: Value = sourceExchangeHelpers.get(i as usize).cloned().unwrap_or(Value::Null);
2889 if (get_value(&get_value(&sourceExchange, &Value::Str("options".into())), &helper) != Value::Null) {
2890 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)); }
2891 }
2892 }
2893 }
2894 return Value::Null;
2895
2896 Value::Null
2897}
2898
2899 fn get_describe_for_extended_ws_exchange(&self, mut currentRestInstance: Value, mut parentRestInstance: Value, mut wsBaseDescribe: Value) -> Value {
2900 let mut extendedRestDescribe: Value = self.deep_extend(parentRestInstance.describe(), &[currentRestInstance.describe()]);
2901 let mut superWithRestDescribe: Value = self.deep_extend(extendedRestDescribe, &[wsBaseDescribe]);
2902 return superWithRestDescribe;
2903
2904 Value::Null
2905}
2906
2907 fn safe_balance(&self, mut balance: Value) -> Value {
2908 let mut balances: indexmap::IndexMap<String, 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())]), &[]).as_map().cloned().unwrap_or_default();
2909 let mut codes: Vec<Value> = Value::Array(balances.keys().map(|__k| Value::Str(__k.clone().into())).collect()).as_array().cloned().unwrap_or_default();
2910 let mut freeBalance: indexmap::IndexMap<String, Value> = ({
2911 let mut m = indexmap::IndexMap::new();
2912 m
2913 });
2914 let mut usedBalance: indexmap::IndexMap<String, Value> = ({
2915 let mut m = indexmap::IndexMap::new();
2916 m
2917 });
2918 let mut totalBalance: indexmap::IndexMap<String, Value> = ({
2919 let mut m = indexmap::IndexMap::new();
2920 m
2921 });
2922 let mut debtBalance: indexmap::IndexMap<String, Value> = ({
2923 let mut m = indexmap::IndexMap::new();
2924 m
2925 });
2926 {
2927 let mut i: i64 = 0;
2928 let mut __for_first_92: bool = true;
2929 while { if !__for_first_92 { i += 1; } __for_first_92 = false; i < (codes.len() as i64) } {
2930 let mut code: Value = codes.get(i as usize).cloned().unwrap_or(Value::Null);
2931 let mut total: Value = self.safe_string(balances.get(code.as_str().unwrap_or("")).cloned().unwrap_or(Value::Null), Value::Str("total".into()), &[]);
2932 let mut free: Value = self.safe_string(balances.get(code.as_str().unwrap_or("")).cloned().unwrap_or(Value::Null), Value::Str("free".into()), &[]);
2933 let mut used: Value = self.safe_string(balances.get(code.as_str().unwrap_or("")).cloned().unwrap_or(Value::Null), Value::Str("used".into()), &[]);
2934 let mut debt: Option<String> = self.safe_string_opt(balances.get(code.as_str().unwrap_or("")).cloned().unwrap_or(Value::Null), Value::Str("debt".into()), &[]);
2935 if (total == Value::Null) && (free != Value::Null) && (used != Value::Null) {
2936 total = crate::precise::Precise::stringAdd(&free, &used);
2937 }
2938 if (free == Value::Null) && (total != Value::Null) && (used != Value::Null) {
2939 free = crate::precise::Precise::stringSub(&total, &used);
2940 }
2941 if (used == Value::Null) && (total != Value::Null) && (free != Value::Null) {
2942 used = crate::precise::Precise::stringSub(&total, &free);
2943 }
2944 freeBalance.insert(crate::runtime::stringify_param(&code), self.parse_number(free, &[]));
2945 usedBalance.insert(crate::runtime::stringify_param(&code), self.parse_number(used, &[]));
2946 totalBalance.insert(crate::runtime::stringify_param(&code), self.parse_number(total, &[]));
2947 let mut entry: indexmap::IndexMap<String, Value> = ({
2948 let mut m = indexmap::IndexMap::new();
2949 m.insert("free".to_string(), freeBalance.get(code.as_str().unwrap_or("")).cloned().unwrap_or(Value::Null));
2950 m.insert("used".to_string(), usedBalance.get(code.as_str().unwrap_or("")).cloned().unwrap_or(Value::Null));
2951 m.insert("total".to_string(), totalBalance.get(code.as_str().unwrap_or("")).cloned().unwrap_or(Value::Null));
2952 m
2953 });
2954 if (debt.is_some()) {
2955 debtBalance.insert(crate::runtime::stringify_param(&code), self.parse_number(debt.map(Value::from).unwrap_or(Value::Null), &[]));
2956 entry.insert("debt".into(), debtBalance.get(code.as_str().unwrap_or("")).cloned().unwrap_or(Value::Null));
2957 }
2958 if let Value::Dict(__d) = &mut balance { std::sync::Arc::make_mut(__d).insert(crate::runtime::stringify_param(&code), self.extend(balances.get(code.as_str().unwrap_or("")).cloned().unwrap_or(Value::Null), &[Value::Map(entry)])); }
2959 }
2960 }
2961 if let Value::Dict(__d) = &mut balance { std::sync::Arc::make_mut(__d).insert("free".into(), Value::Map(freeBalance)); }
2962 if let Value::Dict(__d) = &mut balance { std::sync::Arc::make_mut(__d).insert("used".into(), Value::Map(usedBalance)); }
2963 if let Value::Dict(__d) = &mut balance { std::sync::Arc::make_mut(__d).insert("total".into(), Value::Map(totalBalance)); }
2964 let mut debtBalanceArray: Vec<Value> = Value::Array(debtBalance.keys().map(|__k| Value::Str(__k.clone().into())).collect()).as_array().cloned().unwrap_or_default();
2965 let mut length: f64 = ((debtBalanceArray.len() as i64) as f64);
2966 if (length != 0.0) {
2967 if let Value::Dict(__d) = &mut balance { std::sync::Arc::make_mut(__d).insert("debt".into(), Value::Map(debtBalance)); }
2968 }
2969 return balance;
2970
2971 Value::Null
2972}
2973
2974 fn safe_order(&self, mut order: Value, optional_args: &[Value]) -> Value {
2975 let mut market = get_arg(optional_args, 0, Value::Null);
2976 let mut orderDict: Value = order.clone();
2979 if (order == Value::Null) {
2980 orderDict = Value::Map({
2981 let mut m = indexmap::IndexMap::new();
2982 m
2983 });
2984 }
2985 let mut amount: Value = self.omit_zero(self.safe_string_k(orderDict.clone(), "amount", &[]));
2986 let mut remaining: Value = self.safe_string_k(orderDict.clone(), "remaining", &[]);
2987 let mut filled: Value = self.safe_string_k(orderDict.clone(), "filled", &[]);
2988 let mut cost: Value = self.safe_string_k(orderDict.clone(), "cost", &[]);
2989 let mut average: Value = self.omit_zero(self.safe_string_k(orderDict.clone(), "average", &[]));
2990 let mut price: Value = self.omit_zero(self.safe_string_k(orderDict.clone(), "price", &[]));
2991 let mut lastTradeTimeTimestamp: Value = self.safe_integer_k(orderDict.clone(), "lastTradeTimestamp", &[]);
2992 let mut symbol: Option<String> = self.safe_string_k_opt(orderDict.clone(), "symbol", &[]);
2993 let mut side: Option<String> = self.safe_string_k_opt(orderDict.clone(), "side", &[]);
2994 let mut status: Option<String> = self.safe_string_k_opt(orderDict.clone(), "status", &[]);
2995 let mut parseFilled: bool = filled == Value::Null;
2996 let mut parseCost: bool = cost == Value::Null;
2997 let mut parseLastTradeTimeTimestamp: bool = lastTradeTimeTimestamp == Value::Null;
2998 let mut fee: Value = self.safe_value_k(orderDict.clone(), "fee", &[]);
2999 let mut parseFee: bool = fee == Value::Null;
3000 let mut parseFees: bool = self.safe_value_k(orderDict.clone(), "fees", &[]) == Value::Null;
3001 let mut parseSymbol: bool = symbol.is_none();
3002 let mut parseSide: bool = side.is_none();
3003 let mut shouldParseFees: bool = parseFee || parseFees;
3004 let mut fees: Value = self.safe_list_k(orderDict.clone(), "fees", &[Value::from(vec![])]);
3005 let mut trades: Value = Value::from(vec![]);
3006 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);
3007 if parseFilled || parseCost || shouldParseFees {
3008 let mut rawTrades: Value = self.safe_value_k(orderDict.clone(), "trades", &[trades.clone()]);
3009 let mut firstTrade: Value = self.safe_value(rawTrades.clone(), Value::Int(0), &[]);
3014 let mut tradesAreParsed: bool = (firstTrade != Value::Null) && (in_op(&firstTrade, &Value::Str("info".into()))) && (in_op(&firstTrade, &Value::Str("id".into())));
3016 if !tradesAreParsed {
3017 trades = self.parse_trades(rawTrades.clone(), &[market.clone()]);
3018 } else {
3019 trades = rawTrades;
3020 }
3021 let mut tradesLength: i64 = 0;
3023 let mut isArray: bool = matches!(&trades, Value::Arr(_));
3024 if isArray {
3025 tradesLength = trades.len() as i64;
3026 }
3027 if isArray && ((tradesLength as f64) > ((0i64) as f64)) {
3028 if parseSymbol {
3030 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"));
3031 }
3032 if parseSide {
3033 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"));
3034 }
3035 if (self.safe_string_k(orderDict.clone(), "type", &[]) == Value::Null) {
3036 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"));
3037 }
3038 if (self.safe_string_k(orderDict.clone(), "id", &[]) == Value::Null) {
3039 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"));
3040 }
3041 if parseFilled {
3042 filled = Value::Str("0".into());
3043 }
3044 if parseCost {
3045 cost = Value::Str("0".into());
3046 }
3047 {
3048 let mut i: i64 = 0;
3049 let mut __for_first_94: bool = true;
3050 while { if !__for_first_94 { i += 1; } __for_first_94 = false; i < (trades.len() as i64) } {
3051 let mut trade: Value = trades.as_array().map(Vec::as_slice).unwrap_or_default().get(i as usize).cloned().unwrap_or(Value::Null);
3052 let mut tradeAmount: Option<String> = self.safe_string_k_opt(trade.clone(), "amount", &[]);
3053 if parseFilled && (tradeAmount.is_some()) {
3054 filled = crate::precise::Precise::stringAdd(&filled, &tradeAmount.clone().map(Value::from).unwrap_or(Value::Null));
3055 }
3056 let mut tradeCost: Option<String> = self.safe_string_k_opt(trade.clone(), "cost", &[]);
3057 if parseCost && (tradeCost.is_some()) {
3058 cost = crate::precise::Precise::stringAdd(&cost, &tradeCost.clone().map(Value::from).unwrap_or(Value::Null));
3059 }
3060 if parseSymbol {
3061 symbol = self.safe_string_k_opt(trade.clone(), "symbol", &[]);
3062 }
3063 if parseSide {
3064 side = self.safe_string_k_opt(trade.clone(), "side", &[]);
3065 }
3066 let mut tradeTimestamp: Value = self.safe_integer_k(trade.clone(), "timestamp", &[]);
3067 if parseLastTradeTimeTimestamp && (tradeTimestamp != Value::Null) {
3068 if (lastTradeTimeTimestamp == Value::Null) || tradeTimestamp.as_f64().unwrap_or(f64::NAN) > lastTradeTimeTimestamp.as_f64().unwrap_or(f64::NAN) {
3069 lastTradeTimeTimestamp = tradeTimestamp;
3070 }
3071 }
3072 if shouldParseFees {
3073 let mut tradeFees: Value = self.safe_list_k(trade.clone(), "fees", &[]);
3074 if (tradeFees != Value::Null) {
3075 {
3076 let mut j: i64 = 0;
3077 let mut __for_first_93: bool = true;
3078 while { if !__for_first_93 { j += 1; } __for_first_93 = false; j < (tradeFees.len() as i64) } {
3079 let mut tradeFee: Value = tradeFees.as_array().map(Vec::as_slice).unwrap_or_default().get(j as usize).cloned().unwrap_or(Value::Null);
3080 if let Value::Arr(__a) = &mut fees { std::sync::Arc::make_mut(__a).push(self.extend(Value::Map({
3081 let mut m = indexmap::IndexMap::new();
3082 m
3083 }), &[tradeFee.clone()])); }
3084 }
3085 }
3086 } else {
3087 let mut tradeFee: Value = self.safe_value_k(trade, "fee", &[]);
3088 if (tradeFee != Value::Null) {
3089 if let Value::Arr(__a) = &mut fees { std::sync::Arc::make_mut(__a).push(self.extend(Value::Map({
3090 let mut m = indexmap::IndexMap::new();
3091 m
3092 }), &[tradeFee.clone()])); }
3093 }
3094 }
3095 }
3096 }
3097 }
3098 }
3099 }
3100 if shouldParseFees {
3101 let mut reducedFees: Value = fees.clone();
3102 if self.reduceFees.as_bool() == Some(true) {
3103 reducedFees = self.reduce_fees_by_currency(fees);
3104 }
3105 if (reducedFees == Value::Null) {
3106 reducedFees = Value::from(vec![]);
3107 }
3108 let mut reducedLength: f64 = ((reducedFees.len() as i64) as f64);
3109 {
3110 let mut i: Value = Value::Int(0);
3111 let mut __for_first_95: bool = true;
3112 while { if !__for_first_95 { if let Value::Int(n) = &mut i { *n += 1; } } __for_first_95 = false; i.as_f64().unwrap_or(f64::NAN) < reducedLength } {
3113 { 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); };
3114 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()))) {
3115 { 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); };
3116 }
3117 }
3118 }
3119 if !(parseFee) && (reducedLength == 0.0) {
3120 let mut feeCopy: Value = self.deep_extend(fee, &[]);
3122 { let __be_tmp = self.safe_number_k(feeCopy.clone(), "cost", &[]); add_element_to_object(&mut feeCopy, &Value::Str("cost".into()), __be_tmp); };
3123 if (feeCopy.as_map().is_some_and(|__m| __m.contains_key("rate"))) {
3124 { let __be_tmp = self.safe_number_k(feeCopy.clone(), "rate", &[]); add_element_to_object(&mut feeCopy, &Value::Str("rate".into()), __be_tmp); };
3125 }
3126 append_to_array(&mut reducedFees, feeCopy);
3127 }
3128 add_element_to_object(&mut orderDict, &Value::Str("fees".into()), reducedFees.clone());
3129 if parseFee && (reducedLength == 1.0) {
3130 add_element_to_object(&mut orderDict, &Value::Str("fee".into()), reducedFees.as_array().and_then(|__arr| __arr.get(0)).cloned().unwrap_or(Value::Null));
3131 }
3132 }
3133 if (amount == Value::Null) {
3134 if (filled != Value::Null) && (remaining != Value::Null) {
3136 amount = crate::precise::Precise::stringAdd(&filled, &remaining);
3137 } else if (status.as_deref() == Some("closed")) {
3138 amount = filled.clone();
3139 }
3140 }
3141 if (filled == Value::Null) {
3142 if (amount != Value::Null) && (remaining != Value::Null) {
3143 filled = crate::precise::Precise::stringSub(&amount, &remaining);
3144 } else if (status.as_deref() == Some("closed")) && (amount != Value::Null) {
3145 filled = amount.clone();
3146 }
3147 }
3148 if (remaining == Value::Null) {
3149 if (amount != Value::Null) && (filled != Value::Null) {
3150 remaining = crate::precise::Precise::stringSub(&amount, &filled);
3151 } else if (status.as_deref() == Some("closed")) {
3152 remaining = Value::Str("0".into());
3153 }
3154 }
3155 let mut inverse: bool = self.safe_bool_k_opt(market.clone(), "inverse", &[Value::Bool(false)]).unwrap_or(false);
3157 let mut contractSize: Value = self.number_to_string(self.safe_value_k(market, "contractSize", &[Value::Int(1)]));
3158 if (average == Value::Null) {
3164 if (filled != Value::Null) && (cost != Value::Null) && crate::precise::Precise::stringGt(&filled, &Value::Str("0".into())).as_bool() == Some(true) {
3165 let mut filledTimesContractSize: Value = crate::precise::Precise::stringMul(&filled, &contractSize);
3166 if inverse {
3167 average = crate::precise::Precise::stringDiv(&filledTimesContractSize, &cost);
3168 } else {
3169 average = crate::precise::Precise::stringDiv(&cost, &filledTimesContractSize);
3170 }
3171 }
3172 }
3173 let mut costPriceExists: bool = (average != Value::Null) || (price != Value::Null);
3180 if parseCost && (filled != Value::Null) && costPriceExists {
3181 let mut multiplyPrice: Value = Value::Null;
3182 if (average == Value::Null) {
3183 multiplyPrice = price.clone();
3184 } else {
3185 multiplyPrice = average.clone();
3186 }
3187 let mut filledTimesContractSize: Value = crate::precise::Precise::stringMul(&filled, &contractSize);
3189 if inverse {
3190 cost = crate::precise::Precise::stringDiv(&filledTimesContractSize, &multiplyPrice);
3191 } else {
3192 cost = crate::precise::Precise::stringMul(&filledTimesContractSize, &multiplyPrice);
3193 }
3194 }
3195 let mut orderType: Option<String> = self.safe_string_k(orderDict.clone(), "type", &[]).as_str().map(str::to_owned);
3197 let mut emptyPrice: bool = (price == Value::Null) || crate::precise::Precise::stringEquals(&price, &Value::Str("0".into())).as_bool() == Some(true);
3198 if emptyPrice && (orderType.as_deref() == Some("market")) {
3199 price = average.clone();
3200 }
3201 {
3202 let mut i: Value = Value::Int(0);
3203 let mut __for_first_97: bool = true;
3204 while { if !__for_first_97 { if let Value::Int(n) = &mut i { *n += 1; } } __for_first_97 = false; i.as_f64().unwrap_or(f64::NAN) < ((trades.len() as i64) as f64) } {
3205 let mut entry: Value = get_value(&trades, &i);
3206 { let __be_tmp = self.safe_number_k(entry.clone(), "amount", &[]); add_element_to_object(&mut entry, &Value::Str("amount".into()), __be_tmp); };
3207 { let __be_tmp = self.safe_number_k(entry.clone(), "price", &[]); add_element_to_object(&mut entry, &Value::Str("price".into()), __be_tmp); };
3208 { let __be_tmp = self.safe_number_k(entry.clone(), "cost", &[]); add_element_to_object(&mut entry, &Value::Str("cost".into()), __be_tmp); };
3209 let mut tradeFee: Value = self.safe_dict_k(entry.clone(), "fee", &[Value::Map({
3210 let mut m = indexmap::IndexMap::new();
3211 m
3212})]);
3213 { 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); } }
3214 if (matches!(&tradeFee, Value::Dict(__d) if __d.contains_key("rate"))) {
3215 { 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); } }
3216 }
3217 let mut entryFees: Value = self.safe_list_k(entry.clone(), "fees", &[Value::from(vec![])]);
3218 {
3219 let mut j: Value = Value::Int(0);
3220 let mut __for_first_96: bool = true;
3221 while { if !__for_first_96 { if let Value::Int(n) = &mut j { *n += 1; } } __for_first_96 = false; j.as_f64().unwrap_or(f64::NAN) < ((entryFees.len() as i64) as f64) } {
3222 { 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); };
3223 }
3224 }
3225 add_element_to_object(&mut entry, &Value::Str("fees".into()), entryFees);
3226 add_element_to_object(&mut entry, &Value::Str("fee".into()), tradeFee);
3227 }
3228 }
3229 let mut timeInForce: Value = self.safe_string_k(orderDict.clone(), "timeInForce", &[]);
3230 let mut postOnly: Value = self.safe_value_k(orderDict.clone(), "postOnly", &[]);
3231 if (timeInForce == Value::Null) {
3233 if !isTriggerOrSLTpOrder && (self.safe_string_k(orderDict.clone(), "type", &[]).as_str() == Some("market")) {
3234 timeInForce = Value::Str("IOC".into());
3235 }
3236 if (match &(postOnly) { Value::Bool(__x) => *__x == true, __v => matches!((match __v { Value::Int(__n) => Some(*__n as f64), Value::Float(__f) => Some(*__f), Value::Str(__s) => __s.parse::<f64>().ok(), Value::Bool(__b) => Some(if *__b { 1.0 } else { 0.0 }), _ => None }), Some(__y) if __y == 1.0) }) {
3238 timeInForce = Value::Str("PO".into());
3239 }
3240 } else if (postOnly == Value::Null) {
3241 postOnly = Value::Bool(timeInForce.as_str() == Some("PO"));
3243 }
3244 let mut timestamp: Option<i64> = self.safe_integer_k(orderDict.clone(), "timestamp", &[]).as_i64();
3245 let mut lastUpdateTimestamp: Option<i64> = self.safe_integer_k(orderDict.clone(), "lastUpdateTimestamp", &[]).as_i64();
3246 let mut datetime: Value = self.safe_string_k(orderDict.clone(), "datetime", &[]);
3247 if (datetime == Value::Null) {
3248 datetime = self.iso8601(Value::from(timestamp));
3249 }
3250 let mut triggerPrice: Value = self.parse_number(self.safe_string2(orderDict.clone(), Value::Str("triggerPrice".into()), Value::Str("stopPrice".into()), &[]), &[]);
3251 let mut takeProfitPrice: Value = self.parse_number(self.safe_string_k(orderDict.clone(), "takeProfitPrice", &[]), &[]);
3252 let mut stopLossPrice: Value = self.parse_number(self.safe_string_k(orderDict.clone(), "stopLossPrice", &[]), &[]);
3253 return self.extend(orderDict.clone(), &[Value::Map({
3254 let mut m = indexmap::IndexMap::new();
3255 m.insert("id".to_string(), self.safe_string_k(orderDict.clone(), "id", &[]));
3256 m.insert("clientOrderId".to_string(), self.safe_string_k(orderDict.clone(), "clientOrderId", &[]));
3257 m.insert("timestamp".to_string(), Value::from(timestamp));
3258 m.insert("datetime".to_string(), datetime);
3259 m.insert("symbol".to_string(), symbol.clone().map(Value::from).unwrap_or(Value::Null));
3260 m.insert("type".to_string(), self.safe_string_k(orderDict.clone(), "type", &[]));
3261 m.insert("side".to_string(), side.clone().map(Value::from).unwrap_or(Value::Null));
3262 m.insert("lastTradeTimestamp".to_string(), lastTradeTimeTimestamp);
3263 m.insert("lastUpdateTimestamp".to_string(), Value::from(lastUpdateTimestamp));
3264 m.insert("price".to_string(), self.parse_number(price, &[]));
3265 m.insert("amount".to_string(), self.parse_number(amount, &[]));
3266 m.insert("cost".to_string(), self.parse_number(cost, &[]));
3267 m.insert("average".to_string(), self.parse_number(average, &[]));
3268 m.insert("filled".to_string(), self.parse_number(filled, &[]));
3269 m.insert("remaining".to_string(), self.parse_number(remaining, &[]));
3270 m.insert("timeInForce".to_string(), timeInForce);
3271 m.insert("postOnly".to_string(), postOnly);
3272 m.insert("trades".to_string(), trades);
3273 m.insert("reduceOnly".to_string(), self.safe_value_k(orderDict.clone(), "reduceOnly", &[]));
3274 m.insert("stopPrice".to_string(), triggerPrice.clone());
3275 m.insert("triggerPrice".to_string(), triggerPrice);
3276 m.insert("takeProfitPrice".to_string(), takeProfitPrice);
3277 m.insert("stopLossPrice".to_string(), stopLossPrice);
3278 m.insert("status".to_string(), status.clone().map(Value::from).unwrap_or(Value::Null));
3279 m.insert("fee".to_string(), self.safe_value_k(orderDict, "fee", &[]));
3280 m
3281})]);
3282
3283 Value::Null
3284}
3285
3286 fn parse_orders(&self, mut orders: Value, optional_args: &[Value]) -> Value {
3287 let mut market = get_arg(optional_args, 0, Value::Null);
3288 let mut since = get_arg(optional_args, 1, Value::Null);
3289 let mut limit = get_arg(optional_args, 2, Value::Null);
3290 let mut params = get_arg(optional_args, 3, Value::Map({
3291 let mut m = indexmap::IndexMap::new();
3292 m
3293}));
3294 if (orders == Value::Null) {
3316 return Value::from(vec![]);
3317 }
3318 let mut results: Value = Value::from(vec![]);
3319 if (matches!(&orders, Value::Arr(_))) {
3320 {
3321 let mut i: Value = Value::Int(0);
3322 let mut __for_first_98: bool = true;
3323 while { if !__for_first_98 { if let Value::Int(n) = &mut i { *n += 1; } } __for_first_98 = false; i.as_f64().unwrap_or(f64::NAN) < ((orders.len() as i64) as f64) } {
3324 let mut parsed: Value = <Self as crate::exchange_generated::ExchangeBase>::parse_order(self, get_value(&orders, &i), &[market.clone()]); let mut order: Value = self.extend(parsed, &[params.clone()]);
3326 if let Value::Arr(__a) = &mut results { std::sync::Arc::make_mut(__a).push(order.clone()); }
3327 }
3328 }
3329 } else {
3330 let mut ids: Vec<Value> = object_keys(&orders).as_array().cloned().unwrap_or_default();
3331 {
3332 let mut i: i64 = 0;
3333 let mut __for_first_99: bool = true;
3334 while { if !__for_first_99 { i += 1; } __for_first_99 = false; i < (ids.len() as i64) } {
3335 let mut id: Value = ids.get(i as usize).cloned().unwrap_or(Value::Null);
3336 let mut idExtended: Value = self.extend(Value::Map({
3337 let mut m = indexmap::IndexMap::new();
3338 m.insert("id".to_string(), id.clone());
3339 m
3340 }), &[get_value(&orders, &id)]);
3341 let mut parsedOrder: Value = <Self as crate::exchange_generated::ExchangeBase>::parse_order(self, idExtended, &[market.clone()]); let mut order: Value = self.extend(parsedOrder, &[params.clone()]);
3343 if let Value::Arr(__a) = &mut results { std::sync::Arc::make_mut(__a).push(order); }
3344 }
3345 }
3346 }
3347 results = self.sort_by(results.clone(), Value::Str("timestamp".into()), &[]);
3348 let mut symbol: Option<String> = self.safe_string_k_opt(market, "symbol", &[]);
3349 return self.filter_by_symbol_since_limit(results, &[symbol.map(Value::from).unwrap_or(Value::Null), since, limit]);
3350
3351 Value::Null
3352}
3353
3354 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 {
3355 let mut takerOrMaker = get_arg(optional_args, 0, Value::Str("taker".into()));
3356 let mut feeRate = get_arg(optional_args, 1, Value::Null);
3357 let mut params = get_arg(optional_args, 2, Value::Map({
3358 let mut m = indexmap::IndexMap::new();
3359 m
3360}));
3361 if (type_var.as_str() == Some("market")) && (takerOrMaker.as_str() == Some("maker")) {
3362 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()))));
3363 }
3364 let mut markets: Value = self.markets.clone();
3365 if (markets == Value::Null) {
3366 panic!("{}", crate::exchange_errors::exchange_error(format!("{}{}", self.id.clone(), Value::Str(" markets not loaded".into()))));
3367 }
3368 let mut market: indexmap::IndexMap<String, Value> = self.safe_dict(markets, symbol, &[Value::Map({
3369 let mut m = indexmap::IndexMap::new();
3370 m
3371})]).as_map().cloned().unwrap_or_default();
3372 let mut feeSide: Option<String> = self.safe_string(Value::Map(market.clone()), Value::Str("feeSide".into()), &[Value::Str("quote".into())]).as_str().map(str::to_owned);
3373 let mut useQuote: Value = Value::Null;
3374 if (feeSide.as_deref() == Some("get")) {
3375 useQuote = Value::Bool(side.as_str() == Some("sell"));
3377 } else if (feeSide.as_deref() == Some("give")) {
3378 useQuote = Value::Bool(side.as_str() == Some("buy"));
3380 } else {
3381 useQuote = Value::Bool(feeSide.as_deref() == Some("quote"));
3383 }
3384 let mut cost: Value = self.number_to_string(amount);
3385 let mut key: Value = Value::Null;
3386 if useQuote.as_bool() == Some(true) {
3387 let mut priceString: Value = self.number_to_string(price);
3388 cost = crate::precise::Precise::stringMul(&cost, &priceString);
3389 key = Value::Str("quote".into());
3390 } else {
3391 key = Value::Str("base".into());
3392 }
3393 if !(match &(market.get("spot").cloned().unwrap_or(Value::Null)) { Value::Bool(__x) => *__x == true, __v => matches!((match __v { Value::Int(__n) => Some(*__n as f64), Value::Float(__f) => Some(*__f), Value::Str(__s) => __s.parse::<f64>().ok(), Value::Bool(__b) => Some(if *__b { 1.0 } else { 0.0 }), _ => None }), Some(__y) if __y == 1.0) }) {
3395 key = Value::Str("settle".into());
3396 }
3397 let mut takerOrMakerResolved: Value = (if (type_var.as_str() == Some("market")) { Value::Str("taker".into()) } else { takerOrMaker });
3399 let mut rate: Value = (if (feeRate != Value::Null) { self.number_to_string(feeRate) } else { self.safe_string(Value::Map(market.clone()), takerOrMakerResolved.clone(), &[]) });
3400 cost = crate::precise::Precise::stringMul(&cost, &rate);
3401 return Value::Map({
3402 let mut m = indexmap::IndexMap::new();
3403 m.insert("type".to_string(), takerOrMakerResolved);
3404 m.insert("currency".to_string(), market.get(key.as_str().unwrap_or("")).cloned().unwrap_or(Value::Null));
3405 m.insert("rate".to_string(), self.parse_number(rate, &[]));
3406 m.insert("cost".to_string(), self.parse_number(cost, &[]));
3407 m
3408});
3409
3410 Value::Null
3411}
3412
3413 fn calculate_fee(&self, mut symbol: Value, mut type_var: Value, mut side: Value, mut amount: Value, mut price: Value, optional_args: &[Value]) -> Value {
3414 let mut takerOrMaker = get_arg(optional_args, 0, Value::Str("taker".into()));
3415 let mut params = get_arg(optional_args, 1, Value::Map({
3416 let mut m = indexmap::IndexMap::new();
3417 m
3418}));
3419 return self.calculate_fee_with_rate(symbol, type_var, side, amount, price, &[takerOrMaker, Value::Null, params]);
3420
3421 Value::Null
3422}
3423
3424 fn safe_liquidation(&self, mut liquidation: Value, optional_args: &[Value]) -> Value {
3425 let mut market = get_arg(optional_args, 0, Value::Null);
3426 let __market_empty = indexmap::IndexMap::new();
3427 let market = market.as_map().unwrap_or(&__market_empty);
3428 let mut contracts: Option<String> = self.safe_string_k_opt(liquidation.clone(), "contracts", &[]);
3429 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 });
3430 let mut price: Option<String> = self.safe_string_k_opt(liquidation.clone(), "price", &[]);
3431 let mut baseValue: Value = self.safe_string_k(liquidation.clone(), "baseValue", &[]);
3432 let mut quoteValue: Value = self.safe_string_k(liquidation.clone(), "quoteValue", &[]);
3433 if (baseValue == Value::Null) && (contracts.is_some()) && (contractSize != Value::Null) && (price.is_some()) {
3434 baseValue = crate::precise::Precise::stringMul(&contracts.clone().map(Value::from).unwrap_or(Value::Null), &contractSize);
3435 }
3436 if (quoteValue == Value::Null) && (baseValue != Value::Null) && (price.is_some()) {
3437 quoteValue = crate::precise::Precise::stringMul(&baseValue, &price.clone().map(Value::from).unwrap_or(Value::Null));
3438 }
3439 if let Value::Dict(__d) = &mut liquidation { std::sync::Arc::make_mut(__d).insert("contracts".into(), self.parse_number(contracts.map(Value::from).unwrap_or(Value::Null), &[])); }
3440 if let Value::Dict(__d) = &mut liquidation { std::sync::Arc::make_mut(__d).insert("contractSize".into(), self.parse_number(contractSize, &[])); }
3441 if let Value::Dict(__d) = &mut liquidation { std::sync::Arc::make_mut(__d).insert("price".into(), self.parse_number(price.map(Value::from).unwrap_or(Value::Null), &[])); }
3442 if let Value::Dict(__d) = &mut liquidation { std::sync::Arc::make_mut(__d).insert("baseValue".into(), self.parse_number(baseValue, &[])); }
3443 if let Value::Dict(__d) = &mut liquidation { std::sync::Arc::make_mut(__d).insert("quoteValue".into(), self.parse_number(quoteValue, &[])); }
3444 return liquidation;
3445
3446 Value::Null
3447}
3448
3449 fn safe_trade(&self, mut trade: Value, optional_args: &[Value]) -> Value {
3450 let mut market = get_arg(optional_args, 0, Value::Null);
3451 let __market_empty = indexmap::IndexMap::new();
3452 let market = market.as_map().unwrap_or(&__market_empty);
3453 let mut amount: Option<String> = self.safe_string_k_opt(trade.clone(), "amount", &[]);
3454 let mut price: Option<String> = self.safe_string_k_opt(trade.clone(), "price", &[]);
3455 let mut cost: Value = self.safe_string_k(trade.clone(), "cost", &[]);
3456 if (cost == Value::Null) {
3457 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 });
3459 let mut multiplyPrice: Value = price.clone().map(Value::from).unwrap_or(Value::Null);
3460 if (contractSize != Value::Null) {
3461 let mut inverse: Value = (match market.get("inverse") { Some(Value::Bool(__b)) => Value::Bool(*__b), _ => Value::Bool(false) });
3462 if inverse.as_bool() == Some(true) {
3463 multiplyPrice = crate::precise::Precise::stringDiv(&Value::Str("1".into()), &price.clone().map(Value::from).unwrap_or(Value::Null));
3464 }
3465 multiplyPrice = crate::precise::Precise::stringMul(&multiplyPrice, &contractSize);
3466 }
3467 cost = crate::precise::Precise::stringMul(&multiplyPrice, &amount.clone().map(Value::from).unwrap_or(Value::Null));
3468 }
3469 let resultFeeresultFeesVariable: Vec<Value> = self.parsed_fee_and_fees(trade.clone()).as_array().cloned().unwrap_or_default();
3470 let mut resultFee: Value = resultFeeresultFeesVariable.get(0).cloned().unwrap_or(Value::Null);
3471 let mut resultFees: Value = resultFeeresultFeesVariable.get(1).cloned().unwrap_or(Value::Null);
3472 if let Value::Dict(__d) = &mut trade { std::sync::Arc::make_mut(__d).insert("fee".into(), resultFee); }
3473 if let Value::Dict(__d) = &mut trade { std::sync::Arc::make_mut(__d).insert("fees".into(), resultFees); }
3474 if let Value::Dict(__d) = &mut trade { std::sync::Arc::make_mut(__d).insert("amount".into(), self.parse_number(amount.map(Value::from).unwrap_or(Value::Null), &[])); }
3475 if let Value::Dict(__d) = &mut trade { std::sync::Arc::make_mut(__d).insert("price".into(), self.parse_number(price.map(Value::from).unwrap_or(Value::Null), &[])); }
3476 if let Value::Dict(__d) = &mut trade { std::sync::Arc::make_mut(__d).insert("cost".into(), self.parse_number(cost, &[])); }
3477 return trade;
3478
3479 Value::Null
3480}
3481
3482 fn create_ccxt_trade_id(&self, optional_args: &[Value]) -> Value {
3483 let mut timestamp = get_arg(optional_args, 0, Value::Null);
3484 let mut side = get_arg(optional_args, 1, Value::Null);
3485 let mut amount = get_arg(optional_args, 2, Value::Null);
3486 let mut price = get_arg(optional_args, 3, Value::Null);
3487 let mut takerOrMaker = get_arg(optional_args, 4, Value::Null);
3488 let mut id: Value = Value::Null;
3490 if (timestamp != Value::Null) {
3491 id = self.number_to_string(timestamp);
3492 if (side != Value::Null) {
3493 id = Value::Str(format!("{}{}", id, Value::Str(format!("{}{}", Value::Str("-".into()), side).into())).into());
3494 }
3495 if (amount != Value::Null) {
3496 id = Value::Str(format!("{}{}", id, Value::Str(format!("{}{}", Value::Str("-".into()), amount).into())).into());
3497 }
3498 if (price != Value::Null) {
3499 id = Value::Str(format!("{}{}", id, Value::Str(format!("{}{}", Value::Str("-".into()), price).into())).into());
3500 }
3501 if (takerOrMaker != Value::Null) {
3502 id = Value::Str(format!("{}{}", id, Value::Str(format!("{}{}", Value::Str("-".into()), takerOrMaker).into())).into());
3503 }
3504 }
3505 return id;
3506
3507 Value::Null
3508}
3509
3510 fn parsed_fee_and_fees(&self, mut container: Value) -> Value {
3511 let mut fee: Value = self.safe_dict_k(container.clone(), "fee", &[]);
3512 let mut fees: Value = self.safe_list_k(container, "fees", &[]);
3513 let mut feeDefined: bool = fee != Value::Null;
3514 let mut feesDefined: bool = fees != Value::Null;
3515 let mut shouldParseFees: bool = feeDefined || feesDefined;
3517 if shouldParseFees {
3518 if feeDefined {
3519 fee = self.parse_fee_numeric(fee.clone());
3520 }
3521 if !(feesDefined) {
3522 fees = Value::from(vec![fee.clone()]);
3524 }
3525 let mut reducedFees: Value = fees.clone();
3527 if self.reduceFees.as_bool() == Some(true) {
3528 reducedFees = self.reduce_fees_by_currency(fees.clone());
3529 }
3530 if (reducedFees == Value::Null) {
3531 reducedFees = Value::from(vec![]);
3532 }
3533 let mut reducedLength: f64 = ((reducedFees.len() as i64) as f64);
3534 {
3535 let mut i: Value = Value::Int(0);
3536 let mut __for_first_100: bool = true;
3537 while { if !__for_first_100 { if let Value::Int(n) = &mut i { *n += 1; } } __for_first_100 = false; i.as_f64().unwrap_or(f64::NAN) < reducedLength } {
3538 { let __be_tmp = self.parse_fee_numeric(get_value(&reducedFees, &i)); add_element_to_object(&mut reducedFees, &i, __be_tmp); };
3539 }
3540 }
3541 fees = reducedFees.clone();
3542 if (reducedLength == 1.0) {
3543 fee = reducedFees.as_array().and_then(|__arr| __arr.get(0)).cloned().unwrap_or(Value::Null);
3544 } else if (reducedLength == 0.0) {
3545 fee = Value::Null;
3546 }
3547 }
3548 if (fee == Value::Null) {
3550 fee = Value::Map({
3551 let mut m = indexmap::IndexMap::new();
3552 m.insert("cost".to_string(), Value::Null);
3553 m.insert("currency".to_string(), Value::Null);
3554 m
3555 });
3556 }
3557 if (fees == Value::Null) {
3558 fees = Value::from(vec![]);
3559 }
3560 return Value::from(vec![fee, fees]);
3561
3562 Value::Null
3563}
3564
3565 fn parse_fee_numeric(&self, mut fee: Value) -> Value {
3566 { let __be_tmp = self.safe_number_k(fee.clone(), "cost", &[]); add_element_to_object(&mut fee, &Value::Str("cost".into()), __be_tmp); }; if (in_op(&fee, &Value::Str("rate".into()))) {
3568 { let __be_tmp = self.safe_number_k(fee.clone(), "rate", &[]); add_element_to_object(&mut fee, &Value::Str("rate".into()), __be_tmp); };
3569 }
3570 return fee;
3571
3572 Value::Null
3573}
3574
3575 fn find_nearest_ceiling(&self, mut arr: Value, mut providedValue: Value) -> Value {
3576 let mut length: Value = Value::Int(arr.len() as i64);
3578 {
3579 let mut i: Value = Value::Int(0);
3580 let mut __for_first_101: bool = true;
3581 while { if !__for_first_101 { if let Value::Int(n) = &mut i { *n += 1; } } __for_first_101 = false; i.as_f64().unwrap_or(f64::NAN) < length.as_f64().unwrap_or(f64::NAN) } {
3582 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);
3583 if providedValue.as_f64().unwrap_or(f64::NAN) <= current.as_f64().unwrap_or(f64::NAN) {
3584 return current;
3585 }
3586 }
3587 }
3588 return arr.as_array().and_then(|__arr| match &((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),
3589 _ => Value::Null })) { Value::Int(__n) if *__n >= 0 => __arr.get(*__n as usize), _ => None }).cloned().unwrap_or(Value::Null);
3590
3591 Value::Null
3592}
3593
3594 fn add_key_in_array_items(&self, mut obj: Value, mut keyName: Value) -> Value {
3595 let mut result: Vec<Value> = Vec::new();
3596 let mut keys: Vec<Value> = object_keys(&obj).as_array().cloned().unwrap_or_default();
3597 {
3598 let mut i: i64 = 0;
3599 let mut __for_first_102: bool = true;
3600 while { if !__for_first_102 { i += 1; } __for_first_102 = false; i < (keys.len() as i64) } {
3601 let mut key: Value = keys.get(i as usize).cloned().unwrap_or(Value::Null);
3602 let mut item: Value = get_value(&obj, &key);
3603 if (item == Value::Null) {
3604 continue;
3605 }
3606 let mut itemWithKey: Value = self.extend(Value::Map({
3607 let mut m = indexmap::IndexMap::new();
3608 m
3609 }), &[item]);
3610 if let Value::Dict(__d) = &mut itemWithKey { std::sync::Arc::make_mut(__d).insert(crate::runtime::stringify_param(&keyName), key); }
3611 result.push(itemWithKey);
3612 }
3613 }
3614 return Value::from(result);
3615
3616 Value::Null
3617}
3618
3619 fn invert_flat_string_dictionary(&self, mut dict: Value) -> Value {
3620 let mut reversed: indexmap::IndexMap<String, Value> = ({
3621 let mut m = indexmap::IndexMap::new();
3622 m
3623 });
3624 let mut keys: Vec<Value> = object_keys(&dict).as_array().cloned().unwrap_or_default();
3625 {
3626 let mut i: i64 = 0;
3627 let mut __for_first_103: bool = true;
3628 while { if !__for_first_103 { i += 1; } __for_first_103 = false; i < (keys.len() as i64) } {
3629 let mut key: Value = keys.get(i as usize).cloned().unwrap_or(Value::Null);
3630 let mut value: Value = get_value(&dict, &key);
3631 if matches!(&value, Value::Str(_)) {
3632 reversed.insert(crate::runtime::stringify_param(&value), key);
3633 }
3634 }
3635 }
3636 return Value::Map(reversed);
3637
3638 Value::Null
3639}
3640
3641 fn string_to_base16(&self, mut str_val: Value) -> Value {
3642 return Value::Str(format!("{}{}", Value::Str("0x".into()), self.binary_to_base16(self.base64_to_binary(self.string_to_base64(str_val, &[]), &[]), &[])).into());
3643
3644 Value::Null
3645}
3646
3647 fn reduce_fees_by_currency(&self, mut fees: Value) -> Value {
3648 let mut reduced: Value = Value::Map({
3694 let mut m = indexmap::IndexMap::new();
3695 m
3696 });
3697 {
3698 let mut i: Value = Value::Int(0);
3699 let mut __for_first_104: bool = true;
3700 while { if !__for_first_104 { if let Value::Int(n) = &mut i { *n += 1; } } __for_first_104 = false; i.as_f64().unwrap_or(f64::NAN) < get_array_length(&fees).as_f64().unwrap_or(f64::NAN) } {
3701 let mut fee: Value = get_value(&fees, &i);
3702 let mut code: Value = self.safe_string_k(fee.clone(), "currency", &[]);
3703 let mut feeCurrencyCode: Value = (if (code != Value::Null) { code.clone() } else { Value::Str(format!("{}", i).into()) });
3704 if (feeCurrencyCode != Value::Null) {
3705 let mut rate: Value = self.safe_string_k(fee.clone(), "rate", &[]);
3706 let mut cost: Value = self.safe_string_k(fee, "cost", &[]);
3707 if (cost == Value::Null) {
3708 continue;
3709 }
3710 if !(matches!((&reduced, &feeCurrencyCode), (Value::Dict(__d), Value::Str(__k)) if __d.contains_key(__k.as_ref()))) {
3711 if let Value::Dict(__d) = &mut reduced { std::sync::Arc::make_mut(__d).insert(crate::runtime::stringify_param(&feeCurrencyCode), Value::Map({
3712 let mut m = indexmap::IndexMap::new();
3713 m
3714})); }
3715 }
3716 let mut rateKey: Value = (if (rate == Value::Null) { Value::Str("".into()) } else { rate.clone() });
3717 if (in_op(&(if let (Some(__m), Some(__k)) = (reduced.as_map(), feeCurrencyCode.as_str()) { __m.get(__k).cloned().unwrap_or(Value::Null) } else { Value::Null }), &rateKey)) {
3718 { let __be_tmp = crate::precise::Precise::stringAdd(&crate::value::get_value_k(&get_value(&reduced.as_map().and_then(|__m| feeCurrencyCode.as_str().and_then(|__k| __m.get(__k))).cloned().unwrap_or(Value::Null), &rateKey), "cost"), &cost); add_element_to_object(get_value_mut(get_value_mut(&mut reduced, &feeCurrencyCode), &rateKey), &Value::Str("cost".into()), __be_tmp); }
3719 } else {
3720 let mut newRateFee: indexmap::IndexMap<String, Value> = ({
3721 let mut m = indexmap::IndexMap::new();
3722 m.insert("currency".to_string(), code);
3723 m.insert("cost".to_string(), cost);
3724 m
3725 });
3726 if (rate != Value::Null) {
3727 newRateFee.insert("rate".into(), rate);
3728 }
3729 add_element_to_object(get_value_mut(&mut reduced, &feeCurrencyCode), &rateKey, Value::Map(newRateFee));
3730 }
3731 }
3732 }
3733 }
3734 let mut result: Value = Value::from(vec![]);
3735 let mut feeValues: Vec<Value> = Value::Array(reduced.as_map().map(|__m| __m.values().cloned().collect()).unwrap_or_default()).as_array().cloned().unwrap_or_default();
3736 {
3737 let mut i: i64 = 0;
3738 let mut __for_first_105: bool = true;
3739 while { if !__for_first_105 { i += 1; } __for_first_105 = false; i < (feeValues.len() as i64) } {
3740 let mut reducedFeeValues: Value = object_values(&feeValues.get(i as usize).cloned().unwrap_or(Value::Null));
3741 result = self.array_concat(result.clone(), reducedFeeValues);
3742 }
3743 }
3744 return result;
3745
3746 Value::Null
3747}
3748
3749 fn safe_ticker(&self, mut ticker: Value, optional_args: &[Value]) -> Value {
3750 let mut market = get_arg(optional_args, 0, Value::Null);
3751 let mut open: Value = self.omit_zero(self.safe_string_k(ticker.clone(), "open", &[]));
3752 let mut close: Value = self.omit_zero(self.safe_string2(ticker.clone(), Value::Str("close".into()), Value::Str("last".into()), &[]));
3753 let mut change: Value = self.safe_string_k(ticker.clone(), "change", &[]); let mut percentage: Value = self.omit_zero(self.safe_string_k(ticker.clone(), "percentage", &[]));
3755 let mut average: Value = self.omit_zero(self.safe_string_k(ticker.clone(), "average", &[]));
3756 let mut vwap: Value = self.safe_string_k(ticker.clone(), "vwap", &[]);
3757 let mut baseVolume: Option<String> = self.safe_string_k_opt(ticker.clone(), "baseVolume", &[]);
3758 let mut quoteVolume: Option<String> = self.safe_string_k_opt(ticker.clone(), "quoteVolume", &[]);
3759 if (vwap == Value::Null) {
3760 vwap = crate::precise::Precise::stringDiv(&self.omit_zero(quoteVolume.clone().map(Value::from).unwrap_or(Value::Null)), &baseVolume.clone().map(Value::from).unwrap_or(Value::Null));
3761 }
3762 if (change != Value::Null) {
3764 if (close == Value::Null) && (average != Value::Null) {
3765 close = crate::precise::Precise::stringAdd(&average, &crate::precise::Precise::stringDiv(&change, &Value::Str("2".into())));
3766 }
3767 if (open == Value::Null) && (close != Value::Null) {
3768 open = crate::precise::Precise::stringSub(&close, &change);
3769 }
3770 } else if (percentage != Value::Null) {
3771 if (close == Value::Null) && (average != Value::Null) {
3772 let mut openAddClose: Value = crate::precise::Precise::stringMul(&average, &Value::Str("2".into()));
3773 let mut denominator: Value = crate::precise::Precise::stringAdd(&Value::Str("2".into()), &crate::precise::Precise::stringDiv(&percentage, &Value::Str("100".into())));
3775 let mut calcOpen: Value = (if (open != Value::Null) { open.clone() } else { crate::precise::Precise::stringDiv(&openAddClose, &denominator) });
3776 close = crate::precise::Precise::stringMul(&calcOpen, &crate::precise::Precise::stringAdd(&Value::Str("1".into()), &crate::precise::Precise::stringDiv(&percentage, &Value::Str("100".into()))));
3777 }
3778 if (open == Value::Null) && (close != Value::Null) {
3779 open = crate::precise::Precise::stringDiv(&close, &crate::precise::Precise::stringAdd(&Value::Str("1".into()), &crate::precise::Precise::stringDiv(&percentage, &Value::Str("100".into()))));
3780 }
3781 }
3782 if (change == Value::Null) {
3784 if (close != Value::Null) && (open != Value::Null) {
3785 change = crate::precise::Precise::stringSub(&close, &open);
3786 } else if (close != Value::Null) && (percentage != Value::Null) {
3787 change = crate::precise::Precise::stringMul(&crate::precise::Precise::stringDiv(&percentage, &Value::Str("100".into())), &crate::precise::Precise::stringDiv(&close, &Value::Str("100".into())));
3788 } else if (open != Value::Null) && (percentage != Value::Null) {
3789 change = crate::precise::Precise::stringMul(&open, &crate::precise::Precise::stringDiv(&percentage, &Value::Str("100".into())));
3790 }
3791 }
3792 if (open != Value::Null) {
3794 if (percentage == Value::Null) && (change != Value::Null) {
3796 percentage = crate::precise::Precise::stringMul(&crate::precise::Precise::stringDiv(&change, &open), &Value::Str("100".into()));
3797 }
3798 if (close == Value::Null) && (change != Value::Null) {
3800 close = crate::precise::Precise::stringAdd(&open, &change);
3801 }
3802 if (close == Value::Null) && (average != Value::Null) {
3804 close = crate::precise::Precise::stringSub(&crate::precise::Precise::stringMul(&average, &Value::Str("2".into())), &open);
3806 }
3807 if (average == Value::Null) && (close != Value::Null) {
3809 let mut precision: Value = Value::Int(18);
3810 if (market != Value::Null) && self.is_tick_precision().as_bool() == Some(true) {
3811 let mut marketPrecision: Value = self.safe_dict_k(market, "precision", &[]);
3812 let mut precisionPrice: Option<String> = self.safe_string_k_opt(marketPrecision, "price", &[]);
3813 if (precisionPrice.is_some()) {
3814 precision = self.precision_from_string(precisionPrice.map(Value::from).unwrap_or(Value::Null));
3815 }
3816 }
3817 average = crate::precise::Precise::stringDivPrec(&crate::precise::Precise::stringAdd(&open, &close), &Value::Str("2".into()), &precision);
3818 }
3819 }
3820 let mut closeParsed: Value = self.parse_number(self.omit_zero(close), &[]);
3823 return self.extend(ticker.clone(), &[Value::Map({
3824 let mut m = indexmap::IndexMap::new();
3825 m.insert("bid".to_string(), self.parse_number(self.omit_zero(self.safe_string_k(ticker.clone(), "bid", &[])), &[]));
3826 m.insert("bidVolume".to_string(), self.safe_number_k(ticker.clone(), "bidVolume", &[]));
3827 m.insert("ask".to_string(), self.parse_number(self.omit_zero(self.safe_string_k(ticker.clone(), "ask", &[])), &[]));
3828 m.insert("askVolume".to_string(), self.safe_number_k(ticker.clone(), "askVolume", &[]));
3829 m.insert("high".to_string(), self.parse_number(self.omit_zero(self.safe_string_k(ticker.clone(), "high", &[])), &[]));
3830 m.insert("low".to_string(), self.parse_number(self.omit_zero(self.safe_string_k(ticker.clone(), "low", &[])), &[]));
3831 m.insert("open".to_string(), self.parse_number(self.omit_zero(open), &[]));
3832 m.insert("close".to_string(), closeParsed.clone());
3833 m.insert("last".to_string(), closeParsed);
3834 m.insert("change".to_string(), self.parse_number(change, &[]));
3835 m.insert("percentage".to_string(), self.parse_number(percentage, &[]));
3836 m.insert("average".to_string(), self.parse_number(average, &[]));
3837 m.insert("vwap".to_string(), self.parse_number(vwap, &[]));
3838 m.insert("baseVolume".to_string(), self.parse_number(baseVolume.map(Value::from).unwrap_or(Value::Null), &[]));
3839 m.insert("quoteVolume".to_string(), self.parse_number(quoteVolume.map(Value::from).unwrap_or(Value::Null), &[]));
3840 m.insert("previousClose".to_string(), self.safe_number_k(ticker.clone(), "previousClose", &[]));
3841 m.insert("indexPrice".to_string(), self.safe_number_k(ticker.clone(), "indexPrice", &[]));
3842 m.insert("markPrice".to_string(), self.safe_number_k(ticker, "markPrice", &[]));
3843 m
3844})]);
3845
3846 Value::Null
3847}
3848
3849 fn fetch_borrow_rate(&mut self, mut code: Value, mut amount: Value, optional_args: &[Value]) -> impl ::std::future::Future<Output = Value> + Send { async move {
3850 let mut params = get_arg(optional_args, 0, Value::Map({
3851 let mut m = indexmap::IndexMap::new();
3852 m
3853}));
3854 panic!("{}", crate::exchange_errors::not_supported(format!("{}{}", self.id.clone(), Value::Str(" fetchBorrowRate is deprecated, please use fetchCrossBorrowRate or fetchIsolatedBorrowRate instead".into()))));
3855
3856 Value::Null
3857} }
3858
3859 fn repay_cross_margin(&mut self, mut code: Value, mut amount: Value, optional_args: &[Value]) -> impl ::std::future::Future<Output = Value> + Send { async move {
3860 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 {
3862 if !matches!(__v, crate::Value::Null) { return __v; }
3863 }
3864
3865 let mut params = get_arg(optional_args, 0, Value::Map({
3866 let mut m = indexmap::IndexMap::new();
3867 m
3868}));
3869 panic!("{}", crate::exchange_errors::not_supported(format!("{}{}", self.id.clone(), Value::Str(" repayCrossMargin is not support yet".into()))));
3870
3871 Value::Null
3872} }
3873
3874 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 {
3875 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 {
3877 if !matches!(__v, crate::Value::Null) { return __v; }
3878 }
3879
3880 let mut params = get_arg(optional_args, 0, Value::Map({
3881 let mut m = indexmap::IndexMap::new();
3882 m
3883}));
3884 panic!("{}", crate::exchange_errors::not_supported(format!("{}{}", self.id.clone(), Value::Str(" repayIsolatedMargin is not support yet".into()))));
3885
3886 Value::Null
3887} }
3888
3889 fn borrow_cross_margin(&mut self, mut code: Value, mut amount: Value, optional_args: &[Value]) -> impl ::std::future::Future<Output = Value> + Send { async move {
3890 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 {
3892 if !matches!(__v, crate::Value::Null) { return __v; }
3893 }
3894
3895 let mut params = get_arg(optional_args, 0, Value::Map({
3896 let mut m = indexmap::IndexMap::new();
3897 m
3898}));
3899 panic!("{}", crate::exchange_errors::not_supported(format!("{}{}", self.id.clone(), Value::Str(" borrowCrossMargin is not support yet".into()))));
3900
3901 Value::Null
3902} }
3903
3904 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 {
3905 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 {
3907 if !matches!(__v, crate::Value::Null) { return __v; }
3908 }
3909
3910 let mut params = get_arg(optional_args, 0, Value::Map({
3911 let mut m = indexmap::IndexMap::new();
3912 m
3913}));
3914 panic!("{}", crate::exchange_errors::not_supported(format!("{}{}", self.id.clone(), Value::Str(" borrowIsolatedMargin is not support yet".into()))));
3915
3916 Value::Null
3917} }
3918
3919 fn borrow_margin(&mut self, mut code: Value, mut amount: Value, optional_args: &[Value]) -> impl ::std::future::Future<Output = Value> + Send { async move {
3920 let mut symbol = get_arg(optional_args, 0, Value::Null);
3921 let mut params = get_arg(optional_args, 1, Value::Map({
3922 let mut m = indexmap::IndexMap::new();
3923 m
3924}));
3925 panic!("{}", crate::exchange_errors::not_supported(format!("{}{}", self.id.clone(), Value::Str(" borrowMargin is deprecated, please use borrowCrossMargin or borrowIsolatedMargin instead".into()))));
3926
3927 Value::Null
3928} }
3929
3930 fn repay_margin(&mut self, mut code: Value, mut amount: Value, optional_args: &[Value]) -> impl ::std::future::Future<Output = Value> + Send { async move {
3931 let mut symbol = get_arg(optional_args, 0, Value::Null);
3932 let mut params = get_arg(optional_args, 1, Value::Map({
3933 let mut m = indexmap::IndexMap::new();
3934 m
3935}));
3936 panic!("{}", crate::exchange_errors::not_supported(format!("{}{}", self.id.clone(), Value::Str(" repayMargin is deprecated, please use repayCrossMargin or repayIsolatedMargin instead".into()))));
3937
3938 Value::Null
3939} }
3940
3941 fn fetch_ohlcv(&mut self, mut symbol: Value, optional_args: &[Value]) -> impl ::std::future::Future<Output = Value> + Send { async move {
3942 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 {
3944 if !matches!(__v, crate::Value::Null) { return __v; }
3945 }
3946
3947 let mut timeframe = get_arg(optional_args, 0, Value::Str("1m".into()));
3948 let mut since = get_arg(optional_args, 1, Value::Null);
3949 let mut limit = get_arg(optional_args, 2, Value::Null);
3950 let mut params = get_arg(optional_args, 3, Value::Map({
3951 let mut m = indexmap::IndexMap::new();
3952 m
3953}));
3954 let mut message: String = "".to_string();
3955 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)) {
3956 message = ". If you want to build OHLCV candles from trade executions data, visit https://github.com/ccxt/ccxt/tree/master/examples/ and see \"build-ohlcv-bars\" file".to_string();
3957 }
3958 panic!("{}", crate::exchange_errors::not_supported(format!("{}{}", Value::Str(format!("{}{}", self.id.clone(), Value::Str(" fetchOHLCV() is not supported yet".into())).into()), message)));
3959
3960 Value::Null
3961} }
3962
3963 fn fetch_spot_ohlcv(&mut self, mut symbol: Value, optional_args: &[Value]) -> impl ::std::future::Future<Output = Value> + Send { async move {
3964 let mut timeframe = get_arg(optional_args, 0, Value::Str("1m".into()));
3965 let mut since = get_arg(optional_args, 1, Value::Null);
3966 let mut limit = get_arg(optional_args, 2, Value::Null);
3967 let mut params = get_arg(optional_args, 3, Value::Map({
3968 let mut m = indexmap::IndexMap::new();
3969 m
3970}));
3971 panic!("{}", crate::exchange_errors::not_supported(format!("{}{}", self.id.clone(), Value::Str(" fetchSpotOHLCV() is not supported yet".into()))));
3972
3973 Value::Null
3974} }
3975
3976 fn fetch_contract_ohlcv(&mut self, mut symbol: Value, optional_args: &[Value]) -> impl ::std::future::Future<Output = Value> + Send { async move {
3977 let mut timeframe = get_arg(optional_args, 0, Value::Str("1m".into()));
3978 let mut since = get_arg(optional_args, 1, Value::Null);
3979 let mut limit = get_arg(optional_args, 2, Value::Null);
3980 let mut params = get_arg(optional_args, 3, Value::Map({
3981 let mut m = indexmap::IndexMap::new();
3982 m
3983}));
3984 panic!("{}", crate::exchange_errors::not_supported(format!("{}{}", self.id.clone(), Value::Str(" fetchContractOHLCV() is not supported yet".into()))));
3985
3986 Value::Null
3987} }
3988
3989 fn fetch_ohlcv_ws(&mut self, mut symbol: Value, optional_args: &[Value]) -> impl ::std::future::Future<Output = Value> + Send { async move {
3990 let mut timeframe = get_arg(optional_args, 0, Value::Str("1m".into()));
3991 let mut since = get_arg(optional_args, 1, Value::Null);
3992 let mut limit = get_arg(optional_args, 2, Value::Null);
3993 let mut params = get_arg(optional_args, 3, Value::Map({
3994 let mut m = indexmap::IndexMap::new();
3995 m
3996}));
3997 let mut message: String = "".to_string();
3998 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)) {
3999 message = ". If you want to build OHLCV candles from trade executions data, visit https://github.com/ccxt/ccxt/tree/master/examples/ and see \"build-ohlcv-bars\" file".to_string();
4000 }
4001 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)));
4002
4003 Value::Null
4004} }
4005
4006 fn watch_ohlcv(&mut self, mut symbol: Value, optional_args: &[Value]) -> impl ::std::future::Future<Output = Value> + Send { async move {
4007 let mut timeframe = get_arg(optional_args, 0, Value::Str("1m".into()));
4008 let mut since = get_arg(optional_args, 1, Value::Null);
4009 let mut limit = get_arg(optional_args, 2, Value::Null);
4010 let mut params = get_arg(optional_args, 3, Value::Map({
4011 let mut m = indexmap::IndexMap::new();
4012 m
4013}));
4014 panic!("{}", crate::exchange_errors::not_supported(format!("{}{}", self.id.clone(), Value::Str(" watchOHLCV() is not supported yet".into()))));
4015
4016 Value::Null
4017} }
4018
4019 fn convert_trading_view_to_ohlcv(&self, mut ohlcvs: Value, optional_args: &[Value]) -> Value {
4020 let mut timestamp = get_arg(optional_args, 0, Value::Str("t".into()));
4021 let mut open = get_arg(optional_args, 1, Value::Str("o".into()));
4022 let mut high = get_arg(optional_args, 2, Value::Str("h".into()));
4023 let mut low = get_arg(optional_args, 3, Value::Str("l".into()));
4024 let mut close = get_arg(optional_args, 4, Value::Str("c".into()));
4025 let mut volume = get_arg(optional_args, 5, Value::Str("v".into()));
4026 let mut ms = get_arg(optional_args, 6, Value::Bool(false));
4027 let mut result: Vec<Value> = Vec::new();
4028 let mut timestamps: Value = self.safe_list(ohlcvs.clone(), timestamp, &[Value::from(vec![])]);
4029 let mut opens: Value = self.safe_list(ohlcvs.clone(), open, &[Value::from(vec![])]);
4030 let mut highs: Value = self.safe_list(ohlcvs.clone(), high, &[Value::from(vec![])]);
4031 let mut lows: Value = self.safe_list(ohlcvs.clone(), low, &[Value::from(vec![])]);
4032 let mut closes: Value = self.safe_list(ohlcvs.clone(), close, &[Value::from(vec![])]);
4033 let mut volumes: Value = self.safe_list(ohlcvs, volume, &[Value::from(vec![])]);
4034 {
4035 let mut i: i64 = 0;
4036 let mut __for_first_106: bool = true;
4037 while { if !__for_first_106 { i += 1; } __for_first_106 = false; i < (timestamps.len() as i64) } {
4038 result.push(Value::from(vec![(if ms.as_bool() == Some(true) { self.safe_integer(timestamps.clone(), Value::Int(i), &[]) } else { self.safe_timestamp(timestamps.clone(), Value::Int(i), &[]) }), self.safe_value(opens.clone(), Value::Int(i), &[]), self.safe_value(highs.clone(), Value::Int(i), &[]), self.safe_value(lows.clone(), Value::Int(i), &[]),
4039 self.safe_value(closes.clone(), Value::Int(i), &[]), self.safe_value(volumes.clone(), Value::Int(i), &[])]));
4040 }
4041 }
4042 return Value::from(result);
4043
4044 Value::Null
4045}
4046
4047 fn convert_ohlcv_to_trading_view(&self, mut ohlcvs: Value, optional_args: &[Value]) -> Value {
4048 let mut timestamp = get_arg(optional_args, 0, Value::Str("t".into()));
4049 let mut open = get_arg(optional_args, 1, Value::Str("o".into()));
4050 let mut high = get_arg(optional_args, 2, Value::Str("h".into()));
4051 let mut low = get_arg(optional_args, 3, Value::Str("l".into()));
4052 let mut close = get_arg(optional_args, 4, Value::Str("c".into()));
4053 let mut volume = get_arg(optional_args, 5, Value::Str("v".into()));
4054 let mut ms = get_arg(optional_args, 6, Value::Bool(false));
4055 let __ohlcvs_empty = Vec::new();
4056 let ohlcvs = ohlcvs.as_array().unwrap_or(&__ohlcvs_empty);
4057 let mut result: Value = Value::Map({
4058 let mut m = indexmap::IndexMap::new();
4059 m
4060 });
4061 if let Value::Dict(__d) = &mut result { std::sync::Arc::make_mut(__d).insert(crate::runtime::stringify_param(×tamp), Value::from(vec![])); }
4062 if let Value::Dict(__d) = &mut result { std::sync::Arc::make_mut(__d).insert(crate::runtime::stringify_param(&open), Value::from(vec![])); }
4063 if let Value::Dict(__d) = &mut result { std::sync::Arc::make_mut(__d).insert(crate::runtime::stringify_param(&high), Value::from(vec![])); }
4064 if let Value::Dict(__d) = &mut result { std::sync::Arc::make_mut(__d).insert(crate::runtime::stringify_param(&low), Value::from(vec![])); }
4065 if let Value::Dict(__d) = &mut result { std::sync::Arc::make_mut(__d).insert(crate::runtime::stringify_param(&close), Value::from(vec![])); }
4066 if let Value::Dict(__d) = &mut result { std::sync::Arc::make_mut(__d).insert(crate::runtime::stringify_param(&volume), Value::from(vec![])); }
4067 {
4068 let mut i: Value = Value::Int(0);
4069 let mut __for_first_107: bool = true;
4070 while { if !__for_first_107 { if let Value::Int(n) = &mut i { *n += 1; } } __for_first_107 = false; i.as_f64().unwrap_or(f64::NAN) < ((ohlcvs.len() as i64) as f64) } {
4071 let mut ts: Value = (if ms.as_bool() == Some(true) { ohlcvs.get((i).as_i64().unwrap_or(-1) as usize).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.get((i).as_i64().unwrap_or(-1) as
4072 usize).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 })) });
4073 let mut resultTimestamp: Value = (if let (Some(__m), Some(__k)) = (result.as_map(), timestamp.as_str()) { __m.get(__k).cloned().unwrap_or(Value::Null) } else { Value::Null });
4074 if let Value::Arr(__a) = &mut resultTimestamp { std::sync::Arc::make_mut(__a).push(ts); };
4075 crate::set_value(&mut result, ×tamp, resultTimestamp);
4076 let mut resultOpen: Value = (if let (Some(__m), Some(__k)) = (result.as_map(), open.as_str()) { __m.get(__k).cloned().unwrap_or(Value::Null) } else { Value::Null });
4077 if let Value::Arr(__a) = &mut resultOpen { std::sync::Arc::make_mut(__a).push(ohlcvs.get((i).as_i64().unwrap_or(-1) as usize).cloned().unwrap_or(Value::Null).as_array().and_then(|__arr| __arr.get(1)).cloned().unwrap_or(Value::Null)); };
4078 crate::set_value(&mut result, &open, resultOpen);
4079 let mut resultHigh: Value = (if let (Some(__m), Some(__k)) = (result.as_map(), high.as_str()) { __m.get(__k).cloned().unwrap_or(Value::Null) } else { Value::Null });
4080 if let Value::Arr(__a) = &mut resultHigh { std::sync::Arc::make_mut(__a).push(ohlcvs.get((i).as_i64().unwrap_or(-1) as usize).cloned().unwrap_or(Value::Null).as_array().and_then(|__arr| __arr.get(2)).cloned().unwrap_or(Value::Null)); };
4081 crate::set_value(&mut result, &high, resultHigh);
4082 let mut resultLow: Value = (if let (Some(__m), Some(__k)) = (result.as_map(), low.as_str()) { __m.get(__k).cloned().unwrap_or(Value::Null) } else { Value::Null });
4083 if let Value::Arr(__a) = &mut resultLow { std::sync::Arc::make_mut(__a).push(ohlcvs.get((i).as_i64().unwrap_or(-1) as usize).cloned().unwrap_or(Value::Null).as_array().and_then(|__arr| __arr.get(3)).cloned().unwrap_or(Value::Null)); };
4084 crate::set_value(&mut result, &low, resultLow);
4085 let mut resultClose: Value = (if let (Some(__m), Some(__k)) = (result.as_map(), close.as_str()) { __m.get(__k).cloned().unwrap_or(Value::Null) } else { Value::Null });
4086 if let Value::Arr(__a) = &mut resultClose { std::sync::Arc::make_mut(__a).push(ohlcvs.get((i).as_i64().unwrap_or(-1) as usize).cloned().unwrap_or(Value::Null).as_array().and_then(|__arr| __arr.get(4)).cloned().unwrap_or(Value::Null)); };
4087 crate::set_value(&mut result, &close, resultClose);
4088 let mut resultVolume: Value = (if let (Some(__m), Some(__k)) = (result.as_map(), volume.as_str()) { __m.get(__k).cloned().unwrap_or(Value::Null) } else { Value::Null });
4089 if let Value::Arr(__a) = &mut resultVolume { std::sync::Arc::make_mut(__a).push(ohlcvs.get((i).as_i64().unwrap_or(-1) as usize).cloned().unwrap_or(Value::Null).as_array().and_then(|__arr| __arr.get(5)).cloned().unwrap_or(Value::Null)); };
4090 crate::set_value(&mut result, &volume, resultVolume);
4091 }
4092 }
4093 return result;
4094
4095 Value::Null
4096}
4097
4098 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 {
4099 let mut startRegex = get_arg(optional_args, 0, Value::Null);
4100 let mut endRegex = get_arg(optional_args, 1, Value::Null);
4101 let mut options: Value = self.safe_value(self.options.clone(), method, &[Value::Map({
4102 let mut m = indexmap::IndexMap::new();
4103 m
4104 })]);
4105 let mut muteOnFailure: Value = self.safe_bool_k(options.clone(), "webApiMuteFailure", &[Value::Bool(true)]);
4106 {
4107 if !matches!(self.safe_bool_k(options.clone(), "webApiEnable", &[Value::Bool(true)]), Value::Bool(true)) {
4109 return Value::Null;
4110 }
4111 let mut maxRetries: Value = self.safe_integer_k(options, "webApiRetries", &[Value::Int(10)]);
4112 let mut response: Value = Value::Null;
4113 let mut shouldBreak: bool = false;
4114 {
4115 let mut retry: Value = Value::Int(0);
4116 let mut __for_first_108: bool = true;
4117 while { if !__for_first_108 { if let Value::Int(n) = &mut retry { *n += 1; } } __for_first_108 = false; retry.as_f64().unwrap_or(f64::NAN) < maxRetries.as_f64().unwrap_or(f64::NAN) } {
4118 {
4119 response = self.call_dynamic_checked(endpointMethod.clone(), vec![(Value::Map({
4120 let mut m = indexmap::IndexMap::new();
4121 m
4122 })).clone()]).await;
4123 shouldBreak = true;
4124 break;
4125 }
4126 if shouldBreak {
4127 break;
4128 }
4129 }
4130 }
4131 let mut content: Value = response;
4132 if (content == Value::Null) {
4133 panic!("{}", crate::exchange_errors::null_response(format!("{}{}", self.id.clone(), Value::Str(" fetchWebEndpoint() returned empty content".into()))));
4134 }
4135 if (startRegex != Value::Null) {
4136 let mut splitted_by_start: Vec<Value> = split(&content, &startRegex).as_array().cloned().unwrap_or_default();
4137 content = splitted_by_start.get(1).cloned().unwrap_or(Value::Null); }
4139 if (content == Value::Null) {
4140 panic!("{}", crate::exchange_errors::null_response(format!("{}{}", self.id.clone(), Value::Str(" fetchWebEndpoint() returned empty content".into()))));
4141 }
4142 if (endRegex != Value::Null) {
4143 let mut splitted_by_end: Vec<Value> = split(&content, &endRegex).as_array().cloned().unwrap_or_default();
4144 content = splitted_by_end.get(0).cloned().unwrap_or(Value::Null); }
4146 if ((match &(returnAsJson) { Value::Bool(__x) => *__x == true, __v => matches!((match __v { Value::Int(__n) => Some(*__n as f64), Value::Float(__f) => Some(*__f), Value::Str(__s) => __s.parse::<f64>().ok(), Value::Bool(__b) => Some(if *__b { 1.0 } else { 0.0 }), _ => None }), Some(__y) if __y == 1.0) })) && (matches!(&content, Value::Str(_))) {
4147 let mut jsoned: Value = self.parse_json_value(content.as_str().map(|__s| Value::Str(__s.trim().to_string().into())).unwrap_or(Value::Null)); if (jsoned != Value::Null) && (jsoned != Value::Null) {
4149 return jsoned;
4150 } else {
4151 panic!("{}", crate::exchange_errors::bad_response("could not parse the response into json"));
4152 }
4153 } else {
4154 return content;
4155 }
4156 }
4157 return Value::Null;
4158
4159 Value::Null
4160} }
4161
4162 fn market_ids(&self, optional_args: &[Value]) -> Value {
4163 let mut symbols = get_arg(optional_args, 0, Value::Null);
4164 if (symbols == Value::Null) {
4170 return symbols;
4171 }
4172 let mut result: Vec<Value> = Vec::new();
4173 {
4174 let mut i: i64 = 0;
4175 let mut __for_first_109: bool = true;
4176 while { if !__for_first_109 { i += 1; } __for_first_109 = false; i < (symbols.len() as i64) } {
4177 let mut id: Value = self.market_id(symbols.as_array().map(Vec::as_slice).unwrap_or_default().get(i as usize).cloned().unwrap_or(Value::Null));
4178 if (id != Value::Null) {
4179 result.push(id);
4180 }
4181 }
4182 }
4183 return Value::from(result);
4184
4185 Value::Null
4186}
4187
4188 fn currency_ids(&self, optional_args: &[Value]) -> Value {
4189 let mut codes = get_arg(optional_args, 0, Value::Null);
4190 if (codes == Value::Null) {
4191 return codes;
4192 }
4193 let mut result: Vec<Value> = Vec::new();
4194 {
4195 let mut i: i64 = 0;
4196 let mut __for_first_110: bool = true;
4197 while { if !__for_first_110 { i += 1; } __for_first_110 = false; i < (codes.len() as i64) } {
4198 let mut id: Value = self.currency_id(codes.as_array().map(Vec::as_slice).unwrap_or_default().get(i as usize).cloned().unwrap_or(Value::Null));
4199 if (id != Value::Null) {
4200 result.push(id);
4201 }
4202 }
4203 }
4204 return Value::from(result);
4205
4206 Value::Null
4207}
4208
4209 fn markets_for_symbols(&self, optional_args: &[Value]) -> Value {
4210 let mut symbols = get_arg(optional_args, 0, Value::Null);
4211 if (symbols == Value::Null) {
4212 return Value::Null;
4213 }
4214 let mut result: Vec<Value> = Vec::new();
4215 {
4216 let mut i: i64 = 0;
4217 let mut __for_first_111: bool = true;
4218 while { if !__for_first_111 { i += 1; } __for_first_111 = false; i < (symbols.len() as i64) } {
4219 result.push(<Self as crate::exchange_generated::ExchangeBase>::market(self, symbols.as_array().map(Vec::as_slice).unwrap_or_default().get(i as usize).cloned().unwrap_or(Value::Null)));
4220 }
4221 }
4222 return Value::from(result);
4223
4224 Value::Null
4225}
4226
4227fn market_symbols(&self, optional_args: &[Value]) -> Value {
4229 let mut symbols = get_arg(optional_args, 0, Value::Null);
4230 let mut type_var = get_arg(optional_args, 1, Value::Null);
4231 let mut allowEmpty = get_arg(optional_args, 2, Value::Bool(true));
4232 let mut sameTypeOnly = get_arg(optional_args, 3, Value::Bool(false));
4233 let mut sameSubTypeOnly = get_arg(optional_args, 4, Value::Bool(false));
4234 if (symbols == Value::Null) {
4244 if !(allowEmpty.as_bool() == Some(true)) {
4245 panic!("{}", crate::exchange_errors::arguments_required(format!("{}{}", self.id.clone(), Value::Str(" empty list of symbols is not supported".into()))));
4246 }
4247 return symbols;
4248 }
4249 let mut symbolsLength: f64 = ((symbols.len() as i64) as f64);
4250 if (symbolsLength == 0.0) {
4251 if !(allowEmpty.as_bool() == Some(true)) {
4252 panic!("{}", crate::exchange_errors::arguments_required(format!("{}{}", self.id.clone(), Value::Str(" empty list of symbols is not supported".into()))));
4253 }
4254 return symbols;
4255 }
4256 let mut result: Vec<Value> = Vec::new();
4257 let mut marketType: Value = Value::Null;
4258 let mut isLinearSubType: Value = Value::Null;
4259 {
4260 let mut i: i64 = 0;
4261 let mut __for_first_112: bool = true;
4262 while { if !__for_first_112 { i += 1; } __for_first_112 = false; i < (symbols.len() as i64) } {
4263 let mut market: Value = <Self as crate::exchange_generated::ExchangeBase>::market(self, symbols.as_array().map(Vec::as_slice).unwrap_or_default().get(i as usize).cloned().unwrap_or(Value::Null));
4264 if sameTypeOnly.as_bool() == Some(true) && (marketType != Value::Null) {
4265 if (market.as_map().and_then(|__m| __m.get("type")).cloned().unwrap_or(Value::Null).as_str() != marketType.as_str()) {
4266 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()),
4267 market.as_map().and_then(|__m| __m.get("type")).cloned().unwrap_or(Value::Null)).into()), Value::Str(".".into()))));
4268 }
4269 }
4270 if sameSubTypeOnly.as_bool() == Some(true) && (isLinearSubType != Value::Null) {
4271 if (market.as_map().and_then(|__m| __m.get("linear")).cloned().unwrap_or(Value::Null).as_bool() != isLinearSubType.as_bool()) {
4272 panic!("{}", crate::exchange_errors::bad_request(format!("{}{}", self.id.clone(), Value::Str(" symbols must be of the same subType, either linear or inverse.".into()))));
4273 }
4274 }
4275 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()) {
4276 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()))));
4277 }
4278 marketType = self.safe_string_k(market.clone(), "type", &[]);
4279 if !matches!(self.safe_bool_k(market.clone(), "spot", &[Value::Bool(false)]), Value::Bool(true)) {
4280 isLinearSubType = self.safe_bool_k(market.clone(), "linear", &[]);
4281 }
4282 let mut symbol: Value = self.safe_string_k(market, "symbol", &[symbols.as_array().map(Vec::as_slice).unwrap_or_default().get(i as usize).cloned().unwrap_or(Value::Null)]);
4283 result.push(symbol);
4284 }
4285 }
4286 return Value::from(result);
4287
4288 Value::Null
4289}
4290
4291 fn market_codes(&self, optional_args: &[Value]) -> Value {
4292 let mut codes = get_arg(optional_args, 0, Value::Null);
4293 if (codes == Value::Null) {
4294 return codes;
4295 }
4296 let mut result: Vec<Value> = Vec::new();
4297 {
4298 let mut i: i64 = 0;
4299 let mut __for_first_113: bool = true;
4300 while { if !__for_first_113 { i += 1; } __for_first_113 = false; i < (codes.len() as i64) } {
4301 result.push(self.common_currency_code(codes.as_array().map(Vec::as_slice).unwrap_or_default().get(i as usize).cloned().unwrap_or(Value::Null)));
4302 }
4303 }
4304 return Value::from(result);
4305
4306 Value::Null
4307}
4308
4309 fn parse_order_book_bids_asks(&self, mut bidasks: Value, optional_args: &[Value]) -> Value {
4310 let mut priceKey = get_arg(optional_args, 0, Value::Int(0));
4311 let mut amountKey = get_arg(optional_args, 1, Value::Int(1));
4312 let mut countOrIdKey = get_arg(optional_args, 2, Value::Int(2));
4313 let mut bidasksValue: Value = self.to_array(bidasks);
4314 let mut result: Vec<Value> = Vec::new();
4315 {
4316 let mut i: i64 = 0;
4317 let mut __for_first_114: bool = true;
4318 while { if !__for_first_114 { i += 1; } __for_first_114 = false; i < (bidasksValue.len() as i64) } {
4319 result.push(self.parse_order_book_bid_ask(bidasksValue.as_array().map(Vec::as_slice).unwrap_or_default().get(i as usize).cloned().unwrap_or(Value::Null), &[priceKey.clone(), amountKey.clone(), countOrIdKey.clone()]));
4320 }
4321 }
4322 return Value::from(result);
4323
4324 Value::Null
4325}
4326
4327 fn parse_order_book_bids_asks_l3(&self, mut bidasks: Value, optional_args: &[Value]) -> Value {
4328 let mut priceKey = get_arg(optional_args, 0, Value::Int(0));
4329 let mut amountKey = get_arg(optional_args, 1, Value::Int(1));
4330 let mut countOrIdKey = get_arg(optional_args, 2, Value::Int(2));
4331 let mut bidasksValue: Value = self.to_array(bidasks);
4332 let mut result: Vec<Value> = Vec::new();
4333 {
4334 let mut i: i64 = 0;
4335 let mut __for_first_115: bool = true;
4336 while { if !__for_first_115 { i += 1; } __for_first_115 = false; i < (bidasksValue.len() as i64) } {
4337 result.push(self.parse_order_book_bid_ask_l3(bidasksValue.as_array().map(Vec::as_slice).unwrap_or_default().get(i as usize).cloned().unwrap_or(Value::Null), &[priceKey.clone(), amountKey.clone(), countOrIdKey.clone()]));
4338 }
4339 }
4340 return Value::from(result);
4341
4342 Value::Null
4343}
4344
4345 fn filter_by_key(&self, mut objects: Value, mut key: Value, optional_args: &[Value]) -> Value {
4346 let mut value = get_arg(optional_args, 0, Value::Null);
4347 if (value == Value::Null) {
4348 return objects;
4349 }
4350 let mut result: Vec<Value> = Vec::new();
4351 {
4352 let mut i: Value = Value::Int(0);
4353 let mut __for_first_116: bool = true;
4354 while { if !__for_first_116 { if let Value::Int(n) = &mut i { *n += 1; } } __for_first_116 = false; i.as_f64().unwrap_or(f64::NAN) < get_array_length(&objects).as_f64().unwrap_or(f64::NAN) } {
4355 let mut objectValue: Option<String> = self.safe_string_opt(get_value(&objects, &i), key.clone(), &[]);
4356 if (objectValue.as_deref() == value.as_str()) {
4357 result.push(get_value(&objects, &i));
4358 }
4359 }
4360 }
4361 return Value::from(result);
4362
4363 Value::Null
4364}
4365
4366 fn filter_by_symbol(&self, mut objects: Value, optional_args: &[Value]) -> Value {
4367 let mut symbol = get_arg(optional_args, 0, Value::Null);
4368 return self.filter_by_key(objects, Value::Str("symbol".into()), &[symbol]);
4369
4370 Value::Null
4371}
4372
4373 fn parse_ohlcv(&self, mut ohlcv: Value, optional_args: &[Value]) -> Value {
4374 { 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; } }
4376
4377 let mut market = get_arg(optional_args, 0, Value::Null);
4378 if (matches!(&ohlcv, Value::Arr(_))) {
4379 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), &[])]);
4380 }
4381 return ohlcv;
4382
4383 Value::Null
4384}
4385
4386 fn safe_network(&self, mut network: Value) -> Value {
4387 let __network_empty = indexmap::IndexMap::new();
4388 let network = network.as_map().unwrap_or(&__network_empty);
4389 let mut withdrawEnabled: Value = (match network.get("withdraw") { Some(Value::Bool(__b)) => Value::Bool(*__b), _ => Value::Null });
4390 let mut depositEnabled: Value = (match network.get("deposit") { Some(Value::Bool(__b)) => Value::Bool(*__b), _ => Value::Null });
4391 let mut limits: Value = (match network.get("limits") { Some(__v) if matches!(__v, Value::Dict(_)) => __v.clone(), _ => Value::Null });
4392 let mut withdraw: Value = self.safe_dict_k(limits.clone(), "withdraw", &[]);
4393 let mut deposit: Value = self.safe_dict_k(limits, "deposit", &[]);
4394 let mut isEnabled: Value = withdrawEnabled.clone();
4395 if (withdrawEnabled.as_bool() == Some(true)) {
4396 isEnabled = depositEnabled.clone();
4397 }
4398 return Value::Map({
4399 let mut m = indexmap::IndexMap::new();
4400 m.insert("info".to_string(), network.get("info").cloned().unwrap_or(Value::Null));
4401 m.insert("id".to_string(), (match network.get("id") { 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 }));
4402 m.insert("name".to_string(), (match network.get("name") { 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 }));
4403 m.insert("network".to_string(), (match network.get("network") { 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 }));
4404 m.insert("active".to_string(), (match network.get("active") { Some(Value::Bool(__b)) => Value::Bool(*__b), _ => isEnabled }));
4405 m.insert("deposit".to_string(), depositEnabled);
4406 m.insert("withdraw".to_string(), withdrawEnabled);
4407 m.insert("fee".to_string(), (match network.get("fee") { Some(Value::Float(__f)) => Value::Float(*__f), Some(Value::Int(__n)) => Value::Float(*__n as f64), Some(Value::Str(__s)) => match __s.parse::<f64>() { Ok(__n) => Value::Float(__n), Err(_) => Value::Null }, _ => Value::Null }));
4408 m.insert("precision".to_string(), (match network.get("precision") { Some(Value::Float(__f)) => Value::Float(*__f), Some(Value::Int(__n)) => Value::Float(*__n as f64), Some(Value::Str(__s)) => match __s.parse::<f64>() { Ok(__n) => Value::Float(__n), Err(_) => Value::Null }, _ => Value::Null }));
4409 m.insert("limits".to_string(), Value::Map({
4410 let mut m = indexmap::IndexMap::new();
4411 m.insert("withdraw".to_string(), Value::Map({
4412 let mut m = indexmap::IndexMap::new();
4413 m.insert("min".to_string(), self.safe_number_k(withdraw.clone(), "min", &[]));
4414 m.insert("max".to_string(), self.safe_number_k(withdraw, "max", &[]));
4415 m
4416}));
4417 m.insert("deposit".to_string(), Value::Map({
4418 let mut m = indexmap::IndexMap::new();
4419 m.insert("min".to_string(), self.safe_number_k(deposit.clone(), "min", &[]));
4420 m.insert("max".to_string(), self.safe_number_k(deposit, "max", &[]));
4421 m
4422}));
4423 m
4424}));
4425 m
4426});
4427
4428 Value::Null
4429}
4430
4431 fn network_code_to_id(&self, mut networkCode: Value, optional_args: &[Value]) -> Value {
4432 let mut currencyCode = get_arg(optional_args, 0, Value::Null);
4433 if (networkCode == Value::Null) {
4443 return Value::Null;
4444 }
4445 let mut unifiedCode: Value = self.safe_string(self.networkAliases.clone(), networkCode.clone(), &[networkCode.clone()]);
4446 let mut networkIdsByCodes: Value = self.safe_dict_k(self.options.clone(), "networks", &[Value::Map({
4447 let mut m = indexmap::IndexMap::new();
4448 m
4449})]);
4450 let mut networkId: Value = self.safe_string(networkIdsByCodes.clone(), unifiedCode.clone(), &[]);
4451 if (networkId != Value::Null) {
4452 return networkId;
4453 }
4454 let mut aliases: Value = self.networkAliases.clone();
4456 let mut aliasKeys: Vec<Value> = object_keys(&aliases).as_array().cloned().unwrap_or_default();
4457 {
4458 let mut i: i64 = 0;
4459 let mut __for_first_117: bool = true;
4460 while { if !__for_first_117 { i += 1; } __for_first_117 = false; i < (aliasKeys.len() as i64) } {
4461 let mut alias: Value = aliasKeys.get(i as usize).cloned().unwrap_or(Value::Null);
4462 if ((if let (Some(__m), Some(__k)) = (aliases.as_map(), alias.as_str()) { __m.get(__k).cloned().unwrap_or(Value::Null) } else { Value::Null }).as_str() == unifiedCode.as_str()) && (matches!((&networkIdsByCodes, &alias), (Value::Dict(__d), Value::Str(__k)) if __d.contains_key(__k.as_ref()))) {
4463 return (if let (Some(__m), Some(__k)) = (networkIdsByCodes.as_map(), alias.as_str()) { __m.get(__k).cloned().unwrap_or(Value::Null) } else { Value::Null });
4464 }
4465 }
4466 }
4467 let mut currenciesToCheck: Value = Value::from(vec![]);
4469 if (currencyCode == Value::Null) {
4470 currenciesToCheck = Value::Array(self.currencies.as_map().map(|__m| __m.keys().map(|__k| Value::Str(__k.clone().into())).collect()).unwrap_or_default());
4471 } else {
4472 currenciesToCheck = Value::from(vec![self.safe_dict(self.currencies.clone(), currencyCode, &[])]);
4473 }
4474 {
4475 let mut i: i64 = 0;
4476 let mut __for_first_118: bool = true;
4477 while { if !__for_first_118 { i += 1; } __for_first_118 = false; i < (currenciesToCheck.len() as i64) } {
4478 let mut networks: Value = self.safe_dict_k(currenciesToCheck.as_array().map(Vec::as_slice).unwrap_or_default().get(i as usize).cloned().unwrap_or(Value::Null), "networks", &[Value::Map({
4479 let mut m = indexmap::IndexMap::new();
4480 m
4481})]);
4482 if (matches!((&networks, &unifiedCode), (Value::Dict(__d), Value::Str(__k)) if __d.contains_key(__k.as_ref()))) {
4483 return self.safe_string((if let (Some(__m), Some(__k)) = (networks.as_map(), unifiedCode.as_str()) { __m.get(__k).cloned().unwrap_or(Value::Null) } else { Value::Null }), Value::Str("id".into()), &[]);
4484 }
4485 }
4486 }
4487 return networkCode;
4488
4489 Value::Null
4490}
4491
4492 fn network_id_to_code(&self, optional_args: &[Value]) -> Value {
4493 let mut networkId = get_arg(optional_args, 0, Value::Null);
4494 let mut currencyCode = get_arg(optional_args, 1, Value::Null);
4495 if (networkId == Value::Null) {
4505 return Value::Null;
4506 }
4507 let mut networkCodesByIds: Value = self.safe_dict_k(self.options.clone(), "networksById", &[Value::Map({
4508 let mut m = indexmap::IndexMap::new();
4509 m
4510})]);
4511 let mut mappedCode: Value = self.safe_string(networkCodesByIds, networkId.clone(), &[]);
4512 let mut networkCode: Value = (if (mappedCode == Value::Null) { networkId } else { mappedCode });
4513 return self.safe_string(self.networkAliases.clone(), networkCode.clone(), &[networkCode.clone()]);
4514
4515 Value::Null
4516}
4517
4518 fn handle_network_code_and_params(&self, mut params: Value) -> Value {
4519 let mut networkCodeInParams: Option<String> = self.safe_string2_opt(params.clone(), Value::Str("networkCode".into()), Value::Str("network".into()), &[]);
4520 let mut paramsOmitted: Value = (if (networkCodeInParams.is_some()) { self.omit(params.clone(), Value::from(vec![Value::Str("networkCode".into()), Value::Str("network".into())]), &[]) } else { params });
4521 return Value::from(vec![networkCodeInParams.map(Value::from).unwrap_or(Value::Null), paramsOmitted]);
4522
4523 Value::Null
4524}
4525
4526 fn select_network_key_from_networks(&self, mut currencyCode: Value, mut networkCode: Value, mut indexedNetworkEntries: Value, optional_args: &[Value]) -> Value {
4527 let mut isIndexedByUnifiedNetworkCode = get_arg(optional_args, 0, Value::Bool(false));
4528 let mut chosenNetworkId: Value = Value::Null;
4530 let mut availableNetworkIds: Value = object_keys(&indexedNetworkEntries);
4531 let mut responseNetworksLength: f64 = ((availableNetworkIds.len() as i64) as f64);
4532 if (networkCode != Value::Null) {
4533 if (responseNetworksLength == 0.0) {
4534 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)));
4535 } else {
4536 let mut networkIdOrCode: Value = (if isIndexedByUnifiedNetworkCode.as_bool() == Some(true) { networkCode.clone() } else { self.network_code_to_id(networkCode.clone(), &[currencyCode.clone()]) });
4538 if (networkIdOrCode == Value::Null) {
4539 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)));
4540 }
4541 if (matches!((&indexedNetworkEntries, &networkIdOrCode), (Value::Dict(__d), Value::Str(__k)) if __d.contains_key(__k.as_ref()))) {
4542 chosenNetworkId = networkIdOrCode.clone();
4543 } else {
4544 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()),
4545 currencyCode).into()), Value::Str(", use one of ".into())).into()), Value::Str(availableNetworkIds.as_array().map(|__a| __a.iter().map(|__v| __v.to_string()).collect::<Vec<String>>().join(", ")).unwrap_or_default().into()))));
4546 }
4547 }
4548 } else {
4549 if (responseNetworksLength == 0.0) {
4550 panic!("{}", crate::exchange_errors::not_supported(format!("{}{}", Value::Str(format!("{}{}", self.id.clone(), Value::Str(" - no networks were returned for ".into())).into()), currencyCode)));
4551 } else {
4552 let mut defaultNetworkCode: Value = self.safe_string(self.safe_dict_k(self.options.clone(), "defaultNetworks", &[Value::Map({
4554 let mut m = indexmap::IndexMap::new();
4555 m
4556})]), currencyCode.clone(), &[self.safe_string_k(self.options.clone(), "defaultNetwork", &[])]);
4557 let mut defaultNetworkId: Value = (if isIndexedByUnifiedNetworkCode.as_bool() == Some(true) { defaultNetworkCode.clone() } else { self.network_code_to_id(defaultNetworkCode, &[currencyCode]) });
4558 if (defaultNetworkId == Value::Null) {
4559 panic!("{}", crate::exchange_errors::exchange_error(format!("{}{}", self.id.clone(), Value::Str(" selectNetworkKeyFromNetworks() missing defaultNetworkId".into()))));
4560 }
4561 if (matches!((&indexedNetworkEntries, &defaultNetworkId), (Value::Dict(__d), Value::Str(__k)) if __d.contains_key(__k.as_ref()))) {
4562 return defaultNetworkId;
4563 }
4564 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()),
4565 Value::Str(availableNetworkIds.as_array().map(|__a| __a.iter().map(|__v| __v.to_string()).collect::<Vec<String>>().join(", ")).unwrap_or_default().into()))));
4566 }
4567 }
4568 return chosenNetworkId;
4569
4570 Value::Null
4571}
4572
4573 fn safe_number2(&self, mut dictionary: Value, mut key1: Value, mut key2: Value, optional_args: &[Value]) -> Value {
4574 let mut d = get_arg(optional_args, 0, Value::Null);
4575 let mut value: Option<String> = self.safe_string2_opt(dictionary, key1, key2, &[]);
4576 return self.parse_number(value.map(Value::from).unwrap_or(Value::Null), &[d]);
4577
4578 Value::Null
4579}
4580
4581 fn parse_order_book(&self, mut orderbook: Value, mut symbol: Value, optional_args: &[Value]) -> Value {
4582 { 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,
4584 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; } }
4585
4586 let mut timestamp = get_arg(optional_args, 0, Value::Null);
4587 let mut bidsKey = get_arg(optional_args, 1, Value::Str("bids".into()));
4588 let mut asksKey = get_arg(optional_args, 2, Value::Str("asks".into()));
4589 let mut priceKey = get_arg(optional_args, 3, Value::Int(0));
4590 let mut amountKey = get_arg(optional_args, 4, Value::Int(1));
4591 let mut countOrIdKey = get_arg(optional_args, 5, Value::Int(2));
4592 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()]);
4593 let mut asks: Value = self.parse_order_book_bids_asks(self.safe_value(orderbook, asksKey, &[Value::from(vec![])]), &[priceKey, amountKey, countOrIdKey]);
4594 return Value::Map({
4595 let mut m = indexmap::IndexMap::new();
4596 m.insert("symbol".to_string(), symbol);
4597 m.insert("bids".to_string(), self.sort_by(bids, Value::Int(0), &[Value::Bool(true)]));
4598 m.insert("asks".to_string(), self.sort_by(asks, Value::Int(0), &[]));
4599 m.insert("timestamp".to_string(), timestamp.clone());
4600 m.insert("datetime".to_string(), self.iso8601(timestamp));
4601 m.insert("nonce".to_string(), Value::Null);
4602 m
4603});
4604
4605 Value::Null
4606}
4607
4608 fn parse_order_book_l3(&self, mut orderbook: Value, mut symbol: Value, optional_args: &[Value]) -> Value {
4609 let mut timestamp = get_arg(optional_args, 0, Value::Null);
4610 let mut bidsKey = get_arg(optional_args, 1, Value::Str("bids".into()));
4611 let mut asksKey = get_arg(optional_args, 2, Value::Str("asks".into()));
4612 let mut priceKey = get_arg(optional_args, 3, Value::Int(0));
4613 let mut amountKey = get_arg(optional_args, 4, Value::Int(1));
4614 let mut countOrIdKey = get_arg(optional_args, 5, Value::Int(2));
4615 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()]);
4616 let mut asks: Value = self.parse_order_book_bids_asks_l3(self.safe_value(orderbook, asksKey, &[Value::from(vec![])]), &[priceKey, amountKey, countOrIdKey]);
4617 return Value::Map({
4618 let mut m = indexmap::IndexMap::new();
4619 m.insert("symbol".to_string(), symbol);
4620 m.insert("bids".to_string(), self.sort_by(bids, Value::Int(0), &[Value::Bool(true)]));
4621 m.insert("asks".to_string(), self.sort_by(asks, Value::Int(0), &[]));
4622 m.insert("timestamp".to_string(), timestamp.clone());
4623 m.insert("datetime".to_string(), self.iso8601(timestamp));
4624 m.insert("nonce".to_string(), Value::Null);
4625 m
4626});
4627
4628 Value::Null
4629}
4630
4631 fn parse_ohlc_vs(&self, mut ohlcvs: Value, optional_args: &[Value]) -> Value {
4632 let mut market = get_arg(optional_args, 0, Value::Null);
4633 let mut timeframe = get_arg(optional_args, 1, Value::Str("1m".into()));
4634 let mut since = get_arg(optional_args, 2, Value::Null);
4635 let mut limit = get_arg(optional_args, 3, Value::Null);
4636 let mut tail = get_arg(optional_args, 4, Value::Bool(false));
4637 if (ohlcvs == Value::Null) {
4638 return Value::from(vec![]);
4639 }
4640 let mut results: Vec<Value> = Vec::new();
4641 {
4642 let mut i: i64 = 0;
4643 let mut __for_first_119: bool = true;
4644 while { if !__for_first_119 { i += 1; } __for_first_119 = false; i < (ohlcvs.len() as i64) } {
4645 results.push(<Self as crate::exchange_generated::ExchangeBase>::parse_ohlcv(self, ohlcvs.as_array().map(Vec::as_slice).unwrap_or_default().get(i as usize).cloned().unwrap_or(Value::Null), &[market.clone()]));
4646 }
4647 }
4648 let mut sorted: Value = self.sort_by(Value::from(results), Value::Int(0), &[]);
4649 return self.filter_by_since_limit(sorted, &[since, limit, Value::Int(0), tail]);
4650
4651 Value::Null
4652}
4653
4654 fn parse_leverage_tiers(&self, mut response: Value, optional_args: &[Value]) -> Value {
4655 let mut symbols = get_arg(optional_args, 0, Value::Null);
4656 let mut marketIdKey = get_arg(optional_args, 1, Value::Null);
4657 let mut symbolsNormalized: Value = self.market_symbols(&[symbols]);
4659 let mut tiers: Value = Value::Map({
4660 let mut m = indexmap::IndexMap::new();
4661 m
4662 });
4663 let mut symbolsLength: i64 = 0;
4664 if (symbolsNormalized != Value::Null) {
4665 symbolsLength = symbolsNormalized.len() as i64;
4666 }
4667 let mut noSymbols: bool = (symbolsNormalized == Value::Null) || (((symbolsLength as f64) == 0.0));
4668 if (matches!(&response, Value::Arr(_))) {
4669 {
4670 let mut i: i64 = 0;
4671 let mut __for_first_120: bool = true;
4672 while { if !__for_first_120 { i += 1; } __for_first_120 = false; i < (response.len() as i64) } {
4673 let mut item: Value = self.safe_value(response.clone(), Value::Int(i), &[]);
4674 let mut id: Value = (if (marketIdKey == Value::Null) { Value::Null } else { self.safe_string(item.clone(), marketIdKey.clone(), &[]) });
4675 let mut market: Value = self.safe_market(&[id, Value::Null, Value::Null, Value::Str("swap".into())]);
4676 let mut symbol: Value = self.safe_string_k(market.clone(), "symbol", &[Value::Str("".into())]);
4677 let mut contract: bool = self.safe_bool_k_opt(market.clone(), "contract", &[Value::Bool(false)]).unwrap_or(false);
4678 if contract && (noSymbols || ((symbolsNormalized != Value::Null) && self.in_array(symbol.clone(), symbolsNormalized.clone()).as_bool() == Some(true))) {
4679 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()])); }
4680 }
4681 }
4682 }
4683 } else {
4684 let mut keys: Vec<Value> = object_keys(&response).as_array().cloned().unwrap_or_default();
4685 {
4686 let mut i: i64 = 0;
4687 let mut __for_first_121: bool = true;
4688 while { if !__for_first_121 { i += 1; } __for_first_121 = false; i < (keys.len() as i64) } {
4689 let mut marketId: Value = keys.get(i as usize).cloned().unwrap_or(Value::Null);
4690 let mut item: Value = self.safe_value(response.clone(), marketId.clone(), &[]);
4691 let mut market: Value = self.safe_market(&[marketId, Value::Null, Value::Null, Value::Str("swap".into())]);
4692 let mut symbol: Value = self.safe_string_k(market.clone(), "symbol", &[Value::Str("".into())]);
4693 let mut contract: bool = self.safe_bool_k_opt(market.clone(), "contract", &[Value::Bool(false)]).unwrap_or(false);
4694 if contract && (noSymbols || ((symbolsNormalized != Value::Null) && self.in_array(symbol.clone(), symbolsNormalized.clone()).as_bool() == Some(true))) {
4695 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])); }
4696 }
4697 }
4698 }
4699 }
4700 return tiers;
4701
4702 Value::Null
4703}
4704
4705 fn load_trading_limits(&mut self, optional_args: &[Value]) -> impl ::std::future::Future<Output = Value> + Send { async move {
4706 let mut symbols = get_arg(optional_args, 0, Value::Null);
4707 let mut reload = get_arg(optional_args, 1, Value::Bool(false));
4708 let mut params = get_arg(optional_args, 2, Value::Map({
4709 let mut m = indexmap::IndexMap::new();
4710 m
4711}));
4712 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)) {
4713 if reload.as_bool() == Some(true) || !(matches!(&self.options, Value::Dict(__d) if __d.contains_key("limitsLoaded"))) {
4714 let mut response: Value = self.fetch_trading_limits(&[symbols.clone()]).await;
4715 let mut symbolsArray: Value = self.require_value(symbols, &[Value::Str("loadTradingLimits() requires a symbols argument".into())]);
4716 let mut markets: Value = self.markets.clone();
4717 if (markets == Value::Null) {
4718 panic!("{}", crate::exchange_errors::exchange_error(format!("{}{}", self.id.clone(), Value::Str(" markets not loaded".into()))));
4719 }
4720 {
4721 let mut i: Value = Value::Int(0);
4722 let mut __for_first_122: bool = true;
4723 while { if !__for_first_122 { if let Value::Int(n) = &mut i { *n += 1; } } __for_first_122 = false; i.as_f64().unwrap_or(f64::NAN) < get_array_length(&symbolsArray).as_f64().unwrap_or(f64::NAN) } {
4724 let mut symbol: Value = get_value(&symbolsArray, &i);
4725 { let __be_tmp = self.deep_extend(get_value(&markets, &symbol), &[get_value(&response, &symbol)]); add_element_to_object(&mut markets, &symbol, __be_tmp); };
4726 }
4727 }
4728 { let __be_tmp = self.milliseconds(); if let Value::Dict(__d) = &mut self.options { std::sync::Arc::make_mut(__d).insert("limitsLoaded".into(), __be_tmp); } }
4729 }
4730 }
4731 return self.markets.clone();
4732
4733 Value::Null
4734} }
4735
4736 fn safe_position(&self, mut position: Value) -> Value {
4737 let mut contractSize: Value = self.safe_number_k(position.clone(), "contractSize", &[]);
4740 let mut symbol: Option<String> = self.safe_string_k_opt(position.clone(), "symbol", &[]);
4741 let mut market: Value = Value::Null;
4742 if (symbol.is_some()) {
4743 market = self.safe_value(self.markets.clone(), symbol.map(Value::from).unwrap_or(Value::Null), &[]);
4744 }
4745 if (contractSize == Value::Null) && (market != Value::Null) {
4746 contractSize = self.safe_number_k(market.clone(), "contractSize", &[]);
4747 if let Value::Dict(__d) = &mut position { std::sync::Arc::make_mut(__d).insert("contractSize".into(), contractSize); }
4748 }
4749 let mut isInverse: bool = (market != Value::Null) && self.safe_bool_k(market, "inverse", &[Value::Bool(false)]).as_bool() == Some(true);
4750 let mut side: Option<String> = self.safe_string_k(position.clone(), "side", &[]).as_str().map(str::to_owned);
4751 let mut marginMode: Option<String> = self.safe_string_k(position.clone(), "marginMode", &[]).as_str().map(str::to_owned);
4752 let mut unrealizedPnlString: Value = self.safe_string_k(position.clone(), "unrealizedPnl", &[]);
4753 let mut initialMarginString: Value = self.safe_string_k(position.clone(), "initialMargin", &[]);
4754 let mut maintenanceMarginString: Value = self.safe_string_k(position.clone(), "maintenanceMargin", &[]);
4755 let mut collateralString: Value = self.safe_string_k(position.clone(), "collateral", &[]);
4756 let mut entryPriceString: Value = self.safe_string_k(position.clone(), "entryPrice", &[]);
4757 let mut liquidationPriceString: Value = self.safe_string_k(position.clone(), "liquidationPrice", &[]);
4758 let mut contractsString: Value = self.safe_string_k(position.clone(), "contracts", &[]);
4759 let mut contractSizeString: Value = self.safe_string_k(position.clone(), "contractSize", &[]);
4760 let mut marginString: Value = self.safe_string_k(position.clone(), "positionMargin", &[]);
4762 if (marginString == Value::Null) && (marginMode.as_deref() == Some("isolated")) && (collateralString != Value::Null) {
4763 let mut derivedMargin: Value = collateralString.clone();
4764 if (unrealizedPnlString != Value::Null) && !(crate::precise::Precise::stringEq(&collateralString, &initialMarginString).as_bool() == Some(true)) {
4765 derivedMargin = crate::precise::Precise::stringSub(&collateralString, &unrealizedPnlString);
4766 }
4767 if crate::precise::Precise::stringGt(&derivedMargin, &Value::Str("0".into())).as_bool() == Some(true) {
4768 marginString = derivedMargin.clone();
4769 if let Value::Dict(__d) = &mut position { std::sync::Arc::make_mut(__d).insert("positionMargin".into(), self.parse_number(derivedMargin, &[])); }
4770 }
4771 }
4772 if (marginString == Value::Null) {
4773 if let Value::Dict(__d) = &mut position { std::sync::Arc::make_mut(__d).insert("positionMargin".into(), Value::Null); }; }
4775 if (collateralString == Value::Null) && (marginString != Value::Null) && (unrealizedPnlString != Value::Null) {
4776 collateralString = crate::precise::Precise::stringAdd(&marginString, &unrealizedPnlString);
4777 if let Value::Dict(__d) = &mut position { std::sync::Arc::make_mut(__d).insert("collateral".into(), self.parse_number(collateralString.clone(), &[])); }
4778 }
4779 if (marginMode.as_deref() == Some("isolated")) {
4780 let mut entryMarginString: Value = marginString.clone();
4781 if (entryMarginString == Value::Null) && (collateralString == Value::Null) {
4782 entryMarginString = initialMarginString.clone();
4783 }
4784 let mut hasEntryMargin: bool = (entryMarginString != Value::Null) && crate::precise::Precise::stringGt(&entryMarginString, &Value::Str("0".into())).as_bool() == Some(true);
4785 let mut hasEntryPrice: bool = (entryPriceString != Value::Null) && crate::precise::Precise::stringGt(&entryPriceString, &Value::Str("0".into())).as_bool() == Some(true);
4786 let mut hasLiqPrice: bool = (liquidationPriceString != Value::Null) && crate::precise::Precise::stringGt(&liquidationPriceString, &Value::Str("0".into())).as_bool() == Some(true);
4787 let mut hasContracts: bool = (contractsString != Value::Null) && crate::precise::Precise::stringGt(&contractsString, &Value::Str("0".into())).as_bool() == Some(true);
4788 let mut hasContractSize: bool = (contractSizeString != Value::Null) && crate::precise::Precise::stringGt(&contractSizeString, &Value::Str("0".into())).as_bool() == Some(true);
4789 let mut hasMm: bool = (maintenanceMarginString != Value::Null) && crate::precise::Precise::stringGt(&maintenanceMarginString, &Value::Str("0".into())).as_bool() == Some(true);
4790 let mut priceDiff: Value = Value::Null;
4791 if hasEntryPrice && hasLiqPrice {
4792 if isInverse {
4793 let mut invEntry: Value = crate::precise::Precise::stringDiv(&Value::Str("1".into()), &entryPriceString);
4794 let mut invLiq: Value = crate::precise::Precise::stringDiv(&Value::Str("1".into()), &liquidationPriceString);
4795 if (side.as_deref() == Some("long")) {
4796 priceDiff = crate::precise::Precise::stringSub(&invLiq, &invEntry);
4797 } else if (side.as_deref() == Some("short")) {
4798 priceDiff = crate::precise::Precise::stringSub(&invEntry, &invLiq);
4799 } else {
4800 priceDiff = crate::precise::Precise::stringAbs(&crate::precise::Precise::stringSub(&invEntry, &invLiq));
4801 }
4802 } else {
4803 if (side.as_deref() == Some("long")) {
4804 priceDiff = crate::precise::Precise::stringSub(&entryPriceString, &liquidationPriceString);
4805 } else if (side.as_deref() == Some("short")) {
4806 priceDiff = crate::precise::Precise::stringSub(&liquidationPriceString, &entryPriceString);
4807 } else {
4808 priceDiff = crate::precise::Precise::stringAbs(&crate::precise::Precise::stringSub(&entryPriceString, &liquidationPriceString));
4809 }
4810 }
4811 }
4812 let mut hasPriceDiff: bool = (priceDiff != Value::Null) && crate::precise::Precise::stringGt(&priceDiff, &Value::Str("0".into())).as_bool() == Some(true);
4813 if (maintenanceMarginString == Value::Null) && hasEntryMargin && hasPriceDiff && hasContracts && hasContractSize {
4814 let mut lossFromEntry: Value = crate::precise::Precise::stringMul(&priceDiff, &crate::precise::Precise::stringMul(&contractsString, &contractSizeString));
4815 let mut derivedMm: Value = crate::precise::Precise::stringSub(&entryMarginString, &lossFromEntry);
4816 if crate::precise::Precise::stringGt(&derivedMm, &Value::Str("0".into())).as_bool() == Some(true) {
4817 maintenanceMarginString = derivedMm.clone();
4818 if let Value::Dict(__d) = &mut position { std::sync::Arc::make_mut(__d).insert("maintenanceMargin".into(), self.parse_number(derivedMm.clone(), &[])); }
4819 }
4820 } else if (collateralString == Value::Null) && (initialMarginString == Value::Null) && hasMm && hasPriceDiff && hasContracts && hasContractSize {
4821 let mut lossFromEntry: Value = crate::precise::Precise::stringMul(&priceDiff, &crate::precise::Precise::stringMul(&contractsString, &contractSizeString));
4822 let mut derivedEntryMargin: Value = crate::precise::Precise::stringAdd(&maintenanceMarginString, &lossFromEntry);
4823 if crate::precise::Precise::stringGt(&derivedEntryMargin, &Value::Str("0".into())).as_bool() == Some(true) {
4824 initialMarginString = derivedEntryMargin.clone();
4825 if let Value::Dict(__d) = &mut position { std::sync::Arc::make_mut(__d).insert("initialMargin".into(), self.parse_number(derivedEntryMargin.clone(), &[])); }
4826 marginString = derivedEntryMargin.clone();
4827 if let Value::Dict(__d) = &mut position { std::sync::Arc::make_mut(__d).insert("positionMargin".into(), self.parse_number(derivedEntryMargin.clone(), &[])); }
4828 let mut derivedCollateral: Value = derivedEntryMargin.clone();
4829 if (unrealizedPnlString != Value::Null) {
4830 derivedCollateral = crate::precise::Precise::stringAdd(&derivedEntryMargin, &unrealizedPnlString);
4831 }
4832 if crate::precise::Precise::stringGt(&derivedCollateral, &Value::Str("0".into())).as_bool() == Some(true) {
4833 collateralString = derivedCollateral.clone();
4834 if let Value::Dict(__d) = &mut position { std::sync::Arc::make_mut(__d).insert("collateral".into(), self.parse_number(derivedCollateral, &[])); }
4835 }
4836 }
4837 } else if (liquidationPriceString == Value::Null) && hasEntryMargin && hasMm && hasEntryPrice && hasContracts && hasContractSize && ((side.as_deref() == Some("long")) || (side.as_deref() == Some("short"))) {
4838 let mut marginBuffer: Value = crate::precise::Precise::stringSub(&entryMarginString, &maintenanceMarginString);
4839 let mut totalSize: Value = crate::precise::Precise::stringMul(&contractsString, &contractSizeString);
4840 if crate::precise::Precise::stringGt(&marginBuffer, &Value::Str("0".into())).as_bool() == Some(true) && crate::precise::Precise::stringGt(&totalSize, &Value::Str("0".into())).as_bool() == Some(true) {
4841 let mut bufferPerUnit: Value = crate::precise::Precise::stringDiv(&marginBuffer, &totalSize);
4842 let mut derivedLp: Value = crate::precise::Precise::stringAdd(&entryPriceString, &bufferPerUnit);
4843 if (side.as_deref() == Some("long")) {
4844 derivedLp = crate::precise::Precise::stringSub(&entryPriceString, &bufferPerUnit);
4845 }
4846 if isInverse {
4847 let mut invEntry: Value = crate::precise::Precise::stringDiv(&Value::Str("1".into()), &entryPriceString);
4848 let mut invDerivedLp: Value = crate::precise::Precise::stringSub(&invEntry, &bufferPerUnit);
4849 if (side.as_deref() == Some("long")) {
4850 invDerivedLp = crate::precise::Precise::stringAdd(&invEntry, &bufferPerUnit);
4851 }
4852 derivedLp = crate::precise::Precise::stringDiv(&Value::Str("1".into()), &invDerivedLp);
4855 }
4856 if (derivedLp != Value::Null) && crate::precise::Precise::stringGt(&derivedLp, &Value::Str("0".into())).as_bool() == Some(true) {
4857 liquidationPriceString = derivedLp.clone();
4858 if let Value::Dict(__d) = &mut position { std::sync::Arc::make_mut(__d).insert("liquidationPrice".into(), self.parse_number(derivedLp, &[])); }
4859 }
4860 }
4861 } else if (entryPriceString == Value::Null) && hasEntryMargin && hasMm && hasLiqPrice && hasContracts && hasContractSize && ((side.as_deref() == Some("long")) || (side.as_deref() == Some("short"))) {
4862 let mut marginBuffer: Value = crate::precise::Precise::stringSub(&entryMarginString, &maintenanceMarginString);
4863 let mut totalSize: Value = crate::precise::Precise::stringMul(&contractsString, &contractSizeString);
4864 if crate::precise::Precise::stringGt(&marginBuffer, &Value::Str("0".into())).as_bool() == Some(true) && crate::precise::Precise::stringGt(&totalSize, &Value::Str("0".into())).as_bool() == Some(true) {
4865 let mut bufferPerUnit: Value = crate::precise::Precise::stringDiv(&marginBuffer, &totalSize);
4866 let mut derivedEp: Value = crate::precise::Precise::stringSub(&liquidationPriceString, &bufferPerUnit);
4867 if (side.as_deref() == Some("long")) {
4868 derivedEp = crate::precise::Precise::stringAdd(&liquidationPriceString, &bufferPerUnit);
4869 }
4870 if isInverse {
4871 let mut invLp: Value = crate::precise::Precise::stringDiv(&Value::Str("1".into()), &liquidationPriceString);
4872 let mut invEp: Value = crate::precise::Precise::stringAdd(&invLp, &bufferPerUnit);
4873 if (side.as_deref() == Some("long")) {
4874 invEp = crate::precise::Precise::stringSub(&invLp, &bufferPerUnit);
4875 }
4876 derivedEp = crate::precise::Precise::stringDiv(&Value::Str("1".into()), &invEp);
4879 }
4880 if (derivedEp != Value::Null) && crate::precise::Precise::stringGt(&derivedEp, &Value::Str("0".into())).as_bool() == Some(true) {
4881 entryPriceString = derivedEp.clone();
4882 if let Value::Dict(__d) = &mut position { std::sync::Arc::make_mut(__d).insert("entryPrice".into(), self.parse_number(derivedEp, &[])); }
4883 }
4884 }
4885 } else if (contractsString == Value::Null) && hasEntryMargin && hasMm && hasPriceDiff && hasContractSize {
4886 let mut marginBuffer: Value = crate::precise::Precise::stringSub(&entryMarginString, &maintenanceMarginString);
4887 let mut denom: Value = crate::precise::Precise::stringMul(&priceDiff, &contractSizeString);
4888 if crate::precise::Precise::stringGt(&marginBuffer, &Value::Str("0".into())).as_bool() == Some(true) && crate::precise::Precise::stringGt(&denom, &Value::Str("0".into())).as_bool() == Some(true) {
4889 let mut derivedContracts: Value = crate::precise::Precise::stringDiv(&marginBuffer, &denom);
4890 if crate::precise::Precise::stringGt(&derivedContracts, &Value::Str("0".into())).as_bool() == Some(true) {
4891 contractsString = derivedContracts.clone();
4892 if let Value::Dict(__d) = &mut position { std::sync::Arc::make_mut(__d).insert("contracts".into(), self.parse_number(derivedContracts, &[])); }
4893 }
4894 }
4895 } else if (contractSizeString == Value::Null) && hasEntryMargin && hasMm && hasPriceDiff && hasContracts {
4896 let mut marginBuffer: Value = crate::precise::Precise::stringSub(&entryMarginString, &maintenanceMarginString);
4897 let mut denom: Value = crate::precise::Precise::stringMul(&priceDiff, &contractsString);
4898 if crate::precise::Precise::stringGt(&marginBuffer, &Value::Str("0".into())).as_bool() == Some(true) && crate::precise::Precise::stringGt(&denom, &Value::Str("0".into())).as_bool() == Some(true) {
4899 let mut derivedContractSize: Value = crate::precise::Precise::stringDiv(&marginBuffer, &denom);
4900 if crate::precise::Precise::stringGt(&derivedContractSize, &Value::Str("0".into())).as_bool() == Some(true) {
4901 contractSizeString = derivedContractSize.clone();
4902 if let Value::Dict(__d) = &mut position { std::sync::Arc::make_mut(__d).insert("contractSize".into(), self.parse_number(derivedContractSize, &[])); }
4903 }
4904 }
4905 }
4906 }
4907 let mut isZeroPosition: bool = (contractsString != Value::Null) && crate::precise::Precise::stringEq(&contractsString, &Value::Str("0".into())).as_bool() == Some(true);
4911 if !isZeroPosition {
4912 let mut notionalString: Value = self.safe_string_k(position.clone(), "notional", &[]);
4913 let mut markPriceString: Value = self.safe_string_k(position.clone(), "markPrice", &[]);
4914 let mut lastPriceString: Option<String> = self.safe_string_k(position.clone(), "lastPrice", &[]).as_str().map(str::to_owned);
4915 let mut hasContracts: bool = (contractsString != Value::Null) && crate::precise::Precise::stringGt(&contractsString, &Value::Str("0".into())).as_bool() == Some(true);
4916 let mut hasContractSize: bool = (contractSizeString != Value::Null) && crate::precise::Precise::stringGt(&contractSizeString, &Value::Str("0".into())).as_bool() == Some(true);
4917 let mut hasMarkPrice: bool = (markPriceString != Value::Null) && crate::precise::Precise::stringGt(&markPriceString, &Value::Str("0".into())).as_bool() == Some(true);
4918 let mut hasNotional: bool = (notionalString != Value::Null) && crate::precise::Precise::stringGt(¬ionalString, &Value::Str("0".into())).as_bool() == Some(true);
4919 if (notionalString == Value::Null) && hasMarkPrice && hasContracts && hasContractSize {
4921 let mut totalSize: Value = crate::precise::Precise::stringMul(&contractsString, &contractSizeString);
4922 let mut derivedNotional: Value = crate::precise::Precise::stringMul(&totalSize, &markPriceString);
4923 if isInverse {
4924 derivedNotional = crate::precise::Precise::stringDiv(&totalSize, &markPriceString);
4925 }
4926 if crate::precise::Precise::stringGt(&derivedNotional, &Value::Str("0".into())).as_bool() == Some(true) {
4927 notionalString = derivedNotional.clone();
4928 if let Value::Dict(__d) = &mut position { std::sync::Arc::make_mut(__d).insert("notional".into(), self.parse_number(derivedNotional, &[])); }
4929 }
4930 } else if (markPriceString == Value::Null) && (entryPriceString == Value::Null) && (lastPriceString.is_none()) && hasNotional && hasContracts && hasContractSize {
4931 let mut totalSize: Value = crate::precise::Precise::stringMul(&contractsString, &contractSizeString);
4932 let mut derivedMark: Value = crate::precise::Precise::stringDiv(¬ionalString, &totalSize);
4933 if isInverse {
4934 derivedMark = crate::precise::Precise::stringDiv(&totalSize, ¬ionalString);
4935 }
4936 if crate::precise::Precise::stringGt(&derivedMark, &Value::Str("0".into())).as_bool() == Some(true) {
4937 markPriceString = derivedMark.clone();
4938 if let Value::Dict(__d) = &mut position { std::sync::Arc::make_mut(__d).insert("markPrice".into(), self.parse_number(derivedMark, &[])); }
4939 }
4940 } else if (contractsString == Value::Null) && hasNotional && hasMarkPrice && hasContractSize {
4941 let mut notionalContracts: Value = crate::precise::Precise::stringDiv(¬ionalString, &crate::precise::Precise::stringMul(&markPriceString, &contractSizeString));
4942 if isInverse {
4943 notionalContracts = crate::precise::Precise::stringDiv(&crate::precise::Precise::stringMul(¬ionalString, &markPriceString), &contractSizeString);
4944 }
4945 if crate::precise::Precise::stringGt(¬ionalContracts, &Value::Str("0".into())).as_bool() == Some(true) {
4946 contractsString = notionalContracts.clone();
4947 if let Value::Dict(__d) = &mut position { std::sync::Arc::make_mut(__d).insert("contracts".into(), self.parse_number(notionalContracts, &[])); }
4948 }
4949 } else if (contractSizeString == Value::Null) && hasNotional && hasMarkPrice && hasContracts {
4950 let mut notionalContractSize: Value = crate::precise::Precise::stringDiv(¬ionalString, &crate::precise::Precise::stringMul(&markPriceString, &contractsString));
4951 if isInverse {
4952 notionalContractSize = crate::precise::Precise::stringDiv(&crate::precise::Precise::stringMul(¬ionalString, &markPriceString), &contractsString);
4953 }
4954 if crate::precise::Precise::stringGt(¬ionalContractSize, &Value::Str("0".into())).as_bool() == Some(true) {
4955 contractSizeString = notionalContractSize.clone();
4956 if let Value::Dict(__d) = &mut position { std::sync::Arc::make_mut(__d).insert("contractSize".into(), self.parse_number(notionalContractSize, &[])); }
4957 }
4958 }
4959 if (unrealizedPnlString == Value::Null) && (entryPriceString != Value::Null) && (markPriceString != Value::Null) && (contractsString != Value::Null) && (contractSizeString != Value::Null) {
4961 if crate::precise::Precise::stringGt(&entryPriceString, &Value::Str("0".into())).as_bool() == Some(true) && crate::precise::Precise::stringGt(&markPriceString, &Value::Str("0".into())).as_bool() == Some(true) && crate::precise::Precise::stringGt(&contractsString,
4962 &Value::Str("0".into())).as_bool() == Some(true) && crate::precise::Precise::stringGt(&contractSizeString, &Value::Str("0".into())).as_bool() == Some(true) {
4963 let mut totalSize: Value = crate::precise::Precise::stringMul(&contractsString, &contractSizeString);
4964 let mut pnlDiff: Value = Value::Null;
4965 if isInverse {
4966 let mut invEntry: Value = crate::precise::Precise::stringDiv(&Value::Str("1".into()), &entryPriceString);
4967 let mut invMark: Value = crate::precise::Precise::stringDiv(&Value::Str("1".into()), &markPriceString);
4968 if (side.as_deref() == Some("long")) {
4969 pnlDiff = crate::precise::Precise::stringSub(&invEntry, &invMark);
4970 } else if (side.as_deref() == Some("short")) {
4971 pnlDiff = crate::precise::Precise::stringSub(&invMark, &invEntry);
4972 }
4973 } else {
4974 if (side.as_deref() == Some("long")) {
4975 pnlDiff = crate::precise::Precise::stringSub(&markPriceString, &entryPriceString);
4976 } else if (side.as_deref() == Some("short")) {
4977 pnlDiff = crate::precise::Precise::stringSub(&entryPriceString, &markPriceString);
4978 }
4979 }
4980 if (pnlDiff != Value::Null) {
4981 let mut candidateUpnl: Value = crate::precise::Precise::stringMul(&pnlDiff, &totalSize);
4982 if crate::precise::Precise::stringEq(&candidateUpnl, &Value::Str("0".into())).as_bool() == Some(true) || crate::precise::Precise::stringGe(&crate::precise::Precise::stringAbs(&candidateUpnl), &Value::Str("0.000001".into())).as_bool() == Some(true) {
4983 unrealizedPnlString = candidateUpnl.clone();
4984 if let Value::Dict(__d) = &mut position { std::sync::Arc::make_mut(__d).insert("unrealizedPnl".into(), self.parse_number(unrealizedPnlString.clone(), &[])); }
4985 }
4986 }
4987 }
4988 }
4989 let mut hasValidNotional: bool = (notionalString != Value::Null) && crate::precise::Precise::stringGt(¬ionalString, &Value::Str("0".into())).as_bool() == Some(true);
4991 let mut hasNegativeCollateral: bool = (collateralString != Value::Null) && crate::precise::Precise::stringLt(&collateralString, &Value::Str("0".into())).as_bool() == Some(true);
4992 let mut initialMarginPercentageString: Value = self.safe_string_k(position.clone(), "initialMarginPercentage", &[]);
4993 let mut leverageString: Option<String> = self.safe_string_k_opt(position.clone(), "leverage", &[]);
4994 let mut hasLeverage: bool = (leverageString.is_some()) && crate::precise::Precise::stringGt(&leverageString.clone().map(Value::from).unwrap_or(Value::Null), &Value::Str("0".into())).as_bool() == Some(true);
4995 let mut hasInitialMargin: bool = (initialMarginString != Value::Null) && crate::precise::Precise::stringGt(&initialMarginString, &Value::Str("0".into())).as_bool() == Some(true);
4996 let mut hadInitialMargin: bool = initialMarginString != Value::Null;
4997 if (initialMarginPercentageString == Value::Null) && !hasNegativeCollateral && (hasInitialMargin || !hadInitialMargin) {
4998 if hasInitialMargin && hasValidNotional {
4999 initialMarginPercentageString = crate::precise::Precise::stringDiv(&initialMarginString, ¬ionalString);
5000 } else if hasLeverage {
5001 initialMarginPercentageString = crate::precise::Precise::stringDiv(&Value::Str("1".into()), &leverageString.clone().map(Value::from).unwrap_or(Value::Null));
5002 }
5003 if (initialMarginPercentageString != Value::Null) && crate::precise::Precise::stringGt(&initialMarginPercentageString, &Value::Str("0".into())).as_bool() == Some(true) {
5004 if let Value::Dict(__d) = &mut position { std::sync::Arc::make_mut(__d).insert("initialMarginPercentage".into(), self.parse_number(initialMarginPercentageString.clone(), &[])); }
5005 }
5006 }
5007 let mut hasImp: bool = (initialMarginPercentageString != Value::Null) && crate::precise::Precise::stringGt(&initialMarginPercentageString, &Value::Str("0".into())).as_bool() == Some(true);
5008 if (initialMarginString == Value::Null) && !hasNegativeCollateral && hasValidNotional {
5009 if hasLeverage {
5010 initialMarginString = crate::precise::Precise::stringDiv(¬ionalString, &leverageString.clone().map(Value::from).unwrap_or(Value::Null));
5011 } else if hasImp {
5012 initialMarginString = crate::precise::Precise::stringMul(¬ionalString, &initialMarginPercentageString);
5013 }
5014 if (initialMarginString != Value::Null) && crate::precise::Precise::stringGt(&initialMarginString, &Value::Str("0".into())).as_bool() == Some(true) {
5015 if let Value::Dict(__d) = &mut position { std::sync::Arc::make_mut(__d).insert("initialMargin".into(), self.parse_number(initialMarginString.clone(), &[])); }
5016 }
5017 }
5018 if (leverageString.is_none()) && !hadInitialMargin && hasImp {
5019 let mut derivedLeverage: Value = crate::precise::Precise::stringDiv(&Value::Str("1".into()), &initialMarginPercentageString);
5020 if crate::precise::Precise::stringGt(&derivedLeverage, &Value::Str("0".into())).as_bool() == Some(true) && crate::precise::Precise::stringLe(&derivedLeverage, &Value::Str("200".into())).as_bool() == Some(true) {
5021 if let Value::Dict(__d) = &mut position { std::sync::Arc::make_mut(__d).insert("leverage".into(), self.parse_number(derivedLeverage, &[])); }
5022 }
5023 }
5024 let mut maintenanceMarginPercentageString: Value = self.safe_string_k(position.clone(), "maintenanceMarginPercentage", &[]);
5026 let mut hasValidMm: bool = (maintenanceMarginString != Value::Null) && crate::precise::Precise::stringGt(&maintenanceMarginString, &Value::Str("0".into())).as_bool() == Some(true);
5027 let mut hasValidMmp: bool = (maintenanceMarginPercentageString != Value::Null) && crate::precise::Precise::stringGt(&maintenanceMarginPercentageString, &Value::Str("0".into())).as_bool() == Some(true);
5028 if (maintenanceMarginString == Value::Null) && hasValidNotional && hasValidMmp {
5029 let mut derivedMm: Value = crate::precise::Precise::stringMul(¬ionalString, &maintenanceMarginPercentageString);
5030 if crate::precise::Precise::stringGt(&derivedMm, &Value::Str("0".into())).as_bool() == Some(true) {
5031 maintenanceMarginString = derivedMm.clone();
5032 if let Value::Dict(__d) = &mut position { std::sync::Arc::make_mut(__d).insert("maintenanceMargin".into(), self.parse_number(derivedMm, &[])); }
5033 }
5034 } else if (maintenanceMarginPercentageString == Value::Null) && hasValidNotional && hasValidMm {
5035 let mut derivedMmp: Value = crate::precise::Precise::stringDiv(&maintenanceMarginString, ¬ionalString);
5036 if crate::precise::Precise::stringGt(&derivedMmp, &Value::Str("0".into())).as_bool() == Some(true) {
5037 maintenanceMarginPercentageString = derivedMmp.clone();
5038 if let Value::Dict(__d) = &mut position { std::sync::Arc::make_mut(__d).insert("maintenanceMarginPercentage".into(), self.parse_number(derivedMmp, &[])); }
5039 }
5040 }
5041 let mut marginRatio: Value = self.safe_value_k(position.clone(), "marginRatio", &[]);
5043 if (marginRatio == Value::Null) && (maintenanceMarginString != Value::Null) && (collateralString != Value::Null) {
5044 if crate::precise::Precise::stringGt(&maintenanceMarginString, &Value::Str("0".into())).as_bool() == Some(true) && crate::precise::Precise::stringGt(&collateralString, &Value::Str("0".into())).as_bool() == Some(true) {
5045 let mut derivedMarginRatio: Value = crate::precise::Precise::stringDivPrec(&maintenanceMarginString, &collateralString, &Value::Int(4));
5046 if (derivedMarginRatio != Value::Null) && crate::precise::Precise::stringGt(&derivedMarginRatio, &Value::Str("0".into())).as_bool() == Some(true) {
5047 if let Value::Dict(__d) = &mut position { std::sync::Arc::make_mut(__d).insert("marginRatio".into(), self.parse_number(derivedMarginRatio, &[])); }
5048 }
5049 }
5050 }
5051 }
5052 let mut percentage: Value = self.safe_value_k(position.clone(), "percentage", &[]);
5056 if (percentage == Value::Null) && (unrealizedPnlString != Value::Null) && (initialMarginString != Value::Null) {
5057 let mut percentageString: Value = crate::precise::Precise::stringMul(&crate::precise::Precise::stringDivPrec(&unrealizedPnlString, &initialMarginString, &Value::Int(4)), &Value::Str("100".into()));
5059 if let Value::Dict(__d) = &mut position { std::sync::Arc::make_mut(__d).insert("percentage".into(), self.parse_number(percentageString, &[])); }
5060 }
5061 return position;
5062
5063 Value::Null
5064}
5065
5066 fn parse_positions(&self, mut positions: Value, optional_args: &[Value]) -> Value {
5067 let mut symbols = get_arg(optional_args, 0, Value::Null);
5068 let mut params = get_arg(optional_args, 1, Value::Map({
5069 let mut m = indexmap::IndexMap::new();
5070 m
5071}));
5072 let mut symbolsNormalized: Value = self.market_symbols(&[symbols]);
5073 let mut positionsArray: Value = self.to_array(positions);
5074 let mut result: Vec<Value> = Vec::new();
5075 {
5076 let mut i: i64 = 0;
5077 let mut __for_first_123: bool = true;
5078 while { if !__for_first_123 { i += 1; } __for_first_123 = false; i < (positionsArray.len() as i64) } {
5079 let mut position: Value = self.extend(<Self as crate::exchange_generated::ExchangeBase>::parse_position(self, positionsArray.as_array().map(Vec::as_slice).unwrap_or_default().get(i as usize).cloned().unwrap_or(Value::Null), &[]), &[params.clone()]);
5080 result.push(position);
5081 }
5082 }
5083 return self.filter_by_array_positions(Value::from(result), Value::Str("symbol".into()), &[symbolsNormalized]);
5084
5085 Value::Null
5086}
5087
5088 fn parse_adl_rank(&self, mut info: Value, optional_args: &[Value]) -> Value {
5089 { 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; } }
5091
5092 let mut market = get_arg(optional_args, 0, Value::Null);
5093 if (info == Value::Null) {
5094 panic!("{}", crate::exchange_errors::not_supported(format!("{}{}", self.id.clone(), Value::Str(" parseADLRank() is not supported yet".into()))));
5095 }
5096 panic!("{}", crate::exchange_errors::not_supported(format!("{}{}", self.id.clone(), Value::Str(" parseADLRank() is not supported yet".into()))));
5097
5098 Value::Null
5099}
5100
5101 fn parse_adl_ranks(&self, mut ranks: Value, optional_args: &[Value]) -> Value {
5102 let mut symbols = get_arg(optional_args, 0, Value::Null);
5103 let mut params = get_arg(optional_args, 1, Value::Map({
5104 let mut m = indexmap::IndexMap::new();
5105 m
5106}));
5107 let mut symbolsNormalized: Value = self.market_symbols(&[symbols]);
5108 let mut ranksArray: Value = self.to_array(ranks);
5109 let mut result: Vec<Value> = Vec::new();
5110 {
5111 let mut i: i64 = 0;
5112 let mut __for_first_124: bool = true;
5113 while { if !__for_first_124 { i += 1; } __for_first_124 = false; i < (ranksArray.len() as i64) } {
5114 let mut rank: Value = self.extend(<Self as crate::exchange_generated::ExchangeBase>::parse_adl_rank(self, ranksArray.as_array().map(Vec::as_slice).unwrap_or_default().get(i as usize).cloned().unwrap_or(Value::Null), &[]), &[params.clone()]);
5115 result.push(rank);
5116 }
5117 }
5118 return self.filter_by_array_positions(Value::from(result), Value::Str("symbol".into()), &[symbolsNormalized]);
5119
5120 Value::Null
5121}
5122
5123 fn parse_accounts(&self, mut accounts: Value, optional_args: &[Value]) -> Value {
5124 let mut params = get_arg(optional_args, 0, Value::Map({
5125 let mut m = indexmap::IndexMap::new();
5126 m
5127}));
5128 let mut accountsArray: Value = self.to_array(accounts);
5129 let mut result: Vec<Value> = Vec::new();
5130 {
5131 let mut i: i64 = 0;
5132 let mut __for_first_125: bool = true;
5133 while { if !__for_first_125 { i += 1; } __for_first_125 = false; i < (accountsArray.len() as i64) } {
5134 let mut account: Value = self.extend(<Self as crate::exchange_generated::ExchangeBase>::parse_account(self, accountsArray.as_array().map(Vec::as_slice).unwrap_or_default().get(i as usize).cloned().unwrap_or(Value::Null)), &[params.clone()]);
5135 result.push(account);
5136 }
5137 }
5138 return Value::from(result);
5139
5140 Value::Null
5141}
5142
5143 fn parse_trades_helper(&self, mut isWs: Value, mut trades: Value, optional_args: &[Value]) -> Value {
5144 let mut market = get_arg(optional_args, 0, Value::Null);
5145 let mut since = get_arg(optional_args, 1, Value::Null);
5146 let mut limit = get_arg(optional_args, 2, Value::Null);
5147 let mut params = get_arg(optional_args, 3, Value::Map({
5148 let mut m = indexmap::IndexMap::new();
5149 m
5150}));
5151 let mut tradesArray: Value = self.to_array(trades);
5152 let mut result: Value = Value::from(vec![]);
5153 {
5154 let mut i: i64 = 0;
5155 let mut __for_first_126: bool = true;
5156 while { if !__for_first_126 { i += 1; } __for_first_126 = false; i < (tradesArray.len() as i64) } {
5157 let mut parsed: Value = Value::Null;
5158 if isWs.as_bool() == Some(true) {
5159 parsed = self.parse_ws_trade(tradesArray.as_array().map(Vec::as_slice).unwrap_or_default().get(i as usize).cloned().unwrap_or(Value::Null), &[market.clone()]);
5160 } else {
5161 parsed = <Self as crate::exchange_generated::ExchangeBase>::parse_trade(self, tradesArray.as_array().map(Vec::as_slice).unwrap_or_default().get(i as usize).cloned().unwrap_or(Value::Null), &[market.clone()]);
5162 }
5163 let mut trade: Value = self.extend(parsed, &[params.clone()]);
5164 if let Value::Arr(__a) = &mut result { std::sync::Arc::make_mut(__a).push(trade); }
5165 }
5166 }
5167 result = self.sort_by2(result.clone(), Value::Str("timestamp".into()), Value::Str("id".into()), &[]);
5168 let mut symbol: Option<String> = self.safe_string_k_opt(market, "symbol", &[]);
5169 return self.filter_by_symbol_since_limit(result, &[symbol.map(Value::from).unwrap_or(Value::Null), since, limit]);
5170
5171 Value::Null
5172}
5173
5174 fn parse_trades(&self, mut trades: Value, optional_args: &[Value]) -> Value {
5175 let mut market = get_arg(optional_args, 0, Value::Null);
5176 let mut since = get_arg(optional_args, 1, Value::Null);
5177 let mut limit = get_arg(optional_args, 2, Value::Null);
5178 let mut params = get_arg(optional_args, 3, Value::Map({
5179 let mut m = indexmap::IndexMap::new();
5180 m
5181}));
5182 return self.parse_trades_helper(Value::Bool(false), trades, &[market, since, limit, params]);
5183
5184 Value::Null
5185}
5186
5187 fn parse_ws_trades(&self, mut trades: Value, optional_args: &[Value]) -> Value {
5188 let mut market = get_arg(optional_args, 0, Value::Null);
5189 let mut since = get_arg(optional_args, 1, Value::Null);
5190 let mut limit = get_arg(optional_args, 2, Value::Null);
5191 let mut params = get_arg(optional_args, 3, Value::Map({
5192 let mut m = indexmap::IndexMap::new();
5193 m
5194}));
5195 return self.parse_trades_helper(Value::Bool(true), trades, &[market, since, limit, params]);
5196
5197 Value::Null
5198}
5199
5200 fn parse_transactions(&self, mut transactions: Value, optional_args: &[Value]) -> Value {
5201 let mut currency = get_arg(optional_args, 0, Value::Null);
5202 let mut since = get_arg(optional_args, 1, Value::Null);
5203 let mut limit = get_arg(optional_args, 2, Value::Null);
5204 let mut params = get_arg(optional_args, 3, Value::Map({
5205 let mut m = indexmap::IndexMap::new();
5206 m
5207}));
5208 let mut transactionsArray: Value = self.to_array(transactions);
5209 let mut result: Value = Value::from(vec![]);
5210 {
5211 let mut i: i64 = 0;
5212 let mut __for_first_127: bool = true;
5213 while { if !__for_first_127 { i += 1; } __for_first_127 = false; i < (transactionsArray.len() as i64) } {
5214 let mut transaction: Value = self.extend(<Self as crate::exchange_generated::ExchangeBase>::parse_transaction(self, transactionsArray.as_array().map(Vec::as_slice).unwrap_or_default().get(i as usize).cloned().unwrap_or(Value::Null), &[currency.clone()]), &[params.clone()]);
5215 if let Value::Arr(__a) = &mut result { std::sync::Arc::make_mut(__a).push(transaction); }
5216 }
5217 }
5218 result = self.sort_by(result.clone(), Value::Str("timestamp".into()), &[]);
5219 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 });
5220 return self.filter_by_currency_since_limit(result, &[code, since, limit]);
5221
5222 Value::Null
5223}
5224
5225 fn parse_transfers(&self, mut transfers: Value, optional_args: &[Value]) -> Value {
5226 let mut currency = get_arg(optional_args, 0, Value::Null);
5227 let mut since = get_arg(optional_args, 1, Value::Null);
5228 let mut limit = get_arg(optional_args, 2, Value::Null);
5229 let mut params = get_arg(optional_args, 3, Value::Map({
5230 let mut m = indexmap::IndexMap::new();
5231 m
5232}));
5233 let mut transfersArray: Value = self.to_array(transfers);
5234 let mut result: Value = Value::from(vec![]);
5235 {
5236 let mut i: i64 = 0;
5237 let mut __for_first_128: bool = true;
5238 while { if !__for_first_128 { i += 1; } __for_first_128 = false; i < (transfersArray.len() as i64) } {
5239 let mut transfer: Value = self.extend(<Self as crate::exchange_generated::ExchangeBase>::parse_transfer(self, transfersArray.as_array().map(Vec::as_slice).unwrap_or_default().get(i as usize).cloned().unwrap_or(Value::Null), &[currency.clone()]), &[params.clone()]);
5240 if let Value::Arr(__a) = &mut result { std::sync::Arc::make_mut(__a).push(transfer); }
5241 }
5242 }
5243 result = self.sort_by(result.clone(), Value::Str("timestamp".into()), &[]);
5244 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 });
5245 return self.filter_by_currency_since_limit(result, &[code, since, limit]);
5246
5247 Value::Null
5248}
5249
5250 fn parse_ledger(&self, mut data: Value, optional_args: &[Value]) -> Value {
5251 let mut currency = get_arg(optional_args, 0, Value::Null);
5252 let mut since = get_arg(optional_args, 1, Value::Null);
5253 let mut limit = get_arg(optional_args, 2, Value::Null);
5254 let mut params = get_arg(optional_args, 3, Value::Map({
5255 let mut m = indexmap::IndexMap::new();
5256 m
5257}));
5258 let mut result: Value = Value::from(vec![]);
5259 let mut arrayData: Value = self.to_array(data);
5260 {
5261 let mut i: i64 = 0;
5262 let mut __for_first_130: bool = true;
5263 while { if !__for_first_130 { i += 1; } __for_first_130 = false; i < (arrayData.len() as i64) } {
5264 let mut itemOrItems: Value = <Self as crate::exchange_generated::ExchangeBase>::parse_ledger_entry(self, arrayData.as_array().map(Vec::as_slice).unwrap_or_default().get(i as usize).cloned().unwrap_or(Value::Null), &[currency.clone()]);
5265 if (matches!(&itemOrItems, Value::Arr(_))) {
5266 {
5267 let mut j: Value = Value::Int(0);
5268 let mut __for_first_129: bool = true;
5269 while { if !__for_first_129 { if let Value::Int(n) = &mut j { *n += 1; } } __for_first_129 = false; j.as_f64().unwrap_or(f64::NAN) < get_array_length(&itemOrItems).as_f64().unwrap_or(f64::NAN) } {
5270 if let Value::Arr(__a) = &mut result { std::sync::Arc::make_mut(__a).push(self.extend(get_value(&itemOrItems, &j), &[params.clone()])); }
5271 }
5272 }
5273 } else {
5274 if let Value::Arr(__a) = &mut result { std::sync::Arc::make_mut(__a).push(self.extend(itemOrItems, &[params.clone()])); }
5275 }
5276 }
5277 }
5278 result = self.sort_by(result.clone(), Value::Str("timestamp".into()), &[]);
5279 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 });
5280 return self.filter_by_currency_since_limit(result, &[code, since, limit]);
5281
5282 Value::Null
5283}
5284
5285 fn nonce(&self) -> Value {
5286 { let __v = crate::exchange::DerivedExchange::nonce(self, ); if !matches!(__v, crate::Value::Null) { return __v; } }
5288
5289 return self.seconds();
5290
5291 Value::Null
5292}
5293
5294fn incrementing_nonce(&mut self) -> Value {
5306 let mut currentNonce: Value = <Self as crate::exchange_generated::ExchangeBase>::nonce(self, );
5307 self.lock_last_nonce(&[]);
5308 let mut lastNonce: Value = self.safe_integer_k(self.options.clone(), "lastNonce", &[Value::Int(0)]);
5309 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),
5310 Value::Int(y)) => Value::Float(*x + *y as f64), (Value::Float(x), Value::Float(y)) => Value::Float(x + y), _ => Value::Null }) });
5311 if let Value::Dict(__d) = &mut self.options { std::sync::Arc::make_mut(__d).insert("lastNonce".into(), result.clone()); }
5312 self.unlock_last_nonce(&[]);
5313 return result;
5314
5315 Value::Null
5316}
5317
5318 fn set_headers(&self, mut headers: Value) -> Value {
5319 return headers;
5320
5321 Value::Null
5322}
5323
5324 fn currency_id(&self, mut code: Value) -> Value {
5325 if (code == Value::Null) {
5326 return code;
5327 }
5328 let mut currencyById: Value = self.safe_dict(self.currencies.clone(), code.clone(), &[]);
5329 if (currencyById != Value::Null) {
5330 return currencyById.as_map().and_then(|__m| __m.get("id")).cloned().unwrap_or(Value::Null);
5331 }
5332 let mut currency: Value = self.safe_currency(code.clone(), &[]);
5333 if (currency != Value::Null) {
5334 return currency.as_map().and_then(|__m| __m.get("id")).cloned().unwrap_or(Value::Null);
5335 }
5336 return code;
5337
5338 Value::Null
5339}
5340
5341 fn market_id(&self, mut symbol: Value) -> Value {
5342 let mut market: Value = <Self as crate::exchange_generated::ExchangeBase>::market(self, symbol.clone());
5343 if (market != Value::Null) {
5344 return market.as_map().and_then(|__m| __m.get("id")).cloned().unwrap_or(Value::Null);
5345 }
5346 return symbol;
5347
5348 Value::Null
5349}
5350
5351 fn symbol(&self, mut symbol: Value) -> Value {
5352 if (symbol == Value::Null) {
5353 panic!("{}", crate::exchange_errors::arguments_required(format!("{}{}", self.id.clone(), Value::Str(" symbol() requires a symbol argument".into()))));
5354 }
5355 let mut market: Value = <Self as crate::exchange_generated::ExchangeBase>::market(self, symbol.clone());
5356 return self.safe_string_k(market, "symbol", &[symbol]);
5357
5358 Value::Null
5359}
5360
5361fn handle_param_string(&self, mut params: Value, mut paramName: Value, optional_args: &[Value]) -> Value {
5364 let mut defaultValue = get_arg(optional_args, 0, Value::Null);
5365 let mut value: Value = self.safe_string(params.clone(), paramName.clone(), &[defaultValue]);
5366 let mut paramsOmitted: Value = params.clone();
5367 if (value != Value::Null) {
5368 paramsOmitted = self.omit(params, paramName, &[]);
5369 }
5370 return Value::from(vec![value, paramsOmitted]);
5371
5372 Value::Null
5373}
5374
5375fn handle_param_string2(&self, mut params: Value, mut paramName1: Value, mut paramName2: Value, optional_args: &[Value]) -> Value {
5378 let mut defaultValue = get_arg(optional_args, 0, Value::Null);
5379 let mut value: Value = self.safe_string2(params.clone(), paramName1.clone(), paramName2.clone(), &[defaultValue]);
5380 let mut paramsOmitted: Value = params.clone();
5381 if (value != Value::Null) {
5382 paramsOmitted = self.omit(params, Value::from(vec![paramName1, paramName2]), &[]);
5383 }
5384 return Value::from(vec![value, paramsOmitted]);
5385
5386 Value::Null
5387}
5388
5389 fn handle_param_integer(&self, mut params: Value, mut paramName: Value, optional_args: &[Value]) -> Value {
5390 let mut defaultValue = get_arg(optional_args, 0, Value::Null);
5391 let mut value: Value = self.safe_integer(params.clone(), paramName.clone(), &[defaultValue]);
5392 let mut paramsOmitted: Value = params.clone();
5393 if (value != Value::Null) {
5394 paramsOmitted = self.omit(params, paramName, &[]);
5395 }
5396 return Value::from(vec![value, paramsOmitted]);
5397
5398 Value::Null
5399}
5400
5401 fn handle_param_integer2(&self, mut params: Value, mut paramName1: Value, mut paramName2: Value, optional_args: &[Value]) -> Value {
5402 let mut defaultValue = get_arg(optional_args, 0, Value::Null);
5403 let mut value: Value = self.safe_integer2(params.clone(), paramName1.clone(), paramName2.clone(), &[defaultValue]);
5404 let mut paramsOmitted: Value = params.clone();
5405 if (value != Value::Null) {
5406 paramsOmitted = self.omit(params, Value::from(vec![paramName1, paramName2]), &[]);
5407 }
5408 return Value::from(vec![value, paramsOmitted]);
5409
5410 Value::Null
5411}
5412
5413 fn handle_param_bool(&self, mut params: Value, mut paramName: Value, optional_args: &[Value]) -> Value {
5414 let mut defaultValue = get_arg(optional_args, 0, Value::Null);
5415 let mut value: Value = self.safe_bool(params.clone(), paramName.clone(), &[defaultValue]);
5416 let mut paramsOmitted: Value = params.clone();
5417 if (value != Value::Null) {
5418 paramsOmitted = self.omit(params, paramName, &[]);
5419 }
5420 return Value::from(vec![value, paramsOmitted]);
5421
5422 Value::Null
5423}
5424
5425 fn handle_param_bool2(&self, mut params: Value, mut paramName1: Value, mut paramName2: Value, optional_args: &[Value]) -> Value {
5426 let mut defaultValue = get_arg(optional_args, 0, Value::Null);
5427 let mut value: Value = self.safe_bool2(params.clone(), paramName1.clone(), paramName2.clone(), &[defaultValue]);
5428 let mut paramsOmitted: Value = params.clone();
5429 if (value != Value::Null) {
5430 paramsOmitted = self.omit(params, Value::from(vec![paramName1, paramName2]), &[]);
5431 }
5432 return Value::from(vec![value, paramsOmitted]);
5433
5434 Value::Null
5435}
5436
5437 fn resolve_path(&self, mut path: Value, mut params: Value) -> Value {
5438 return Value::from(vec![self.implode_params(path.clone(), params.clone()), self.omit(params, self.extract_params(path), &[])]);
5439
5440 Value::Null
5441}
5442
5443 fn get_list_from_object_values(&self, mut objects: Value, mut key: Value) -> Value {
5444 let mut newArray: Value = self.to_array(objects);
5445 let mut results: Vec<Value> = Vec::new();
5446 {
5447 let mut i: i64 = 0;
5448 let mut __for_first_131: bool = true;
5449 while { if !__for_first_131 { i += 1; } __for_first_131 = false; i < (newArray.len() as i64) } {
5450 results.push(get_value(&newArray.as_array().map(Vec::as_slice).unwrap_or_default().get(i as usize).cloned().unwrap_or(Value::Null), &key));
5451 }
5452 }
5453 return Value::from(results);
5454
5455 Value::Null
5456}
5457
5458 fn get_symbols_for_market_type(&self, optional_args: &[Value]) -> Value {
5459 let mut marketType = get_arg(optional_args, 0, Value::Null);
5460 let mut subType = get_arg(optional_args, 1, Value::Null);
5461 let mut symbolWithActiveStatus = get_arg(optional_args, 2, Value::Bool(true));
5462 let mut symbolWithUnknownStatus = get_arg(optional_args, 3, Value::Bool(true));
5463 let mut filteredMarkets: Value = self.markets.clone();
5464 if (marketType != Value::Null) {
5465 filteredMarkets = self.filter_by(filteredMarkets.clone(), Value::Str("type".into()), marketType, &[]);
5466 }
5467 if (subType != Value::Null) {
5468 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())])]);
5469 filteredMarkets = self.filter_by(filteredMarkets.clone(), Value::Str("subType".into()), subType, &[]);
5470 }
5471 let mut activeStatuses: Vec<Value> = Vec::new();
5472 if symbolWithActiveStatus.as_bool() == Some(true) {
5473 activeStatuses.push(Value::Bool(true));
5474 }
5475 if symbolWithUnknownStatus.as_bool() == Some(true) {
5476 activeStatuses.push(Value::Null);
5477 }
5478 filteredMarkets = self.filter_by_array(filteredMarkets.clone(), Value::Str("active".into()), &[Value::from(activeStatuses), Value::Bool(false)]);
5479 return self.get_list_from_object_values(filteredMarkets, Value::Str("symbol".into()));
5480
5481 Value::Null
5482}
5483
5484 fn filter_by_array(&self, mut objects: Value, mut key: Value, optional_args: &[Value]) -> Value {
5485 let mut values = get_arg(optional_args, 0, Value::Null);
5486 let mut indexed = get_arg(optional_args, 1, Value::Bool(true));
5487 let mut objectsValue: Value = self.to_array(objects);
5488 if (values == Value::Null) || (values == Value::Null) || ((match &(values) { Value::Bool(__x) => *__x == false, __v => matches!((match __v { Value::Int(__n) => Some(*__n as f64), Value::Float(__f) => Some(*__f), Value::Str(__s) => __s.parse::<f64>().ok(), Value::Bool(__b) => Some(if *__b { 1.0 } else { 0.0 }), _ => None }),
5490 Some(__y) if __y == 0.0) })) || ((match &(values) { Value::Int(__x) => *__x == 0, __v => matches!((match __v { Value::Int(__n) => Some(*__n as f64), Value::Float(__f) => Some(*__f), Value::Str(__s) => __s.parse::<f64>().ok(), Value::Bool(__b) => Some(if *__b { 1.0 } else { 0.0 }), _ => None }), Some(__y) if __y == 0.0) })) || (values.as_str() == Some("")) {
5491 if indexed.as_bool() == Some(true) {
5493 return self.index_by(objectsValue.clone(), key.clone());
5494 } else {
5495 return objectsValue;
5496 }
5497 }
5498 let mut results: Vec<Value> = Vec::new();
5499 {
5500 let mut i: i64 = 0;
5501 let mut __for_first_132: bool = true;
5502 while { if !__for_first_132 { i += 1; } __for_first_132 = false; i < (objectsValue.len() as i64) } {
5503 if self.in_array(get_value(&objectsValue.as_array().map(Vec::as_slice).unwrap_or_default().get(i as usize).cloned().unwrap_or(Value::Null), &key), values.clone()).as_bool() == Some(true) {
5504 results.push(objectsValue.as_array().map(Vec::as_slice).unwrap_or_default().get(i as usize).cloned().unwrap_or(Value::Null));
5505 }
5506 }
5507 }
5508 if indexed.as_bool() == Some(true) {
5510 return self.index_by(Value::from(results), key);
5511 }
5512 return Value::from(results);
5513
5514 Value::Null
5515}
5516
5517 fn filter_out_by_array(&self, mut objects: Value, mut key: Value, optional_args: &[Value]) -> Value {
5518 let mut values = get_arg(optional_args, 0, Value::Null);
5519 let mut indexed = get_arg(optional_args, 1, Value::Bool(true));
5520 let mut objectsValue: Value = self.to_array(objects);
5521 if (values == Value::Null) || (values == Value::Null) || ((match &(values) { Value::Bool(__x) => *__x == false, __v => matches!((match __v { Value::Int(__n) => Some(*__n as f64), Value::Float(__f) => Some(*__f), Value::Str(__s) => __s.parse::<f64>().ok(), Value::Bool(__b) => Some(if *__b { 1.0 } else { 0.0 }), _ => None }),
5523 Some(__y) if __y == 0.0) })) || ((match &(values) { Value::Int(__x) => *__x == 0, __v => matches!((match __v { Value::Int(__n) => Some(*__n as f64), Value::Float(__f) => Some(*__f), Value::Str(__s) => __s.parse::<f64>().ok(), Value::Bool(__b) => Some(if *__b { 1.0 } else { 0.0 }), _ => None }), Some(__y) if __y == 0.0) })) || (values.as_str() == Some("")) {
5524 if indexed.as_bool() == Some(true) {
5526 return self.index_by(objectsValue.clone(), key.clone());
5527 } else {
5528 return objectsValue;
5529 }
5530 }
5531 let mut results: Vec<Value> = Vec::new();
5532 {
5533 let mut i: i64 = 0;
5534 let mut __for_first_133: bool = true;
5535 while { if !__for_first_133 { i += 1; } __for_first_133 = false; i < (objectsValue.len() as i64) } {
5536 if !(self.in_array(get_value(&objectsValue.as_array().map(Vec::as_slice).unwrap_or_default().get(i as usize).cloned().unwrap_or(Value::Null), &key), values.clone()).as_bool() == Some(true)) {
5537 results.push(objectsValue.as_array().map(Vec::as_slice).unwrap_or_default().get(i as usize).cloned().unwrap_or(Value::Null));
5538 }
5539 }
5540 }
5541 if indexed.as_bool() == Some(true) {
5543 return self.index_by(Value::from(results), key);
5544 }
5545 return Value::from(results);
5546
5547 Value::Null
5548}
5549
5550 fn fetch2(&mut self, mut path: Value, optional_args: &[Value]) -> impl ::std::future::Future<Output = Value> + Send { async move {
5551 let mut api = get_arg(optional_args, 0, Value::from(vec![Value::Str("public".into())]));
5552 let mut method = get_arg(optional_args, 1, Value::Str("GET".into()));
5553 let mut params = get_arg(optional_args, 2, Value::Map({
5554 let mut m = indexmap::IndexMap::new();
5555 m
5556}));
5557 let mut config = get_arg(optional_args, 3, Value::Map({
5558 let mut m = indexmap::IndexMap::new();
5559 m
5560}));
5561 if self.enableRateLimit.as_bool() == Some(true) {
5562 let mut cost: Value = self.calculate_rate_limiter_cost(api.clone(), method.clone(), path.clone(), params.clone(), &[config]);
5563 self.throttle(&[cost]).await;
5564 }
5565 let mut retries: Value = Value::Int(0);
5566 let mut requestParams: Value = params;
5568 let retriesMaxRetriesOnFailureparamsMaxRetriesOnFailureVariable: Vec<Value> = self.handle_option_integer_and_params(requestParams, path.clone(), Value::Str("maxRetriesOnFailure".into()), &[retries]).as_array().cloned().unwrap_or_default();
5569 let mut retriesMaxRetriesOnFailure: Value = retriesMaxRetriesOnFailureparamsMaxRetriesOnFailureVariable.get(0).cloned().unwrap_or(Value::Null);
5570 let mut paramsMaxRetriesOnFailure: Value = retriesMaxRetriesOnFailureparamsMaxRetriesOnFailureVariable.get(1).cloned().unwrap_or(Value::Null);
5571 let mut retryDelay: Value = Value::Int(0);
5572 let retryDelayMaxRetriesOnFailureDelayparamsMaxRetriesOnFailureDelayVariable: Vec<Value> = self.handle_option_integer_and_params(paramsMaxRetriesOnFailure, path.clone(), Value::Str("maxRetriesOnFailureDelay".into()), &[retryDelay]).as_array().cloned().unwrap_or_default();
5573 let mut retryDelayMaxRetriesOnFailureDelay: Value = retryDelayMaxRetriesOnFailureDelayparamsMaxRetriesOnFailureDelayVariable.get(0).cloned().unwrap_or(Value::Null);
5574 let mut paramsMaxRetriesOnFailureDelay: Value = retryDelayMaxRetriesOnFailureDelayparamsMaxRetriesOnFailureDelayVariable.get(1).cloned().unwrap_or(Value::Null);
5575 let mut fetchDataCacheEnabled: bool = self.fetchHistoryCacheSize.as_f64().unwrap_or(f64::NAN) > ((0i64) as f64);
5576 {
5577 let mut i: Value = Value::Int(0);
5578 let mut __for_first_134: bool = true;
5579 while { if !__for_first_134 { if let Value::Int(n) = &mut i { *n += 1; } } __for_first_134 = false; i.as_f64().unwrap_or(f64::NAN) < (match (&(retriesMaxRetriesOnFailure), &(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),
5580 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) } {
5581 let mut fetchData: Value = Value::Null;
5582 if fetchDataCacheEnabled {
5583 fetchData = Value::Map({
5584 let mut m = indexmap::IndexMap::new();
5585 m.insert("request".to_string(), Value::Null);
5586 m.insert("response".to_string(), Value::Map({
5587 let mut m = indexmap::IndexMap::new();
5588 m.insert("body".to_string(), Value::Null);
5589 m
5590}));
5591 m.insert("error".to_string(), Value::Null);
5592 m
5593 });
5594 }
5595 let _try_result = futures::FutureExt::catch_unwind(std::panic::AssertUnwindSafe(async {
5596 self.set_last_rest_request_timestamp();
5597 let mut request: indexmap::IndexMap<String, Value> = <Self as crate::exchange_generated::ExchangeBase>::sign(self, path.clone(), &[api.clone(), method.clone(), paramsMaxRetriesOnFailureDelay.clone()]).as_map().cloned().unwrap_or_default();
5598 if (fetchData != Value::Null) {
5599 if let Value::Dict(__d) = &mut fetchData { std::sync::Arc::make_mut(__d).insert("request".into(), Value::Map(request.clone())); }
5600 }
5601 self.set_last_request(Value::Map(request.clone()));
5602 let mut response: Value = self.fetch(request.get("url").cloned().unwrap_or(Value::Null), &[request.get("method").cloned().unwrap_or(Value::Null), request.get("headers").cloned().unwrap_or(Value::Null), request.get("body").cloned().unwrap_or(Value::Null)]).await;
5603 if (fetchData != Value::Null) {
5604 if let Value::Dict(__rda) = &mut fetchData { if let Value::Dict(__rdb) = std::sync::Arc::make_mut(__rda).entry("response".to_string()).or_insert(Value::Null) { std::sync::Arc::make_mut(__rdb).insert("body".to_string(), response.clone()); } }
5605 self.add_fetch_cache(fetchData.clone());
5606 }
5607 return response;
5608 #[allow(unreachable_code)] { Value::Null }})).await;
5609match _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);
5610 if (fetchData != Value::Null) {
5611 if let Value::Dict(__d) = &mut fetchData { std::sync::Arc::make_mut(__d).insert("error".into(), e.clone()); }
5612 self.add_fetch_cache(fetchData);
5613 }
5614 if is_instance(&e, &Value::Str("OperationFailed".into())) {
5615 if i.as_f64().unwrap_or(f64::NAN) < retriesMaxRetriesOnFailure.as_f64().unwrap_or(f64::NAN) {
5616 if self.verbose.as_bool() == Some(true) {
5617 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 });
5618 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()), Value::Str(format!("{}",
5619 index).into())).into()), Value::Str(" of ".into())).into()), Value::Str(format!("{}", retriesMaxRetriesOnFailure).into())).into()), Value::Str("...".into())).into()));
5620 }
5621 if (retryDelayMaxRetriesOnFailureDelay != Value::Null) && (retryDelayMaxRetriesOnFailureDelay.as_f64() != Some(0.0)) {
5622 self.sleep(retryDelayMaxRetriesOnFailureDelay.clone()).await;
5623 }
5624 } else {
5625 panic!("{}", e);
5626 }
5627 } else {
5628 panic!("{}", e);
5629 }
5630 } }
5631 }
5632 }
5633 return Value::Null;
5634
5635 Value::Null
5636} }
5637
5638 fn request(&mut self, mut path: Value, optional_args: &[Value]) -> impl ::std::future::Future<Output = Value> + Send { async move {
5639 let mut api = get_arg(optional_args, 0, Value::from(vec![Value::Str("public".into())]));
5640 let mut method = get_arg(optional_args, 1, Value::Str("GET".into()));
5641 let mut params = get_arg(optional_args, 2, Value::Map({
5642 let mut m = indexmap::IndexMap::new();
5643 m
5644}));
5645 let mut config = get_arg(optional_args, 3, Value::Map({
5646 let mut m = indexmap::IndexMap::new();
5647 m
5648}));
5649 return self.fetch2(path, &[api, method, params, config]).await;
5650
5651 Value::Null
5652} }
5653
5654 fn load_accounts(&mut self, optional_args: &[Value]) -> impl ::std::future::Future<Output = Value> + Send { async move {
5655 let mut reload = get_arg(optional_args, 0, Value::Bool(false));
5656 let mut params = get_arg(optional_args, 1, Value::Map({
5657 let mut m = indexmap::IndexMap::new();
5658 m
5659}));
5660 if reload.as_bool() == Some(true) {
5661 { let __t = self.fetch_accounts(&[params.clone()]).await; self.accounts = __t; }
5662 } else {
5663 if (self.accounts.clone() != Value::Null) {
5664 return self.accounts.clone();
5665 } else {
5666 { let __t = self.fetch_accounts(&[params]).await; self.accounts = __t; }
5667 }
5668 }
5669 { let __t = self.index_by(self.accounts.clone(), Value::Str("id".into())); self.accountsById = __t; }
5670 return self.accounts.clone();
5671
5672 Value::Null
5673} }
5674
5675 fn build_ohlcvc(&self, mut trades: Value, optional_args: &[Value]) -> Value {
5676 let mut timeframe = get_arg(optional_args, 0, Value::Str("1m".into()));
5677 let mut since = get_arg(optional_args, 1, Value::Int(0));
5678 let mut limit = get_arg(optional_args, 2, Value::Int(2147483647));
5679 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 });
5682 let mut ohlcvs: Value = Value::from(vec![]);
5683 let mut i_timestamp: Value = Value::Int(0);
5684 let mut i_high: Value = Value::Int(2);
5686 let mut i_low: Value = Value::Int(3);
5687 let mut i_close: Value = Value::Int(4);
5688 let mut i_volume: Value = Value::Int(5);
5689 let mut i_count: Value = Value::Int(6);
5690 let mut tradesLength: Value = Value::Int(trades.len() as i64);
5691 let mut oldest: Value = crate::runtime::Math::min(&tradesLength, &limit);
5692 let mut options: Value = self.safe_dict_k(self.options.clone(), "buildOHLCVC", &[Value::Map({
5693 let mut m = indexmap::IndexMap::new();
5694 m
5695})]);
5696 let mut skipZeroPrices: bool = self.safe_bool_k_opt(options, "skipZeroPrices", &[Value::Bool(true)]).unwrap_or(true);
5697 {
5698 let mut i: Value = Value::Int(0);
5699 let mut __for_first_135: bool = true;
5700 while { if !__for_first_135 { if let Value::Int(n) = &mut i { *n += 1; } } __for_first_135 = false; i.as_f64().unwrap_or(f64::NAN) < oldest.as_f64().unwrap_or(f64::NAN) } {
5701 let mut trade: Value = self.safe_dict(trades.clone(), i.clone(), &[Value::Map({
5702 let mut m = indexmap::IndexMap::new();
5703 m
5704})]);
5705 let mut ts: Value = self.safe_integer_k(trade.clone(), "timestamp", &[]);
5706 let mut price: Value = trade.as_map().and_then(|__m| __m.get("price")).cloned().unwrap_or(Value::Null);
5707 if (ts == Value::Null) || (price == Value::Null) {
5708 continue;
5709 }
5710 if ts.as_f64().unwrap_or(f64::NAN) < since.as_f64().unwrap_or(f64::NAN) {
5711 continue;
5712 }
5713 if (ts == Value::Null) {
5714 panic!("{}", crate::exchange_errors::exchange_error(format!("{}{}", self.id.clone(), Value::Str(" buildOHLCVC() missing ts".into()))));
5715 }
5716 let mut openingTime: Value = (match (&(((match ((ts).as_f64(), (ms).as_f64()) { (Some(x), Some(y)) if y != 0.0 => Value::Float(x / y), _ => Value::Null })).as_f64().map(|__x| Value::Float(__x.floor())).unwrap_or(Value::Null)), &(ms)) { (Value::Int(x), Value::Int(y)) => Value::Int(x * y), (Value::Int(x),
5717 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 }); if openingTime.as_f64().unwrap_or(f64::NAN) < since.as_f64().unwrap_or(f64::NAN) {
5719 continue;
5720 }
5721 let mut ohlcv_length: Value = Value::Int(ohlcvs.len() as i64);
5722 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 });
5723 if (price == Value::Null) {
5724 panic!("{}", crate::exchange_errors::arguments_required(format!("{}{}", self.id.clone(), Value::Str(" buildOHLCVC() requires a price argument".into()))));
5725 }
5726 if skipZeroPrices && !(price.as_f64().unwrap_or(f64::NAN) > ((0i64) as f64)) && !(price.as_f64().unwrap_or(f64::NAN) < ((0i64) as f64)) {
5727 continue;
5728 }
5729 let mut isNewCandle: bool = candle.as_f64() == Value::Int(-1).as_f64();
5730 if !(isNewCandle) {
5731 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);
5732 if (candleTimestamp == Value::Null) {
5733 panic!("{}", crate::exchange_errors::exchange_error(format!("{}{}", self.id.clone(), Value::Str(" buildOHLCVC() missing candle timestamp".into()))));
5734 }
5735 isNewCandle = (match (&(openingTime), &(self.sum(&[candleTimestamp, ms.clone()]))) { (__a, __b) => (match ((match __a { Value::Int(__n) => Some(*__n as f64), Value::Float(__f) => Some(*__f), Value::Str(__s) => __s.parse::<f64>().ok(), Value::Bool(__b) => Some(if *__b { 1.0 } else { 0.0 }), _ => None }),
5736 (match __b { Value::Int(__n) => Some(*__n as f64), Value::Float(__f) => Some(*__f), Value::Str(__s) => __s.parse::<f64>().ok(), Value::Bool(__b) => Some(if *__b { 1.0 } else { 0.0 }), _ => None })) { (Some(__x), Some(__y)) => __x > __y, _ => matches!((__a, __b), (Value::Str(__x), Value::Str(__y)) if __x > __y) }) || (match (__a,
5737 __b) { (Value::Null, Value::Null) => true, (Value::Bool(__x), Value::Bool(__y)) => __x == __y, (Value::Str(__x), Value::Str(__y)) => __x == __y, (Value::Int(__x), Value::Int(__y)) => __x == __y, (Value::Float(__x), Value::Float(__y)) => __x == __y, _ => matches!(((match __a { Value::Int(__n) => Some(*__n as f64),
5738 Value::Float(__f) => Some(*__f), Value::Str(__s) => __s.parse::<f64>().ok(), Value::Bool(__b) => Some(if *__b { 1.0 } else { 0.0 }), _ => None }), (match __b { Value::Int(__n) => Some(*__n as f64), Value::Float(__f) => Some(*__f), Value::Str(__s) => __s.parse::<f64>().ok(), Value::Bool(__b) => Some(if *__b { 1.0 } else { 0.0 }),
5739 _ => None })), (Some(__x), Some(__y)) if __x == __y) }) });
5740 }
5741 if isNewCandle {
5742 if let Value::Arr(__a) = &mut ohlcvs { std::sync::Arc::make_mut(__a).push(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)])); }
5744 } else {
5745 let mut prevCandle: Value = self.safe_value(ohlcvs.clone(), candle.clone(), &[]);
5747 let mut prevHigh: Value = self.safe_value(prevCandle.clone(), i_high.clone(), &[]);
5748 let mut prevLow: Value = self.safe_value(prevCandle.clone(), i_low.clone(), &[]);
5749 add_element_to_object(get_value_mut(&mut ohlcvs, &candle), &i_high, crate::runtime::Math::max(&(if (prevHigh == Value::Null) { price.clone() } else { prevHigh }), &price));
5750 add_element_to_object(get_value_mut(&mut ohlcvs, &candle), &i_low, crate::runtime::Math::min(&(if (prevLow == Value::Null) { price.clone() } else { prevLow }), &price));
5751 add_element_to_object(get_value_mut(&mut ohlcvs, &candle), &i_close, price);
5752 add_element_to_object(get_value_mut(&mut ohlcvs, &candle), &i_volume, self.sum(&[self.safe_value(prevCandle.clone(), i_volume.clone(), &[]), trade.as_map().and_then(|__m| __m.get("amount")).cloned().unwrap_or(Value::Null)]));
5753 add_element_to_object(get_value_mut(&mut ohlcvs, &candle), &i_count, self.sum(&[self.safe_value(prevCandle, i_count.clone(), &[]), Value::Int(1)]));
5754 }
5755 }
5756 }
5757 return ohlcvs;
5758
5759 Value::Null
5760}
5761
5762 fn parse_trading_view_ohlcv(&self, mut ohlcvs: Value, optional_args: &[Value]) -> Value {
5763 let mut market = get_arg(optional_args, 0, Value::Null);
5764 let mut timeframe = get_arg(optional_args, 1, Value::Str("1m".into()));
5765 let mut since = get_arg(optional_args, 2, Value::Null);
5766 let mut limit = get_arg(optional_args, 3, Value::Null);
5767 let mut result: Value = self.convert_trading_view_to_ohlcv(ohlcvs, &[]);
5768 return self.parse_ohlc_vs(result, &[market, timeframe, since, limit]);
5769
5770 Value::Null
5771}
5772
5773 fn fetch_borrow_interest(&mut self, optional_args: &[Value]) -> impl ::std::future::Future<Output = Value> + Send { async move {
5774 let mut code = get_arg(optional_args, 0, Value::Null);
5775 let mut symbol = get_arg(optional_args, 1, Value::Null);
5776 let mut since = get_arg(optional_args, 2, Value::Null);
5777 let mut limit = get_arg(optional_args, 3, Value::Null);
5778 let mut params = get_arg(optional_args, 4, Value::Map({
5779 let mut m = indexmap::IndexMap::new();
5780 m
5781}));
5782 panic!("{}", crate::exchange_errors::not_supported(format!("{}{}", self.id.clone(), Value::Str(" fetchBorrowInterest() is not supported yet".into()))));
5783
5784 Value::Null
5785} }
5786
5787 fn fetch_ledger(&mut self, optional_args: &[Value]) -> impl ::std::future::Future<Output = Value> + Send { async move {
5788 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 {
5790 if !matches!(__v, crate::Value::Null) { return __v; }
5791 }
5792
5793 let mut code = get_arg(optional_args, 0, Value::Null);
5794 let mut since = get_arg(optional_args, 1, Value::Null);
5795 let mut limit = get_arg(optional_args, 2, Value::Null);
5796 let mut params = get_arg(optional_args, 3, Value::Map({
5797 let mut m = indexmap::IndexMap::new();
5798 m
5799}));
5800 panic!("{}", crate::exchange_errors::not_supported(format!("{}{}", self.id.clone(), Value::Str(" fetchLedger() is not supported yet".into()))));
5801
5802 Value::Null
5803} }
5804
5805 fn fetch_ledger_entry(&mut self, mut id: Value, optional_args: &[Value]) -> impl ::std::future::Future<Output = Value> + Send { async move {
5806 let mut code = get_arg(optional_args, 0, Value::Null);
5807 let mut params = get_arg(optional_args, 1, Value::Map({
5808 let mut m = indexmap::IndexMap::new();
5809 m
5810}));
5811 panic!("{}", crate::exchange_errors::not_supported(format!("{}{}", self.id.clone(), Value::Str(" fetchLedgerEntry() is not supported yet".into()))));
5812
5813 Value::Null
5814} }
5815
5816 fn parse_order_book_bid_ask(&self, mut bidask: Value, optional_args: &[Value]) -> Value {
5817 let mut priceKey = get_arg(optional_args, 0, Value::Int(0));
5818 let mut amountKey = get_arg(optional_args, 1, Value::Int(1));
5819 let mut countOrIdKey = get_arg(optional_args, 2, Value::Int(2));
5820 let mut price: Value = self.safe_float(bidask.clone(), priceKey, &[]);
5821 let mut amount: Value = self.safe_float(bidask.clone(), amountKey, &[]);
5822 let mut countOrId: Value = self.safe_integer(bidask, countOrIdKey, &[]);
5823 let mut bidAsk: Vec<Value> = vec![price, amount];
5824 if (countOrId != Value::Null) {
5825 bidAsk.push(countOrId);
5826 }
5827 return Value::from(bidAsk);
5828
5829 Value::Null
5830}
5831
5832 fn parse_order_book_bid_ask_l3(&self, mut bidask: Value, optional_args: &[Value]) -> Value {
5833 let mut priceKey = get_arg(optional_args, 0, Value::Int(0));
5834 let mut amountKey = get_arg(optional_args, 1, Value::Int(1));
5835 let mut countOrIdKey = get_arg(optional_args, 2, Value::Int(2));
5836 let mut price: Value = self.safe_float(bidask.clone(), priceKey, &[]);
5837 let mut amount: Value = self.safe_float(bidask.clone(), amountKey, &[]);
5838 let mut countOrId: Option<String> = self.safe_string_opt(bidask, countOrIdKey, &[]);
5839 let mut bidAsk: Vec<Value> = vec![price, amount];
5840 if (countOrId.is_some()) {
5841 bidAsk.push(countOrId.map(Value::from).unwrap_or(Value::Null));
5842 }
5843 return Value::from(bidAsk);
5844
5845 Value::Null
5846}
5847
5848 fn safe_currency(&self, mut currencyId: Value, optional_args: &[Value]) -> Value {
5849 let mut currency = get_arg(optional_args, 0, Value::Null);
5850 if (currencyId == Value::Null) && (currency != Value::Null) {
5851 return currency;
5852 }
5853 if (currencyId != Value::Null) && (self.currencies_by_id.clone() != Value::Null) && (matches!((&self.currencies_by_id, ¤cyId), (Value::Dict(__d), Value::Str(__k)) if __d.contains_key(__k.as_ref()))) && ((if let (Some(__m), Some(__k)) = (self.currencies_by_id.as_map(), currencyId.as_str()) { __m.get(__k).cloned().unwrap_or(Value::Null) } else { Value::Null }) != Value::Null) {
5854 return (if let (Some(__m), Some(__k)) = (self.currencies_by_id.as_map(), currencyId.as_str()) { __m.get(__k).cloned().unwrap_or(Value::Null) } else { Value::Null });
5855 }
5856 let mut code: Value = currencyId.clone();
5857 if (currencyId != Value::Null) {
5858 code = self.common_currency_code((if let Some(__s) = currencyId.as_str() { Value::Str(__s.to_uppercase().into()) } else { Value::Null }));
5859 }
5860 return self.safe_currency_structure(Value::Map({
5861 let mut m = indexmap::IndexMap::new();
5862 m.insert("id".to_string(), currencyId);
5863 m.insert("code".to_string(), code);
5864 m.insert("precision".to_string(), Value::Null);
5865 m
5866}));
5867
5868 Value::Null
5869}
5870
5871 fn safe_market(&self, optional_args: &[Value]) -> Value {
5872 let mut marketId = get_arg(optional_args, 0, Value::Null);
5873 let mut market = get_arg(optional_args, 1, Value::Null);
5874 let mut delimiter = get_arg(optional_args, 2, Value::Null);
5875 let mut marketType = get_arg(optional_args, 3, Value::Null);
5876 if (marketId != Value::Null) {
5877 if (self.markets_by_id.clone() != Value::Null) && (matches!((&self.markets_by_id, &marketId), (Value::Dict(__d), Value::Str(__k)) if __d.contains_key(__k.as_ref()))) {
5878 let mut markets: Vec<Value> = self.safe_list(self.markets_by_id.clone(), marketId.clone(), &[Value::from(vec![])]).as_array().cloned().unwrap_or_default();
5879 let mut numMarkets: f64 = ((markets.len() as i64) as f64);
5880 if (numMarkets == 1.0) {
5881 return markets.get(0).cloned().unwrap_or(Value::Null);
5882 } else {
5883 if (marketType == Value::Null) && (market == Value::Null) {
5884 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()))));
5885 }
5886 let mut marketTypeResolved: Value = (if (marketType == Value::Null) { self.safe_string_k(market.clone(), "type", &[Value::Str("".into())]) } else { marketType });
5887 {
5888 let mut i: i64 = 0;
5889 let mut __for_first_136: bool = true;
5890 while { if !__for_first_136 { i += 1; } __for_first_136 = false; i < (markets.len() as i64) } {
5891 let mut currentMarket: Value = markets.get(i as usize).cloned().unwrap_or(Value::Null);
5892 if matches!(self.safe_bool(currentMarket.clone(), marketTypeResolved.clone(), &[Value::Bool(false)]), Value::Bool(true)) {
5893 return currentMarket;
5894 }
5895 }
5896 }
5897 }
5898 } else if (delimiter != Value::Null) && (delimiter.as_str() != Some("")) {
5899 let mut parts: Value = Value::Array(marketId.as_str().zip(delimiter.as_str()).map(|(__s, __d)| __s.split(__d).map(Value::from).collect()).unwrap_or_default());
5900 let mut partsLength: f64 = ((parts.len() as i64) as f64);
5901 let mut result: Value = self.safe_market_structure(&[Value::Map({
5902 let mut m = indexmap::IndexMap::new();
5903 m.insert("symbol".to_string(), marketId.clone());
5904 m.insert("marketId".to_string(), marketId.clone());
5905 m
5906})]);
5907 if (result == Value::Null) {
5908 panic!("{}", crate::exchange_errors::exchange_error(format!("{}{}", self.id.clone(), Value::Str(" safeMarket() failed to build market structure".into()))));
5909 }
5910 if (partsLength == 2.0) {
5911 let mut baseId: Option<String> = self.safe_string_opt(parts.clone(), Value::Int(0), &[]);
5912 let mut quoteId: Option<String> = self.safe_string_opt(parts, Value::Int(1), &[]);
5913 let mut base: Value = self.safe_currency_code(baseId.clone().map(Value::from).unwrap_or(Value::Null), &[]);
5914 let mut quote: Value = self.safe_currency_code(quoteId.clone().map(Value::from).unwrap_or(Value::Null), &[]);
5915 if let Value::Dict(__d) = &mut result { std::sync::Arc::make_mut(__d).insert("baseId".into(), baseId.map(Value::from).unwrap_or(Value::Null)); }
5916 if let Value::Dict(__d) = &mut result { std::sync::Arc::make_mut(__d).insert("quoteId".into(), quoteId.map(Value::from).unwrap_or(Value::Null)); }
5917 if (base != Value::Null) {
5918 if let Value::Dict(__d) = &mut result { std::sync::Arc::make_mut(__d).insert("base".into(), base.clone()); }
5919 }
5920 if (quote != Value::Null) {
5921 if let Value::Dict(__d) = &mut result { std::sync::Arc::make_mut(__d).insert("quote".into(), quote.clone()); }
5922 }
5923 if (base != Value::Null) && (quote != Value::Null) {
5924 if let Value::Dict(__rda) = &mut result { std::sync::Arc::make_mut(__rda).insert("symbol".to_string(), Value::Str(format!("{}{}", Value::Str(format!("{}{}", base, Value::Str("/".into())).into()), quote).into())); }
5925 }
5926 }
5927 return result;
5928 }
5929 }
5930 if (market != Value::Null) {
5931 return market;
5932 }
5933 let mut emptyMarket: Value = self.safe_market_structure(&[Value::Map({
5934 let mut m = indexmap::IndexMap::new();
5935 m.insert("symbol".to_string(), marketId.clone());
5936 m.insert("marketId".to_string(), marketId);
5937 m
5938})]);
5939 if (emptyMarket == Value::Null) {
5940 panic!("{}", crate::exchange_errors::exchange_error(format!("{}{}", self.id.clone(), Value::Str(" safeMarket() failed to build market structure".into()))));
5941 }
5942 return emptyMarket;
5943
5944 Value::Null
5945}
5946
5947 fn market_or_null(&self, optional_args: &[Value]) -> Value {
5948 let mut symbol = get_arg(optional_args, 0, Value::Null);
5949 if (symbol == Value::Null) {
5950 return Value::Null;
5951 }
5952 return <Self as crate::exchange_generated::ExchangeBase>::market(self, symbol);
5953
5954 Value::Null
5955}
5956
5957 fn check_required_credentials(&self, optional_args: &[Value]) -> Value {
5958 let mut error = get_arg(optional_args, 0, Value::Bool(true));
5959 let mut keys: Vec<Value> = Value::Array(self.requiredCredentials.as_map().map(|__m| __m.keys().map(|__k| Value::Str(__k.clone().into())).collect()).unwrap_or_default()).as_array().cloned().unwrap_or_default();
5966 {
5967 let mut i: i64 = 0;
5968 let mut __for_first_137: bool = true;
5969 while { if !__for_first_137 { i += 1; } __for_first_137 = false; i < (keys.len() as i64) } {
5970 let mut key: Value = keys.get(i as usize).cloned().unwrap_or(Value::Null);
5971 let mut credentialValue: Value = self.prop(&key);
5972 let mut credentialMissing: bool = (credentialValue == Value::Null) || (credentialValue == Value::Null) || ((match &(credentialValue) { Value::Bool(__x) => *__x == false, __v => matches!((match __v { Value::Int(__n) => Some(*__n as f64), Value::Float(__f) => Some(*__f), Value::Str(__s) => __s.parse::<f64>().ok(),
5973 Value::Bool(__b) => Some(if *__b { 1.0 } else { 0.0 }), _ => None }), Some(__y) if __y == 0.0) })) || (credentialValue.as_str() == Some(""));
5974 if ((if let (Some(__m), Some(__k)) = (self.requiredCredentials.as_map(), key.as_str()) { __m.get(__k).cloned().unwrap_or(Value::Null) } else { Value::Null }).as_bool() == Some(true)) && credentialMissing {
5975 if error.as_bool() == Some(true) {
5976 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()))));
5977 } else {
5978 return Value::Bool(false);
5979 }
5980 }
5981 }
5982 }
5983 return Value::Bool(true);
5984
5985 Value::Null
5986}
5987
5988 fn oath(&self) -> Value {
5989 if (self.twofa.clone() != Value::Null) {
5990 return totp(self.twofa.clone());
5991 } else {
5992 panic!("{}", crate::exchange_errors::exchange_error(format!("{}{}", self.id.clone(), Value::Str(" exchange.twofa has not been set for 2FA Two-Factor Authentication".into()))));
5993 }
5994
5995 Value::Null
5996}
5997
5998 fn fetch_balance(&mut self, optional_args: &[Value]) -> impl ::std::future::Future<Output = Value> + Send { async move {
5999 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 {
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(" fetchBalance() is not supported yet".into()))));
6009
6010 Value::Null
6011} }
6012
6013 fn fetch_balance_ws(&mut self, 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 panic!("{}", crate::exchange_errors::not_supported(format!("{}{}", self.id.clone(), Value::Str(" fetchBalanceWs() is not supported yet".into()))));
6019
6020 Value::Null
6021} }
6022
6023 fn parse_balance(&self, mut response: Value) -> Value {
6024 { let __v = crate::exchange::DerivedExchange::parse_balance(self, response); if !matches!(__v, crate::Value::Null) { return __v; } }
6026
6027 panic!("{}", crate::exchange_errors::not_supported(format!("{}{}", self.id.clone(), Value::Str(" parseBalance() is not supported yet".into()))));
6028
6029 Value::Null
6030}
6031
6032 fn watch_balance(&mut self, optional_args: &[Value]) -> impl ::std::future::Future<Output = Value> + Send { async move {
6033 let mut params = get_arg(optional_args, 0, Value::Map({
6034 let mut m = indexmap::IndexMap::new();
6035 m
6036}));
6037 panic!("{}", crate::exchange_errors::not_supported(format!("{}{}", self.id.clone(), Value::Str(" watchBalance() is not supported yet".into()))));
6038
6039 Value::Null
6040} }
6041
6042 fn fetch_partial_balance(&mut self, mut part: Value, optional_args: &[Value]) -> impl ::std::future::Future<Output = Value> + Send { async move {
6043 let mut params = get_arg(optional_args, 0, Value::Map({
6044 let mut m = indexmap::IndexMap::new();
6045 m
6046}));
6047 let mut balance: Value = self.fetch_balance(&[params]).await;
6048 return (if let (Some(__m), Some(__k)) = (balance.as_map(), part.as_str()) { __m.get(__k).cloned().unwrap_or(Value::Null) } else { Value::Null });
6049
6050 Value::Null
6051} }
6052
6053 fn fetch_free_balance(&mut self, optional_args: &[Value]) -> impl ::std::future::Future<Output = Value> + Send { async move {
6054 let mut params = get_arg(optional_args, 0, Value::Map({
6055 let mut m = indexmap::IndexMap::new();
6056 m
6057}));
6058 return self.fetch_partial_balance(Value::Str("free".into()), &[params]).await;
6059
6060 Value::Null
6061} }
6062
6063 fn fetch_used_balance(&mut self, optional_args: &[Value]) -> impl ::std::future::Future<Output = Value> + Send { async move {
6064 let mut params = get_arg(optional_args, 0, Value::Map({
6065 let mut m = indexmap::IndexMap::new();
6066 m
6067}));
6068 return self.fetch_partial_balance(Value::Str("used".into()), &[params]).await;
6069
6070 Value::Null
6071} }
6072
6073 fn fetch_total_balance(&mut self, optional_args: &[Value]) -> impl ::std::future::Future<Output = Value> + Send { async move {
6074 let mut params = get_arg(optional_args, 0, Value::Map({
6075 let mut m = indexmap::IndexMap::new();
6076 m
6077}));
6078 return self.fetch_partial_balance(Value::Str("total".into()), &[params]).await;
6079
6080 Value::Null
6081} }
6082
6083 fn fetch_status(&mut self, optional_args: &[Value]) -> impl ::std::future::Future<Output = Value> + Send { async move {
6084 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 {
6086 if !matches!(__v, crate::Value::Null) { return __v; }
6087 }
6088
6089 let mut params = get_arg(optional_args, 0, Value::Map({
6090 let mut m = indexmap::IndexMap::new();
6091 m
6092}));
6093 panic!("{}", crate::exchange_errors::not_supported(format!("{}{}", self.id.clone(), Value::Str(" fetchStatus() is not supported yet".into()))));
6094
6095 Value::Null
6096} }
6097
6098 fn fetch_transaction_fee(&mut self, mut code: Value, optional_args: &[Value]) -> impl ::std::future::Future<Output = Value> + Send { async move {
6099 let mut params = get_arg(optional_args, 0, Value::Map({
6100 let mut m = indexmap::IndexMap::new();
6101 m
6102}));
6103 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)) {
6104 panic!("{}", crate::exchange_errors::not_supported(format!("{}{}", self.id.clone(), Value::Str(" fetchTransactionFee() is not supported yet".into()))));
6105 }
6106 return self.fetch_transaction_fees(&[Value::from(vec![code]), params]).await;
6107
6108 Value::Null
6109} }
6110
6111 fn fetch_transaction_fees(&mut self, optional_args: &[Value]) -> impl ::std::future::Future<Output = Value> + Send { async move {
6112 let mut codes = get_arg(optional_args, 0, Value::Null);
6113 let mut params = get_arg(optional_args, 1, Value::Map({
6114 let mut m = indexmap::IndexMap::new();
6115 m
6116}));
6117 panic!("{}", crate::exchange_errors::not_supported(format!("{}{}", self.id.clone(), Value::Str(" fetchTransactionFees() is not supported yet".into()))));
6118
6119 Value::Null
6120} }
6121
6122 fn fetch_deposit_withdraw_fees(&mut self, optional_args: &[Value]) -> impl ::std::future::Future<Output = Value> + Send { async move {
6123 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 {
6125 if !matches!(__v, crate::Value::Null) { return __v; }
6126 }
6127
6128 let mut codes = get_arg(optional_args, 0, Value::Null);
6129 let mut params = get_arg(optional_args, 1, Value::Map({
6130 let mut m = indexmap::IndexMap::new();
6131 m
6132}));
6133 panic!("{}", crate::exchange_errors::not_supported(format!("{}{}", self.id.clone(), Value::Str(" fetchDepositWithdrawFees() is not supported yet".into()))));
6134
6135 Value::Null
6136} }
6137
6138 fn fetch_deposit_withdraw_fee(&mut self, mut code: Value, optional_args: &[Value]) -> impl ::std::future::Future<Output = Value> + Send { async move {
6139 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 {
6141 if !matches!(__v, crate::Value::Null) { return __v; }
6142 }
6143
6144 let mut params = get_arg(optional_args, 0, Value::Map({
6145 let mut m = indexmap::IndexMap::new();
6146 m
6147}));
6148 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)) {
6149 panic!("{}", crate::exchange_errors::not_supported(format!("{}{}", self.id.clone(), Value::Str(" fetchDepositWithdrawFee() is not supported yet".into()))));
6150 }
6151 let mut fees: Value = self.fetch_deposit_withdraw_fees(&[Value::from(vec![code.clone()]), params]).await;
6152 return self.safe_dict(fees, code, &[]);
6153
6154 Value::Null
6155} }
6156
6157 fn get_supported_mapping(&self, mut key: Value, optional_args: &[Value]) -> Value {
6158 let mut mapping = get_arg(optional_args, 0, Value::Map({
6159 let mut m = indexmap::IndexMap::new();
6160 m
6161}));
6162 if (key == Value::Null) {
6163 panic!("{}", crate::exchange_errors::arguments_required(format!("{}{}", self.id.clone(), Value::Str(" getSupportedMapping() requires a key argument".into()))));
6164 }
6165 if (matches!((&mapping, &key), (Value::Dict(__d), Value::Str(__k)) if __d.contains_key(__k.as_ref()))) {
6166 return (if let (Some(__m), Some(__k)) = (mapping.as_map(), key.as_str()) { __m.get(__k).cloned().unwrap_or(Value::Null) } else { Value::Null });
6167 } else {
6168 let mut keys: Value = object_keys(&mapping);
6169 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()),
6170 Value::Str(", must be one of ".into())).into()), Value::Str(keys.as_array().map(|__a| __a.iter().map(|__v| __v.to_string()).collect::<Vec<String>>().join(", ")).unwrap_or_default().into()))));
6171 }
6172
6173 Value::Null
6174}
6175
6176 fn fetch_cross_borrow_rate(&mut self, mut code: Value, optional_args: &[Value]) -> impl ::std::future::Future<Output = Value> + Send { async move {
6177 let mut params = get_arg(optional_args, 0, Value::Map({
6178 let mut m = indexmap::IndexMap::new();
6179 m
6180}));
6181 self.load_markets(&[]).await;
6182 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)) {
6183 panic!("{}", crate::exchange_errors::not_supported(format!("{}{}", self.id.clone(), Value::Str(" fetchCrossBorrowRate() is not supported yet".into()))));
6184 }
6185 let mut borrowRates: Value = self.fetch_cross_borrow_rates(&[params]).await;
6186 let mut rate: Value = self.safe_dict(borrowRates, code.clone(), &[]);
6187 if (rate == Value::Null) {
6188 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)));
6189 }
6190 return rate;
6191
6192 Value::Null
6193} }
6194
6195 fn fetch_isolated_borrow_rate(&mut self, mut symbol: Value, optional_args: &[Value]) -> impl ::std::future::Future<Output = Value> + Send { async move {
6196 let mut params = get_arg(optional_args, 0, Value::Map({
6197 let mut m = indexmap::IndexMap::new();
6198 m
6199}));
6200 self.load_markets(&[]).await;
6201 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)) {
6202 panic!("{}", crate::exchange_errors::not_supported(format!("{}{}", self.id.clone(), Value::Str(" fetchIsolatedBorrowRate() is not supported yet".into()))));
6203 }
6204 let mut borrowRates: Value = self.fetch_isolated_borrow_rates(&[params]).await;
6205 let mut rate: Value = self.safe_dict(borrowRates, symbol.clone(), &[]);
6206 if (rate == Value::Null) {
6207 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)));
6208 }
6209 return rate;
6210
6211 Value::Null
6212} }
6213
6214fn require_value(&self, mut value: Value, optional_args: &[Value]) -> Value {
6217 let mut message = get_arg(optional_args, 0, Value::Null);
6218 if (value == Value::Null) {
6219 let mut errorMessage: Value = (if (message != Value::Null) { message } else { Value::Str("value is required".into()) });
6220 panic!("{}", crate::exchange_errors::arguments_required(format!("{}{}", Value::Str(format!("{}{}", self.id.clone(), Value::Str(" ".into())).into()), errorMessage)));
6221 }
6222 return value;
6223
6224 Value::Null
6225}
6226
6227fn handle_option_and_params(&self, mut params: Value, mut methodName: Value, mut optionName: Value, optional_args: &[Value]) -> Value {
6230 let mut defaultValue = get_arg(optional_args, 0, Value::Null);
6231 let mut defaultOptionName: Value = Value::Str(format!("{}{}", Value::Str("default".into()), self.capitalize(optionName.clone())).into()); let mut value: Value = self.safe_value2(params.clone(), optionName.clone(), defaultOptionName.clone(), &[]);
6235 if (value != Value::Null) {
6236 let mut paramsOmitted: Value = self.omit(params.clone(), Value::from(vec![optionName.clone(), defaultOptionName.clone()]), &[]);
6237 return Value::from(vec![value.clone(), paramsOmitted]);
6238 } else {
6239 let callerMethodNameparamsCallerMethodNameVariable: Vec<Value> = self.handle_param_string(params, Value::Str("callerMethodName".into()), &[methodName]).as_array().cloned().unwrap_or_default();
6241 let mut callerMethodName: Value = callerMethodNameparamsCallerMethodNameVariable.get(0).cloned().unwrap_or(Value::Null);
6242 let mut paramsCallerMethodName: Value = callerMethodNameparamsCallerMethodNameVariable.get(1).cloned().unwrap_or(Value::Null);
6243 let mut exchangeWideMethodOptions: Value = self.safe_value(self.options.clone(), callerMethodName, &[]);
6245 if (exchangeWideMethodOptions != Value::Null) {
6246 value = self.safe_value2(exchangeWideMethodOptions, optionName.clone(), defaultOptionName.clone(), &[]);
6248 }
6249 if (value == Value::Null) {
6250 value = self.safe_value2(self.options.clone(), optionName, defaultOptionName, &[]);
6252 }
6253 if (value == Value::Null) {
6255 value = defaultValue;
6256 }
6257 return Value::from(vec![value, paramsCallerMethodName]);
6258 }
6259
6260 Value::Null
6261}
6262
6263fn handle_option_and_params2(&self, mut params: Value, mut methodName1: Value, mut optionName1: Value, mut optionName2: Value, optional_args: &[Value]) -> Value {
6266 let mut defaultValue = get_arg(optional_args, 0, Value::Null);
6267 let valueparamsOption1Variable: Vec<Value> = self.handle_option_and_params(params, methodName1.clone(), optionName1, &[]).as_array().cloned().unwrap_or_default();
6268 let mut value: Value = valueparamsOption1Variable.get(0).cloned().unwrap_or(Value::Null);
6269 let mut paramsOption1: Value = valueparamsOption1Variable.get(1).cloned().unwrap_or(Value::Null);
6270 if (value != Value::Null) {
6271 let mut paramsOmitted: Value = self.omit(paramsOption1.clone(), optionName2.clone(), &[]);
6273 return Value::from(vec![value, paramsOmitted]);
6274 }
6275 return self.handle_option_and_params(paramsOption1, methodName1, optionName2, &[defaultValue]);
6276
6277 Value::Null
6278}
6279
6280fn handle_option_string_and_params(&self, mut params: Value, mut methodName: Value, mut optionName: Value, optional_args: &[Value]) -> Value {
6283 let mut defaultValue = get_arg(optional_args, 0, Value::Null);
6284 let valuenewParamsVariable: Vec<Value> = self.handle_option_and_params(params, methodName.clone(), optionName.clone(), &[defaultValue]).as_array().cloned().unwrap_or_default();
6286 let mut value: Value = valuenewParamsVariable.get(0).cloned().unwrap_or(Value::Null);
6287 let mut newParams: Value = valuenewParamsVariable.get(1).cloned().unwrap_or(Value::Null);
6288 return Value::from(vec![self.check_option_string(methodName, optionName, value), newParams]);
6289
6290 Value::Null
6291}
6292
6293fn handle_option_string_and_params2(&self, mut params: Value, mut methodName: Value, mut optionName1: Value, mut optionName2: Value, optional_args: &[Value]) -> Value {
6296 let mut defaultValue = get_arg(optional_args, 0, Value::Null);
6297 let valuenewParamsVariable: Vec<Value> = self.handle_option_and_params2(params, methodName.clone(), optionName1.clone(), optionName2, &[defaultValue]).as_array().cloned().unwrap_or_default();
6298 let mut value: Value = valuenewParamsVariable.get(0).cloned().unwrap_or(Value::Null);
6299 let mut newParams: Value = valuenewParamsVariable.get(1).cloned().unwrap_or(Value::Null);
6300 return Value::from(vec![self.check_option_string(methodName, optionName1, value), newParams]);
6301
6302 Value::Null
6303}
6304
6305fn handle_option_bool_and_params(&self, mut params: Value, mut methodName: Value, mut optionName: Value, optional_args: &[Value]) -> Value {
6308 let mut defaultValue = get_arg(optional_args, 0, Value::Null);
6309 let valuenewParamsVariable: Vec<Value> = self.handle_option_and_params(params, methodName.clone(), optionName.clone(), &[defaultValue]).as_array().cloned().unwrap_or_default();
6311 let mut value: Value = valuenewParamsVariable.get(0).cloned().unwrap_or(Value::Null);
6312 let mut newParams: Value = valuenewParamsVariable.get(1).cloned().unwrap_or(Value::Null);
6313 return Value::from(vec![self.check_option_bool(methodName, optionName, value), newParams]);
6314
6315 Value::Null
6316}
6317
6318fn handle_option_bool_and_params2(&self, mut params: Value, mut methodName: Value, mut optionName1: Value, mut optionName2: Value, optional_args: &[Value]) -> Value {
6321 let mut defaultValue = get_arg(optional_args, 0, Value::Null);
6322 let valuenewParamsVariable: Vec<Value> = self.handle_option_and_params2(params, methodName.clone(), optionName1.clone(), optionName2, &[defaultValue]).as_array().cloned().unwrap_or_default();
6323 let mut value: Value = valuenewParamsVariable.get(0).cloned().unwrap_or(Value::Null);
6324 let mut newParams: Value = valuenewParamsVariable.get(1).cloned().unwrap_or(Value::Null);
6325 return Value::from(vec![self.check_option_bool(methodName, optionName1, value), newParams]);
6326
6327 Value::Null
6328}
6329
6330fn handle_option_integer_and_params(&self, mut params: Value, mut methodName: Value, mut optionName: Value, optional_args: &[Value]) -> Value {
6333 let mut defaultValue = get_arg(optional_args, 0, Value::Null);
6334 let valuenewParamsVariable: Vec<Value> = self.handle_option_and_params(params, methodName.clone(), optionName.clone(), &[defaultValue]).as_array().cloned().unwrap_or_default();
6336 let mut value: Value = valuenewParamsVariable.get(0).cloned().unwrap_or(Value::Null);
6337 let mut newParams: Value = valuenewParamsVariable.get(1).cloned().unwrap_or(Value::Null);
6338 return Value::from(vec![self.check_option_integer(methodName, optionName, value), newParams]);
6339
6340 Value::Null
6341}
6342
6343fn handle_option_integer_and_params2(&self, mut params: Value, mut methodName: Value, mut optionName1: Value, mut optionName2: Value, optional_args: &[Value]) -> Value {
6346 let mut defaultValue = get_arg(optional_args, 0, Value::Null);
6347 let valuenewParamsVariable: Vec<Value> = self.handle_option_and_params2(params, methodName.clone(), optionName1.clone(), optionName2, &[defaultValue]).as_array().cloned().unwrap_or_default();
6348 let mut value: Value = valuenewParamsVariable.get(0).cloned().unwrap_or(Value::Null);
6349 let mut newParams: Value = valuenewParamsVariable.get(1).cloned().unwrap_or(Value::Null);
6350 return Value::from(vec![self.check_option_integer(methodName, optionName1, value), newParams]);
6351
6352 Value::Null
6353}
6354
6355 fn handle_option(&self, mut methodName: Value, mut optionName: Value, optional_args: &[Value]) -> Value {
6356 let mut defaultValue = get_arg(optional_args, 0, Value::Null);
6357 let mut res: Value = self.handle_option_and_params(Value::Map({
6358 let mut m = indexmap::IndexMap::new();
6359 m
6360}), methodName, optionName, &[defaultValue]);
6361 return self.safe_value(res, Value::Int(0), &[]);
6362
6363 Value::Null
6364}
6365
6366 fn handle_market_type_and_params(&self, mut methodName: Value, optional_args: &[Value]) -> Value {
6367 let mut market = get_arg(optional_args, 0, Value::Null);
6368 let mut params = get_arg(optional_args, 1, Value::Map({
6369 let mut m = indexmap::IndexMap::new();
6370 m
6371}));
6372 let mut defaultValue = get_arg(optional_args, 2, Value::Null);
6373 let mut type_var: Option<String> = self.safe_string2_opt(params.clone(), Value::Str("defaultType".into()), Value::Str("type".into()), &[]);
6387 if (type_var.is_some()) {
6388 let mut paramsOmitted: Value = self.omit(params.clone(), Value::from(vec![Value::Str("defaultType".into()), Value::Str("type".into())]), &[]);
6389 return Value::from(vec![type_var.map(Value::from).unwrap_or(Value::Null), paramsOmitted]);
6390 }
6391 if (market != Value::Null) {
6393 return Value::from(vec![market.as_map().and_then(|__m| __m.get("type")).cloned().unwrap_or(Value::Null), params.clone()]);
6394 }
6395 if (defaultValue != Value::Null) {
6397 return Value::from(vec![defaultValue, params.clone()]);
6398 }
6399 let mut methodOptions: Value = self.safe_dict(self.options.clone(), methodName, &[]);
6400 if (methodOptions != Value::Null) {
6401 if matches!(&methodOptions, Value::Str(_)) {
6402 return Value::from(vec![methodOptions.clone(), params.clone()]);
6403 } else {
6404 let mut typeFromMethod: Option<String> = self.safe_string2_opt(methodOptions, Value::Str("defaultType".into()), Value::Str("type".into()), &[]);
6405 if (typeFromMethod.is_some()) {
6406 return Value::from(vec![typeFromMethod.map(Value::from).unwrap_or(Value::Null), params.clone()]);
6407 }
6408 }
6409 }
6410 let mut defaultType: Value = self.safe_string2(self.options.clone(), Value::Str("defaultType".into()), Value::Str("type".into()), &[Value::Str("spot".into())]);
6411 return Value::from(vec![defaultType, params]);
6412
6413 Value::Null
6414}
6415
6416 fn handle_sub_type_and_params(&self, mut methodName: Value, optional_args: &[Value]) -> Value {
6417 let mut market = get_arg(optional_args, 0, Value::Null);
6418 let mut params = get_arg(optional_args, 1, Value::Map({
6419 let mut m = indexmap::IndexMap::new();
6420 m
6421}));
6422 let mut defaultValue = get_arg(optional_args, 2, Value::Null);
6423 let mut subType: Value = Value::Null;
6424 let mut subTypeInParams: Option<String> = self.safe_string2_opt(params.clone(), Value::Str("subType".into()), Value::Str("defaultSubType".into()), &[]);
6426 if (subTypeInParams.is_some()) {
6428 if (subTypeInParams.as_deref() == Some("linear")) || (subTypeInParams.as_deref() == Some("inverse")) {
6429 subType = subTypeInParams.map(Value::from).unwrap_or(Value::Null);
6430 }
6431 let mut paramsOmitted: Value = self.omit(params.clone(), Value::from(vec![Value::Str("subType".into()), Value::Str("defaultSubType".into())]), &[]);
6432 return Value::from(vec![subType.clone(), paramsOmitted]);
6433 } else {
6434 if (market != Value::Null) {
6436 if matches!(self.safe_bool_k(market.clone(), "linear", &[Value::Bool(false)]), Value::Bool(true)) {
6437 subType = Value::Str("linear".into());
6438 } else if matches!(self.safe_bool_k(market, "inverse", &[Value::Bool(false)]), Value::Bool(true)) {
6439 subType = Value::Str("inverse".into());
6440 }
6441 }
6442 if (subType == Value::Null) {
6444 let mut values: Vec<Value> = self.handle_option_and_params(Value::Map({
6445 let mut m = indexmap::IndexMap::new();
6446 m
6447}), methodName, Value::Str("subType".into()), &[defaultValue]).as_array().cloned().unwrap_or_default(); subType = values.get(0).cloned().unwrap_or(Value::Null);
6449 }
6450 }
6451 return Value::from(vec![subType, params]);
6452
6453 Value::Null
6454}
6455
6456 fn handle_margin_mode_and_params(&self, mut methodName: Value, optional_args: &[Value]) -> Value {
6457 let mut params = get_arg(optional_args, 0, Value::Map({
6458 let mut m = indexmap::IndexMap::new();
6459 m
6460}));
6461 let mut defaultValue = get_arg(optional_args, 1, Value::Null);
6462 return self.handle_option_string_and_params(params, methodName, Value::Str("marginMode".into()), &[defaultValue]);
6463
6464 Value::Null
6465}
6466
6467 fn throw_exactly_matched_exception(&self, mut exact: Value, mut string: Value, mut message: Value) {
6468 let __exact_empty = indexmap::IndexMap::new();
6469 let exact = exact.as_map().unwrap_or(&__exact_empty);
6470 if (string == Value::Null) {
6471 return;
6472 }
6473 if (matches!(string.as_str(), Some(__k) if exact.contains_key(__k))) {
6474 panic!("{}", crate::exchange_errors::create_error(&crate::runtime::stringify_param(&((if let Some(__k) = string.as_str() { exact.get(__k).cloned().unwrap_or(Value::Null) } else { Value::Null }))), &crate::runtime::stringify_param(&(message))));
6475 }
6476}
6477
6478 fn throw_broadly_matched_exception(&self, mut broad: Value, mut string: Value, mut message: Value) {
6479 let mut broadKey: Value = self.find_broadly_matched_key(broad.clone(), string);
6480 if (broadKey != Value::Null) {
6481 panic!("{}", crate::exchange_errors::create_error(&crate::runtime::stringify_param(&((if let (Some(__m), Some(__k)) = (broad.as_map(), broadKey.as_str()) { __m.get(__k).cloned().unwrap_or(Value::Null) } else { Value::Null }))), &crate::runtime::stringify_param(&(message))));
6482 }
6483}
6484
6485 fn find_broadly_matched_key(&self, mut broad: Value, mut string: Value) -> Value {
6486 let mut keys: Vec<Value> = object_keys(&broad).as_array().cloned().unwrap_or_default();
6488 {
6489 let mut i: i64 = 0;
6490 let mut __for_first_138: bool = true;
6491 while { if !__for_first_138 { i += 1; } __for_first_138 = false; i < (keys.len() as i64) } {
6492 let mut key: Value = keys.get(i as usize).cloned().unwrap_or(Value::Null);
6493 if (string != Value::Null) {
6494 if Value::Int(string.as_str().zip(key.as_str()).and_then(|(__s, __n)| __s.find(__n)).map(|__i| __i as i64).unwrap_or(-1)).as_f64().unwrap_or(f64::NAN) >= ((0i64) as f64) {
6495 return key;
6496 }
6497 }
6498 }
6499 }
6500 return Value::Null;
6501
6502 Value::Null
6503}
6504
6505 fn handle_errors(&self, mut code: Value, mut reason: Value, mut url: Value, mut method: Value, mut headers: Value, mut body: Value, mut response: Value, mut requestHeaders: Value, mut requestBody: Value) -> Value {
6506 { let __v = crate::exchange::DerivedExchange::handle_errors(self, code, reason, url, method, headers, body, response, requestHeaders, requestBody); if !matches!(__v, crate::Value::Null) { return __v; } }
6508
6509 return Value::Null;
6510
6511 Value::Null
6512}
6513
6514 fn calculate_rate_limiter_cost(&self, mut api: Value, mut method: Value, mut path: Value, mut params: Value, optional_args: &[Value]) -> Value {
6515 let mut config = get_arg(optional_args, 0, Value::Map({
6516 let mut m = indexmap::IndexMap::new();
6517 m
6518}));
6519 let __config_empty = indexmap::IndexMap::new();
6520 let config = config.as_map().unwrap_or(&__config_empty);
6521 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) });
6522
6523 Value::Null
6524}
6525
6526 fn fetch_spot_tickers(&mut self, optional_args: &[Value]) -> impl ::std::future::Future<Output = Value> + Send { async move {
6527 let mut symbols = get_arg(optional_args, 0, Value::Null);
6528 let mut params = get_arg(optional_args, 1, Value::Map({
6529 let mut m = indexmap::IndexMap::new();
6530 m
6531}));
6532 panic!("{}", crate::exchange_errors::not_supported(format!("{}{}", self.id.clone(), Value::Str(" fetchSpotTickers() is not supported yet".into()))));
6533
6534 Value::Null
6535} }
6536
6537 fn fetch_contract_tickers(&mut self, optional_args: &[Value]) -> impl ::std::future::Future<Output = Value> + Send { async move {
6538 let mut symbols = get_arg(optional_args, 0, Value::Null);
6539 let mut params = get_arg(optional_args, 1, Value::Map({
6540 let mut m = indexmap::IndexMap::new();
6541 m
6542}));
6543 panic!("{}", crate::exchange_errors::not_supported(format!("{}{}", self.id.clone(), Value::Str(" fetchContractTickers() is not supported yet".into()))));
6544
6545 Value::Null
6546} }
6547
6548 fn fetch_order_books(&mut self, optional_args: &[Value]) -> impl ::std::future::Future<Output = Value> + Send { async move {
6549 let mut symbols = get_arg(optional_args, 0, Value::Null);
6550 let mut limit = get_arg(optional_args, 1, Value::Null);
6551 let mut params = get_arg(optional_args, 2, Value::Map({
6552 let mut m = indexmap::IndexMap::new();
6553 m
6554}));
6555 panic!("{}", crate::exchange_errors::not_supported(format!("{}{}", self.id.clone(), Value::Str(" fetchOrderBooks() is not supported yet".into()))));
6556
6557 Value::Null
6558} }
6559
6560 fn un_watch_tickers(&mut self, optional_args: &[Value]) -> impl ::std::future::Future<Output = Value> + Send { async move {
6561 let mut symbols = get_arg(optional_args, 0, Value::Null);
6562 let mut params = get_arg(optional_args, 1, Value::Map({
6563 let mut m = indexmap::IndexMap::new();
6564 m
6565}));
6566 panic!("{}", crate::exchange_errors::not_supported(format!("{}{}", self.id.clone(), Value::Str(" unWatchTickers() is not supported yet".into()))));
6567
6568 Value::Null
6569} }
6570
6571 fn un_watch_funding_rate(&mut self, mut symbol: Value, optional_args: &[Value]) -> impl ::std::future::Future<Output = Value> + Send { async move {
6572 let mut params = get_arg(optional_args, 0, Value::Map({
6573 let mut m = indexmap::IndexMap::new();
6574 m
6575}));
6576 panic!("{}", crate::exchange_errors::not_supported(format!("{}{}", self.id.clone(), Value::Str(" unWatchFundingRate() is not supported yet".into()))));
6577
6578 Value::Null
6579} }
6580
6581 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 {
6582 let mut params = get_arg(optional_args, 0, Value::Map({
6583 let mut m = indexmap::IndexMap::new();
6584 m
6585}));
6586 panic!("{}", crate::exchange_errors::not_supported(format!("{}{}", self.id.clone(), Value::Str(" createTwapOrder() is not supported yet".into()))));
6587
6588 Value::Null
6589} }
6590
6591 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 {
6592 let mut amount = get_arg(optional_args, 0, Value::Null);
6593 let mut params = get_arg(optional_args, 1, Value::Map({
6594 let mut m = indexmap::IndexMap::new();
6595 m
6596}));
6597 panic!("{}", crate::exchange_errors::not_supported(format!("{}{}", self.id.clone(), Value::Str(" createConvertTrade() is not supported yet".into()))));
6598
6599 Value::Null
6600} }
6601
6602 fn fetch_convert_trade(&mut self, mut id: Value, optional_args: &[Value]) -> impl ::std::future::Future<Output = Value> + Send { async move {
6603 let mut code = get_arg(optional_args, 0, Value::Null);
6604 let mut params = get_arg(optional_args, 1, Value::Map({
6605 let mut m = indexmap::IndexMap::new();
6606 m
6607}));
6608 panic!("{}", crate::exchange_errors::not_supported(format!("{}{}", self.id.clone(), Value::Str(" fetchConvertTrade() is not supported yet".into()))));
6609
6610 Value::Null
6611} }
6612
6613 fn fetch_convert_trade_history(&mut self, optional_args: &[Value]) -> impl ::std::future::Future<Output = Value> + Send { async move {
6614 let mut code = get_arg(optional_args, 0, Value::Null);
6615 let mut since = get_arg(optional_args, 1, Value::Null);
6616 let mut limit = get_arg(optional_args, 2, Value::Null);
6617 let mut params = get_arg(optional_args, 3, Value::Map({
6618 let mut m = indexmap::IndexMap::new();
6619 m
6620}));
6621 panic!("{}", crate::exchange_errors::not_supported(format!("{}{}", self.id.clone(), Value::Str(" fetchConvertTradeHistory() is not supported yet".into()))));
6622
6623 Value::Null
6624} }
6625
6626 fn fetch_position_mode(&mut self, optional_args: &[Value]) -> impl ::std::future::Future<Output = Value> + Send { async move {
6627 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 {
6629 if !matches!(__v, crate::Value::Null) { return __v; }
6630 }
6631
6632 let mut symbol = get_arg(optional_args, 0, Value::Null);
6633 let mut params = get_arg(optional_args, 1, Value::Map({
6634 let mut m = indexmap::IndexMap::new();
6635 m
6636}));
6637 panic!("{}", crate::exchange_errors::not_supported(format!("{}{}", self.id.clone(), Value::Str(" fetchPositionMode() is not supported yet".into()))));
6638
6639 Value::Null
6640} }
6641
6642 fn fetch_adl_rank(&mut self, mut symbol: Value, optional_args: &[Value]) -> impl ::std::future::Future<Output = Value> + Send { async move {
6643 let mut params = get_arg(optional_args, 0, Value::Map({
6644 let mut m = indexmap::IndexMap::new();
6645 m
6646}));
6647 panic!("{}", crate::exchange_errors::not_supported(format!("{}{}", self.id.clone(), Value::Str(" fetchADLRank() is not supported yet".into()))));
6648
6649 Value::Null
6650} }
6651
6652 fn fetch_positions_adl_rank(&mut self, optional_args: &[Value]) -> impl ::std::future::Future<Output = Value> + Send { async move {
6653 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 {
6655 if !matches!(__v, crate::Value::Null) { return __v; }
6656 }
6657
6658 let mut symbols = get_arg(optional_args, 0, Value::Null);
6659 let mut params = get_arg(optional_args, 1, Value::Map({
6660 let mut m = indexmap::IndexMap::new();
6661 m
6662}));
6663 panic!("{}", crate::exchange_errors::not_supported(format!("{}{}", self.id.clone(), Value::Str(" fetchPositionsADLRank() is not supported yet".into()))));
6664
6665 Value::Null
6666} }
6667
6668 fn fetch_position_adl_rank(&mut self, mut symbol: Value, optional_args: &[Value]) -> impl ::std::future::Future<Output = Value> + Send { async move {
6669 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 {
6671 if !matches!(__v, crate::Value::Null) { return __v; }
6672 }
6673
6674 let mut params = get_arg(optional_args, 0, Value::Map({
6675 let mut m = indexmap::IndexMap::new();
6676 m
6677}));
6678 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)) {
6679 self.load_markets(&[]).await;
6680 let mut market: Value = <Self as crate::exchange_generated::ExchangeBase>::market(self, symbol);
6681 let mut symbolResolved: Value = market.as_map().and_then(|__m| __m.get("symbol")).cloned().unwrap_or(Value::Null);
6682 let mut ranks: Value = self.fetch_positions_adl_rank(&[Value::from(vec![symbolResolved.clone()]), params]).await;
6683 let mut rank: Value = self.safe_dict(ranks, Value::Int(0), &[]);
6684 if (rank == Value::Null) {
6685 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)));
6686 } else {
6687 return rank;
6688 }
6689 } else {
6690 panic!("{}", crate::exchange_errors::not_supported(format!("{}{}", self.id.clone(), Value::Str(" fetchPositionsADLRank() is not supported yet".into()))));
6691 }
6692
6693 Value::Null
6694} }
6695
6696 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 {
6697 let mut price = get_arg(optional_args, 0, Value::Null);
6698 let mut takeProfit = get_arg(optional_args, 1, Value::Null);
6699 let mut stopLoss = get_arg(optional_args, 2, Value::Null);
6700 let mut params = get_arg(optional_args, 3, Value::Map({
6701 let mut m = indexmap::IndexMap::new();
6702 m
6703}));
6704 if (takeProfit == Value::Null) && (stopLoss == Value::Null) {
6705 panic!("{}", crate::exchange_errors::arguments_required(format!("{}{}", self.id.clone(), Value::Str(" createOrderWithTakeProfitAndStopLoss() requires either a takeProfit or stopLoss argument".into()))));
6706 }
6707 let mut takeProfitType: Option<String> = self.safe_string_k_opt(params.clone(), "takeProfitType", &[]);
6708 let mut takeProfitPriceType: Option<String> = self.safe_string_k_opt(params.clone(), "takeProfitPriceType", &[]);
6709 let mut takeProfitLimitPrice: Option<String> = self.safe_string_k_opt(params.clone(), "takeProfitLimitPrice", &[]);
6710 let mut takeProfitAmount: Option<String> = self.safe_string_k_opt(params.clone(), "takeProfitAmount", &[]);
6711 let mut stopLossType: Option<String> = self.safe_string_k_opt(params.clone(), "stopLossType", &[]);
6712 let mut stopLossPriceType: Option<String> = self.safe_string_k_opt(params.clone(), "stopLossPriceType", &[]);
6713 let mut stopLossLimitPrice: Option<String> = self.safe_string_k_opt(params.clone(), "stopLossLimitPrice", &[]);
6714 let mut stopLossAmount: Option<String> = self.safe_string_k_opt(params.clone(), "stopLossAmount", &[]);
6715 if (takeProfit != Value::Null) {
6716 let mut takeProfitRequest: indexmap::IndexMap<String, Value> = ({
6717 let mut m = indexmap::IndexMap::new();
6718 m.insert("triggerPrice".to_string(), takeProfit);
6719 m
6720 });
6721 if (takeProfitType.is_some()) {
6722 takeProfitRequest.insert("type".into(), takeProfitType.map(Value::from).unwrap_or(Value::Null));
6723 }
6724 if (takeProfitPriceType.is_some()) {
6725 takeProfitRequest.insert("priceType".into(), takeProfitPriceType.map(Value::from).unwrap_or(Value::Null));
6726 }
6727 if (takeProfitLimitPrice.is_some()) {
6728 takeProfitRequest.insert("price".into(), self.parse_to_numeric(takeProfitLimitPrice.map(Value::from).unwrap_or(Value::Null)));
6729 }
6730 if (takeProfitAmount.is_some()) {
6731 takeProfitRequest.insert("amount".into(), self.parse_to_numeric(takeProfitAmount.map(Value::from).unwrap_or(Value::Null)));
6732 }
6733 if let Value::Dict(__d) = &mut params { std::sync::Arc::make_mut(__d).insert("takeProfit".into(), Value::Map(takeProfitRequest)); }
6734 }
6735 if (stopLoss != Value::Null) {
6736 let mut stopLossRequest: indexmap::IndexMap<String, Value> = ({
6737 let mut m = indexmap::IndexMap::new();
6738 m.insert("triggerPrice".to_string(), stopLoss);
6739 m
6740 });
6741 if (stopLossType.is_some()) {
6742 stopLossRequest.insert("type".into(), stopLossType.map(Value::from).unwrap_or(Value::Null));
6743 }
6744 if (stopLossPriceType.is_some()) {
6745 stopLossRequest.insert("priceType".into(), stopLossPriceType.map(Value::from).unwrap_or(Value::Null));
6746 }
6747 if (stopLossLimitPrice.is_some()) {
6748 stopLossRequest.insert("price".into(), self.parse_to_numeric(stopLossLimitPrice.map(Value::from).unwrap_or(Value::Null)));
6749 }
6750 if (stopLossAmount.is_some()) {
6751 stopLossRequest.insert("amount".into(), self.parse_to_numeric(stopLossAmount.map(Value::from).unwrap_or(Value::Null)));
6752 }
6753 if let Value::Dict(__d) = &mut params { std::sync::Arc::make_mut(__d).insert("stopLoss".into(), Value::Map(stopLossRequest)); }
6754 }
6755 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())]), &[]);
6756 return paramsOmitted;
6757
6758 Value::Null
6759}
6760
6761 fn create_spot_orders(&mut self, mut orders: Value, optional_args: &[Value]) -> impl ::std::future::Future<Output = Value> + Send { async move {
6762 let mut params = get_arg(optional_args, 0, Value::Map({
6763 let mut m = indexmap::IndexMap::new();
6764 m
6765}));
6766 panic!("{}", crate::exchange_errors::not_supported(format!("{}{}", self.id.clone(), Value::Str(" createSpotOrders() is not supported yet".into()))));
6767
6768 Value::Null
6769} }
6770
6771 fn create_contract_orders(&mut self, mut orders: Value, optional_args: &[Value]) -> impl ::std::future::Future<Output = Value> + Send { async move {
6772 let mut params = get_arg(optional_args, 0, Value::Map({
6773 let mut m = indexmap::IndexMap::new();
6774 m
6775}));
6776 panic!("{}", crate::exchange_errors::not_supported(format!("{}{}", self.id.clone(), Value::Str(" createContractOrders() is not supported yet".into()))));
6777
6778 Value::Null
6779} }
6780
6781 fn cancel_spot_order(&mut self, mut id: Value, optional_args: &[Value]) -> impl ::std::future::Future<Output = Value> + Send { async move {
6782 let mut symbol = get_arg(optional_args, 0, Value::Null);
6783 let mut params = get_arg(optional_args, 1, Value::Map({
6784 let mut m = indexmap::IndexMap::new();
6785 m
6786}));
6787 panic!("{}", crate::exchange_errors::not_supported(format!("{}{}", self.id.clone(), Value::Str(" cancelSpotOrder() is not supported yet".into()))));
6788
6789 Value::Null
6790} }
6791
6792 fn cancel_contract_order(&mut self, mut id: Value, optional_args: &[Value]) -> impl ::std::future::Future<Output = Value> + Send { async move {
6793 let mut symbol = get_arg(optional_args, 0, Value::Null);
6794 let mut params = get_arg(optional_args, 1, Value::Map({
6795 let mut m = indexmap::IndexMap::new();
6796 m
6797}));
6798 panic!("{}", crate::exchange_errors::not_supported(format!("{}{}", self.id.clone(), Value::Str(" cancelContractOrder() is not supported yet".into()))));
6799
6800 Value::Null
6801} }
6802
6803 fn cancel_all_spot_orders(&mut self, optional_args: &[Value]) -> impl ::std::future::Future<Output = Value> + Send { async move {
6804 let mut symbol = get_arg(optional_args, 0, Value::Null);
6805 let mut params = get_arg(optional_args, 1, Value::Map({
6806 let mut m = indexmap::IndexMap::new();
6807 m
6808}));
6809 panic!("{}", crate::exchange_errors::not_supported(format!("{}{}", self.id.clone(), Value::Str(" cancelAllSpotOrders() is not supported yet".into()))));
6810
6811 Value::Null
6812} }
6813
6814 fn cancel_all_contract_orders(&mut self, optional_args: &[Value]) -> impl ::std::future::Future<Output = Value> + Send { async move {
6815 let mut symbol = get_arg(optional_args, 0, Value::Null);
6816 let mut params = get_arg(optional_args, 1, Value::Map({
6817 let mut m = indexmap::IndexMap::new();
6818 m
6819}));
6820 panic!("{}", crate::exchange_errors::not_supported(format!("{}{}", self.id.clone(), Value::Str(" cancelAllContractOrders() is not supported yet".into()))));
6821
6822 Value::Null
6823} }
6824
6825 fn cancel_all_orders_after(&mut self, mut timeout: Value, optional_args: &[Value]) -> impl ::std::future::Future<Output = Value> + Send { async move {
6826 let mut params = get_arg(optional_args, 0, Value::Map({
6827 let mut m = indexmap::IndexMap::new();
6828 m
6829}));
6830 panic!("{}", crate::exchange_errors::not_supported(format!("{}{}", self.id.clone(), Value::Str(" cancelAllOrdersAfter() is not supported yet".into()))));
6831
6832 Value::Null
6833} }
6834
6835 fn cancel_orders_for_symbols(&mut self, mut orders: Value, optional_args: &[Value]) -> impl ::std::future::Future<Output = Value> + Send { async move {
6836 let mut params = get_arg(optional_args, 0, Value::Map({
6837 let mut m = indexmap::IndexMap::new();
6838 m
6839}));
6840 panic!("{}", crate::exchange_errors::not_supported(format!("{}{}", self.id.clone(), Value::Str(" cancelOrdersForSymbols() is not supported yet".into()))));
6841
6842 Value::Null
6843} }
6844
6845 fn fetch_my_liquidations(&mut self, optional_args: &[Value]) -> impl ::std::future::Future<Output = Value> + Send { async move {
6846 let mut symbol = get_arg(optional_args, 0, Value::Null);
6847 let mut since = get_arg(optional_args, 1, Value::Null);
6848 let mut limit = get_arg(optional_args, 2, Value::Null);
6849 let mut params = get_arg(optional_args, 3, Value::Map({
6850 let mut m = indexmap::IndexMap::new();
6851 m
6852}));
6853 panic!("{}", crate::exchange_errors::not_supported(format!("{}{}", self.id.clone(), Value::Str(" fetchMyLiquidations() is not supported yet".into()))));
6854
6855 Value::Null
6856} }
6857
6858 fn fetch_liquidations(&mut self, mut symbol: Value, optional_args: &[Value]) -> impl ::std::future::Future<Output = Value> + Send { async move {
6859 let mut since = get_arg(optional_args, 0, Value::Null);
6860 let mut limit = get_arg(optional_args, 1, Value::Null);
6861 let mut params = get_arg(optional_args, 2, Value::Map({
6862 let mut m = indexmap::IndexMap::new();
6863 m
6864}));
6865 panic!("{}", crate::exchange_errors::not_supported(format!("{}{}", self.id.clone(), Value::Str(" fetchLiquidations() is not supported yet".into()))));
6866
6867 Value::Null
6868} }
6869
6870 fn fetch_greeks(&mut self, mut symbol: Value, optional_args: &[Value]) -> impl ::std::future::Future<Output = Value> + Send { async move {
6871 let mut params = get_arg(optional_args, 0, Value::Map({
6872 let mut m = indexmap::IndexMap::new();
6873 m
6874}));
6875 panic!("{}", crate::exchange_errors::not_supported(format!("{}{}", self.id.clone(), Value::Str(" fetchGreeks() is not supported yet".into()))));
6876
6877 Value::Null
6878} }
6879
6880 fn fetch_all_greeks(&mut self, optional_args: &[Value]) -> impl ::std::future::Future<Output = Value> + Send { async move {
6881 let mut symbols = get_arg(optional_args, 0, Value::Null);
6882 let mut params = get_arg(optional_args, 1, Value::Map({
6883 let mut m = indexmap::IndexMap::new();
6884 m
6885}));
6886 panic!("{}", crate::exchange_errors::not_supported(format!("{}{}", self.id.clone(), Value::Str(" fetchAllGreeks() is not supported yet".into()))));
6887
6888 Value::Null
6889} }
6890
6891 fn fetch_option_chain(&mut self, mut code: Value, optional_args: &[Value]) -> impl ::std::future::Future<Output = Value> + Send { async move {
6892 let mut params = get_arg(optional_args, 0, Value::Map({
6893 let mut m = indexmap::IndexMap::new();
6894 m
6895}));
6896 panic!("{}", crate::exchange_errors::not_supported(format!("{}{}", self.id.clone(), Value::Str(" fetchOptionChain() is not supported yet".into()))));
6897
6898 Value::Null
6899} }
6900
6901 fn fetch_option(&mut self, mut symbol: Value, optional_args: &[Value]) -> impl ::std::future::Future<Output = Value> + Send { async move {
6902 let mut params = get_arg(optional_args, 0, Value::Map({
6903 let mut m = indexmap::IndexMap::new();
6904 m
6905}));
6906 panic!("{}", crate::exchange_errors::not_supported(format!("{}{}", self.id.clone(), Value::Str(" fetchOption() is not supported yet".into()))));
6907
6908 Value::Null
6909} }
6910
6911 fn fetch_convert_quote(&mut self, mut fromCode: Value, mut toCode: Value, optional_args: &[Value]) -> impl ::std::future::Future<Output = Value> + Send { async move {
6912 let mut amount = get_arg(optional_args, 0, Value::Null);
6913 let mut params = get_arg(optional_args, 1, Value::Map({
6914 let mut m = indexmap::IndexMap::new();
6915 m
6916}));
6917 panic!("{}", crate::exchange_errors::not_supported(format!("{}{}", self.id.clone(), Value::Str(" fetchConvertQuote() is not supported yet".into()))));
6918
6919 Value::Null
6920} }
6921
6922 fn fetch_deposits_withdrawals(&mut self, optional_args: &[Value]) -> impl ::std::future::Future<Output = Value> + Send { async move {
6923 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 {
6925 if !matches!(__v, crate::Value::Null) { return __v; }
6926 }
6927
6928 let mut code = get_arg(optional_args, 0, Value::Null);
6929 let mut since = get_arg(optional_args, 1, Value::Null);
6930 let mut limit = get_arg(optional_args, 2, Value::Null);
6931 let mut params = get_arg(optional_args, 3, Value::Map({
6932 let mut m = indexmap::IndexMap::new();
6933 m
6934}));
6935 panic!("{}", crate::exchange_errors::not_supported(format!("{}{}", self.id.clone(), Value::Str(" fetchDepositsWithdrawals() is not supported yet".into()))));
6936
6937 Value::Null
6938} }
6939
6940 fn fetch_deposits(&mut self, optional_args: &[Value]) -> impl ::std::future::Future<Output = Value> + Send { async move {
6941 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 {
6943 if !matches!(__v, crate::Value::Null) { return __v; }
6944 }
6945
6946 let mut code = get_arg(optional_args, 0, Value::Null);
6947 let mut since = get_arg(optional_args, 1, Value::Null);
6948 let mut limit = get_arg(optional_args, 2, Value::Null);
6949 let mut params = get_arg(optional_args, 3, Value::Map({
6950 let mut m = indexmap::IndexMap::new();
6951 m
6952}));
6953 panic!("{}", crate::exchange_errors::not_supported(format!("{}{}", self.id.clone(), Value::Str(" fetchDeposits() is not supported yet".into()))));
6954
6955 Value::Null
6956} }
6957
6958 fn fetch_withdrawals(&mut self, optional_args: &[Value]) -> impl ::std::future::Future<Output = Value> + Send { async move {
6959 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 {
6961 if !matches!(__v, crate::Value::Null) { return __v; }
6962 }
6963
6964 let mut code = get_arg(optional_args, 0, Value::Null);
6965 let mut since = get_arg(optional_args, 1, Value::Null);
6966 let mut limit = get_arg(optional_args, 2, Value::Null);
6967 let mut params = get_arg(optional_args, 3, Value::Map({
6968 let mut m = indexmap::IndexMap::new();
6969 m
6970}));
6971 panic!("{}", crate::exchange_errors::not_supported(format!("{}{}", self.id.clone(), Value::Str(" fetchWithdrawals() is not supported yet".into()))));
6972
6973 Value::Null
6974} }
6975
6976 fn fetch_deposits_ws(&mut self, optional_args: &[Value]) -> impl ::std::future::Future<Output = Value> + Send { async move {
6977 let mut code = get_arg(optional_args, 0, Value::Null);
6978 let mut since = get_arg(optional_args, 1, Value::Null);
6979 let mut limit = get_arg(optional_args, 2, Value::Null);
6980 let mut params = get_arg(optional_args, 3, Value::Map({
6981 let mut m = indexmap::IndexMap::new();
6982 m
6983}));
6984 panic!("{}", crate::exchange_errors::not_supported(format!("{}{}", self.id.clone(), Value::Str(" fetchDepositsWs() is not supported yet".into()))));
6985
6986 Value::Null
6987} }
6988
6989 fn fetch_withdrawals_ws(&mut self, optional_args: &[Value]) -> impl ::std::future::Future<Output = Value> + Send { async move {
6990 let mut code = get_arg(optional_args, 0, Value::Null);
6991 let mut since = get_arg(optional_args, 1, Value::Null);
6992 let mut limit = get_arg(optional_args, 2, Value::Null);
6993 let mut params = get_arg(optional_args, 3, Value::Map({
6994 let mut m = indexmap::IndexMap::new();
6995 m
6996}));
6997 panic!("{}", crate::exchange_errors::not_supported(format!("{}{}", self.id.clone(), Value::Str(" fetchWithdrawalsWs() is not supported yet".into()))));
6998
6999 Value::Null
7000} }
7001
7002 fn fetch_funding_rate_history(&mut self, optional_args: &[Value]) -> impl ::std::future::Future<Output = Value> + Send { async move {
7003 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 {
7005 if !matches!(__v, crate::Value::Null) { return __v; }
7006 }
7007
7008 let mut symbol = get_arg(optional_args, 0, Value::Null);
7009 let mut since = get_arg(optional_args, 1, Value::Null);
7010 let mut limit = get_arg(optional_args, 2, Value::Null);
7011 let mut params = get_arg(optional_args, 3, Value::Map({
7012 let mut m = indexmap::IndexMap::new();
7013 m
7014}));
7015 panic!("{}", crate::exchange_errors::not_supported(format!("{}{}", self.id.clone(), Value::Str(" fetchFundingRateHistory() is not supported yet".into()))));
7016
7017 Value::Null
7018} }
7019
7020 fn fetch_funding_history(&mut self, optional_args: &[Value]) -> impl ::std::future::Future<Output = Value> + Send { async move {
7021 let mut symbol = get_arg(optional_args, 0, Value::Null);
7022 let mut since = get_arg(optional_args, 1, Value::Null);
7023 let mut limit = get_arg(optional_args, 2, Value::Null);
7024 let mut params = get_arg(optional_args, 3, Value::Map({
7025 let mut m = indexmap::IndexMap::new();
7026 m
7027}));
7028 panic!("{}", crate::exchange_errors::not_supported(format!("{}{}", self.id.clone(), Value::Str(" fetchFundingHistory() is not supported yet".into()))));
7029
7030 Value::Null
7031} }
7032
7033 fn parse_last_price(&self, mut price: Value, optional_args: &[Value]) -> Value {
7034 { 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; } }
7036
7037 let mut market = get_arg(optional_args, 0, Value::Null);
7038 panic!("{}", crate::exchange_errors::not_supported(format!("{}{}", self.id.clone(), Value::Str(" parseLastPrice() is not supported yet".into()))));
7039
7040 Value::Null
7041}
7042
7043 fn fetch_deposit_address(&mut self, mut code: Value, optional_args: &[Value]) -> impl ::std::future::Future<Output = Value> + Send { async move {
7044 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 {
7046 if !matches!(__v, crate::Value::Null) { return __v; }
7047 }
7048
7049 let mut params = get_arg(optional_args, 0, Value::Map({
7050 let mut m = indexmap::IndexMap::new();
7051 m
7052}));
7053 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)) {
7054 let mut depositAddressesList: Value = self.fetch_deposit_addresses(&[Value::from(vec![code.clone()]), params.clone()]).await;
7055 let mut depositAddresses: Value = self.index_by(depositAddressesList, Value::Str("currency".into()));
7056 if (self.safe_dict(depositAddresses.clone(), code.clone(), &[]) == Value::Null) {
7057 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()))));
7058 }
7059 return self.safe_dict(depositAddresses, code.clone(), &[]);
7060 } 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)) {
7061 let mut network: Option<String> = self.safe_string_k_opt(params.clone(), "network", &[]);
7062 let mut paramsOmitted: Value = self.omit(params, Value::Str("network".into()), &[]);
7063 let mut addressStructures: Value = self.fetch_deposit_addresses_by_network(code, &[paramsOmitted]).await;
7064 if (network.is_some()) {
7065 return self.safe_dict(addressStructures.clone(), network.map(Value::from).unwrap_or(Value::Null), &[]);
7066 } else {
7067 let mut keys: Vec<Value> = object_keys(&addressStructures).as_array().cloned().unwrap_or_default();
7068 let mut key: Value = keys.get(0).cloned().unwrap_or(Value::Null);
7069 return self.safe_dict(addressStructures, key, &[]);
7070 }
7071 } else {
7072 panic!("{}", crate::exchange_errors::not_supported(format!("{}{}", self.id.clone(), Value::Str(" fetchDepositAddress() is not supported yet".into()))));
7073 }
7074
7075 Value::Null
7076} }
7077
7078 fn fetch_contract_deposit_address(&mut self, mut code: Value, optional_args: &[Value]) -> impl ::std::future::Future<Output = Value> + Send { async move {
7079 let mut params = get_arg(optional_args, 0, Value::Map({
7080 let mut m = indexmap::IndexMap::new();
7081 m
7082}));
7083 panic!("{}", crate::exchange_errors::not_supported(format!("{}{}", self.id.clone(), Value::Str(" fetchContractDepositAddress() is not supported yet".into()))));
7084
7085 Value::Null
7086} }
7087
7088 fn account(&self) -> Value {
7089 return Value::Map({
7090 let mut m = indexmap::IndexMap::new();
7091 m.insert("free".to_string(), Value::Null);
7092 m.insert("used".to_string(), Value::Null);
7093 m.insert("total".to_string(), Value::Null);
7094 m
7095});
7096
7097 Value::Null
7098}
7099
7100fn merge_balance_account(&self, mut result: Value, mut code: Value, mut account: Value) -> Value {
7110 if !(matches!((&result, &code), (Value::Dict(__d), Value::Str(__k)) if __d.contains_key(__k.as_ref()))) {
7111 if let Value::Dict(__d) = &mut result { std::sync::Arc::make_mut(__d).insert(crate::runtime::stringify_param(&code), account.clone()); }
7112 return result;
7113 }
7114 let mut fields: Value = Value::from(vec![Value::Str("free".into()), Value::Str("used".into()), Value::Str("total".into()), Value::Str("debt".into())]);
7115 {
7116 let mut i: i64 = 0;
7117 let mut __for_first_139: bool = true;
7118 while { if !__for_first_139 { i += 1; } __for_first_139 = false; i < (fields.len() as i64) } {
7119 let mut field: Value = fields.as_array().map(Vec::as_slice).unwrap_or_default().get(i as usize).cloned().unwrap_or(Value::Null);
7120 let mut current: Option<String> = self.safe_string_opt((if let (Some(__m), Some(__k)) = (result.as_map(), code.as_str()) { __m.get(__k).cloned().unwrap_or(Value::Null) } else { Value::Null }), field.clone(), &[]);
7121 let mut incoming: Value = self.safe_string(account.clone(), field.clone(), &[]);
7122 if (current.is_none()) {
7123 if let Value::Dict(__h0) = &mut result { if let Some(Value::Dict(__h1)) = std::sync::Arc::make_mut(__h0).get_mut(&crate::runtime::stringify_param(&code)) { std::sync::Arc::make_mut(__h1).insert(crate::runtime::stringify_param(&field), incoming.clone()); } }
7124 } else if (incoming != Value::Null) {
7125 if let Value::Dict(__h0) = &mut result { if let Some(Value::Dict(__h1)) = std::sync::Arc::make_mut(__h0).get_mut(&crate::runtime::stringify_param(&code)) { std::sync::Arc::make_mut(__h1).insert(crate::runtime::stringify_param(&field), crate::precise::Precise::stringAdd(¤t.clone().map(Value::from).unwrap_or(Value::Null), &incoming)); } }
7126 }
7127 }
7128 }
7129 return result;
7130
7131 Value::Null
7132}
7133
7134 fn common_currency_code(&self, mut code: Value) -> Value {
7135 if !(self.substituteCommonCurrencyCodes.as_bool() == Some(true)) {
7136 return code;
7137 }
7138 return self.safe_string(self.commonCurrencies.clone(), code.clone(), &[code.clone()]);
7139
7140 Value::Null
7141}
7142
7143 fn currency(&self, mut code: Value) -> Value {
7144 if (code == Value::Null) {
7145 panic!("{}", crate::exchange_errors::arguments_required(format!("{}{}", self.id.clone(), Value::Str(" currency() requires a code argument".into()))));
7146 }
7147 let mut keys: Vec<Value> = Value::Array(self.currencies.as_map().map(|__m| __m.keys().map(|__k| Value::Str(__k.clone().into())).collect()).unwrap_or_default()).as_array().cloned().unwrap_or_default();
7148 let mut numCurrencies: f64 = ((keys.len() as i64) as f64);
7149 if (numCurrencies == 0.0) {
7150 panic!("{}", crate::exchange_errors::exchange_error(format!("{}{}", self.id.clone(), Value::Str(" currencies not loaded".into()))));
7151 }
7152 if matches!(&code, Value::Str(_)) {
7153 let mut currencies: Value = self.currencies.clone();
7154 let mut currenciesById: Value = self.currencies_by_id.clone();
7155 if (matches!((¤cies, &code), (Value::Dict(__d), Value::Str(__k)) if __d.contains_key(__k.as_ref()))) {
7156 return (if let (Some(__m), Some(__k)) = (currencies.as_map(), code.as_str()) { __m.get(__k).cloned().unwrap_or(Value::Null) } else { Value::Null });
7157 } else if (currenciesById != Value::Null) && (matches!((¤ciesById, &code), (Value::Dict(__d), Value::Str(__k)) if __d.contains_key(__k.as_ref()))) {
7158 return (if let (Some(__m), Some(__k)) = (currenciesById.as_map(), code.as_str()) { __m.get(__k).cloned().unwrap_or(Value::Null) } else { Value::Null });
7159 }
7160 }
7161 panic!("{}", crate::exchange_errors::exchange_error(format!("{}{}", Value::Str(format!("{}{}", self.id.clone(), Value::Str(" does not have currency code ".into())).into()), code)));
7162
7163 Value::Null
7164}
7165
7166 fn market(&self, mut symbol: Value) -> Value {
7167 { let __v = crate::exchange::DerivedExchange::market(self, symbol.clone()); if !matches!(__v, crate::Value::Null) { return __v; } }
7169 self.market_non_virtual(symbol)
7170 }
7171
7172 fn market_non_virtual(&self, mut symbol: Value) -> Value {
7173 if (symbol == Value::Null) {
7174 panic!("{}", crate::exchange_errors::arguments_required(format!("{}{}", self.id.clone(), Value::Str(" market() requires a symbol argument".into()))));
7175 }
7176 let mut markets: Value = self.markets.clone();
7177 if (markets == Value::Null) {
7178 panic!("{}", crate::exchange_errors::exchange_error(format!("{}{}", self.id.clone(), Value::Str(" markets not loaded".into()))));
7179 }
7180 let mut marketsById: Value = self.markets_by_id.clone();
7181 if (matches!((&markets, &symbol), (Value::Dict(__d), Value::Str(__k)) if __d.contains_key(__k.as_ref()))) {
7182 return get_value(&markets, &symbol);
7183 } else if (marketsById != Value::Null) && (matches!((&marketsById, &symbol), (Value::Dict(__d), Value::Str(__k)) if __d.contains_key(__k.as_ref()))) {
7184 let mut marketsList: Value = get_value(&marketsById, &symbol);
7185 let mut defaultType: Value = self.safe_string2(self.options.clone(), Value::Str("defaultType".into()), Value::Str("defaultSubType".into()), &[Value::Str("spot".into())]);
7186 {
7187 let mut i: Value = Value::Int(0);
7188 let mut __for_first_140: bool = true;
7189 while { if !__for_first_140 { if let Value::Int(n) = &mut i { *n += 1; } } __for_first_140 = false; i.as_f64().unwrap_or(f64::NAN) < Value::Int(marketsList.len() as i64).as_f64().unwrap_or(f64::NAN) } {
7190 let mut market: Value = get_value(&marketsList, &i);
7191 if matches!(self.safe_bool(market.clone(), defaultType.clone(), &[Value::Bool(false)]), Value::Bool(true)) {
7192 return market;
7193 }
7194 }
7195 }
7196 return get_value(&marketsList, &Value::Int(0));
7197 } else if (symbol.as_str().unwrap_or("").ends_with("-C")) || (symbol.as_str().unwrap_or("").ends_with("-P")) || (symbol.as_str().unwrap_or("").starts_with("C-")) || (symbol.as_str().unwrap_or("").starts_with("P-")) {
7198 return <Self as crate::exchange_generated::ExchangeBase>::create_expired_option_market(self, symbol.clone());
7199 }
7200 panic!("{}", crate::exchange_errors::bad_symbol(format!("{}{}", Value::Str(format!("{}{}", self.id.clone(), Value::Str(" does not have market symbol ".into())).into()), symbol)));
7201
7202 Value::Null
7203}
7204
7205 fn create_expired_option_market(&self, mut symbol: Value) -> Value {
7206 { let __v = crate::exchange::DerivedExchange::create_expired_option_market(self, symbol); if !matches!(__v, crate::Value::Null) { return __v; } }
7208
7209 panic!("{}", crate::exchange_errors::not_supported(format!("{}{}", self.id.clone(), Value::Str(" createExpiredOptionMarket () is not supported yet".into()))));
7210
7211 Value::Null
7212}
7213
7214 fn is_leveraged_currency(&self, mut currencyCode: Value, optional_args: &[Value]) -> Value {
7215 let mut checkBaseCoin = get_arg(optional_args, 0, Value::Bool(false));
7216 let mut existingCurrencies = get_arg(optional_args, 1, Value::Null);
7217 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())]);
7218 {
7219 let mut i: i64 = 0;
7220 let mut __for_first_141: bool = true;
7221 while { if !__for_first_141 { i += 1; } __for_first_141 = false; i < (leverageSuffixes.len() as i64) } {
7222 let mut leverageSuffix: Value = leverageSuffixes.as_array().map(Vec::as_slice).unwrap_or_default().get(i as usize).cloned().unwrap_or(Value::Null);
7223 let mut endsWithSuffix: bool = ends_with(¤cyCode, &leverageSuffix);
7224 if endsWithSuffix {
7225 if !(checkBaseCoin.as_bool() == Some(true)) {
7226 return Value::Bool(true);
7227 } else {
7228 let mut baseCurrencyCode: Value = replace_str(¤cyCode, &leverageSuffix, &Value::Str("".into()));
7230 if (existingCurrencies != Value::Null) && (matches!((&existingCurrencies, &baseCurrencyCode), (Value::Dict(__d), Value::Str(__k)) if __d.contains_key(__k.as_ref()))) {
7231 return Value::Bool(true);
7232 }
7233 }
7234 }
7235 }
7236 }
7237 return Value::Bool(false);
7238
7239 Value::Null
7240}
7241
7242 fn cost_to_precision(&self, mut symbol: Value, mut cost: Value) -> Value {
7243 if (cost == Value::Null) {
7244 return Value::Null;
7245 }
7246 let mut market: indexmap::IndexMap<String, Value> = <Self as crate::exchange_generated::ExchangeBase>::market(self, symbol).as_map().cloned().unwrap_or_default();
7247 return self.decimal_to_precision(cost, Value::Int(crate::runtime::TRUNCATE), self.safe_string2(market.get("precision").cloned().unwrap_or(Value::Null), Value::Str("cost".into()), Value::Str("price".into()), &[]), &[self.precisionMode.clone(), self.paddingMode.clone()]);
7248
7249 Value::Null
7250}
7251
7252 fn price_to_precision(&self, mut symbol: Value, mut price: Value) -> Value {
7253 if (price == Value::Null) {
7254 return Value::Null;
7255 }
7256 let mut market: Value = <Self as crate::exchange_generated::ExchangeBase>::market(self, symbol);
7257 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()]);
7258 if (result.as_str() == Some("0")) {
7259 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));
7260 if (pricePrecision == Value::Null) {
7261 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()))));
7262 }
7263 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()),
7264 Value::Str(" must be greater than minimum price precision of ".into())).into()), pricePrecision)));
7265 }
7266 return result;
7267
7268 Value::Null
7269}
7270
7271 fn amount_to_precision(&self, mut symbol: Value, mut amount: Value) -> Value {
7272 if (amount == Value::Null) {
7273 return Value::Null;
7274 }
7275 let mut market: Value = <Self as crate::exchange_generated::ExchangeBase>::market(self, symbol);
7276 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()]);
7277 if (result.as_str() == Some("0")) {
7278 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));
7279 if (amountPrecision == Value::Null) {
7280 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()))));
7281 }
7282 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()),
7283 Value::Str(" must be greater than minimum amount precision of ".into())).into()), amountPrecision)));
7284 }
7285 return result;
7286
7287 Value::Null
7288}
7289
7290 fn fee_to_precision(&self, mut symbol: Value, mut fee: Value) -> Value {
7291 if (fee == Value::Null) {
7292 return Value::Null;
7293 }
7294 let mut market: indexmap::IndexMap<String, Value> = <Self as crate::exchange_generated::ExchangeBase>::market(self, symbol).as_map().cloned().unwrap_or_default();
7295 return self.decimal_to_precision(fee, Value::Int(crate::runtime::ROUND), market.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()]);
7296
7297 Value::Null
7298}
7299
7300 fn currency_to_precision(&self, mut code: Value, mut fee: Value, optional_args: &[Value]) -> Value {
7301 let mut networkCode = get_arg(optional_args, 0, Value::Null);
7302 if (code == Value::Null) {
7303 panic!("{}", crate::exchange_errors::arguments_required(format!("{}{}", self.id.clone(), Value::Str(" currencyToPrecision() requires a code argument".into()))));
7304 }
7305 let mut currency: Value = (if let (Some(__m), Some(__k)) = (self.currencies.as_map(), code.as_str()) { __m.get(__k).cloned().unwrap_or(Value::Null) } else { Value::Null });
7306 let mut precision: Value = self.safe_value_k(currency.clone(), "precision", &[]);
7307 if (networkCode != Value::Null) {
7308 let mut networks: Value = self.safe_dict_k(currency, "networks", &[Value::Map({
7309 let mut m = indexmap::IndexMap::new();
7310 m
7311})]);
7312 let mut networkItem: Value = self.safe_dict(networks, networkCode, &[Value::Map({
7313 let mut m = indexmap::IndexMap::new();
7314 m
7315})]);
7316 precision = self.safe_value_k(networkItem, "precision", &[precision.clone()]);
7317 }
7318 if (precision == Value::Null) {
7319 return self.force_string(fee.clone());
7320 } else {
7321 let mut roundingMode: Value = self.safe_integer_k(self.options.clone(), "currencyToPrecisionRoundingMode", &[Value::Int(crate::runtime::ROUND)]);
7322 return self.decimal_to_precision(fee, roundingMode, precision, &[self.precisionMode.clone(), self.paddingMode.clone()]);
7323 }
7324
7325 Value::Null
7326}
7327
7328 fn force_string(&self, mut value: Value) -> Value {
7329 if !matches!(&value, Value::Str(_)) {
7330 return self.number_to_string(value.clone());
7331 }
7332 return value;
7333
7334 Value::Null
7335}
7336
7337 fn is_tick_precision(&self) -> Value {
7338 return Value::Bool(self.precisionMode.as_f64() == Value::Int(crate::runtime::TICK_SIZE).as_f64());
7339
7340 Value::Null
7341}
7342
7343 fn is_significant_precision(&self) -> Value {
7344 return Value::Bool(self.precisionMode.as_f64() == Value::Int(crate::runtime::SIGNIFICANT_DIGITS).as_f64());
7345
7346 Value::Null
7347}
7348
7349 fn safe_number(&self, mut obj: Value, mut key: Value, optional_args: &[Value]) -> Value {
7350 let mut defaultNumber = get_arg(optional_args, 0, Value::Null);
7351 let mut value: Option<String> = self.safe_string_opt(obj, key, &[]);
7352 return self.parse_number(value.map(Value::from).unwrap_or(Value::Null), &[defaultNumber]);
7353
7354 Value::Null
7355}
7356
7357 fn safe_number_n(&self, mut obj: Value, mut arr: Value, optional_args: &[Value]) -> Value {
7358 let mut defaultNumber = get_arg(optional_args, 0, Value::Null);
7359 let mut value: Value = self.safe_string_n(obj, arr, &[]);
7360 return self.parse_number(value, &[defaultNumber]);
7361
7362 Value::Null
7363}
7364
7365 fn parse_precision(&self, optional_args: &[Value]) -> Value {
7366 let mut precision = get_arg(optional_args, 0, Value::Null);
7367 if (precision == Value::Null) {
7374 return Value::Null;
7375 }
7376 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 });
7377 if (precisionNumber.as_f64() == Some(0.0)) {
7378 return Value::Str("1".into());
7379 }
7380 if precisionNumber.as_f64().unwrap_or(f64::NAN) > ((0i64) as f64) {
7381 let mut parsedPrecision: Value = Value::Str("0.".into());
7382 {
7383 let mut i: Value = Value::Int(0);
7384 let mut __for_first_142: bool = true;
7385 while { if !__for_first_142 { if let Value::Int(n) = &mut i { *n += 1; } } __for_first_142 = 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),
7386 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) } {
7387 parsedPrecision = Value::Str(format!("{}{}", parsedPrecision, Value::Str("0".into())).into());
7388 }
7389 }
7390 return Value::Str(format!("{}{}", parsedPrecision, Value::Str("1".into())).into());
7391 } else {
7392 let mut parsedPrecision: Value = Value::Str("1".into());
7393 {
7394 let mut i: Value = Value::Int(0);
7395 let mut __for_first_143: bool = true;
7396 while { if !__for_first_143 { if let Value::Int(n) = &mut i { *n += 1; } } __for_first_143 = false; i.as_f64().unwrap_or(f64::NAN) < (match (&(Value::Int(-1)), &(precisionNumber)) { (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),
7397 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) } {
7398 parsedPrecision = Value::Str(format!("{}{}", parsedPrecision, Value::Str("0".into())).into());
7399 }
7400 }
7401 return Value::Str(format!("{}{}", parsedPrecision, Value::Str("0".into())).into());
7402 }
7403
7404 Value::Null
7405}
7406
7407 fn integer_precision_to_amount(&self, mut precision: Value) -> Value {
7408 if (precision == Value::Null) {
7416 return Value::Null;
7417 }
7418 if crate::precise::Precise::stringGe(&precision, &Value::Str("0".into())).as_bool() == Some(true) {
7419 return self.parse_precision(&[precision.clone()]);
7420 } else {
7421 let mut positivePrecisionString: Value = crate::precise::Precise::stringAbs(&precision);
7422 if (positivePrecisionString == Value::Null) {
7423 return Value::Null;
7424 }
7425 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 });
7426 let mut parsedPrecision: Value = Value::Str("1".into());
7427 {
7428 let mut i: Value = Value::Int(0);
7429 let mut __for_first_144: bool = true;
7430 while { if !__for_first_144 { if let Value::Int(n) = &mut i { *n += 1; } } __for_first_144 = 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),
7431 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) } {
7432 parsedPrecision = Value::Str(format!("{}{}", parsedPrecision, Value::Str("0".into())).into());
7433 }
7434 }
7435 return Value::Str(format!("{}{}", parsedPrecision, Value::Str("0".into())).into());
7436 }
7437}
7438
7439 fn load_time_difference(&mut self, optional_args: &[Value]) -> impl ::std::future::Future<Output = Value> + Send { async move {
7440 let mut params = get_arg(optional_args, 0, Value::Map({
7441 let mut m = indexmap::IndexMap::new();
7442 m
7443}));
7444 let mut serverTime: Value = self.fetch_time(&[params]).await;
7445 let mut after: Value = self.milliseconds();
7446 if (serverTime == Value::Null) {
7447 panic!("{}", crate::exchange_errors::exchange_error(format!("{}{}", self.id.clone(), Value::Str(" loadTimeDifference() missing serverTime".into()))));
7448 }
7449 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),
7450 Value::Float(y)) => Value::Float(x - y), _ => Value::Null })); }
7451 return self.parse_to_int(self.options.as_map().and_then(|__m| __m.get("timeDifference")).cloned().unwrap_or(Value::Null));
7452
7453 Value::Null
7454} }
7455
7456 fn implode_hostname(&self, mut url: Value) -> Value {
7457 return self.implode_params(url, Value::Map({
7458 let mut m = indexmap::IndexMap::new();
7459 m.insert("hostname".to_string(), self.hostname.clone());
7460 m
7461}));
7462
7463 Value::Null
7464}
7465
7466 fn fetch_market_leverage_tiers(&mut self, mut symbol: Value, optional_args: &[Value]) -> impl ::std::future::Future<Output = Value> + Send { async move {
7467 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 {
7469 if !matches!(__v, crate::Value::Null) { return __v; }
7470 }
7471
7472 let mut params = get_arg(optional_args, 0, Value::Map({
7473 let mut m = indexmap::IndexMap::new();
7474 m
7475}));
7476 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)) {
7477 let mut market: Value = <Self as crate::exchange_generated::ExchangeBase>::market(self, symbol.clone());
7478 if !matches!(self.safe_bool_k(market, "contract", &[Value::Bool(false)]), Value::Bool(true)) {
7479 panic!("{}", crate::exchange_errors::bad_symbol(format!("{}{}", self.id.clone(), Value::Str(" fetchMarketLeverageTiers() supports contract markets only".into()))));
7480 }
7481 let mut tiers: Value = self.fetch_leverage_tiers(&[Value::from(vec![symbol.clone()])]).await;
7482 let mut marketTiers: Value = self.safe_list(tiers, symbol, &[]);
7483 return marketTiers;
7484 } else {
7485 panic!("{}", crate::exchange_errors::not_supported(format!("{}{}", self.id.clone(), Value::Str(" fetchMarketLeverageTiers() is not supported yet".into()))));
7486 }
7487
7488 Value::Null
7489} }
7490
7491 fn create_sub_account(&mut self, mut name: Value, optional_args: &[Value]) -> impl ::std::future::Future<Output = Value> + Send { async move {
7492 let mut params = get_arg(optional_args, 0, Value::Map({
7493 let mut m = indexmap::IndexMap::new();
7494 m
7495}));
7496 panic!("{}", crate::exchange_errors::not_supported(format!("{}{}", self.id.clone(), Value::Str(" createSubAccount() is not supported yet".into()))));
7497
7498 Value::Null
7499} }
7500
7501 fn safe_currency_code(&self, mut currencyId: Value, optional_args: &[Value]) -> Value {
7502 let mut currency = get_arg(optional_args, 0, Value::Null);
7503 let mut currencyResolved: indexmap::IndexMap<String, Value> = self.safe_currency(currencyId, &[currency]).as_map().cloned().unwrap_or_default();
7504 return currencyResolved.get("code").cloned().unwrap_or(Value::Null);
7505
7506 Value::Null
7507}
7508
7509 fn filter_by_symbol_since_limit(&self, mut array: Value, optional_args: &[Value]) -> Value {
7510 let mut symbol = get_arg(optional_args, 0, Value::Null);
7511 let mut since = get_arg(optional_args, 1, Value::Null);
7512 let mut limit = get_arg(optional_args, 2, Value::Null);
7513 let mut tail = get_arg(optional_args, 3, Value::Bool(false));
7514 return self.filter_by_value_since_limit(array, Value::Str("symbol".into()), &[symbol, since, limit, Value::Str("timestamp".into()), tail]);
7515
7516 Value::Null
7517}
7518
7519 fn filter_by_currency_since_limit(&self, mut array: Value, optional_args: &[Value]) -> Value {
7520 let mut code = get_arg(optional_args, 0, Value::Null);
7521 let mut since = get_arg(optional_args, 1, Value::Null);
7522 let mut limit = get_arg(optional_args, 2, Value::Null);
7523 let mut tail = get_arg(optional_args, 3, Value::Bool(false));
7524 return self.filter_by_value_since_limit(array, Value::Str("currency".into()), &[code, since, limit, Value::Str("timestamp".into()), tail]);
7525
7526 Value::Null
7527}
7528
7529 fn filter_by_symbols_since_limit(&self, mut array: Value, optional_args: &[Value]) -> Value {
7530 let mut symbols = get_arg(optional_args, 0, Value::Null);
7531 let mut since = get_arg(optional_args, 1, Value::Null);
7532 let mut limit = get_arg(optional_args, 2, Value::Null);
7533 let mut tail = get_arg(optional_args, 3, Value::Bool(false));
7534 let mut result: Value = self.filter_by_array(array, Value::Str("symbol".into()), &[symbols, Value::Bool(false)]);
7535 return self.filter_by_since_limit(result, &[since, limit, Value::Str("timestamp".into()), tail]);
7536
7537 Value::Null
7538}
7539
7540 fn parse_last_prices(&self, mut pricesData: Value, optional_args: &[Value]) -> Value {
7541 let mut symbols = get_arg(optional_args, 0, Value::Null);
7542 let mut params = get_arg(optional_args, 1, Value::Map({
7543 let mut m = indexmap::IndexMap::new();
7544 m
7545}));
7546 let mut results: Vec<Value> = Vec::new();
7566 if (matches!(&pricesData, Value::Arr(_))) {
7567 {
7568 let mut i: i64 = 0;
7569 let mut __for_first_145: bool = true;
7570 while { if !__for_first_145 { i += 1; } __for_first_145 = false; i < (pricesData.len() as i64) } {
7571 results.push(self.extend(<Self as crate::exchange_generated::ExchangeBase>::parse_last_price(self, pricesData.as_array().map(Vec::as_slice).unwrap_or_default().get(i as usize).cloned().unwrap_or(Value::Null), &[]), &[params.clone()]));
7572 }
7573 }
7574 } else {
7575 let mut marketIds: Vec<Value> = object_keys(&pricesData).as_array().cloned().unwrap_or_default();
7576 {
7577 let mut i: i64 = 0;
7578 let mut __for_first_146: bool = true;
7579 while { if !__for_first_146 { i += 1; } __for_first_146 = false; i < (marketIds.len() as i64) } {
7580 let mut marketId: Value = marketIds.get(i as usize).cloned().unwrap_or(Value::Null);
7581 let mut market: Value = self.safe_market(&[marketId.clone()]);
7582 results.push(self.extend(<Self as crate::exchange_generated::ExchangeBase>::parse_last_price(self, get_value(&pricesData, &marketId), &[market]), &[params.clone()]));
7583 }
7584 }
7585 }
7586 return self.index_by(self.filter_by_array(Value::from(results), Value::Str("symbol".into()), &[self.market_symbols(&[symbols]), Value::Bool(false)]), Value::Str("symbol".into()));
7587
7588 Value::Null
7589}
7590
7591 fn parse_tickers(&self, mut tickers: Value, optional_args: &[Value]) -> Value {
7592 let mut symbols = get_arg(optional_args, 0, Value::Null);
7593 let mut params = get_arg(optional_args, 1, Value::Map({
7594 let mut m = indexmap::IndexMap::new();
7595 m
7596}));
7597 let mut results: Vec<Value> = Vec::new();
7620 if (matches!(&tickers, Value::Arr(_))) {
7621 {
7622 let mut i: i64 = 0;
7623 let mut __for_first_147: bool = true;
7624 while { if !__for_first_147 { i += 1; } __for_first_147 = false; i < (tickers.len() as i64) } {
7625 results.push(self.extend(<Self as crate::exchange_generated::ExchangeBase>::parse_ticker(self, tickers.as_array().map(Vec::as_slice).unwrap_or_default().get(i as usize).cloned().unwrap_or(Value::Null), &[]), &[params.clone()]));
7626 }
7627 }
7628 } else {
7629 let mut marketIds: Vec<Value> = object_keys(&tickers).as_array().cloned().unwrap_or_default();
7630 {
7631 let mut i: i64 = 0;
7632 let mut __for_first_148: bool = true;
7633 while { if !__for_first_148 { i += 1; } __for_first_148 = false; i < (marketIds.len() as i64) } {
7634 let mut marketId: Value = marketIds.get(i as usize).cloned().unwrap_or(Value::Null);
7635 let mut market: Value = self.safe_market(&[marketId.clone()]);
7636 results.push(self.extend(<Self as crate::exchange_generated::ExchangeBase>::parse_ticker(self, get_value(&tickers, &marketId), &[market]), &[params.clone()]));
7637 }
7638 }
7639 }
7640 return self.filter_by_array_tickers(Value::from(results), Value::Str("symbol".into()), &[self.market_symbols(&[symbols])]);
7641
7642 Value::Null
7643}
7644
7645 fn parse_deposit_addresses(&self, mut addresses: Value, optional_args: &[Value]) -> Value {
7646 let mut codes = get_arg(optional_args, 0, Value::Null);
7647 let mut indexed = get_arg(optional_args, 1, Value::Bool(true));
7648 let mut params = get_arg(optional_args, 2, Value::Map({
7649 let mut m = indexmap::IndexMap::new();
7650 m
7651}));
7652 let mut result: Value = Value::from(vec![]);
7653 {
7654 let mut i: Value = Value::Int(0);
7655 let mut __for_first_149: bool = true;
7656 while { if !__for_first_149 { if let Value::Int(n) = &mut i { *n += 1; } } __for_first_149 = false; i.as_f64().unwrap_or(f64::NAN) < get_array_length(&addresses).as_f64().unwrap_or(f64::NAN) } {
7657 let mut address: Value = self.extend(<Self as crate::exchange_generated::ExchangeBase>::parse_deposit_address(self, get_value(&addresses, &i), &[]), &[params.clone()]);
7658 if let Value::Arr(__a) = &mut result { std::sync::Arc::make_mut(__a).push(address); }
7659 }
7660 }
7661 if (codes != Value::Null) {
7662 result = self.to_array(self.filter_by_array(result.clone(), Value::Str("currency".into()), &[codes, Value::Bool(false)]));
7663 }
7664 if indexed.as_bool() == Some(true) {
7665 result = self.to_array(self.filter_by_array(result.clone(), Value::Str("currency".into()), &[Value::Null, indexed]));
7666 }
7667 return result;
7668
7669 Value::Null
7670}
7671
7672 fn parse_borrow_interests(&self, mut response: Value, optional_args: &[Value]) -> Value {
7673 let mut market = get_arg(optional_args, 0, Value::Null);
7674 let mut interests: Value = Value::from(vec![]);
7675 {
7676 let mut i: Value = Value::Int(0);
7677 let mut __for_first_150: bool = true;
7678 while { if !__for_first_150 { if let Value::Int(n) = &mut i { *n += 1; } } __for_first_150 = false; i.as_f64().unwrap_or(f64::NAN) < get_array_length(&response).as_f64().unwrap_or(f64::NAN) } {
7679 let mut row: Value = self.safe_value(response.clone(), i.clone(), &[]);
7680 if let Value::Arr(__a) = &mut interests { std::sync::Arc::make_mut(__a).push(<Self as crate::exchange_generated::ExchangeBase>::parse_borrow_interest(self, row, &[market.clone()])); }
7681 }
7682 }
7683 return interests;
7684
7685 Value::Null
7686}
7687
7688 fn parse_borrow_rate(&self, mut info: Value, optional_args: &[Value]) -> Value {
7689 { 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; } }
7691
7692 let mut currency = get_arg(optional_args, 0, Value::Null);
7693 panic!("{}", crate::exchange_errors::not_supported(format!("{}{}", self.id.clone(), Value::Str(" parseBorrowRate() is not supported yet".into()))));
7694
7695 Value::Null
7696}
7697
7698 fn parse_borrow_rate_history(&self, mut response: Value, mut code: Value, mut since: Value, mut limit: Value) -> Value {
7699 let mut result: Vec<Value> = Vec::new();
7700 {
7701 let mut i: Value = Value::Int(0);
7702 let mut __for_first_151: bool = true;
7703 while { if !__for_first_151 { if let Value::Int(n) = &mut i { *n += 1; } } __for_first_151 = false; i.as_f64().unwrap_or(f64::NAN) < get_array_length(&response).as_f64().unwrap_or(f64::NAN) } {
7704 let mut item: Value = self.safe_value(response.clone(), i.clone(), &[]);
7705 let mut borrowRate: Value = <Self as crate::exchange_generated::ExchangeBase>::parse_borrow_rate(self, item, &[]);
7706 result.push(borrowRate);
7707 }
7708 }
7709 let mut sorted: Value = self.sort_by(Value::from(result), Value::Str("timestamp".into()), &[]);
7710 return self.filter_by_currency_since_limit(sorted, &[code, since, limit]);
7711
7712 Value::Null
7713}
7714
7715 fn parse_isolated_borrow_rates(&self, mut info: Value) -> Value {
7716 let mut result: Value = Value::Map({
7717 let mut m = indexmap::IndexMap::new();
7718 m
7719 });
7720 {
7721 let mut i: Value = Value::Int(0);
7722 let mut __for_first_152: bool = true;
7723 while { if !__for_first_152 { if let Value::Int(n) = &mut i { *n += 1; } } __for_first_152 = false; i.as_f64().unwrap_or(f64::NAN) < get_array_length(&info).as_f64().unwrap_or(f64::NAN) } {
7724 let mut item: Value = self.safe_value(info.clone(), i.clone(), &[]);
7725 let mut borrowRate: Value = self.parse_isolated_borrow_rate(item, &[]);
7726 let mut symbol: Option<String> = self.safe_string_k_opt(borrowRate.clone(), "symbol", &[]);
7727 if let Value::Dict(__d) = &mut result { std::sync::Arc::make_mut(__d).insert(symbol.as_deref().unwrap_or("null").to_string(), borrowRate); }
7728 }
7729 }
7730 return result;
7731
7732 Value::Null
7733}
7734
7735 fn parse_funding_rate_histories(&self, mut response: Value, optional_args: &[Value]) -> Value {
7736 let mut market = get_arg(optional_args, 0, Value::Null);
7737 let mut since = get_arg(optional_args, 1, Value::Null);
7738 let mut limit = get_arg(optional_args, 2, Value::Null);
7739 let mut rates: Vec<Value> = Vec::new();
7740 {
7741 let mut i: Value = Value::Int(0);
7742 let mut __for_first_153: bool = true;
7743 while { if !__for_first_153 { if let Value::Int(n) = &mut i { *n += 1; } } __for_first_153 = false; i.as_f64().unwrap_or(f64::NAN) < get_array_length(&response).as_f64().unwrap_or(f64::NAN) } {
7744 let mut entry: Value = get_value(&response, &i);
7745 rates.push(<Self as crate::exchange_generated::ExchangeBase>::parse_funding_rate_history(self, entry, &[market.clone()]));
7746 }
7747 }
7748 let mut sorted: Value = self.sort_by(Value::from(rates), Value::Str("timestamp".into()), &[]);
7749 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) });
7750 return self.filter_by_symbol_since_limit(sorted, &[symbol, since, limit]);
7751
7752 Value::Null
7753}
7754
7755 fn safe_symbol(&self, mut marketId: Value, optional_args: &[Value]) -> Value {
7756 let mut market = get_arg(optional_args, 0, Value::Null);
7757 let mut delimiter = get_arg(optional_args, 1, Value::Null);
7758 let mut marketType = get_arg(optional_args, 2, Value::Null);
7759 let mut marketResolved: Value = self.safe_market(&[marketId, market, delimiter, marketType]);
7760 return marketResolved.as_map().and_then(|__m| __m.get("symbol")).cloned().unwrap_or(Value::Null);
7761
7762 Value::Null
7763}
7764
7765 fn parse_funding_rate(&self, mut contract: Value, optional_args: &[Value]) -> Value {
7766 { 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; } }
7768
7769 let mut market = get_arg(optional_args, 0, Value::Null);
7770 panic!("{}", crate::exchange_errors::not_supported(format!("{}{}", self.id.clone(), Value::Str(" parseFundingRate() is not supported yet".into()))));
7771
7772 Value::Null
7773}
7774
7775 fn parse_funding_rates(&self, mut response: Value, optional_args: &[Value]) -> Value {
7776 let mut symbols = get_arg(optional_args, 0, Value::Null);
7777 let mut fundingRates: indexmap::IndexMap<String, Value> = ({
7778 let mut m = indexmap::IndexMap::new();
7779 m
7780 });
7781 {
7782 let mut i: Value = Value::Int(0);
7783 let mut __for_first_154: bool = true;
7784 while { if !__for_first_154 { if let Value::Int(n) = &mut i { *n += 1; } } __for_first_154 = false; i.as_f64().unwrap_or(f64::NAN) < get_array_length(&response).as_f64().unwrap_or(f64::NAN) } {
7785 let mut entry: Value = get_value(&response, &i);
7786 let mut parsed: Value = <Self as crate::exchange_generated::ExchangeBase>::parse_funding_rate(self, entry, &[]);
7787 if (parsed.as_map().and_then(|__m| __m.get("symbol")).cloned().unwrap_or(Value::Null) != Value::Null) {
7788 fundingRates.insert(crate::runtime::stringify_param(&(parsed.as_map().and_then(|__m| __m.get("symbol")).cloned().unwrap_or(Value::Null))), parsed);
7789 }
7790 }
7791 }
7792 return self.index_by(self.filter_by_array(Value::Map(fundingRates), Value::Str("symbol".into()), &[symbols, Value::Bool(false)]), Value::Str("symbol".into()));
7793
7794 Value::Null
7795}
7796
7797 fn parse_long_short_ratio(&self, mut info: Value, optional_args: &[Value]) -> Value {
7798 let mut market = get_arg(optional_args, 0, Value::Null);
7799 panic!("{}", crate::exchange_errors::not_supported(format!("{}{}", self.id.clone(), Value::Str(" parseLongShortRatio() is not supported yet".into()))));
7800
7801 Value::Null
7802}
7803
7804 fn parse_long_short_ratio_history(&self, mut response: Value, optional_args: &[Value]) -> Value {
7805 let mut market = get_arg(optional_args, 0, Value::Null);
7806 let mut since = get_arg(optional_args, 1, Value::Null);
7807 let mut limit = get_arg(optional_args, 2, Value::Null);
7808 let mut rates: Vec<Value> = Vec::new();
7809 {
7810 let mut i: Value = Value::Int(0);
7811 let mut __for_first_155: bool = true;
7812 while { if !__for_first_155 { if let Value::Int(n) = &mut i { *n += 1; } } __for_first_155 = false; i.as_f64().unwrap_or(f64::NAN) < get_array_length(&response).as_f64().unwrap_or(f64::NAN) } {
7813 let mut entry: Value = get_value(&response, &i);
7814 rates.push(self.parse_long_short_ratio(entry, &[market.clone()]));
7815 }
7816 }
7817 let mut sorted: Value = self.sort_by(Value::from(rates), Value::Str("timestamp".into()), &[]);
7818 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) });
7819 return self.filter_by_symbol_since_limit(sorted, &[symbol, since, limit]);
7820
7821 Value::Null
7822}
7823
7824 fn handle_trigger_prices_and_params(&self, mut symbol: Value, mut params: Value, optional_args: &[Value]) -> Value {
7825 let mut omitParams = get_arg(optional_args, 0, Value::Bool(true));
7826 let mut triggerPrice: Value = self.safe_string2(params.clone(), Value::Str("triggerPrice".into()), Value::Str("stopPrice".into()), &[]);
7828 let mut triggerPriceStr: Value = Value::Null;
7829 let mut stopLossPrice: Value = self.safe_string_k(params.clone(), "stopLossPrice", &[]);
7830 let mut stopLossPriceStr: Value = Value::Null;
7831 let mut takeProfitPrice: Value = self.safe_string_k(params.clone(), "takeProfitPrice", &[]);
7832 let mut takeProfitPriceStr: Value = Value::Null;
7833 let mut keysToOmit: Vec<Value> = Vec::new();
7835 if (triggerPrice != Value::Null) {
7836 if omitParams.as_bool() == Some(true) {
7837 keysToOmit.push(Value::Str("triggerPrice".into()));
7838 keysToOmit.push(Value::Str("stopPrice".into()));
7839 }
7840 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 }));
7841 }
7842 if (stopLossPrice != Value::Null) {
7843 if omitParams.as_bool() == Some(true) {
7844 keysToOmit.push(Value::Str("stopLossPrice".into()));
7845 }
7846 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 }));
7847 }
7848 if (takeProfitPrice != Value::Null) {
7849 if omitParams.as_bool() == Some(true) {
7850 keysToOmit.push(Value::Str("takeProfitPrice".into()));
7851 }
7852 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 }));
7853 }
7854 let mut keysToOmitLength: f64 = ((keysToOmit.len() as i64) as f64);
7855 let mut paramsOmitted: Value = (if (keysToOmitLength > ((0i64) as f64)) { self.omit(params.clone(), Value::from(keysToOmit), &[]) } else { params });
7856 return Value::from(vec![triggerPriceStr, stopLossPriceStr, takeProfitPriceStr, paramsOmitted]);
7857
7858 Value::Null
7859}
7860
7861 fn handle_trigger_direction_and_params(&self, mut params: Value, optional_args: &[Value]) -> Value {
7862 let mut exchangeSpecificKey = get_arg(optional_args, 0, Value::Null);
7863 let mut allowEmpty = get_arg(optional_args, 1, Value::Bool(false));
7864 let mut triggerDirection: Value = self.safe_string_k(params.clone(), "triggerDirection", &[]);
7870 let mut exchangeSpecificDefined: bool = (exchangeSpecificKey != Value::Null) && (matches!((¶ms, &exchangeSpecificKey), (Value::Dict(__d), Value::Str(__k)) if __d.contains_key(__k.as_ref())));
7871 let mut paramsOmitted: Value = (if (triggerDirection != Value::Null) { self.omit(params.clone(), Value::Str("triggerDirection".into()), &[]) } else { params });
7872 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 && !(allowEmpty.as_bool() == Some(true)) {
7876 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()))));
7877 }
7878 if (triggerDirection.as_str() == Some("up")) || (triggerDirection.as_str() == Some("above")) {
7880 triggerDirection = Value::Str("ascending".into());
7881 } else if (triggerDirection.as_str() == Some("down")) || (triggerDirection.as_str() == Some("below")) {
7882 triggerDirection = Value::Str("descending".into());
7883 }
7884 return Value::from(vec![triggerDirection, paramsOmitted]);
7885
7886 Value::Null
7887}
7888
7889 fn handle_trigger_and_params(&self, mut params: Value) -> Value {
7890 let mut isTrigger: Value = self.safe_bool2(params.clone(), Value::Str("trigger".into()), Value::Str("stop".into()), &[]);
7891 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 });
7892 return Value::from(vec![isTrigger, paramsOmitted]);
7893
7894 Value::Null
7895}
7896
7897 fn is_trigger_order(&self, mut params: Value) -> Value {
7898 return self.handle_trigger_and_params(params);
7899
7900 Value::Null
7901}
7902
7903 fn is_post_only(&self, mut isMarketOrder: Value, mut exchangeSpecificParam: Value, optional_args: &[Value]) -> Value {
7904 let mut params = get_arg(optional_args, 0, Value::Map({
7905 let mut m = indexmap::IndexMap::new();
7906 m
7907}));
7908 let mut timeInForce: Option<String> = self.safe_string_upper_k_opt(params.clone(), "timeInForce", &[]);
7917 let mut ioc: bool = timeInForce.as_deref() == Some("IOC");
7919 let mut fok: bool = timeInForce.as_deref() == Some("FOK");
7920 let mut timeInForcePostOnly: bool = timeInForce.as_deref() == Some("PO");
7921 let mut postOnly: bool = self.safe_bool2(params, Value::Str("postOnly".into()), Value::Str("post_only".into()), &[Value::Bool(false)]).as_bool() == Some(true) || timeInForcePostOnly || is_true(&exchangeSpecificParam);
7922 if postOnly {
7923 if ioc || fok {
7924 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.map(Value::from).unwrap_or(Value::Null))));
7925 } else if isMarketOrder.as_bool() == Some(true) {
7926 panic!("{}", crate::exchange_errors::invalid_order(format!("{}{}", self.id.clone(), Value::Str(" market orders cannot be postOnly".into()))));
7927 } else {
7928 return Value::Bool(true);
7929 }
7930 } else {
7931 return Value::Bool(false);
7932 }
7933
7934 Value::Null
7935}
7936
7937 fn handle_post_only(&self, mut isMarketOrder: Value, mut exchangeSpecificPostOnlyOption: Value, optional_args: &[Value]) -> Value {
7938 let mut params = get_arg(optional_args, 0, Value::Map({
7939 let mut m = indexmap::IndexMap::new();
7940 m
7941}));
7942 let mut timeInForce: Option<String> = self.safe_string_upper_k_opt(params.clone(), "timeInForce", &[]);
7951 let mut ioc: bool = timeInForce.as_deref() == Some("IOC");
7952 let mut fok: bool = timeInForce.as_deref() == Some("FOK");
7953 let mut po: bool = timeInForce.as_deref() == Some("PO");
7954 let mut postOnly: bool = self.safe_bool_k(params.clone(), "postOnly", &[Value::Bool(false)]).as_bool() == Some(true) || po || is_true(&exchangeSpecificPostOnlyOption);
7955 if postOnly {
7956 if ioc || fok {
7957 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.map(Value::from).unwrap_or(Value::Null))));
7958 } else if isMarketOrder.as_bool() == Some(true) {
7959 panic!("{}", crate::exchange_errors::invalid_order(format!("{}{}", self.id.clone(), Value::Str(" market orders cannot be postOnly".into()))));
7960 } else {
7961 let mut keysToOmit: Value = Value::from(vec![]);
7962 if po {
7963 keysToOmit = Value::from(vec![Value::Str("timeInForce".into()), Value::Str("postOnly".into())]);
7964 } else {
7965 keysToOmit = Value::from(vec![Value::Str("postOnly".into())]);
7966 }
7967 let mut paramsOmitted: Value = self.omit(params.clone(), keysToOmit, &[]);
7968 return Value::from(vec![Value::Bool(true), paramsOmitted]);
7969 }
7970 }
7971 return Value::from(vec![Value::Bool(false), params]);
7972
7973 Value::Null
7974}
7975
7976 fn fetch_last_prices(&mut self, optional_args: &[Value]) -> impl ::std::future::Future<Output = Value> + Send { async move {
7977 let mut symbols = get_arg(optional_args, 0, Value::Null);
7978 let mut params = get_arg(optional_args, 1, Value::Map({
7979 let mut m = indexmap::IndexMap::new();
7980 m
7981}));
7982 panic!("{}", crate::exchange_errors::not_supported(format!("{}{}", self.id.clone(), Value::Str(" fetchLastPrices() is not supported yet".into()))));
7983
7984 Value::Null
7985} }
7986
7987 fn fetch_trading_fees(&mut self, optional_args: &[Value]) -> impl ::std::future::Future<Output = Value> + Send { async move {
7988 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 {
7990 if !matches!(__v, crate::Value::Null) { return __v; }
7991 }
7992
7993 let mut params = get_arg(optional_args, 0, Value::Map({
7994 let mut m = indexmap::IndexMap::new();
7995 m
7996}));
7997 panic!("{}", crate::exchange_errors::not_supported(format!("{}{}", self.id.clone(), Value::Str(" fetchTradingFees() is not supported yet".into()))));
7998
7999 Value::Null
8000} }
8001
8002 fn fetch_trading_fees_ws(&mut self, optional_args: &[Value]) -> impl ::std::future::Future<Output = Value> + Send { async move {
8003 let mut params = get_arg(optional_args, 0, Value::Map({
8004 let mut m = indexmap::IndexMap::new();
8005 m
8006}));
8007 panic!("{}", crate::exchange_errors::not_supported(format!("{}{}", self.id.clone(), Value::Str(" fetchTradingFeesWs() is not supported yet".into()))));
8008
8009 Value::Null
8010} }
8011
8012 fn fetch_convert_currencies(&mut self, optional_args: &[Value]) -> impl ::std::future::Future<Output = Value> + Send { async move {
8013 let mut params = get_arg(optional_args, 0, Value::Map({
8014 let mut m = indexmap::IndexMap::new();
8015 m
8016}));
8017 panic!("{}", crate::exchange_errors::not_supported(format!("{}{}", self.id.clone(), Value::Str(" fetchConvertCurrencies() is not supported yet".into()))));
8018
8019 Value::Null
8020} }
8021
8022 fn parse_open_interest(&self, mut interest: Value, optional_args: &[Value]) -> Value {
8023 { 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; } }
8025
8026 let mut market = get_arg(optional_args, 0, Value::Null);
8027 panic!("{}", crate::exchange_errors::not_supported(format!("{}{}", self.id.clone(), Value::Str(" parseOpenInterest () is not supported yet".into()))));
8028
8029 Value::Null
8030}
8031
8032 fn parse_open_interests(&self, mut response: Value, optional_args: &[Value]) -> Value {
8033 let mut symbols = get_arg(optional_args, 0, Value::Null);
8034 let mut result: indexmap::IndexMap<String, Value> = ({
8035 let mut m = indexmap::IndexMap::new();
8036 m
8037 });
8038 {
8039 let mut i: Value = Value::Int(0);
8040 let mut __for_first_156: bool = true;
8041 while { if !__for_first_156 { if let Value::Int(n) = &mut i { *n += 1; } } __for_first_156 = false; i.as_f64().unwrap_or(f64::NAN) < get_array_length(&response).as_f64().unwrap_or(f64::NAN) } {
8042 let mut entry: Value = get_value(&response, &i);
8043 let mut parsed: Value = <Self as crate::exchange_generated::ExchangeBase>::parse_open_interest(self, entry, &[]);
8044 if (parsed.as_map().and_then(|__m| __m.get("symbol")).cloned().unwrap_or(Value::Null) != Value::Null) {
8045 result.insert(crate::runtime::stringify_param(&(parsed.as_map().and_then(|__m| __m.get("symbol")).cloned().unwrap_or(Value::Null))), parsed);
8046 }
8047 }
8048 }
8049 return self.index_by(self.filter_by_array(Value::Map(result), Value::Str("symbol".into()), &[symbols, Value::Bool(false)]), Value::Str("symbol".into()));
8050
8051 Value::Null
8052}
8053
8054 fn parse_open_interests_history(&self, mut response: Value, optional_args: &[Value]) -> Value {
8055 let mut market = get_arg(optional_args, 0, Value::Null);
8056 let mut since = get_arg(optional_args, 1, Value::Null);
8057 let mut limit = get_arg(optional_args, 2, Value::Null);
8058 let mut interests: Vec<Value> = Vec::new();
8059 {
8060 let mut i: Value = Value::Int(0);
8061 let mut __for_first_157: bool = true;
8062 while { if !__for_first_157 { if let Value::Int(n) = &mut i { *n += 1; } } __for_first_157 = false; i.as_f64().unwrap_or(f64::NAN) < get_array_length(&response).as_f64().unwrap_or(f64::NAN) } {
8063 let mut entry: Value = get_value(&response, &i);
8064 let mut interest: Value = <Self as crate::exchange_generated::ExchangeBase>::parse_open_interest(self, entry, &[market.clone()]);
8065 interests.push(interest);
8066 }
8067 }
8068 let mut sorted: Value = self.sort_by(Value::from(interests), Value::Str("timestamp".into()), &[]);
8069 let mut symbol: Option<String> = self.safe_string_k_opt(market, "symbol", &[]);
8070 return self.filter_by_symbol_since_limit(sorted, &[symbol.map(Value::from).unwrap_or(Value::Null), since, limit]);
8071
8072 Value::Null
8073}
8074
8075 fn fetch_funding_rate(&mut self, mut symbol: Value, optional_args: &[Value]) -> impl ::std::future::Future<Output = Value> + Send { async move {
8076 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 {
8078 if !matches!(__v, crate::Value::Null) { return __v; }
8079 }
8080
8081 let mut params = get_arg(optional_args, 0, Value::Map({
8082 let mut m = indexmap::IndexMap::new();
8083 m
8084}));
8085 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)) {
8086 self.load_markets(&[]).await;
8087 let mut market: Value = <Self as crate::exchange_generated::ExchangeBase>::market(self, symbol);
8088 let mut symbolResolved: Value = market.as_map().and_then(|__m| __m.get("symbol")).cloned().unwrap_or(Value::Null);
8089 if !matches!(self.safe_bool_k(market, "contract", &[Value::Bool(false)]), Value::Bool(true)) {
8090 panic!("{}", crate::exchange_errors::bad_symbol(format!("{}{}", self.id.clone(), Value::Str(" fetchFundingRate() supports contract markets only".into()))));
8091 }
8092 let mut rates: Value = self.fetch_funding_rates(&[Value::from(vec![symbolResolved.clone()]), params]).await;
8093 let mut rate: Value = self.safe_dict(rates, symbolResolved.clone(), &[]);
8094 if (rate == Value::Null) {
8095 panic!("{}", crate::exchange_errors::null_response(format!("{}{}", Value::Str(format!("{}{}", self.id.clone(), Value::Str(" fetchFundingRate () returned no data for ".into())).into()), symbolResolved)));
8096 } else {
8097 return rate;
8098 }
8099 } else {
8100 panic!("{}", crate::exchange_errors::not_supported(format!("{}{}", self.id.clone(), Value::Str(" fetchFundingRate () is not supported yet".into()))));
8101 }
8102
8103 Value::Null
8104} }
8105
8106 fn fetch_funding_interval(&mut self, mut symbol: Value, optional_args: &[Value]) -> impl ::std::future::Future<Output = Value> + Send { async move {
8107 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 {
8109 if !matches!(__v, crate::Value::Null) { return __v; }
8110 }
8111
8112 let mut params = get_arg(optional_args, 0, Value::Map({
8113 let mut m = indexmap::IndexMap::new();
8114 m
8115}));
8116 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)) {
8117 self.load_markets(&[]).await;
8118 let mut market: Value = <Self as crate::exchange_generated::ExchangeBase>::market(self, symbol);
8119 let mut symbolResolved: Value = market.as_map().and_then(|__m| __m.get("symbol")).cloned().unwrap_or(Value::Null);
8120 if !matches!(self.safe_bool_k(market, "contract", &[Value::Bool(false)]), Value::Bool(true)) {
8121 panic!("{}", crate::exchange_errors::bad_symbol(format!("{}{}", self.id.clone(), Value::Str(" fetchFundingInterval() supports contract markets only".into()))));
8122 }
8123 let mut rates: Value = self.fetch_funding_intervals(&[Value::from(vec![symbolResolved.clone()]), params]).await;
8124 let mut rate: Value = self.safe_dict(rates, symbolResolved.clone(), &[]);
8125 if (rate == Value::Null) {
8126 panic!("{}", crate::exchange_errors::null_response(format!("{}{}", Value::Str(format!("{}{}", self.id.clone(), Value::Str(" fetchFundingInterval() returned no data for ".into())).into()), symbolResolved)));
8127 } else {
8128 return rate;
8129 }
8130 } else {
8131 panic!("{}", crate::exchange_errors::not_supported(format!("{}{}", self.id.clone(), Value::Str(" fetchFundingInterval() is not supported yet".into()))));
8132 }
8133
8134 Value::Null
8135} }
8136
8137 fn fetch_mark_ohlcv(&mut self, mut symbol: Value, optional_args: &[Value]) -> impl ::std::future::Future<Output = Value> + Send { async move {
8138 let mut timeframe = get_arg(optional_args, 0, Value::Str("1m".into()));
8139 let mut since = get_arg(optional_args, 1, Value::Null);
8140 let mut limit = get_arg(optional_args, 2, Value::Null);
8141 let mut params = get_arg(optional_args, 3, Value::Map({
8142 let mut m = indexmap::IndexMap::new();
8143 m
8144}));
8145 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)) {
8157 let mut request: indexmap::IndexMap<String, Value> = ({
8158 let mut m = indexmap::IndexMap::new();
8159 m.insert("price".to_string(), Value::Str("mark".into()));
8160 m
8161 });
8162 return self.fetch_ohlcv(symbol, &[timeframe, since, limit, self.extend(Value::Map(request), &[params])]).await;
8163 } else {
8164 panic!("{}", crate::exchange_errors::not_supported(format!("{}{}", self.id.clone(), Value::Str(" fetchMarkOHLCV () is not supported yet".into()))));
8165 }
8166} }
8167
8168 fn fetch_index_ohlcv(&mut self, mut symbol: Value, optional_args: &[Value]) -> impl ::std::future::Future<Output = Value> + Send { async move {
8169 let mut timeframe = get_arg(optional_args, 0, Value::Str("1m".into()));
8170 let mut since = get_arg(optional_args, 1, Value::Null);
8171 let mut limit = get_arg(optional_args, 2, Value::Null);
8172 let mut params = get_arg(optional_args, 3, Value::Map({
8173 let mut m = indexmap::IndexMap::new();
8174 m
8175}));
8176 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)) {
8188 let mut request: indexmap::IndexMap<String, Value> = ({
8189 let mut m = indexmap::IndexMap::new();
8190 m.insert("price".to_string(), Value::Str("index".into()));
8191 m
8192 });
8193 return self.fetch_ohlcv(symbol, &[timeframe, since, limit, self.extend(Value::Map(request), &[params])]).await;
8194 } else {
8195 panic!("{}", crate::exchange_errors::not_supported(format!("{}{}", self.id.clone(), Value::Str(" fetchIndexOHLCV () is not supported yet".into()))));
8196 }
8197} }
8198
8199 fn fetch_premium_index_ohlcv(&mut self, mut symbol: Value, optional_args: &[Value]) -> impl ::std::future::Future<Output = Value> + Send { async move {
8200 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 {
8202 if !matches!(__v, crate::Value::Null) { return __v; }
8203 }
8204
8205 let mut timeframe = get_arg(optional_args, 0, Value::Str("1m".into()));
8206 let mut since = get_arg(optional_args, 1, Value::Null);
8207 let mut limit = get_arg(optional_args, 2, Value::Null);
8208 let mut params = get_arg(optional_args, 3, Value::Map({
8209 let mut m = indexmap::IndexMap::new();
8210 m
8211}));
8212 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)) {
8224 let mut request: indexmap::IndexMap<String, Value> = ({
8225 let mut m = indexmap::IndexMap::new();
8226 m.insert("price".to_string(), Value::Str("premiumIndex".into()));
8227 m
8228 });
8229 return self.fetch_ohlcv(symbol, &[timeframe, since, limit, self.extend(Value::Map(request), &[params])]).await;
8230 } else {
8231 panic!("{}", crate::exchange_errors::not_supported(format!("{}{}", self.id.clone(), Value::Str(" fetchPremiumIndexOHLCV () is not supported yet".into()))));
8232 }
8233} }
8234
8235 fn handle_time_in_force(&self, optional_args: &[Value]) -> Value {
8236 let mut params = get_arg(optional_args, 0, Value::Map({
8237 let mut m = indexmap::IndexMap::new();
8238 m
8239}));
8240 let mut timeInForce: Option<String> = self.safe_string_upper_k_opt(params, "timeInForce", &[]); if (timeInForce.is_some()) {
8248 let mut exchangeValue: Value = self.safe_string(self.options.as_map().and_then(|__m| __m.get("timeInForce")).cloned().unwrap_or(Value::Null), timeInForce.clone().map(Value::from).unwrap_or(Value::Null), &[]);
8249 if (exchangeValue == Value::Null) {
8250 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.map(Value::from).unwrap_or(Value::Null)).into()), Value::Str("\"".into()))));
8251 }
8252 return exchangeValue;
8253 }
8254 return Value::Null;
8255
8256 Value::Null
8257}
8258
8259 fn convert_type_to_account(&self, mut account: Value) -> Value {
8260 let mut accountsByType: Value = self.safe_dict_k(self.options.clone(), "accountsByType", &[Value::Map({
8268 let mut m = indexmap::IndexMap::new();
8269 m
8270})]);
8271 let mut lowercaseAccount: Value = (if let Some(__s) = (account).as_str() { Value::Str(__s.to_lowercase().into()) } else { Value::Null });
8272 if (matches!((&accountsByType, &lowercaseAccount), (Value::Dict(__d), Value::Str(__k)) if __d.contains_key(__k.as_ref()))) {
8273 return (if let (Some(__m), Some(__k)) = (accountsByType.as_map(), lowercaseAccount.as_str()) { __m.get(__k).cloned().unwrap_or(Value::Null) } else { Value::Null });
8274 }
8275 let mut markets: Value = self.markets.clone();
8276 let mut marketsById: Value = self.markets_by_id.clone();
8277 if ((markets != Value::Null) && (matches!((&markets, &account), (Value::Dict(__d), Value::Str(__k)) if __d.contains_key(__k.as_ref())))) || ((marketsById != Value::Null) && (matches!((&marketsById, &account), (Value::Dict(__d), Value::Str(__k)) if __d.contains_key(__k.as_ref())))) {
8278 let mut market: indexmap::IndexMap<String, Value> = <Self as crate::exchange_generated::ExchangeBase>::market(self, account.clone()).as_map().cloned().unwrap_or_default();
8279 return market.get("id").cloned().unwrap_or(Value::Null);
8280 } else {
8281 return account;
8282 }
8283
8284 Value::Null
8285}
8286
8287 fn check_required_argument(&self, mut methodName: Value, mut argument: Value, mut argumentName: Value, optional_args: &[Value]) {
8288 let mut options = get_arg(optional_args, 0, Value::from(vec![]));
8289 let mut optionsLength: f64 = ((options.len() as i64) as f64);
8299 if (argument == Value::Null) || ((optionsLength > ((0i64) as f64)) && (!(self.in_array(argument, options.clone()).as_bool() == Some(true)))) {
8300 let mut messageOptions: Value = Value::Str(options.as_array().map(|__a| __a.iter().map(|__v| __v.to_string()).collect::<Vec<String>>().join(", ")).unwrap_or_default().into());
8301 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());
8302 if (!matches!(&messageOptions, Value::Str(__s15) if __s15 == "")) {
8303 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());
8304 }
8305 panic!("{}", crate::exchange_errors::arguments_required(message));
8306 }
8307}
8308
8309 fn check_required_margin_argument(&self, mut methodName: Value, mut symbol: Value, mut marginMode: Value) {
8310 if (marginMode.as_str() == Some("isolated")) && (symbol == Value::Null) {
8318 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()))));
8319 } else if (marginMode.as_str() == Some("cross")) && (symbol != Value::Null) {
8320 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()))));
8321 }
8322}
8323
8324 fn parse_deposit_withdraw_fees(&self, mut response: Value, optional_args: &[Value]) -> Value {
8325 let mut codes = get_arg(optional_args, 0, Value::Null);
8326 let mut currencyIdKey = get_arg(optional_args, 1, Value::Null);
8327 let mut depositWithdrawFees: indexmap::IndexMap<String, Value> = ({
8336 let mut m = indexmap::IndexMap::new();
8337 m
8338 });
8339 let mut isArray: bool = matches!(&response, Value::Arr(_));
8340 let mut responseKeys: Value = response.clone();
8341 if !(isArray) {
8342 responseKeys = object_keys(&response);
8343 }
8344 {
8345 let mut i: Value = Value::Int(0);
8346 let mut __for_first_158: bool = true;
8347 while { if !__for_first_158 { if let Value::Int(n) = &mut i { *n += 1; } } __for_first_158 = false; i.as_f64().unwrap_or(f64::NAN) < get_array_length(&responseKeys).as_f64().unwrap_or(f64::NAN) } {
8348 let mut entry: Value = get_value(&responseKeys, &i);
8349 let mut dictionary: Value = (if isArray { entry.clone() } else { get_value(&response, &entry) });
8350 let mut currencyId: Value = entry;
8351 if isArray {
8352 currencyId = (if (currencyIdKey == Value::Null) { Value::Null } else { self.safe_string(dictionary.clone(), currencyIdKey.clone(), &[]) });
8353 }
8354 let mut currency: Value = self.safe_currency(currencyId, &[]);
8355 let mut code: Option<String> = self.safe_string_k_opt(currency.clone(), "code", &[]);
8356 if (codes == Value::Null) || self.in_array(code.clone().map(Value::from).unwrap_or(Value::Null), codes.clone()).as_bool() == Some(true) {
8357 depositWithdrawFees.insert(code.as_deref().unwrap_or("null").to_string(), <Self as crate::exchange_generated::ExchangeBase>::parse_deposit_withdraw_fee(self, dictionary, &[currency]));
8358 }
8359 }
8360 }
8361 return Value::Map(depositWithdrawFees);
8362
8363 Value::Null
8364}
8365
8366 fn parse_deposit_withdraw_fee(&self, mut fee: Value, optional_args: &[Value]) -> Value {
8367 { 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; } }
8369
8370 let mut currency = get_arg(optional_args, 0, Value::Null);
8371 panic!("{}", crate::exchange_errors::not_supported(format!("{}{}", self.id.clone(), Value::Str(" parseDepositWithdrawFee() is not supported yet".into()))));
8372
8373 Value::Null
8374}
8375
8376 fn deposit_withdraw_fee(&self, mut info: Value) -> Value {
8377 return Value::Map({
8378 let mut m = indexmap::IndexMap::new();
8379 m.insert("info".to_string(), info);
8380 m.insert("withdraw".to_string(), Value::Map({
8381 let mut m = indexmap::IndexMap::new();
8382 m.insert("fee".to_string(), Value::Null);
8383 m.insert("percentage".to_string(), Value::Null);
8384 m
8385}));
8386 m.insert("deposit".to_string(), Value::Map({
8387 let mut m = indexmap::IndexMap::new();
8388 m.insert("fee".to_string(), Value::Null);
8389 m.insert("percentage".to_string(), Value::Null);
8390 m
8391}));
8392 m.insert("networks".to_string(), Value::Map({
8393 let mut m = indexmap::IndexMap::new();
8394 m
8395}));
8396 m
8397});
8398
8399 Value::Null
8400}
8401
8402 fn assign_default_deposit_withdraw_fees(&self, mut fee: Value, optional_args: &[Value]) -> Value {
8403 let mut currency = get_arg(optional_args, 0, Value::Null);
8404 let __currency_empty = indexmap::IndexMap::new();
8405 let currency = currency.as_map().unwrap_or(&__currency_empty);
8406 let mut networkKeys: Vec<Value> = object_keys(&fee.as_map().and_then(|__m| __m.get("networks")).cloned().unwrap_or(Value::Null)).as_array().cloned().unwrap_or_default();
8415 let mut numNetworks: f64 = ((networkKeys.len() as i64) as f64);
8416 if (numNetworks == 1.0) {
8417 { let __be_tmp = crate::value::get_value_k(&get_value(&crate::value::get_value_k(&fee, "networks"), &networkKeys.get(0).cloned().unwrap_or(Value::Null)), "withdraw"); if let Value::Dict(__d) = &mut fee { std::sync::Arc::make_mut(__d).insert("withdraw".into(), __be_tmp); } }
8418 { let __be_tmp = crate::value::get_value_k(&get_value(&crate::value::get_value_k(&fee, "networks"), &networkKeys.get(0).cloned().unwrap_or(Value::Null)), "deposit"); if let Value::Dict(__d) = &mut fee { std::sync::Arc::make_mut(__d).insert("deposit".into(), __be_tmp); } }
8419 return fee;
8420 }
8421 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 });
8422 {
8423 let mut i: Value = Value::Int(0);
8424 let mut __for_first_159: bool = true;
8425 while { if !__for_first_159 { if let Value::Int(n) = &mut i { *n += 1; } } __for_first_159 = false; i.as_f64().unwrap_or(f64::NAN) < numNetworks } {
8426 let mut network: Value = networkKeys.get(i.as_i64().unwrap_or(-1) as usize).cloned().unwrap_or(Value::Null);
8427 if (network.as_str() == currencyCode.as_str()) {
8428 { let __be_tmp = crate::value::get_value_k(&get_value(&crate::value::get_value_k(&fee, "networks"), &networkKeys.get(i.as_i64().unwrap_or(-1) as usize).cloned().unwrap_or(Value::Null)), "withdraw"); if let Value::Dict(__d) = &mut fee { std::sync::Arc::make_mut(__d).insert("withdraw".into(), __be_tmp); } }
8429 { let __be_tmp = crate::value::get_value_k(&get_value(&crate::value::get_value_k(&fee, "networks"), &networkKeys.get(i.as_i64().unwrap_or(-1) as usize).cloned().unwrap_or(Value::Null)), "deposit"); if let Value::Dict(__d) = &mut fee { std::sync::Arc::make_mut(__d).insert("deposit".into(), __be_tmp); } }
8430 }
8431 }
8432 }
8433 return fee;
8434
8435 Value::Null
8436}
8437
8438 fn parse_income(&self, mut info: Value, optional_args: &[Value]) -> Value {
8439 { 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; } }
8441
8442 let mut market = get_arg(optional_args, 0, Value::Null);
8443 panic!("{}", crate::exchange_errors::not_supported(format!("{}{}", self.id.clone(), Value::Str(" parseIncome () is not supported yet".into()))));
8444
8445 Value::Null
8446}
8447
8448 fn parse_incomes(&self, mut incomes: Value, optional_args: &[Value]) -> Value {
8449 let mut market = get_arg(optional_args, 0, Value::Null);
8450 let mut since = get_arg(optional_args, 1, Value::Null);
8451 let mut limit = get_arg(optional_args, 2, Value::Null);
8452 let mut result: Vec<Value> = Vec::new();
8463 {
8464 let mut i: Value = Value::Int(0);
8465 let mut __for_first_160: bool = true;
8466 while { if !__for_first_160 { if let Value::Int(n) = &mut i { *n += 1; } } __for_first_160 = false; i.as_f64().unwrap_or(f64::NAN) < get_array_length(&incomes).as_f64().unwrap_or(f64::NAN) } {
8467 let mut entry: Value = get_value(&incomes, &i);
8468 let mut parsed: Value = <Self as crate::exchange_generated::ExchangeBase>::parse_income(self, entry, &[market.clone()]);
8469 result.push(parsed);
8470 }
8471 }
8472 let mut sorted: Value = self.sort_by(Value::from(result), Value::Str("timestamp".into()), &[]);
8473 let mut symbol: Option<String> = self.safe_string_k_opt(market, "symbol", &[]);
8474 return self.filter_by_symbol_since_limit(sorted, &[symbol.map(Value::from).unwrap_or(Value::Null), since, limit]);
8475
8476 Value::Null
8477}
8478
8479 fn get_market_from_symbols(&self, optional_args: &[Value]) -> Value {
8480 let mut symbols = get_arg(optional_args, 0, Value::Null);
8481 if (symbols == Value::Null) {
8487 return Value::Null;
8488 }
8489 let mut firstMarket: Option<String> = self.safe_string_opt(symbols, Value::Int(0), &[]);
8490 if (firstMarket.is_none()) {
8491 return Value::Null;
8492 }
8493 let mut market: Value = <Self as crate::exchange_generated::ExchangeBase>::market(self, firstMarket.map(Value::from).unwrap_or(Value::Null));
8494 return market;
8495
8496 Value::Null
8497}
8498
8499 fn parse_ws_ohlc_vs(&self, mut ohlcvs: Value, optional_args: &[Value]) -> Value {
8500 let mut market = get_arg(optional_args, 0, Value::Null);
8501 let mut timeframe = get_arg(optional_args, 1, Value::Str("1m".into()));
8502 let mut since = get_arg(optional_args, 2, Value::Null);
8503 let mut limit = get_arg(optional_args, 3, Value::Null);
8504 let mut results: Vec<Value> = Vec::new();
8505 {
8506 let mut i: i64 = 0;
8507 let mut __for_first_161: bool = true;
8508 while { if !__for_first_161 { i += 1; } __for_first_161 = false; i < (ohlcvs.len() as i64) } {
8509 results.push(self.parse_ws_ohlcv(self.safe_value(ohlcvs.clone(), Value::Int(i), &[]), &[market.clone()]));
8510 }
8511 }
8512 return Value::from(results);
8513
8514 Value::Null
8515}
8516
8517 fn fetch_transactions(&mut self, optional_args: &[Value]) -> impl ::std::future::Future<Output = Value> + Send { async move {
8518 let mut code = get_arg(optional_args, 0, Value::Null);
8519 let mut since = get_arg(optional_args, 1, Value::Null);
8520 let mut limit = get_arg(optional_args, 2, Value::Null);
8521 let mut params = get_arg(optional_args, 3, Value::Map({
8522 let mut m = indexmap::IndexMap::new();
8523 m
8524}));
8525 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)) {
8537 return self.fetch_deposits_withdrawals(&[code, since, limit, params]).await;
8538 } else {
8539 panic!("{}", crate::exchange_errors::not_supported(format!("{}{}", self.id.clone(), Value::Str(" fetchTransactions () is not supported yet".into()))));
8540 }
8541} }
8542
8543 fn filter_by_array_positions(&self, mut objects: Value, mut key: Value, optional_args: &[Value]) -> Value {
8544 let mut values = get_arg(optional_args, 0, Value::Null);
8545 return self.to_array(self.filter_by_array(objects, key, &[values, Value::Bool(false)]));
8546
8547 Value::Null
8548}
8549
8550 fn filter_by_array_tickers(&self, mut objects: Value, mut key: Value, optional_args: &[Value]) -> Value {
8551 let mut values = get_arg(optional_args, 0, Value::Null);
8552 return self.index_by(self.filter_by_array(objects, key.clone(), &[values, Value::Bool(false)]), key);
8553
8554 Value::Null
8555}
8556
8557 fn filter_by_array_adl_ranks(&self, mut objects: Value, mut key: Value, optional_args: &[Value]) -> Value {
8558 let mut values = get_arg(optional_args, 0, Value::Null);
8559 let mut indexed = get_arg(optional_args, 1, Value::Bool(true));
8560 return self.to_array(self.filter_by_array(objects, key, &[values, indexed]));
8561
8562 Value::Null
8563}
8564
8565 fn create_ohlcv_object(&self, mut symbol: Value, mut timeframe: Value, mut data: Value) -> Value {
8566 let mut res: Value = Value::Map({
8567 let mut m = indexmap::IndexMap::new();
8568 m
8569 });
8570 if let Value::Dict(__d) = &mut res { std::sync::Arc::make_mut(__d).insert(crate::runtime::stringify_param(&symbol), Value::Map({
8571 let mut m = indexmap::IndexMap::new();
8572 m
8573})); }
8574 add_element_to_object(get_value_mut(&mut res, &symbol), &timeframe, data);
8575 return res;
8576
8577 Value::Null
8578}
8579
8580 fn handle_max_entries_per_request_and_params(&self, mut method: Value, optional_args: &[Value]) -> Value {
8581 let mut maxEntriesPerRequest = get_arg(optional_args, 0, Value::Null);
8582 let mut params = get_arg(optional_args, 1, Value::Map({
8583 let mut m = indexmap::IndexMap::new();
8584 m
8585}));
8586 let newMaxEntriesPerRequestparamsMaxEntriesPerRequestVariable: Vec<Value> = self.handle_option_integer_and_params(params, method, Value::Str("maxEntriesPerRequest".into()), &[]).as_array().cloned().unwrap_or_default();
8587 let mut newMaxEntriesPerRequest: Value = newMaxEntriesPerRequestparamsMaxEntriesPerRequestVariable.get(0).cloned().unwrap_or(Value::Null);
8588 let mut paramsMaxEntriesPerRequest: Value = newMaxEntriesPerRequestparamsMaxEntriesPerRequestVariable.get(1).cloned().unwrap_or(Value::Null);
8589 let mut maxEntriesPerRequestOption: Value = (if (newMaxEntriesPerRequest != Value::Null) { newMaxEntriesPerRequest } else { maxEntriesPerRequest });
8590 let mut maxEntriesPerRequestResolved: Value = (if (maxEntriesPerRequestOption == Value::Null) { Value::Int(1000) } else { maxEntriesPerRequestOption }); return Value::from(vec![maxEntriesPerRequestResolved, paramsMaxEntriesPerRequest]);
8592
8593 Value::Null
8594}
8595
8596 fn fetch_paginated_call_dynamic(&mut self, mut method: Value, optional_args: &[Value]) -> impl ::std::future::Future<Output = Value> + Send { async move {
8597 let mut symbol = get_arg(optional_args, 0, Value::Null);
8598 let mut since = get_arg(optional_args, 1, Value::Null);
8599 let mut limit = get_arg(optional_args, 2, Value::Null);
8600 let mut params = get_arg(optional_args, 3, Value::Map({
8601 let mut m = indexmap::IndexMap::new();
8602 m
8603}));
8604 let mut maxEntriesPerRequest = get_arg(optional_args, 4, Value::Null);
8605 let mut removeRepeated = get_arg(optional_args, 5, Value::Bool(true));
8606 let maxCallsPaginationCallsparamsPaginationCallsVariable: Vec<Value> = self.handle_option_integer_and_params(params, method.clone(), Value::Str("paginationCalls".into()), &[Value::Int(10)]).as_array().cloned().unwrap_or_default();
8607 let mut maxCallsPaginationCalls: Value = maxCallsPaginationCallsparamsPaginationCallsVariable.get(0).cloned().unwrap_or(Value::Null);
8608 let mut paramsPaginationCalls: Value = maxCallsPaginationCallsparamsPaginationCallsVariable.get(1).cloned().unwrap_or(Value::Null);
8609 let maxRetriesOptionparamsMaxRetriesVariable: Vec<Value> = self.handle_option_integer_and_params(paramsPaginationCalls, method.clone(), Value::Str("maxRetries".into()), &[Value::Int(3)]).as_array().cloned().unwrap_or_default();
8610 let mut maxRetriesOption: Value = maxRetriesOptionparamsMaxRetriesVariable.get(0).cloned().unwrap_or(Value::Null);
8611 let mut paramsMaxRetries: Value = maxRetriesOptionparamsMaxRetriesVariable.get(1).cloned().unwrap_or(Value::Null);
8612 let removeRepeatedOptionparamsRemoveRepeatedVariable: Vec<Value> = self.handle_option_and_params(paramsMaxRetries, method.clone(), Value::Str("removeRepeated".into()), &[removeRepeated]).as_array().cloned().unwrap_or_default();
8613 let mut removeRepeatedOption: Value = removeRepeatedOptionparamsRemoveRepeatedVariable.get(0).cloned().unwrap_or(Value::Null);
8614 let mut paramsRemoveRepeated: Value = removeRepeatedOptionparamsRemoveRepeatedVariable.get(1).cloned().unwrap_or(Value::Null);
8615 let paginationDirectionparamsPaginationDirectionVariable: Vec<Value> = self.handle_option_string_and_params(paramsRemoveRepeated, method.clone(), Value::Str("paginationDirection".into()), &[Value::Str("backward".into())]).as_array().cloned().unwrap_or_default();
8616 let mut paginationDirection: Value = paginationDirectionparamsPaginationDirectionVariable.get(0).cloned().unwrap_or(Value::Null);
8617 let mut paramsPaginationDirection: Value = paginationDirectionparamsPaginationDirectionVariable.get(1).cloned().unwrap_or(Value::Null);
8618 let mut paginationTimestamp: Value = Value::Null;
8619 let mut result: Value = Value::from(vec![]);
8620 let mut errors: Value = Value::Int(0);
8621 let mut until: Value = self.safe_integer_n(paramsPaginationDirection.clone(), Value::from(vec![Value::Str("until".into()), Value::Str("untill".into()), Value::Str("till".into())]), &[]); let maxEntriesPerRequestOptionparamsMaxEntriesPerRequestVariable: Vec<Value> = self.handle_max_entries_per_request_and_params(method.clone(), &[maxEntriesPerRequest, paramsPaginationDirection]).as_array().cloned().unwrap_or_default();
8623 let mut maxEntriesPerRequestOption: Value = maxEntriesPerRequestOptionparamsMaxEntriesPerRequestVariable.get(0).cloned().unwrap_or(Value::Null);
8624 let mut paramsMaxEntriesPerRequest: Value = maxEntriesPerRequestOptionparamsMaxEntriesPerRequestVariable.get(1).cloned().unwrap_or(Value::Null);
8625 if (paginationDirection.as_str() == Some("forward")) {
8626 if (since == Value::Null) {
8627 panic!("{}", crate::exchange_errors::arguments_required(format!("{}{}", self.id.clone(), Value::Str(" pagination requires a since argument when paginationDirection set to forward".into()))));
8628 }
8629 paginationTimestamp = since.clone();
8630 }
8631 let mut shouldBreak: bool = false;
8632 {
8633 let mut i: Value = Value::Int(0);
8634 let mut __for_first_162: bool = true;
8635 while { if !__for_first_162 { if let Value::Int(n) = &mut i { *n += 1; } } __for_first_162 = false; i.as_f64().unwrap_or(f64::NAN) < maxCallsPaginationCalls.as_f64().unwrap_or(f64::NAN) } {
8636 {
8637 if (paginationDirection.as_str() == Some("backward")) {
8638 if (paginationTimestamp != Value::Null) {
8641 if let Value::Dict(__d) = &mut paramsMaxEntriesPerRequest { std::sync::Arc::make_mut(__d).insert("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),
8642 Value::Int(y)) => Value::Float(*x - *y as f64), (Value::Float(x), Value::Float(y)) => Value::Float(x - y), _ => Value::Null })); }
8643 }
8644 let mut response: Value = self.call_dynamic_checked(method.clone(), vec![(symbol).clone(), (Value::Null).clone(), (maxEntriesPerRequestOption).clone(), (paramsMaxEntriesPerRequest).clone()]).await;
8645 let mut responseLength: Value = get_array_length(&response);
8646 if self.verbose.as_bool() == Some(true) {
8647 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((match (&(i), &(Value::Int(1))) { (Value::Int(x), Value::Int(y)) => Value::Int(x + y),
8648 (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 }))).into()), Value::Str(" method ".into())).into()), method).into()), Value::Str(" response length ".into())).into()),
8649 Value::Str(format!("{}", responseLength).into())).into());
8650 if (paginationTimestamp != Value::Null) {
8651 backwardMessage = Value::Str(format!("{}{}", backwardMessage, Value::Str(format!("{}{}", Value::Str(" timestamp ".into()), self.number_to_string(paginationTimestamp.clone())).into())).into());
8652 }
8653 self.log(backwardMessage);
8654 }
8655 if (responseLength.as_f64() == Some(0.0)) {
8656 shouldBreak = true;
8657 break;
8658 }
8659 errors = Value::Int(0);
8660 result = self.array_concat(result.clone(), response.clone());
8661 let mut firstElement: Value = self.safe_dict(response.clone(), Value::Int(0), &[]);
8662 paginationTimestamp = self.safe_integer2(firstElement, Value::Str("timestamp".into()), Value::Int(0), &[]);
8663 if (paginationTimestamp == Value::Null) {
8664 shouldBreak = true;
8665 break;
8666 }
8667 if (since != Value::Null) && (paginationTimestamp.as_f64().unwrap_or(f64::NAN) <= since.as_f64().unwrap_or(f64::NAN)) {
8668 shouldBreak = true;
8669 break;
8670 }
8671 } else {
8672 let mut response: Value = self.call_dynamic_checked(method.clone(), vec![(symbol).clone(), (paginationTimestamp).clone(), (maxEntriesPerRequestOption).clone(), (paramsMaxEntriesPerRequest).clone()]).await;
8674 let mut responseLength: Value = get_array_length(&response);
8675 if self.verbose.as_bool() == Some(true) {
8676 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((match (&(i), &(Value::Int(1))) { (Value::Int(x), Value::Int(y)) => Value::Int(x + y),
8677 (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 }))).into()), Value::Str(" method ".into())).into()), method).into()), Value::Str(" response length ".into())).into()),
8678 Value::Str(format!("{}", responseLength).into())).into());
8679 if (paginationTimestamp != Value::Null) {
8680 forwardMessage = Value::Str(format!("{}{}", forwardMessage, Value::Str(format!("{}{}", Value::Str(" timestamp ".into()), self.number_to_string(paginationTimestamp.clone())).into())).into());
8681 }
8682 self.log(forwardMessage);
8683 }
8684 if (responseLength.as_f64() == Some(0.0)) {
8685 shouldBreak = true;
8686 break;
8687 }
8688 errors = Value::Int(0);
8689 result = self.array_concat(result.clone(), response.clone());
8690 let mut last: Value = self.safe_dict(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 }), &[]);
8691 let mut lastTimestamp: Value = self.safe_integer_k(last, "timestamp", &[Value::Int(0)]);
8692 if (lastTimestamp == Value::Null) {
8693 shouldBreak = true;
8694 break;
8695 }
8696 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 });
8697 paginationTimestamp = nextPaginationTimestamp.clone();
8698 if (until != Value::Null) && (nextPaginationTimestamp.as_f64().unwrap_or(f64::NAN) >= until.as_f64().unwrap_or(f64::NAN)) {
8699 shouldBreak = true;
8700 break;
8701 }
8702 }
8703 }
8704 if shouldBreak {
8705 break;
8706 }
8707 }
8708 }
8709 let mut uniqueResults: Value = result.clone();
8710 if is_true(&removeRepeatedOption) {
8711 uniqueResults = self.remove_repeated_elements_from_array(result, &[]);
8712 }
8713 let mut key: Value = (if (method.as_str() == Some("fetchOHLCV")) { Value::Int(0) } else { Value::Str("timestamp".into()) });
8714 let mut sortedRes: Value = self.sort_by(uniqueResults, key.clone(), &[]);
8715 return self.filter_by_since_limit(sortedRes, &[since, limit, key]);
8716
8717 Value::Null
8718} }
8719
8720 fn safe_deterministic_call(&mut self, mut method: Value, optional_args: &[Value]) -> impl ::std::future::Future<Output = Value> + Send { async move {
8721 let mut symbol = get_arg(optional_args, 0, Value::Null);
8722 let mut since = get_arg(optional_args, 1, Value::Null);
8723 let mut limit = get_arg(optional_args, 2, Value::Null);
8724 let mut timeframe = get_arg(optional_args, 3, Value::Null);
8725 let mut params = get_arg(optional_args, 4, Value::Map({
8726 let mut m = indexmap::IndexMap::new();
8727 m
8728}));
8729 let mut maxRetries: Value = Value::Int(3);
8730 let maxRetriesOptionparamsMaxRetriesVariable: Vec<Value> = self.handle_option_integer_and_params(params, method.clone(), Value::Str("maxRetries".into()), &[maxRetries]).as_array().cloned().unwrap_or_default();
8731 let mut maxRetriesOption: Value = maxRetriesOptionparamsMaxRetriesVariable.get(0).cloned().unwrap_or(Value::Null);
8732 let mut paramsMaxRetries: Value = maxRetriesOptionparamsMaxRetriesVariable.get(1).cloned().unwrap_or(Value::Null);
8733 let mut errors: Value = Value::Int(0);
8734 while errors.as_f64().unwrap_or(f64::NAN) <= maxRetriesOption.as_f64().unwrap_or(f64::NAN) {
8735 let _try_result = futures::FutureExt::catch_unwind(std::panic::AssertUnwindSafe(async {
8736 if ((timeframe != Value::Null) && (timeframe.as_str() != Some(""))) && (method.as_str() != Some("fetchFundingRateHistory")) {
8737 return self.call_dynamic_checked(method.clone(), vec![(symbol).clone(), (timeframe).clone(), (since).clone(), (limit).clone(), (paramsMaxRetries).clone()]).await;
8738 } else {
8739 return self.call_dynamic_checked(method.clone(), vec![(symbol).clone(), (since).clone(), (limit).clone(), (paramsMaxRetries).clone()]).await;
8740 }
8741 #[allow(unreachable_code)] { Value::Null }})).await;
8742match _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);
8743 if matches!(&e, Value::Str(__s) if __s.contains("[RateLimitExceeded]")) {
8744 panic!("{}", e);
8745 }
8746 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 });
8747 if errors.as_f64().unwrap_or(f64::NAN) > maxRetriesOption.as_f64().unwrap_or(f64::NAN) {
8748 panic!("{}", e);
8749 }
8750 } }
8751 }
8752 return Value::from(vec![]);
8753
8754 Value::Null
8755} }
8756
8757 fn fetch_paginated_call_deterministic(&mut self, mut method: Value, optional_args: &[Value]) -> impl ::std::future::Future<Output = Value> + Send { async move {
8758 let mut symbol = get_arg(optional_args, 0, Value::Null);
8759 let mut since = get_arg(optional_args, 1, Value::Null);
8760 let mut limit = get_arg(optional_args, 2, Value::Null);
8761 let mut timeframe = get_arg(optional_args, 3, Value::Null);
8762 let mut params = get_arg(optional_args, 4, Value::Map({
8763 let mut m = indexmap::IndexMap::new();
8764 m
8765}));
8766 let mut maxEntriesPerRequest = get_arg(optional_args, 5, Value::Null);
8767 let mut maxCalls: Value = Value::Int(10);
8768 let maxCallsPaginationCallsparamsPaginationCallsVariable: Vec<Value> = self.handle_option_integer_and_params(params, method.clone(), Value::Str("paginationCalls".into()), &[maxCalls]).as_array().cloned().unwrap_or_default();
8769 let mut maxCallsPaginationCalls: Value = maxCallsPaginationCallsparamsPaginationCallsVariable.get(0).cloned().unwrap_or(Value::Null);
8770 let mut paramsPaginationCalls: Value = maxCallsPaginationCallsparamsPaginationCallsVariable.get(1).cloned().unwrap_or(Value::Null);
8771 let mut maxCallsLimit: Value = self.parse_to_int(maxCallsPaginationCalls);
8772 let maxEntriesPerRequestOptionparamsMaxEntriesPerRequestVariable: Vec<Value> = self.handle_max_entries_per_request_and_params(method.clone(), &[maxEntriesPerRequest, paramsPaginationCalls]).as_array().cloned().unwrap_or_default();
8773 let mut maxEntriesPerRequestOption: Value = maxEntriesPerRequestOptionparamsMaxEntriesPerRequestVariable.get(0).cloned().unwrap_or(Value::Null);
8774 let mut paramsMaxEntriesPerRequest: Value = maxEntriesPerRequestOptionparamsMaxEntriesPerRequestVariable.get(1).cloned().unwrap_or(Value::Null);
8775 let mut paramsOmitted: Value = self.omit(paramsMaxEntriesPerRequest, Value::Str("paginationDirection".into()), &[]);
8779 let mut current: Value = self.milliseconds();
8780 let mut tasks: Vec<Value> = Vec::new();
8781 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 });
8782 let mut maxEntriesPerRequestValue: Value = self.require_value(maxEntriesPerRequestOption, &[Value::Str("fetchPaginatedCallDeterministic() maxEntriesPerRequest is required".into())]);
8783 let mut step: Value = (match (&(time), &(self.parse_to_int(maxEntriesPerRequestValue.clone()))) { (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 });
8784 let mut until: Value = self.safe_integer2(paramsOmitted.clone(), Value::Str("until".into()), Value::Str("till".into()), &[]); let mut currentSince: Value = (match (&((match (&(current), &(((match (&(maxCallsLimit), &(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),
8786 _ => Value::Null })))) { (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),
8787 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 });
8788 if (since != Value::Null) {
8789 if (until != Value::Null) {
8790 currentSince = since.clone();
8795 } else {
8796 currentSince = crate::runtime::Math::max(¤tSince, &since);
8797 }
8798 } else {
8799 currentSince = crate::runtime::Math::max(¤tSince, &Value::Int(1241440531000)); }
8801 if (until != Value::Null) {
8802 if (since == Value::Null) {
8803 panic!("{}", crate::exchange_errors::arguments_required(format!("{}{}", self.id.clone(), Value::Str(" fetchPaginatedCallDeterministic() requires a since argument when until is set".into()))));
8804 }
8805 let mut requiredCalls: Value = ((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(),
8806 (step).as_f64()) { (Some(x), Some(y)) if y != 0.0 => Value::Float(x / y), _ => Value::Null })).as_f64().map(|__x| Value::Float(__x.ceil())).unwrap_or(Value::Null);
8807 if requiredCalls.as_f64().unwrap_or(f64::NAN) > maxCallsLimit.as_f64().unwrap_or(f64::NAN) {
8808 panic!("{}", crate::exchange_errors::bad_request(format!("{}{}", Value::Str(format!("{}{}", Value::Str(format!("{}{}", Value::Str(format!("{}{}", self.id.clone(),
8809 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()), Value::Str(format!("{}", maxCallsLimit).into())).into()), Value::Str(" required calls is ".into())).into()), Value::Str(format!("{}", requiredCalls).into()))));
8810 }
8811 }
8812 {
8813 let mut i: Value = Value::Int(0);
8814 let mut __for_first_163: bool = true;
8815 while { if !__for_first_163 { if let Value::Int(n) = &mut i { *n += 1; } } __for_first_163 = false; i.as_f64().unwrap_or(f64::NAN) < maxCallsLimit.as_f64().unwrap_or(f64::NAN) } {
8816 if (until != Value::Null) && (currentSince.as_f64().unwrap_or(f64::NAN) >= until.as_f64().unwrap_or(f64::NAN)) {
8817 break;
8818 }
8819 if currentSince.as_f64().unwrap_or(f64::NAN) >= current.as_f64().unwrap_or(f64::NAN) {
8820 break;
8821 }
8822 tasks.push(self.safe_deterministic_call(method.clone(), &[symbol.clone(), currentSince.clone(), maxEntriesPerRequestValue.clone(), timeframe.clone(), paramsOmitted.clone()]).await);
8823 currentSince = (match (&(self.sum(&[currentSince.clone(), step.clone()])), &(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 });
8825 }
8826 }
8827 let mut results: Vec<Value> = promise_all(&Value::from(tasks)).await.as_array().cloned().unwrap_or_default();
8828 let mut result: Value = Value::from(vec![]);
8829 {
8830 let mut i: i64 = 0;
8831 let mut __for_first_164: bool = true;
8832 while { if !__for_first_164 { i += 1; } __for_first_164 = false; i < (results.len() as i64) } {
8833 result = self.array_concat(result.clone(), results.get(i as usize).cloned().unwrap_or(Value::Null));
8834 }
8835 }
8836 let mut uniqueResults: Value = self.remove_repeated_elements_from_array(result, &[]);
8837 let mut key: Value = (if (method.as_str() == Some("fetchOHLCV")) { Value::Int(0) } else { Value::Str("timestamp".into()) });
8838 return self.filter_by_since_limit(uniqueResults, &[since, limit, key]);
8839
8840 Value::Null
8841} }
8842
8843fn fetch_paginated_call_cursor(&mut self, mut method: Value, optional_args: &[Value]) -> impl ::std::future::Future<Output = Value> + Send { async move {
8846 let mut symbol = get_arg(optional_args, 0, Value::Null);
8847 let mut since = get_arg(optional_args, 1, Value::Null);
8848 let mut limit = get_arg(optional_args, 2, Value::Null);
8849 let mut params = get_arg(optional_args, 3, Value::Map({
8850 let mut m = indexmap::IndexMap::new();
8851 m
8852}));
8853 let mut cursorReceived = get_arg(optional_args, 4, Value::Null);
8854 let mut cursorSent = get_arg(optional_args, 5, Value::Null);
8855 let mut cursorIncrement = get_arg(optional_args, 6, Value::Null);
8856 let mut maxEntriesPerRequest = get_arg(optional_args, 7, Value::Null);
8857 let mut maxCalls: Value = Value::Int(10);
8858 let maxCallsPaginationCallsparamsPaginationCallsVariable: Vec<Value> = self.handle_option_integer_and_params(params, method.clone(), Value::Str("paginationCalls".into()), &[maxCalls]).as_array().cloned().unwrap_or_default();
8859 let mut maxCallsPaginationCalls: Value = maxCallsPaginationCallsparamsPaginationCallsVariable.get(0).cloned().unwrap_or(Value::Null);
8860 let mut paramsPaginationCalls: Value = maxCallsPaginationCallsparamsPaginationCallsVariable.get(1).cloned().unwrap_or(Value::Null);
8861 let mut maxRetries: Value = Value::Int(3);
8862 let maxRetriesOptionparamsMaxRetriesVariable: Vec<Value> = self.handle_option_integer_and_params(paramsPaginationCalls, method.clone(), Value::Str("maxRetries".into()), &[maxRetries]).as_array().cloned().unwrap_or_default();
8863 let mut maxRetriesOption: Value = maxRetriesOptionparamsMaxRetriesVariable.get(0).cloned().unwrap_or(Value::Null);
8864 let mut paramsMaxRetries: Value = maxRetriesOptionparamsMaxRetriesVariable.get(1).cloned().unwrap_or(Value::Null);
8865 let maxEntriesPerRequestOptionparamsMaxEntriesPerRequestVariable: Vec<Value> = self.handle_max_entries_per_request_and_params(method.clone(), &[maxEntriesPerRequest, paramsMaxRetries]).as_array().cloned().unwrap_or_default();
8866 let mut maxEntriesPerRequestOption: Value = maxEntriesPerRequestOptionparamsMaxEntriesPerRequestVariable.get(0).cloned().unwrap_or(Value::Null);
8867 let mut paramsMaxEntriesPerRequest: Value = maxEntriesPerRequestOptionparamsMaxEntriesPerRequestVariable.get(1).cloned().unwrap_or(Value::Null);
8868 let mut cursorValue: Value = Value::Null;
8869 let mut errors: Value = Value::Int(0);
8870 let mut result: Value = Value::from(vec![]);
8871 let mut timeframe: Option<String> = self.safe_string_k_opt(paramsMaxEntriesPerRequest.clone(), "timeframe", &[]);
8872 let mut paramsOmitted: Value = self.omit(paramsMaxEntriesPerRequest, Value::Str("timeframe".into()), &[]); let mut shouldBreak: bool = false;
8874 {
8875 let mut i: Value = Value::Int(0);
8876 let mut __for_first_166: bool = true;
8877 while { if !__for_first_166 { if let Value::Int(n) = &mut i { *n += 1; } } __for_first_166 = false; i.as_f64().unwrap_or(f64::NAN) < maxCallsPaginationCalls.as_f64().unwrap_or(f64::NAN) } {
8878 {
8879 if (cursorValue != Value::Null) {
8880 if (cursorIncrement != Value::Null) {
8881 cursorValue = self.sum(&[self.parse_to_int(cursorValue.clone()), cursorIncrement.clone()]);
8882 }
8883 if let Value::Dict(__d) = &mut paramsOmitted { std::sync::Arc::make_mut(__d).insert(crate::runtime::stringify_param(&cursorSent), cursorValue.clone()); }
8884 }
8885 let mut response: Value = Value::Null;
8886 if (method.as_str() == Some("fetchAccounts")) {
8887 response = self.call_dynamic_checked(method.clone(), vec![(paramsOmitted).clone()]).await;
8888 } else if (method.as_str() == Some("getLeverageTiersPaginated")) || (method.as_str() == Some("fetchPositions")) {
8889 response = self.call_dynamic_checked(method.clone(), vec![(symbol).clone(), (paramsOmitted).clone()]).await;
8890 } else if (method.as_str() == Some("fetchOpenInterestHistory")) {
8891 if !matches!(&symbol, Value::Str(_)) {
8892 panic!("{}", crate::exchange_errors::arguments_required(format!("{}{}", self.id.clone(), Value::Str(" fetchPaginatedCallCursor() requires a symbol argument".into()))));
8893 }
8894 if (timeframe.is_none()) {
8895 panic!("{}", crate::exchange_errors::arguments_required(format!("{}{}", self.id.clone(), Value::Str(" fetchPaginatedCallCursor() requires a timeframe argument".into()))));
8896 }
8897 response = self.call_dynamic_checked(method.clone(), vec![(symbol).clone(), (timeframe.clone().map(Value::from).unwrap_or(Value::Null)).clone(), (since).clone(), (maxEntriesPerRequestOption).clone(), (paramsOmitted).clone()]).await;
8898 } else {
8899 response = self.call_dynamic_checked(method.clone(), vec![(symbol).clone(), (since).clone(), (maxEntriesPerRequestOption).clone(), (paramsOmitted).clone()]).await;
8900 }
8901 errors = Value::Int(0);
8902 if (response == Value::Null) {
8903 panic!("{}", crate::exchange_errors::null_response(format!("{}{}", self.id.clone(), Value::Str(" fetchPaginatedCallCursor() returned empty response".into()))));
8904 }
8905 let mut responseLength: Value = Value::Int(response.len() as i64);
8906 if self.verbose.as_bool() == Some(true) {
8907 let mut cursorString: Value = Value::Str("".into());
8908 if (cursorValue != Value::Null) {
8909 cursorString = Value::Str(format!("{}", cursorValue).into());
8910 }
8911 let mut cursorMessage: Value = Value::Str(format!("{}{}", Value::Str(format!("{}{}", Value::Str(format!("{}{}", Value::Str(format!("{}{}", Value::Str(format!("{}{}", Value::Str(format!("{}{}", Value::Str(format!("{}{}", Value::Str("Cursor pagination call ".into()), Value::Str(format!("{}", ((match (&(i),
8912 &(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 }))).into())).into()),
8913 Value::Str(" method ".into())).into()), method).into()), Value::Str(" response length ".into())).into()), Value::Str(format!("{}", responseLength).into())).into()), Value::Str(" cursor ".into())).into()), cursorString).into());
8914 self.log(cursorMessage);
8915 }
8916 if (responseLength.as_f64() == Some(0.0)) {
8917 shouldBreak = true;
8918 break;
8919 }
8920 result = self.array_concat(result.clone(), response.clone());
8921 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 }), &[]);
8922 cursorValue = Value::Null; {
8925 let mut j: Value = Value::Int(0);
8926 let mut __for_first_165: bool = true;
8927 while { if !__for_first_165 { if let Value::Int(n) = &mut j { *n += 1; } } __for_first_165 = false; j.as_f64().unwrap_or(f64::NAN) < responseLength.as_f64().unwrap_or(f64::NAN) } {
8928 if (cursorValue == Value::Null) {
8929 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 })),
8930 &(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 });
8931 let mut entry: Value = self.safe_dict(response.clone(), index, &[]);
8932 let mut info: Value = self.safe_dict_k(entry, "info", &[]);
8933 if (cursorReceived != Value::Null) {
8934 cursorValue = self.safe_value(info, cursorReceived.clone(), &[]);
8935 }
8936 }
8937 }
8938 }
8939 if (cursorValue == Value::Null) {
8940 shouldBreak = true;
8941 break;
8942 }
8943 let mut lastTimestamp: Value = self.safe_integer_k(last, "timestamp", &[]);
8944 if (since == Value::Null) {
8945 panic!("{}", crate::exchange_errors::arguments_required(format!("{}{}", self.id.clone(), Value::Str(" fetchPaginatedCallCursor() requires a since argument".into()))));
8946 }
8947 if (lastTimestamp != Value::Null) && lastTimestamp.as_f64().unwrap_or(f64::NAN) < since.as_f64().unwrap_or(f64::NAN) {
8948 shouldBreak = true;
8949 break;
8950 }
8951 }
8952 if shouldBreak {
8953 break;
8954 }
8955 }
8956 }
8957 let mut sorted: Value = self.sort_cursor_paginated_result(result);
8958 let mut key: Value = (if (method.as_str() == Some("fetchOHLCV")) { Value::Int(0) } else { Value::Str("timestamp".into()) });
8959 return self.filter_by_since_limit(sorted, &[since, limit, key]);
8960
8961 Value::Null
8962} }
8963
8964 fn fetch_paginated_call_incremental(&mut self, mut method: Value, optional_args: &[Value]) -> impl ::std::future::Future<Output = Value> + Send { async move {
8965 let mut symbol = get_arg(optional_args, 0, Value::Null);
8966 let mut since = get_arg(optional_args, 1, Value::Null);
8967 let mut limit = get_arg(optional_args, 2, Value::Null);
8968 let mut params = get_arg(optional_args, 3, Value::Map({
8969 let mut m = indexmap::IndexMap::new();
8970 m
8971}));
8972 let mut pageKey = get_arg(optional_args, 4, Value::Null);
8973 let mut maxEntriesPerRequest = get_arg(optional_args, 5, Value::Null);
8974 let mut maxCalls: Value = Value::Int(10);
8975 let maxCallsPaginationCallsparamsPaginationCallsVariable: Vec<Value> = self.handle_option_integer_and_params(params, method.clone(), Value::Str("paginationCalls".into()), &[maxCalls]).as_array().cloned().unwrap_or_default();
8976 let mut maxCallsPaginationCalls: Value = maxCallsPaginationCallsparamsPaginationCallsVariable.get(0).cloned().unwrap_or(Value::Null);
8977 let mut paramsPaginationCalls: Value = maxCallsPaginationCallsparamsPaginationCallsVariable.get(1).cloned().unwrap_or(Value::Null);
8978 let mut maxCallsLimit: Value = self.parse_to_int(maxCallsPaginationCalls);
8979 let mut maxRetries: Value = Value::Int(3);
8980 let maxRetriesOptionparamsMaxRetriesVariable: Vec<Value> = self.handle_option_integer_and_params(paramsPaginationCalls, method.clone(), Value::Str("maxRetries".into()), &[maxRetries]).as_array().cloned().unwrap_or_default();
8981 let mut maxRetriesOption: Value = maxRetriesOptionparamsMaxRetriesVariable.get(0).cloned().unwrap_or(Value::Null);
8982 let mut paramsMaxRetries: Value = maxRetriesOptionparamsMaxRetriesVariable.get(1).cloned().unwrap_or(Value::Null);
8983 let maxEntriesPerRequestOptionparamsMaxEntriesPerRequestVariable: Vec<Value> = self.handle_max_entries_per_request_and_params(method.clone(), &[maxEntriesPerRequest, paramsMaxRetries]).as_array().cloned().unwrap_or_default();
8984 let mut maxEntriesPerRequestOption: Value = maxEntriesPerRequestOptionparamsMaxEntriesPerRequestVariable.get(0).cloned().unwrap_or(Value::Null);
8985 let mut paramsMaxEntriesPerRequest: Value = maxEntriesPerRequestOptionparamsMaxEntriesPerRequestVariable.get(1).cloned().unwrap_or(Value::Null);
8986 let mut errors: Value = Value::Int(0);
8987 let mut result: Value = Value::from(vec![]);
8988 let mut shouldBreak: bool = false;
8989 {
8990 let mut i: Value = Value::Int(0);
8991 let mut __for_first_167: bool = true;
8992 while { if !__for_first_167 { if let Value::Int(n) = &mut i { *n += 1; } } __for_first_167 = false; i.as_f64().unwrap_or(f64::NAN) < maxCallsLimit.as_f64().unwrap_or(f64::NAN) } {
8993 {
8994 if let Value::Dict(__d) = &mut paramsMaxEntriesPerRequest { std::sync::Arc::make_mut(__d).insert(crate::runtime::stringify_param(&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),
8995 Value::Int(y)) => Value::Float(*x + *y as f64), (Value::Float(x), Value::Float(y)) => Value::Float(x + y), _ => Value::Null })); }
8996 let mut response: Value = self.call_dynamic_checked(method.clone(), vec![(symbol).clone(), (since).clone(), (maxEntriesPerRequestOption).clone(), (paramsMaxEntriesPerRequest).clone()]).await;
8997 errors = Value::Int(0);
8998 let mut responseLength: Value = get_array_length(&response);
8999 if self.verbose.as_bool() == Some(true) {
9000 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 }));
9001 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()), Value::Str(format!("{}", iteration).into())).into()), Value::Str(" method ".into())).into()), method).into()),
9002 Value::Str(" response length ".into())).into()), Value::Str(format!("{}", responseLength).into())).into());
9003 self.log(incrementalMessage);
9004 }
9005 if (responseLength.as_f64() == Some(0.0)) {
9006 shouldBreak = true;
9007 break;
9008 }
9009 result = self.array_concat(result.clone(), response);
9010 }
9011 if shouldBreak {
9012 break;
9013 }
9014 }
9015 }
9016 return self.filter_by_since_limit(self.sort_cursor_paginated_result(result), &[since, limit, (if (method.as_str() == Some("fetchOHLCV")) { Value::Int(0) } else { Value::Str("timestamp".into()) })]);
9017
9018 Value::Null
9019} }
9020
9021 fn sort_cursor_paginated_result(&self, mut result: Value) -> Value {
9022 let mut first: Value = self.safe_dict(result.clone(), Value::Int(0), &[]);
9023 if (first != Value::Null) {
9024 if (matches!(&first, Value::Dict(__d) if __d.contains_key("timestamp"))) {
9025 return self.sort_by(result.clone(), Value::Str("timestamp".into()), &[Value::Bool(true)]);
9026 }
9027 if (matches!(&first, Value::Dict(__d) if __d.contains_key("id"))) {
9028 return self.sort_by(result.clone(), Value::Str("id".into()), &[Value::Bool(true)]);
9029 }
9030 }
9031 return result;
9032
9033 Value::Null
9034}
9035
9036 fn remove_repeated_elements_from_array(&self, mut input: Value, optional_args: &[Value]) -> Value {
9037 let mut fallbackToTimestamp = get_arg(optional_args, 0, Value::Bool(true));
9038 let mut uniqueDic: Value = Value::Map({
9039 let mut m = indexmap::IndexMap::new();
9040 m
9041 });
9042 let mut uniqueResult: Value = Value::from(vec![]);
9043 {
9044 let mut i: i64 = 0;
9045 let mut __for_first_168: bool = true;
9046 while { if !__for_first_168 { i += 1; } __for_first_168 = false; i < (input.len() as i64) } {
9047 let mut entry: Value = input.as_array().map(Vec::as_slice).unwrap_or_default().get(i as usize).cloned().unwrap_or(Value::Null);
9048 let mut uniqValue: Value = self.safe_string_k(entry.clone(), "id", &[]);
9049 if fallbackToTimestamp.as_bool() == Some(true) {
9050 uniqValue = self.safe_string_n(entry.clone(), Value::from(vec![Value::Str("id".into()), Value::Str("timestamp".into()), Value::Int(0)]), &[]);
9051 }
9052 if (uniqValue != Value::Null) && !(matches!((&uniqueDic, &uniqValue), (Value::Dict(__d), Value::Str(__k)) if __d.contains_key(__k.as_ref()))) {
9053 if let Value::Dict(__d) = &mut uniqueDic { std::sync::Arc::make_mut(__d).insert(crate::runtime::stringify_param(&uniqValue), Value::Int(1)); }
9054 if let Value::Arr(__a) = &mut uniqueResult { std::sync::Arc::make_mut(__a).push(entry); }
9055 }
9056 }
9057 }
9058 let mut valuesLength: f64 = ((uniqueResult.len() as i64) as f64);
9059 if valuesLength > ((0i64) as f64) {
9060 return uniqueResult;
9061 }
9062 return input;
9063
9064 Value::Null
9065}
9066
9067 fn remove_repeated_trades_from_array(&self, mut input: Value) -> Value {
9068 let __input_empty = Vec::new();
9069 let input = input.as_array().unwrap_or(&__input_empty);
9070 let mut uniqueResult: Value = Value::Map({
9071 let mut m = indexmap::IndexMap::new();
9072 m
9073 });
9074 {
9075 let mut i: Value = Value::Int(0);
9076 let mut __for_first_169: bool = true;
9077 while { if !__for_first_169 { if let Value::Int(n) = &mut i { *n += 1; } } __for_first_169 = false; i.as_f64().unwrap_or(f64::NAN) < ((input.len() as i64) as f64) } {
9078 let mut entry: Value = input.get((i).as_i64().unwrap_or(-1) as usize).cloned().unwrap_or(Value::Null);
9079 let mut id: Value = self.safe_string_k(entry.clone(), "id", &[]);
9080 if (id == Value::Null) {
9081 let price: String = self.safe_string_k_opt(entry.clone(), "price", &[Value::Str("".into())]).unwrap_or_default();
9082 let amount: String = self.safe_string_k_opt(entry.clone(), "amount", &[Value::Str("".into())]).unwrap_or_default();
9083 let mut timestamp: Option<String> = self.safe_string_k_opt(entry.clone(), "timestamp", &[]);
9084 let side: String = self.safe_string_k_opt(entry.clone(), "side", &[Value::Str("".into())]).unwrap_or_default();
9085 if (timestamp.is_none()) {
9087 panic!("{}", crate::exchange_errors::exchange_error(format!("{}{}", self.id.clone(), Value::Str(" removeRepeatedTradesFromArray() missing timestamp".into()))));
9088 }
9089 id = Value::Str(format!("{}{}", Value::Str(format!("{}{}", Value::Str(format!("{}{}", Value::Str(format!("{}{}", Value::Str("t_".into()), Value::Str(format!("{}", timestamp.map(Value::from).unwrap_or(Value::Null)).into())).into()), Value::Str("_".into())).into()), side).into()), Value::Str("_".into())).into());
9091 id = Value::Str(format!("{}{}", id, (Value::Str(format!("{}{}", Value::Str(format!("{}{}", price, Value::Str("_".into())).into()), amount).into()))).into());
9092 }
9093 if (id != Value::Null) && !(matches!((&uniqueResult, &id), (Value::Dict(__d), Value::Str(__k)) if __d.contains_key(__k.as_ref()))) {
9094 if let Value::Dict(__d) = &mut uniqueResult { std::sync::Arc::make_mut(__d).insert(crate::runtime::stringify_param(&id), entry); }
9095 }
9096 }
9097 }
9098 let mut values: Value = Value::Array(uniqueResult.as_map().map(|__m| __m.values().cloned().collect()).unwrap_or_default());
9099 return values;
9100
9101 Value::Null
9102}
9103
9104 fn remove_keys_from_dict(&self, mut dict: Value, mut removeKeys: Value) -> Value {
9105 let mut keys: Vec<Value> = object_keys(&dict).as_array().cloned().unwrap_or_default();
9106 let mut newDict: indexmap::IndexMap<String, Value> = ({
9107 let mut m = indexmap::IndexMap::new();
9108 m
9109 });
9110 {
9111 let mut i: i64 = 0;
9112 let mut __for_first_170: bool = true;
9113 while { if !__for_first_170 { i += 1; } __for_first_170 = false; i < (keys.len() as i64) } {
9114 let mut key: Value = keys.get(i as usize).cloned().unwrap_or(Value::Null);
9115 if !(self.in_array(key.clone(), removeKeys.clone()).as_bool() == Some(true)) {
9116 newDict.insert(crate::runtime::stringify_param(&key), (if let (Some(__m), Some(__k)) = (dict.as_map(), key.as_str()) { __m.get(__k).cloned().unwrap_or(Value::Null) } else { Value::Null }));
9117 }
9118 }
9119 }
9120 return Value::Map(newDict);
9121
9122 Value::Null
9123}
9124
9125 fn handle_until_option(&self, mut key: Value, mut request: Value, mut params: Value, optional_args: &[Value]) -> Value {
9126 let mut multiplier = get_arg(optional_args, 0, Value::Int(1));
9127 let mut until: Value = self.safe_integer2(params.clone(), Value::Str("until".into()), Value::Str("till".into()), &[]);
9128 if (until != Value::Null) {
9129 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),
9130 Value::Int(y)) => Value::Float(*x * *y as f64), (Value::Float(x), Value::Float(y)) => Value::Float(x * y), _ => Value::Null }))); }
9131 }
9132 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 });
9133 return Value::from(vec![request, paramsOmitted]);
9134
9135 Value::Null
9136}
9137
9138 fn safe_open_interest(&self, mut interest: Value, optional_args: &[Value]) -> Value {
9139 let mut market = get_arg(optional_args, 0, Value::Null);
9140 let mut symbol: Option<String> = self.safe_string_k_opt(interest.clone(), "symbol", &[]);
9141 if (symbol.is_none()) {
9142 symbol = self.safe_string_k_opt(market, "symbol", &[]);
9143 }
9144 return self.extend(interest.clone(), &[Value::Map({
9145 let mut m = indexmap::IndexMap::new();
9146 m.insert("symbol".to_string(), symbol.map(Value::from).unwrap_or(Value::Null));
9147 m.insert("baseVolume".to_string(), self.safe_number_k(interest.clone(), "baseVolume", &[]));
9148 m.insert("quoteVolume".to_string(), self.safe_number_k(interest.clone(), "quoteVolume", &[]));
9149 m.insert("openInterestAmount".to_string(), self.safe_number_k(interest.clone(), "openInterestAmount", &[]));
9150 m.insert("openInterestValue".to_string(), self.safe_number_k(interest.clone(), "openInterestValue", &[]));
9151 m.insert("timestamp".to_string(), self.safe_integer_k(interest.clone(), "timestamp", &[]));
9152 m.insert("datetime".to_string(), self.safe_string_k(interest.clone(), "datetime", &[]));
9153 m.insert("info".to_string(), self.safe_value_k(interest, "info", &[]));
9154 m
9155})]);
9156
9157 Value::Null
9158}
9159
9160 fn parse_liquidation(&self, mut liquidation: Value, optional_args: &[Value]) -> Value {
9161 { 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; } }
9163
9164 let mut market = get_arg(optional_args, 0, Value::Null);
9165 panic!("{}", crate::exchange_errors::not_supported(format!("{}{}", self.id.clone(), Value::Str(" parseLiquidation () is not supported yet".into()))));
9166
9167 Value::Null
9168}
9169
9170 fn parse_liquidations(&self, mut liquidations: Value, optional_args: &[Value]) -> Value {
9171 let mut market = get_arg(optional_args, 0, Value::Null);
9172 let mut since = get_arg(optional_args, 1, Value::Null);
9173 let mut limit = get_arg(optional_args, 2, Value::Null);
9174 let __liquidations_empty = Vec::new();
9175 let liquidations = liquidations.as_array().unwrap_or(&__liquidations_empty);
9176 let mut result: Vec<Value> = Vec::new();
9187 {
9188 let mut i: Value = Value::Int(0);
9189 let mut __for_first_171: bool = true;
9190 while { if !__for_first_171 { if let Value::Int(n) = &mut i { *n += 1; } } __for_first_171 = false; i.as_f64().unwrap_or(f64::NAN) < ((liquidations.len() as i64) as f64) } {
9191 let mut entry: Value = liquidations.get((i).as_i64().unwrap_or(-1) as usize).cloned().unwrap_or(Value::Null);
9192 let mut parsed: Value = <Self as crate::exchange_generated::ExchangeBase>::parse_liquidation(self, entry, &[market.clone()]);
9193 result.push(parsed);
9194 }
9195 }
9196 let mut sorted: Value = self.sort_by(Value::from(result), Value::Str("timestamp".into()), &[]);
9197 let mut symbol: Option<String> = self.safe_string_k_opt(market, "symbol", &[]);
9198 return self.filter_by_symbol_since_limit(sorted, &[symbol.map(Value::from).unwrap_or(Value::Null), since, limit]);
9199
9200 Value::Null
9201}
9202
9203 fn parse_greeks(&self, mut greeks: Value, optional_args: &[Value]) -> Value {
9204 { 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; } }
9206
9207 let mut market = get_arg(optional_args, 0, Value::Null);
9208 panic!("{}", crate::exchange_errors::not_supported(format!("{}{}", self.id.clone(), Value::Str(" parseGreeks () is not supported yet".into()))));
9209
9210 Value::Null
9211}
9212
9213 fn parse_all_greeks(&self, mut greeks: Value, optional_args: &[Value]) -> Value {
9214 let mut symbols = get_arg(optional_args, 0, Value::Null);
9215 let mut params = get_arg(optional_args, 1, Value::Map({
9216 let mut m = indexmap::IndexMap::new();
9217 m
9218}));
9219 let mut results: Vec<Value> = Vec::new();
9223 if (matches!(&greeks, Value::Arr(_))) {
9224 {
9225 let mut i: i64 = 0;
9226 let mut __for_first_172: bool = true;
9227 while { if !__for_first_172 { i += 1; } __for_first_172 = false; i < (greeks.len() as i64) } {
9228 results.push(self.extend(<Self as crate::exchange_generated::ExchangeBase>::parse_greeks(self, greeks.as_array().map(Vec::as_slice).unwrap_or_default().get(i as usize).cloned().unwrap_or(Value::Null), &[]), &[params.clone()]));
9229 }
9230 }
9231 } else {
9232 let mut marketIds: Vec<Value> = object_keys(&greeks).as_array().cloned().unwrap_or_default();
9233 {
9234 let mut i: i64 = 0;
9235 let mut __for_first_173: bool = true;
9236 while { if !__for_first_173 { i += 1; } __for_first_173 = false; i < (marketIds.len() as i64) } {
9237 let mut marketId: Value = marketIds.get(i as usize).cloned().unwrap_or(Value::Null);
9238 let mut market: Value = self.safe_market(&[marketId.clone()]);
9239 results.push(self.extend(<Self as crate::exchange_generated::ExchangeBase>::parse_greeks(self, get_value(&greeks, &marketId), &[market]), &[params.clone()]));
9240 }
9241 }
9242 }
9243 return self.index_by(self.filter_by_array(Value::from(results), Value::Str("symbol".into()), &[self.market_symbols(&[symbols]), Value::Bool(false)]), Value::Str("symbol".into()));
9244
9245 Value::Null
9246}
9247
9248 fn parse_option(&self, mut chain: Value, optional_args: &[Value]) -> Value {
9249 let mut currency = get_arg(optional_args, 0, Value::Null);
9250 let mut market = get_arg(optional_args, 1, Value::Null);
9251 panic!("{}", crate::exchange_errors::not_supported(format!("{}{}", self.id.clone(), Value::Str(" parseOption () is not supported yet".into()))));
9252
9253 Value::Null
9254}
9255
9256 fn parse_option_chain(&self, mut response: Value, optional_args: &[Value]) -> Value {
9257 let mut currencyKey = get_arg(optional_args, 0, Value::Null);
9258 let mut symbolKey = get_arg(optional_args, 1, Value::Null);
9259 let __response_empty = Vec::new();
9260 let response = response.as_array().unwrap_or(&__response_empty);
9261 let mut optionStructures: indexmap::IndexMap<String, Value> = ({
9262 let mut m = indexmap::IndexMap::new();
9263 m
9264 });
9265 {
9266 let mut i: Value = Value::Int(0);
9267 let mut __for_first_174: bool = true;
9268 while { if !__for_first_174 { if let Value::Int(n) = &mut i { *n += 1; } } __for_first_174 = false; i.as_f64().unwrap_or(f64::NAN) < ((response.len() as i64) as f64) } {
9269 let mut info: Value = response.get((i).as_i64().unwrap_or(-1) as usize).cloned().unwrap_or(Value::Null);
9270 let mut currencyId: Value = (if (currencyKey == Value::Null) { Value::Null } else { self.safe_string(info.clone(), currencyKey.clone(), &[]) });
9271 let mut currency: Value = self.safe_currency(currencyId, &[]);
9272 let mut marketId: Value = (if (symbolKey == Value::Null) { Value::Null } else { self.safe_string(info.clone(), symbolKey.clone(), &[]) });
9273 let mut market: Value = self.safe_market(&[marketId, Value::Null, Value::Null, Value::Str("option".into())]);
9274 optionStructures.insert(crate::runtime::stringify_param(&(market.as_map().and_then(|__m| __m.get("symbol")).cloned().unwrap_or(Value::Null))), self.parse_option(info, &[currency, market]));
9275 }
9276 }
9277 return Value::Map(optionStructures);
9278
9279 Value::Null
9280}
9281
9282 fn parse_margin_modes(&self, mut response: Value, optional_args: &[Value]) -> Value {
9283 let mut symbols = get_arg(optional_args, 0, Value::Null);
9284 let mut symbolKey = get_arg(optional_args, 1, Value::Null);
9285 let mut marketType = get_arg(optional_args, 2, Value::Null);
9286 let __response_empty = Vec::new();
9287 let response = response.as_array().unwrap_or(&__response_empty);
9288 let mut marginModeStructures: indexmap::IndexMap<String, Value> = ({
9289 let mut m = indexmap::IndexMap::new();
9290 m
9291 });
9292 let mut marketTypeResolved: Value = (if (marketType == Value::Null) { Value::Str("swap".into()) } else { marketType }); {
9294 let mut i: Value = Value::Int(0);
9295 let mut __for_first_175: bool = true;
9296 while { if !__for_first_175 { if let Value::Int(n) = &mut i { *n += 1; } } __for_first_175 = false; i.as_f64().unwrap_or(f64::NAN) < ((response.len() as i64) as f64) } {
9297 let mut info: Value = response.get((i).as_i64().unwrap_or(-1) as usize).cloned().unwrap_or(Value::Null);
9298 let mut marketId: Value = (if (symbolKey == Value::Null) { Value::Null } else { self.safe_string(info.clone(), symbolKey.clone(), &[]) });
9299 let mut market: Value = self.safe_market(&[marketId, Value::Null, Value::Null, marketTypeResolved.clone()]);
9300 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) {
9301 marginModeStructures.insert(crate::runtime::stringify_param(&(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]));
9302 }
9303 }
9304 }
9305 return Value::Map(marginModeStructures);
9306
9307 Value::Null
9308}
9309
9310 fn parse_margin_mode(&self, mut marginMode: Value, optional_args: &[Value]) -> Value {
9311 { 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; } }
9313
9314 let mut market = get_arg(optional_args, 0, Value::Null);
9315 panic!("{}", crate::exchange_errors::not_supported(format!("{}{}", self.id.clone(), Value::Str(" parseMarginMode () is not supported yet".into()))));
9316
9317 Value::Null
9318}
9319
9320 fn parse_leverages(&self, mut response: Value, optional_args: &[Value]) -> Value {
9321 let mut symbols = get_arg(optional_args, 0, Value::Null);
9322 let mut symbolKey = get_arg(optional_args, 1, Value::Null);
9323 let mut marketType = get_arg(optional_args, 2, Value::Null);
9324 let __response_empty = Vec::new();
9325 let response = response.as_array().unwrap_or(&__response_empty);
9326 let mut leverageStructures: indexmap::IndexMap<String, Value> = ({
9327 let mut m = indexmap::IndexMap::new();
9328 m
9329 });
9330 let mut marketTypeResolved: Value = (if (marketType == Value::Null) { Value::Str("swap".into()) } else { marketType }); {
9332 let mut i: Value = Value::Int(0);
9333 let mut __for_first_176: bool = true;
9334 while { if !__for_first_176 { if let Value::Int(n) = &mut i { *n += 1; } } __for_first_176 = false; i.as_f64().unwrap_or(f64::NAN) < ((response.len() as i64) as f64) } {
9335 let mut info: Value = response.get((i).as_i64().unwrap_or(-1) as usize).cloned().unwrap_or(Value::Null);
9336 let mut marketId: Value = (if (symbolKey == Value::Null) { Value::Null } else { self.safe_string(info.clone(), symbolKey.clone(), &[]) });
9337 let mut market: Value = self.safe_market(&[marketId, Value::Null, Value::Null, marketTypeResolved.clone()]);
9338 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) {
9339 leverageStructures.insert(crate::runtime::stringify_param(&(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]));
9340 }
9341 }
9342 }
9343 return Value::Map(leverageStructures);
9344
9345 Value::Null
9346}
9347
9348 fn parse_leverage(&self, mut leverage: Value, optional_args: &[Value]) -> Value {
9349 { 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; } }
9351
9352 let mut market = get_arg(optional_args, 0, Value::Null);
9353 panic!("{}", crate::exchange_errors::not_supported(format!("{}{}", self.id.clone(), Value::Str(" parseLeverage () is not supported yet".into()))));
9354
9355 Value::Null
9356}
9357
9358 fn parse_conversions(&self, mut conversions: Value, optional_args: &[Value]) -> Value {
9359 let mut code = get_arg(optional_args, 0, Value::Null);
9360 let mut fromCurrencyKey = get_arg(optional_args, 1, Value::Null);
9361 let mut toCurrencyKey = get_arg(optional_args, 2, Value::Null);
9362 let mut since = get_arg(optional_args, 3, Value::Null);
9363 let mut limit = get_arg(optional_args, 4, Value::Null);
9364 let mut params = get_arg(optional_args, 5, Value::Map({
9365 let mut m = indexmap::IndexMap::new();
9366 m
9367}));
9368 let mut conversionsArray: Value = self.to_array(conversions);
9369 let mut result: Vec<Value> = Vec::new();
9370 let mut fromCurrency: Value = Value::Null;
9371 let mut toCurrency: Value = Value::Null;
9372 {
9373 let mut i: i64 = 0;
9374 let mut __for_first_177: bool = true;
9375 while { if !__for_first_177 { i += 1; } __for_first_177 = false; i < (conversionsArray.len() as i64) } {
9376 let mut entry: Value = conversionsArray.as_array().map(Vec::as_slice).unwrap_or_default().get(i as usize).cloned().unwrap_or(Value::Null);
9377 let mut fromId: Value = (if (fromCurrencyKey == Value::Null) { Value::Null } else { self.safe_string(entry.clone(), fromCurrencyKey.clone(), &[]) });
9378 let mut toId: Value = (if (toCurrencyKey == Value::Null) { Value::Null } else { self.safe_string(entry.clone(), toCurrencyKey.clone(), &[]) });
9379 if (fromId != Value::Null) {
9380 fromCurrency = self.safe_currency(fromId, &[]);
9381 }
9382 if (toId != Value::Null) {
9383 toCurrency = self.safe_currency(toId, &[]);
9384 }
9385 let mut conversion: Value = self.extend(<Self as crate::exchange_generated::ExchangeBase>::parse_conversion(self, entry, &[fromCurrency.clone(), toCurrency.clone()]), &[params.clone()]);
9386 result.push(conversion);
9387 }
9388 }
9389 let mut sorted: Value = self.sort_by(Value::from(result), Value::Str("timestamp".into()), &[]);
9390 if (code == Value::Null) {
9391 return self.filter_by_since_limit(sorted.clone(), &[since.clone(), limit.clone()]);
9392 }
9393 let mut currency: Value = self.safe_currency(code, &[]);
9394 if (currency == Value::Null) {
9395 panic!("{}", crate::exchange_errors::exchange_error(format!("{}{}", self.id.clone(), Value::Str(" parseConversions() could not resolve currency".into()))));
9396 }
9397 let mut currencyCode: Value = currency.as_map().and_then(|__m| __m.get("code")).cloned().unwrap_or(Value::Null);
9398 let mut fromConversion: Value = self.filter_by(sorted.clone(), Value::Str("fromCurrency".into()), currencyCode.clone(), &[]);
9399 let mut toConversion: Value = self.filter_by(sorted, Value::Str("toCurrency".into()), currencyCode, &[]);
9400 let mut both: Value = self.array_concat(fromConversion, toConversion);
9401 return self.filter_by_since_limit(both, &[since, limit]);
9402
9403 Value::Null
9404}
9405
9406 fn parse_conversion(&self, mut conversion: Value, optional_args: &[Value]) -> Value {
9407 { 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; } }
9409
9410 let mut fromCurrency = get_arg(optional_args, 0, Value::Null);
9411 let mut toCurrency = get_arg(optional_args, 1, Value::Null);
9412 if (conversion == Value::Null) {
9413 panic!("{}", crate::exchange_errors::not_supported(format!("{}{}", self.id.clone(), Value::Str(" parseConversion () is not supported yet".into()))));
9414 }
9415 panic!("{}", crate::exchange_errors::not_supported(format!("{}{}", self.id.clone(), Value::Str(" parseConversion () is not supported yet".into()))));
9416
9417 Value::Null
9418}
9419
9420 fn convert_expire_date(&self, mut date: Value) -> Value {
9421 if (date == Value::Null) {
9422 return Value::Null;
9423 }
9424 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(Value::from).unwrap_or(Value::Null);
9426 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(Value::from).unwrap_or(Value::Null);
9427 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(Value::from).unwrap_or(Value::Null);
9428 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());
9431 return reconstructedDate;
9432
9433 Value::Null
9434}
9435
9436 fn convert_expire_date_to_market_id_date(&self, mut date: Value) -> Value {
9437 if (date == Value::Null) {
9438 return Value::Null;
9439 }
9440 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(Value::from).unwrap_or(Value::Null);
9442 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(Value::from).unwrap_or(Value::Null);
9443 let mut month: Value = Value::Null;
9444 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(Value::from).unwrap_or(Value::Null);
9445 if (monthRaw.as_str() == Some("01")) {
9446 month = Value::Str("JAN".into());
9447 } else if (monthRaw.as_str() == Some("02")) {
9448 month = Value::Str("FEB".into());
9449 } else if (monthRaw.as_str() == Some("03")) {
9450 month = Value::Str("MAR".into());
9451 } else if (monthRaw.as_str() == Some("04")) {
9452 month = Value::Str("APR".into());
9453 } else if (monthRaw.as_str() == Some("05")) {
9454 month = Value::Str("MAY".into());
9455 } else if (monthRaw.as_str() == Some("06")) {
9456 month = Value::Str("JUN".into());
9457 } else if (monthRaw.as_str() == Some("07")) {
9458 month = Value::Str("JUL".into());
9459 } else if (monthRaw.as_str() == Some("08")) {
9460 month = Value::Str("AUG".into());
9461 } else if (monthRaw.as_str() == Some("09")) {
9462 month = Value::Str("SEP".into());
9463 } else if (monthRaw.as_str() == Some("10")) {
9464 month = Value::Str("OCT".into());
9465 } else if (monthRaw.as_str() == Some("11")) {
9466 month = Value::Str("NOV".into());
9467 } else if (monthRaw.as_str() == Some("12")) {
9468 month = Value::Str("DEC".into());
9469 }
9470 if (month == Value::Null) {
9471 panic!("{}", crate::exchange_errors::bad_symbol(format!("{}{}", Value::Str(format!("{}{}", self.id.clone(), Value::Str(" invalid expiry date ".into())).into()), date)));
9472 }
9473 let mut reconstructedDate: Value = Value::Str(format!("{}{}", Value::Str(format!("{}{}", day, month).into()), year).into());
9474 return reconstructedDate;
9475
9476 Value::Null
9477}
9478
9479 fn convert_market_id_expire_date(&self, mut date: Value) -> Value {
9480 if (date == Value::Null) {
9481 return Value::Null;
9482 }
9483 let mut monthMappping: indexmap::IndexMap<String, Value> = ({
9485 let mut m = indexmap::IndexMap::new();
9486 m.insert("JAN".to_string(), Value::Str("01".into()));
9487 m.insert("FEB".to_string(), Value::Str("02".into()));
9488 m.insert("MAR".to_string(), Value::Str("03".into()));
9489 m.insert("APR".to_string(), Value::Str("04".into()));
9490 m.insert("MAY".to_string(), Value::Str("05".into()));
9491 m.insert("JUN".to_string(), Value::Str("06".into()));
9492 m.insert("JUL".to_string(), Value::Str("07".into()));
9493 m.insert("AUG".to_string(), Value::Str("08".into()));
9494 m.insert("SEP".to_string(), Value::Str("09".into()));
9495 m.insert("OCT".to_string(), Value::Str("10".into()));
9496 m.insert("NOV".to_string(), Value::Str("11".into()));
9497 m.insert("DEC".to_string(), Value::Str("12".into()));
9498 m
9499 });
9500 let mut datePadded: Value = date.clone();
9502 if (Value::Int(date.len() as i64).as_f64() == Some(6.0)) {
9503 datePadded = Value::Str(format!("{}{}", Value::Str("0".into()), date).into());
9504 }
9505 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(Value::from).unwrap_or(Value::Null);
9506 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(Value::from).unwrap_or(Value::Null);
9507 let mut month: Option<String> = self.safe_string_opt(Value::Map(monthMappping), monthName, &[]);
9508 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(Value::from).unwrap_or(Value::Null);
9509 if (month.is_none()) {
9510 panic!("{}", crate::exchange_errors::bad_symbol(format!("{}{}", Value::Str(format!("{}{}", self.id.clone(), Value::Str(" invalid expiry date ".into())).into()), date)));
9511 }
9512 let mut reconstructedDate: Value = Value::Str(format!("{}{}", Value::Str(format!("{}{}", day, month.map(Value::from).unwrap_or(Value::Null)).into()), year).into());
9513 return reconstructedDate;
9514
9515 Value::Null
9516}
9517
9518 fn load_markets_and_sign_in(&mut self) -> impl ::std::future::Future<Output = Value> + Send { async move {
9519 promise_all(&Value::from(vec![self.load_markets(&[]).await, self.sign_in(&[]).await])).await;
9520
9521 Value::Null
9522} }
9523
9524 fn parse_margin_modification(&self, mut data: Value, optional_args: &[Value]) -> Value {
9525 { 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; } }
9527
9528 let mut market = get_arg(optional_args, 0, Value::Null);
9529 if (data == Value::Null) {
9530 panic!("{}", crate::exchange_errors::not_supported(format!("{}{}", self.id.clone(), Value::Str(" parseMarginModification() is not supported yet".into()))));
9531 }
9532 panic!("{}", crate::exchange_errors::not_supported(format!("{}{}", self.id.clone(), Value::Str(" parseMarginModification() is not supported yet".into()))));
9533
9534 Value::Null
9535}
9536
9537 fn parse_margin_modifications(&self, mut response: Value, optional_args: &[Value]) -> Value {
9538 let mut symbols = get_arg(optional_args, 0, Value::Null);
9539 let mut symbolKey = get_arg(optional_args, 1, Value::Null);
9540 let mut marketType = get_arg(optional_args, 2, Value::Null);
9541 let mut marginModifications: Vec<Value> = Vec::new();
9542 if (response == Value::Null) {
9543 return Value::from(marginModifications);
9544 }
9545 {
9546 let mut i: i64 = 0;
9547 let mut __for_first_178: bool = true;
9548 while { if !__for_first_178 { i += 1; } __for_first_178 = false; i < (response.len() as i64) } {
9549 let mut info: Value = response.as_array().map(Vec::as_slice).unwrap_or_default().get(i as usize).cloned().unwrap_or(Value::Null);
9550 let mut marketId: Value = (if (symbolKey == Value::Null) { Value::Null } else { self.safe_string(info.clone(), symbolKey.clone(), &[]) });
9551 let mut market: Value = self.safe_market(&[marketId, Value::Null, Value::Null, marketType.clone()]);
9552 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) {
9553 marginModifications.push(<Self as crate::exchange_generated::ExchangeBase>::parse_margin_modification(self, info, &[market]));
9554 }
9555 }
9556 }
9557 return Value::from(marginModifications);
9558
9559 Value::Null
9560}
9561
9562 fn fetch_transfer(&mut self, mut id: Value, optional_args: &[Value]) -> impl ::std::future::Future<Output = Value> + Send { async move {
9563 let mut code = get_arg(optional_args, 0, Value::Null);
9564 let mut params = get_arg(optional_args, 1, Value::Map({
9565 let mut m = indexmap::IndexMap::new();
9566 m
9567}));
9568 panic!("{}", crate::exchange_errors::not_supported(format!("{}{}", self.id.clone(), Value::Str(" fetchTransfer () is not supported yet".into()))));
9569
9570 Value::Null
9571} }
9572
9573 fn fetch_transfers(&mut self, optional_args: &[Value]) -> impl ::std::future::Future<Output = Value> + Send { async move {
9574 let mut code = get_arg(optional_args, 0, Value::Null);
9575 let mut since = get_arg(optional_args, 1, Value::Null);
9576 let mut limit = get_arg(optional_args, 2, Value::Null);
9577 let mut params = get_arg(optional_args, 3, Value::Map({
9578 let mut m = indexmap::IndexMap::new();
9579 m
9580}));
9581 panic!("{}", crate::exchange_errors::not_supported(format!("{}{}", self.id.clone(), Value::Str(" fetchTransfers () is not supported yet".into()))));
9582
9583 Value::Null
9584} }
9585
9586 fn un_watch_ohlcv(&mut self, mut symbol: Value, optional_args: &[Value]) -> impl ::std::future::Future<Output = Value> + Send { async move {
9587 let mut timeframe = get_arg(optional_args, 0, Value::Str("1m".into()));
9588 let mut params = get_arg(optional_args, 1, Value::Map({
9589 let mut m = indexmap::IndexMap::new();
9590 m
9591}));
9592 panic!("{}", crate::exchange_errors::not_supported(format!("{}{}", self.id.clone(), Value::Str(" unWatchOHLCV () is not supported yet".into()))));
9593
9594 Value::Null
9595} }
9596
9597 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 {
9598 let mut params = get_arg(optional_args, 0, Value::Map({
9599 let mut m = indexmap::IndexMap::new();
9600 m
9601}));
9602 panic!("{}", crate::exchange_errors::not_supported(format!("{}{}", self.id.clone(), Value::Str(" withdrawWs () is not supported yet".into()))));
9603
9604 Value::Null
9605} }
9606
9607 fn un_watch_my_trades(&mut self, optional_args: &[Value]) -> impl ::std::future::Future<Output = Value> + Send { async move {
9608 let mut symbol = get_arg(optional_args, 0, Value::Null);
9609 let mut params = get_arg(optional_args, 1, Value::Map({
9610 let mut m = indexmap::IndexMap::new();
9611 m
9612}));
9613 panic!("{}", crate::exchange_errors::not_supported(format!("{}{}", self.id.clone(), Value::Str(" unWatchMyTrades () is not supported yet".into()))));
9614
9615 Value::Null
9616} }
9617
9618 fn fetch_orders_by_status_ws(&mut self, mut status: Value, optional_args: &[Value]) -> impl ::std::future::Future<Output = Value> + Send { async move {
9619 let mut symbol = get_arg(optional_args, 0, Value::Null);
9620 let mut since = get_arg(optional_args, 1, Value::Null);
9621 let mut limit = get_arg(optional_args, 2, Value::Null);
9622 let mut params = get_arg(optional_args, 3, Value::Map({
9623 let mut m = indexmap::IndexMap::new();
9624 m
9625}));
9626 panic!("{}", crate::exchange_errors::not_supported(format!("{}{}", self.id.clone(), Value::Str(" fetchOrdersByStatusWs () is not supported yet".into()))));
9627
9628 Value::Null
9629} }
9630
9631 fn un_watch_bids_asks(&mut self, optional_args: &[Value]) -> impl ::std::future::Future<Output = Value> + Send { async move {
9632 let mut symbols = get_arg(optional_args, 0, Value::Null);
9633 let mut params = get_arg(optional_args, 1, Value::Map({
9634 let mut m = indexmap::IndexMap::new();
9635 m
9636}));
9637 panic!("{}", crate::exchange_errors::not_supported(format!("{}{}", self.id.clone(), Value::Str(" unWatchBidsAsks () is not supported yet".into()))));
9638
9639 Value::Null
9640} }
9641
9642 fn clean_unsubscription(&self, mut client: Value, mut subHash: Value, mut unsubHash: Value, optional_args: &[Value]) {
9643 let mut subHashIsPrefix = get_arg(optional_args, 0, Value::Bool(false));
9644 if (unsubHash != Value::Null) && (matches!((&get_value(&client, &Value::Str("subscriptions".into())), &unsubHash), (Value::Dict(__d), Value::Str(__k)) if __d.contains_key(__k.as_ref()))) {
9645 remove(&mut get_value(&client, &Value::Str("subscriptions".into())), &unsubHash);
9646 }
9647 if (subHash != Value::Null) {
9648 if !(subHashIsPrefix.as_bool() == Some(true)) {
9649 if (matches!((&get_value(&client, &Value::Str("subscriptions".into())), &subHash), (Value::Dict(__d), Value::Str(__k)) if __d.contains_key(__k.as_ref()))) {
9650 remove(&mut get_value(&client, &Value::Str("subscriptions".into())), &subHash);
9651 }
9652 if (matches!((&get_value(&client, &Value::Str("futures".into())), &subHash), (Value::Dict(__d), Value::Str(__k)) if __d.contains_key(__k.as_ref()))) {
9653 let mut error = crate::exchange_errors::unsubscribe_error(format!("{}{}", Value::Str(format!("{}{}", self.id.clone(), Value::Str(" ".into())).into()), subHash));
9654 client.reject(&[Value::from(error.clone()), subHash.clone()]);
9655 }
9656 } else {
9657 let mut clientSubscriptions: Vec<Value> = object_keys(&get_value(&client, &Value::Str("subscriptions".into()))).as_array().cloned().unwrap_or_default();
9658 {
9659 let mut i: i64 = 0;
9660 let mut __for_first_179: bool = true;
9661 while { if !__for_first_179 { i += 1; } __for_first_179 = false; i < (clientSubscriptions.len() as i64) } {
9662 let mut sub: Value = clientSubscriptions.get(i as usize).cloned().unwrap_or(Value::Null);
9663 if (sub.as_str().zip(subHash.as_str()).is_some_and(|(__s, __p)| __s.starts_with(__p))) {
9664 remove(&mut get_value(&client, &Value::Str("subscriptions".into())), &sub);
9665 }
9666 }
9667 }
9668 let mut clientFutures: Vec<Value> = Value::Array(get_value(&client, &Value::Str("futures".into())).as_map().map(|__m| __m.keys().map(|__k| Value::Str(__k.clone().into())).collect()).unwrap_or_default()).as_array().cloned().unwrap_or_default();
9669 {
9670 let mut i: i64 = 0;
9671 let mut __for_first_180: bool = true;
9672 while { if !__for_first_180 { i += 1; } __for_first_180 = false; i < (clientFutures.len() as i64) } {
9673 let mut future: Value = clientFutures.get(i as usize).cloned().unwrap_or(Value::Null);
9674 if (future.as_str().zip(subHash.as_str()).is_some_and(|(__s, __p)| __s.starts_with(__p))) {
9675 let mut error = crate::exchange_errors::unsubscribe_error(format!("{}{}", Value::Str(format!("{}{}", self.id.clone(), Value::Str(" ".into())).into()), future));
9676 client.reject(&[Value::from(error), future]);
9677 }
9678 }
9679 }
9680 }
9681 }
9682 client.resolve(&[Value::Bool(true), unsubHash]);
9683}
9684
9685 fn clean_cache(&mut self, mut subscription: Value) {
9686 let __subscription_empty = indexmap::IndexMap::new();
9687 let subscription = subscription.as_map().unwrap_or(&__subscription_empty);
9688 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);
9689 let mut symbols: Value = (match subscription.get("symbols") { Some(__v) if matches!(__v, Value::Arr(_)) => __v.clone(), _ => Value::from(vec![]) });
9690 let mut symbolsLength: f64 = ((symbols.len() as i64) as f64);
9691 if (topic.as_deref() == Some("ohlcv")) {
9692 let mut symbolsAndTimeframes: Vec<Value> = (match subscription.get("symbolsAndTimeframes") { Some(__v) if matches!(__v, Value::Arr(_)) => __v.clone(), _ => Value::from(vec![]) }).as_array().cloned().unwrap_or_default();
9693 {
9694 let mut i: i64 = 0;
9695 let mut __for_first_181: bool = true;
9696 while { if !__for_first_181 { i += 1; } __for_first_181 = false; i < (symbolsAndTimeframes.len() as i64) } {
9697 let mut symbolAndTimeFrame: Value = symbolsAndTimeframes.get(i as usize).cloned().unwrap_or(Value::Null);
9698 let mut symbol: Option<String> = self.safe_string_opt(symbolAndTimeFrame.clone(), Value::Int(0), &[]);
9699 let mut timeframe: Value = self.safe_string(symbolAndTimeFrame, Value::Int(1), &[]);
9700 if (symbol.is_none()) {
9701 panic!("{}", crate::exchange_errors::arguments_required(format!("{}{}", self.id.clone(), Value::Str(" cleanCache() requires a symbol argument".into()))));
9702 }
9703 if (timeframe == Value::Null) {
9704 panic!("{}", crate::exchange_errors::arguments_required(format!("{}{}", self.id.clone(), Value::Str(" cleanCache() requires a timeframe argument".into()))));
9705 }
9706 if (matches!((&self.ohlcvs, &symbol.clone().map(Value::from).unwrap_or(Value::Null)), (Value::Dict(__d), Value::Str(__k)) if __d.contains_key(__k.as_ref()))) {
9707 if ((if let (Some(__m), Some(__k)) = (self.ohlcvs.as_map(), symbol.as_deref()) { __m.get(__k).cloned().unwrap_or(Value::Null) } else { Value::Null }).as_map().is_some_and(|__m| timeframe.as_str().is_some_and(|__k| __m.contains_key(__k)))) {
9708 remove(&mut get_value(&self.ohlcvs, &symbol.clone().map(Value::from).unwrap_or(Value::Null)), &timeframe);
9709 }
9710 }
9711 }
9712 }
9713 } else if symbolsLength > ((0i64) as f64) {
9714 {
9715 let mut i: i64 = 0;
9716 let mut __for_first_182: bool = true;
9717 while { if !__for_first_182 { i += 1; } __for_first_182 = false; i < (symbols.len() as i64) } {
9718 let mut symbol: Value = self.safe_string(symbols.clone(), Value::Int(i), &[Value::Str("".into())]);
9719 if (topic.as_deref() == Some("trades")) {
9720 if (matches!((&self.trades, &symbol), (Value::Dict(__d), Value::Str(__k)) if __d.contains_key(__k.as_ref()))) {
9721 if let (Value::Dict(__d), Value::Str(__k)) = (&mut self.trades.clone(), &symbol) { std::sync::Arc::make_mut(__d).shift_remove(__k.as_ref()); }
9722 }
9723 } else if (topic.as_deref() == Some("orderbook")) {
9724 if (matches!((&self.orderbooks, &symbol), (Value::Dict(__d), Value::Str(__k)) if __d.contains_key(__k.as_ref()))) {
9725 if let (Value::Dict(__d), Value::Str(__k)) = (&mut self.orderbooks.clone(), &symbol) { std::sync::Arc::make_mut(__d).shift_remove(__k.as_ref()); }
9726 }
9727 } else if (topic.as_deref() == Some("ticker")) {
9728 if (matches!((&self.tickers, &symbol), (Value::Dict(__d), Value::Str(__k)) if __d.contains_key(__k.as_ref()))) {
9729 if let (Value::Dict(__d), Value::Str(__k)) = (&mut self.tickers.clone(), &symbol) { std::sync::Arc::make_mut(__d).shift_remove(__k.as_ref()); }
9730 }
9731 } else if (topic.as_deref() == Some("bidsasks")) {
9732 if (matches!((&self.bidsasks, &symbol), (Value::Dict(__d), Value::Str(__k)) if __d.contains_key(__k.as_ref()))) {
9733 if let (Value::Dict(__d), Value::Str(__k)) = (&mut self.bidsasks.clone(), &symbol) { std::sync::Arc::make_mut(__d).shift_remove(__k.as_ref()); }
9734 }
9735 }
9736 }
9737 }
9738 } else {
9739 if (topic.as_deref() == Some("myTrades")) {
9740 self.myTrades = Value::Null;
9741 } else if (topic.as_deref() == Some("orders")) {
9742 self.orders = Value::Null;
9743 } else if (topic.as_deref() == Some("positions")) && (self.positions.clone() != Value::Null) {
9744 self.positions = Value::Null;
9745 let mut clients: Vec<Value> = Value::Array(self.clients.as_map().map(|__m| __m.values().cloned().collect()).unwrap_or_default()).as_array().cloned().unwrap_or_default();
9746 {
9747 let mut i: i64 = 0;
9748 let mut __for_first_183: bool = true;
9749 while { if !__for_first_183 { i += 1; } __for_first_183 = false; i < (clients.len() as i64) } {
9750 let mut client: Value = clients.get(i as usize).cloned().unwrap_or(Value::Null);
9751 let mut futures: Value = get_value(&client, &Value::Str("futures".into()));
9752 if (matches!(&futures, Value::Dict(__d) if __d.contains_key("fetchPositionsSnapshot"))) {
9753 remove(&mut futures, &Value::Str("fetchPositionsSnapshot".into()));
9754 }
9755 }
9756 }
9757 } else if ((topic.as_deref() == Some("ticker")) || (topic.as_deref() == Some("markPrice"))) && (self.tickers.clone() != Value::Null) {
9758 let mut tickerSymbols: Vec<Value> = Value::Array(self.tickers.as_map().map(|__m| __m.keys().map(|__k| Value::Str(__k.clone().into())).collect()).unwrap_or_default()).as_array().cloned().unwrap_or_default();
9759 {
9760 let mut i: i64 = 0;
9761 let mut __for_first_184: bool = true;
9762 while { if !__for_first_184 { i += 1; } __for_first_184 = false; i < (tickerSymbols.len() as i64) } {
9763 let mut tickerSymbol: Value = tickerSymbols.get(i as usize).cloned().unwrap_or(Value::Null);
9764 if (matches!((&self.tickers, &tickerSymbol), (Value::Dict(__d), Value::Str(__k)) if __d.contains_key(__k.as_ref()))) {
9765 if let (Value::Dict(__d), Value::Str(__k)) = (&mut self.tickers.clone(), &tickerSymbol) { std::sync::Arc::make_mut(__d).shift_remove(__k.as_ref()); }
9766 }
9767 }
9768 }
9769 } else if (topic.as_deref() == Some("bidsasks")) && (self.bidsasks.clone() != Value::Null) {
9770 let mut bidsaskSymbols: Vec<Value> = Value::Array(self.bidsasks.as_map().map(|__m| __m.keys().map(|__k| Value::Str(__k.clone().into())).collect()).unwrap_or_default()).as_array().cloned().unwrap_or_default();
9771 {
9772 let mut i: i64 = 0;
9773 let mut __for_first_185: bool = true;
9774 while { if !__for_first_185 { i += 1; } __for_first_185 = false; i < (bidsaskSymbols.len() as i64) } {
9775 let mut bidsaskSymbol: Value = bidsaskSymbols.get(i as usize).cloned().unwrap_or(Value::Null);
9776 if (matches!((&self.bidsasks, &bidsaskSymbol), (Value::Dict(__d), Value::Str(__k)) if __d.contains_key(__k.as_ref()))) {
9777 if let (Value::Dict(__d), Value::Str(__k)) = (&mut self.bidsasks.clone(), &bidsaskSymbol) { std::sync::Arc::make_mut(__d).shift_remove(__k.as_ref()); }
9778 }
9779 }
9780 }
9781 }
9782 }
9783}
9784
9785 fn timeframe_from_milliseconds(&self, mut ms: Value) -> Value {
9786 let mut msInt: Value = self.parse_to_int(ms);
9787 if msInt.as_f64().unwrap_or(f64::NAN) <= ((0i64) as f64) {
9788 return Value::Str("".into());
9789 }
9790 let mut second: Value = Value::Int(1000);
9791 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 });
9792 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 });
9793 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 });
9794 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 });
9795 if ((match (&(msInt), &(week)) { (Value::Int(x), Value::Int(y)) if *y != 0 => Value::Int(x % y), (Value::Int(x), Value::Float(y)) if *y != 0.0 => Value::Float(*x as f64 % *y), (Value::Float(x), Value::Int(y)) if *y != 0 => Value::Float(*x % *y as f64), (Value::Float(x), Value::Float(y)) if *y != 0.0 => Value::Float(x % y), _ => Value::Null }).as_f64() == Some(0.0)) {
9796 return Value::Str(format!("{}{}", Value::Str(format!("{}", self.parse_to_int((match ((msInt).as_f64(), (week).as_f64()) { (Some(x), Some(y)) if y != 0.0 => Value::Float(x / y), _ => Value::Null }))).into()), Value::Str("w".into())).into());
9797 }
9798 if ((match (&(msInt), &(day)) { (Value::Int(x), Value::Int(y)) if *y != 0 => Value::Int(x % y), (Value::Int(x), Value::Float(y)) if *y != 0.0 => Value::Float(*x as f64 % *y), (Value::Float(x), Value::Int(y)) if *y != 0 => Value::Float(*x % *y as f64), (Value::Float(x), Value::Float(y)) if *y != 0.0 => Value::Float(x % y), _ => Value::Null }).as_f64() == Some(0.0)) {
9799 return Value::Str(format!("{}{}", Value::Str(format!("{}", self.parse_to_int((match ((msInt).as_f64(), (day).as_f64()) { (Some(x), Some(y)) if y != 0.0 => Value::Float(x / y), _ => Value::Null }))).into()), Value::Str("d".into())).into());
9800 }
9801 if ((match (&(msInt), &(hour)) { (Value::Int(x), Value::Int(y)) if *y != 0 => Value::Int(x % y), (Value::Int(x), Value::Float(y)) if *y != 0.0 => Value::Float(*x as f64 % *y), (Value::Float(x), Value::Int(y)) if *y != 0 => Value::Float(*x % *y as f64), (Value::Float(x), Value::Float(y)) if *y != 0.0 => Value::Float(x % y), _ => Value::Null }).as_f64() == Some(0.0)) {
9802 return Value::Str(format!("{}{}", Value::Str(format!("{}", self.parse_to_int((match ((msInt).as_f64(), (hour).as_f64()) { (Some(x), Some(y)) if y != 0.0 => Value::Float(x / y), _ => Value::Null }))).into()), Value::Str("h".into())).into());
9803 }
9804 if ((match (&(msInt), &(minute)) { (Value::Int(x), Value::Int(y)) if *y != 0 => Value::Int(x % y), (Value::Int(x), Value::Float(y)) if *y != 0.0 => Value::Float(*x as f64 % *y), (Value::Float(x), Value::Int(y)) if *y != 0 => Value::Float(*x % *y as f64), (Value::Float(x), Value::Float(y)) if *y != 0.0 => Value::Float(x % y), _ => Value::Null }).as_f64() == Some(0.0)) {
9805 return Value::Str(format!("{}{}", Value::Str(format!("{}", self.parse_to_int((match ((msInt).as_f64(), (minute).as_f64()) { (Some(x), Some(y)) if y != 0.0 => Value::Float(x / y), _ => Value::Null }))).into()), Value::Str("m".into())).into());
9806 }
9807 if ((match (&(msInt), &(Value::Int(1000))) { (Value::Int(x), Value::Int(y)) if *y != 0 => Value::Int(x % y), (Value::Int(x), Value::Float(y)) if *y != 0.0 => Value::Float(*x as f64 % *y), (Value::Float(x), Value::Int(y)) if *y != 0 => Value::Float(*x % *y as f64), (Value::Float(x), Value::Float(y)) if *y != 0.0 => Value::Float(x % y), _ => Value::Null }).as_f64() == Some(0.0)) {
9808 return Value::Str(format!("{}{}", Value::Str(format!("{}", self.parse_to_int((match ((msInt).as_f64(), (Value::Int(1000)).as_f64()) { (Some(x), Some(y)) if y != 0.0 => Value::Float(x / y), _ => Value::Null }))).into()), Value::Str("s".into())).into());
9809 }
9810 return Value::Str("".into());
9811
9812 Value::Null
9813}
9814
9815 fn is_uta_enabled(&mut self, optional_args: &[Value]) -> impl ::std::future::Future<Output = Value> + Send { async move {
9816 let mut params = get_arg(optional_args, 0, Value::Map({
9817 let mut m = indexmap::IndexMap::new();
9818 m
9819}));
9820 return Value::Bool(false);
9821
9822 Value::Null
9823} }
9824 fn close_position(&mut self, mut symbol: Value, optional_args: &[Value]) -> impl ::std::future::Future<Output = Value> + Send { async move {
9825 let mut side = get_arg(optional_args, 0, Value::Null);
9826 let mut params = get_arg(optional_args, 1, Value::Map({
9827 let mut m = indexmap::IndexMap::new();
9828 m
9829}));
9830 panic!("{}", crate::exchange_errors::not_supported(format!("{}{}", self.id.clone(), Value::Str(" closePosition() is not supported yet".into()))));
9831
9832 Value::Null
9833} }
9834
9835 fn close_all_positions(&mut self, optional_args: &[Value]) -> impl ::std::future::Future<Output = Value> + Send { async move {
9836 let mut params = get_arg(optional_args, 0, Value::Map({
9837 let mut m = indexmap::IndexMap::new();
9838 m
9839}));
9840 panic!("{}", crate::exchange_errors::not_supported(format!("{}{}", self.id.clone(), Value::Str(" closeAllPositions() is not supported yet".into()))));
9841
9842 Value::Null
9843} }
9844
9845 fn edit_orders(&mut self, mut orders: Value, optional_args: &[Value]) -> impl ::std::future::Future<Output = Value> + Send { async move {
9846 let mut params = get_arg(optional_args, 0, Value::Map({
9847 let mut m = indexmap::IndexMap::new();
9848 m
9849}));
9850 panic!("{}", crate::exchange_errors::not_supported(format!("{}{}", self.id.clone(), Value::Str(" editOrders() is not supported yet".into()))));
9851
9852 Value::Null
9853} }
9854
9855 fn fetch_canceled_and_closed_orders(&mut self, optional_args: &[Value]) -> impl ::std::future::Future<Output = Value> + Send { async move {
9856 let mut symbol = get_arg(optional_args, 0, Value::Null);
9857 let mut since = get_arg(optional_args, 1, Value::Null);
9858 let mut limit = get_arg(optional_args, 2, Value::Null);
9859 let mut params = get_arg(optional_args, 3, Value::Map({
9860 let mut m = indexmap::IndexMap::new();
9861 m
9862}));
9863 panic!("{}", crate::exchange_errors::not_supported(format!("{}{}", self.id.clone(), Value::Str(" fetchCanceledAndClosedOrders() is not supported yet".into()))));
9864
9865 Value::Null
9866} }
9867
9868 fn fetch_position_history(&mut self, mut symbol: Value, optional_args: &[Value]) -> impl ::std::future::Future<Output = Value> + Send { async move {
9869 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 {
9871 if !matches!(__v, crate::Value::Null) { return __v; }
9872 }
9873
9874 let mut since = get_arg(optional_args, 0, Value::Null);
9875 let mut limit = get_arg(optional_args, 1, Value::Null);
9876 let mut params = get_arg(optional_args, 2, Value::Map({
9877 let mut m = indexmap::IndexMap::new();
9878 m
9879}));
9880 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)) {
9891 return self.fetch_positions_history(&[Value::from(vec![symbol]), since, limit, params]).await;
9892 } else {
9893 panic!("{}", crate::exchange_errors::not_supported(format!("{}{}", self.id.clone(), Value::Str(" fetchPositionHistory () is not supported yet".into()))));
9894 }
9895} }
9896
9897 fn fetch_positions_history(&mut self, optional_args: &[Value]) -> impl ::std::future::Future<Output = Value> + Send { async move {
9898 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 {
9900 if !matches!(__v, crate::Value::Null) { return __v; }
9901 }
9902
9903 let mut symbols = get_arg(optional_args, 0, Value::Null);
9904 let mut since = get_arg(optional_args, 1, Value::Null);
9905 let mut limit = get_arg(optional_args, 2, Value::Null);
9906 let mut params = get_arg(optional_args, 3, Value::Map({
9907 let mut m = indexmap::IndexMap::new();
9908 m
9909}));
9910 panic!("{}", crate::exchange_errors::not_supported(format!("{}{}", self.id.clone(), Value::Str(" fetchPositionsHistory () is not supported yet".into()))));
9911
9912 Value::Null
9913} }
9914
9915 fn fetch_positions_risk(&mut self, optional_args: &[Value]) -> impl ::std::future::Future<Output = Value> + Send { async move {
9916 let mut symbols = get_arg(optional_args, 0, Value::Null);
9917 let mut params = get_arg(optional_args, 1, Value::Map({
9918 let mut m = indexmap::IndexMap::new();
9919 m
9920}));
9921 panic!("{}", crate::exchange_errors::not_supported(format!("{}{}", self.id.clone(), Value::Str(" fetchPositionsRisk() is not supported yet".into()))));
9922
9923 Value::Null
9924} }
9925
9926 fn fetch_positions_for_symbol(&mut self, mut symbol: Value, optional_args: &[Value]) -> impl ::std::future::Future<Output = Value> + Send { async move {
9927 let mut params = get_arg(optional_args, 0, Value::Map({
9928 let mut m = indexmap::IndexMap::new();
9929 m
9930}));
9931 panic!("{}", crate::exchange_errors::not_supported(format!("{}{}", self.id.clone(), Value::Str(" fetchPositionsForSymbol() is not supported yet".into()))));
9932
9933 Value::Null
9934} }
9935
9936 fn fetch_positions_for_symbol_ws(&mut self, mut symbol: Value, optional_args: &[Value]) -> impl ::std::future::Future<Output = Value> + Send { async move {
9937 let mut params = get_arg(optional_args, 0, Value::Map({
9938 let mut m = indexmap::IndexMap::new();
9939 m
9940}));
9941 panic!("{}", crate::exchange_errors::not_supported(format!("{}{}", self.id.clone(), Value::Str(" fetchPositionsForSymbol() is not supported yet".into()))));
9942
9943 Value::Null
9944} }
9945
9946 fn watch_position(&mut self, optional_args: &[Value]) -> impl ::std::future::Future<Output = Value> + Send { async move {
9947 let mut symbol = get_arg(optional_args, 0, Value::Null);
9948 let mut params = get_arg(optional_args, 1, Value::Map({
9949 let mut m = indexmap::IndexMap::new();
9950 m
9951}));
9952 panic!("{}", crate::exchange_errors::not_supported(format!("{}{}", self.id.clone(), Value::Str(" watchPosition() is not supported yet".into()))));
9953
9954 Value::Null
9955} }
9956
9957 fn watch_my_trades_for_symbols(&mut self, mut symbols: Value, optional_args: &[Value]) -> impl ::std::future::Future<Output = Value> + Send { async move {
9958 let mut since = get_arg(optional_args, 0, Value::Null);
9959 let mut limit = get_arg(optional_args, 1, Value::Null);
9960 let mut params = get_arg(optional_args, 2, Value::Map({
9961 let mut m = indexmap::IndexMap::new();
9962 m
9963}));
9964 panic!("{}", crate::exchange_errors::not_supported(format!("{}{}", self.id.clone(), Value::Str(" watchMyTradesForSymbols() is not supported yet".into()))));
9965
9966 Value::Null
9967} }
9968
9969 fn watch_trades_for_symbols(&mut self, mut symbols: Value, optional_args: &[Value]) -> impl ::std::future::Future<Output = Value> + Send { async move {
9970 let mut since = get_arg(optional_args, 0, Value::Null);
9971 let mut limit = get_arg(optional_args, 1, Value::Null);
9972 let mut params = get_arg(optional_args, 2, Value::Map({
9973 let mut m = indexmap::IndexMap::new();
9974 m
9975}));
9976 panic!("{}", crate::exchange_errors::not_supported(format!("{}{}", self.id.clone(), Value::Str(" watchTradesForSymbols() is not supported yet".into()))));
9977
9978 Value::Null
9979} }
9980
9981 fn fetch_bids_asks(&mut self, optional_args: &[Value]) -> impl ::std::future::Future<Output = Value> + Send { async move {
9982 let mut symbols = get_arg(optional_args, 0, Value::Null);
9983 let mut params = get_arg(optional_args, 1, Value::Map({
9984 let mut m = indexmap::IndexMap::new();
9985 m
9986}));
9987 panic!("{}", crate::exchange_errors::not_supported(format!("{}{}", self.id.clone(), Value::Str(" fetchBidsAsks() is not supported yet".into()))));
9988
9989 Value::Null
9990} }
9991
9992 fn fetch_mark_price(&mut self, mut symbol: Value, optional_args: &[Value]) -> impl ::std::future::Future<Output = Value> + Send { async move {
9993 let mut params = get_arg(optional_args, 0, Value::Map({
9994 let mut m = indexmap::IndexMap::new();
9995 m
9996}));
9997 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)) {
9998 self.load_markets(&[]).await;
9999 let mut market: Value = <Self as crate::exchange_generated::ExchangeBase>::market(self, symbol);
10000 let mut symbolResolved: Value = market.as_map().and_then(|__m| __m.get("symbol")).cloned().unwrap_or(Value::Null);
10001 let mut tickers: Value = self.fetch_mark_prices(&[Value::from(vec![symbolResolved.clone()]), params]).await;
10002 let mut ticker: Value = self.safe_dict(tickers, symbolResolved.clone(), &[]);
10003 if (ticker == Value::Null) {
10004 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)));
10005 } else {
10006 return ticker;
10007 }
10008 } else {
10009 panic!("{}", crate::exchange_errors::not_supported(format!("{}{}", self.id.clone(), Value::Str(" fetchMarkPrices() is not supported yet".into()))));
10010 }
10011
10012 Value::Null
10013} }
10014
10015 fn fetch_mark_prices(&mut self, optional_args: &[Value]) -> impl ::std::future::Future<Output = Value> + Send { async move {
10016 let mut symbols = get_arg(optional_args, 0, Value::Null);
10017 let mut params = get_arg(optional_args, 1, Value::Map({
10018 let mut m = indexmap::IndexMap::new();
10019 m
10020}));
10021 panic!("{}", crate::exchange_errors::not_supported(format!("{}{}", self.id.clone(), Value::Str(" fetchMarkPrices() is not supported yet".into()))));
10022
10023 Value::Null
10024} }
10025
10026 fn watch_bids_asks(&mut self, optional_args: &[Value]) -> impl ::std::future::Future<Output = Value> + Send { async move {
10027 let mut symbols = get_arg(optional_args, 0, Value::Null);
10028 let mut params = get_arg(optional_args, 1, Value::Map({
10029 let mut m = indexmap::IndexMap::new();
10030 m
10031}));
10032 panic!("{}", crate::exchange_errors::not_supported(format!("{}{}", self.id.clone(), Value::Str(" watchBidsAsks() is not supported yet".into()))));
10033
10034 Value::Null
10035} }
10036
10037 fn watch_mark_price(&mut self, mut symbol: Value, optional_args: &[Value]) -> impl ::std::future::Future<Output = Value> + Send { async move {
10038 let mut params = get_arg(optional_args, 0, Value::Map({
10039 let mut m = indexmap::IndexMap::new();
10040 m
10041}));
10042 panic!("{}", crate::exchange_errors::not_supported(format!("{}{}", self.id.clone(), Value::Str(" watchMarkPrice () is not supported yet".into()))));
10043
10044 Value::Null
10045} }
10046
10047 fn watch_mark_prices(&mut self, optional_args: &[Value]) -> impl ::std::future::Future<Output = Value> + Send { async move {
10048 let mut symbols = get_arg(optional_args, 0, Value::Null);
10049 let mut params = get_arg(optional_args, 1, Value::Map({
10050 let mut m = indexmap::IndexMap::new();
10051 m
10052}));
10053 panic!("{}", crate::exchange_errors::not_supported(format!("{}{}", self.id.clone(), Value::Str(" watchMarkPrices () is not supported yet".into()))));
10054
10055 Value::Null
10056} }
10057
10058 fn fetch_l3_order_book(&mut self, mut symbol: Value, optional_args: &[Value]) -> impl ::std::future::Future<Output = Value> + Send { async move {
10059 let mut limit = get_arg(optional_args, 0, Value::Null);
10060 let mut params = get_arg(optional_args, 1, Value::Map({
10061 let mut m = indexmap::IndexMap::new();
10062 m
10063}));
10064 panic!("{}", crate::exchange_errors::bad_request(format!("{}{}", self.id.clone(), Value::Str(" fetchL3OrderBook() is not supported yet".into()))));
10065
10066 Value::Null
10067} }
10068
10069 fn watch_order_book_for_symbols(&mut self, mut symbols: Value, optional_args: &[Value]) -> impl ::std::future::Future<Output = Value> + Send { async move {
10070 let mut limit = get_arg(optional_args, 0, Value::Null);
10071 let mut params = get_arg(optional_args, 1, Value::Map({
10072 let mut m = indexmap::IndexMap::new();
10073 m
10074}));
10075 panic!("{}", crate::exchange_errors::not_supported(format!("{}{}", self.id.clone(), Value::Str(" watchOrderBookForSymbols() is not supported yet".into()))));
10076
10077 Value::Null
10078} }
10079
10080 fn watch_orders_for_symbols(&mut self, mut symbols: Value, optional_args: &[Value]) -> impl ::std::future::Future<Output = Value> + Send { async move {
10081 let mut since = get_arg(optional_args, 0, Value::Null);
10082 let mut limit = get_arg(optional_args, 1, Value::Null);
10083 let mut params = get_arg(optional_args, 2, Value::Map({
10084 let mut m = indexmap::IndexMap::new();
10085 m
10086}));
10087 panic!("{}", crate::exchange_errors::not_supported(format!("{}{}", self.id.clone(), Value::Str(" watchOrdersForSymbols() is not supported yet".into()))));
10088
10089 Value::Null
10090} }
10091
10092 fn cancel_all_orders_ws(&mut self, optional_args: &[Value]) -> impl ::std::future::Future<Output = Value> + Send { async move {
10093 let mut symbol = get_arg(optional_args, 0, Value::Null);
10094 let mut params = get_arg(optional_args, 1, Value::Map({
10095 let mut m = indexmap::IndexMap::new();
10096 m
10097}));
10098 panic!("{}", crate::exchange_errors::not_supported(format!("{}{}", self.id.clone(), Value::Str(" cancelAllOrdersWs() is not supported yet".into()))));
10099
10100 Value::Null
10101} }
10102
10103 fn cancel_order_ws(&mut self, mut id: Value, optional_args: &[Value]) -> impl ::std::future::Future<Output = Value> + Send { async move {
10104 let mut symbol = get_arg(optional_args, 0, Value::Null);
10105 let mut params = get_arg(optional_args, 1, Value::Map({
10106 let mut m = indexmap::IndexMap::new();
10107 m
10108}));
10109 panic!("{}", crate::exchange_errors::not_supported(format!("{}{}", self.id.clone(), Value::Str(" cancelOrderWs() is not supported yet".into()))));
10110
10111 Value::Null
10112} }
10113
10114 fn cancel_orders_ws(&mut self, mut ids: Value, optional_args: &[Value]) -> impl ::std::future::Future<Output = Value> + Send { async move {
10115 let mut symbol = get_arg(optional_args, 0, Value::Null);
10116 let mut params = get_arg(optional_args, 1, Value::Map({
10117 let mut m = indexmap::IndexMap::new();
10118 m
10119}));
10120 panic!("{}", crate::exchange_errors::not_supported(format!("{}{}", self.id.clone(), Value::Str(" cancelOrdersWs() is not supported yet".into()))));
10121
10122 Value::Null
10123} }
10124
10125 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 {
10126 let mut params = get_arg(optional_args, 0, Value::Map({
10127 let mut m = indexmap::IndexMap::new();
10128 m
10129}));
10130 return self.create_order_ws(symbol, Value::Str("limit".into()), Value::Str("buy".into()), amount, &[price, params]).await;
10131
10132 Value::Null
10133} }
10134
10135 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 {
10136 let mut params = get_arg(optional_args, 0, Value::Map({
10137 let mut m = indexmap::IndexMap::new();
10138 m
10139}));
10140 return self.create_order_ws(symbol, Value::Str("limit".into()), side, amount, &[price, params]).await;
10141
10142 Value::Null
10143} }
10144
10145 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 {
10146 let mut params = get_arg(optional_args, 0, Value::Map({
10147 let mut m = indexmap::IndexMap::new();
10148 m
10149}));
10150 return self.create_order_ws(symbol, Value::Str("limit".into()), Value::Str("sell".into()), amount, &[price, params]).await;
10151
10152 Value::Null
10153} }
10154
10155 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 {
10156 let mut params = get_arg(optional_args, 0, Value::Map({
10157 let mut m = indexmap::IndexMap::new();
10158 m
10159}));
10160 return self.create_order_ws(symbol, Value::Str("market".into()), Value::Str("buy".into()), amount, &[Value::Null, params]).await;
10161
10162 Value::Null
10163} }
10164
10165 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 {
10166 let mut params = get_arg(optional_args, 0, Value::Map({
10167 let mut m = indexmap::IndexMap::new();
10168 m
10169}));
10170 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|
10181 __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) !=
10182 Value::Null) && (self.has.as_map().and_then(|__m| __m.get("createMarketSellOrderWithCostWs")).cloned().unwrap_or(Value::Null).as_bool() != Some(false)))) {
10183 return self.create_order_ws(symbol, Value::Str("market".into()), side, cost, &[Value::Int(1), params]).await;
10184 }
10185 panic!("{}", crate::exchange_errors::not_supported(format!("{}{}", self.id.clone(), Value::Str(" createMarketOrderWithCostWs() is not supported yet".into()))));
10186
10187 Value::Null
10188} }
10189
10190 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 {
10191 let mut price = get_arg(optional_args, 0, Value::Null);
10192 let mut params = get_arg(optional_args, 1, Value::Map({
10193 let mut m = indexmap::IndexMap::new();
10194 m
10195}));
10196 return self.create_order_ws(symbol, Value::Str("market".into()), side, amount, &[price, params]).await;
10197
10198 Value::Null
10199} }
10200
10201 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 {
10202 let mut params = get_arg(optional_args, 0, Value::Map({
10203 let mut m = indexmap::IndexMap::new();
10204 m
10205}));
10206 return self.create_order_ws(symbol, Value::Str("market".into()), Value::Str("sell".into()), amount, &[Value::Null, params]).await;
10207
10208 Value::Null
10209} }
10210
10211 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 {
10212 let mut price = get_arg(optional_args, 0, Value::Null);
10213 let mut takeProfit = get_arg(optional_args, 1, Value::Null);
10214 let mut stopLoss = get_arg(optional_args, 2, Value::Null);
10215 let mut params = get_arg(optional_args, 3, Value::Map({
10216 let mut m = indexmap::IndexMap::new();
10217 m
10218}));
10219 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()]);
10242 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)) {
10243 return self.create_order_ws(symbol, type_var, side, amount, &[price, paramsValue]).await;
10244 }
10245 panic!("{}", crate::exchange_errors::not_supported(format!("{}{}", self.id.clone(), Value::Str(" createOrderWithTakeProfitAndStopLossWs() is not supported yet".into()))));
10246
10247 Value::Null
10248} }
10249
10250 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 {
10251 let mut price = get_arg(optional_args, 0, Value::Null);
10252 let mut params = get_arg(optional_args, 1, Value::Map({
10253 let mut m = indexmap::IndexMap::new();
10254 m
10255}));
10256 panic!("{}", crate::exchange_errors::not_supported(format!("{}{}", self.id.clone(), Value::Str(" createOrderWs() is not supported yet".into()))));
10257
10258 Value::Null
10259} }
10260
10261 fn create_orders_ws(&mut self, mut orders: Value, optional_args: &[Value]) -> impl ::std::future::Future<Output = Value> + Send { async move {
10262 let mut params = get_arg(optional_args, 0, Value::Map({
10263 let mut m = indexmap::IndexMap::new();
10264 m
10265}));
10266 panic!("{}", crate::exchange_errors::not_supported(format!("{}{}", self.id.clone(), Value::Str(" createOrdersWs () is not supported yet".into()))));
10267
10268 Value::Null
10269} }
10270
10271 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 {
10272 let mut price = get_arg(optional_args, 0, Value::Null);
10273 let mut params = get_arg(optional_args, 1, Value::Map({
10274 let mut m = indexmap::IndexMap::new();
10275 m
10276}));
10277 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)) {
10278 panic!("{}", crate::exchange_errors::not_supported(format!("{}{}", self.id.clone(), Value::Str(" createPostOnlyOrderWs() is not supported yet".into()))));
10279 }
10280 let mut query: Value = self.extend(params, &[Value::Map({
10281 let mut m = indexmap::IndexMap::new();
10282 m.insert("postOnly".to_string(), Value::Bool(true));
10283 m
10284 })]);
10285 return self.create_order_ws(symbol, type_var, side, amount, &[price, query]).await;
10286
10287 Value::Null
10288} }
10289
10290 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 {
10291 let mut price = get_arg(optional_args, 0, Value::Null);
10292 let mut params = get_arg(optional_args, 1, Value::Map({
10293 let mut m = indexmap::IndexMap::new();
10294 m
10295}));
10296 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)) {
10297 panic!("{}", crate::exchange_errors::not_supported(format!("{}{}", self.id.clone(), Value::Str(" createReduceOnlyOrderWs() is not supported yet".into()))));
10298 }
10299 let mut query: Value = self.extend(params, &[Value::Map({
10300 let mut m = indexmap::IndexMap::new();
10301 m.insert("reduceOnly".to_string(), Value::Bool(true));
10302 m
10303 })]);
10304 return self.create_order_ws(symbol, type_var, side, amount, &[price, query]).await;
10305
10306 Value::Null
10307} }
10308
10309 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 {
10310 let mut params = get_arg(optional_args, 0, Value::Map({
10311 let mut m = indexmap::IndexMap::new();
10312 m
10313}));
10314 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)) {
10315 panic!("{}", crate::exchange_errors::not_supported(format!("{}{}", self.id.clone(), Value::Str(" createStopLimitOrderWs() is not supported yet".into()))));
10316 }
10317 let mut query: Value = self.extend(params, &[Value::Map({
10318 let mut m = indexmap::IndexMap::new();
10319 m.insert("stopPrice".to_string(), triggerPrice);
10320 m
10321 })]);
10322 return self.create_order_ws(symbol, Value::Str("limit".into()), side, amount, &[price, query]).await;
10323
10324 Value::Null
10325} }
10326
10327 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 {
10328 let mut price = get_arg(optional_args, 0, Value::Null);
10329 let mut stopLossPrice = get_arg(optional_args, 1, Value::Null);
10330 let mut params = get_arg(optional_args, 2, Value::Map({
10331 let mut m = indexmap::IndexMap::new();
10332 m
10333}));
10334 if (stopLossPrice == Value::Null) {
10348 panic!("{}", crate::exchange_errors::arguments_required(format!("{}{}", self.id.clone(), Value::Str(" createStopLossOrderWs() requires a stopLossPrice argument".into()))));
10349 }
10350 let mut paramsExtended: Value = self.extend(params, &[Value::Map({
10351 let mut m = indexmap::IndexMap::new();
10352 m.insert("stopLossPrice".to_string(), stopLossPrice);
10353 m
10354 })]);
10355 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)) {
10356 return self.create_order_ws(symbol, type_var, side, amount, &[price, paramsExtended]).await;
10357 }
10358 panic!("{}", crate::exchange_errors::not_supported(format!("{}{}", self.id.clone(), Value::Str(" createStopLossOrderWs() is not supported yet".into()))));
10359
10360 Value::Null
10361} }
10362
10363 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 {
10364 let mut params = get_arg(optional_args, 0, Value::Map({
10365 let mut m = indexmap::IndexMap::new();
10366 m
10367}));
10368 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)) {
10369 panic!("{}", crate::exchange_errors::not_supported(format!("{}{}", self.id.clone(), Value::Str(" createStopMarketOrderWs() is not supported yet".into()))));
10370 }
10371 let mut query: Value = self.extend(params, &[Value::Map({
10372 let mut m = indexmap::IndexMap::new();
10373 m.insert("stopPrice".to_string(), triggerPrice);
10374 m
10375 })]);
10376 return self.create_order_ws(symbol, Value::Str("market".into()), side, amount, &[Value::Null, query]).await;
10377
10378 Value::Null
10379} }
10380
10381 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 {
10382 let mut price = get_arg(optional_args, 0, Value::Null);
10383 let mut triggerPrice = get_arg(optional_args, 1, Value::Null);
10384 let mut params = get_arg(optional_args, 2, Value::Map({
10385 let mut m = indexmap::IndexMap::new();
10386 m
10387}));
10388 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)) {
10389 panic!("{}", crate::exchange_errors::not_supported(format!("{}{}", self.id.clone(), Value::Str(" createStopOrderWs() is not supported yet".into()))));
10390 }
10391 if (triggerPrice == Value::Null) {
10392 panic!("{}", crate::exchange_errors::arguments_required(format!("{}{}", self.id.clone(), Value::Str(" createStopOrderWs() requires a stopPrice argument".into()))));
10393 }
10394 let mut query: Value = self.extend(params, &[Value::Map({
10395 let mut m = indexmap::IndexMap::new();
10396 m.insert("stopPrice".to_string(), triggerPrice);
10397 m
10398 })]);
10399 return self.create_order_ws(symbol, type_var, side, amount, &[price, query]).await;
10400
10401 Value::Null
10402} }
10403
10404 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 {
10405 let mut price = get_arg(optional_args, 0, Value::Null);
10406 let mut takeProfitPrice = get_arg(optional_args, 1, Value::Null);
10407 let mut params = get_arg(optional_args, 2, Value::Map({
10408 let mut m = indexmap::IndexMap::new();
10409 m
10410}));
10411 if (takeProfitPrice == Value::Null) {
10425 panic!("{}", crate::exchange_errors::arguments_required(format!("{}{}", self.id.clone(), Value::Str(" createTakeProfitOrderWs() requires a takeProfitPrice argument".into()))));
10426 }
10427 let mut paramsExtended: Value = self.extend(params, &[Value::Map({
10428 let mut m = indexmap::IndexMap::new();
10429 m.insert("takeProfitPrice".to_string(), takeProfitPrice);
10430 m
10431 })]);
10432 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)) {
10433 return self.create_order_ws(symbol, type_var, side, amount, &[price, paramsExtended]).await;
10434 }
10435 panic!("{}", crate::exchange_errors::not_supported(format!("{}{}", self.id.clone(), Value::Str(" createTakeProfitOrderWs() is not supported yet".into()))));
10436
10437 Value::Null
10438} }
10439
10440 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 {
10441 let mut price = get_arg(optional_args, 0, Value::Null);
10442 let mut trailingAmount = get_arg(optional_args, 1, Value::Null);
10443 let mut trailingTriggerPrice = get_arg(optional_args, 2, Value::Null);
10444 let mut params = get_arg(optional_args, 3, Value::Map({
10445 let mut m = indexmap::IndexMap::new();
10446 m
10447}));
10448 if (trailingAmount == Value::Null) {
10463 panic!("{}", crate::exchange_errors::arguments_required(format!("{}{}", self.id.clone(), Value::Str(" createTrailingAmountOrderWs() requires a trailingAmount argument".into()))));
10464 }
10465 if let Value::Dict(__d) = &mut params { std::sync::Arc::make_mut(__d).insert("trailingAmount".into(), trailingAmount); }
10466 if (trailingTriggerPrice != Value::Null) {
10467 if let Value::Dict(__d) = &mut params { std::sync::Arc::make_mut(__d).insert("trailingTriggerPrice".into(), trailingTriggerPrice); }
10468 }
10469 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)) {
10470 return self.create_order_ws(symbol, type_var, side, amount, &[price, params]).await;
10471 }
10472 panic!("{}", crate::exchange_errors::not_supported(format!("{}{}", self.id.clone(), Value::Str(" createTrailingAmountOrderWs() is not supported yet".into()))));
10473
10474 Value::Null
10475} }
10476
10477 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 {
10478 let mut price = get_arg(optional_args, 0, Value::Null);
10479 let mut trailingPercent = get_arg(optional_args, 1, Value::Null);
10480 let mut trailingTriggerPrice = get_arg(optional_args, 2, Value::Null);
10481 let mut params = get_arg(optional_args, 3, Value::Map({
10482 let mut m = indexmap::IndexMap::new();
10483 m
10484}));
10485 if (trailingPercent == Value::Null) {
10500 panic!("{}", crate::exchange_errors::arguments_required(format!("{}{}", self.id.clone(), Value::Str(" createTrailingPercentOrderWs() requires a trailingPercent argument".into()))));
10501 }
10502 if let Value::Dict(__d) = &mut params { std::sync::Arc::make_mut(__d).insert("trailingPercent".into(), trailingPercent); }
10503 if (trailingTriggerPrice != Value::Null) {
10504 if let Value::Dict(__d) = &mut params { std::sync::Arc::make_mut(__d).insert("trailingTriggerPrice".into(), trailingTriggerPrice); }
10505 }
10506 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)) {
10507 return self.create_order_ws(symbol, type_var, side, amount, &[price, params]).await;
10508 }
10509 panic!("{}", crate::exchange_errors::not_supported(format!("{}{}", self.id.clone(), Value::Str(" createTrailingPercentOrderWs() is not supported yet".into()))));
10510
10511 Value::Null
10512} }
10513
10514 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 {
10515 let mut price = get_arg(optional_args, 0, Value::Null);
10516 let mut triggerPrice = get_arg(optional_args, 1, Value::Null);
10517 let mut params = get_arg(optional_args, 2, Value::Map({
10518 let mut m = indexmap::IndexMap::new();
10519 m
10520}));
10521 if (triggerPrice == Value::Null) {
10535 panic!("{}", crate::exchange_errors::arguments_required(format!("{}{}", self.id.clone(), Value::Str(" createTriggerOrderWs() requires a triggerPrice argument".into()))));
10536 }
10537 let mut paramsExtended: Value = self.extend(params, &[Value::Map({
10538 let mut m = indexmap::IndexMap::new();
10539 m.insert("triggerPrice".to_string(), triggerPrice);
10540 m
10541 })]);
10542 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)) {
10543 return self.create_order_ws(symbol, type_var, side, amount, &[price, paramsExtended]).await;
10544 }
10545 panic!("{}", crate::exchange_errors::not_supported(format!("{}{}", self.id.clone(), Value::Str(" createTriggerOrderWs() is not supported yet".into()))));
10546
10547 Value::Null
10548} }
10549
10550 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 {
10551 let mut amount = get_arg(optional_args, 0, Value::Null);
10552 let mut price = get_arg(optional_args, 1, Value::Null);
10553 let mut params = get_arg(optional_args, 2, Value::Map({
10554 let mut m = indexmap::IndexMap::new();
10555 m
10556}));
10557 self.cancel_order_ws(id, &[symbol.clone()]).await;
10558 return self.create_order_ws(symbol, type_var, side, amount, &[price, params]).await;
10559
10560 Value::Null
10561} }
10562
10563 fn fetch_closed_orders_ws(&mut self, optional_args: &[Value]) -> impl ::std::future::Future<Output = Value> + Send { async move {
10564 let mut symbol = get_arg(optional_args, 0, Value::Null);
10565 let mut since = get_arg(optional_args, 1, Value::Null);
10566 let mut limit = get_arg(optional_args, 2, Value::Null);
10567 let mut params = get_arg(optional_args, 3, Value::Map({
10568 let mut m = indexmap::IndexMap::new();
10569 m
10570}));
10571 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)) {
10572 let mut orders: Value = self.fetch_orders_ws(&[symbol, since, limit, params]).await;
10573 return self.filter_by(orders, Value::Str("status".into()), Value::Str("closed".into()), &[]);
10574 }
10575 panic!("{}", crate::exchange_errors::not_supported(format!("{}{}", self.id.clone(), Value::Str(" fetchClosedOrdersWs() is not supported yet".into()))));
10576
10577 Value::Null
10578} }
10579
10580 fn fetch_my_trades_ws(&mut self, optional_args: &[Value]) -> impl ::std::future::Future<Output = Value> + Send { async move {
10581 let mut symbol = get_arg(optional_args, 0, Value::Null);
10582 let mut since = get_arg(optional_args, 1, Value::Null);
10583 let mut limit = get_arg(optional_args, 2, Value::Null);
10584 let mut params = get_arg(optional_args, 3, Value::Map({
10585 let mut m = indexmap::IndexMap::new();
10586 m
10587}));
10588 panic!("{}", crate::exchange_errors::not_supported(format!("{}{}", self.id.clone(), Value::Str(" fetchMyTradesWs() is not supported yet".into()))));
10589
10590 Value::Null
10591} }
10592
10593 fn fetch_open_orders_ws(&mut self, optional_args: &[Value]) -> impl ::std::future::Future<Output = Value> + Send { async move {
10594 let mut symbol = get_arg(optional_args, 0, Value::Null);
10595 let mut since = get_arg(optional_args, 1, Value::Null);
10596 let mut limit = get_arg(optional_args, 2, Value::Null);
10597 let mut params = get_arg(optional_args, 3, Value::Map({
10598 let mut m = indexmap::IndexMap::new();
10599 m
10600}));
10601 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)) {
10602 let mut orders: Value = self.fetch_orders_ws(&[symbol, since, limit, params]).await;
10603 return self.filter_by(orders, Value::Str("status".into()), Value::Str("open".into()), &[]);
10604 }
10605 panic!("{}", crate::exchange_errors::not_supported(format!("{}{}", self.id.clone(), Value::Str(" fetchOpenOrdersWs() is not supported yet".into()))));
10606
10607 Value::Null
10608} }
10609
10610 fn fetch_order_book_ws(&mut self, mut symbol: Value, optional_args: &[Value]) -> impl ::std::future::Future<Output = Value> + Send { async move {
10611 let mut limit = get_arg(optional_args, 0, Value::Null);
10612 let mut params = get_arg(optional_args, 1, Value::Map({
10613 let mut m = indexmap::IndexMap::new();
10614 m
10615}));
10616 panic!("{}", crate::exchange_errors::not_supported(format!("{}{}", self.id.clone(), Value::Str(" fetchOrderBookWs() is not supported yet".into()))));
10617
10618 Value::Null
10619} }
10620
10621 fn fetch_order_ws(&mut self, mut id: Value, optional_args: &[Value]) -> impl ::std::future::Future<Output = Value> + Send { async move {
10622 let mut symbol = get_arg(optional_args, 0, Value::Null);
10623 let mut params = get_arg(optional_args, 1, Value::Map({
10624 let mut m = indexmap::IndexMap::new();
10625 m
10626}));
10627 panic!("{}", crate::exchange_errors::not_supported(format!("{}{}", self.id.clone(), Value::Str(" fetchOrderWs() is not supported yet".into()))));
10628
10629 Value::Null
10630} }
10631
10632 fn fetch_orders_ws(&mut self, optional_args: &[Value]) -> impl ::std::future::Future<Output = Value> + Send { async move {
10633 let mut symbol = get_arg(optional_args, 0, Value::Null);
10634 let mut since = get_arg(optional_args, 1, Value::Null);
10635 let mut limit = get_arg(optional_args, 2, Value::Null);
10636 let mut params = get_arg(optional_args, 3, Value::Map({
10637 let mut m = indexmap::IndexMap::new();
10638 m
10639}));
10640 panic!("{}", crate::exchange_errors::not_supported(format!("{}{}", self.id.clone(), Value::Str(" fetchOrdersWs() is not supported yet".into()))));
10641
10642 Value::Null
10643} }
10644
10645 fn fetch_position_ws(&mut self, mut symbol: Value, optional_args: &[Value]) -> impl ::std::future::Future<Output = Value> + Send { async move {
10646 let mut params = get_arg(optional_args, 0, Value::Map({
10647 let mut m = indexmap::IndexMap::new();
10648 m
10649}));
10650 panic!("{}", crate::exchange_errors::not_supported(format!("{}{}", self.id.clone(), Value::Str(" fetchPositionWs() is not supported yet".into()))));
10651
10652 Value::Null
10653} }
10654
10655 fn fetch_positions_ws(&mut self, optional_args: &[Value]) -> impl ::std::future::Future<Output = Value> + Send { async move {
10656 let mut symbols = get_arg(optional_args, 0, Value::Null);
10657 let mut params = get_arg(optional_args, 1, Value::Map({
10658 let mut m = indexmap::IndexMap::new();
10659 m
10660}));
10661 panic!("{}", crate::exchange_errors::not_supported(format!("{}{}", self.id.clone(), Value::Str(" fetchPositions() is not supported yet".into()))));
10662
10663 Value::Null
10664} }
10665
10666 fn fetch_ticker_ws(&mut self, mut symbol: Value, optional_args: &[Value]) -> impl ::std::future::Future<Output = Value> + Send { async move {
10667 let mut params = get_arg(optional_args, 0, Value::Map({
10668 let mut m = indexmap::IndexMap::new();
10669 m
10670}));
10671 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)) {
10672 self.load_markets(&[]).await;
10673 let mut market: Value = <Self as crate::exchange_generated::ExchangeBase>::market(self, symbol);
10674 let mut symbolResolved: Value = market.as_map().and_then(|__m| __m.get("symbol")).cloned().unwrap_or(Value::Null);
10675 let mut tickers: Value = self.fetch_tickers_ws(&[Value::from(vec![symbolResolved.clone()]), params]).await;
10676 let mut ticker: Value = self.safe_dict(tickers, symbolResolved.clone(), &[]);
10677 if (ticker == Value::Null) {
10678 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)));
10679 } else {
10680 return ticker;
10681 }
10682 } else {
10683 panic!("{}", crate::exchange_errors::not_supported(format!("{}{}", self.id.clone(), Value::Str(" fetchTickerWs() is not supported yet".into()))));
10684 }
10685
10686 Value::Null
10687} }
10688
10689 fn fetch_tickers_ws(&mut self, optional_args: &[Value]) -> impl ::std::future::Future<Output = Value> + Send { async move {
10690 let mut symbols = get_arg(optional_args, 0, Value::Null);
10691 let mut params = get_arg(optional_args, 1, Value::Map({
10692 let mut m = indexmap::IndexMap::new();
10693 m
10694}));
10695 panic!("{}", crate::exchange_errors::not_supported(format!("{}{}", self.id.clone(), Value::Str(" fetchTickersWs() is not supported yet".into()))));
10696
10697 Value::Null
10698} }
10699
10700 fn fetch_trades_ws(&mut self, mut symbol: Value, optional_args: &[Value]) -> impl ::std::future::Future<Output = Value> + Send { async move {
10701 let mut since = get_arg(optional_args, 0, Value::Null);
10702 let mut limit = get_arg(optional_args, 1, Value::Null);
10703 let mut params = get_arg(optional_args, 2, Value::Map({
10704 let mut m = indexmap::IndexMap::new();
10705 m
10706}));
10707 panic!("{}", crate::exchange_errors::not_supported(format!("{}{}", self.id.clone(), Value::Str(" fetchTradesWs() is not supported yet".into()))));
10708
10709 Value::Null
10710} }
10711
10712
10713 fn fetch_trades(&mut self, mut symbol: Value, optional_args: &[Value]) -> impl ::std::future::Future<Output = Value> + Send { async move {
10714 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 {
10716 if !matches!(__v, crate::Value::Null) { return __v; }
10717 }
10718
10719 let mut since = get_arg(optional_args, 0, Value::Null);
10720 let mut limit = get_arg(optional_args, 1, Value::Null);
10721 let mut params = get_arg(optional_args, 2, Value::Map({
10722 let mut m = indexmap::IndexMap::new();
10723 m
10724}));
10725 panic!("{}", crate::exchange_errors::not_supported(format!("{}{}", self.id.clone(), Value::Str(" fetchTrades() is not supported yet".into()))));
10726
10727 Value::Null
10728} }
10729
10730 fn watch_trades(&mut self, mut symbol: Value, optional_args: &[Value]) -> impl ::std::future::Future<Output = Value> + Send { async move {
10731 let mut since = get_arg(optional_args, 0, Value::Null);
10732 let mut limit = get_arg(optional_args, 1, Value::Null);
10733 let mut params = get_arg(optional_args, 2, Value::Map({
10734 let mut m = indexmap::IndexMap::new();
10735 m
10736}));
10737 panic!("{}", crate::exchange_errors::not_supported(format!("{}{}", self.id.clone(), Value::Str(" watchTrades() is not supported yet".into()))));
10738
10739 Value::Null
10740} }
10741
10742 fn fetch_order_book(&mut self, mut symbol: Value, optional_args: &[Value]) -> impl ::std::future::Future<Output = Value> + Send { async move {
10743 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 {
10745 if !matches!(__v, crate::Value::Null) { return __v; }
10746 }
10747
10748 let mut limit = get_arg(optional_args, 0, Value::Null);
10749 let mut params = get_arg(optional_args, 1, Value::Map({
10750 let mut m = indexmap::IndexMap::new();
10751 m
10752}));
10753 panic!("{}", crate::exchange_errors::not_supported(format!("{}{}", self.id.clone(), Value::Str(" fetchOrderBook() is not supported yet".into()))));
10754
10755 Value::Null
10756} }
10757
10758 fn fetch_rest_order_book_safe(&mut self, mut symbol: Value, optional_args: &[Value]) -> impl ::std::future::Future<Output = Value> + Send { async move {
10759 let mut limit = get_arg(optional_args, 0, Value::Null);
10760 let mut params = get_arg(optional_args, 1, Value::Map({
10761 let mut m = indexmap::IndexMap::new();
10762 m
10763}));
10764 let mut fetchSnapshotMaxRetries: Value = self.handle_option(Value::Str("watchOrderBook".into()), Value::Str("maxRetries".into()), &[Value::Int(3)]);
10765 {
10766 let mut i: Value = Value::Int(0);
10767 let mut __for_first_186: bool = true;
10768 while { if !__for_first_186 { if let Value::Int(n) = &mut i { *n += 1; } } __for_first_186 = false; i.as_f64().unwrap_or(f64::NAN) < fetchSnapshotMaxRetries.as_f64().unwrap_or(f64::NAN) } {
10769 let _try_result = futures::FutureExt::catch_unwind(std::panic::AssertUnwindSafe(async {
10770 let mut orderBook: Value = self.fetch_order_book(symbol.clone(), &[limit.clone(), params.clone()]).await;
10771 return orderBook;
10772 #[allow(unreachable_code)] { Value::Null }})).await;
10773match _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);
10774 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) {
10775 panic!("{}", e);
10776 }
10777 } }
10778 }
10779 }
10780 return Value::Null;
10781
10782 Value::Null
10783} }
10784
10785 fn watch_order_book(&mut self, mut symbol: Value, optional_args: &[Value]) -> impl ::std::future::Future<Output = Value> + Send { async move {
10786 let mut limit = get_arg(optional_args, 0, Value::Null);
10787 let mut params = get_arg(optional_args, 1, Value::Map({
10788 let mut m = indexmap::IndexMap::new();
10789 m
10790}));
10791 panic!("{}", crate::exchange_errors::not_supported(format!("{}{}", self.id.clone(), Value::Str(" watchOrderBook() is not supported yet".into()))));
10792
10793 Value::Null
10794} }
10795
10796 fn fetch_open_interest(&mut self, mut symbol: Value, optional_args: &[Value]) -> impl ::std::future::Future<Output = Value> + Send { async move {
10797 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 {
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 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)) {
10807 let mut openInterests: Value = self.fetch_open_interests(&[Value::from(vec![symbol.clone()]), params]).await;
10808 let mut openInterest: Value = self.safe_dict(openInterests, symbol, &[]);
10809 return openInterest;
10810 } else {
10811 panic!("{}", crate::exchange_errors::not_supported(format!("{}{}", self.id.clone(), Value::Str(" fetchOpenInterest() is not supported yet".into()))));
10812 }
10813
10814 Value::Null
10815} }
10816
10817 fn fetch_l2_order_book(&mut self, mut symbol: Value, optional_args: &[Value]) -> impl ::std::future::Future<Output = Value> + Send { async move {
10818 let mut limit = get_arg(optional_args, 0, Value::Null);
10819 let mut params = get_arg(optional_args, 1, Value::Map({
10820 let mut m = indexmap::IndexMap::new();
10821 m
10822}));
10823 let mut orderbook: Value = self.fetch_order_book(symbol, &[limit, params]).await;
10824 return self.extend(orderbook.clone(), &[Value::Map({
10825 let mut m = indexmap::IndexMap::new();
10826 m.insert("asks".to_string(), self.sort_by(self.aggregate(orderbook.book_field("asks")), Value::Int(0), &[]));
10827 m.insert("bids".to_string(), self.sort_by(self.aggregate(orderbook.book_field("bids")), Value::Int(0), &[Value::Bool(true)]));
10828 m
10829})]);
10830
10831 Value::Null
10832} }
10833
10834 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 {
10835 let mut price = get_arg(optional_args, 0, Value::Null);
10836 let mut params = get_arg(optional_args, 1, Value::Map({
10837 let mut m = indexmap::IndexMap::new();
10838 m
10839}));
10840 return self.edit_limit_order(id, symbol, Value::Str("buy".into()), amount, &[price, params]).await;
10841
10842 Value::Null
10843} }
10844
10845 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 {
10846 let mut price = get_arg(optional_args, 0, Value::Null);
10847 let mut params = get_arg(optional_args, 1, Value::Map({
10848 let mut m = indexmap::IndexMap::new();
10849 m
10850}));
10851 return self.edit_limit_order(id, symbol, Value::Str("sell".into()), amount, &[price, params]).await;
10852
10853 Value::Null
10854} }
10855
10856 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 {
10857 let mut price = get_arg(optional_args, 0, Value::Null);
10858 let mut params = get_arg(optional_args, 1, Value::Map({
10859 let mut m = indexmap::IndexMap::new();
10860 m
10861}));
10862 return self.edit_order(id, symbol, Value::Str("limit".into()), side, &[amount, price, params]).await;
10863
10864 Value::Null
10865} }
10866
10867 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 {
10868 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 {
10870 if !matches!(__v, crate::Value::Null) { return __v; }
10871 }
10872
10873 let mut amount = get_arg(optional_args, 0, Value::Null);
10874 let mut price = get_arg(optional_args, 1, Value::Null);
10875 let mut params = get_arg(optional_args, 2, Value::Map({
10876 let mut m = indexmap::IndexMap::new();
10877 m
10878}));
10879 self.cancel_order(id, &[symbol.clone()]).await;
10880 return self.create_order(symbol, type_var, side, amount, &[price, params]).await;
10881
10882 Value::Null
10883} }
10884
10885 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 {
10886 let mut amount = get_arg(optional_args, 0, Value::Null);
10887 let mut price = get_arg(optional_args, 1, Value::Null);
10888 let mut params = get_arg(optional_args, 2, Value::Map({
10889 let mut m = indexmap::IndexMap::new();
10890 m
10891}));
10892 let mut extendedParams: Value = self.extend(params, &[Value::Map({
10893 let mut m = indexmap::IndexMap::new();
10894 m.insert("clientOrderId".to_string(), clientOrderId);
10895 m
10896 })]);
10897 return self.edit_order(Value::Str("".into()), symbol, type_var, side, &[amount, price, extendedParams]).await;
10898
10899 Value::Null
10900} }
10901
10902 fn fetch_position(&mut self, mut symbol: Value, optional_args: &[Value]) -> impl ::std::future::Future<Output = Value> + Send { async move {
10903 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 {
10905 if !matches!(__v, crate::Value::Null) { return __v; }
10906 }
10907
10908 let mut params = get_arg(optional_args, 0, Value::Map({
10909 let mut m = indexmap::IndexMap::new();
10910 m
10911}));
10912 panic!("{}", crate::exchange_errors::not_supported(format!("{}{}", self.id.clone(), Value::Str(" fetchPosition() is not supported yet".into()))));
10913
10914 Value::Null
10915} }
10916
10917 fn watch_positions(&mut self, optional_args: &[Value]) -> impl ::std::future::Future<Output = Value> + Send { async move {
10918 let mut symbols = get_arg(optional_args, 0, Value::Null);
10919 let mut since = get_arg(optional_args, 1, Value::Null);
10920 let mut limit = get_arg(optional_args, 2, Value::Null);
10921 let mut params = get_arg(optional_args, 3, Value::Map({
10922 let mut m = indexmap::IndexMap::new();
10923 m
10924}));
10925 panic!("{}", crate::exchange_errors::not_supported(format!("{}{}", self.id.clone(), Value::Str(" watchPositions() is not supported yet".into()))));
10926
10927 Value::Null
10928} }
10929
10930 fn watch_position_for_symbols(&mut self, optional_args: &[Value]) -> impl ::std::future::Future<Output = Value> + Send { async move {
10931 let mut symbols = get_arg(optional_args, 0, Value::Null);
10932 let mut since = get_arg(optional_args, 1, Value::Null);
10933 let mut limit = get_arg(optional_args, 2, Value::Null);
10934 let mut params = get_arg(optional_args, 3, Value::Map({
10935 let mut m = indexmap::IndexMap::new();
10936 m
10937}));
10938 return self.watch_positions(&[symbols, since, limit, params]).await;
10939
10940 Value::Null
10941} }
10942
10943 fn fetch_positions(&mut self, optional_args: &[Value]) -> impl ::std::future::Future<Output = Value> + Send { async move {
10944 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 {
10946 if !matches!(__v, crate::Value::Null) { return __v; }
10947 }
10948
10949 let mut symbols = get_arg(optional_args, 0, Value::Null);
10950 let mut params = get_arg(optional_args, 1, Value::Map({
10951 let mut m = indexmap::IndexMap::new();
10952 m
10953}));
10954 panic!("{}", crate::exchange_errors::not_supported(format!("{}{}", self.id.clone(), Value::Str(" fetchPositions() is not supported yet".into()))));
10955
10956 Value::Null
10957} }
10958
10959 fn fetch_ticker(&mut self, mut symbol: Value, optional_args: &[Value]) -> impl ::std::future::Future<Output = Value> + Send { async move {
10960 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 {
10962 if !matches!(__v, crate::Value::Null) { return __v; }
10963 }
10964
10965 let mut params = get_arg(optional_args, 0, Value::Map({
10966 let mut m = indexmap::IndexMap::new();
10967 m
10968}));
10969 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)) {
10970 self.load_markets(&[]).await;
10971 let mut market: Value = <Self as crate::exchange_generated::ExchangeBase>::market(self, symbol);
10972 let mut symbolResolved: Value = market.as_map().and_then(|__m| __m.get("symbol")).cloned().unwrap_or(Value::Null);
10973 let mut tickers: Value = self.fetch_tickers(&[Value::from(vec![symbolResolved.clone()]), params]).await;
10974 let mut ticker: Value = self.safe_dict(tickers, symbolResolved.clone(), &[]);
10975 if (ticker == Value::Null) {
10976 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)));
10977 } else {
10978 return ticker;
10979 }
10980 } else {
10981 panic!("{}", crate::exchange_errors::not_supported(format!("{}{}", self.id.clone(), Value::Str(" fetchTicker() is not supported yet".into()))));
10982 }
10983
10984 Value::Null
10985} }
10986
10987 fn watch_ticker(&mut self, mut symbol: Value, optional_args: &[Value]) -> impl ::std::future::Future<Output = Value> + Send { async move {
10988 let mut params = get_arg(optional_args, 0, Value::Map({
10989 let mut m = indexmap::IndexMap::new();
10990 m
10991}));
10992 panic!("{}", crate::exchange_errors::not_supported(format!("{}{}", self.id.clone(), Value::Str(" watchTicker() is not supported yet".into()))));
10993
10994 Value::Null
10995} }
10996
10997 fn fetch_tickers(&mut self, optional_args: &[Value]) -> impl ::std::future::Future<Output = Value> + Send { async move {
10998 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 {
11000 if !matches!(__v, crate::Value::Null) { return __v; }
11001 }
11002
11003 let mut symbols = get_arg(optional_args, 0, Value::Null);
11004 let mut params = get_arg(optional_args, 1, Value::Map({
11005 let mut m = indexmap::IndexMap::new();
11006 m
11007}));
11008 panic!("{}", crate::exchange_errors::not_supported(format!("{}{}", self.id.clone(), Value::Str(" fetchTickers() is not supported yet".into()))));
11009
11010 Value::Null
11011} }
11012
11013 fn watch_tickers(&mut self, optional_args: &[Value]) -> impl ::std::future::Future<Output = Value> + Send { async move {
11014 let mut symbols = get_arg(optional_args, 0, Value::Null);
11015 let mut params = get_arg(optional_args, 1, Value::Map({
11016 let mut m = indexmap::IndexMap::new();
11017 m
11018}));
11019 panic!("{}", crate::exchange_errors::not_supported(format!("{}{}", self.id.clone(), Value::Str(" watchTickers() is not supported yet".into()))));
11020
11021 Value::Null
11022} }
11023
11024 fn fetch_order(&mut self, mut id: Value, optional_args: &[Value]) -> impl ::std::future::Future<Output = Value> + Send { async move {
11025 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 {
11027 if !matches!(__v, crate::Value::Null) { return __v; }
11028 }
11029
11030 let mut symbol = get_arg(optional_args, 0, Value::Null);
11031 let mut params = get_arg(optional_args, 1, Value::Map({
11032 let mut m = indexmap::IndexMap::new();
11033 m
11034}));
11035 panic!("{}", crate::exchange_errors::not_supported(format!("{}{}", self.id.clone(), Value::Str(" fetchOrder() is not supported yet".into()))));
11036
11037 Value::Null
11038} }
11039
11040fn fetch_order_with_client_order_id(&mut self, mut clientOrderId: Value, optional_args: &[Value]) -> impl ::std::future::Future<Output = Value> + Send { async move {
11050 let mut symbol = get_arg(optional_args, 0, Value::Null);
11051 let mut params = get_arg(optional_args, 1, Value::Map({
11052 let mut m = indexmap::IndexMap::new();
11053 m
11054}));
11055 let mut extendedParams: Value = self.extend(params, &[Value::Map({
11056 let mut m = indexmap::IndexMap::new();
11057 m.insert("clientOrderId".to_string(), clientOrderId);
11058 m
11059 })]);
11060 return self.fetch_order(Value::Str("".into()), &[symbol, extendedParams]).await;
11061
11062 Value::Null
11063} }
11064
11065 fn fetch_order_status(&mut self, mut id: Value, optional_args: &[Value]) -> impl ::std::future::Future<Output = Value> + Send { async move {
11066 let mut symbol = get_arg(optional_args, 0, Value::Null);
11067 let mut params = get_arg(optional_args, 1, Value::Map({
11068 let mut m = indexmap::IndexMap::new();
11069 m
11070}));
11071 let mut order: Value = self.fetch_order(id, &[symbol, params]).await;
11074 return self.safe_string_k(order, "status", &[]);
11075
11076 Value::Null
11077} }
11078
11079 fn fetch_unified_order(&mut self, mut order: Value, optional_args: &[Value]) -> impl ::std::future::Future<Output = Value> + Send { async move {
11080 let mut params = get_arg(optional_args, 0, Value::Map({
11081 let mut m = indexmap::IndexMap::new();
11082 m
11083}));
11084 return self.fetch_order(self.safe_string_k(order.clone(), "id", &[Value::Str("".into())]), &[self.safe_string_k(order, "symbol", &[]), params]).await;
11085
11086 Value::Null
11087} }
11088
11089 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 {
11090 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 {
11092 if !matches!(__v, crate::Value::Null) { return __v; }
11093 }
11094
11095 let mut price = get_arg(optional_args, 0, Value::Null);
11096 let mut params = get_arg(optional_args, 1, Value::Map({
11097 let mut m = indexmap::IndexMap::new();
11098 m
11099}));
11100 panic!("{}", crate::exchange_errors::not_supported(format!("{}{}", self.id.clone(), Value::Str(" createOrder() is not supported yet".into()))));
11101
11102 Value::Null
11103} }
11104
11105 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 {
11106 let mut price = get_arg(optional_args, 0, Value::Null);
11107 let mut trailingAmount = get_arg(optional_args, 1, Value::Null);
11108 let mut trailingTriggerPrice = get_arg(optional_args, 2, Value::Null);
11109 let mut params = get_arg(optional_args, 3, Value::Map({
11110 let mut m = indexmap::IndexMap::new();
11111 m
11112}));
11113 if (trailingAmount == Value::Null) {
11128 panic!("{}", crate::exchange_errors::arguments_required(format!("{}{}", self.id.clone(), Value::Str(" createTrailingAmountOrder() requires a trailingAmount argument".into()))));
11129 }
11130 if let Value::Dict(__d) = &mut params { std::sync::Arc::make_mut(__d).insert("trailingAmount".into(), trailingAmount); }
11131 if (trailingTriggerPrice != Value::Null) {
11132 if let Value::Dict(__d) = &mut params { std::sync::Arc::make_mut(__d).insert("trailingTriggerPrice".into(), trailingTriggerPrice); }
11133 }
11134 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)) {
11135 return self.create_order(symbol, type_var, side, amount, &[price, params]).await;
11136 }
11137 panic!("{}", crate::exchange_errors::not_supported(format!("{}{}", self.id.clone(), Value::Str(" createTrailingAmountOrder() is not supported yet".into()))));
11138
11139 Value::Null
11140} }
11141
11142 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 {
11143 let mut price = get_arg(optional_args, 0, Value::Null);
11144 let mut trailingPercent = get_arg(optional_args, 1, Value::Null);
11145 let mut trailingTriggerPrice = get_arg(optional_args, 2, Value::Null);
11146 let mut params = get_arg(optional_args, 3, Value::Map({
11147 let mut m = indexmap::IndexMap::new();
11148 m
11149}));
11150 if (trailingPercent == Value::Null) {
11165 panic!("{}", crate::exchange_errors::arguments_required(format!("{}{}", self.id.clone(), Value::Str(" createTrailingPercentOrder() requires a trailingPercent argument".into()))));
11166 }
11167 if let Value::Dict(__d) = &mut params { std::sync::Arc::make_mut(__d).insert("trailingPercent".into(), trailingPercent); }
11168 if (trailingTriggerPrice != Value::Null) {
11169 if let Value::Dict(__d) = &mut params { std::sync::Arc::make_mut(__d).insert("trailingTriggerPrice".into(), trailingTriggerPrice); }
11170 }
11171 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)) {
11172 return self.create_order(symbol, type_var, side, amount, &[price, params]).await;
11173 }
11174 panic!("{}", crate::exchange_errors::not_supported(format!("{}{}", self.id.clone(), Value::Str(" createTrailingPercentOrder() is not supported yet".into()))));
11175
11176 Value::Null
11177} }
11178
11179 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 {
11180 let mut params = get_arg(optional_args, 0, Value::Map({
11181 let mut m = indexmap::IndexMap::new();
11182 m
11183}));
11184 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|
11195 __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) !=
11196 Value::Null) && (self.has.as_map().and_then(|__m| __m.get("createMarketSellOrderWithCost")).cloned().unwrap_or(Value::Null).as_bool() != Some(false)))) {
11197 return self.create_order(symbol, Value::Str("market".into()), side, cost, &[Value::Int(1), params]).await;
11198 }
11199 panic!("{}", crate::exchange_errors::not_supported(format!("{}{}", self.id.clone(), Value::Str(" createMarketOrderWithCost() is not supported yet".into()))));
11200
11201 Value::Null
11202} }
11203
11204 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 {
11205 let mut params = get_arg(optional_args, 0, Value::Map({
11206 let mut m = indexmap::IndexMap::new();
11207 m
11208}));
11209 if ((match &(self.options.as_map().and_then(|__m| __m.get("createMarketBuyOrderRequiresPrice")).cloned().unwrap_or(Value::Null)) { Value::Bool(__x) => *__x == true, __v => matches!((match __v { Value::Int(__n) => Some(*__n as f64), Value::Float(__f) => Some(*__f), Value::Str(__s) => __s.parse::<f64>().ok(),
11219 Value::Bool(__b) => Some(if *__b { 1.0 } else { 0.0 }), _ => None }), Some(__y) if __y == 1.0) })) || ((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))) {
11220 return self.create_order(symbol, Value::Str("market".into()), Value::Str("buy".into()), cost, &[Value::Int(1), params]).await;
11221 }
11222 panic!("{}", crate::exchange_errors::not_supported(format!("{}{}", self.id.clone(), Value::Str(" createMarketBuyOrderWithCost() is not supported yet".into()))));
11223
11224 Value::Null
11225} }
11226
11227 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 {
11228 let mut params = get_arg(optional_args, 0, Value::Map({
11229 let mut m = indexmap::IndexMap::new();
11230 m
11231}));
11232 if ((match &(self.options.as_map().and_then(|__m| __m.get("createMarketSellOrderRequiresPrice")).cloned().unwrap_or(Value::Null)) { Value::Bool(__x) => *__x == true, __v => matches!((match __v { Value::Int(__n) => Some(*__n as f64), Value::Float(__f) => Some(*__f), Value::Str(__s) => __s.parse::<f64>().ok(),
11242 Value::Bool(__b) => Some(if *__b { 1.0 } else { 0.0 }), _ => None }), Some(__y) if __y == 1.0) })) || ((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))) {
11243 return self.create_order(symbol, Value::Str("market".into()), Value::Str("sell".into()), cost, &[Value::Int(1), params]).await;
11244 }
11245 panic!("{}", crate::exchange_errors::not_supported(format!("{}{}", self.id.clone(), Value::Str(" createMarketSellOrderWithCost() is not supported yet".into()))));
11246
11247 Value::Null
11248} }
11249
11250 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 {
11251 let mut price = get_arg(optional_args, 0, Value::Null);
11252 let mut triggerPrice = get_arg(optional_args, 1, Value::Null);
11253 let mut params = get_arg(optional_args, 2, Value::Map({
11254 let mut m = indexmap::IndexMap::new();
11255 m
11256}));
11257 if (triggerPrice == Value::Null) {
11271 panic!("{}", crate::exchange_errors::arguments_required(format!("{}{}", self.id.clone(), Value::Str(" createTriggerOrder() requires a triggerPrice argument".into()))));
11272 }
11273 let mut paramsExtended: Value = self.extend(params, &[Value::Map({
11274 let mut m = indexmap::IndexMap::new();
11275 m.insert("triggerPrice".to_string(), triggerPrice);
11276 m
11277 })]);
11278 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)) {
11279 return self.create_order(symbol, type_var, side, amount, &[price, paramsExtended]).await;
11280 }
11281 panic!("{}", crate::exchange_errors::not_supported(format!("{}{}", self.id.clone(), Value::Str(" createTriggerOrder() is not supported yet".into()))));
11282
11283 Value::Null
11284} }
11285
11286 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 {
11287 let mut price = get_arg(optional_args, 0, Value::Null);
11288 let mut stopLossPrice = get_arg(optional_args, 1, Value::Null);
11289 let mut params = get_arg(optional_args, 2, Value::Map({
11290 let mut m = indexmap::IndexMap::new();
11291 m
11292}));
11293 if (stopLossPrice == Value::Null) {
11307 panic!("{}", crate::exchange_errors::arguments_required(format!("{}{}", self.id.clone(), Value::Str(" createStopLossOrder() requires a stopLossPrice argument".into()))));
11308 }
11309 let mut paramsExtended: Value = self.extend(params, &[Value::Map({
11310 let mut m = indexmap::IndexMap::new();
11311 m.insert("stopLossPrice".to_string(), stopLossPrice);
11312 m
11313 })]);
11314 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)) {
11315 return self.create_order(symbol, type_var, side, amount, &[price, paramsExtended]).await;
11316 }
11317 panic!("{}", crate::exchange_errors::not_supported(format!("{}{}", self.id.clone(), Value::Str(" createStopLossOrder() is not supported yet".into()))));
11318
11319 Value::Null
11320} }
11321
11322 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 {
11323 let mut price = get_arg(optional_args, 0, Value::Null);
11324 let mut takeProfitPrice = get_arg(optional_args, 1, Value::Null);
11325 let mut params = get_arg(optional_args, 2, Value::Map({
11326 let mut m = indexmap::IndexMap::new();
11327 m
11328}));
11329 if (takeProfitPrice == Value::Null) {
11343 panic!("{}", crate::exchange_errors::arguments_required(format!("{}{}", self.id.clone(), Value::Str(" createTakeProfitOrder() requires a takeProfitPrice argument".into()))));
11344 }
11345 let mut paramsExtended: Value = self.extend(params, &[Value::Map({
11346 let mut m = indexmap::IndexMap::new();
11347 m.insert("takeProfitPrice".to_string(), takeProfitPrice);
11348 m
11349 })]);
11350 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)) {
11351 return self.create_order(symbol, type_var, side, amount, &[price, paramsExtended]).await;
11352 }
11353 panic!("{}", crate::exchange_errors::not_supported(format!("{}{}", self.id.clone(), Value::Str(" createTakeProfitOrder() is not supported yet".into()))));
11354
11355 Value::Null
11356} }
11357
11358 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 {
11359 let mut price = get_arg(optional_args, 0, Value::Null);
11360 let mut takeProfit = get_arg(optional_args, 1, Value::Null);
11361 let mut stopLoss = get_arg(optional_args, 2, Value::Null);
11362 let mut params = get_arg(optional_args, 3, Value::Map({
11363 let mut m = indexmap::IndexMap::new();
11364 m
11365}));
11366 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()]);
11389 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)) {
11390 return self.create_order(symbol, type_var, side, amount, &[price, paramsValue]).await;
11391 }
11392 panic!("{}", crate::exchange_errors::not_supported(format!("{}{}", self.id.clone(), Value::Str(" createOrderWithTakeProfitAndStopLoss() is not supported yet".into()))));
11393
11394 Value::Null
11395} }
11396
11397 fn create_orders(&mut self, mut orders: Value, optional_args: &[Value]) -> impl ::std::future::Future<Output = Value> + Send { async move {
11398 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 {
11400 if !matches!(__v, crate::Value::Null) { return __v; }
11401 }
11402
11403 let mut params = get_arg(optional_args, 0, Value::Map({
11404 let mut m = indexmap::IndexMap::new();
11405 m
11406}));
11407 panic!("{}", crate::exchange_errors::not_supported(format!("{}{}", self.id.clone(), Value::Str(" createOrders() is not supported yet".into()))));
11408
11409 Value::Null
11410} }
11411
11412 fn cancel_order(&mut self, mut id: Value, optional_args: &[Value]) -> impl ::std::future::Future<Output = Value> + Send { async move {
11413 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 {
11415 if !matches!(__v, crate::Value::Null) { return __v; }
11416 }
11417
11418 let mut symbol = get_arg(optional_args, 0, Value::Null);
11419 let mut params = get_arg(optional_args, 1, Value::Map({
11420 let mut m = indexmap::IndexMap::new();
11421 m
11422}));
11423 panic!("{}", crate::exchange_errors::not_supported(format!("{}{}", self.id.clone(), Value::Str(" cancelOrder() is not supported yet".into()))));
11424
11425 Value::Null
11426} }
11427
11428fn cancel_order_with_client_order_id(&mut self, mut clientOrderId: Value, optional_args: &[Value]) -> impl ::std::future::Future<Output = Value> + Send { async move {
11438 let mut symbol = get_arg(optional_args, 0, Value::Null);
11439 let mut params = get_arg(optional_args, 1, Value::Map({
11440 let mut m = indexmap::IndexMap::new();
11441 m
11442}));
11443 let mut extendedParams: Value = self.extend(params, &[Value::Map({
11444 let mut m = indexmap::IndexMap::new();
11445 m.insert("clientOrderId".to_string(), clientOrderId);
11446 m
11447 })]);
11448 return self.cancel_order(Value::Str("".into()), &[symbol, extendedParams]).await;
11449
11450 Value::Null
11451} }
11452
11453 fn cancel_orders(&mut self, mut ids: Value, optional_args: &[Value]) -> impl ::std::future::Future<Output = Value> + Send { async move {
11454 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 {
11456 if !matches!(__v, crate::Value::Null) { return __v; }
11457 }
11458
11459 let mut symbol = get_arg(optional_args, 0, Value::Null);
11460 let mut params = get_arg(optional_args, 1, Value::Map({
11461 let mut m = indexmap::IndexMap::new();
11462 m
11463}));
11464 panic!("{}", crate::exchange_errors::not_supported(format!("{}{}", self.id.clone(), Value::Str(" cancelOrders() is not supported yet".into()))));
11465
11466 Value::Null
11467} }
11468
11469fn cancel_orders_with_client_order_ids(&mut self, mut clientOrderIds: Value, optional_args: &[Value]) -> impl ::std::future::Future<Output = Value> + Send { async move {
11479 let mut symbol = get_arg(optional_args, 0, Value::Null);
11480 let mut params = get_arg(optional_args, 1, Value::Map({
11481 let mut m = indexmap::IndexMap::new();
11482 m
11483}));
11484 let mut extendedParams: Value = self.extend(params, &[Value::Map({
11485 let mut m = indexmap::IndexMap::new();
11486 m.insert("clientOrderIds".to_string(), clientOrderIds);
11487 m
11488 })]);
11489 return self.cancel_orders(Value::from(vec![]), &[symbol, extendedParams]).await;
11490
11491 Value::Null
11492} }
11493
11494 fn cancel_all_orders(&mut self, optional_args: &[Value]) -> impl ::std::future::Future<Output = Value> + Send { async move {
11495 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 {
11497 if !matches!(__v, crate::Value::Null) { return __v; }
11498 }
11499
11500 let mut symbol = get_arg(optional_args, 0, Value::Null);
11501 let mut params = get_arg(optional_args, 1, Value::Map({
11502 let mut m = indexmap::IndexMap::new();
11503 m
11504}));
11505 panic!("{}", crate::exchange_errors::not_supported(format!("{}{}", self.id.clone(), Value::Str(" cancelAllOrders() is not supported yet".into()))));
11506
11507 Value::Null
11508} }
11509
11510 fn cancel_unified_order(&mut self, mut order: Value, optional_args: &[Value]) -> impl ::std::future::Future<Output = Value> + Send { async move {
11511 let mut params = get_arg(optional_args, 0, Value::Map({
11512 let mut m = indexmap::IndexMap::new();
11513 m
11514}));
11515 return self.cancel_order(self.safe_string_k(order.clone(), "id", &[]), &[self.safe_string_k(order, "symbol", &[]), params]).await;
11516
11517 Value::Null
11518} }
11519
11520 fn fetch_orders(&mut self, optional_args: &[Value]) -> impl ::std::future::Future<Output = Value> + Send { async move {
11521 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 {
11523 if !matches!(__v, crate::Value::Null) { return __v; }
11524 }
11525
11526 let mut symbol = get_arg(optional_args, 0, Value::Null);
11527 let mut since = get_arg(optional_args, 1, Value::Null);
11528 let mut limit = get_arg(optional_args, 2, Value::Null);
11529 let mut params = get_arg(optional_args, 3, Value::Map({
11530 let mut m = indexmap::IndexMap::new();
11531 m
11532}));
11533 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) !=
11534 Value::Null) && (self.has.as_map().and_then(|__m| __m.get("fetchClosedOrders")).cloned().unwrap_or(Value::Null).as_bool() != Some(false))) {
11535 panic!("{}", crate::exchange_errors::not_supported(format!("{}{}", self.id.clone(), Value::Str(" fetchOrders() is not supported yet, consider using fetchOpenOrders() and fetchClosedOrders() instead".into()))));
11536 }
11537 panic!("{}", crate::exchange_errors::not_supported(format!("{}{}", self.id.clone(), Value::Str(" fetchOrders() is not supported yet".into()))));
11538
11539 Value::Null
11540} }
11541
11542 fn fetch_order_trades(&mut self, mut id: Value, optional_args: &[Value]) -> impl ::std::future::Future<Output = Value> + Send { async move {
11543 let mut symbol = get_arg(optional_args, 0, Value::Null);
11544 let mut since = get_arg(optional_args, 1, Value::Null);
11545 let mut limit = get_arg(optional_args, 2, Value::Null);
11546 let mut params = get_arg(optional_args, 3, Value::Map({
11547 let mut m = indexmap::IndexMap::new();
11548 m
11549}));
11550 panic!("{}", crate::exchange_errors::not_supported(format!("{}{}", self.id.clone(), Value::Str(" fetchOrderTrades() is not supported yet".into()))));
11551
11552 Value::Null
11553} }
11554
11555 fn watch_orders(&mut self, optional_args: &[Value]) -> impl ::std::future::Future<Output = Value> + Send { async move {
11556 let mut symbol = get_arg(optional_args, 0, Value::Null);
11557 let mut since = get_arg(optional_args, 1, Value::Null);
11558 let mut limit = get_arg(optional_args, 2, Value::Null);
11559 let mut params = get_arg(optional_args, 3, Value::Map({
11560 let mut m = indexmap::IndexMap::new();
11561 m
11562}));
11563 panic!("{}", crate::exchange_errors::not_supported(format!("{}{}", self.id.clone(), Value::Str(" watchOrders() is not supported yet".into()))));
11564
11565 Value::Null
11566} }
11567
11568 fn fetch_open_orders(&mut self, optional_args: &[Value]) -> impl ::std::future::Future<Output = Value> + Send { async move {
11569 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 {
11571 if !matches!(__v, crate::Value::Null) { return __v; }
11572 }
11573
11574 let mut symbol = get_arg(optional_args, 0, Value::Null);
11575 let mut since = get_arg(optional_args, 1, Value::Null);
11576 let mut limit = get_arg(optional_args, 2, Value::Null);
11577 let mut params = get_arg(optional_args, 3, Value::Map({
11578 let mut m = indexmap::IndexMap::new();
11579 m
11580}));
11581 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)) {
11582 let mut orders: Value = self.fetch_orders(&[symbol, since, limit, params]).await;
11583 return self.filter_by(orders, Value::Str("status".into()), Value::Str("open".into()), &[]);
11584 }
11585 panic!("{}", crate::exchange_errors::not_supported(format!("{}{}", self.id.clone(), Value::Str(" fetchOpenOrders() is not supported yet".into()))));
11586
11587 Value::Null
11588} }
11589
11590 fn fetch_closed_orders(&mut self, optional_args: &[Value]) -> impl ::std::future::Future<Output = Value> + Send { async move {
11591 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 {
11593 if !matches!(__v, crate::Value::Null) { return __v; }
11594 }
11595
11596 let mut symbol = get_arg(optional_args, 0, Value::Null);
11597 let mut since = get_arg(optional_args, 1, Value::Null);
11598 let mut limit = get_arg(optional_args, 2, Value::Null);
11599 let mut params = get_arg(optional_args, 3, Value::Map({
11600 let mut m = indexmap::IndexMap::new();
11601 m
11602}));
11603 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)) {
11604 let mut orders: Value = self.fetch_orders(&[symbol, since, limit, params]).await;
11605 return self.filter_by(orders, Value::Str("status".into()), Value::Str("closed".into()), &[]);
11606 }
11607 panic!("{}", crate::exchange_errors::not_supported(format!("{}{}", self.id.clone(), Value::Str(" fetchClosedOrders() is not supported yet".into()))));
11608
11609 Value::Null
11610} }
11611
11612 fn fetch_canceled_orders(&mut self, optional_args: &[Value]) -> impl ::std::future::Future<Output = Value> + Send { async move {
11613 let mut symbol = get_arg(optional_args, 0, Value::Null);
11614 let mut since = get_arg(optional_args, 1, Value::Null);
11615 let mut limit = get_arg(optional_args, 2, Value::Null);
11616 let mut params = get_arg(optional_args, 3, Value::Map({
11617 let mut m = indexmap::IndexMap::new();
11618 m
11619}));
11620 panic!("{}", crate::exchange_errors::not_supported(format!("{}{}", self.id.clone(), Value::Str(" fetchCanceledOrders() is not supported yet".into()))));
11621
11622 Value::Null
11623} }
11624
11625 fn fetch_my_trades(&mut self, optional_args: &[Value]) -> impl ::std::future::Future<Output = Value> + Send { async move {
11626 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 {
11628 if !matches!(__v, crate::Value::Null) { return __v; }
11629 }
11630
11631 let mut symbol = get_arg(optional_args, 0, Value::Null);
11632 let mut since = get_arg(optional_args, 1, Value::Null);
11633 let mut limit = get_arg(optional_args, 2, Value::Null);
11634 let mut params = get_arg(optional_args, 3, Value::Map({
11635 let mut m = indexmap::IndexMap::new();
11636 m
11637}));
11638 panic!("{}", crate::exchange_errors::not_supported(format!("{}{}", self.id.clone(), Value::Str(" fetchMyTrades() is not supported yet".into()))));
11639
11640 Value::Null
11641} }
11642
11643 fn watch_my_trades(&mut self, optional_args: &[Value]) -> impl ::std::future::Future<Output = Value> + Send { async move {
11644 let mut symbol = get_arg(optional_args, 0, Value::Null);
11645 let mut since = get_arg(optional_args, 1, Value::Null);
11646 let mut limit = get_arg(optional_args, 2, Value::Null);
11647 let mut params = get_arg(optional_args, 3, Value::Map({
11648 let mut m = indexmap::IndexMap::new();
11649 m
11650}));
11651 panic!("{}", crate::exchange_errors::not_supported(format!("{}{}", self.id.clone(), Value::Str(" watchMyTrades() is not supported yet".into()))));
11652
11653 Value::Null
11654} }
11655
11656 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 {
11657 let mut params = get_arg(optional_args, 0, Value::Map({
11658 let mut m = indexmap::IndexMap::new();
11659 m
11660}));
11661 return self.create_order(symbol, Value::Str("limit".into()), side, amount, &[price, params]).await;
11662
11663 Value::Null
11664} }
11665
11666 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 {
11667 let mut price = get_arg(optional_args, 0, Value::Null);
11668 let mut params = get_arg(optional_args, 1, Value::Map({
11669 let mut m = indexmap::IndexMap::new();
11670 m
11671}));
11672 return self.create_order(symbol, Value::Str("market".into()), side, amount, &[price, params]).await;
11673
11674 Value::Null
11675} }
11676
11677 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 {
11678 let mut params = get_arg(optional_args, 0, Value::Map({
11679 let mut m = indexmap::IndexMap::new();
11680 m
11681}));
11682 return self.create_order(symbol, Value::Str("limit".into()), Value::Str("buy".into()), amount, &[price, params]).await;
11683
11684 Value::Null
11685} }
11686
11687 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 {
11688 let mut params = get_arg(optional_args, 0, Value::Map({
11689 let mut m = indexmap::IndexMap::new();
11690 m
11691}));
11692 return self.create_order(symbol, Value::Str("limit".into()), Value::Str("sell".into()), amount, &[price, params]).await;
11693
11694 Value::Null
11695} }
11696
11697 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 {
11698 let mut params = get_arg(optional_args, 0, Value::Map({
11699 let mut m = indexmap::IndexMap::new();
11700 m
11701}));
11702 return self.create_order(symbol, Value::Str("market".into()), Value::Str("buy".into()), amount, &[Value::Null, params]).await;
11703
11704 Value::Null
11705} }
11706
11707 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 {
11708 let mut params = get_arg(optional_args, 0, Value::Map({
11709 let mut m = indexmap::IndexMap::new();
11710 m
11711}));
11712 return self.create_order(symbol, Value::Str("market".into()), Value::Str("sell".into()), amount, &[Value::Null, params]).await;
11713
11714 Value::Null
11715} }
11716
11717 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 {
11718 let mut price = get_arg(optional_args, 0, Value::Null);
11719 let mut params = get_arg(optional_args, 1, Value::Map({
11720 let mut m = indexmap::IndexMap::new();
11721 m
11722}));
11723 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)) {
11724 panic!("{}", crate::exchange_errors::not_supported(format!("{}{}", self.id.clone(), Value::Str(" createPostOnlyOrder() is not supported yet".into()))));
11725 }
11726 let mut query: Value = self.extend(params, &[Value::Map({
11727 let mut m = indexmap::IndexMap::new();
11728 m.insert("postOnly".to_string(), Value::Bool(true));
11729 m
11730 })]);
11731 return self.create_order(symbol, type_var, side, amount, &[price, query]).await;
11732
11733 Value::Null
11734} }
11735
11736 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 {
11737 let mut price = get_arg(optional_args, 0, Value::Null);
11738 let mut params = get_arg(optional_args, 1, Value::Map({
11739 let mut m = indexmap::IndexMap::new();
11740 m
11741}));
11742 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)) {
11743 panic!("{}", crate::exchange_errors::not_supported(format!("{}{}", self.id.clone(), Value::Str(" createReduceOnlyOrder() is not supported yet".into()))));
11744 }
11745 let mut query: Value = self.extend(params, &[Value::Map({
11746 let mut m = indexmap::IndexMap::new();
11747 m.insert("reduceOnly".to_string(), Value::Bool(true));
11748 m
11749 })]);
11750 return self.create_order(symbol, type_var, side, amount, &[price, query]).await;
11751
11752 Value::Null
11753} }
11754
11755 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 {
11756 let mut price = get_arg(optional_args, 0, Value::Null);
11757 let mut triggerPrice = get_arg(optional_args, 1, Value::Null);
11758 let mut params = get_arg(optional_args, 2, Value::Map({
11759 let mut m = indexmap::IndexMap::new();
11760 m
11761}));
11762 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)) {
11763 panic!("{}", crate::exchange_errors::not_supported(format!("{}{}", self.id.clone(), Value::Str(" createStopOrder() is not supported yet".into()))));
11764 }
11765 if (triggerPrice == Value::Null) {
11766 panic!("{}", crate::exchange_errors::arguments_required(format!("{}{}", self.id.clone(), Value::Str(" create_stop_order() requires a stopPrice argument".into()))));
11767 }
11768 let mut query: Value = self.extend(params, &[Value::Map({
11769 let mut m = indexmap::IndexMap::new();
11770 m.insert("stopPrice".to_string(), triggerPrice);
11771 m
11772 })]);
11773 return self.create_order(symbol, type_var, side, amount, &[price, query]).await;
11774
11775 Value::Null
11776} }
11777
11778 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 {
11779 let mut params = get_arg(optional_args, 0, Value::Map({
11780 let mut m = indexmap::IndexMap::new();
11781 m
11782}));
11783 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)) {
11784 panic!("{}", crate::exchange_errors::not_supported(format!("{}{}", self.id.clone(), Value::Str(" createStopLimitOrder() is not supported yet".into()))));
11785 }
11786 let mut query: Value = self.extend(params, &[Value::Map({
11787 let mut m = indexmap::IndexMap::new();
11788 m.insert("stopPrice".to_string(), triggerPrice);
11789 m
11790 })]);
11791 return self.create_order(symbol, Value::Str("limit".into()), side, amount, &[price, query]).await;
11792
11793 Value::Null
11794} }
11795
11796 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 {
11797 let mut params = get_arg(optional_args, 0, Value::Map({
11798 let mut m = indexmap::IndexMap::new();
11799 m
11800}));
11801 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)) {
11802 panic!("{}", crate::exchange_errors::not_supported(format!("{}{}", self.id.clone(), Value::Str(" createStopMarketOrder() is not supported yet".into()))));
11803 }
11804 let mut query: Value = self.extend(params, &[Value::Map({
11805 let mut m = indexmap::IndexMap::new();
11806 m.insert("stopPrice".to_string(), triggerPrice);
11807 m
11808 })]);
11809 return self.create_order(symbol, Value::Str("market".into()), side, amount, &[Value::Null, query]).await;
11810
11811 Value::Null
11812} }
11813
11814 fn fetch_trading_fee(&mut self, mut symbol: Value, optional_args: &[Value]) -> impl ::std::future::Future<Output = Value> + Send { async move {
11815 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 {
11817 if !matches!(__v, crate::Value::Null) { return __v; }
11818 }
11819
11820 let mut params = get_arg(optional_args, 0, Value::Map({
11821 let mut m = indexmap::IndexMap::new();
11822 m
11823}));
11824 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)) {
11825 panic!("{}", crate::exchange_errors::not_supported(format!("{}{}", self.id.clone(), Value::Str(" fetchTradingFee() is not supported yet".into()))));
11826 }
11827 let mut fees: Value = self.fetch_trading_fees(&[params]).await;
11828 let mut fee: Value = self.safe_dict(fees, symbol, &[]);
11829 return fee;
11830
11831 Value::Null
11832} }
11833 fn call_dynamic_base<'a>(&'a mut self, method: &'a str, args: Vec<crate::Value>)
11835 -> std::pin::Pin<Box<dyn std::future::Future<Output = crate::Value> + Send + 'a>>
11836 {
11837 Box::pin(async move {
11838 match method {
11839 "account" => self.account(),
11840 "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)),
11841 "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,
11842 "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)),
11843 "arrays_concat" => self.arrays_concat(args.get(0).cloned().unwrap_or(crate::Value::Null)),
11844 "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())..]),
11845 "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,
11846 "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,
11847 "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,
11848 "build_ohlcvc" => self.build_ohlcvc(args.get(0).cloned().unwrap_or(crate::Value::Null), &args[1.min(args.len())..]),
11849 "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())..]),
11850 "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())..]),
11851 "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())..]),
11852 "call_method" => self.call_method(args.get(0).cloned().unwrap_or(crate::Value::Null), &args[1.min(args.len())..]).await,
11853 "cancel_all_contract_orders" => self.cancel_all_contract_orders(&args[..]).await,
11854 "cancel_all_orders" => self.cancel_all_orders(&args[..]).await,
11855 "cancel_all_orders_after" => self.cancel_all_orders_after(args.get(0).cloned().unwrap_or(crate::Value::Null), &args[1.min(args.len())..]).await,
11856 "cancel_all_orders_ws" => self.cancel_all_orders_ws(&args[..]).await,
11857 "cancel_all_spot_orders" => self.cancel_all_spot_orders(&args[..]).await,
11858 "cancel_contract_order" => self.cancel_contract_order(args.get(0).cloned().unwrap_or(crate::Value::Null), &args[1.min(args.len())..]).await,
11859 "cancel_order" => self.cancel_order(args.get(0).cloned().unwrap_or(crate::Value::Null), &args[1.min(args.len())..]).await,
11860 "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,
11861 "cancel_order_ws" => self.cancel_order_ws(args.get(0).cloned().unwrap_or(crate::Value::Null), &args[1.min(args.len())..]).await,
11862 "cancel_orders" => self.cancel_orders(args.get(0).cloned().unwrap_or(crate::Value::Null), &args[1.min(args.len())..]).await,
11863 "cancel_orders_for_symbols" => self.cancel_orders_for_symbols(args.get(0).cloned().unwrap_or(crate::Value::Null), &args[1.min(args.len())..]).await,
11864 "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,
11865 "cancel_orders_ws" => self.cancel_orders_ws(args.get(0).cloned().unwrap_or(crate::Value::Null), &args[1.min(args.len())..]).await,
11866 "cancel_spot_order" => self.cancel_spot_order(args.get(0).cloned().unwrap_or(crate::Value::Null), &args[1.min(args.len())..]).await,
11867 "cancel_unified_order" => self.cancel_unified_order(args.get(0).cloned().unwrap_or(crate::Value::Null), &args[1.min(args.len())..]).await,
11868 "check_address" => self.check_address(&args[..]),
11869 "check_proxy_settings" => self.check_proxy_settings(&args[..]),
11870 "check_proxy_url_settings" => self.check_proxy_url_settings(&args[..]),
11871 "check_required_credentials" => self.check_required_credentials(&args[..]),
11872 "check_ws_proxy_settings" => self.check_ws_proxy_settings(),
11873 "close_all_positions" => self.close_all_positions(&args[..]).await,
11874 "close_position" => self.close_position(args.get(0).cloned().unwrap_or(crate::Value::Null), &args[1.min(args.len())..]).await,
11875 "common_currency_code" => self.common_currency_code(args.get(0).cloned().unwrap_or(crate::Value::Null)),
11876 "convert_expire_date" => self.convert_expire_date(args.get(0).cloned().unwrap_or(crate::Value::Null)),
11877 "convert_expire_date_to_market_id_date" => self.convert_expire_date_to_market_id_date(args.get(0).cloned().unwrap_or(crate::Value::Null)),
11878 "convert_market_id_expire_date" => self.convert_market_id_expire_date(args.get(0).cloned().unwrap_or(crate::Value::Null)),
11879 "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())..]),
11880 "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())..]),
11881 "convert_type_to_account" => self.convert_type_to_account(args.get(0).cloned().unwrap_or(crate::Value::Null)),
11882 "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)),
11883 "create_ccxt_trade_id" => self.create_ccxt_trade_id(&args[..]),
11884 "create_contract_orders" => self.create_contract_orders(args.get(0).cloned().unwrap_or(crate::Value::Null), &args[1.min(args.len())..]).await,
11885 "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,
11886 "create_deposit_address" => self.create_deposit_address(args.get(0).cloned().unwrap_or(crate::Value::Null), &args[1.min(args.len())..]).await,
11887 "create_expired_option_market" => <Self as crate::exchange_generated::ExchangeBase>::create_expired_option_market(self, args.get(0).cloned().unwrap_or(crate::Value::Null)),
11888 "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,
11889 "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,
11890 "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,
11891 "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,
11892 "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,
11893 "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,
11894 "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,
11895 "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,
11896 "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,
11897 "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,
11898 "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,
11899 "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,
11900 "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,
11901 "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,
11902 "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,
11903 "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,
11904 "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)),
11905 "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,
11906 "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,
11907 "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,
11908 "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,
11909 "create_orders" => self.create_orders(args.get(0).cloned().unwrap_or(crate::Value::Null), &args[1.min(args.len())..]).await,
11910 "create_orders_ws" => self.create_orders_ws(args.get(0).cloned().unwrap_or(crate::Value::Null), &args[1.min(args.len())..]).await,
11911 "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,
11912 "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,
11913 "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,
11914 "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,
11915 "create_spot_orders" => self.create_spot_orders(args.get(0).cloned().unwrap_or(crate::Value::Null), &args[1.min(args.len())..]).await,
11916 "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,
11917 "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,
11918 "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,
11919 "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,
11920 "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,
11921 "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,
11922 "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,
11923 "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,
11924 "create_sub_account" => self.create_sub_account(args.get(0).cloned().unwrap_or(crate::Value::Null), &args[1.min(args.len())..]).await,
11925 "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,
11926 "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,
11927 "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,
11928 "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,
11929 "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,
11930 "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,
11931 "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,
11932 "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,
11933 "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,
11934 "currency" => self.currency(args.get(0).cloned().unwrap_or(crate::Value::Null)),
11935 "currency_id" => self.currency_id(args.get(0).cloned().unwrap_or(crate::Value::Null)),
11936 "currency_ids" => self.currency_ids(&args[..]),
11937 "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())..]),
11938 "deposit_withdraw_fee" => self.deposit_withdraw_fee(args.get(0).cloned().unwrap_or(crate::Value::Null)),
11939 "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,
11940 "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,
11941 "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,
11942 "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,
11943 "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,
11944 "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,
11945 "edit_orders" => self.edit_orders(args.get(0).cloned().unwrap_or(crate::Value::Null), &args[1.min(args.len())..]).await,
11946 "feature_value" => self.feature_value(args.get(0).cloned().unwrap_or(crate::Value::Null), &args[1.min(args.len())..]),
11947 "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())..]),
11948 "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())..]),
11949 "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)),
11950 "fetch" => self.fetch(args.get(0).cloned().unwrap_or(crate::Value::Null), &args[1.min(args.len())..]).await,
11951 "fetch2" => self.fetch2(args.get(0).cloned().unwrap_or(crate::Value::Null), &args[1.min(args.len())..]).await,
11952 "fetch_accounts" => self.fetch_accounts(&args[..]).await,
11953 "fetch_adl_rank" => self.fetch_adl_rank(args.get(0).cloned().unwrap_or(crate::Value::Null), &args[1.min(args.len())..]).await,
11954 "fetch_all_greeks" => self.fetch_all_greeks(&args[..]).await,
11955 "fetch_balance" => self.fetch_balance(&args[..]).await,
11956 "fetch_balance_ws" => self.fetch_balance_ws(&args[..]).await,
11957 "fetch_bids_asks" => self.fetch_bids_asks(&args[..]).await,
11958 "fetch_borrow_interest" => self.fetch_borrow_interest(&args[..]).await,
11959 "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,
11960 "fetch_canceled_and_closed_orders" => self.fetch_canceled_and_closed_orders(&args[..]).await,
11961 "fetch_canceled_orders" => self.fetch_canceled_orders(&args[..]).await,
11962 "fetch_closed_orders" => self.fetch_closed_orders(&args[..]).await,
11963 "fetch_closed_orders_ws" => self.fetch_closed_orders_ws(&args[..]).await,
11964 "fetch_contract_deposit_address" => self.fetch_contract_deposit_address(args.get(0).cloned().unwrap_or(crate::Value::Null), &args[1.min(args.len())..]).await,
11965 "fetch_contract_ohlcv" => self.fetch_contract_ohlcv(args.get(0).cloned().unwrap_or(crate::Value::Null), &args[1.min(args.len())..]).await,
11966 "fetch_contract_tickers" => self.fetch_contract_tickers(&args[..]).await,
11967 "fetch_convert_currencies" => self.fetch_convert_currencies(&args[..]).await,
11968 "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,
11969 "fetch_convert_trade" => self.fetch_convert_trade(args.get(0).cloned().unwrap_or(crate::Value::Null), &args[1.min(args.len())..]).await,
11970 "fetch_convert_trade_history" => self.fetch_convert_trade_history(&args[..]).await,
11971 "fetch_cross_borrow_rate" => self.fetch_cross_borrow_rate(args.get(0).cloned().unwrap_or(crate::Value::Null), &args[1.min(args.len())..]).await,
11972 "fetch_cross_borrow_rates" => self.fetch_cross_borrow_rates(&args[..]).await,
11973 "fetch_deposit_address" => self.fetch_deposit_address(args.get(0).cloned().unwrap_or(crate::Value::Null), &args[1.min(args.len())..]).await,
11974 "fetch_deposit_addresses" => self.fetch_deposit_addresses(&args[..]).await,
11975 "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,
11976 "fetch_deposit_withdraw_fee" => self.fetch_deposit_withdraw_fee(args.get(0).cloned().unwrap_or(crate::Value::Null), &args[1.min(args.len())..]).await,
11977 "fetch_deposit_withdraw_fees" => self.fetch_deposit_withdraw_fees(&args[..]).await,
11978 "fetch_deposits" => self.fetch_deposits(&args[..]).await,
11979 "fetch_deposits_withdrawals" => self.fetch_deposits_withdrawals(&args[..]).await,
11980 "fetch_deposits_ws" => self.fetch_deposits_ws(&args[..]).await,
11981 "fetch_free_balance" => self.fetch_free_balance(&args[..]).await,
11982 "fetch_funding_history" => self.fetch_funding_history(&args[..]).await,
11983 "fetch_funding_interval" => self.fetch_funding_interval(args.get(0).cloned().unwrap_or(crate::Value::Null), &args[1.min(args.len())..]).await,
11984 "fetch_funding_intervals" => self.fetch_funding_intervals(&args[..]).await,
11985 "fetch_funding_rate" => self.fetch_funding_rate(args.get(0).cloned().unwrap_or(crate::Value::Null), &args[1.min(args.len())..]).await,
11986 "fetch_funding_rate_history" => self.fetch_funding_rate_history(&args[..]).await,
11987 "fetch_funding_rates" => self.fetch_funding_rates(&args[..]).await,
11988 "fetch_greeks" => self.fetch_greeks(args.get(0).cloned().unwrap_or(crate::Value::Null), &args[1.min(args.len())..]).await,
11989 "fetch_index_ohlcv" => self.fetch_index_ohlcv(args.get(0).cloned().unwrap_or(crate::Value::Null), &args[1.min(args.len())..]).await,
11990 "fetch_isolated_borrow_rate" => self.fetch_isolated_borrow_rate(args.get(0).cloned().unwrap_or(crate::Value::Null), &args[1.min(args.len())..]).await,
11991 "fetch_isolated_borrow_rates" => self.fetch_isolated_borrow_rates(&args[..]).await,
11992 "fetch_l2_order_book" => self.fetch_l2_order_book(args.get(0).cloned().unwrap_or(crate::Value::Null), &args[1.min(args.len())..]).await,
11993 "fetch_l3_order_book" => self.fetch_l3_order_book(args.get(0).cloned().unwrap_or(crate::Value::Null), &args[1.min(args.len())..]).await,
11994 "fetch_last_prices" => self.fetch_last_prices(&args[..]).await,
11995 "fetch_ledger" => self.fetch_ledger(&args[..]).await,
11996 "fetch_ledger_entry" => self.fetch_ledger_entry(args.get(0).cloned().unwrap_or(crate::Value::Null), &args[1.min(args.len())..]).await,
11997 "fetch_leverage" => self.fetch_leverage(args.get(0).cloned().unwrap_or(crate::Value::Null), &args[1.min(args.len())..]).await,
11998 "fetch_leverage_tiers" => self.fetch_leverage_tiers(&args[..]).await,
11999 "fetch_leverages" => self.fetch_leverages(&args[..]).await,
12000 "fetch_liquidations" => self.fetch_liquidations(args.get(0).cloned().unwrap_or(crate::Value::Null), &args[1.min(args.len())..]).await,
12001 "fetch_long_short_ratio" => self.fetch_long_short_ratio(args.get(0).cloned().unwrap_or(crate::Value::Null), &args[1.min(args.len())..]).await,
12002 "fetch_long_short_ratio_history" => self.fetch_long_short_ratio_history(&args[..]).await,
12003 "fetch_margin_adjustment_history" => self.fetch_margin_adjustment_history(&args[..]).await,
12004 "fetch_margin_mode" => self.fetch_margin_mode(args.get(0).cloned().unwrap_or(crate::Value::Null), &args[1.min(args.len())..]).await,
12005 "fetch_margin_modes" => self.fetch_margin_modes(&args[..]).await,
12006 "fetch_mark_ohlcv" => self.fetch_mark_ohlcv(args.get(0).cloned().unwrap_or(crate::Value::Null), &args[1.min(args.len())..]).await,
12007 "fetch_mark_price" => self.fetch_mark_price(args.get(0).cloned().unwrap_or(crate::Value::Null), &args[1.min(args.len())..]).await,
12008 "fetch_mark_prices" => self.fetch_mark_prices(&args[..]).await,
12009 "fetch_market_leverage_tiers" => self.fetch_market_leverage_tiers(args.get(0).cloned().unwrap_or(crate::Value::Null), &args[1.min(args.len())..]).await,
12010 "fetch_my_liquidations" => self.fetch_my_liquidations(&args[..]).await,
12011 "fetch_my_trades" => self.fetch_my_trades(&args[..]).await,
12012 "fetch_my_trades_ws" => self.fetch_my_trades_ws(&args[..]).await,
12013 "fetch_ohlcv" => self.fetch_ohlcv(args.get(0).cloned().unwrap_or(crate::Value::Null), &args[1.min(args.len())..]).await,
12014 "fetch_ohlcv_ws" => self.fetch_ohlcv_ws(args.get(0).cloned().unwrap_or(crate::Value::Null), &args[1.min(args.len())..]).await,
12015 "fetch_open_interest" => self.fetch_open_interest(args.get(0).cloned().unwrap_or(crate::Value::Null), &args[1.min(args.len())..]).await,
12016 "fetch_open_interest_history" => self.fetch_open_interest_history(args.get(0).cloned().unwrap_or(crate::Value::Null), &args[1.min(args.len())..]).await,
12017 "fetch_open_interests" => self.fetch_open_interests(&args[..]).await,
12018 "fetch_open_orders" => self.fetch_open_orders(&args[..]).await,
12019 "fetch_open_orders_ws" => self.fetch_open_orders_ws(&args[..]).await,
12020 "fetch_option" => self.fetch_option(args.get(0).cloned().unwrap_or(crate::Value::Null), &args[1.min(args.len())..]).await,
12021 "fetch_option_chain" => self.fetch_option_chain(args.get(0).cloned().unwrap_or(crate::Value::Null), &args[1.min(args.len())..]).await,
12022 "fetch_order" => self.fetch_order(args.get(0).cloned().unwrap_or(crate::Value::Null), &args[1.min(args.len())..]).await,
12023 "fetch_order_book" => self.fetch_order_book(args.get(0).cloned().unwrap_or(crate::Value::Null), &args[1.min(args.len())..]).await,
12024 "fetch_order_book_ws" => self.fetch_order_book_ws(args.get(0).cloned().unwrap_or(crate::Value::Null), &args[1.min(args.len())..]).await,
12025 "fetch_order_books" => self.fetch_order_books(&args[..]).await,
12026 "fetch_order_status" => self.fetch_order_status(args.get(0).cloned().unwrap_or(crate::Value::Null), &args[1.min(args.len())..]).await,
12027 "fetch_order_trades" => self.fetch_order_trades(args.get(0).cloned().unwrap_or(crate::Value::Null), &args[1.min(args.len())..]).await,
12028 "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,
12029 "fetch_order_ws" => self.fetch_order_ws(args.get(0).cloned().unwrap_or(crate::Value::Null), &args[1.min(args.len())..]).await,
12030 "fetch_orders" => self.fetch_orders(&args[..]).await,
12031 "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,
12032 "fetch_orders_ws" => self.fetch_orders_ws(&args[..]).await,
12033 "fetch_paginated_call_cursor" => self.fetch_paginated_call_cursor(args.get(0).cloned().unwrap_or(crate::Value::Null), &args[1.min(args.len())..]).await,
12034 "fetch_paginated_call_deterministic" => self.fetch_paginated_call_deterministic(args.get(0).cloned().unwrap_or(crate::Value::Null), &args[1.min(args.len())..]).await,
12035 "fetch_paginated_call_dynamic" => self.fetch_paginated_call_dynamic(args.get(0).cloned().unwrap_or(crate::Value::Null), &args[1.min(args.len())..]).await,
12036 "fetch_paginated_call_incremental" => self.fetch_paginated_call_incremental(args.get(0).cloned().unwrap_or(crate::Value::Null), &args[1.min(args.len())..]).await,
12037 "fetch_partial_balance" => self.fetch_partial_balance(args.get(0).cloned().unwrap_or(crate::Value::Null), &args[1.min(args.len())..]).await,
12038 "fetch_payment_methods" => self.fetch_payment_methods(&args[..]).await,
12039 "fetch_position" => self.fetch_position(args.get(0).cloned().unwrap_or(crate::Value::Null), &args[1.min(args.len())..]).await,
12040 "fetch_position_adl_rank" => self.fetch_position_adl_rank(args.get(0).cloned().unwrap_or(crate::Value::Null), &args[1.min(args.len())..]).await,
12041 "fetch_position_history" => self.fetch_position_history(args.get(0).cloned().unwrap_or(crate::Value::Null), &args[1.min(args.len())..]).await,
12042 "fetch_position_mode" => self.fetch_position_mode(&args[..]).await,
12043 "fetch_position_ws" => self.fetch_position_ws(args.get(0).cloned().unwrap_or(crate::Value::Null), &args[1.min(args.len())..]).await,
12044 "fetch_positions" => self.fetch_positions(&args[..]).await,
12045 "fetch_positions_adl_rank" => self.fetch_positions_adl_rank(&args[..]).await,
12046 "fetch_positions_for_symbol" => self.fetch_positions_for_symbol(args.get(0).cloned().unwrap_or(crate::Value::Null), &args[1.min(args.len())..]).await,
12047 "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,
12048 "fetch_positions_history" => self.fetch_positions_history(&args[..]).await,
12049 "fetch_positions_risk" => self.fetch_positions_risk(&args[..]).await,
12050 "fetch_positions_ws" => self.fetch_positions_ws(&args[..]).await,
12051 "fetch_premium_index_ohlcv" => self.fetch_premium_index_ohlcv(args.get(0).cloned().unwrap_or(crate::Value::Null), &args[1.min(args.len())..]).await,
12052 "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,
12053 "fetch_spot_ohlcv" => self.fetch_spot_ohlcv(args.get(0).cloned().unwrap_or(crate::Value::Null), &args[1.min(args.len())..]).await,
12054 "fetch_spot_tickers" => self.fetch_spot_tickers(&args[..]).await,
12055 "fetch_status" => self.fetch_status(&args[..]).await,
12056 "fetch_ticker" => self.fetch_ticker(args.get(0).cloned().unwrap_or(crate::Value::Null), &args[1.min(args.len())..]).await,
12057 "fetch_ticker_ws" => self.fetch_ticker_ws(args.get(0).cloned().unwrap_or(crate::Value::Null), &args[1.min(args.len())..]).await,
12058 "fetch_tickers" => self.fetch_tickers(&args[..]).await,
12059 "fetch_tickers_ws" => self.fetch_tickers_ws(&args[..]).await,
12060 "fetch_time" => self.fetch_time(&args[..]).await,
12061 "fetch_total_balance" => self.fetch_total_balance(&args[..]).await,
12062 "fetch_trades" => self.fetch_trades(args.get(0).cloned().unwrap_or(crate::Value::Null), &args[1.min(args.len())..]).await,
12063 "fetch_trades_ws" => self.fetch_trades_ws(args.get(0).cloned().unwrap_or(crate::Value::Null), &args[1.min(args.len())..]).await,
12064 "fetch_trading_fee" => self.fetch_trading_fee(args.get(0).cloned().unwrap_or(crate::Value::Null), &args[1.min(args.len())..]).await,
12065 "fetch_trading_fees" => self.fetch_trading_fees(&args[..]).await,
12066 "fetch_trading_fees_ws" => self.fetch_trading_fees_ws(&args[..]).await,
12067 "fetch_trading_limits" => self.fetch_trading_limits(&args[..]).await,
12068 "fetch_transaction_fee" => self.fetch_transaction_fee(args.get(0).cloned().unwrap_or(crate::Value::Null), &args[1.min(args.len())..]).await,
12069 "fetch_transaction_fees" => self.fetch_transaction_fees(&args[..]).await,
12070 "fetch_transactions" => self.fetch_transactions(&args[..]).await,
12071 "fetch_transfer" => self.fetch_transfer(args.get(0).cloned().unwrap_or(crate::Value::Null), &args[1.min(args.len())..]).await,
12072 "fetch_transfers" => self.fetch_transfers(&args[..]).await,
12073 "fetch_unified_order" => self.fetch_unified_order(args.get(0).cloned().unwrap_or(crate::Value::Null), &args[1.min(args.len())..]).await,
12074 "fetch_used_balance" => self.fetch_used_balance(&args[..]).await,
12075 "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,
12076 "fetch_withdrawals" => self.fetch_withdrawals(&args[..]).await,
12077 "fetch_withdrawals_ws" => self.fetch_withdrawals_ws(&args[..]).await,
12078 "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())..]),
12079 "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())..]),
12080 "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())..]),
12081 "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())..]),
12082 "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())..]),
12083 "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())..]),
12084 "filter_by_limit" => self.filter_by_limit(args.get(0).cloned().unwrap_or(crate::Value::Null), &args[1.min(args.len())..]),
12085 "filter_by_since_limit" => self.filter_by_since_limit(args.get(0).cloned().unwrap_or(crate::Value::Null), &args[1.min(args.len())..]),
12086 "filter_by_symbol" => self.filter_by_symbol(args.get(0).cloned().unwrap_or(crate::Value::Null), &args[1.min(args.len())..]),
12087 "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())..]),
12088 "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())..]),
12089 "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())..]),
12090 "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())..]),
12091 "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)),
12092 "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)),
12093 "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)),
12094 "find_timeframe" => self.find_timeframe(args.get(0).cloned().unwrap_or(crate::Value::Null), &args[1.min(args.len())..]),
12095 "force_string" => self.force_string(args.get(0).cloned().unwrap_or(crate::Value::Null)),
12096 "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)),
12097 "get_default_options" => self.get_default_options(),
12098 "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)),
12099 "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)),
12100 "get_market_from_symbols" => self.get_market_from_symbols(&args[..]),
12101 "get_supported_mapping" => self.get_supported_mapping(args.get(0).cloned().unwrap_or(crate::Value::Null), &args[1.min(args.len())..]),
12102 "get_symbols_for_market_type" => self.get_symbols_for_market_type(&args[..]),
12103 "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),
12104 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)),
12105 "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())..]),
12106 "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())..]),
12107 "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())..]),
12108 "handle_network_code_and_params" => self.handle_network_code_and_params(args.get(0).cloned().unwrap_or(crate::Value::Null)),
12109 "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())..]),
12110 "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())..]),
12111 "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())..]),
12112 "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())..]),
12113 "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())..]),
12114 "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())..]),
12115 "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())..]),
12116 "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())..]),
12117 "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())..]),
12118 "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())..]),
12119 "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())..]),
12120 "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())..]),
12121 "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())..]),
12122 "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())..]),
12123 "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())..]),
12124 "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())..]),
12125 "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())..]),
12126 "handle_time_in_force" => self.handle_time_in_force(&args[..]),
12127 "handle_trigger_and_params" => self.handle_trigger_and_params(args.get(0).cloned().unwrap_or(crate::Value::Null)),
12128 "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())..]),
12129 "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())..]),
12130 "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())..]),
12131 "implode_hostname" => self.implode_hostname(args.get(0).cloned().unwrap_or(crate::Value::Null)),
12132 "incrementing_nonce" => self.incrementing_nonce(),
12133 "integer_precision_to_amount" => self.integer_precision_to_amount(args.get(0).cloned().unwrap_or(crate::Value::Null)),
12134 "invert_flat_string_dictionary" => self.invert_flat_string_dictionary(args.get(0).cloned().unwrap_or(crate::Value::Null)),
12135 "is_empty_string" => self.is_empty_string(args.get(0).cloned().unwrap_or(crate::Value::Null)),
12136 "is_leveraged_currency" => self.is_leveraged_currency(args.get(0).cloned().unwrap_or(crate::Value::Null), &args[1.min(args.len())..]),
12137 "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())..]),
12138 "is_round_number" => self.is_round_number(args.get(0).cloned().unwrap_or(crate::Value::Null)),
12139 "is_significant_precision" => self.is_significant_precision(),
12140 "is_tick_precision" => self.is_tick_precision(),
12141 "is_trigger_order" => self.is_trigger_order(args.get(0).cloned().unwrap_or(crate::Value::Null)),
12142 "is_uta_enabled" => self.is_uta_enabled(&args[..]).await,
12143 "load_accounts" => self.load_accounts(&args[..]).await,
12144 "load_markets" => self.load_markets(&args[..]).await,
12145 "load_markets_and_sign_in" => self.load_markets_and_sign_in().await,
12146 "load_time_difference" => self.load_time_difference(&args[..]).await,
12147 "load_trading_limits" => self.load_trading_limits(&args[..]).await,
12148 "market" => <Self as crate::exchange_generated::ExchangeBase>::market(self, args.get(0).cloned().unwrap_or(crate::Value::Null)),
12149 "market_codes" => self.market_codes(&args[..]),
12150 "market_id" => self.market_id(args.get(0).cloned().unwrap_or(crate::Value::Null)),
12151 "market_ids" => self.market_ids(&args[..]),
12152 "market_non_virtual" => self.market_non_virtual(args.get(0).cloned().unwrap_or(crate::Value::Null)),
12153 "market_or_null" => self.market_or_null(&args[..]),
12154 "market_symbols" => self.market_symbols(&args[..]),
12155 "markets_for_symbols" => self.markets_for_symbols(&args[..]),
12156 "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)),
12157 "network_code_to_id" => self.network_code_to_id(args.get(0).cloned().unwrap_or(crate::Value::Null), &args[1.min(args.len())..]),
12158 "network_id_to_code" => self.network_id_to_code(&args[..]),
12159 "nonce" => <Self as crate::exchange_generated::ExchangeBase>::nonce(self),
12160 "oath" => self.oath(),
12161 "orderbook_checksum_message" => self.orderbook_checksum_message(args.get(0).cloned().unwrap_or(crate::Value::Null)),
12162 "parse_account" => <Self as crate::exchange_generated::ExchangeBase>::parse_account(self, args.get(0).cloned().unwrap_or(crate::Value::Null)),
12163 "parse_accounts" => self.parse_accounts(args.get(0).cloned().unwrap_or(crate::Value::Null), &args[1.min(args.len())..]),
12164 "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())..]),
12165 "parse_adl_ranks" => self.parse_adl_ranks(args.get(0).cloned().unwrap_or(crate::Value::Null), &args[1.min(args.len())..]),
12166 "parse_all_greeks" => self.parse_all_greeks(args.get(0).cloned().unwrap_or(crate::Value::Null), &args[1.min(args.len())..]),
12167 "parse_balance" => <Self as crate::exchange_generated::ExchangeBase>::parse_balance(self, args.get(0).cloned().unwrap_or(crate::Value::Null)),
12168 "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())..]),
12169 "parse_borrow_interests" => self.parse_borrow_interests(args.get(0).cloned().unwrap_or(crate::Value::Null), &args[1.min(args.len())..]),
12170 "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())..]),
12171 "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)),
12172 "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())..]),
12173 "parse_conversions" => self.parse_conversions(args.get(0).cloned().unwrap_or(crate::Value::Null), &args[1.min(args.len())..]),
12174 "parse_currencies" => self.parse_currencies(args.get(0).cloned().unwrap_or(crate::Value::Null)),
12175 "parse_currency" => <Self as crate::exchange_generated::ExchangeBase>::parse_currency(self, args.get(0).cloned().unwrap_or(crate::Value::Null)),
12176 "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())..]),
12177 "parse_deposit_addresses" => self.parse_deposit_addresses(args.get(0).cloned().unwrap_or(crate::Value::Null), &args[1.min(args.len())..]),
12178 "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())..]),
12179 "parse_deposit_withdraw_fees" => self.parse_deposit_withdraw_fees(args.get(0).cloned().unwrap_or(crate::Value::Null), &args[1.min(args.len())..]),
12180 "parse_fee_numeric" => self.parse_fee_numeric(args.get(0).cloned().unwrap_or(crate::Value::Null)),
12181 "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())..]),
12182 "parse_funding_rate_histories" => self.parse_funding_rate_histories(args.get(0).cloned().unwrap_or(crate::Value::Null), &args[1.min(args.len())..]),
12183 "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())..]),
12184 "parse_funding_rates" => self.parse_funding_rates(args.get(0).cloned().unwrap_or(crate::Value::Null), &args[1.min(args.len())..]),
12185 "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())..]),
12186 "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())..]),
12187 "parse_incomes" => self.parse_incomes(args.get(0).cloned().unwrap_or(crate::Value::Null), &args[1.min(args.len())..]),
12188 "parse_isolated_borrow_rate" => self.parse_isolated_borrow_rate(args.get(0).cloned().unwrap_or(crate::Value::Null), &args[1.min(args.len())..]),
12189 "parse_isolated_borrow_rates" => self.parse_isolated_borrow_rates(args.get(0).cloned().unwrap_or(crate::Value::Null)),
12190 "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())..]),
12191 "parse_last_prices" => self.parse_last_prices(args.get(0).cloned().unwrap_or(crate::Value::Null), &args[1.min(args.len())..]),
12192 "parse_ledger" => self.parse_ledger(args.get(0).cloned().unwrap_or(crate::Value::Null), &args[1.min(args.len())..]),
12193 "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())..]),
12194 "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())..]),
12195 "parse_leverage_tiers" => self.parse_leverage_tiers(args.get(0).cloned().unwrap_or(crate::Value::Null), &args[1.min(args.len())..]),
12196 "parse_leverages" => self.parse_leverages(args.get(0).cloned().unwrap_or(crate::Value::Null), &args[1.min(args.len())..]),
12197 "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())..]),
12198 "parse_liquidations" => self.parse_liquidations(args.get(0).cloned().unwrap_or(crate::Value::Null), &args[1.min(args.len())..]),
12199 "parse_long_short_ratio" => self.parse_long_short_ratio(args.get(0).cloned().unwrap_or(crate::Value::Null), &args[1.min(args.len())..]),
12200 "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())..]),
12201 "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())..]),
12202 "parse_margin_modes" => self.parse_margin_modes(args.get(0).cloned().unwrap_or(crate::Value::Null), &args[1.min(args.len())..]),
12203 "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())..]),
12204 "parse_margin_modifications" => self.parse_margin_modifications(args.get(0).cloned().unwrap_or(crate::Value::Null), &args[1.min(args.len())..]),
12205 "parse_market" => <Self as crate::exchange_generated::ExchangeBase>::parse_market(self, args.get(0).cloned().unwrap_or(crate::Value::Null)),
12206 "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())..]),
12207 "parse_markets" => self.parse_markets(args.get(0).cloned().unwrap_or(crate::Value::Null)),
12208 "parse_ohlc_vs" => self.parse_ohlc_vs(args.get(0).cloned().unwrap_or(crate::Value::Null), &args[1.min(args.len())..]),
12209 "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())..]),
12210 "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())..]),
12211 "parse_open_interests" => self.parse_open_interests(args.get(0).cloned().unwrap_or(crate::Value::Null), &args[1.min(args.len())..]),
12212 "parse_open_interests_history" => self.parse_open_interests_history(args.get(0).cloned().unwrap_or(crate::Value::Null), &args[1.min(args.len())..]),
12213 "parse_option" => self.parse_option(args.get(0).cloned().unwrap_or(crate::Value::Null), &args[1.min(args.len())..]),
12214 "parse_option_chain" => self.parse_option_chain(args.get(0).cloned().unwrap_or(crate::Value::Null), &args[1.min(args.len())..]),
12215 "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())..]),
12216 "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())..]),
12217 "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())..]),
12218 "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())..]),
12219 "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())..]),
12220 "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())..]),
12221 "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())..]),
12222 "parse_orders" => self.parse_orders(args.get(0).cloned().unwrap_or(crate::Value::Null), &args[1.min(args.len())..]),
12223 "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())..]),
12224 "parse_positions" => self.parse_positions(args.get(0).cloned().unwrap_or(crate::Value::Null), &args[1.min(args.len())..]),
12225 "parse_precision" => self.parse_precision(&args[..]),
12226 "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())..]),
12227 "parse_tickers" => self.parse_tickers(args.get(0).cloned().unwrap_or(crate::Value::Null), &args[1.min(args.len())..]),
12228 "parse_to_int" => self.parse_to_int(args.get(0).cloned().unwrap_or(crate::Value::Null)),
12229 "parse_to_numeric" => self.parse_to_numeric(args.get(0).cloned().unwrap_or(crate::Value::Null)),
12230 "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())..]),
12231 "parse_trades" => self.parse_trades(args.get(0).cloned().unwrap_or(crate::Value::Null), &args[1.min(args.len())..]),
12232 "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())..]),
12233 "parse_trading_view_ohlcv" => self.parse_trading_view_ohlcv(args.get(0).cloned().unwrap_or(crate::Value::Null), &args[1.min(args.len())..]),
12234 "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())..]),
12235 "parse_transactions" => self.parse_transactions(args.get(0).cloned().unwrap_or(crate::Value::Null), &args[1.min(args.len())..]),
12236 "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())..]),
12237 "parse_transfers" => self.parse_transfers(args.get(0).cloned().unwrap_or(crate::Value::Null), &args[1.min(args.len())..]),
12238 "parse_ws_ohlc_vs" => self.parse_ws_ohlc_vs(args.get(0).cloned().unwrap_or(crate::Value::Null), &args[1.min(args.len())..]),
12239 "parse_ws_ohlcv" => self.parse_ws_ohlcv(args.get(0).cloned().unwrap_or(crate::Value::Null), &args[1.min(args.len())..]),
12240 "parse_ws_order" => self.parse_ws_order(args.get(0).cloned().unwrap_or(crate::Value::Null), &args[1.min(args.len())..]),
12241 "parse_ws_order_trade" => self.parse_ws_order_trade(args.get(0).cloned().unwrap_or(crate::Value::Null), &args[1.min(args.len())..]),
12242 "parse_ws_trade" => self.parse_ws_trade(args.get(0).cloned().unwrap_or(crate::Value::Null), &args[1.min(args.len())..]),
12243 "parse_ws_trades" => self.parse_ws_trades(args.get(0).cloned().unwrap_or(crate::Value::Null), &args[1.min(args.len())..]),
12244 "parsed_fee_and_fees" => self.parsed_fee_and_fees(args.get(0).cloned().unwrap_or(crate::Value::Null)),
12245 "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)),
12246 "reduce_fees_by_currency" => self.reduce_fees_by_currency(args.get(0).cloned().unwrap_or(crate::Value::Null)),
12247 "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,
12248 "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)),
12249 "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())..]),
12250 "remove_repeated_trades_from_array" => self.remove_repeated_trades_from_array(args.get(0).cloned().unwrap_or(crate::Value::Null)),
12251 "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,
12252 "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,
12253 "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,
12254 "request" => self.request(args.get(0).cloned().unwrap_or(crate::Value::Null), &args[1.min(args.len())..]).await,
12255 "require_value" => self.require_value(args.get(0).cloned().unwrap_or(crate::Value::Null), &args[1.min(args.len())..]),
12256 "resolve_path" => self.resolve_path(args.get(0).cloned().unwrap_or(crate::Value::Null), args.get(1).cloned().unwrap_or(crate::Value::Null)),
12257 "safe_balance" => self.safe_balance(args.get(0).cloned().unwrap_or(crate::Value::Null)),
12258 "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())..]),
12259 "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())..]),
12260 "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())..]),
12261 "safe_currency" => self.safe_currency(args.get(0).cloned().unwrap_or(crate::Value::Null), &args[1.min(args.len())..]),
12262 "safe_currency_code" => self.safe_currency_code(args.get(0).cloned().unwrap_or(crate::Value::Null), &args[1.min(args.len())..]),
12263 "safe_currency_structure" => self.safe_currency_structure(args.get(0).cloned().unwrap_or(crate::Value::Null)),
12264 "safe_deterministic_call" => self.safe_deterministic_call(args.get(0).cloned().unwrap_or(crate::Value::Null), &args[1.min(args.len())..]).await,
12265 "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())..]),
12266 "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())..]),
12267 "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())..]),
12268 "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())..]),
12269 "safe_ledger_entry" => self.safe_ledger_entry(args.get(0).cloned().unwrap_or(crate::Value::Null), &args[1.min(args.len())..]),
12270 "safe_liquidation" => self.safe_liquidation(args.get(0).cloned().unwrap_or(crate::Value::Null), &args[1.min(args.len())..]),
12271 "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())..]),
12272 "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())..]),
12273 "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())..]),
12274 "safe_market" => self.safe_market(&args[..]),
12275 "safe_market_structure" => self.safe_market_structure(&args[..]),
12276 "safe_network" => self.safe_network(args.get(0).cloned().unwrap_or(crate::Value::Null)),
12277 "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())..]),
12278 "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())..]),
12279 "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())..]),
12280 "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())..]),
12281 "safe_open_interest" => self.safe_open_interest(args.get(0).cloned().unwrap_or(crate::Value::Null), &args[1.min(args.len())..]),
12282 "safe_order" => self.safe_order(args.get(0).cloned().unwrap_or(crate::Value::Null), &args[1.min(args.len())..]),
12283 "safe_position" => self.safe_position(args.get(0).cloned().unwrap_or(crate::Value::Null)),
12284 "safe_symbol" => self.safe_symbol(args.get(0).cloned().unwrap_or(crate::Value::Null), &args[1.min(args.len())..]),
12285 "safe_ticker" => self.safe_ticker(args.get(0).cloned().unwrap_or(crate::Value::Null), &args[1.min(args.len())..]),
12286 "safe_trade" => self.safe_trade(args.get(0).cloned().unwrap_or(crate::Value::Null), &args[1.min(args.len())..]),
12287 "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())..]),
12288 "set_headers" => self.set_headers(args.get(0).cloned().unwrap_or(crate::Value::Null)),
12289 "set_leverage" => self.set_leverage(args.get(0).cloned().unwrap_or(crate::Value::Null), &args[1.min(args.len())..]).await,
12290 "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,
12291 "set_margin_mode" => self.set_margin_mode(args.get(0).cloned().unwrap_or(crate::Value::Null), &args[1.min(args.len())..]).await,
12292 "set_markets" => self.set_markets(args.get(0).cloned().unwrap_or(crate::Value::Null), &args[1.min(args.len())..]),
12293 "set_markets_from_exchange" => self.set_markets_from_exchange(args.get(0).cloned().unwrap_or(crate::Value::Null)),
12294 "set_position_mode" => self.set_position_mode(args.get(0).cloned().unwrap_or(crate::Value::Null), &args[1.min(args.len())..]).await,
12295 "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())..]),
12296 "sign" => <Self as crate::exchange_generated::ExchangeBase>::sign(self, args.get(0).cloned().unwrap_or(crate::Value::Null), &args[1.min(args.len())..]),
12297 "sign_in" => self.sign_in(&args[..]).await,
12298 "sort_cursor_paginated_result" => self.sort_cursor_paginated_result(args.get(0).cloned().unwrap_or(crate::Value::Null)),
12299 "string_to_base16" => self.string_to_base16(args.get(0).cloned().unwrap_or(crate::Value::Null)),
12300 "symbol" => self.symbol(args.get(0).cloned().unwrap_or(crate::Value::Null)),
12301 "timeframe_from_milliseconds" => self.timeframe_from_milliseconds(args.get(0).cloned().unwrap_or(crate::Value::Null)),
12302 "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,
12303 "un_watch_bids_asks" => self.un_watch_bids_asks(&args[..]).await,
12304 "un_watch_funding_rate" => self.un_watch_funding_rate(args.get(0).cloned().unwrap_or(crate::Value::Null), &args[1.min(args.len())..]).await,
12305 "un_watch_funding_rates" => self.un_watch_funding_rates(&args[..]).await,
12306 "un_watch_mark_price" => self.un_watch_mark_price(args.get(0).cloned().unwrap_or(crate::Value::Null), &args[1.min(args.len())..]).await,
12307 "un_watch_mark_prices" => self.un_watch_mark_prices(&args[..]).await,
12308 "un_watch_my_trades" => self.un_watch_my_trades(&args[..]).await,
12309 "un_watch_ohlcv" => self.un_watch_ohlcv(args.get(0).cloned().unwrap_or(crate::Value::Null), &args[1.min(args.len())..]).await,
12310 "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,
12311 "un_watch_order_book" => self.un_watch_order_book(args.get(0).cloned().unwrap_or(crate::Value::Null), &args[1.min(args.len())..]).await,
12312 "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,
12313 "un_watch_orders" => self.un_watch_orders(&args[..]).await,
12314 "un_watch_positions" => self.un_watch_positions(&args[..]).await,
12315 "un_watch_ticker" => self.un_watch_ticker(args.get(0).cloned().unwrap_or(crate::Value::Null), &args[1.min(args.len())..]).await,
12316 "un_watch_tickers" => self.un_watch_tickers(&args[..]).await,
12317 "un_watch_trades" => self.un_watch_trades(args.get(0).cloned().unwrap_or(crate::Value::Null), &args[1.min(args.len())..]).await,
12318 "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,
12319 "url_encoder_for_proxy_url" => self.url_encoder_for_proxy_url(args.get(0).cloned().unwrap_or(crate::Value::Null)),
12320 "watch_balance" => self.watch_balance(&args[..]).await,
12321 "watch_bids_asks" => self.watch_bids_asks(&args[..]).await,
12322 "watch_funding_rate" => self.watch_funding_rate(args.get(0).cloned().unwrap_or(crate::Value::Null), &args[1.min(args.len())..]).await,
12323 "watch_funding_rates" => self.watch_funding_rates(&args[..]).await,
12324 "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,
12325 "watch_liquidations" => self.watch_liquidations(args.get(0).cloned().unwrap_or(crate::Value::Null), &args[1.min(args.len())..]).await,
12326 "watch_liquidations_for_symbols" => self.watch_liquidations_for_symbols(args.get(0).cloned().unwrap_or(crate::Value::Null), &args[1.min(args.len())..]).await,
12327 "watch_mark_price" => self.watch_mark_price(args.get(0).cloned().unwrap_or(crate::Value::Null), &args[1.min(args.len())..]).await,
12328 "watch_mark_prices" => self.watch_mark_prices(&args[..]).await,
12329 "watch_my_liquidations" => self.watch_my_liquidations(args.get(0).cloned().unwrap_or(crate::Value::Null), &args[1.min(args.len())..]).await,
12330 "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,
12331 "watch_my_trades" => self.watch_my_trades(&args[..]).await,
12332 "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,
12333 "watch_ohlcv" => self.watch_ohlcv(args.get(0).cloned().unwrap_or(crate::Value::Null), &args[1.min(args.len())..]).await,
12334 "watch_ohlcv_for_symbols" => self.watch_ohlcv_for_symbols(args.get(0).cloned().unwrap_or(crate::Value::Null), &args[1.min(args.len())..]).await,
12335 "watch_order_book" => self.watch_order_book(args.get(0).cloned().unwrap_or(crate::Value::Null), &args[1.min(args.len())..]).await,
12336 "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,
12337 "watch_orders" => self.watch_orders(&args[..]).await,
12338 "watch_orders_for_symbols" => self.watch_orders_for_symbols(args.get(0).cloned().unwrap_or(crate::Value::Null), &args[1.min(args.len())..]).await,
12339 "watch_position" => self.watch_position(&args[..]).await,
12340 "watch_position_for_symbols" => self.watch_position_for_symbols(&args[..]).await,
12341 "watch_positions" => self.watch_positions(&args[..]).await,
12342 "watch_ticker" => self.watch_ticker(args.get(0).cloned().unwrap_or(crate::Value::Null), &args[1.min(args.len())..]).await,
12343 "watch_tickers" => self.watch_tickers(&args[..]).await,
12344 "watch_trades" => self.watch_trades(args.get(0).cloned().unwrap_or(crate::Value::Null), &args[1.min(args.len())..]).await,
12345 "watch_trades_for_symbols" => self.watch_trades_for_symbols(args.get(0).cloned().unwrap_or(crate::Value::Null), &args[1.min(args.len())..]).await,
12346 "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,
12347 "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,
12348 _ => {
12362 if self.internals.implicit_api.is_empty() {
12363 self.build_implicit_api();
12364 }
12365 if self.internals.implicit_api.contains_key(method) {
12366 self.call_method(crate::Value::Str(method.to_string().into()), &args[..]).await
12367 } else {
12368 self.internals.dynamic_dispatch_miss = Some(method.to_string());
12369 crate::Value::Null
12370 }
12371 }
12372 }
12373 })
12374 }
12375}