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::Bool(true));
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::Bool(true));
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::Bool(true));
117 m.insert("createMarketOrderWs".to_string(), Value::Bool(true));
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::Bool(true));
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::Bool(true));
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::Bool(true));
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::Bool(true));
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::Bool(true));
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::Bool(true));
262 m.insert("fetchTradesWs".to_string(), Value::Null);
263 m.insert("fetchTradingFee".to_string(), Value::Null);
264 m.insert("fetchTradingFees".to_string(), Value::Null);
265 m.insert("fetchTradingFeesWs".to_string(), Value::Null);
266 m.insert("fetchTradingLimits".to_string(), Value::Null);
267 m.insert("fetchTransactionFee".to_string(), Value::Null);
268 m.insert("fetchTransactionFees".to_string(), Value::Null);
269 m.insert("fetchTransactions".to_string(), Value::Null);
270 m.insert("fetchTransfer".to_string(), Value::Null);
271 m.insert("fetchTransfers".to_string(), Value::Null);
272 m.insert("fetchUnderlyingAssets".to_string(), Value::Null);
273 m.insert("fetchVolatilityHistory".to_string(), Value::Null);
274 m.insert("fetchWithdrawAddresses".to_string(), Value::Null);
275 m.insert("fetchWithdrawal".to_string(), Value::Null);
276 m.insert("fetchWithdrawals".to_string(), Value::Null);
277 m.insert("fetchWithdrawalsWs".to_string(), Value::Null);
278 m.insert("fetchWithdrawalWhitelist".to_string(), Value::Null);
279 m.insert("reduceMargin".to_string(), Value::Null);
280 m.insert("repayCrossMargin".to_string(), Value::Null);
281 m.insert("repayIsolatedMargin".to_string(), Value::Null);
282 m.insert("setLeverage".to_string(), Value::Null);
283 m.insert("setMargin".to_string(), Value::Null);
284 m.insert("setMarginMode".to_string(), Value::Null);
285 m.insert("setPositionMode".to_string(), Value::Null);
286 m.insert("signIn".to_string(), Value::Null);
287 m.insert("transfer".to_string(), Value::Null);
288 m.insert("watchBalance".to_string(), Value::Null);
289 m.insert("watchMyTrades".to_string(), Value::Null);
290 m.insert("watchOHLCV".to_string(), Value::Null);
291 m.insert("watchOHLCVForSymbols".to_string(), Value::Null);
292 m.insert("watchOrderBook".to_string(), Value::Null);
293 m.insert("watchBidsAsks".to_string(), Value::Null);
294 m.insert("watchOrderBookForSymbols".to_string(), Value::Null);
295 m.insert("watchOrders".to_string(), Value::Null);
296 m.insert("watchOrdersForSymbols".to_string(), Value::Null);
297 m.insert("watchPosition".to_string(), Value::Null);
298 m.insert("watchPositions".to_string(), Value::Null);
299 m.insert("watchStatus".to_string(), Value::Null);
300 m.insert("watchTicker".to_string(), Value::Null);
301 m.insert("watchTickers".to_string(), Value::Null);
302 m.insert("watchTrades".to_string(), Value::Null);
303 m.insert("watchTradesForSymbols".to_string(), Value::Null);
304 m.insert("watchLiquidations".to_string(), Value::Null);
305 m.insert("watchLiquidationsForSymbols".to_string(), Value::Null);
306 m.insert("watchMyLiquidations".to_string(), Value::Null);
307 m.insert("unWatchOrders".to_string(), Value::Null);
308 m.insert("unWatchTrades".to_string(), Value::Null);
309 m.insert("unWatchTradesForSymbols".to_string(), Value::Null);
310 m.insert("unWatchOHLCVForSymbols".to_string(), Value::Null);
311 m.insert("unWatchOrderBookForSymbols".to_string(), Value::Null);
312 m.insert("unWatchPositions".to_string(), Value::Null);
313 m.insert("unWatchOrderBook".to_string(), Value::Null);
314 m.insert("unWatchTickers".to_string(), Value::Null);
315 m.insert("unWatchMyTrades".to_string(), Value::Null);
316 m.insert("unWatchTicker".to_string(), Value::Null);
317 m.insert("unWatchOHLCV".to_string(), Value::Null);
318 m.insert("watchMyLiquidationsForSymbols".to_string(), Value::Null);
319 m.insert("withdraw".to_string(), Value::Null);
320 m.insert("ws".to_string(), Value::Null);
321 m
322}));
323 m.insert("urls".to_string(), Value::Map({
324 let mut m = indexmap::IndexMap::new();
325 m.insert("logo".to_string(), Value::Null);
326 m.insert("api".to_string(), Value::Null);
327 m.insert("test".to_string(), Value::Null);
328 m.insert("www".to_string(), Value::Null);
329 m.insert("doc".to_string(), Value::Null);
330 m.insert("api_management".to_string(), Value::Null);
331 m.insert("fees".to_string(), Value::Null);
332 m.insert("referral".to_string(), Value::Null);
333 m
334}));
335 m.insert("api".to_string(), Value::Null);
336 m.insert("requiredCredentials".to_string(), Value::Map({
337 let mut m = indexmap::IndexMap::new();
338 m.insert("apiKey".to_string(), Value::Bool(true));
339 m.insert("secret".to_string(), Value::Bool(true));
340 m.insert("uid".to_string(), Value::Bool(false));
341 m.insert("accountId".to_string(), Value::Bool(false));
342 m.insert("login".to_string(), Value::Bool(false));
343 m.insert("password".to_string(), Value::Bool(false));
344 m.insert("twofa".to_string(), Value::Bool(false));
345 m.insert("privateKey".to_string(), Value::Bool(false));
346 m.insert("walletAddress".to_string(), Value::Bool(false));
347 m.insert("token".to_string(), Value::Bool(false));
348 m
349}));
350 m.insert("markets".to_string(), Value::Null);
351 m.insert("currencies".to_string(), Value::Map({
352 let mut m = indexmap::IndexMap::new();
353 m
354}));
355 m.insert("timeframes".to_string(), Value::Null);
356 m.insert("fees".to_string(), Value::Map({
357 let mut m = indexmap::IndexMap::new();
358 m.insert("trading".to_string(), Value::Map({
359 let mut m = indexmap::IndexMap::new();
360 m.insert("tierBased".to_string(), Value::Null);
361 m.insert("percentage".to_string(), Value::Null);
362 m.insert("taker".to_string(), Value::Null);
363 m.insert("maker".to_string(), Value::Null);
364 m
365}));
366 m.insert("funding".to_string(), Value::Map({
367 let mut m = indexmap::IndexMap::new();
368 m.insert("tierBased".to_string(), Value::Null);
369 m.insert("percentage".to_string(), Value::Null);
370 m.insert("withdraw".to_string(), Value::Map({
371 let mut m = indexmap::IndexMap::new();
372 m
373}));
374 m.insert("deposit".to_string(), Value::Map({
375 let mut m = indexmap::IndexMap::new();
376 m
377}));
378 m
379}));
380 m
381}));
382 m.insert("status".to_string(), Value::Map({
383 let mut m = indexmap::IndexMap::new();
384 m.insert("status".to_string(), Value::Str("ok".into()));
385 m.insert("updated".to_string(), Value::Null);
386 m.insert("eta".to_string(), Value::Null);
387 m.insert("url".to_string(), Value::Null);
388 m.insert("info".to_string(), Value::Null);
389 m
390}));
391 m.insert("exceptions".to_string(), Value::Null);
392 m.insert("httpExceptions".to_string(), Value::Map({
393 let mut m = indexmap::IndexMap::new();
394 m.insert("422".to_string(), Value::Str("ExchangeError".into()).clone());
395 m.insert("418".to_string(), Value::Str("DDoSProtection".into()).clone());
396 m.insert("429".to_string(), Value::Str("RateLimitExceeded".into()).clone());
397 m.insert("404".to_string(), Value::Str("ExchangeNotAvailable".into()).clone());
398 m.insert("409".to_string(), Value::Str("ExchangeNotAvailable".into()).clone());
399 m.insert("410".to_string(), Value::Str("ExchangeNotAvailable".into()).clone());
400 m.insert("451".to_string(), Value::Str("ExchangeNotAvailable".into()).clone());
401 m.insert("500".to_string(), Value::Str("ExchangeNotAvailable".into()).clone());
402 m.insert("501".to_string(), Value::Str("ExchangeNotAvailable".into()).clone());
403 m.insert("502".to_string(), Value::Str("ExchangeNotAvailable".into()).clone());
404 m.insert("520".to_string(), Value::Str("ExchangeNotAvailable".into()).clone());
405 m.insert("521".to_string(), Value::Str("ExchangeNotAvailable".into()).clone());
406 m.insert("522".to_string(), Value::Str("ExchangeNotAvailable".into()).clone());
407 m.insert("525".to_string(), Value::Str("ExchangeNotAvailable".into()).clone());
408 m.insert("526".to_string(), Value::Str("ExchangeNotAvailable".into()).clone());
409 m.insert("400".to_string(), Value::Str("ExchangeNotAvailable".into()).clone());
410 m.insert("403".to_string(), Value::Str("ExchangeNotAvailable".into()).clone());
411 m.insert("405".to_string(), Value::Str("ExchangeNotAvailable".into()).clone());
412 m.insert("503".to_string(), Value::Str("ExchangeNotAvailable".into()).clone());
413 m.insert("530".to_string(), Value::Str("ExchangeNotAvailable".into()).clone());
414 m.insert("408".to_string(), Value::Str("RequestTimeout".into()).clone());
415 m.insert("504".to_string(), Value::Str("RequestTimeout".into()).clone());
416 m.insert("401".to_string(), Value::Str("AuthenticationError".into()).clone());
417 m.insert("407".to_string(), Value::Str("AuthenticationError".into()).clone());
418 m.insert("511".to_string(), Value::Str("AuthenticationError".into()).clone());
419 m
420}));
421 m.insert("commonCurrencies".to_string(), Value::Map({
422 let mut m = indexmap::IndexMap::new();
423 m.insert("XBT".to_string(), Value::Str("BTC".into()));
424 m.insert("BCHSV".to_string(), Value::Str("BSV".into()));
425 m
426}));
427 m.insert("precisionMode".to_string(), Value::Int(crate::runtime::TICK_SIZE));
428 m.insert("paddingMode".to_string(), Value::Int(crate::runtime::NO_PADDING));
429 m.insert("limits".to_string(), Value::Map({
430 let mut m = indexmap::IndexMap::new();
431 m.insert("leverage".to_string(), Value::Map({
432 let mut m = indexmap::IndexMap::new();
433 m.insert("min".to_string(), Value::Null);
434 m.insert("max".to_string(), Value::Null);
435 m
436}));
437 m.insert("amount".to_string(), Value::Map({
438 let mut m = indexmap::IndexMap::new();
439 m.insert("min".to_string(), Value::Null);
440 m.insert("max".to_string(), Value::Null);
441 m
442}));
443 m.insert("price".to_string(), Value::Map({
444 let mut m = indexmap::IndexMap::new();
445 m.insert("min".to_string(), Value::Null);
446 m.insert("max".to_string(), Value::Null);
447 m
448}));
449 m.insert("cost".to_string(), Value::Map({
450 let mut m = indexmap::IndexMap::new();
451 m.insert("min".to_string(), Value::Null);
452 m.insert("max".to_string(), Value::Null);
453 m
454}));
455 m
456}));
457 m.insert("rollingWindowSize".to_string(), Value::Int(60000));
458 m
459});
460
461 Value::Null
462}
463
464 fn clean_rest_data(&mut self) {
465 self.ids = Value::Null;
466 self.markets = Value::Null;
467 self.markets_by_id = Value::Null;
468 self.symbols = Value::from(vec![]);
469 self.codes = Value::Null;
470 { let __t = self.create_safe_dictionary(&[]); self.currencies = __t; }
471 self.currencies_by_id = Value::Null;
472 self.baseCurrencies = Value::Null;
473 self.quoteCurrencies = Value::Null;
474 self.last_http_response = Value::Null;
475 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 is_true(&self.is_dictionary(value.clone())) {
562 return value;
563 }
564 return defaultValue;
565
566 Value::Null
567}
568
569 fn safe_dict(&self, mut dictionaryOrList: Value, mut key: Value, optional_args: &[Value]) -> Value {
570 let mut defaultValue = get_arg(optional_args, 0, Value::Null);
571 let mut value: Value = self.safe_value(dictionaryOrList, key, &[defaultValue.clone()]);
578 if (value == Value::Null) {
579 return defaultValue;
580 }
581 if is_true(&self.is_dictionary(value.clone())) {
582 return value;
583 }
584 return defaultValue;
585
586 Value::Null
587}
588
589 fn safe_dict2(&self, mut dictionaryOrList: Value, mut key1: Value, mut key2: Value, optional_args: &[Value]) -> Value {
590 let mut defaultValue = get_arg(optional_args, 0, Value::Null);
591 let mut value: Value = self.safe_value(dictionaryOrList.clone(), key1, &[]);
598 if is_true(&self.is_dictionary(value.clone())) {
599 return value;
600 }
601 let mut value2: Value = self.safe_value(dictionaryOrList, key2, &[]);
602 if is_true(&self.is_dictionary(value2.clone())) {
603 return value2;
604 }
605 return defaultValue;
606
607 Value::Null
608}
609
610 fn safe_list_n(&self, mut dictionaryOrList: Value, mut keys: Value, optional_args: &[Value]) -> Value {
611 let mut defaultValue = get_arg(optional_args, 0, Value::Null);
612 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 add_element_to_object(&mut dict, &k, value);
680 }
681}
682
683 fn handle_deltas(&self, mut bookside: Value, mut deltas: Value) {
684 {
685 let mut i: Value = Value::Int(0);
686 let mut __for_first_71: bool = true;
687 while { if !__for_first_71 { i = (match (&(i), &(Value::Int(1))) { (Value::Int(x), Value::Int(y)) => Value::Int(x + y), (Value::Int(x), Value::Float(y)) => Value::Float(*x as f64 + *y), (Value::Float(x), Value::Int(y)) => Value::Float(*x + *y as f64), (Value::Float(x), Value::Float(y)) => Value::Float(x + y), _ => Value::Null }); } __for_first_71 = false; i.as_f64().unwrap_or(f64::NAN) < get_array_length(&deltas).as_f64().unwrap_or(f64::NAN) } {
688 self.handle_delta(bookside.clone(), get_value(&deltas, &i));
689 }
690 }
691}
692
693 fn handle_delta(&self, mut bookside: Value, mut delta: Value) {
694 panic!("{}", crate::exchange_errors::not_supported(format!("{}{}", self.id.clone(), Value::Str(" handleDelta not supported yet".into()))));
695}
696
697 fn handle_book_deltas(&self, mut orderbook: Value, mut deltas: Value) {
698 {
699 let mut i: Value = Value::Int(0);
700 let mut __for_first_72: bool = true;
701 while { if !__for_first_72 { i = (match (&(i), &(Value::Int(1))) { (Value::Int(x), Value::Int(y)) => Value::Int(x + y), (Value::Int(x), Value::Float(y)) => Value::Float(*x as f64 + *y), (Value::Float(x), Value::Int(y)) => Value::Float(*x + *y as f64), (Value::Float(x), Value::Float(y)) => Value::Float(x + y), _ => Value::Null }); } __for_first_72 = false; i.as_f64().unwrap_or(f64::NAN) < get_array_length(&deltas).as_f64().unwrap_or(f64::NAN) } {
702 self.handle_book_delta(orderbook.clone(), get_value(&deltas, &i));
703 }
704 }
705}
706
707 fn handle_book_delta(&self, mut orderbook: Value, mut delta: Value) {
708 panic!("{}", crate::exchange_errors::not_supported(format!("{}{}", self.id.clone(), Value::Str(" handleBookDelta not supported yet".into()))));
709}
710
711 fn handle_deltas_with_keys(&self, mut bookSide: Value, mut deltas: Value, optional_args: &[Value]) {
712 let mut priceKey = get_arg(optional_args, 0, Value::Int(0));
713 let mut amountKey = get_arg(optional_args, 1, Value::Int(1));
714 let mut countOrIdKey = get_arg(optional_args, 2, Value::Int(2));
715 {
716 let mut i: Value = Value::Int(0);
717 let mut __for_first_73: bool = true;
718 while { if !__for_first_73 { i = (match (&(i), &(Value::Int(1))) { (Value::Int(x), Value::Int(y)) => Value::Int(x + y), (Value::Int(x), Value::Float(y)) => Value::Float(*x as f64 + *y), (Value::Float(x), Value::Int(y)) => Value::Float(*x + *y as f64), (Value::Float(x), Value::Float(y)) => Value::Float(x + y), _ => Value::Null }); } __for_first_73 = false; i.as_f64().unwrap_or(f64::NAN) < get_array_length(&deltas).as_f64().unwrap_or(f64::NAN) } {
719 let mut bidAsk: Value = self.parse_order_book_bid_ask(get_value(&deltas, &i), &[priceKey.clone(), amountKey.clone(), countOrIdKey.clone()]);
720 bookSide.store_array(bidAsk);
721 }
722 }
723}
724
725 fn get_cache_index(&self, mut orderbook: Value, mut deltas: Value) -> Value {
726 return Value::Int(-1);
727
728 Value::Null
729}
730
731 fn arrays_concat(&self, mut arraysOfArrays: Value) -> Value {
732 let mut result: Value = Value::from(vec![]);
733 {
734 let mut i: Value = Value::Int(0);
735 let mut __for_first_74: bool = true;
736 while { if !__for_first_74 { i = (match (&(i), &(Value::Int(1))) { (Value::Int(x), Value::Int(y)) => Value::Int(x + y), (Value::Int(x), Value::Float(y)) => Value::Float(*x as f64 + *y), (Value::Float(x), Value::Int(y)) => Value::Float(*x + *y as f64), (Value::Float(x), Value::Float(y)) => Value::Float(x + y), _ => Value::Null }); } __for_first_74 = false; i.as_f64().unwrap_or(f64::NAN) < ((arraysOfArrays.len() as i64) as f64) } {
737 result = self.array_concat(result.clone(), arraysOfArrays.as_array().and_then(|__arr| match &i { Value::Int(__n) => __arr.get(*__n as usize), Value::Str(__s) => __s.parse::<usize>().ok().and_then(|__n| __arr.get(__n)), _ => None }).cloned().unwrap_or(Value::Null));
738 }
739 }
740 return result;
741
742 Value::Null
743}
744
745 fn find_timeframe(&self, mut timeframe: Value, optional_args: &[Value]) -> Value {
746 let mut timeframes = get_arg(optional_args, 0, Value::Null);
747 let mut timeframesResolved: Value = (if (timeframes == Value::Null) { self.timeframes.clone() } else { timeframes });
748 let mut keys: Value = object_keys(&timeframesResolved);
749 {
750 let mut i: Value = Value::Int(0);
751 let mut __for_first_75: bool = true;
752 while { if !__for_first_75 { i = (match (&(i), &(Value::Int(1))) { (Value::Int(x), Value::Int(y)) => Value::Int(x + y), (Value::Int(x), Value::Float(y)) => Value::Float(*x as f64 + *y), (Value::Float(x), Value::Int(y)) => Value::Float(*x + *y as f64), (Value::Float(x), Value::Float(y)) => Value::Float(x + y), _ => Value::Null }); } __for_first_75 = false; i.as_f64().unwrap_or(f64::NAN) < ((keys.len() as i64) as f64) } {
753 let mut key: Value = keys.as_array().and_then(|__arr| match &i { Value::Int(__n) => __arr.get(*__n as usize), Value::Str(__s) => __s.parse::<usize>().ok().and_then(|__n| __arr.get(__n)), _ => None }).cloned().unwrap_or(Value::Null);
754 if is_equal(&timeframesResolved.as_map().and_then(|__m| key.as_str().and_then(|__k| __m.get(__k))).cloned().unwrap_or(Value::Null), &timeframe) {
755 return key;
756 }
757 }
758 }
759 return Value::Null;
760
761 Value::Null
762}
763
764 fn check_proxy_url_settings(&self, optional_args: &[Value]) -> Value {
765 let mut url = get_arg(optional_args, 0, Value::Null);
766 let mut method = get_arg(optional_args, 1, Value::Null);
767 let mut headers = get_arg(optional_args, 2, Value::Null);
768 let mut body = get_arg(optional_args, 3, Value::Null);
769 let mut usedProxies: Value = Value::from(vec![]);
770 let mut proxyUrl: Value = Value::Null;
771 if (self.proxyUrl.clone() != Value::Null) {
772 append_to_array(&mut usedProxies, Value::Str("proxyUrl".into()));
773 proxyUrl = self.proxyUrl.clone();
774 }
775 if (self.proxy_url.clone() != Value::Null) {
776 append_to_array(&mut usedProxies, Value::Str("proxy_url".into()));
777 proxyUrl = self.proxy_url.clone();
778 }
779 if (self.proxyUrlCallback.clone() != Value::Null) {
780 append_to_array(&mut usedProxies, Value::Str("proxyUrlCallback".into()));
781 proxyUrl = self.proxy_url_callback_fn(url.clone(), method.clone(), headers.clone(), body.clone());
782 }
783 if (self.proxy_url_callback.clone() != Value::Null) {
784 append_to_array(&mut usedProxies, Value::Str("proxy_url_callback".into()));
785 proxyUrl = self.proxy_url_callback_fn(url.clone(), method.clone(), headers.clone(), body.clone());
786 }
787 if (self.proxy.clone() != Value::Null) {
789 append_to_array(&mut usedProxies, Value::Str("proxy".into()));
790 if is_function(&self.proxy) {
791 proxyUrl = self.proxy_fn(url, method, headers, body);
792 } else {
793 proxyUrl = self.proxy.clone();
794 }
795 }
796 let mut length: f64 = ((usedProxies.len() as i64) as f64);
797 if length > ((1i64) as f64) {
798 let mut joinedProxyNames: Value = join(&usedProxies, &Value::Str(",".into()));
799 panic!("{}", crate::exchange_errors::invalid_proxy_settings(format!("{}{}", Value::Str(format!("{}{}", Value::Str(format!("{}{}", self.id.clone(), Value::Str(" you have multiple conflicting proxy settings (".into())).into()), joinedProxyNames).into()), Value::Str("), please use only one from : proxyUrl, proxy_url, proxyUrlCallback, proxy_url_callback".into()))));
800 }
801 return proxyUrl;
802
803 Value::Null
804}
805
806 fn url_encoder_for_proxy_url(&self, mut targetUrl: Value) -> Value {
807 let mut includesQuery: bool = Value::Int(targetUrl.as_str().and_then(|__s| __s.find("?")).map(|__i| __i as i64).unwrap_or(-1)).as_f64().unwrap_or(f64::NAN) >= ((0i64) as f64);
809 let mut finalUrl: Value = (if includesQuery { self.encode_uri_component(targetUrl.clone()) } else { targetUrl });
810 return finalUrl;
811
812 Value::Null
813}
814
815 fn check_proxy_settings(&self, optional_args: &[Value]) -> Value {
816 let mut url = get_arg(optional_args, 0, Value::Null);
817 let mut method = get_arg(optional_args, 1, Value::Null);
818 let mut headers = get_arg(optional_args, 2, Value::Null);
819 let mut body = get_arg(optional_args, 3, Value::Null);
820 let mut usedProxies: Value = Value::from(vec![]);
821 let mut httpProxy: Value = Value::Null;
822 let mut httpsProxy: Value = Value::Null;
823 let mut socksProxy: Value = Value::Null;
824 let mut isHttpProxyDefined: Value = self.value_is_defined(self.httpProxy.clone());
826 let mut isHttp_proxy_defined: Value = self.value_is_defined(self.http_proxy.clone());
827 if is_true(&isHttpProxyDefined) || is_true(&isHttp_proxy_defined) {
828 append_to_array(&mut usedProxies, Value::Str("httpProxy".into()));
829 httpProxy = (if is_true(&isHttpProxyDefined) { self.httpProxy.clone() } else { self.http_proxy.clone() });
830 }
831 let mut ishttpProxyCallbackDefined: Value = self.value_is_defined(self.httpProxyCallback.clone());
832 let mut ishttp_proxy_callback_defined: Value = self.value_is_defined(self.http_proxy_callback.clone());
833 if is_true(&ishttpProxyCallbackDefined) || is_true(&ishttp_proxy_callback_defined) {
834 append_to_array(&mut usedProxies, Value::Str("httpProxyCallback".into()));
835 httpProxy = (if is_true(&ishttpProxyCallbackDefined) { self.http_proxy_callback_fn(url.clone(), method.clone(), headers.clone(), body.clone()) } else { self.http_proxy_callback_fn(url.clone(), method.clone(), headers.clone(), body.clone()) });
836 }
837 let mut isHttpsProxyDefined: Value = self.value_is_defined(self.httpsProxy.clone());
839 let mut isHttps_proxy_defined: Value = self.value_is_defined(self.https_proxy.clone());
840 if is_true(&isHttpsProxyDefined) || is_true(&isHttps_proxy_defined) {
841 append_to_array(&mut usedProxies, Value::Str("httpsProxy".into()));
842 httpsProxy = (if is_true(&isHttpsProxyDefined) { self.httpsProxy.clone() } else { self.https_proxy.clone() });
843 }
844 let mut ishttpsProxyCallbackDefined: Value = self.value_is_defined(self.httpsProxyCallback.clone());
845 let mut ishttps_proxy_callback_defined: Value = self.value_is_defined(self.https_proxy_callback.clone());
846 if is_true(&ishttpsProxyCallbackDefined) || is_true(&ishttps_proxy_callback_defined) {
847 append_to_array(&mut usedProxies, Value::Str("httpsProxyCallback".into()));
848 httpsProxy = (if is_true(&ishttpsProxyCallbackDefined) { self.https_proxy_callback_fn(url.clone(), method.clone(), headers.clone(), body.clone()) } else { self.https_proxy_callback_fn(url.clone(), method.clone(), headers.clone(), body.clone()) });
849 }
850 let mut isSocksProxyDefined: Value = self.value_is_defined(self.socksProxy.clone());
852 let mut isSocks_proxy_defined: Value = self.value_is_defined(self.socks_proxy.clone());
853 if is_true(&isSocksProxyDefined) || is_true(&isSocks_proxy_defined) {
854 append_to_array(&mut usedProxies, Value::Str("socksProxy".into()));
855 socksProxy = (if is_true(&isSocksProxyDefined) { self.socksProxy.clone() } else { self.socks_proxy.clone() });
856 }
857 let mut issocksProxyCallbackDefined: Value = self.value_is_defined(self.socksProxyCallback.clone());
858 let mut issocks_proxy_callback_defined: Value = self.value_is_defined(self.socks_proxy_callback.clone());
859 if is_true(&issocksProxyCallbackDefined) || is_true(&issocks_proxy_callback_defined) {
860 append_to_array(&mut usedProxies, Value::Str("socksProxyCallback".into()));
861 socksProxy = (if is_true(&issocksProxyCallbackDefined) { self.socks_proxy_callback_fn(url.clone(), method.clone(), headers.clone(), body.clone()) } else { self.socks_proxy_callback_fn(url, method, headers, body) });
862 }
863 let mut length: f64 = ((usedProxies.len() as i64) as f64);
865 if length > ((1i64) as f64) {
866 let mut joinedProxyNames: Value = join(&usedProxies, &Value::Str(",".into()));
867 panic!("{}", crate::exchange_errors::invalid_proxy_settings(format!("{}{}", Value::Str(format!("{}{}", Value::Str(format!("{}{}", self.id.clone(), Value::Str(" you have multiple conflicting proxy settings (".into())).into()), joinedProxyNames).into()), Value::Str("), please use only one from: httpProxy, httpsProxy, httpProxyCallback, httpsProxyCallback, socksProxy, socksProxyCallback".into()))));
868 }
869 return Value::from(vec![httpProxy, httpsProxy, socksProxy]);
870
871 Value::Null
872}
873
874 fn check_ws_proxy_settings(&self) -> Value {
875 let mut usedProxies: Value = Value::from(vec![]);
876 let mut wsProxy: Value = Value::Null;
877 let mut wssProxy: Value = Value::Null;
878 let mut wsSocksProxy: Value = Value::Null;
879 let mut isWsProxyDefined: Value = self.value_is_defined(self.wsProxy.clone());
881 let mut is_ws_proxy_defined: Value = self.value_is_defined(self.ws_proxy.clone());
882 if is_true(&isWsProxyDefined) || is_true(&is_ws_proxy_defined) {
883 append_to_array(&mut usedProxies, Value::Str("wsProxy".into()));
884 wsProxy = (if is_true(&(isWsProxyDefined)) { self.wsProxy.clone() } else { self.ws_proxy.clone() });
885 }
886 let mut isWssProxyDefined: Value = self.value_is_defined(self.wssProxy.clone());
888 let mut is_wss_proxy_defined: Value = self.value_is_defined(self.wss_proxy.clone());
889 if is_true(&isWssProxyDefined) || is_true(&is_wss_proxy_defined) {
890 append_to_array(&mut usedProxies, Value::Str("wssProxy".into()));
891 wssProxy = (if is_true(&(isWssProxyDefined)) { self.wssProxy.clone() } else { self.wss_proxy.clone() });
892 }
893 let mut isWsSocksProxyDefined: Value = self.value_is_defined(self.wsSocksProxy.clone());
895 let mut is_ws_socks_proxy_defined: Value = self.value_is_defined(self.ws_socks_proxy.clone());
896 if is_true(&isWsSocksProxyDefined) || is_true(&is_ws_socks_proxy_defined) {
897 append_to_array(&mut usedProxies, Value::Str("wsSocksProxy".into()));
898 wsSocksProxy = (if is_true(&(isWsSocksProxyDefined)) { self.wsSocksProxy.clone() } else { self.ws_socks_proxy.clone() });
899 }
900 let mut length: f64 = ((usedProxies.len() as i64) as f64);
902 if length > ((1i64) as f64) {
903 let mut joinedProxyNames: Value = join(&usedProxies, &Value::Str(",".into()));
904 panic!("{}", crate::exchange_errors::invalid_proxy_settings(format!("{}{}", Value::Str(format!("{}{}", Value::Str(format!("{}{}", self.id.clone(), Value::Str(" you have multiple conflicting proxy settings (".into())).into()), joinedProxyNames).into()), Value::Str("), please use only one from: wsProxy, wssProxy, wsSocksProxy".into()))));
905 }
906 return Value::from(vec![wsProxy, wssProxy, wsSocksProxy]);
907
908 Value::Null
909}
910
911 fn check_conflicting_proxies(&self, mut proxyAgentSet: Value, mut proxyUrlSet: Value) {
912 let mut proxyAgentIsSet: bool = (proxyAgentSet != Value::Null) && (proxyAgentSet != Value::Null) && (proxyAgentSet.as_str() != Some(""));
913 let mut proxyUrlIsSet: bool = (proxyUrlSet != Value::Null) && (proxyUrlSet != Value::Null) && (proxyUrlSet.as_str() != Some(""));
914 if proxyAgentIsSet && proxyUrlIsSet {
915 panic!("{}", crate::exchange_errors::invalid_proxy_settings(format!("{}{}", self.id.clone(), Value::Str(" you have multiple conflicting proxy settings, please use only one from : proxyUrl, httpProxy, httpsProxy, socksProxy".into()))));
916 }
917}
918
919 fn check_address(&self, optional_args: &[Value]) -> Value {
920 let mut address = get_arg(optional_args, 0, Value::Null);
921 if (address == Value::Null) {
922 panic!("{}", crate::exchange_errors::invalid_address(format!("{}{}", self.id.clone(), Value::Str(" address is undefined".into()))));
923 }
924 let mut uniqChars: Value = (self.unique(self.string_to_chars_array(address.clone())));
926 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) || Value::Int(address.as_str().and_then(|__s| __s.find(" ")).map(|__i| __i as i64).unwrap_or(-1)).as_f64().unwrap_or(f64::NAN) > ((-1i64) as f64) {
928 panic!("{}", crate::exchange_errors::invalid_address(format!("{}{}", Value::Str(format!("{}{}", Value::Str(format!("{}{}", Value::Str(format!("{}{}", Value::Str(format!("{}{}", self.id.clone(), Value::Str(" address is invalid or has less than ".into())).into()), to_string_val(&self.minFundingAddressLength)).into()), Value::Str(" characters: \"".into())).into()), to_string_val(&address)).into()), Value::Str("\"".into()))));
929 }
930 return address;
931
932 Value::Null
933}
934
935 fn find_message_hashes(&self, mut client: Value, mut element: Value) -> Value {
936 let mut result: Value = Value::from(vec![]);
937 let mut messageHashes: Value = object_keys(&get_value(&client, &Value::Str("futures".into())));
938 {
939 let mut i: Value = Value::Int(0);
940 let mut __for_first_76: bool = true;
941 while { if !__for_first_76 { i = (match (&(i), &(Value::Int(1))) { (Value::Int(x), Value::Int(y)) => Value::Int(x + y), (Value::Int(x), Value::Float(y)) => Value::Float(*x as f64 + *y), (Value::Float(x), Value::Int(y)) => Value::Float(*x + *y as f64), (Value::Float(x), Value::Float(y)) => Value::Float(x + y), _ => Value::Null }); } __for_first_76 = false; i.as_f64().unwrap_or(f64::NAN) < ((messageHashes.len() as i64) as f64) } {
942 let mut messageHash: Value = messageHashes.as_array().and_then(|__arr| match &i { Value::Int(__n) => __arr.get(*__n as usize), Value::Str(__s) => __s.parse::<usize>().ok().and_then(|__n| __arr.get(__n)), _ => None }).cloned().unwrap_or(Value::Null);
943 if get_index_of(&messageHash, &element).as_f64().unwrap_or(f64::NAN) >= ((0i64) as f64) {
944 append_to_array(&mut result, messageHash.clone());
945 }
946 }
947 }
948 return result;
949
950 Value::Null
951}
952
953 fn filter_by_limit(&self, mut array: Value, optional_args: &[Value]) -> Value {
954 let mut limit = get_arg(optional_args, 0, Value::Null);
955 let mut key = get_arg(optional_args, 1, Value::Str("timestamp".into()));
956 let mut fromStart = get_arg(optional_args, 2, Value::Bool(false));
957 if self.value_is_defined(limit.clone()).as_bool() == Some(true) {
958 let mut arrayLength: Value = Value::Int(array.len() as i64);
959 if arrayLength.as_f64().unwrap_or(f64::NAN) > ((0i64) as f64) {
960 let mut ascending: bool = true;
961 if (in_op(&array.as_array().and_then(|__arr| __arr.get(0)).cloned().unwrap_or(Value::Null), &key)) {
962 let mut first: Value = get_value(&array.as_array().and_then(|__arr| __arr.get(0)).cloned().unwrap_or(Value::Null), &key);
963 let mut last: Value = get_value(&get_value(&array, &(match (&(arrayLength), &(Value::Int(1))) { (Value::Int(x), Value::Int(y)) => Value::Int(x - y), (Value::Int(x), Value::Float(y)) => Value::Float(*x as f64 - *y), (Value::Float(x), Value::Int(y)) => Value::Float(*x - *y as f64), (Value::Float(x), Value::Float(y)) => Value::Float(x - y), _ => Value::Null })), &key);
964 if (first != Value::Null) && (last != Value::Null) {
965 ascending = is_less_than_or_equal(&first, &last); }
967 }
968 if is_true(&fromStart) {
969 let mut limitResolved: Value = (if (limit.as_f64().unwrap_or(f64::NAN) > arrayLength.as_f64().unwrap_or(f64::NAN)) { arrayLength } else { limit.clone() });
970 if ascending {
971 return self.array_slice(array.clone(), Value::Int(0), &[limitResolved.clone()]);
972 }
973 return self.array_slice(array.clone(), negate(&limitResolved), &[]);
974 }
975 if ascending {
976 return self.array_slice(array.clone(), negate(&limit), &[]);
977 }
978 return self.array_slice(array.clone(), Value::Int(0), &[limit]);
979 }
980 }
981 return array;
982
983 Value::Null
984}
985
986 fn filter_by_since_limit(&self, mut array: Value, optional_args: &[Value]) -> Value {
987 let mut since = get_arg(optional_args, 0, Value::Null);
988 let mut limit = get_arg(optional_args, 1, Value::Null);
989 let mut key = get_arg(optional_args, 2, Value::Str("timestamp".into()));
990 let mut tail = get_arg(optional_args, 3, Value::Bool(false));
991 if (array == Value::Null) {
992 return Value::from(vec![]);
993 }
994 let mut sinceIsDefined: Value = self.value_is_defined(since.clone());
995 let mut parsedArray: Value = self.to_array(array);
996 let mut result: Value = parsedArray.clone();
997 if is_true(&sinceIsDefined) {
998 result = Value::from(vec![]);
999 {
1000 let mut i: Value = Value::Int(0);
1001 let mut __for_first_77: bool = true;
1002 while { if !__for_first_77 { i = (match (&(i), &(Value::Int(1))) { (Value::Int(x), Value::Int(y)) => Value::Int(x + y), (Value::Int(x), Value::Float(y)) => Value::Float(*x as f64 + *y), (Value::Float(x), Value::Int(y)) => Value::Float(*x + *y as f64), (Value::Float(x), Value::Float(y)) => Value::Float(x + y), _ => Value::Null }); } __for_first_77 = false; i.as_f64().unwrap_or(f64::NAN) < get_array_length(&parsedArray).as_f64().unwrap_or(f64::NAN) } {
1003 let mut entry: Value = get_value(&parsedArray, &i);
1004 let mut entry: Value = get_value(&parsedArray, &i);
1005 let mut value: Value = self.safe_value(entry.clone(), key.clone(), &[]);
1006 if (value != Value::Null) && (value != Value::Null) && (!is_equal(&value, &Value::Int(0))) && (is_greater_than_or_equal(&value, &since)) {
1007 append_to_array(&mut result, entry);
1008 }
1009 }
1010 }
1011 }
1012 if is_true(&tail) && (limit != Value::Null) {
1013 return self.array_slice(result.clone(), negate(&limit), &[]);
1014 }
1015 let mut shouldFilterFromStart: Value = Value::Bool(!is_true(&tail) && is_true(&sinceIsDefined));
1018 return self.filter_by_limit(result, &[limit, key, shouldFilterFromStart]);
1019
1020 Value::Null
1021}
1022
1023 fn filter_by_value_since_limit(&self, mut array: Value, mut field: Value, optional_args: &[Value]) -> Value {
1024 let mut value = get_arg(optional_args, 0, Value::Null);
1025 let mut since = get_arg(optional_args, 1, Value::Null);
1026 let mut limit = get_arg(optional_args, 2, Value::Null);
1027 let mut key = get_arg(optional_args, 3, Value::Str("timestamp".into()));
1028 let mut tail = get_arg(optional_args, 4, Value::Bool(false));
1029 let mut valueIsDefined: Value = self.value_is_defined(value.clone());
1030 let mut sinceIsDefined: Value = self.value_is_defined(since.clone());
1031 let mut parsedArray: Value = self.to_array(array);
1032 let mut result: Value = parsedArray.clone();
1033 if is_true(&valueIsDefined) || is_true(&sinceIsDefined) {
1035 result = Value::from(vec![]);
1036 {
1037 let mut i: Value = Value::Int(0);
1038 let mut __for_first_78: bool = true;
1039 while { if !__for_first_78 { i = (match (&(i), &(Value::Int(1))) { (Value::Int(x), Value::Int(y)) => Value::Int(x + y), (Value::Int(x), Value::Float(y)) => Value::Float(*x as f64 + *y), (Value::Float(x), Value::Int(y)) => Value::Float(*x + *y as f64), (Value::Float(x), Value::Float(y)) => Value::Float(x + y), _ => Value::Null }); } __for_first_78 = false; i.as_f64().unwrap_or(f64::NAN) < get_array_length(&parsedArray).as_f64().unwrap_or(f64::NAN) } {
1040 let mut entry: Value = get_value(&parsedArray, &i);
1041 let mut entry: Value = get_value(&parsedArray, &i);
1042 let mut entryFiledEqualValue: Value = Value::Bool(is_equal(&self.safe_value(entry.clone(), field.clone(), &[]), &value));
1045 let mut firstCondition: Value = (if is_true(&valueIsDefined) { entryFiledEqualValue } else { Value::Bool(true) });
1046 let mut entryKeyValue: Value = self.safe_value(entry.clone(), key.clone(), &[]);
1047 let mut entryKeyGESince: Value = Value::Bool((entryKeyValue != Value::Null) && (entryKeyValue != Value::Null) && (!is_equal(&entryKeyValue, &Value::Int(0))) && (since != Value::Null) && (is_greater_than_or_equal(&entryKeyValue, &since)));
1048 let mut secondCondition: Value = (if is_true(&sinceIsDefined) { entryKeyGESince } else { Value::Bool(true) });
1049 if is_true(&firstCondition) && is_true(&secondCondition) {
1050 append_to_array(&mut result, entry);
1051 }
1052 }
1053 }
1054 }
1055 if is_true(&tail) && (limit != Value::Null) {
1056 return self.array_slice(result.clone(), negate(&limit), &[]);
1057 }
1058 return self.filter_by_limit(result, &[limit, key, sinceIsDefined]);
1059
1060 Value::Null
1061}
1062
1063fn set_sandbox_mode(&mut self, mut enabled: Value) {
1070 if is_true(&enabled) {
1071 if (matches!(&self.urls, Value::Dict(__d) if __d.contains_key("test"))) {
1072 if matches!(&self.urls.as_map().and_then(|__m| __m.get("api")).cloned().unwrap_or(Value::Null), Value::Str(_)) {
1073 { let __be_tmp = crate::value::get_value_k(&self.urls, "api"); add_element_to_object(&mut self.urls, &Value::Str("apiBackup".into()), __be_tmp); };
1074 { let __be_tmp = crate::value::get_value_k(&self.urls, "test"); add_element_to_object(&mut self.urls, &Value::Str("api".into()), __be_tmp); };
1075 } else {
1076 { let __be_tmp = self.clone_value(crate::value::get_value_k(&self.urls, "api")); add_element_to_object(&mut self.urls, &Value::Str("apiBackup".into()), __be_tmp); };
1077 { let __be_tmp = self.clone_value(crate::value::get_value_k(&self.urls, "test")); add_element_to_object(&mut self.urls, &Value::Str("api".into()), __be_tmp); };
1078 }
1079 } else {
1080 panic!("{}", crate::exchange_errors::not_supported(format!("{}{}", self.id.clone(), Value::Str(" does not have a sandbox URL".into()))));
1081 }
1082 self.isSandboxModeEnabled = Value::Bool(true);
1084 } else if (matches!(&self.urls, Value::Dict(__d) if __d.contains_key("apiBackup"))) {
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, "apiBackup"); add_element_to_object(&mut self.urls, &Value::Str("api".into()), __be_tmp); };
1087 } else {
1088 { let __be_tmp = self.clone_value(crate::value::get_value_k(&self.urls, "apiBackup")); add_element_to_object(&mut self.urls, &Value::Str("api".into()), __be_tmp); };
1089 }
1090 let mut newUrls: Value = self.omit(self.urls.clone(), Value::Str("apiBackup".into()), &[]);
1091 self.urls = newUrls;
1092 self.isSandboxModeEnabled = Value::Bool(false);
1094 }
1095}
1096
1097fn enable_demo_trading(&mut self, mut enable: Value) {
1104 if is_true(&self.isSandboxModeEnabled) {
1105 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()))));
1106 }
1107 if is_true(&enable) {
1108 { let __be_tmp = crate::value::get_value_k(&self.urls, "api"); add_element_to_object(&mut self.urls, &Value::Str("apiBackupDemoTrading".into()), __be_tmp); };
1109 { let __be_tmp = crate::value::get_value_k(&self.urls, "demo"); add_element_to_object(&mut self.urls, &Value::Str("api".into()), __be_tmp); };
1110 } else if (matches!(&self.urls, Value::Dict(__d) if __d.contains_key("apiBackupDemoTrading"))) {
1111 { let __be_tmp = crate::value::get_value_k(&self.urls, "apiBackupDemoTrading"); add_element_to_object(&mut self.urls, &Value::Str("api".into()), __be_tmp); };
1112 let mut newUrls: Value = self.omit(self.urls.clone(), Value::Str("apiBackupDemoTrading".into()), &[]);
1113 self.urls = newUrls;
1114 }
1115 if let Value::Dict(__d) = &mut self.options { std::sync::Arc::make_mut(__d).insert("enableDemoTrading".into(), enable); }
1116}
1117
1118 fn sign(&self, mut path: Value, optional_args: &[Value]) -> Value {
1119 { let __v = crate::exchange::DerivedExchange::sign(self, path, crate::runtime::get_arg(optional_args, 0, crate::Value::Null), crate::runtime::get_arg(optional_args, 1, crate::Value::Null), crate::runtime::get_arg(optional_args, 2, crate::Value::Null), crate::runtime::get_arg(optional_args, 3, crate::Value::Null), crate::runtime::get_arg(optional_args, 4, crate::Value::Null)); if !matches!(__v, crate::Value::Null) { return __v; } }
1121
1122 let mut api = get_arg(optional_args, 0, Value::Str("public".into()));
1123 let mut method = get_arg(optional_args, 1, Value::Str("GET".into()));
1124 let mut params = get_arg(optional_args, 2, Value::Map({
1125 let mut m = indexmap::IndexMap::new();
1126 m
1127}));
1128 let mut headers = get_arg(optional_args, 3, Value::Null);
1129 let mut body = get_arg(optional_args, 4, Value::Null);
1130 return Value::Map({
1131 let mut m = indexmap::IndexMap::new();
1132 m.insert("url".to_string(), Value::Null);
1133 m.insert("method".to_string(), Value::Null);
1134 m.insert("headers".to_string(), Value::Null);
1135 m.insert("body".to_string(), Value::Null);
1136 m
1137});
1138
1139 Value::Null
1140}
1141
1142 fn fetch_accounts(&mut self, optional_args: &[Value]) -> impl ::std::future::Future<Output = Value> + Send { async move {
1143 let mut params = get_arg(optional_args, 0, Value::Map({
1144 let mut m = indexmap::IndexMap::new();
1145 m
1146}));
1147 panic!("{}", crate::exchange_errors::not_supported(format!("{}{}", self.id.clone(), Value::Str(" fetchAccounts() is not supported yet".into()))));
1148
1149 Value::Null
1150} }
1151
1152 fn watch_liquidations(&mut self, mut symbol: Value, optional_args: &[Value]) -> impl ::std::future::Future<Output = Value> + Send { async move {
1153 let mut since = get_arg(optional_args, 0, Value::Null);
1154 let mut limit = get_arg(optional_args, 1, Value::Null);
1155 let mut params = get_arg(optional_args, 2, Value::Map({
1156 let mut m = indexmap::IndexMap::new();
1157 m
1158}));
1159 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)) {
1160 return self.watch_liquidations_for_symbols(Value::from(vec![symbol]), &[since, limit, params]).await;
1161 }
1162 panic!("{}", crate::exchange_errors::not_supported(format!("{}{}", self.id.clone(), Value::Str(" watchLiquidations() is not supported yet".into()))));
1163
1164 Value::Null
1165} }
1166
1167 fn watch_liquidations_for_symbols(&mut self, mut symbols: Value, optional_args: &[Value]) -> impl ::std::future::Future<Output = Value> + Send { async move {
1168 let mut since = get_arg(optional_args, 0, Value::Null);
1169 let mut limit = get_arg(optional_args, 1, Value::Null);
1170 let mut params = get_arg(optional_args, 2, Value::Map({
1171 let mut m = indexmap::IndexMap::new();
1172 m
1173}));
1174 panic!("{}", crate::exchange_errors::not_supported(format!("{}{}", self.id.clone(), Value::Str(" watchLiquidationsForSymbols() is not supported yet".into()))));
1175
1176 Value::Null
1177} }
1178
1179 fn watch_my_liquidations(&mut self, mut symbol: 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 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)) {
1187 return self.watch_my_liquidations_for_symbols(Value::from(vec![symbol]), &[since, limit, params]).await;
1188 }
1189 panic!("{}", crate::exchange_errors::not_supported(format!("{}{}", self.id.clone(), Value::Str(" watchMyLiquidations() is not supported yet".into()))));
1190
1191 Value::Null
1192} }
1193
1194 fn watch_my_liquidations_for_symbols(&mut self, mut symbols: Value, optional_args: &[Value]) -> impl ::std::future::Future<Output = Value> + Send { async move {
1195 let mut since = get_arg(optional_args, 0, Value::Null);
1196 let mut limit = get_arg(optional_args, 1, Value::Null);
1197 let mut params = get_arg(optional_args, 2, Value::Map({
1198 let mut m = indexmap::IndexMap::new();
1199 m
1200}));
1201 panic!("{}", crate::exchange_errors::not_supported(format!("{}{}", self.id.clone(), Value::Str(" watchMyLiquidationsForSymbols() is not supported yet".into()))));
1202
1203 Value::Null
1204} }
1205
1206 fn un_watch_orders(&mut self, optional_args: &[Value]) -> impl ::std::future::Future<Output = Value> + Send { async move {
1207 let mut symbol = get_arg(optional_args, 0, Value::Null);
1208 let mut params = get_arg(optional_args, 1, Value::Map({
1209 let mut m = indexmap::IndexMap::new();
1210 m
1211}));
1212 panic!("{}", crate::exchange_errors::not_supported(format!("{}{}", self.id.clone(), Value::Str(" unWatchOrders() is not supported yet".into()))));
1213
1214 Value::Null
1215} }
1216
1217 fn un_watch_trades(&mut self, mut symbol: Value, optional_args: &[Value]) -> impl ::std::future::Future<Output = Value> + Send { async move {
1218 let mut params = get_arg(optional_args, 0, Value::Map({
1219 let mut m = indexmap::IndexMap::new();
1220 m
1221}));
1222 panic!("{}", crate::exchange_errors::not_supported(format!("{}{}", self.id.clone(), Value::Str(" unWatchTrades() is not supported yet".into()))));
1223
1224 Value::Null
1225} }
1226
1227 fn un_watch_trades_for_symbols(&mut self, mut symbols: Value, optional_args: &[Value]) -> impl ::std::future::Future<Output = Value> + Send { async move {
1228 let mut params = get_arg(optional_args, 0, Value::Map({
1229 let mut m = indexmap::IndexMap::new();
1230 m
1231}));
1232 panic!("{}", crate::exchange_errors::not_supported(format!("{}{}", self.id.clone(), Value::Str(" unWatchTradesForSymbols() is not supported yet".into()))));
1233
1234 Value::Null
1235} }
1236
1237 fn watch_ohlcv_for_symbols(&mut self, mut symbolsAndTimeframes: Value, optional_args: &[Value]) -> impl ::std::future::Future<Output = Value> + Send { async move {
1238 let mut since = get_arg(optional_args, 0, Value::Null);
1239 let mut limit = get_arg(optional_args, 1, Value::Null);
1240 let mut params = get_arg(optional_args, 2, 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(" watchOHLCVForSymbols() is not supported yet".into()))));
1245
1246 Value::Null
1247} }
1248
1249 fn un_watch_ohlcv_for_symbols(&mut self, mut symbolsAndTimeframes: Value, optional_args: &[Value]) -> impl ::std::future::Future<Output = Value> + Send { async move {
1250 let mut params = get_arg(optional_args, 0, Value::Map({
1251 let mut m = indexmap::IndexMap::new();
1252 m
1253}));
1254 panic!("{}", crate::exchange_errors::not_supported(format!("{}{}", self.id.clone(), Value::Str(" unWatchOHLCVForSymbols() is not supported yet".into()))));
1255
1256 Value::Null
1257} }
1258
1259 fn un_watch_order_book_for_symbols(&mut self, mut symbols: Value, optional_args: &[Value]) -> impl ::std::future::Future<Output = Value> + Send { async move {
1260 let mut params = get_arg(optional_args, 0, Value::Map({
1261 let mut m = indexmap::IndexMap::new();
1262 m
1263}));
1264 panic!("{}", crate::exchange_errors::not_supported(format!("{}{}", self.id.clone(), Value::Str(" unWatchOrderBookForSymbols() is not supported yet".into()))));
1265
1266 Value::Null
1267} }
1268
1269 fn un_watch_positions(&mut self, optional_args: &[Value]) -> impl ::std::future::Future<Output = Value> + Send { async move {
1270 let mut symbols = get_arg(optional_args, 0, Value::Null);
1271 let mut params = get_arg(optional_args, 1, Value::Map({
1272 let mut m = indexmap::IndexMap::new();
1273 m
1274}));
1275 panic!("{}", crate::exchange_errors::not_supported(format!("{}{}", self.id.clone(), Value::Str(" unWatchPositions() is not supported yet".into()))));
1276
1277 Value::Null
1278} }
1279
1280 fn un_watch_ticker(&mut self, mut symbol: Value, optional_args: &[Value]) -> impl ::std::future::Future<Output = Value> + Send { async move {
1281 let mut params = get_arg(optional_args, 0, Value::Map({
1282 let mut m = indexmap::IndexMap::new();
1283 m
1284}));
1285 panic!("{}", crate::exchange_errors::not_supported(format!("{}{}", self.id.clone(), Value::Str(" unWatchTicker() is not supported yet".into()))));
1286
1287 Value::Null
1288} }
1289
1290 fn un_watch_mark_price(&mut self, mut symbol: Value, optional_args: &[Value]) -> impl ::std::future::Future<Output = Value> + Send { async move {
1291 let mut params = get_arg(optional_args, 0, Value::Map({
1292 let mut m = indexmap::IndexMap::new();
1293 m
1294}));
1295 panic!("{}", crate::exchange_errors::not_supported(format!("{}{}", self.id.clone(), Value::Str(" unWatchMarkPrice() is not supported yet".into()))));
1296
1297 Value::Null
1298} }
1299
1300 fn un_watch_mark_prices(&mut self, optional_args: &[Value]) -> impl ::std::future::Future<Output = Value> + Send { async move {
1301 let mut symbols = get_arg(optional_args, 0, Value::Null);
1302 let mut params = get_arg(optional_args, 1, Value::Map({
1303 let mut m = indexmap::IndexMap::new();
1304 m
1305}));
1306 panic!("{}", crate::exchange_errors::not_supported(format!("{}{}", self.id.clone(), Value::Str(" unWatchMarkPrices() is not supported yet".into()))));
1307
1308 Value::Null
1309} }
1310
1311 fn fetch_deposit_addresses(&mut self, optional_args: &[Value]) -> impl ::std::future::Future<Output = Value> + Send { async move {
1312 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 {
1314 if !matches!(__v, crate::Value::Null) { return __v; }
1315 }
1316
1317 let mut codes = get_arg(optional_args, 0, Value::Null);
1318 let mut params = get_arg(optional_args, 1, Value::Map({
1319 let mut m = indexmap::IndexMap::new();
1320 m
1321}));
1322 panic!("{}", crate::exchange_errors::not_supported(format!("{}{}", self.id.clone(), Value::Str(" fetchDepositAddresses() is not supported yet".into()))));
1323
1324 Value::Null
1325} }
1326
1327 fn fetch_margin_mode(&mut self, mut symbol: Value, optional_args: &[Value]) -> impl ::std::future::Future<Output = Value> + Send { async move {
1328 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 {
1330 if !matches!(__v, crate::Value::Null) { return __v; }
1331 }
1332
1333 let mut params = get_arg(optional_args, 0, Value::Map({
1334 let mut m = indexmap::IndexMap::new();
1335 m
1336}));
1337 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)) {
1338 let mut marginModes: Value = self.fetch_margin_modes(&[Value::from(vec![symbol.clone()]), params]).await;
1339 let mut marginMode: Value = self.safe_dict(marginModes, symbol, &[]);
1340 return marginMode;
1341 } else {
1342 panic!("{}", crate::exchange_errors::not_supported(format!("{}{}", self.id.clone(), Value::Str(" fetchMarginMode() is not supported yet".into()))));
1343 }
1344
1345 Value::Null
1346} }
1347
1348 fn fetch_margin_modes(&mut self, optional_args: &[Value]) -> impl ::std::future::Future<Output = Value> + Send { async move {
1349 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 {
1351 if !matches!(__v, crate::Value::Null) { return __v; }
1352 }
1353
1354 let mut symbols = get_arg(optional_args, 0, Value::Null);
1355 let mut params = get_arg(optional_args, 1, Value::Map({
1356 let mut m = indexmap::IndexMap::new();
1357 m
1358}));
1359 panic!("{}", crate::exchange_errors::not_supported(format!("{}{}", self.id.clone(), Value::Str(" fetchMarginModes () is not supported yet".into()))));
1360
1361 Value::Null
1362} }
1363
1364 fn un_watch_order_book(&mut self, mut symbol: Value, optional_args: &[Value]) -> impl ::std::future::Future<Output = Value> + Send { async move {
1365 let mut params = get_arg(optional_args, 0, Value::Map({
1366 let mut m = indexmap::IndexMap::new();
1367 m
1368}));
1369 panic!("{}", crate::exchange_errors::not_supported(format!("{}{}", self.id.clone(), Value::Str(" unWatchOrderBook() is not supported yet".into()))));
1370
1371 Value::Null
1372} }
1373
1374 fn fetch_time(&mut self, optional_args: &[Value]) -> impl ::std::future::Future<Output = Value> + Send { async move {
1375 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 {
1377 if !matches!(__v, crate::Value::Null) { return __v; }
1378 }
1379
1380 let mut params = get_arg(optional_args, 0, Value::Map({
1381 let mut m = indexmap::IndexMap::new();
1382 m
1383}));
1384 panic!("{}", crate::exchange_errors::not_supported(format!("{}{}", self.id.clone(), Value::Str(" fetchTime() is not supported yet".into()))));
1385
1386 Value::Null
1387} }
1388
1389 fn fetch_trading_limits(&mut self, optional_args: &[Value]) -> impl ::std::future::Future<Output = Value> + Send { async move {
1390 let mut symbols = get_arg(optional_args, 0, Value::Null);
1391 let mut params = get_arg(optional_args, 1, Value::Map({
1392 let mut m = indexmap::IndexMap::new();
1393 m
1394}));
1395 panic!("{}", crate::exchange_errors::not_supported(format!("{}{}", self.id.clone(), Value::Str(" fetchTradingLimits() is not supported yet".into()))));
1396
1397 Value::Null
1398} }
1399
1400 fn parse_currency(&self, mut rawCurrency: Value) -> Value {
1401 { let __v = crate::exchange::DerivedExchange::parse_currency(self, rawCurrency); if !matches!(__v, crate::Value::Null) { return __v; } }
1403
1404 panic!("{}", crate::exchange_errors::not_supported(format!("{}{}", self.id.clone(), Value::Str(" parseCurrency() is not supported yet".into()))));
1405
1406 Value::Null
1407}
1408
1409 fn parse_currencies(&self, mut rawCurrencies: Value) -> Value {
1410 let mut result: Value = Value::Map({
1411 let mut m = indexmap::IndexMap::new();
1412 m
1413 });
1414 let mut arr: Value = self.to_array(rawCurrencies);
1415 {
1416 let mut i: Value = Value::Int(0);
1417 let mut __for_first_79: bool = true;
1418 while { if !__for_first_79 { i = (match (&(i), &(Value::Int(1))) { (Value::Int(x), Value::Int(y)) => Value::Int(x + y), (Value::Int(x), Value::Float(y)) => Value::Float(*x as f64 + *y), (Value::Float(x), Value::Int(y)) => Value::Float(*x + *y as f64), (Value::Float(x), Value::Float(y)) => Value::Float(x + y), _ => Value::Null }); } __for_first_79 = false; i.as_f64().unwrap_or(f64::NAN) < ((arr.len() as i64) as f64) } {
1419 let mut parsed: Value = <Self as crate::exchange_generated::ExchangeBase>::parse_currency(self, arr.as_array().and_then(|__arr| match &i { Value::Int(__n) => __arr.get(*__n as usize), Value::Str(__s) => __s.parse::<usize>().ok().and_then(|__n| __arr.get(__n)), _ => None }).cloned().unwrap_or(Value::Null));
1420 if (parsed == Value::Null) {
1421 continue;
1422 }
1423 let mut code: Value = parsed.as_map().and_then(|__m| __m.get("code")).cloned().unwrap_or(Value::Null);
1424 if let Value::Dict(__d) = &mut result { std::sync::Arc::make_mut(__d).insert(crate::runtime::stringify_param(&code), parsed); }
1425 }
1426 }
1427 return result;
1428
1429 Value::Null
1430}
1431
1432 fn parse_market(&self, mut market: Value) -> Value {
1433 { let __v = crate::exchange::DerivedExchange::parse_market(self, market); if !matches!(__v, crate::Value::Null) { return __v; } }
1435
1436 panic!("{}", crate::exchange_errors::not_supported(format!("{}{}", self.id.clone(), Value::Str(" parseMarket() is not supported yet".into()))));
1437
1438 Value::Null
1439}
1440
1441 fn parse_markets(&self, mut markets: Value) -> Value {
1442 let mut result: Value = Value::from(vec![]);
1443 {
1444 let mut i: Value = Value::Int(0);
1445 let mut __for_first_80: bool = true;
1446 while { if !__for_first_80 { i = (match (&(i), &(Value::Int(1))) { (Value::Int(x), Value::Int(y)) => Value::Int(x + y), (Value::Int(x), Value::Float(y)) => Value::Float(*x as f64 + *y), (Value::Float(x), Value::Int(y)) => Value::Float(*x + *y as f64), (Value::Float(x), Value::Float(y)) => Value::Float(x + y), _ => Value::Null }); } __for_first_80 = false; i.as_f64().unwrap_or(f64::NAN) < get_array_length(&markets).as_f64().unwrap_or(f64::NAN) } {
1447 let mut market: Value = <Self as crate::exchange_generated::ExchangeBase>::parse_market(self, get_value(&markets, &i));
1448 if (market != Value::Null) {
1450 append_to_array(&mut result, market);
1451 }
1452 }
1453 }
1454 return result;
1455
1456 Value::Null
1457}
1458
1459 fn parse_ticker(&self, mut ticker: Value, optional_args: &[Value]) -> Value {
1460 { 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; } }
1462
1463 let mut market = get_arg(optional_args, 0, Value::Null);
1464 panic!("{}", crate::exchange_errors::not_supported(format!("{}{}", self.id.clone(), Value::Str(" parseTicker() is not supported yet".into()))));
1465
1466 Value::Null
1467}
1468
1469 fn parse_deposit_address(&self, mut depositAddress: Value, optional_args: &[Value]) -> Value {
1470 { 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; } }
1472
1473 let mut currency = get_arg(optional_args, 0, Value::Null);
1474 panic!("{}", crate::exchange_errors::not_supported(format!("{}{}", self.id.clone(), Value::Str(" parseDepositAddress() is not supported yet".into()))));
1475
1476 Value::Null
1477}
1478
1479 fn parse_trade(&self, mut trade: Value, optional_args: &[Value]) -> Value {
1480 { 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; } }
1482
1483 let mut market = get_arg(optional_args, 0, Value::Null);
1484 panic!("{}", crate::exchange_errors::not_supported(format!("{}{}", self.id.clone(), Value::Str(" parseTrade() is not supported yet".into()))));
1485
1486 Value::Null
1487}
1488
1489 fn parse_transaction(&self, mut transaction: Value, optional_args: &[Value]) -> Value {
1490 { 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; } }
1492
1493 let mut currency = get_arg(optional_args, 0, Value::Null);
1494 panic!("{}", crate::exchange_errors::not_supported(format!("{}{}", self.id.clone(), Value::Str(" parseTransaction() is not supported yet".into()))));
1495
1496 Value::Null
1497}
1498
1499 fn parse_transfer(&self, mut transfer: Value, optional_args: &[Value]) -> Value {
1500 { 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; } }
1502
1503 let mut currency = get_arg(optional_args, 0, Value::Null);
1504 if (transfer == Value::Null) {
1505 panic!("{}", crate::exchange_errors::not_supported(format!("{}{}", self.id.clone(), Value::Str(" parseTransfer() is not supported yet".into()))));
1506 }
1507 panic!("{}", crate::exchange_errors::not_supported(format!("{}{}", self.id.clone(), Value::Str(" parseTransfer() is not supported yet".into()))));
1508
1509 Value::Null
1510}
1511
1512 fn parse_account(&self, mut account: Value) -> Value {
1513 { let __v = crate::exchange::DerivedExchange::parse_account(self, account); if !matches!(__v, crate::Value::Null) { return __v; } }
1515
1516 panic!("{}", crate::exchange_errors::not_supported(format!("{}{}", self.id.clone(), Value::Str(" parseAccount() is not supported yet".into()))));
1517
1518 Value::Null
1519}
1520
1521 fn parse_ledger_entry(&self, mut item: Value, optional_args: &[Value]) -> Value {
1522 { 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; } }
1524
1525 let mut currency = get_arg(optional_args, 0, Value::Null);
1526 panic!("{}", crate::exchange_errors::not_supported(format!("{}{}", self.id.clone(), Value::Str(" parseLedgerEntry() is not supported yet".into()))));
1527
1528 Value::Null
1529}
1530
1531 fn parse_order(&self, mut order: Value, optional_args: &[Value]) -> Value {
1532 { 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; } }
1534
1535 let mut market = get_arg(optional_args, 0, Value::Null);
1536 panic!("{}", crate::exchange_errors::not_supported(format!("{}{}", self.id.clone(), Value::Str(" parseOrder() is not supported yet".into()))));
1537
1538 Value::Null
1539}
1540
1541 fn fetch_cross_borrow_rates(&mut self, optional_args: &[Value]) -> impl ::std::future::Future<Output = Value> + Send { async move {
1542 let mut params = get_arg(optional_args, 0, Value::Map({
1543 let mut m = indexmap::IndexMap::new();
1544 m
1545}));
1546 panic!("{}", crate::exchange_errors::not_supported(format!("{}{}", self.id.clone(), Value::Str(" fetchCrossBorrowRates() is not supported yet".into()))));
1547
1548 Value::Null
1549} }
1550
1551 fn fetch_isolated_borrow_rates(&mut self, optional_args: &[Value]) -> impl ::std::future::Future<Output = Value> + Send { async move {
1552 let mut params = get_arg(optional_args, 0, Value::Map({
1553 let mut m = indexmap::IndexMap::new();
1554 m
1555}));
1556 panic!("{}", crate::exchange_errors::not_supported(format!("{}{}", self.id.clone(), Value::Str(" fetchIsolatedBorrowRates() is not supported yet".into()))));
1557
1558 Value::Null
1559} }
1560
1561 fn parse_market_leverage_tiers(&self, mut info: Value, optional_args: &[Value]) -> Value {
1562 { 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; } }
1564
1565 let mut market = get_arg(optional_args, 0, Value::Null);
1566 panic!("{}", crate::exchange_errors::not_supported(format!("{}{}", self.id.clone(), Value::Str(" parseMarketLeverageTiers() is not supported yet".into()))));
1567
1568 Value::Null
1569}
1570
1571 fn fetch_leverage_tiers(&mut self, optional_args: &[Value]) -> impl ::std::future::Future<Output = Value> + Send { async move {
1572 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 {
1574 if !matches!(__v, crate::Value::Null) { return __v; }
1575 }
1576
1577 let mut symbols = get_arg(optional_args, 0, Value::Null);
1578 let mut params = get_arg(optional_args, 1, Value::Map({
1579 let mut m = indexmap::IndexMap::new();
1580 m
1581}));
1582 panic!("{}", crate::exchange_errors::not_supported(format!("{}{}", self.id.clone(), Value::Str(" fetchLeverageTiers() is not supported yet".into()))));
1583
1584 Value::Null
1585} }
1586
1587 fn parse_position(&self, mut position: Value, optional_args: &[Value]) -> Value {
1588 { 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; } }
1590
1591 let mut market = get_arg(optional_args, 0, Value::Null);
1592 panic!("{}", crate::exchange_errors::not_supported(format!("{}{}", self.id.clone(), Value::Str(" parsePosition() is not supported yet".into()))));
1593
1594 Value::Null
1595}
1596
1597 fn parse_funding_rate_history(&self, mut info: Value, optional_args: &[Value]) -> Value {
1598 { 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; } }
1600
1601 let mut market = get_arg(optional_args, 0, Value::Null);
1602 panic!("{}", crate::exchange_errors::not_supported(format!("{}{}", self.id.clone(), Value::Str(" parseFundingRateHistory() is not supported yet".into()))));
1603
1604 Value::Null
1605}
1606
1607 fn parse_borrow_interest(&self, mut info: Value, optional_args: &[Value]) -> Value {
1608 { 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; } }
1610
1611 let mut market = get_arg(optional_args, 0, Value::Null);
1612 panic!("{}", crate::exchange_errors::not_supported(format!("{}{}", self.id.clone(), Value::Str(" parseBorrowInterest() is not supported yet".into()))));
1613
1614 Value::Null
1615}
1616
1617 fn parse_isolated_borrow_rate(&self, mut info: Value, optional_args: &[Value]) -> Value {
1618 let mut market = get_arg(optional_args, 0, Value::Null);
1619 panic!("{}", crate::exchange_errors::not_supported(format!("{}{}", self.id.clone(), Value::Str(" parseIsolatedBorrowRate() is not supported yet".into()))));
1620
1621 Value::Null
1622}
1623
1624 fn parse_ws_trade(&self, mut trade: Value, optional_args: &[Value]) -> Value {
1625 let mut market = get_arg(optional_args, 0, Value::Null);
1626 panic!("{}", crate::exchange_errors::not_supported(format!("{}{}", self.id.clone(), Value::Str(" parseWsTrade() is not supported yet".into()))));
1627
1628 Value::Null
1629}
1630
1631 fn parse_ws_order(&self, mut order: Value, optional_args: &[Value]) -> Value {
1632 let mut market = get_arg(optional_args, 0, Value::Null);
1633 panic!("{}", crate::exchange_errors::not_supported(format!("{}{}", self.id.clone(), Value::Str(" parseWsOrder() is not supported yet".into()))));
1634
1635 Value::Null
1636}
1637
1638 fn parse_ws_order_trade(&self, mut trade: Value, optional_args: &[Value]) -> Value {
1639 let mut market = get_arg(optional_args, 0, Value::Null);
1640 panic!("{}", crate::exchange_errors::not_supported(format!("{}{}", self.id.clone(), Value::Str(" parseWsOrderTrade() is not supported yet".into()))));
1641
1642 Value::Null
1643}
1644
1645 fn parse_ws_ohlcv(&self, mut ohlcv: Value, optional_args: &[Value]) -> Value {
1646 let mut market = get_arg(optional_args, 0, Value::Null);
1647 return <Self as crate::exchange_generated::ExchangeBase>::parse_ohlcv(self, ohlcv, &[market]);
1648
1649 Value::Null
1650}
1651
1652 fn fetch_funding_rates(&mut self, optional_args: &[Value]) -> impl ::std::future::Future<Output = Value> + Send { async move {
1653 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 {
1655 if !matches!(__v, crate::Value::Null) { return __v; }
1656 }
1657
1658 let mut symbols = get_arg(optional_args, 0, Value::Null);
1659 let mut params = get_arg(optional_args, 1, Value::Map({
1660 let mut m = indexmap::IndexMap::new();
1661 m
1662}));
1663 panic!("{}", crate::exchange_errors::not_supported(format!("{}{}", self.id.clone(), Value::Str(" fetchFundingRates() is not supported yet".into()))));
1664
1665 Value::Null
1666} }
1667
1668 fn fetch_funding_intervals(&mut self, optional_args: &[Value]) -> impl ::std::future::Future<Output = Value> + Send { async move {
1669 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 {
1671 if !matches!(__v, crate::Value::Null) { return __v; }
1672 }
1673
1674 let mut symbols = get_arg(optional_args, 0, Value::Null);
1675 let mut params = get_arg(optional_args, 1, Value::Map({
1676 let mut m = indexmap::IndexMap::new();
1677 m
1678}));
1679 panic!("{}", crate::exchange_errors::not_supported(format!("{}{}", self.id.clone(), Value::Str(" fetchFundingIntervals() is not supported yet".into()))));
1680
1681 Value::Null
1682} }
1683
1684 fn watch_funding_rate(&mut self, mut symbol: Value, optional_args: &[Value]) -> impl ::std::future::Future<Output = Value> + Send { async move {
1685 let mut params = get_arg(optional_args, 0, Value::Map({
1686 let mut m = indexmap::IndexMap::new();
1687 m
1688}));
1689 panic!("{}", crate::exchange_errors::not_supported(format!("{}{}", self.id.clone(), Value::Str(" watchFundingRate() is not supported yet".into()))));
1690
1691 Value::Null
1692} }
1693
1694 fn watch_funding_rates(&mut self, optional_args: &[Value]) -> impl ::std::future::Future<Output = Value> + Send { async move {
1695 let mut symbols = get_arg(optional_args, 0, Value::Null);
1696 let mut params = get_arg(optional_args, 1, Value::Map({
1697 let mut m = indexmap::IndexMap::new();
1698 m
1699}));
1700 panic!("{}", crate::exchange_errors::not_supported(format!("{}{}", self.id.clone(), Value::Str(" watchFundingRates() is not supported yet".into()))));
1701
1702 Value::Null
1703} }
1704
1705 fn un_watch_funding_rates(&mut self, optional_args: &[Value]) -> impl ::std::future::Future<Output = Value> + Send { async move {
1706 let mut symbols = get_arg(optional_args, 0, Value::Null);
1707 let mut params = get_arg(optional_args, 1, Value::Map({
1708 let mut m = indexmap::IndexMap::new();
1709 m
1710}));
1711 panic!("{}", crate::exchange_errors::not_supported(format!("{}{}", self.id.clone(), Value::Str(" unWatchFundingRates() is not supported yet".into()))));
1712
1713 Value::Null
1714} }
1715
1716 fn watch_funding_rates_for_symbols(&mut self, mut symbols: Value, optional_args: &[Value]) -> impl ::std::future::Future<Output = Value> + Send { async move {
1717 let mut params = get_arg(optional_args, 0, Value::Map({
1718 let mut m = indexmap::IndexMap::new();
1719 m
1720}));
1721 return self.watch_funding_rates(&[symbols, params]).await;
1722
1723 Value::Null
1724} }
1725
1726 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 {
1727 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 {
1729 if !matches!(__v, crate::Value::Null) { return __v; }
1730 }
1731
1732 let mut params = get_arg(optional_args, 0, Value::Map({
1733 let mut m = indexmap::IndexMap::new();
1734 m
1735}));
1736 panic!("{}", crate::exchange_errors::not_supported(format!("{}{}", self.id.clone(), Value::Str(" transfer() is not supported yet".into()))));
1737
1738 Value::Null
1739} }
1740
1741 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 {
1742 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 {
1744 if !matches!(__v, crate::Value::Null) { return __v; }
1745 }
1746
1747 let mut tag = get_arg(optional_args, 0, Value::Null);
1748 let mut params = get_arg(optional_args, 1, Value::Map({
1749 let mut m = indexmap::IndexMap::new();
1750 m
1751}));
1752 panic!("{}", crate::exchange_errors::not_supported(format!("{}{}", self.id.clone(), Value::Str(" withdraw() is not supported yet".into()))));
1753
1754 Value::Null
1755} }
1756
1757 fn create_deposit_address(&mut self, mut code: Value, optional_args: &[Value]) -> impl ::std::future::Future<Output = Value> + Send { async move {
1758 let mut params = get_arg(optional_args, 0, Value::Map({
1759 let mut m = indexmap::IndexMap::new();
1760 m
1761}));
1762 panic!("{}", crate::exchange_errors::not_supported(format!("{}{}", self.id.clone(), Value::Str(" createDepositAddress() is not supported yet".into()))));
1763
1764 Value::Null
1765} }
1766
1767 fn set_leverage(&mut self, mut leverage: Value, optional_args: &[Value]) -> impl ::std::future::Future<Output = Value> + Send { async move {
1768 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 {
1770 if !matches!(__v, crate::Value::Null) { return __v; }
1771 }
1772
1773 let mut symbol = get_arg(optional_args, 0, Value::Null);
1774 let mut params = get_arg(optional_args, 1, Value::Map({
1775 let mut m = indexmap::IndexMap::new();
1776 m
1777}));
1778 panic!("{}", crate::exchange_errors::not_supported(format!("{}{}", self.id.clone(), Value::Str(" setLeverage() is not supported yet".into()))));
1779
1780 Value::Null
1781} }
1782
1783 fn fetch_leverage(&mut self, mut symbol: Value, optional_args: &[Value]) -> impl ::std::future::Future<Output = Value> + Send { async move {
1784 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 {
1786 if !matches!(__v, crate::Value::Null) { return __v; }
1787 }
1788
1789 let mut params = get_arg(optional_args, 0, Value::Map({
1790 let mut m = indexmap::IndexMap::new();
1791 m
1792}));
1793 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)) {
1794 let mut leverages: Value = self.fetch_leverages(&[Value::from(vec![symbol.clone()]), params]).await;
1795 let mut leverage: Value = self.safe_dict(leverages, symbol, &[]);
1796 return leverage;
1797 } else {
1798 panic!("{}", crate::exchange_errors::not_supported(format!("{}{}", self.id.clone(), Value::Str(" fetchLeverage() is not supported yet".into()))));
1799 }
1800
1801 Value::Null
1802} }
1803
1804 fn fetch_leverages(&mut self, optional_args: &[Value]) -> impl ::std::future::Future<Output = Value> + Send { async move {
1805 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 {
1807 if !matches!(__v, crate::Value::Null) { return __v; }
1808 }
1809
1810 let mut symbols = get_arg(optional_args, 0, Value::Null);
1811 let mut params = get_arg(optional_args, 1, Value::Map({
1812 let mut m = indexmap::IndexMap::new();
1813 m
1814}));
1815 panic!("{}", crate::exchange_errors::not_supported(format!("{}{}", self.id.clone(), Value::Str(" fetchLeverages() is not supported yet".into()))));
1816
1817 Value::Null
1818} }
1819
1820 fn set_position_mode(&mut self, mut hedged: Value, optional_args: &[Value]) -> impl ::std::future::Future<Output = Value> + Send { async move {
1821 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 {
1823 if !matches!(__v, crate::Value::Null) { return __v; }
1824 }
1825
1826 let mut symbol = get_arg(optional_args, 0, Value::Null);
1827 let mut params = get_arg(optional_args, 1, Value::Map({
1828 let mut m = indexmap::IndexMap::new();
1829 m
1830}));
1831 panic!("{}", crate::exchange_errors::not_supported(format!("{}{}", self.id.clone(), Value::Str(" setPositionMode() is not supported yet".into()))));
1832
1833 Value::Null
1834} }
1835
1836 fn add_margin(&mut self, mut symbol: Value, mut amount: Value, optional_args: &[Value]) -> impl ::std::future::Future<Output = Value> + Send { async move {
1837 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 {
1839 if !matches!(__v, crate::Value::Null) { return __v; }
1840 }
1841
1842 let mut params = get_arg(optional_args, 0, Value::Map({
1843 let mut m = indexmap::IndexMap::new();
1844 m
1845}));
1846 panic!("{}", crate::exchange_errors::not_supported(format!("{}{}", self.id.clone(), Value::Str(" addMargin() is not supported yet".into()))));
1847
1848 Value::Null
1849} }
1850
1851 fn reduce_margin(&mut self, mut symbol: Value, mut amount: Value, optional_args: &[Value]) -> impl ::std::future::Future<Output = Value> + Send { async move {
1852 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 {
1854 if !matches!(__v, crate::Value::Null) { return __v; }
1855 }
1856
1857 let mut params = get_arg(optional_args, 0, Value::Map({
1858 let mut m = indexmap::IndexMap::new();
1859 m
1860}));
1861 panic!("{}", crate::exchange_errors::not_supported(format!("{}{}", self.id.clone(), Value::Str(" reduceMargin() is not supported yet".into()))));
1862
1863 Value::Null
1864} }
1865
1866 fn set_margin(&mut self, mut symbol: Value, mut amount: Value, optional_args: &[Value]) -> impl ::std::future::Future<Output = Value> + Send { async move {
1867 let mut params = get_arg(optional_args, 0, Value::Map({
1868 let mut m = indexmap::IndexMap::new();
1869 m
1870}));
1871 panic!("{}", crate::exchange_errors::not_supported(format!("{}{}", self.id.clone(), Value::Str(" setMargin() is not supported yet".into()))));
1872
1873 Value::Null
1874} }
1875
1876 fn fetch_long_short_ratio(&mut self, mut symbol: Value, optional_args: &[Value]) -> impl ::std::future::Future<Output = Value> + Send { async move {
1877 let mut timeframe = get_arg(optional_args, 0, Value::Null);
1878 let mut params = get_arg(optional_args, 1, 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(" fetchLongShortRatio() is not supported yet".into()))));
1883
1884 Value::Null
1885} }
1886
1887 fn fetch_long_short_ratio_history(&mut self, optional_args: &[Value]) -> impl ::std::future::Future<Output = Value> + Send { async move {
1888 let mut symbol = get_arg(optional_args, 0, Value::Null);
1889 let mut timeframe = get_arg(optional_args, 1, Value::Null);
1890 let mut since = get_arg(optional_args, 2, Value::Null);
1891 let mut limit = get_arg(optional_args, 3, Value::Null);
1892 let mut params = get_arg(optional_args, 4, Value::Map({
1893 let mut m = indexmap::IndexMap::new();
1894 m
1895}));
1896 panic!("{}", crate::exchange_errors::not_supported(format!("{}{}", self.id.clone(), Value::Str(" fetchLongShortRatioHistory() is not supported yet".into()))));
1897
1898 Value::Null
1899} }
1900
1901 fn fetch_margin_adjustment_history(&mut self, optional_args: &[Value]) -> impl ::std::future::Future<Output = Value> + Send { async move {
1902 let mut symbol = get_arg(optional_args, 0, Value::Null);
1903 let mut type_var = get_arg(optional_args, 1, Value::Null);
1904 let mut since = get_arg(optional_args, 2, Value::Null);
1905 let mut limit = get_arg(optional_args, 3, Value::Null);
1906 let mut params = get_arg(optional_args, 4, Value::Map({
1907 let mut m = indexmap::IndexMap::new();
1908 m
1909}));
1910 panic!("{}", crate::exchange_errors::not_supported(format!("{}{}", self.id.clone(), Value::Str(" fetchMarginAdjustmentHistory() is not supported yet".into()))));
1911
1912 Value::Null
1913} }
1914
1915 fn set_margin_mode(&mut self, mut marginMode: Value, optional_args: &[Value]) -> impl ::std::future::Future<Output = Value> + Send { async move {
1916 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 {
1918 if !matches!(__v, crate::Value::Null) { return __v; }
1919 }
1920
1921 let mut symbol = get_arg(optional_args, 0, Value::Null);
1922 let mut params = get_arg(optional_args, 1, Value::Map({
1923 let mut m = indexmap::IndexMap::new();
1924 m
1925}));
1926 panic!("{}", crate::exchange_errors::not_supported(format!("{}{}", self.id.clone(), Value::Str(" setMarginMode() is not supported yet".into()))));
1927
1928 Value::Null
1929} }
1930
1931 fn fetch_deposit_addresses_by_network(&mut self, mut code: Value, optional_args: &[Value]) -> impl ::std::future::Future<Output = Value> + Send { async move {
1932 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 {
1934 if !matches!(__v, crate::Value::Null) { return __v; }
1935 }
1936
1937 let mut params = get_arg(optional_args, 0, Value::Map({
1938 let mut m = indexmap::IndexMap::new();
1939 m
1940}));
1941 panic!("{}", crate::exchange_errors::not_supported(format!("{}{}", self.id.clone(), Value::Str(" fetchDepositAddressesByNetwork() is not supported yet".into()))));
1942
1943 Value::Null
1944} }
1945
1946 fn fetch_open_interest_history(&mut self, mut symbol: Value, optional_args: &[Value]) -> impl ::std::future::Future<Output = Value> + Send { async move {
1947 let mut timeframe = get_arg(optional_args, 0, Value::Str("1h".into()));
1948 let mut since = get_arg(optional_args, 1, Value::Null);
1949 let mut limit = get_arg(optional_args, 2, Value::Null);
1950 let mut params = get_arg(optional_args, 3, Value::Map({
1951 let mut m = indexmap::IndexMap::new();
1952 m
1953}));
1954 panic!("{}", crate::exchange_errors::not_supported(format!("{}{}", self.id.clone(), Value::Str(" fetchOpenInterestHistory() is not supported yet".into()))));
1955
1956 Value::Null
1957} }
1958
1959 fn fetch_open_interests(&mut self, optional_args: &[Value]) -> impl ::std::future::Future<Output = Value> + Send { async move {
1960 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 {
1962 if !matches!(__v, crate::Value::Null) { return __v; }
1963 }
1964
1965 let mut symbols = get_arg(optional_args, 0, Value::Null);
1966 let mut params = get_arg(optional_args, 1, Value::Map({
1967 let mut m = indexmap::IndexMap::new();
1968 m
1969}));
1970 panic!("{}", crate::exchange_errors::not_supported(format!("{}{}", self.id.clone(), Value::Str(" fetchOpenInterests() is not supported yet".into()))));
1971
1972 Value::Null
1973} }
1974
1975 fn sign_in(&mut self, optional_args: &[Value]) -> impl ::std::future::Future<Output = Value> + Send { async move {
1976 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 {
1978 if !matches!(__v, crate::Value::Null) { return __v; }
1979 }
1980
1981 let mut params = get_arg(optional_args, 0, Value::Map({
1982 let mut m = indexmap::IndexMap::new();
1983 m
1984}));
1985 panic!("{}", crate::exchange_errors::not_supported(format!("{}{}", self.id.clone(), Value::Str(" signIn() is not supported yet".into()))));
1986
1987 Value::Null
1988} }
1989
1990 fn fetch_payment_methods(&mut self, optional_args: &[Value]) -> impl ::std::future::Future<Output = Value> + Send { async move {
1991 let mut params = get_arg(optional_args, 0, Value::Map({
1992 let mut m = indexmap::IndexMap::new();
1993 m
1994}));
1995 panic!("{}", crate::exchange_errors::not_supported(format!("{}{}", self.id.clone(), Value::Str(" fetchPaymentMethods() is not supported yet".into()))));
1996
1997 Value::Null
1998} }
1999
2000 fn parse_to_int(&self, mut number: Value) -> Value {
2001 let mut stringifiedNumber: Value = self.number_to_string(number);
2007 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 });
2008 return crate::runtime::parse_int(&convertedNumber);
2009
2010 Value::Null
2011}
2012
2013 fn parse_to_numeric(&self, mut number: Value) -> Value {
2014 let mut stringVersion: Value = self.number_to_string(number); if Value::Int(stringVersion.as_str().and_then(|__s| __s.find(".")).map(|__i| __i as i64).unwrap_or(-1)).as_f64().unwrap_or(f64::NAN) >= ((0i64) as f64) {
2020 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 });
2021 }
2022 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 });
2023
2024 Value::Null
2025}
2026
2027 fn is_round_number(&self, mut value: Value) -> Value {
2028 let mut res: Value = self.parse_to_numeric((mod_val(&value, &Value::Int(1))));
2031 return Value::Bool(res.as_f64() == Some(0.0));
2032
2033 Value::Null
2034}
2035
2036 fn is_empty_string(&self, mut value: Value) -> Value {
2037 return Value::Bool(!(self.value_is_defined(value.clone()).as_bool() == Some(true)) || (value.as_str() == Some("")));
2038
2039 Value::Null
2040}
2041
2042 fn safe_number_omit_zero(&self, mut obj: Value, mut key: Value, optional_args: &[Value]) -> Value {
2043 let mut defaultValue = get_arg(optional_args, 0, Value::Null);
2044 let mut value: Value = self.safe_string(obj, key, &[]);
2045 let mut final_val: Value = self.parse_number(self.omit_zero(value), &[]);
2046 return (if (final_val == Value::Null) { defaultValue } else { final_val });
2047
2048 Value::Null
2049}
2050
2051 fn safe_integer_omit_zero(&self, mut obj: Value, mut key: Value, optional_args: &[Value]) -> Value {
2052 let mut defaultValue = get_arg(optional_args, 0, Value::Null);
2053 let mut timestamp: Value = self.safe_integer(obj, key, &[defaultValue]);
2054 if (timestamp == Value::Null) || (timestamp.as_f64() == Some(0.0)) {
2055 return Value::Null;
2056 }
2057 return timestamp;
2058
2059 Value::Null
2060}
2061
2062 fn after_construct(&mut self) {
2063 self.create_networks_by_id_object();
2065 self.features_generator();
2066 if (self.markets.clone() != Value::Null) {
2068 self.set_markets(self.markets.clone(), &[]);
2069 }
2070 self.init_rest_rate_limiter();
2072 let mut isSandbox: Value = self.safe_bool2(self.options.clone(), Value::Str("sandbox".into()), Value::Str("testnet".into()), &[Value::Bool(false)]);
2074 if (isSandbox.as_bool() == Some(true)) {
2075 self.set_sandbox_mode(isSandbox);
2076 }
2077}
2078
2079 fn init_rest_rate_limiter(&mut self) {
2080 if (self.rateLimit.clone() == Value::Null) || ((self.id.clone() != Value::Null) && (self.rateLimit.as_f64() == Value::Int(-1).as_f64())) {
2081 panic!("{}", crate::exchange_errors::exchange_error(format!("{}{}", self.id.clone(), Value::Str(".rateLimit property is not configured".into()))));
2082 }
2083 let mut refillRate: Value = self.MAX_VALUE.clone();
2084 if self.rateLimit.as_f64().unwrap_or(f64::NAN) > ((0i64) as f64) {
2085 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 });
2086 }
2087 let mut useLeaky: bool = (self.rollingWindowSize.as_f64() == Some(0.0)) || (self.rateLimiterAlgorithm.as_str() == Some("leakyBucket"));
2088 let mut algorithm: Value = (if useLeaky { Value::Str("leakyBucket".into()) } else { Value::Str("rollingWindow".into()) });
2089 let mut defaultBucket: Value = Value::Map({
2090 let mut m = indexmap::IndexMap::new();
2091 m.insert("delay".to_string(), Value::Float(0.001));
2092 m.insert("capacity".to_string(), Value::Int(1));
2093 m.insert("cost".to_string(), Value::Int(1));
2094 m.insert("refillRate".to_string(), refillRate);
2095 m.insert("algorithm".to_string(), algorithm);
2096 m.insert("windowSize".to_string(), self.rollingWindowSize.clone());
2097 m.insert("rateLimit".to_string(), self.rateLimit.clone());
2098 m
2099 });
2100 let mut existingBucket: Value = (if (self.tokenBucket.clone() == Value::Null) { Value::Map({
2101 let mut m = indexmap::IndexMap::new();
2102 m
2103}) } else { self.tokenBucket.clone() });
2104 { let __t = self.extend(defaultBucket, &[existingBucket]); self.tokenBucket = __t; }
2105 self.init_throttler();
2106}
2107
2108 fn features_generator(&mut self) {
2109 if (self.features.clone() == Value::Null) {
2124 return;
2125 }
2126 let mut initialFeatures: Value = self.features.clone();
2128 self.features = Value::Map({
2129 let mut m = indexmap::IndexMap::new();
2130 m
2131 });
2132 let mut unifiedMarketTypes: Value = Value::from(vec![Value::Str("spot".into()), Value::Str("swap".into()), Value::Str("future".into()), Value::Str("option".into())]);
2133 let mut subTypes: Value = Value::from(vec![Value::Str("linear".into()), Value::Str("inverse".into())]);
2134 {
2135 let mut i: Value = Value::Int(0);
2136 let mut __for_first_82: bool = true;
2137 while { if !__for_first_82 { i = (match (&(i), &(Value::Int(1))) { (Value::Int(x), Value::Int(y)) => Value::Int(x + y), (Value::Int(x), Value::Float(y)) => Value::Float(*x as f64 + *y), (Value::Float(x), Value::Int(y)) => Value::Float(*x + *y as f64), (Value::Float(x), Value::Float(y)) => Value::Float(x + y), _ => Value::Null }); } __for_first_82 = false; i.as_f64().unwrap_or(f64::NAN) < ((unifiedMarketTypes.len() as i64) as f64) } {
2138 let mut marketType: Value = unifiedMarketTypes.as_array().and_then(|__arr| match &i { Value::Int(__n) => __arr.get(*__n as usize), Value::Str(__s) => __s.parse::<usize>().ok().and_then(|__n| __arr.get(__n)), _ => None }).cloned().unwrap_or(Value::Null);
2139 if !(in_op(&initialFeatures, &marketType)) {
2141 if let Value::Dict(__d) = &mut self.features { std::sync::Arc::make_mut(__d).insert(crate::runtime::stringify_param(&marketType), Value::Null); }
2142 } else {
2143 if (marketType.as_str() == Some("spot")) {
2144 { 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); } }
2145 } else {
2146 if let Value::Dict(__d) = &mut self.features { std::sync::Arc::make_mut(__d).insert(crate::runtime::stringify_param(&marketType), Value::Map({
2147 let mut m = indexmap::IndexMap::new();
2148 m
2149})); }
2150 {
2151 let mut j: Value = Value::Int(0);
2152 let mut __for_first_81: bool = true;
2153 while { if !__for_first_81 { j = (match (&(j), &(Value::Int(1))) { (Value::Int(x), Value::Int(y)) => Value::Int(x + y), (Value::Int(x), Value::Float(y)) => Value::Float(*x as f64 + *y), (Value::Float(x), Value::Int(y)) => Value::Float(*x + *y as f64), (Value::Float(x), Value::Float(y)) => Value::Float(x + y), _ => Value::Null }); } __for_first_81 = false; j.as_f64().unwrap_or(f64::NAN) < ((subTypes.len() as i64) as f64) } {
2154 let mut subType: Value = subTypes.as_array().and_then(|__arr| match &j { Value::Int(__n) => __arr.get(*__n as usize), Value::Str(__s) => __s.parse::<usize>().ok().and_then(|__n| __arr.get(__n)), _ => None }).cloned().unwrap_or(Value::Null);
2155 { 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); };
2156 }
2157 }
2158 }
2159 }
2160 }
2161 }
2162}
2163
2164 fn features_mapper(&mut self, mut initialFeatures: Value, mut marketType: Value, optional_args: &[Value]) -> Value {
2165 let mut subType = get_arg(optional_args, 0, Value::Null);
2166 let mut featuresObj: Value = (if (subType != Value::Null) { get_value(&initialFeatures.as_map().and_then(|__m| marketType.as_str().and_then(|__k| __m.get(__k))).cloned().unwrap_or(Value::Null), &subType) } else { initialFeatures.as_map().and_then(|__m| marketType.as_str().and_then(|__k| __m.get(__k))).cloned().unwrap_or(Value::Null) });
2167 if (featuresObj == Value::Null) {
2169 return Value::Null;
2170 }
2171 let mut extendsStr: Value = self.safe_string_k(featuresObj.clone(), "extends", &[]);
2172 if (extendsStr != Value::Null) {
2173 featuresObj = self.omit(featuresObj.clone(), Value::Str("extends".into()), &[]);
2174 let mut extendObj: Value = self.features_mapper(initialFeatures, extendsStr, &[]);
2175 featuresObj = self.deep_extend(extendObj, &[featuresObj.clone()]);
2176 }
2177 if (in_op(&featuresObj, &Value::Str("createOrder".into()))) {
2182 let mut value: Value = self.safe_dict_k(crate::value::get_value_k(&featuresObj, "createOrder"), "attachedStopLossTakeProfit", &[]);
2183 add_element_to_object(get_value_mut(&mut featuresObj, &Value::Str("createOrder".into())), &Value::Str("stopLoss".into()), value.clone());
2184 add_element_to_object(get_value_mut(&mut featuresObj, &Value::Str("createOrder".into())), &Value::Str("takeProfit".into()), value.clone());
2185 if (marketType.as_str() == Some("spot")) {
2186 add_element_to_object(get_value_mut(&mut featuresObj, &Value::Str("createOrder".into())), &Value::Str("hedged".into()), Value::Bool(false));
2188 if !(in_op(&crate::value::get_value_k(&featuresObj, "createOrder"), &Value::Str("leverage".into()))) {
2190 add_element_to_object(get_value_mut(&mut featuresObj, &Value::Str("createOrder".into())), &Value::Str("leverage".into()), Value::Bool(false));
2191 }
2192 }
2193 if (self.safe_bool(crate::value::get_value_k(&crate::value::get_value_k(&featuresObj, "createOrder"), "timeInForce"), Value::Str("GTC".into()), &[]) == Value::Null) {
2195 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));
2196 }
2197 }
2198 let mut keys: Value = object_keys(&featuresObj);
2200 {
2201 let mut i: Value = Value::Int(0);
2202 let mut __for_first_83: bool = true;
2203 while { if !__for_first_83 { i = (match (&(i), &(Value::Int(1))) { (Value::Int(x), Value::Int(y)) => Value::Int(x + y), (Value::Int(x), Value::Float(y)) => Value::Float(*x as f64 + *y), (Value::Float(x), Value::Int(y)) => Value::Float(*x + *y as f64), (Value::Float(x), Value::Float(y)) => Value::Float(x + y), _ => Value::Null }); } __for_first_83 = false; i.as_f64().unwrap_or(f64::NAN) < ((keys.len() as i64) as f64) } {
2204 let mut key: Value = keys.as_array().and_then(|__arr| match &i { Value::Int(__n) => __arr.get(*__n as usize), Value::Str(__s) => __s.parse::<usize>().ok().and_then(|__n| __arr.get(__n)), _ => None }).cloned().unwrap_or(Value::Null);
2205 let mut featureBlock: Value = get_value(&featuresObj, &key);
2206 let mut featureBlock: Value = get_value(&featuresObj, &key);
2207 if !(self.in_array(key.clone(), Value::from(vec![Value::Str("sandbox".into())])).as_bool() == Some(true)) && (featureBlock != Value::Null) {
2208 if !(in_op(&featureBlock, &Value::Str("symbolRequired".into()))) {
2210 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())])));
2211 }
2212 }
2213 }
2214 }
2215 return featuresObj;
2216
2217 Value::Null
2218}
2219
2220 fn feature_value(&self, mut symbol: Value, optional_args: &[Value]) -> Value {
2221 let mut methodName = get_arg(optional_args, 0, Value::Null);
2222 let mut paramName = get_arg(optional_args, 1, Value::Null);
2223 let mut defaultValue = get_arg(optional_args, 2, Value::Null);
2224 let mut market: Value = self.market(symbol.clone());
2235 return self.feature_value_by_type(market.as_map().and_then(|__m| __m.get("type")).cloned().unwrap_or(Value::Null), market.as_map().and_then(|__m| __m.get("subType")).cloned().unwrap_or(Value::Null), &[methodName, paramName, defaultValue]);
2236
2237 Value::Null
2238}
2239
2240 fn feature_value_by_type(&self, mut marketType: Value, mut subType: Value, optional_args: &[Value]) -> Value {
2241 let mut methodName = get_arg(optional_args, 0, Value::Null);
2242 let mut paramName = get_arg(optional_args, 1, Value::Null);
2243 let mut defaultValue = get_arg(optional_args, 2, Value::Null);
2244 if (self.features.clone() == Value::Null) {
2257 return defaultValue;
2258 }
2259 if (marketType == Value::Null) {
2260 return defaultValue;
2261 }
2262 if !(in_op(&self.features, &marketType)) {
2264 return defaultValue;
2265 }
2266 if (get_value(&self.features, &marketType) == Value::Null) {
2268 return defaultValue;
2269 }
2270 let mut methodsContainer: Value = get_value(&self.features, &marketType);
2271 if (subType == Value::Null) {
2272 if (marketType.as_str() != Some("spot")) {
2273 return defaultValue;
2274 }
2275 } else {
2276 if !(in_op(&get_value(&self.features, &marketType), &subType)) {
2277 return defaultValue;
2278 }
2279 if (get_value(&get_value(&self.features, &marketType), &subType) == Value::Null) {
2281 return defaultValue;
2282 }
2283 methodsContainer = get_value(&get_value(&self.features, &marketType), &subType);
2284 }
2285 if (methodName == Value::Null) {
2287 return (if (defaultValue != Value::Null) { defaultValue.clone() } else { methodsContainer.clone() });
2288 }
2289 if !(in_op(&methodsContainer, &methodName)) {
2290 return defaultValue;
2291 }
2292 let mut methodDict: Value = get_value(&methodsContainer, &methodName);
2293 let mut methodDict: Value = get_value(&methodsContainer, &methodName);
2294 if (methodDict == Value::Null) {
2295 return defaultValue;
2296 }
2297 if (paramName == Value::Null) {
2299 return (if (defaultValue != Value::Null) { defaultValue.clone() } else { methodDict.clone() });
2300 }
2301 let mut splited: Value = split(¶mName, &Value::Str(".".into())); let mut parentKey: Value = splited.as_array().and_then(|__arr| __arr.get(0)).cloned().unwrap_or(Value::Null);
2303 let mut subKey: Value = self.safe_string(splited, Value::Int(1), &[]);
2304 if !(in_op(&methodDict, &parentKey)) {
2305 return defaultValue;
2306 }
2307 let mut dictionary: Value = self.safe_dict(methodDict.clone(), parentKey.clone(), &[]);
2308 if (dictionary == Value::Null) {
2309 return get_value(&methodDict, &parentKey);
2310 } else {
2311 if (subKey == Value::Null) {
2313 return get_value(&methodDict, &parentKey);
2314 }
2315 if !(in_op(&get_value(&methodDict, &parentKey), &subKey)) {
2317 return defaultValue;
2318 }
2319 return get_value(&get_value(&methodDict, &parentKey), &subKey);
2320 }
2321
2322 Value::Null
2323}
2324
2325 fn orderbook_checksum_message(&self, mut symbol: Value) -> Value {
2326 if (symbol == Value::Null) {
2327 panic!("{}", crate::exchange_errors::arguments_required(format!("{}{}", self.id.clone(), Value::Str(" orderbookChecksumMessage() requires a symbol argument".into()))));
2328 }
2329 return Value::Str(format!("{}{}", Value::Str(format!("{}{}", symbol, Value::Str(" : ".into())).into()), Value::Str("orderbook data checksum validation failed. You can reconnect by calling watchOrderBook again or you can mute the error by setting exchange.options[\"watchOrderBook\"][\"checksum\"] = false".into())).into());
2330
2331 Value::Null
2332}
2333
2334 fn create_networks_by_id_object(&mut self) {
2335 let mut networkIdsToCodesGenerated: Value = self.invert_flat_string_dictionary(self.safe_value_k(self.options.clone(), "networks", &[Value::Map({
2337 let mut m = indexmap::IndexMap::new();
2338 m
2339 })])); { let __be_tmp = self.extend(networkIdsToCodesGenerated, &[self.safe_value_k(self.options.clone(), "networksById", &[Value::Map({
2341 let mut m = indexmap::IndexMap::new();
2342 m
2343})])]); if let Value::Dict(__d) = &mut self.options { std::sync::Arc::make_mut(__d).insert("networksById".into(), __be_tmp); } }; }
2345
2346 fn get_default_options(&self) -> Value {
2347 return Value::Map({
2348 let mut m = indexmap::IndexMap::new();
2349 m.insert("defaultNetworkCodeReplacements".to_string(), Value::Map({
2350 let mut m = indexmap::IndexMap::new();
2351 m.insert("ETH".to_string(), Value::Map({
2352 let mut m = indexmap::IndexMap::new();
2353 m.insert("primary".to_string(), Value::Str("ETH".into()));
2354 m.insert("secondary".to_string(), Value::Str("ERC20".into()));
2355 m.insert("default".to_string(), Value::Str("secondary".into()));
2356 m
2357}));
2358 m.insert("CRO".to_string(), Value::Map({
2359 let mut m = indexmap::IndexMap::new();
2360 m.insert("primary".to_string(), Value::Str("CRONOS".into()));
2361 m.insert("secondary".to_string(), Value::Str("CRC20".into()));
2362 m.insert("default".to_string(), Value::Str("secondary".into()));
2363 m
2364}));
2365 m.insert("TRX".to_string(), Value::Map({
2366 let mut m = indexmap::IndexMap::new();
2367 m.insert("primary".to_string(), Value::Str("TRX".into()));
2368 m.insert("secondary".to_string(), Value::Str("TRC20".into()));
2369 m.insert("default".to_string(), Value::Str("secondary".into()));
2370 m
2371}));
2372 m.insert("BTC".to_string(), Value::Map({
2373 let mut m = indexmap::IndexMap::new();
2374 m.insert("primary".to_string(), Value::Str("BTC".into()));
2375 m.insert("secondary".to_string(), Value::Str("BRC20".into()));
2376 m.insert("default".to_string(), Value::Str("primary".into()));
2377 m
2378}));
2379 m
2380}));
2381 m.insert("backwardSupportedNetworkCodes".to_string(), Value::Map({
2382 let mut m = indexmap::IndexMap::new();
2383 m.insert("ARB".to_string(), Value::Str("ARBITRUM".into()));
2384 m.insert("ARBONE".to_string(), Value::Str("ARBITRUM".into()));
2385 m.insert("ARBNOVA".to_string(), Value::Str("ARBITRUM_NOVA".into()));
2386 m
2387}));
2388 m
2389});
2390
2391 Value::Null
2392}
2393
2394 fn safe_ledger_entry(&self, mut entry: Value, optional_args: &[Value]) -> Value {
2395 let mut currency = get_arg(optional_args, 0, Value::Null);
2396 let mut currencyResolved: Value = self.safe_currency(Value::Null, &[currency]);
2397 let mut direction: Value = self.safe_string_k(entry.clone(), "direction", &[]);
2398 let mut before: Value = self.safe_string_k(entry.clone(), "before", &[]);
2399 let mut after: Value = self.safe_string_k(entry.clone(), "after", &[]);
2400 let mut amount: Value = self.safe_string_k(entry.clone(), "amount", &[]);
2401 if (amount != Value::Null) {
2402 if (before == Value::Null) && (after != Value::Null) {
2403 before = crate::precise::Precise::stringSub(&after, &amount);
2404 } else if (before != Value::Null) && (after == Value::Null) {
2405 after = crate::precise::Precise::stringAdd(&before, &amount);
2406 }
2407 }
2408 if (before != Value::Null) && (after != Value::Null) {
2409 if (direction == Value::Null) {
2410 if is_true(&crate::precise::Precise::stringGt(&before, &after)) {
2411 direction = Value::Str("out".into());
2412 }
2413 if is_true(&crate::precise::Precise::stringGt(&after, &before)) {
2414 direction = Value::Str("in".into());
2415 }
2416 }
2417 }
2418 let mut fee: Value = self.safe_value_k(entry.clone(), "fee", &[]);
2419 if (fee != Value::Null) {
2420 { let __be_tmp = self.safe_number_k(fee.clone(), "cost", &[]); add_element_to_object(&mut fee, &Value::Str("cost".into()), __be_tmp); };
2421 }
2422 let mut timestamp: Value = self.safe_integer_k(entry.clone(), "timestamp", &[]);
2423 let mut info: Value = self.safe_dict_k(entry.clone(), "info", &[Value::Map({
2424 let mut m = indexmap::IndexMap::new();
2425 m
2426})]);
2427 return Value::Map({
2428 let mut m = indexmap::IndexMap::new();
2429 m.insert("id".to_string(), self.safe_string_k(entry.clone(), "id", &[]));
2430 m.insert("timestamp".to_string(), timestamp.clone());
2431 m.insert("datetime".to_string(), self.iso8601(timestamp));
2432 m.insert("direction".to_string(), direction);
2433 m.insert("account".to_string(), self.safe_string_k(entry.clone(), "account", &[]));
2434 m.insert("referenceId".to_string(), self.safe_string_k(entry.clone(), "referenceId", &[]));
2435 m.insert("referenceAccount".to_string(), self.safe_string_k(entry.clone(), "referenceAccount", &[]));
2436 m.insert("type".to_string(), self.safe_string_k(entry.clone(), "type", &[]));
2437 m.insert("currency".to_string(), currencyResolved.as_map().and_then(|__m| __m.get("code")).cloned().unwrap_or(Value::Null));
2438 m.insert("amount".to_string(), self.parse_number(amount, &[]));
2439 m.insert("before".to_string(), self.parse_number(before, &[]));
2440 m.insert("after".to_string(), self.parse_number(after, &[]));
2441 m.insert("status".to_string(), self.safe_string_k(entry, "status", &[]));
2442 m.insert("fee".to_string(), fee);
2443 m.insert("info".to_string(), info);
2444 m
2445});
2446
2447 Value::Null
2448}
2449
2450 fn safe_currency_structure(&self, mut currency: Value) -> Value {
2451 let mut networks: Value = self.safe_dict_k(currency.clone(), "networks", &[Value::Map({
2453 let mut m = indexmap::IndexMap::new();
2454 m
2455})]);
2456 let mut keys: Value = object_keys(&networks);
2457 let mut length: f64 = ((keys.len() as i64) as f64);
2458 if (length != 0.0) {
2459 {
2460 let mut i: Value = Value::Int(0);
2461 let mut __for_first_84: bool = true;
2462 while { if !__for_first_84 { i = (match (&(i), &(Value::Int(1))) { (Value::Int(x), Value::Int(y)) => Value::Int(x + y), (Value::Int(x), Value::Float(y)) => Value::Float(*x as f64 + *y), (Value::Float(x), Value::Int(y)) => Value::Float(*x + *y as f64), (Value::Float(x), Value::Float(y)) => Value::Float(x + y), _ => Value::Null }); } __for_first_84 = false; i.as_f64().unwrap_or(f64::NAN) < length } {
2463 let mut key: Value = keys.as_array().and_then(|__arr| match &i { Value::Int(__n) => __arr.get(*__n as usize), Value::Str(__s) => __s.parse::<usize>().ok().and_then(|__n| __arr.get(__n)), _ => None }).cloned().unwrap_or(Value::Null);
2464 let mut network: Value = networks.as_map().and_then(|__m| key.as_str().and_then(|__k| __m.get(__k))).cloned().unwrap_or(Value::Null);
2465 let mut deposit: Value = self.safe_bool_k(network.clone(), "deposit", &[]);
2466 let mut currencyDeposit: Value = self.safe_bool_k(currency.clone(), "deposit", &[]);
2467 if (currencyDeposit == Value::Null) || (deposit.as_bool() == Some(true)) {
2468 if let Value::Dict(__d) = &mut currency { std::sync::Arc::make_mut(__d).insert("deposit".into(), deposit); }
2469 }
2470 let mut withdraw: Value = self.safe_bool_k(network.clone(), "withdraw", &[]);
2471 let mut currencyWithdraw: Value = self.safe_bool_k(currency.clone(), "withdraw", &[]);
2472 if (currencyWithdraw == Value::Null) || (withdraw.as_bool() == Some(true)) {
2473 if let Value::Dict(__d) = &mut currency { std::sync::Arc::make_mut(__d).insert("withdraw".into(), withdraw); }
2474 }
2475 let mut fee: Value = self.safe_string_k(network.clone(), "fee", &[]);
2477 let mut feeMain: Value = self.safe_string_k(currency.clone(), "fee", &[]);
2478 if (feeMain == Value::Null) || is_true(&crate::precise::Precise::stringLt(&fee, &feeMain)) {
2479 if let Value::Dict(__d) = &mut currency { std::sync::Arc::make_mut(__d).insert("fee".into(), self.parse_number(fee.clone(), &[])); }
2480 }
2481 let mut precision: Value = self.safe_string_k(network.clone(), "precision", &[]);
2483 let mut precisionMain: Value = self.safe_string_k(currency.clone(), "precision", &[]);
2484 if (precisionMain == Value::Null) || is_true(&crate::precise::Precise::stringGt(&precision, &precisionMain)) {
2485 if let Value::Dict(__d) = &mut currency { std::sync::Arc::make_mut(__d).insert("precision".into(), self.parse_number(precision.clone(), &[])); }
2486 }
2487 let mut limits: Value = self.safe_dict_k(network, "limits", &[]);
2489 let mut limitsMain: Value = self.safe_dict_k(currency.clone(), "limits", &[]);
2490 if (limitsMain == Value::Null) {
2491 if let Value::Dict(__d) = &mut currency { std::sync::Arc::make_mut(__d).insert("limits".into(), Value::Map({
2492 let mut m = indexmap::IndexMap::new();
2493 m
2494})); }
2495 }
2496 let mut limitsDeposit: Value = self.safe_dict_k(limits.clone(), "deposit", &[]);
2498 let mut limitsDepositMain: Value = self.safe_dict_k(limitsMain.clone(), "deposit", &[]);
2499 if (limitsDepositMain == Value::Null) {
2500 add_element_to_object(get_value_mut(&mut currency, &Value::Str("limits".into())), &Value::Str("deposit".into()), Value::Map({
2501 let mut m = indexmap::IndexMap::new();
2502 m
2503}));
2504 }
2505 let mut limitsDepositMin: Value = self.safe_string_k(limitsDeposit.clone(), "min", &[]);
2506 let mut limitsDepositMax: Value = self.safe_string_k(limitsDeposit, "max", &[]);
2507 let mut limitsDepositMinMain: Value = self.safe_string_k(limitsDepositMain.clone(), "min", &[]);
2508 let mut limitsDepositMaxMain: Value = self.safe_string_k(limitsDepositMain, "max", &[]);
2509 if (limitsDepositMinMain == Value::Null) || is_true(&crate::precise::Precise::stringLt(&limitsDepositMin, &limitsDepositMinMain)) {
2511 add_element_to_object(get_value_mut(get_value_mut(&mut currency, &Value::Str("limits".into())), &Value::Str("deposit".into())), &Value::Str("min".into()), self.parse_number(limitsDepositMin, &[]));
2512 }
2513 if (limitsDepositMaxMain == Value::Null) || is_true(&crate::precise::Precise::stringGt(&limitsDepositMax, &limitsDepositMaxMain)) {
2515 add_element_to_object(get_value_mut(get_value_mut(&mut currency, &Value::Str("limits".into())), &Value::Str("deposit".into())), &Value::Str("max".into()), self.parse_number(limitsDepositMax, &[]));
2516 }
2517 let mut limitsWithdraw: Value = self.safe_dict_k(limits, "withdraw", &[]);
2519 let mut limitsWithdrawMain: Value = self.safe_dict_k(limitsMain, "withdraw", &[]);
2520 if (limitsWithdrawMain == Value::Null) {
2521 add_element_to_object(get_value_mut(&mut currency, &Value::Str("limits".into())), &Value::Str("withdraw".into()), Value::Map({
2522 let mut m = indexmap::IndexMap::new();
2523 m
2524}));
2525 }
2526 let mut limitsWithdrawMin: Value = self.safe_string_k(limitsWithdraw.clone(), "min", &[]);
2527 let mut limitsWithdrawMax: Value = self.safe_string_k(limitsWithdraw, "max", &[]);
2528 let mut limitsWithdrawMinMain: Value = self.safe_string_k(limitsWithdrawMain.clone(), "min", &[]);
2529 let mut limitsWithdrawMaxMain: Value = self.safe_string_k(limitsWithdrawMain, "max", &[]);
2530 if (limitsWithdrawMinMain == Value::Null) || is_true(&crate::precise::Precise::stringLt(&limitsWithdrawMin, &limitsWithdrawMinMain)) {
2532 add_element_to_object(get_value_mut(get_value_mut(&mut currency, &Value::Str("limits".into())), &Value::Str("withdraw".into())), &Value::Str("min".into()), self.parse_number(limitsWithdrawMin, &[]));
2533 }
2534 if (limitsWithdrawMaxMain == Value::Null) || is_true(&crate::precise::Precise::stringGt(&limitsWithdrawMax, &limitsWithdrawMaxMain)) {
2536 add_element_to_object(get_value_mut(get_value_mut(&mut currency, &Value::Str("limits".into())), &Value::Str("withdraw".into())), &Value::Str("max".into()), self.parse_number(limitsWithdrawMax, &[]));
2537 }
2538 }
2539 }
2540 }
2541 return self.extend(Value::Map({
2542 let mut m = indexmap::IndexMap::new();
2543 m.insert("info".to_string(), Value::Null);
2544 m.insert("id".to_string(), Value::Null);
2545 m.insert("numericId".to_string(), Value::Null);
2546 m.insert("code".to_string(), Value::Null);
2547 m.insert("precision".to_string(), Value::Null);
2548 m.insert("type".to_string(), Value::Null);
2549 m.insert("name".to_string(), Value::Null);
2550 m.insert("active".to_string(), Value::Null);
2551 m.insert("deposit".to_string(), Value::Null);
2552 m.insert("withdraw".to_string(), Value::Null);
2553 m.insert("fee".to_string(), Value::Null);
2554 m.insert("fees".to_string(), Value::Map({
2555 let mut m = indexmap::IndexMap::new();
2556 m
2557}));
2558 m.insert("networks".to_string(), Value::Map({
2559 let mut m = indexmap::IndexMap::new();
2560 m
2561}));
2562 m.insert("limits".to_string(), Value::Map({
2563 let mut m = indexmap::IndexMap::new();
2564 m.insert("deposit".to_string(), Value::Map({
2565 let mut m = indexmap::IndexMap::new();
2566 m.insert("min".to_string(), Value::Null);
2567 m.insert("max".to_string(), Value::Null);
2568 m
2569}));
2570 m.insert("withdraw".to_string(), Value::Map({
2571 let mut m = indexmap::IndexMap::new();
2572 m.insert("min".to_string(), Value::Null);
2573 m.insert("max".to_string(), Value::Null);
2574 m
2575}));
2576 m
2577}));
2578 m
2579}), &[currency]);
2580
2581 Value::Null
2582}
2583
2584 fn safe_market_structure(&self, optional_args: &[Value]) -> Value {
2585 let mut market = get_arg(optional_args, 0, Value::Null);
2586 let mut cleanStructure: Value = Value::Map({
2587 let mut m = indexmap::IndexMap::new();
2588 m.insert("id".to_string(), Value::Null);
2589 m.insert("lowercaseId".to_string(), Value::Null);
2590 m.insert("symbol".to_string(), Value::Null);
2591 m.insert("base".to_string(), Value::Null);
2592 m.insert("quote".to_string(), Value::Null);
2593 m.insert("settle".to_string(), Value::Null);
2594 m.insert("baseId".to_string(), Value::Null);
2595 m.insert("quoteId".to_string(), Value::Null);
2596 m.insert("settleId".to_string(), Value::Null);
2597 m.insert("type".to_string(), Value::Null);
2598 m.insert("spot".to_string(), Value::Null);
2599 m.insert("margin".to_string(), Value::Null);
2600 m.insert("swap".to_string(), Value::Null);
2601 m.insert("future".to_string(), Value::Null);
2602 m.insert("option".to_string(), Value::Null);
2603 m.insert("index".to_string(), Value::Null);
2604 m.insert("active".to_string(), Value::Null);
2605 m.insert("contract".to_string(), Value::Null);
2606 m.insert("linear".to_string(), Value::Null);
2607 m.insert("inverse".to_string(), Value::Null);
2608 m.insert("subType".to_string(), Value::Null);
2609 m.insert("taker".to_string(), Value::Null);
2610 m.insert("maker".to_string(), Value::Null);
2611 m.insert("contractSize".to_string(), Value::Null);
2612 m.insert("expiry".to_string(), Value::Null);
2613 m.insert("expiryDatetime".to_string(), Value::Null);
2614 m.insert("strike".to_string(), Value::Null);
2615 m.insert("optionType".to_string(), Value::Null);
2616 m.insert("precision".to_string(), Value::Map({
2617 let mut m = indexmap::IndexMap::new();
2618 m.insert("amount".to_string(), Value::Null);
2619 m.insert("price".to_string(), Value::Null);
2620 m.insert("cost".to_string(), Value::Null);
2621 m.insert("base".to_string(), Value::Null);
2622 m.insert("quote".to_string(), Value::Null);
2623 m
2624}));
2625 m.insert("limits".to_string(), Value::Map({
2626 let mut m = indexmap::IndexMap::new();
2627 m.insert("leverage".to_string(), Value::Map({
2628 let mut m = indexmap::IndexMap::new();
2629 m.insert("min".to_string(), Value::Null);
2630 m.insert("max".to_string(), Value::Null);
2631 m
2632}));
2633 m.insert("amount".to_string(), Value::Map({
2634 let mut m = indexmap::IndexMap::new();
2635 m.insert("min".to_string(), Value::Null);
2636 m.insert("max".to_string(), Value::Null);
2637 m
2638}));
2639 m.insert("price".to_string(), Value::Map({
2640 let mut m = indexmap::IndexMap::new();
2641 m.insert("min".to_string(), Value::Null);
2642 m.insert("max".to_string(), Value::Null);
2643 m
2644}));
2645 m.insert("cost".to_string(), Value::Map({
2646 let mut m = indexmap::IndexMap::new();
2647 m.insert("min".to_string(), Value::Null);
2648 m.insert("max".to_string(), Value::Null);
2649 m
2650}));
2651 m
2652}));
2653 m.insert("marginModes".to_string(), Value::Map({
2654 let mut m = indexmap::IndexMap::new();
2655 m.insert("cross".to_string(), Value::Null);
2656 m.insert("isolated".to_string(), Value::Null);
2657 m
2658}));
2659 m.insert("created".to_string(), Value::Null);
2660 m.insert("info".to_string(), Value::Null);
2661 m
2662 });
2663 if (market != Value::Null) {
2664 let mut result: Value = self.extend(cleanStructure.clone(), &[market]);
2665 if is_equal(&result.as_map().and_then(|__m| __m.get("spot")).cloned().unwrap_or(Value::Null), &Value::Bool(true)) {
2667 if (result.as_map().and_then(|__m| __m.get("contract")).cloned().unwrap_or(Value::Null) == Value::Null) {
2668 add_element_to_object(&mut result, &Value::Str("contract".into()), Value::Bool(false));
2669 }
2670 if (result.as_map().and_then(|__m| __m.get("swap")).cloned().unwrap_or(Value::Null) == Value::Null) {
2671 add_element_to_object(&mut result, &Value::Str("swap".into()), Value::Bool(false));
2672 }
2673 if (result.as_map().and_then(|__m| __m.get("future")).cloned().unwrap_or(Value::Null) == Value::Null) {
2674 add_element_to_object(&mut result, &Value::Str("future".into()), Value::Bool(false));
2675 }
2676 if (result.as_map().and_then(|__m| __m.get("option")).cloned().unwrap_or(Value::Null) == Value::Null) {
2677 add_element_to_object(&mut result, &Value::Str("option".into()), Value::Bool(false));
2678 }
2679 if (result.as_map().and_then(|__m| __m.get("index")).cloned().unwrap_or(Value::Null) == Value::Null) {
2680 add_element_to_object(&mut result, &Value::Str("index".into()), Value::Bool(false));
2681 }
2682 }
2683 return result;
2684 }
2685 return self.extend(cleanStructure, &[]);
2686
2687 Value::Null
2688}
2689
2690 fn set_markets(&mut self, mut markets: Value, optional_args: &[Value]) -> Value {
2691 let mut currencies = get_arg(optional_args, 0, Value::Null);
2692 let mut values: Value = Value::from(vec![]);
2693 { let __t = self.create_safe_dictionary(&[]); self.markets_by_id = __t; }
2694 let mut marketValues: Value = self.sort_by(self.to_array(markets.clone()), Value::Str("spot".into()), &[Value::Bool(true), Value::Bool(true)]);
2697 {
2698 let mut i: Value = Value::Int(0);
2699 let mut __for_first_86: bool = true;
2700 while { if !__for_first_86 { i = (match (&(i), &(Value::Int(1))) { (Value::Int(x), Value::Int(y)) => Value::Int(x + y), (Value::Int(x), Value::Float(y)) => Value::Float(*x as f64 + *y), (Value::Float(x), Value::Int(y)) => Value::Float(*x + *y as f64), (Value::Float(x), Value::Float(y)) => Value::Float(x + y), _ => Value::Null }); } __for_first_86 = false; i.as_f64().unwrap_or(f64::NAN) < ((marketValues.len() as i64) as f64) } {
2701 let mut value: Value = marketValues.as_array().and_then(|__arr| match &i { Value::Int(__n) => __arr.get(*__n as usize), Value::Str(__s) => __s.parse::<usize>().ok().and_then(|__n| __arr.get(__n)), _ => None }).cloned().unwrap_or(Value::Null);
2702 if (in_op(&self.markets_by_id, &crate::value::get_value_k(&value, "id"))) {
2703 let mut marketsByIdArray: Value = get_value(&self.markets_by_id, &crate::value::get_value_k(&value, "id"));
2704 append_to_array(&mut marketsByIdArray, value.clone());
2705 add_element_to_object(&mut self.markets_by_id, &crate::value::get_value_k(&value, "id"), marketsByIdArray);
2706 } else {
2707 add_element_to_object(&mut self.markets_by_id, &crate::value::get_value_k(&value, "id"), Value::from(vec![value.clone()]));
2708 }
2709 let mut valueDefined: Value = Value::Map({
2713 let mut m = indexmap::IndexMap::new();
2714 m
2715 });
2716 let mut valueKeys: Value = object_keys(&value);
2717 {
2718 let mut j: Value = Value::Int(0);
2719 let mut __for_first_85: bool = true;
2720 while { if !__for_first_85 { j = (match (&(j), &(Value::Int(1))) { (Value::Int(x), Value::Int(y)) => Value::Int(x + y), (Value::Int(x), Value::Float(y)) => Value::Float(*x as f64 + *y), (Value::Float(x), Value::Int(y)) => Value::Float(*x + *y as f64), (Value::Float(x), Value::Float(y)) => Value::Float(x + y), _ => Value::Null }); } __for_first_85 = false; j.as_f64().unwrap_or(f64::NAN) < ((valueKeys.len() as i64) as f64) } {
2721 let mut valueKey: Value = valueKeys.as_array().and_then(|__arr| match &j { Value::Int(__n) => __arr.get(*__n as usize), Value::Str(__s) => __s.parse::<usize>().ok().and_then(|__n| __arr.get(__n)), _ => None }).cloned().unwrap_or(Value::Null);
2722 if (get_value(&value, &valueKey) != Value::Null) {
2723 if let Value::Dict(__d) = &mut valueDefined { std::sync::Arc::make_mut(__d).insert(crate::runtime::stringify_param(&valueKey), get_value(&value, &valueKey)); }
2724 }
2725 }
2726 }
2727 let mut market: Value = self.deep_extend(self.safe_market_structure(&[]), &[Value::Map({
2728 let mut m = indexmap::IndexMap::new();
2729 m.insert("precision".to_string(), self.precision.clone());
2730 m.insert("limits".to_string(), self.limits.clone());
2731 m
2732 }), self.fees.as_map().and_then(|__m| __m.get("trading")).cloned().unwrap_or(Value::Null), valueDefined]);
2733 if is_equal(&market.as_map().and_then(|__m| __m.get("linear")).cloned().unwrap_or(Value::Null), &Value::Bool(true)) {
2734 add_element_to_object(&mut market, &Value::Str("subType".into()), Value::Str("linear".into()));
2735 } else if is_equal(&market.as_map().and_then(|__m| __m.get("inverse")).cloned().unwrap_or(Value::Null), &Value::Bool(true)) {
2736 add_element_to_object(&mut market, &Value::Str("subType".into()), Value::Str("inverse".into()));
2737 } else {
2738 add_element_to_object(&mut market, &Value::Str("subType".into()), Value::Null);
2739 }
2740 append_to_array(&mut values, market.clone());
2741 }
2742 }
2743 { let __t = self.map_to_safe_map(self.index_by(values.clone(), Value::Str("symbol".into()))); self.markets = __t; }
2744 let mut marketsSortedBySymbol: Value = self.keysort(self.markets.clone(), &[]);
2745 let mut marketsSortedById: Value = self.keysort(self.markets_by_id.clone(), &[]);
2746 self.symbols = object_keys(&marketsSortedBySymbol);
2747 self.ids = object_keys(&marketsSortedById);
2748 let mut numCurrencies: Value = Value::Int(0);
2749 if (currencies != Value::Null) {
2750 let mut keys: Value = object_keys(¤cies);
2751 numCurrencies = Value::Int(keys.len() as i64);
2752 }
2753 if numCurrencies.as_f64().unwrap_or(f64::NAN) > ((0i64) as f64) {
2754 { let __t = self.map_to_safe_map(self.deep_extend(self.currencies.clone(), &[currencies.clone()])); self.currencies = __t; }
2756 } else {
2757 let mut baseCurrencies: Value = Value::from(vec![]);
2758 let mut quoteCurrencies: Value = Value::from(vec![]);
2759 {
2760 let mut i: Value = Value::Int(0);
2761 let mut __for_first_87: bool = true;
2762 while { if !__for_first_87 { i = (match (&(i), &(Value::Int(1))) { (Value::Int(x), Value::Int(y)) => Value::Int(x + y), (Value::Int(x), Value::Float(y)) => Value::Float(*x as f64 + *y), (Value::Float(x), Value::Int(y)) => Value::Float(*x + *y as f64), (Value::Float(x), Value::Float(y)) => Value::Float(x + y), _ => Value::Null }); } __for_first_87 = false; i.as_f64().unwrap_or(f64::NAN) < ((values.len() as i64) as f64) } {
2763 let mut market: Value = values.as_array().and_then(|__arr| match &i { Value::Int(__n) => __arr.get(*__n as usize), Value::Str(__s) => __s.parse::<usize>().ok().and_then(|__n| __arr.get(__n)), _ => None }).cloned().unwrap_or(Value::Null);
2764 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()), &[]) });
2765 let mut marketPrecision: Value = self.safe_dict_k(market.clone(), "precision", &[Value::Map({
2766 let mut m = indexmap::IndexMap::new();
2767 m
2768})]);
2769 if (matches!(&market, Value::Dict(__d) if __d.contains_key("base"))) {
2770 let mut currency: Value = self.safe_currency_structure(Value::Map({
2771 let mut m = indexmap::IndexMap::new();
2772 m.insert("id".to_string(), self.safe_string2(market.clone(), Value::Str("baseId".into()), Value::Str("base".into()), &[]));
2773 m.insert("numericId".to_string(), self.safe_integer_k(market.clone(), "baseNumericId", &[]));
2774 m.insert("code".to_string(), self.safe_string_k(market.clone(), "base", &[]));
2775 m.insert("precision".to_string(), self.safe_value2(marketPrecision.clone(), Value::Str("base".into()), Value::Str("amount".into()), &[defaultCurrencyPrecision.clone()]));
2776 m
2777 }));
2778 append_to_array(&mut baseCurrencies, currency.clone());
2779 }
2780 if (matches!(&market, Value::Dict(__d) if __d.contains_key("quote"))) {
2781 let mut currency: Value = self.safe_currency_structure(Value::Map({
2782 let mut m = indexmap::IndexMap::new();
2783 m.insert("id".to_string(), self.safe_string2(market.clone(), Value::Str("quoteId".into()), Value::Str("quote".into()), &[]));
2784 m.insert("numericId".to_string(), self.safe_integer_k(market.clone(), "quoteNumericId", &[]));
2785 m.insert("code".to_string(), self.safe_string_k(market.clone(), "quote", &[]));
2786 m.insert("precision".to_string(), self.safe_value2(marketPrecision, Value::Str("quote".into()), Value::Str("price".into()), &[defaultCurrencyPrecision]));
2787 m
2788 }));
2789 append_to_array(&mut quoteCurrencies, currency);
2790 }
2791 }
2792 }
2793 baseCurrencies = self.sort_by(baseCurrencies.clone(), Value::Str("code".into()), &[Value::Bool(false), Value::Str("".into())]);
2794 quoteCurrencies = self.sort_by(quoteCurrencies.clone(), Value::Str("code".into()), &[Value::Bool(false), Value::Str("".into())]);
2795 { let __t = self.map_to_safe_map(self.index_by(baseCurrencies.clone(), Value::Str("code".into()))); self.baseCurrencies = __t; }
2796 { let __t = self.map_to_safe_map(self.index_by(quoteCurrencies.clone(), Value::Str("code".into()))); self.quoteCurrencies = __t; }
2797 let mut allCurrencies: Value = self.array_concat(baseCurrencies, quoteCurrencies);
2798 let mut groupedCurrencies: Value = self.group_by(allCurrencies, Value::Str("code".into()), &[]);
2799 let mut codes: Value = object_keys(&groupedCurrencies);
2800 let mut resultingCurrencies: Value = Value::from(vec![]);
2801 {
2802 let mut i: Value = Value::Int(0);
2803 let mut __for_first_89: bool = true;
2804 while { if !__for_first_89 { i = (match (&(i), &(Value::Int(1))) { (Value::Int(x), Value::Int(y)) => Value::Int(x + y), (Value::Int(x), Value::Float(y)) => Value::Float(*x as f64 + *y), (Value::Float(x), Value::Int(y)) => Value::Float(*x + *y as f64), (Value::Float(x), Value::Float(y)) => Value::Float(x + y), _ => Value::Null }); } __for_first_89 = false; i.as_f64().unwrap_or(f64::NAN) < ((codes.len() as i64) as f64) } {
2805 let mut code: Value = codes.as_array().and_then(|__arr| match &i { Value::Int(__n) => __arr.get(*__n as usize), Value::Str(__s) => __s.parse::<usize>().ok().and_then(|__n| __arr.get(__n)), _ => None }).cloned().unwrap_or(Value::Null);
2806 let mut groupedCurrenciesCode: Value = self.safe_list(groupedCurrencies.clone(), code, &[Value::from(vec![])]);
2807 let mut highestPrecisionCurrency: Value = self.safe_value(groupedCurrenciesCode.clone(), Value::Int(0), &[]);
2808 {
2809 let mut j: Value = Value::Int(1);
2810 let mut __for_first_88: bool = true;
2811 while { if !__for_first_88 { j = (match (&(j), &(Value::Int(1))) { (Value::Int(x), Value::Int(y)) => Value::Int(x + y), (Value::Int(x), Value::Float(y)) => Value::Float(*x as f64 + *y), (Value::Float(x), Value::Int(y)) => Value::Float(*x + *y as f64), (Value::Float(x), Value::Float(y)) => Value::Float(x + y), _ => Value::Null }); } __for_first_88 = false; j.as_f64().unwrap_or(f64::NAN) < ((groupedCurrenciesCode.len() as i64) as f64) } {
2812 let mut currentCurrency: Value = get_value(&groupedCurrenciesCode, &j);
2813 let mut currentCurrency: Value = get_value(&groupedCurrenciesCode, &j);
2814 let mut currentPrecision: Value = self.safe_number_k(currentCurrency.clone(), "precision", &[]);
2815 let mut highestPrecision: Value = self.safe_number_k(highestPrecisionCurrency.clone(), "precision", &[]);
2816 if (currentPrecision == Value::Null) || (highestPrecision == Value::Null) {
2817 continue;
2818 }
2819 if (self.precisionMode.as_f64() == Value::Int(crate::runtime::TICK_SIZE).as_f64()) {
2820 if currentPrecision.as_f64().unwrap_or(f64::NAN) < highestPrecision.as_f64().unwrap_or(f64::NAN) {
2821 highestPrecisionCurrency = currentCurrency.clone();
2822 }
2823 } else if currentPrecision.as_f64().unwrap_or(f64::NAN) > highestPrecision.as_f64().unwrap_or(f64::NAN) {
2824 highestPrecisionCurrency = currentCurrency;
2825 }
2826 }
2827 }
2828 append_to_array(&mut resultingCurrencies, highestPrecisionCurrency);
2829 }
2830 }
2831 let mut sortedCurrencies: Value = self.sort_by(resultingCurrencies, Value::Str("code".into()), &[]);
2832 { let __t = self.map_to_safe_map(self.deep_extend(self.currencies.clone(), &[self.index_by(sortedCurrencies, Value::Str("code".into()))])); self.currencies = __t; }
2833 }
2834 { let __t = self.index_by_safe(self.currencies.clone(), Value::Str("id".into())); self.currencies_by_id = __t; }
2835 let mut currenciesSortedByCode: Value = self.keysort(self.currencies.clone(), &[]);
2836 self.codes = object_keys(¤ciesSortedByCode);
2837 if (self.markets.clone() == Value::Null) {
2838 panic!("{}", crate::exchange_errors::exchange_error(format!("{}{}", self.id.clone(), Value::Str(" setMarkets() markets not set".into()))));
2839 }
2840 return self.markets.clone();
2841
2842 Value::Null
2843}
2844
2845 fn set_markets_from_exchange(&mut self, mut sourceExchange: Value) -> Value {
2846 if !is_equal(&self.id, &get_value(&sourceExchange, &Value::Str("id".into()))) {
2848 panic!("{}", crate::exchange_errors::arguments_required(format!("{}{}", add(&Value::Str(format!("{}{}", self.id.clone(), Value::Str(" shareMarkets() can only share markets with exchanges of the same type (got ".into())).into()), &crate::value::get_value_k(&sourceExchange, "id")), Value::Str(")".into()))));
2849 }
2850 if (get_value(&sourceExchange, &Value::Str("markets".into())) == Value::Null) || (get_value(&sourceExchange, &Value::Str("markets".into())) == Value::Null) {
2852 panic!("{}", crate::exchange_errors::exchange_error("setMarketsFromExchange() source exchange must have loaded markets first. Can call by using loadMarkets function"));
2853 }
2854 self.markets = get_value(&sourceExchange, &Value::Str("markets".into()));
2856 self.markets_by_id = get_value(&sourceExchange, &Value::Str("markets_by_id".into()));
2857 self.symbols = get_value(&sourceExchange, &Value::Str("symbols".into()));
2858 self.ids = get_value(&sourceExchange, &Value::Str("ids".into()));
2859 self.currencies = get_value(&sourceExchange, &Value::Str("currencies".into()));
2860 self.currencies_by_id = get_value(&sourceExchange, &Value::Str("currencies_by_id".into()));
2861 self.baseCurrencies = get_value(&sourceExchange, &Value::Str("baseCurrencies".into()));
2862 self.quoteCurrencies = get_value(&sourceExchange, &Value::Str("quoteCurrencies".into()));
2863 self.codes = get_value(&sourceExchange, &Value::Str("codes".into()));
2864 let mut sourceExchangeHelpers: Value = self.safe_list(get_value(&sourceExchange, &Value::Str("options".into())), Value::Str("marketHelperProps".into()), &[Value::from(vec![])]);
2866 {
2867 let mut i: Value = Value::Int(0);
2868 let mut __for_first_90: bool = true;
2869 while { if !__for_first_90 { i = (match (&(i), &(Value::Int(1))) { (Value::Int(x), Value::Int(y)) => Value::Int(x + y), (Value::Int(x), Value::Float(y)) => Value::Float(*x as f64 + *y), (Value::Float(x), Value::Int(y)) => Value::Float(*x + *y as f64), (Value::Float(x), Value::Float(y)) => Value::Float(x + y), _ => Value::Null }); } __for_first_90 = false; i.as_f64().unwrap_or(f64::NAN) < ((sourceExchangeHelpers.len() as i64) as f64) } {
2870 let mut helper: Value = get_value(&sourceExchangeHelpers, &i);
2871 let mut helper: Value = get_value(&sourceExchangeHelpers, &i);
2872 if (get_value(&get_value(&sourceExchange, &Value::Str("options".into())), &helper) != Value::Null) {
2873 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)); }
2874 }
2875 }
2876 }
2877 return Value::Null;
2878
2879 Value::Null
2880}
2881
2882 fn get_describe_for_extended_ws_exchange(&self, mut currentRestInstance: Value, mut parentRestInstance: Value, mut wsBaseDescribe: Value) -> Value {
2883 let mut extendedRestDescribe: Value = self.deep_extend(parentRestInstance.describe(), &[currentRestInstance.describe()]);
2884 let mut superWithRestDescribe: Value = self.deep_extend(extendedRestDescribe, &[wsBaseDescribe]);
2885 return superWithRestDescribe;
2886
2887 Value::Null
2888}
2889
2890 fn safe_balance(&self, mut balance: Value) -> Value {
2891 let mut balances: Value = self.omit(balance.clone(), Value::from(vec![Value::Str("info".into()), Value::Str("timestamp".into()), Value::Str("datetime".into()), Value::Str("free".into()), Value::Str("used".into()), Value::Str("total".into())]), &[]);
2892 let mut codes: Value = object_keys(&balances);
2893 if let Value::Dict(__d) = &mut balance { std::sync::Arc::make_mut(__d).insert("free".into(), Value::Map({
2894 let mut m = indexmap::IndexMap::new();
2895 m
2896})); }
2897 if let Value::Dict(__d) = &mut balance { std::sync::Arc::make_mut(__d).insert("used".into(), Value::Map({
2898 let mut m = indexmap::IndexMap::new();
2899 m
2900})); }
2901 if let Value::Dict(__d) = &mut balance { std::sync::Arc::make_mut(__d).insert("total".into(), Value::Map({
2902 let mut m = indexmap::IndexMap::new();
2903 m
2904})); }
2905 let mut debtBalance: Value = Value::Map({
2906 let mut m = indexmap::IndexMap::new();
2907 m
2908 });
2909 {
2910 let mut i: Value = Value::Int(0);
2911 let mut __for_first_91: bool = true;
2912 while { if !__for_first_91 { i = (match (&(i), &(Value::Int(1))) { (Value::Int(x), Value::Int(y)) => Value::Int(x + y), (Value::Int(x), Value::Float(y)) => Value::Float(*x as f64 + *y), (Value::Float(x), Value::Int(y)) => Value::Float(*x + *y as f64), (Value::Float(x), Value::Float(y)) => Value::Float(x + y), _ => Value::Null }); } __for_first_91 = false; i.as_f64().unwrap_or(f64::NAN) < ((codes.len() as i64) as f64) } {
2913 let mut code: Value = codes.as_array().and_then(|__arr| match &i { Value::Int(__n) => __arr.get(*__n as usize), Value::Str(__s) => __s.parse::<usize>().ok().and_then(|__n| __arr.get(__n)), _ => None }).cloned().unwrap_or(Value::Null);
2914 let mut total: Value = self.safe_string(balance.as_map().and_then(|__m| code.as_str().and_then(|__k| __m.get(__k))).cloned().unwrap_or(Value::Null), Value::Str("total".into()), &[]);
2915 let mut free: Value = self.safe_string(balance.as_map().and_then(|__m| code.as_str().and_then(|__k| __m.get(__k))).cloned().unwrap_or(Value::Null), Value::Str("free".into()), &[]);
2916 let mut used: Value = self.safe_string(balance.as_map().and_then(|__m| code.as_str().and_then(|__k| __m.get(__k))).cloned().unwrap_or(Value::Null), Value::Str("used".into()), &[]);
2917 let mut debt: Value = self.safe_string(balance.as_map().and_then(|__m| code.as_str().and_then(|__k| __m.get(__k))).cloned().unwrap_or(Value::Null), Value::Str("debt".into()), &[]);
2918 if (total == Value::Null) && (free != Value::Null) && (used != Value::Null) {
2919 total = crate::precise::Precise::stringAdd(&free, &used);
2920 }
2921 if (free == Value::Null) && (total != Value::Null) && (used != Value::Null) {
2922 free = crate::precise::Precise::stringSub(&total, &used);
2923 }
2924 if (used == Value::Null) && (total != Value::Null) && (free != Value::Null) {
2925 used = crate::precise::Precise::stringSub(&total, &free);
2926 }
2927 add_element_to_object(get_value_mut(&mut balance, &code), &Value::Str("free".into()), self.parse_number(free, &[]));
2928 add_element_to_object(get_value_mut(&mut balance, &code), &Value::Str("used".into()), self.parse_number(used, &[]));
2929 add_element_to_object(get_value_mut(&mut balance, &code), &Value::Str("total".into()), self.parse_number(total, &[]));
2930 { let __be_tmp = crate::value::get_value_k(&get_value(&balance, &code), "free"); add_element_to_object(get_value_mut(&mut balance, &Value::Str("free".into())), &code, __be_tmp); };
2931 { let __be_tmp = crate::value::get_value_k(&get_value(&balance, &code), "used"); add_element_to_object(get_value_mut(&mut balance, &Value::Str("used".into())), &code, __be_tmp); };
2932 { let __be_tmp = crate::value::get_value_k(&get_value(&balance, &code), "total"); add_element_to_object(get_value_mut(&mut balance, &Value::Str("total".into())), &code, __be_tmp); };
2933 if (debt != Value::Null) {
2934 add_element_to_object(get_value_mut(&mut balance, &code), &Value::Str("debt".into()), self.parse_number(debt, &[]));
2935 if let Value::Dict(__d) = &mut debtBalance { std::sync::Arc::make_mut(__d).insert(crate::runtime::stringify_param(&code), crate::value::get_value_k(&balance.as_map().and_then(|__m| code.as_str().and_then(|__k| __m.get(__k))).cloned().unwrap_or(Value::Null), "debt")); }
2936 }
2937 }
2938 }
2939 let mut debtBalanceArray: Value = object_keys(&debtBalance);
2940 let mut length: Value = Value::Int(debtBalanceArray.len() as i64);
2941 if (length != Value::Null) && (length.as_f64() != Some(0.0)) {
2942 if let Value::Dict(__d) = &mut balance { std::sync::Arc::make_mut(__d).insert("debt".into(), debtBalance); }
2943 }
2944 return balance;
2945
2946 Value::Null
2947}
2948
2949 fn safe_order(&self, mut order: Value, optional_args: &[Value]) -> Value {
2950 let mut market = get_arg(optional_args, 0, Value::Null);
2951 let mut orderDict: Value = order.clone();
2954 if (order == Value::Null) {
2955 orderDict = Value::Map({
2956 let mut m = indexmap::IndexMap::new();
2957 m
2958 });
2959 }
2960 let mut amount: Value = self.omit_zero(self.safe_string_k(orderDict.clone(), "amount", &[]));
2961 let mut remaining: Value = self.safe_string_k(orderDict.clone(), "remaining", &[]);
2962 let mut filled: Value = self.safe_string_k(orderDict.clone(), "filled", &[]);
2963 let mut cost: Value = self.safe_string_k(orderDict.clone(), "cost", &[]);
2964 let mut average: Value = self.omit_zero(self.safe_string_k(orderDict.clone(), "average", &[]));
2965 let mut price: Value = self.omit_zero(self.safe_string_k(orderDict.clone(), "price", &[]));
2966 let mut lastTradeTimeTimestamp: Value = self.safe_integer_k(orderDict.clone(), "lastTradeTimestamp", &[]);
2967 let mut symbol: Value = self.safe_string_k(orderDict.clone(), "symbol", &[]);
2968 let mut side: Value = self.safe_string_k(orderDict.clone(), "side", &[]);
2969 let mut status: Value = self.safe_string_k(orderDict.clone(), "status", &[]);
2970 let mut parseFilled: bool = filled == Value::Null;
2971 let mut parseCost: bool = cost == Value::Null;
2972 let mut parseLastTradeTimeTimestamp: bool = lastTradeTimeTimestamp == Value::Null;
2973 let mut fee: Value = self.safe_value_k(orderDict.clone(), "fee", &[]);
2974 let mut parseFee: bool = fee == Value::Null;
2975 let mut parseFees: bool = self.safe_value_k(orderDict.clone(), "fees", &[]) == Value::Null;
2976 let mut parseSymbol: bool = symbol == Value::Null;
2977 let mut parseSide: bool = side == Value::Null;
2978 let mut shouldParseFees: bool = parseFee || parseFees;
2979 let mut fees: Value = self.safe_list_k(orderDict.clone(), "fees", &[Value::from(vec![])]);
2980 let mut trades: Value = Value::from(vec![]);
2981 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);
2982 if parseFilled || parseCost || shouldParseFees {
2983 let mut rawTrades: Value = self.safe_value_k(orderDict.clone(), "trades", &[trades.clone()]);
2984 let mut firstTrade: Value = self.safe_value(rawTrades.clone(), Value::Int(0), &[]);
2989 let mut tradesAreParsed: bool = (firstTrade != Value::Null) && (in_op(&firstTrade, &Value::Str("info".into()))) && (in_op(&firstTrade, &Value::Str("id".into())));
2991 if !tradesAreParsed {
2992 trades = self.parse_trades(rawTrades.clone(), &[market.clone()]);
2993 } else {
2994 trades = rawTrades;
2995 }
2996 let mut tradesLength: Value = Value::Int(0);
2998 let mut isArray: bool = matches!(&trades, Value::Arr(_));
2999 if isArray {
3000 tradesLength = Value::Int(trades.len() as i64);
3001 }
3002 if isArray && (tradesLength.as_f64().unwrap_or(f64::NAN) > ((0i64) as f64)) {
3003 if (orderDict.as_map().and_then(|__m| __m.get("symbol")).cloned().unwrap_or(Value::Null) == Value::Null) {
3005 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"));
3006 }
3007 if (orderDict.as_map().and_then(|__m| __m.get("side")).cloned().unwrap_or(Value::Null) == Value::Null) {
3008 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"));
3009 }
3010 if (orderDict.as_map().and_then(|__m| __m.get("type")).cloned().unwrap_or(Value::Null) == Value::Null) {
3011 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"));
3012 }
3013 if (orderDict.as_map().and_then(|__m| __m.get("id")).cloned().unwrap_or(Value::Null) == Value::Null) {
3014 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"));
3015 }
3016 if parseFilled {
3017 filled = Value::Str("0".into());
3018 }
3019 if parseCost {
3020 cost = Value::Str("0".into());
3021 }
3022 {
3023 let mut i: Value = Value::Int(0);
3024 let mut __for_first_93: bool = true;
3025 while { if !__for_first_93 { i = (match (&(i), &(Value::Int(1))) { (Value::Int(x), Value::Int(y)) => Value::Int(x + y), (Value::Int(x), Value::Float(y)) => Value::Float(*x as f64 + *y), (Value::Float(x), Value::Int(y)) => Value::Float(*x + *y as f64), (Value::Float(x), Value::Float(y)) => Value::Float(x + y), _ => Value::Null }); } __for_first_93 = false; i.as_f64().unwrap_or(f64::NAN) < ((trades.len() as i64) as f64) } {
3026 let mut trade: Value = trades.as_array().and_then(|__arr| match &i { Value::Int(__n) => __arr.get(*__n as usize), Value::Str(__s) => __s.parse::<usize>().ok().and_then(|__n| __arr.get(__n)), _ => None }).cloned().unwrap_or(Value::Null);
3027 let mut tradeAmount: Value = self.safe_string_k(trade.clone(), "amount", &[]);
3028 if parseFilled && (tradeAmount != Value::Null) {
3029 filled = crate::precise::Precise::stringAdd(&filled, &tradeAmount);
3030 }
3031 let mut tradeCost: Value = self.safe_string_k(trade.clone(), "cost", &[]);
3032 if parseCost && (tradeCost != Value::Null) {
3033 cost = crate::precise::Precise::stringAdd(&cost, &tradeCost);
3034 }
3035 if parseSymbol {
3036 symbol = self.safe_string_k(trade.clone(), "symbol", &[]);
3037 }
3038 if parseSide {
3039 side = self.safe_string_k(trade.clone(), "side", &[]);
3040 }
3041 let mut tradeTimestamp: Value = self.safe_value_k(trade.clone(), "timestamp", &[]);
3042 if parseLastTradeTimeTimestamp && (tradeTimestamp != Value::Null) {
3043 if (lastTradeTimeTimestamp == Value::Null) {
3044 lastTradeTimeTimestamp = tradeTimestamp.clone();
3045 } else {
3046 lastTradeTimeTimestamp = crate::runtime::Math::max(&lastTradeTimeTimestamp, &tradeTimestamp);
3047 }
3048 }
3049 if shouldParseFees {
3050 let mut tradeFees: Value = self.safe_value_k(trade.clone(), "fees", &[]);
3051 if (tradeFees != Value::Null) {
3052 {
3053 let mut j: Value = Value::Int(0);
3054 let mut __for_first_92: bool = true;
3055 while { if !__for_first_92 { j = (match (&(j), &(Value::Int(1))) { (Value::Int(x), Value::Int(y)) => Value::Int(x + y), (Value::Int(x), Value::Float(y)) => Value::Float(*x as f64 + *y), (Value::Float(x), Value::Int(y)) => Value::Float(*x + *y as f64), (Value::Float(x), Value::Float(y)) => Value::Float(x + y), _ => Value::Null }); } __for_first_92 = false; j.as_f64().unwrap_or(f64::NAN) < get_array_length(&tradeFees).as_f64().unwrap_or(f64::NAN) } {
3056 let mut tradeFee: Value = get_value(&tradeFees, &j);
3057 let mut tradeFee: Value = get_value(&tradeFees, &j);
3058 append_to_array(&mut fees, self.extend(Value::Map({
3059 let mut m = indexmap::IndexMap::new();
3060 m
3061 }), &[tradeFee.clone()]));
3062 }
3063 }
3064 } else {
3065 let mut tradeFee: Value = self.safe_value_k(trade, "fee", &[]);
3066 if (tradeFee != Value::Null) {
3067 append_to_array(&mut fees, self.extend(Value::Map({
3068 let mut m = indexmap::IndexMap::new();
3069 m
3070 }), &[tradeFee.clone()]));
3071 }
3072 }
3073 }
3074 }
3075 }
3076 }
3077 }
3078 if shouldParseFees {
3079 let mut reducedFees: Value = fees.clone();
3080 if is_true(&self.reduceFees) {
3081 reducedFees = self.reduce_fees_by_currency(fees);
3082 }
3083 if (reducedFees == Value::Null) {
3084 reducedFees = Value::from(vec![]);
3085 }
3086 let mut reducedLength: f64 = ((reducedFees.len() as i64) as f64);
3087 {
3088 let mut i: Value = Value::Int(0);
3089 let mut __for_first_94: bool = true;
3090 while { if !__for_first_94 { i = (match (&(i), &(Value::Int(1))) { (Value::Int(x), Value::Int(y)) => Value::Int(x + y), (Value::Int(x), Value::Float(y)) => Value::Float(*x as f64 + *y), (Value::Float(x), Value::Int(y)) => Value::Float(*x + *y as f64), (Value::Float(x), Value::Float(y)) => Value::Float(x + y), _ => Value::Null }); } __for_first_94 = false; i.as_f64().unwrap_or(f64::NAN) < reducedLength } {
3091 { 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); };
3092 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()))) {
3093 { 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); };
3094 }
3095 }
3096 }
3097 if !parseFee && (reducedLength == 0.0) {
3098 let mut feeCopy: Value = self.deep_extend(fee, &[]);
3100 { let __be_tmp = self.safe_number_k(feeCopy.clone(), "cost", &[]); add_element_to_object(&mut feeCopy, &Value::Str("cost".into()), __be_tmp); };
3101 if (in_op(&feeCopy, &Value::Str("rate".into()))) {
3102 { let __be_tmp = self.safe_number_k(feeCopy.clone(), "rate", &[]); add_element_to_object(&mut feeCopy, &Value::Str("rate".into()), __be_tmp); };
3103 }
3104 append_to_array(&mut reducedFees, feeCopy);
3105 }
3106 add_element_to_object(&mut orderDict, &Value::Str("fees".into()), reducedFees.clone());
3107 if parseFee && (reducedLength == 1.0) {
3108 add_element_to_object(&mut orderDict, &Value::Str("fee".into()), reducedFees.as_array().and_then(|__arr| __arr.get(0)).cloned().unwrap_or(Value::Null));
3109 }
3110 }
3111 if (amount == Value::Null) {
3112 if (filled != Value::Null) && (remaining != Value::Null) {
3114 amount = crate::precise::Precise::stringAdd(&filled, &remaining);
3115 } else if (status.as_str() == Some("closed")) {
3116 amount = filled.clone();
3117 }
3118 }
3119 if (filled == Value::Null) {
3120 if (amount != Value::Null) && (remaining != Value::Null) {
3121 filled = crate::precise::Precise::stringSub(&amount, &remaining);
3122 } else if (status.as_str() == Some("closed")) && (amount != Value::Null) {
3123 filled = amount.clone();
3124 }
3125 }
3126 if (remaining == Value::Null) {
3127 if (amount != Value::Null) && (filled != Value::Null) {
3128 remaining = crate::precise::Precise::stringSub(&amount, &filled);
3129 } else if (status.as_str() == Some("closed")) {
3130 remaining = Value::Str("0".into());
3131 }
3132 }
3133 let mut inverse: Value = self.safe_bool_k(market.clone(), "inverse", &[Value::Bool(false)]);
3135 let mut contractSize: Value = self.number_to_string(self.safe_value_k(market, "contractSize", &[Value::Int(1)]));
3136 if (average == Value::Null) {
3142 if (filled != Value::Null) && (cost != Value::Null) && is_true(&crate::precise::Precise::stringGt(&filled, &Value::Str("0".into()))) {
3143 let mut filledTimesContractSize: Value = crate::precise::Precise::stringMul(&filled, &contractSize);
3144 if (inverse.as_bool() == Some(true)) {
3145 average = crate::precise::Precise::stringDiv(&filledTimesContractSize, &cost);
3146 } else {
3147 average = crate::precise::Precise::stringDiv(&cost, &filledTimesContractSize);
3148 }
3149 }
3150 }
3151 let mut costPriceExists: bool = (average != Value::Null) || (price != Value::Null);
3158 if parseCost && (filled != Value::Null) && costPriceExists {
3159 let mut multiplyPrice: Value = Value::Null;
3160 if (average == Value::Null) {
3161 multiplyPrice = price.clone();
3162 } else {
3163 multiplyPrice = average.clone();
3164 }
3165 let mut filledTimesContractSize: Value = crate::precise::Precise::stringMul(&filled, &contractSize);
3167 if (inverse.as_bool() == Some(true)) {
3168 cost = crate::precise::Precise::stringDiv(&filledTimesContractSize, &multiplyPrice);
3169 } else {
3170 cost = crate::precise::Precise::stringMul(&filledTimesContractSize, &multiplyPrice);
3171 }
3172 }
3173 let mut orderType: Value = self.safe_value_k(orderDict.clone(), "type", &[]);
3175 let mut emptyPrice: bool = (price == Value::Null) || is_true(&crate::precise::Precise::stringEquals(&price, &Value::Str("0".into())));
3176 if emptyPrice && (orderType.as_str() == Some("market")) {
3177 price = average.clone();
3178 }
3179 {
3180 let mut i: Value = Value::Int(0);
3181 let mut __for_first_96: bool = true;
3182 while { if !__for_first_96 { i = (match (&(i), &(Value::Int(1))) { (Value::Int(x), Value::Int(y)) => Value::Int(x + y), (Value::Int(x), Value::Float(y)) => Value::Float(*x as f64 + *y), (Value::Float(x), Value::Int(y)) => Value::Float(*x + *y as f64), (Value::Float(x), Value::Float(y)) => Value::Float(x + y), _ => Value::Null }); } __for_first_96 = false; i.as_f64().unwrap_or(f64::NAN) < ((trades.len() as i64) as f64) } {
3183 let mut entry: Value = get_value(&trades, &i);
3184 let mut entry: Value = get_value(&trades, &i);
3185 { let __be_tmp = self.safe_number_k(entry.clone(), "amount", &[]); add_element_to_object(&mut entry, &Value::Str("amount".into()), __be_tmp); };
3186 { let __be_tmp = self.safe_number_k(entry.clone(), "price", &[]); add_element_to_object(&mut entry, &Value::Str("price".into()), __be_tmp); };
3187 { let __be_tmp = self.safe_number_k(entry.clone(), "cost", &[]); add_element_to_object(&mut entry, &Value::Str("cost".into()), __be_tmp); };
3188 let mut tradeFee: Value = self.safe_dict_k(entry.clone(), "fee", &[Value::Map({
3189 let mut m = indexmap::IndexMap::new();
3190 m
3191})]);
3192 { 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); } }
3193 if (matches!(&tradeFee, Value::Dict(__d) if __d.contains_key("rate"))) {
3194 { 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); } }
3195 }
3196 let mut entryFees: Value = self.safe_list_k(entry.clone(), "fees", &[Value::from(vec![])]);
3197 {
3198 let mut j: Value = Value::Int(0);
3199 let mut __for_first_95: bool = true;
3200 while { if !__for_first_95 { j = (match (&(j), &(Value::Int(1))) { (Value::Int(x), Value::Int(y)) => Value::Int(x + y), (Value::Int(x), Value::Float(y)) => Value::Float(*x as f64 + *y), (Value::Float(x), Value::Int(y)) => Value::Float(*x + *y as f64), (Value::Float(x), Value::Float(y)) => Value::Float(x + y), _ => Value::Null }); } __for_first_95 = false; j.as_f64().unwrap_or(f64::NAN) < ((entryFees.len() as i64) as f64) } {
3201 { 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); };
3202 }
3203 }
3204 add_element_to_object(&mut entry, &Value::Str("fees".into()), entryFees);
3205 add_element_to_object(&mut entry, &Value::Str("fee".into()), tradeFee);
3206 }
3207 }
3208 let mut timeInForce: Value = self.safe_string_k(orderDict.clone(), "timeInForce", &[]);
3209 let mut postOnly: Value = self.safe_value_k(orderDict.clone(), "postOnly", &[]);
3210 if (timeInForce == Value::Null) {
3212 if !isTriggerOrSLTpOrder && (self.safe_string_k(orderDict.clone(), "type", &[]).as_str() == Some("market")) {
3213 timeInForce = Value::Str("IOC".into());
3214 }
3215 if is_equal(&postOnly, &Value::Bool(true)) {
3217 timeInForce = Value::Str("PO".into());
3218 }
3219 } else if (postOnly == Value::Null) {
3220 postOnly = Value::Bool(timeInForce.as_str() == Some("PO"));
3222 }
3223 let mut timestamp: Value = self.safe_integer_k(orderDict.clone(), "timestamp", &[]);
3224 let mut lastUpdateTimestamp: Value = self.safe_integer_k(orderDict.clone(), "lastUpdateTimestamp", &[]);
3225 let mut datetime: Value = self.safe_string_k(orderDict.clone(), "datetime", &[]);
3226 if (datetime == Value::Null) {
3227 datetime = self.iso8601(timestamp.clone());
3228 }
3229 let mut triggerPrice: Value = self.parse_number(self.safe_string2(orderDict.clone(), Value::Str("triggerPrice".into()), Value::Str("stopPrice".into()), &[]), &[]);
3230 let mut takeProfitPrice: Value = self.parse_number(self.safe_string_k(orderDict.clone(), "takeProfitPrice", &[]), &[]);
3231 let mut stopLossPrice: Value = self.parse_number(self.safe_string_k(orderDict.clone(), "stopLossPrice", &[]), &[]);
3232 return self.extend(orderDict.clone(), &[Value::Map({
3233 let mut m = indexmap::IndexMap::new();
3234 m.insert("id".to_string(), self.safe_string_k(orderDict.clone(), "id", &[]));
3235 m.insert("clientOrderId".to_string(), self.safe_string_k(orderDict.clone(), "clientOrderId", &[]));
3236 m.insert("timestamp".to_string(), timestamp);
3237 m.insert("datetime".to_string(), datetime);
3238 m.insert("symbol".to_string(), symbol);
3239 m.insert("type".to_string(), self.safe_string_k(orderDict.clone(), "type", &[]));
3240 m.insert("side".to_string(), side);
3241 m.insert("lastTradeTimestamp".to_string(), lastTradeTimeTimestamp);
3242 m.insert("lastUpdateTimestamp".to_string(), lastUpdateTimestamp);
3243 m.insert("price".to_string(), self.parse_number(price, &[]));
3244 m.insert("amount".to_string(), self.parse_number(amount, &[]));
3245 m.insert("cost".to_string(), self.parse_number(cost, &[]));
3246 m.insert("average".to_string(), self.parse_number(average, &[]));
3247 m.insert("filled".to_string(), self.parse_number(filled, &[]));
3248 m.insert("remaining".to_string(), self.parse_number(remaining, &[]));
3249 m.insert("timeInForce".to_string(), timeInForce);
3250 m.insert("postOnly".to_string(), postOnly);
3251 m.insert("trades".to_string(), trades);
3252 m.insert("reduceOnly".to_string(), self.safe_value_k(orderDict.clone(), "reduceOnly", &[]));
3253 m.insert("stopPrice".to_string(), triggerPrice.clone());
3254 m.insert("triggerPrice".to_string(), triggerPrice);
3255 m.insert("takeProfitPrice".to_string(), takeProfitPrice);
3256 m.insert("stopLossPrice".to_string(), stopLossPrice);
3257 m.insert("status".to_string(), status);
3258 m.insert("fee".to_string(), self.safe_value_k(orderDict, "fee", &[]));
3259 m
3260})]);
3261
3262 Value::Null
3263}
3264
3265 fn parse_orders(&self, mut orders: Value, optional_args: &[Value]) -> Value {
3266 let mut market = get_arg(optional_args, 0, Value::Null);
3267 let mut since = get_arg(optional_args, 1, Value::Null);
3268 let mut limit = get_arg(optional_args, 2, Value::Null);
3269 let mut params = get_arg(optional_args, 3, Value::Map({
3270 let mut m = indexmap::IndexMap::new();
3271 m
3272}));
3273 if (orders == Value::Null) {
3295 return Value::from(vec![]);
3296 }
3297 let mut results: Value = Value::from(vec![]);
3298 if (matches!(&orders, Value::Arr(_))) {
3299 {
3300 let mut i: Value = Value::Int(0);
3301 let mut __for_first_97: bool = true;
3302 while { if !__for_first_97 { i = (match (&(i), &(Value::Int(1))) { (Value::Int(x), Value::Int(y)) => Value::Int(x + y), (Value::Int(x), Value::Float(y)) => Value::Float(*x as f64 + *y), (Value::Float(x), Value::Int(y)) => Value::Float(*x + *y as f64), (Value::Float(x), Value::Float(y)) => Value::Float(x + y), _ => Value::Null }); } __for_first_97 = false; i.as_f64().unwrap_or(f64::NAN) < ((orders.len() as i64) as f64) } {
3303 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()]);
3305 append_to_array(&mut results, order.clone());
3306 }
3307 }
3308 } else {
3309 let mut ids: Value = object_keys(&orders);
3310 {
3311 let mut i: Value = Value::Int(0);
3312 let mut __for_first_98: bool = true;
3313 while { if !__for_first_98 { i = (match (&(i), &(Value::Int(1))) { (Value::Int(x), Value::Int(y)) => Value::Int(x + y), (Value::Int(x), Value::Float(y)) => Value::Float(*x as f64 + *y), (Value::Float(x), Value::Int(y)) => Value::Float(*x + *y as f64), (Value::Float(x), Value::Float(y)) => Value::Float(x + y), _ => Value::Null }); } __for_first_98 = false; i.as_f64().unwrap_or(f64::NAN) < ((ids.len() as i64) as f64) } {
3314 let mut id: Value = ids.as_array().and_then(|__arr| match &i { Value::Int(__n) => __arr.get(*__n as usize), Value::Str(__s) => __s.parse::<usize>().ok().and_then(|__n| __arr.get(__n)), _ => None }).cloned().unwrap_or(Value::Null);
3315 let mut idExtended: Value = self.extend(Value::Map({
3316 let mut m = indexmap::IndexMap::new();
3317 m.insert("id".to_string(), id.clone());
3318 m
3319 }), &[get_value(&orders, &id)]);
3320 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()]);
3322 append_to_array(&mut results, order);
3323 }
3324 }
3325 }
3326 results = self.sort_by(results.clone(), Value::Str("timestamp".into()), &[]);
3327 let mut symbol: Value = self.safe_string_k(market, "symbol", &[]);
3328 return self.filter_by_symbol_since_limit(results, &[symbol, since, limit]);
3329
3330 Value::Null
3331}
3332
3333 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 {
3334 let mut takerOrMaker = get_arg(optional_args, 0, Value::Str("taker".into()));
3335 let mut feeRate = get_arg(optional_args, 1, Value::Null);
3336 let mut params = get_arg(optional_args, 2, Value::Map({
3337 let mut m = indexmap::IndexMap::new();
3338 m
3339}));
3340 if (type_var.as_str() == Some("market")) && (takerOrMaker.as_str() == Some("maker")) {
3341 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()))));
3342 }
3343 let mut markets: Value = self.markets.clone();
3344 if (markets == Value::Null) {
3345 panic!("{}", crate::exchange_errors::exchange_error(format!("{}{}", self.id.clone(), Value::Str(" markets not loaded".into()))));
3346 }
3347 let mut market: Value = get_value(&markets, &symbol);
3348 let mut market: Value = get_value(&markets, &symbol);
3349 let mut feeSide: Option<String> = self.safe_string_k(market.clone(), "feeSide", &[Value::Str("quote".into())]).as_str().map(str::to_owned);
3350 let mut useQuote: Value = Value::Null;
3351 if (feeSide.as_deref() == Some("get")) {
3352 useQuote = Value::Bool(side.as_str() == Some("sell"));
3354 } else if (feeSide.as_deref() == Some("give")) {
3355 useQuote = Value::Bool(side.as_str() == Some("buy"));
3357 } else {
3358 useQuote = Value::Bool(feeSide.as_deref() == Some("quote"));
3360 }
3361 let mut cost: Value = self.number_to_string(amount);
3362 let mut key: Value = Value::Null;
3363 if useQuote.as_bool() == Some(true) {
3364 let mut priceString: Value = self.number_to_string(price);
3365 cost = crate::precise::Precise::stringMul(&cost, &priceString);
3366 key = Value::Str("quote".into());
3367 } else {
3368 key = Value::Str("base".into());
3369 }
3370 if !is_equal(&crate::value::get_value_k(&market, "spot"), &Value::Bool(true)) {
3372 key = Value::Str("settle".into());
3373 }
3374 let mut takerOrMakerResolved: Value = (if (type_var.as_str() == Some("market")) { Value::Str("taker".into()) } else { takerOrMaker });
3376 let mut rate: Value = (if (feeRate != Value::Null) { self.number_to_string(feeRate) } else { self.safe_string(market.clone(), takerOrMakerResolved.clone(), &[]) });
3377 cost = crate::precise::Precise::stringMul(&cost, &rate);
3378 return Value::Map({
3379 let mut m = indexmap::IndexMap::new();
3380 m.insert("type".to_string(), takerOrMakerResolved);
3381 m.insert("currency".to_string(), get_value(&market, &key));
3382 m.insert("rate".to_string(), self.parse_number(rate, &[]));
3383 m.insert("cost".to_string(), self.parse_number(cost, &[]));
3384 m
3385});
3386
3387 Value::Null
3388}
3389
3390 fn calculate_fee(&self, mut symbol: Value, mut type_var: Value, mut side: Value, mut amount: Value, mut price: Value, optional_args: &[Value]) -> Value {
3391 let mut takerOrMaker = get_arg(optional_args, 0, Value::Str("taker".into()));
3392 let mut params = get_arg(optional_args, 1, Value::Map({
3393 let mut m = indexmap::IndexMap::new();
3394 m
3395}));
3396 return self.calculate_fee_with_rate(symbol, type_var, side, amount, price, &[takerOrMaker, Value::Null, params]);
3397
3398 Value::Null
3399}
3400
3401 fn safe_liquidation(&self, mut liquidation: Value, optional_args: &[Value]) -> Value {
3402 let mut market = get_arg(optional_args, 0, Value::Null);
3403 let __market_empty = indexmap::IndexMap::new();
3404 let market = market.as_map().unwrap_or(&__market_empty);
3405 let mut contracts: Value = self.safe_string_k(liquidation.clone(), "contracts", &[]);
3406 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 });
3407 let mut price: Value = self.safe_string_k(liquidation.clone(), "price", &[]);
3408 let mut baseValue: Value = self.safe_string_k(liquidation.clone(), "baseValue", &[]);
3409 let mut quoteValue: Value = self.safe_string_k(liquidation.clone(), "quoteValue", &[]);
3410 if (baseValue == Value::Null) && (contracts != Value::Null) && (contractSize != Value::Null) && (price != Value::Null) {
3411 baseValue = crate::precise::Precise::stringMul(&contracts, &contractSize);
3412 }
3413 if (quoteValue == Value::Null) && (baseValue != Value::Null) && (price != Value::Null) {
3414 quoteValue = crate::precise::Precise::stringMul(&baseValue, &price);
3415 }
3416 if let Value::Dict(__d) = &mut liquidation { std::sync::Arc::make_mut(__d).insert("contracts".into(), self.parse_number(contracts, &[])); }
3417 if let Value::Dict(__d) = &mut liquidation { std::sync::Arc::make_mut(__d).insert("contractSize".into(), self.parse_number(contractSize, &[])); }
3418 if let Value::Dict(__d) = &mut liquidation { std::sync::Arc::make_mut(__d).insert("price".into(), self.parse_number(price, &[])); }
3419 if let Value::Dict(__d) = &mut liquidation { std::sync::Arc::make_mut(__d).insert("baseValue".into(), self.parse_number(baseValue, &[])); }
3420 if let Value::Dict(__d) = &mut liquidation { std::sync::Arc::make_mut(__d).insert("quoteValue".into(), self.parse_number(quoteValue, &[])); }
3421 return liquidation;
3422
3423 Value::Null
3424}
3425
3426 fn safe_trade(&self, mut trade: Value, optional_args: &[Value]) -> Value {
3427 let mut market = get_arg(optional_args, 0, Value::Null);
3428 let __market_empty = indexmap::IndexMap::new();
3429 let market = market.as_map().unwrap_or(&__market_empty);
3430 let mut amount: Value = self.safe_string_k(trade.clone(), "amount", &[]);
3431 let mut price: Value = self.safe_string_k(trade.clone(), "price", &[]);
3432 let mut cost: Value = self.safe_string_k(trade.clone(), "cost", &[]);
3433 if (cost == Value::Null) {
3434 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 });
3436 let mut multiplyPrice: Value = price.clone();
3437 if (contractSize != Value::Null) {
3438 let mut inverse: Value = (match market.get("inverse") { Some(Value::Bool(__b)) => Value::Bool(*__b), _ => Value::Bool(false) });
3439 if (inverse.as_bool() == Some(true)) {
3440 multiplyPrice = crate::precise::Precise::stringDiv(&Value::Str("1".into()), &price);
3441 }
3442 multiplyPrice = crate::precise::Precise::stringMul(&multiplyPrice, &contractSize);
3443 }
3444 cost = crate::precise::Precise::stringMul(&multiplyPrice, &amount);
3445 }
3446 let mut resultFeeresultFeesVariable = self.parsed_fee_and_fees(trade.clone());
3447 let mut resultFee: Value = resultFeeresultFeesVariable.as_array().and_then(|__arr| __arr.get(0)).cloned().unwrap_or(Value::Null);
3448 let mut resultFees: Value = resultFeeresultFeesVariable.as_array().and_then(|__arr| __arr.get(1)).cloned().unwrap_or(Value::Null);
3449 if let Value::Dict(__d) = &mut trade { std::sync::Arc::make_mut(__d).insert("fee".into(), resultFee); }
3450 if let Value::Dict(__d) = &mut trade { std::sync::Arc::make_mut(__d).insert("fees".into(), resultFees); }
3451 if let Value::Dict(__d) = &mut trade { std::sync::Arc::make_mut(__d).insert("amount".into(), self.parse_number(amount, &[])); }
3452 if let Value::Dict(__d) = &mut trade { std::sync::Arc::make_mut(__d).insert("price".into(), self.parse_number(price, &[])); }
3453 if let Value::Dict(__d) = &mut trade { std::sync::Arc::make_mut(__d).insert("cost".into(), self.parse_number(cost, &[])); }
3454 return trade;
3455
3456 Value::Null
3457}
3458
3459 fn create_ccxt_trade_id(&self, optional_args: &[Value]) -> Value {
3460 let mut timestamp = get_arg(optional_args, 0, Value::Null);
3461 let mut side = get_arg(optional_args, 1, Value::Null);
3462 let mut amount = get_arg(optional_args, 2, Value::Null);
3463 let mut price = get_arg(optional_args, 3, Value::Null);
3464 let mut takerOrMaker = get_arg(optional_args, 4, Value::Null);
3465 let mut id: Value = Value::Null;
3467 if (timestamp != Value::Null) {
3468 id = self.number_to_string(timestamp);
3469 if (side != Value::Null) {
3470 id = Value::Str(format!("{}{}", id, Value::Str(format!("{}{}", Value::Str("-".into()), side).into())).into());
3471 }
3472 if (amount != Value::Null) {
3473 id = Value::Str(format!("{}{}", id, Value::Str(format!("{}{}", Value::Str("-".into()), self.number_to_string(amount)).into())).into());
3474 }
3475 if (price != Value::Null) {
3476 id = Value::Str(format!("{}{}", id, Value::Str(format!("{}{}", Value::Str("-".into()), self.number_to_string(price)).into())).into());
3477 }
3478 if (takerOrMaker != Value::Null) {
3479 id = Value::Str(format!("{}{}", id, Value::Str(format!("{}{}", Value::Str("-".into()), takerOrMaker).into())).into());
3480 }
3481 }
3482 return id;
3483
3484 Value::Null
3485}
3486
3487 fn parsed_fee_and_fees(&self, mut container: Value) -> Value {
3488 let mut fee: Value = self.safe_dict_k(container.clone(), "fee", &[]);
3489 let mut fees: Value = self.safe_list_k(container, "fees", &[]);
3490 let mut feeDefined: bool = fee != Value::Null;
3491 let mut feesDefined: bool = fees != Value::Null;
3492 let mut shouldParseFees: bool = feeDefined || feesDefined;
3494 if shouldParseFees {
3495 if feeDefined {
3496 fee = self.parse_fee_numeric(fee.clone());
3497 }
3498 if !feesDefined {
3499 fees = Value::from(vec![fee.clone()]);
3501 }
3502 let mut reducedFees: Value = fees.clone();
3504 if is_true(&self.reduceFees) {
3505 reducedFees = self.reduce_fees_by_currency(fees.clone());
3506 }
3507 if (reducedFees == Value::Null) {
3508 reducedFees = Value::from(vec![]);
3509 }
3510 let mut reducedLength: f64 = ((reducedFees.len() as i64) as f64);
3511 {
3512 let mut i: Value = Value::Int(0);
3513 let mut __for_first_99: bool = true;
3514 while { if !__for_first_99 { i = (match (&(i), &(Value::Int(1))) { (Value::Int(x), Value::Int(y)) => Value::Int(x + y), (Value::Int(x), Value::Float(y)) => Value::Float(*x as f64 + *y), (Value::Float(x), Value::Int(y)) => Value::Float(*x + *y as f64), (Value::Float(x), Value::Float(y)) => Value::Float(x + y), _ => Value::Null }); } __for_first_99 = false; i.as_f64().unwrap_or(f64::NAN) < reducedLength } {
3515 { let __be_tmp = self.parse_fee_numeric(get_value(&reducedFees, &i)); add_element_to_object(&mut reducedFees, &i, __be_tmp); };
3516 }
3517 }
3518 fees = reducedFees.clone();
3519 if (reducedLength == 1.0) {
3520 fee = reducedFees.as_array().and_then(|__arr| __arr.get(0)).cloned().unwrap_or(Value::Null);
3521 } else if (reducedLength == 0.0) {
3522 fee = Value::Null;
3523 }
3524 }
3525 if (fee == Value::Null) {
3527 fee = Value::Map({
3528 let mut m = indexmap::IndexMap::new();
3529 m.insert("cost".to_string(), Value::Null);
3530 m.insert("currency".to_string(), Value::Null);
3531 m
3532 });
3533 }
3534 if (fees == Value::Null) {
3535 fees = Value::from(vec![]);
3536 }
3537 return Value::from(vec![fee, fees]);
3538
3539 Value::Null
3540}
3541
3542 fn parse_fee_numeric(&self, mut fee: Value) -> Value {
3543 { 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()))) {
3545 { let __be_tmp = self.safe_number_k(fee.clone(), "rate", &[]); add_element_to_object(&mut fee, &Value::Str("rate".into()), __be_tmp); };
3546 }
3547 return fee;
3548
3549 Value::Null
3550}
3551
3552 fn find_nearest_ceiling(&self, mut arr: Value, mut providedValue: Value) -> Value {
3553 let mut length: Value = Value::Int(arr.len() as i64);
3555 {
3556 let mut i: Value = Value::Int(0);
3557 let mut __for_first_100: bool = true;
3558 while { if !__for_first_100 { i = (match (&(i), &(Value::Int(1))) { (Value::Int(x), Value::Int(y)) => Value::Int(x + y), (Value::Int(x), Value::Float(y)) => Value::Float(*x as f64 + *y), (Value::Float(x), Value::Int(y)) => Value::Float(*x + *y as f64), (Value::Float(x), Value::Float(y)) => Value::Float(x + y), _ => Value::Null }); } __for_first_100 = false; i.as_f64().unwrap_or(f64::NAN) < length.as_f64().unwrap_or(f64::NAN) } {
3559 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);
3560 if providedValue.as_f64().unwrap_or(f64::NAN) <= current.as_f64().unwrap_or(f64::NAN) {
3561 return current;
3562 }
3563 }
3564 }
3565 return get_value(&arr, &(match (&(length), &(Value::Int(1))) { (Value::Int(x), Value::Int(y)) => Value::Int(x - y), (Value::Int(x), Value::Float(y)) => Value::Float(*x as f64 - *y), (Value::Float(x), Value::Int(y)) => Value::Float(*x - *y as f64), (Value::Float(x), Value::Float(y)) => Value::Float(x - y), _ => Value::Null }));
3566
3567 Value::Null
3568}
3569
3570 fn add_key_in_array_items(&self, mut obj: Value, mut keyName: Value) -> Value {
3571 let mut result: Value = Value::from(vec![]);
3572 let mut keys: Value = object_keys(&obj);
3573 {
3574 let mut i: Value = Value::Int(0);
3575 let mut __for_first_101: bool = true;
3576 while { if !__for_first_101 { i = (match (&(i), &(Value::Int(1))) { (Value::Int(x), Value::Int(y)) => Value::Int(x + y), (Value::Int(x), Value::Float(y)) => Value::Float(*x as f64 + *y), (Value::Float(x), Value::Int(y)) => Value::Float(*x + *y as f64), (Value::Float(x), Value::Float(y)) => Value::Float(x + y), _ => Value::Null }); } __for_first_101 = false; i.as_f64().unwrap_or(f64::NAN) < ((keys.len() as i64) as f64) } {
3577 let mut key: Value = keys.as_array().and_then(|__arr| match &i { Value::Int(__n) => __arr.get(*__n as usize), Value::Str(__s) => __s.parse::<usize>().ok().and_then(|__n| __arr.get(__n)), _ => None }).cloned().unwrap_or(Value::Null);
3578 let mut item: Value = get_value(&obj, &key);
3579 let mut item: Value = get_value(&obj, &key);
3580 if (item == Value::Null) {
3581 continue;
3582 }
3583 let mut itemWithKey: Value = self.extend(Value::Map({
3584 let mut m = indexmap::IndexMap::new();
3585 m
3586 }), &[item]);
3587 add_element_to_object(&mut itemWithKey, &keyName, key);
3588 append_to_array(&mut result, itemWithKey);
3589 }
3590 }
3591 return result;
3592
3593 Value::Null
3594}
3595
3596 fn invert_flat_string_dictionary(&self, mut dict: Value) -> Value {
3597 let mut reversed: Value = Value::Map({
3598 let mut m = indexmap::IndexMap::new();
3599 m
3600 });
3601 let mut keys: Value = object_keys(&dict);
3602 {
3603 let mut i: Value = Value::Int(0);
3604 let mut __for_first_102: bool = true;
3605 while { if !__for_first_102 { i = (match (&(i), &(Value::Int(1))) { (Value::Int(x), Value::Int(y)) => Value::Int(x + y), (Value::Int(x), Value::Float(y)) => Value::Float(*x as f64 + *y), (Value::Float(x), Value::Int(y)) => Value::Float(*x + *y as f64), (Value::Float(x), Value::Float(y)) => Value::Float(x + y), _ => Value::Null }); } __for_first_102 = false; i.as_f64().unwrap_or(f64::NAN) < ((keys.len() as i64) as f64) } {
3606 let mut key: Value = keys.as_array().and_then(|__arr| match &i { Value::Int(__n) => __arr.get(*__n as usize), Value::Str(__s) => __s.parse::<usize>().ok().and_then(|__n| __arr.get(__n)), _ => None }).cloned().unwrap_or(Value::Null);
3607 let mut value: Value = get_value(&dict, &key);
3608 let mut value: Value = get_value(&dict, &key);
3609 if matches!(&value, Value::Str(_)) {
3610 if let Value::Dict(__d) = &mut reversed { std::sync::Arc::make_mut(__d).insert(crate::runtime::stringify_param(&value), key); }
3611 }
3612 }
3613 }
3614 return reversed;
3615
3616 Value::Null
3617}
3618
3619 fn string_to_base16(&self, mut str_val: Value) -> Value {
3620 return Value::Str(format!("{}{}", Value::Str("0x".into()), self.binary_to_base16(self.base64_to_binary(self.string_to_base64(str_val, &[]), &[]), &[])).into());
3621
3622 Value::Null
3623}
3624
3625 fn reduce_fees_by_currency(&self, mut fees: Value) -> Value {
3626 let mut reduced: Value = Value::Map({
3672 let mut m = indexmap::IndexMap::new();
3673 m
3674 });
3675 {
3676 let mut i: Value = Value::Int(0);
3677 let mut __for_first_103: bool = true;
3678 while { if !__for_first_103 { i = (match (&(i), &(Value::Int(1))) { (Value::Int(x), Value::Int(y)) => Value::Int(x + y), (Value::Int(x), Value::Float(y)) => Value::Float(*x as f64 + *y), (Value::Float(x), Value::Int(y)) => Value::Float(*x + *y as f64), (Value::Float(x), Value::Float(y)) => Value::Float(x + y), _ => Value::Null }); } __for_first_103 = false; i.as_f64().unwrap_or(f64::NAN) < get_array_length(&fees).as_f64().unwrap_or(f64::NAN) } {
3679 let mut fee: Value = get_value(&fees, &i);
3680 let mut fee: Value = get_value(&fees, &i);
3681 let mut code: Value = self.safe_string_k(fee.clone(), "currency", &[]);
3682 let mut feeCurrencyCode: Value = (if (code != Value::Null) { code.clone() } else { to_string_val(&i) });
3683 if (feeCurrencyCode != Value::Null) {
3684 let mut rate: Value = self.safe_string_k(fee.clone(), "rate", &[]);
3685 let mut cost: Value = self.safe_string_k(fee, "cost", &[]);
3686 if (cost == Value::Null) {
3687 continue;
3688 }
3689 if !(in_op(&reduced, &feeCurrencyCode)) {
3690 if let Value::Dict(__d) = &mut reduced { std::sync::Arc::make_mut(__d).insert(crate::runtime::stringify_param(&feeCurrencyCode), Value::Map({
3691 let mut m = indexmap::IndexMap::new();
3692 m
3693})); }
3694 }
3695 let mut rateKey: Value = (if (rate == Value::Null) { Value::Str("".into()) } else { rate.clone() });
3696 if (in_op(&reduced.as_map().and_then(|__m| feeCurrencyCode.as_str().and_then(|__k| __m.get(__k))).cloned().unwrap_or(Value::Null), &rateKey)) {
3697 { let __be_tmp = crate::precise::Precise::stringAdd(&crate::value::get_value_k(&get_value(&get_value(&reduced, &feeCurrencyCode), &rateKey), "cost"), &cost); add_element_to_object(get_value_mut(get_value_mut(&mut reduced, &feeCurrencyCode), &rateKey), &Value::Str("cost".into()), __be_tmp); };
3698 } else {
3699 add_element_to_object(get_value_mut(&mut reduced, &feeCurrencyCode), &rateKey, Value::Map({
3700 let mut m = indexmap::IndexMap::new();
3701 m.insert("currency".to_string(), code);
3702 m.insert("cost".to_string(), cost);
3703 m
3704}));
3705 if (rate != Value::Null) {
3706 add_element_to_object(get_value_mut(get_value_mut(&mut reduced, &feeCurrencyCode), &rateKey), &Value::Str("rate".into()), rate);
3707 }
3708 }
3709 }
3710 }
3711 }
3712 let mut result: Value = Value::from(vec![]);
3713 let mut feeValues: Value = object_values(&reduced);
3714 {
3715 let mut i: Value = Value::Int(0);
3716 let mut __for_first_104: bool = true;
3717 while { if !__for_first_104 { i = (match (&(i), &(Value::Int(1))) { (Value::Int(x), Value::Int(y)) => Value::Int(x + y), (Value::Int(x), Value::Float(y)) => Value::Float(*x as f64 + *y), (Value::Float(x), Value::Int(y)) => Value::Float(*x + *y as f64), (Value::Float(x), Value::Float(y)) => Value::Float(x + y), _ => Value::Null }); } __for_first_104 = false; i.as_f64().unwrap_or(f64::NAN) < ((feeValues.len() as i64) as f64) } {
3718 let mut reducedFeeValues: Value = object_values(&feeValues.as_array().and_then(|__arr| match &i { Value::Int(__n) => __arr.get(*__n as usize), Value::Str(__s) => __s.parse::<usize>().ok().and_then(|__n| __arr.get(__n)), _ => None }).cloned().unwrap_or(Value::Null));
3719 result = self.array_concat(result.clone(), reducedFeeValues);
3720 }
3721 }
3722 return result;
3723
3724 Value::Null
3725}
3726
3727 fn safe_ticker(&self, mut ticker: Value, optional_args: &[Value]) -> Value {
3728 let mut market = get_arg(optional_args, 0, Value::Null);
3729 let mut open: Value = self.omit_zero(self.safe_string_k(ticker.clone(), "open", &[]));
3730 let mut close: Value = self.omit_zero(self.safe_string2(ticker.clone(), Value::Str("close".into()), Value::Str("last".into()), &[]));
3731 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", &[]));
3733 let mut average: Value = self.omit_zero(self.safe_string_k(ticker.clone(), "average", &[]));
3734 let mut vwap: Value = self.safe_string_k(ticker.clone(), "vwap", &[]);
3735 let mut baseVolume: Value = self.safe_string_k(ticker.clone(), "baseVolume", &[]);
3736 let mut quoteVolume: Value = self.safe_string_k(ticker.clone(), "quoteVolume", &[]);
3737 if (vwap == Value::Null) {
3738 vwap = crate::precise::Precise::stringDiv(&self.omit_zero(quoteVolume.clone()), &baseVolume);
3739 }
3740 if (change != Value::Null) {
3742 if (close == Value::Null) && (average != Value::Null) {
3743 close = crate::precise::Precise::stringAdd(&average, &crate::precise::Precise::stringDiv(&change, &Value::Str("2".into())));
3744 }
3745 if (open == Value::Null) && (close != Value::Null) {
3746 open = crate::precise::Precise::stringSub(&close, &change);
3747 }
3748 } else if (percentage != Value::Null) {
3749 if (close == Value::Null) && (average != Value::Null) {
3750 let mut openAddClose: Value = crate::precise::Precise::stringMul(&average, &Value::Str("2".into()));
3751 let mut denominator: Value = crate::precise::Precise::stringAdd(&Value::Str("2".into()), &crate::precise::Precise::stringDiv(&percentage, &Value::Str("100".into())));
3753 let mut calcOpen: Value = (if (open != Value::Null) { open.clone() } else { crate::precise::Precise::stringDiv(&openAddClose, &denominator) });
3754 close = crate::precise::Precise::stringMul(&calcOpen, &crate::precise::Precise::stringAdd(&Value::Str("1".into()), &crate::precise::Precise::stringDiv(&percentage, &Value::Str("100".into()))));
3755 }
3756 if (open == Value::Null) && (close != Value::Null) {
3757 open = crate::precise::Precise::stringDiv(&close, &crate::precise::Precise::stringAdd(&Value::Str("1".into()), &crate::precise::Precise::stringDiv(&percentage, &Value::Str("100".into()))));
3758 }
3759 }
3760 if (change == Value::Null) {
3762 if (close != Value::Null) && (open != Value::Null) {
3763 change = crate::precise::Precise::stringSub(&close, &open);
3764 } else if (close != Value::Null) && (percentage != Value::Null) {
3765 change = crate::precise::Precise::stringMul(&crate::precise::Precise::stringDiv(&percentage, &Value::Str("100".into())), &crate::precise::Precise::stringDiv(&close, &Value::Str("100".into())));
3766 } else if (open != Value::Null) && (percentage != Value::Null) {
3767 change = crate::precise::Precise::stringMul(&open, &crate::precise::Precise::stringDiv(&percentage, &Value::Str("100".into())));
3768 }
3769 }
3770 if (open != Value::Null) {
3772 if (percentage == Value::Null) && (change != Value::Null) {
3774 percentage = crate::precise::Precise::stringMul(&crate::precise::Precise::stringDiv(&change, &open), &Value::Str("100".into()));
3775 }
3776 if (close == Value::Null) && (change != Value::Null) {
3778 close = crate::precise::Precise::stringAdd(&open, &change);
3779 }
3780 if (close == Value::Null) && (average != Value::Null) {
3782 close = crate::precise::Precise::stringSub(&crate::precise::Precise::stringMul(&average, &Value::Str("2".into())), &open);
3784 }
3785 if (average == Value::Null) && (close != Value::Null) {
3787 let mut precision: Value = Value::Int(18);
3788 if (market != Value::Null) && self.is_tick_precision().as_bool() == Some(true) {
3789 let mut marketPrecision: Value = self.safe_dict_k(market, "precision", &[]);
3790 let mut precisionPrice: Value = self.safe_string_k(marketPrecision, "price", &[]);
3791 if (precisionPrice != Value::Null) {
3792 precision = self.precision_from_string(precisionPrice);
3793 }
3794 }
3795 average = crate::precise::Precise::stringDivPrec(&crate::precise::Precise::stringAdd(&open, &close), &Value::Str("2".into()), &precision);
3796 }
3797 }
3798 let mut closeParsed: Value = self.parse_number(self.omit_zero(close), &[]);
3801 return self.extend(ticker.clone(), &[Value::Map({
3802 let mut m = indexmap::IndexMap::new();
3803 m.insert("bid".to_string(), self.parse_number(self.omit_zero(self.safe_string_k(ticker.clone(), "bid", &[])), &[]));
3804 m.insert("bidVolume".to_string(), self.safe_number_k(ticker.clone(), "bidVolume", &[]));
3805 m.insert("ask".to_string(), self.parse_number(self.omit_zero(self.safe_string_k(ticker.clone(), "ask", &[])), &[]));
3806 m.insert("askVolume".to_string(), self.safe_number_k(ticker.clone(), "askVolume", &[]));
3807 m.insert("high".to_string(), self.parse_number(self.omit_zero(self.safe_string_k(ticker.clone(), "high", &[])), &[]));
3808 m.insert("low".to_string(), self.parse_number(self.omit_zero(self.safe_string_k(ticker.clone(), "low", &[])), &[]));
3809 m.insert("open".to_string(), self.parse_number(self.omit_zero(open), &[]));
3810 m.insert("close".to_string(), closeParsed.clone());
3811 m.insert("last".to_string(), closeParsed);
3812 m.insert("change".to_string(), self.parse_number(change, &[]));
3813 m.insert("percentage".to_string(), self.parse_number(percentage, &[]));
3814 m.insert("average".to_string(), self.parse_number(average, &[]));
3815 m.insert("vwap".to_string(), self.parse_number(vwap, &[]));
3816 m.insert("baseVolume".to_string(), self.parse_number(baseVolume, &[]));
3817 m.insert("quoteVolume".to_string(), self.parse_number(quoteVolume, &[]));
3818 m.insert("previousClose".to_string(), self.safe_number_k(ticker.clone(), "previousClose", &[]));
3819 m.insert("indexPrice".to_string(), self.safe_number_k(ticker.clone(), "indexPrice", &[]));
3820 m.insert("markPrice".to_string(), self.safe_number_k(ticker, "markPrice", &[]));
3821 m
3822})]);
3823
3824 Value::Null
3825}
3826
3827 fn fetch_borrow_rate(&mut self, mut code: Value, mut amount: Value, optional_args: &[Value]) -> impl ::std::future::Future<Output = Value> + Send { async move {
3828 let mut params = get_arg(optional_args, 0, Value::Map({
3829 let mut m = indexmap::IndexMap::new();
3830 m
3831}));
3832 panic!("{}", crate::exchange_errors::not_supported(format!("{}{}", self.id.clone(), Value::Str(" fetchBorrowRate is deprecated, please use fetchCrossBorrowRate or fetchIsolatedBorrowRate instead".into()))));
3833
3834 Value::Null
3835} }
3836
3837 fn repay_cross_margin(&mut self, mut code: Value, mut amount: Value, optional_args: &[Value]) -> impl ::std::future::Future<Output = Value> + Send { async move {
3838 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 {
3840 if !matches!(__v, crate::Value::Null) { return __v; }
3841 }
3842
3843 let mut params = get_arg(optional_args, 0, Value::Map({
3844 let mut m = indexmap::IndexMap::new();
3845 m
3846}));
3847 panic!("{}", crate::exchange_errors::not_supported(format!("{}{}", self.id.clone(), Value::Str(" repayCrossMargin is not support yet".into()))));
3848
3849 Value::Null
3850} }
3851
3852 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 {
3853 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 {
3855 if !matches!(__v, crate::Value::Null) { return __v; }
3856 }
3857
3858 let mut params = get_arg(optional_args, 0, Value::Map({
3859 let mut m = indexmap::IndexMap::new();
3860 m
3861}));
3862 panic!("{}", crate::exchange_errors::not_supported(format!("{}{}", self.id.clone(), Value::Str(" repayIsolatedMargin is not support yet".into()))));
3863
3864 Value::Null
3865} }
3866
3867 fn borrow_cross_margin(&mut self, mut code: Value, mut amount: Value, optional_args: &[Value]) -> impl ::std::future::Future<Output = Value> + Send { async move {
3868 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 {
3870 if !matches!(__v, crate::Value::Null) { return __v; }
3871 }
3872
3873 let mut params = get_arg(optional_args, 0, Value::Map({
3874 let mut m = indexmap::IndexMap::new();
3875 m
3876}));
3877 panic!("{}", crate::exchange_errors::not_supported(format!("{}{}", self.id.clone(), Value::Str(" borrowCrossMargin is not support yet".into()))));
3878
3879 Value::Null
3880} }
3881
3882 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 {
3883 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 {
3885 if !matches!(__v, crate::Value::Null) { return __v; }
3886 }
3887
3888 let mut params = get_arg(optional_args, 0, Value::Map({
3889 let mut m = indexmap::IndexMap::new();
3890 m
3891}));
3892 panic!("{}", crate::exchange_errors::not_supported(format!("{}{}", self.id.clone(), Value::Str(" borrowIsolatedMargin is not support yet".into()))));
3893
3894 Value::Null
3895} }
3896
3897 fn borrow_margin(&mut self, mut code: Value, mut amount: Value, optional_args: &[Value]) -> impl ::std::future::Future<Output = Value> + Send { async move {
3898 let mut symbol = get_arg(optional_args, 0, Value::Null);
3899 let mut params = get_arg(optional_args, 1, Value::Map({
3900 let mut m = indexmap::IndexMap::new();
3901 m
3902}));
3903 panic!("{}", crate::exchange_errors::not_supported(format!("{}{}", self.id.clone(), Value::Str(" borrowMargin is deprecated, please use borrowCrossMargin or borrowIsolatedMargin instead".into()))));
3904
3905 Value::Null
3906} }
3907
3908 fn repay_margin(&mut self, mut code: Value, mut amount: Value, optional_args: &[Value]) -> impl ::std::future::Future<Output = Value> + Send { async move {
3909 let mut symbol = get_arg(optional_args, 0, Value::Null);
3910 let mut params = get_arg(optional_args, 1, 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(" repayMargin is deprecated, please use repayCrossMargin or repayIsolatedMargin instead".into()))));
3915
3916 Value::Null
3917} }
3918
3919 fn fetch_ohlcv(&mut self, mut symbol: Value, optional_args: &[Value]) -> impl ::std::future::Future<Output = Value> + Send { async move {
3920 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 {
3922 if !matches!(__v, crate::Value::Null) { return __v; }
3923 }
3924
3925 let mut timeframe = get_arg(optional_args, 0, Value::Str("1m".into()));
3926 let mut since = get_arg(optional_args, 1, Value::Null);
3927 let mut limit = get_arg(optional_args, 2, Value::Null);
3928 let mut params = get_arg(optional_args, 3, Value::Map({
3929 let mut m = indexmap::IndexMap::new();
3930 m
3931}));
3932 let mut message: Value = Value::Str("".into());
3933 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)) {
3934 message = Value::Str(". If you want to build OHLCV candles from trade executions data, visit https://github.com/ccxt/ccxt/tree/master/examples/ and see \"build-ohlcv-bars\" file".into());
3935 }
3936 panic!("{}", crate::exchange_errors::not_supported(format!("{}{}", Value::Str(format!("{}{}", self.id.clone(), Value::Str(" fetchOHLCV() is not supported yet".into())).into()), message)));
3937
3938 Value::Null
3939} }
3940
3941 fn fetch_spot_ohlcv(&mut self, mut symbol: Value, optional_args: &[Value]) -> impl ::std::future::Future<Output = Value> + Send { async move {
3942 let mut timeframe = get_arg(optional_args, 0, Value::Str("1m".into()));
3943 let mut since = get_arg(optional_args, 1, Value::Null);
3944 let mut limit = get_arg(optional_args, 2, Value::Null);
3945 let mut params = get_arg(optional_args, 3, Value::Map({
3946 let mut m = indexmap::IndexMap::new();
3947 m
3948}));
3949 panic!("{}", crate::exchange_errors::not_supported(format!("{}{}", self.id.clone(), Value::Str(" fetchSpotOHLCV() is not supported yet".into()))));
3950
3951 Value::Null
3952} }
3953
3954 fn fetch_contract_ohlcv(&mut self, mut symbol: Value, optional_args: &[Value]) -> impl ::std::future::Future<Output = Value> + Send { async move {
3955 let mut timeframe = get_arg(optional_args, 0, Value::Str("1m".into()));
3956 let mut since = get_arg(optional_args, 1, Value::Null);
3957 let mut limit = get_arg(optional_args, 2, Value::Null);
3958 let mut params = get_arg(optional_args, 3, Value::Map({
3959 let mut m = indexmap::IndexMap::new();
3960 m
3961}));
3962 panic!("{}", crate::exchange_errors::not_supported(format!("{}{}", self.id.clone(), Value::Str(" fetchContractOHLCV() is not supported yet".into()))));
3963
3964 Value::Null
3965} }
3966
3967 fn fetch_ohlcv_ws(&mut self, mut symbol: Value, optional_args: &[Value]) -> impl ::std::future::Future<Output = Value> + Send { async move {
3968 let mut timeframe = get_arg(optional_args, 0, Value::Str("1m".into()));
3969 let mut since = get_arg(optional_args, 1, Value::Null);
3970 let mut limit = get_arg(optional_args, 2, Value::Null);
3971 let mut params = get_arg(optional_args, 3, Value::Map({
3972 let mut m = indexmap::IndexMap::new();
3973 m
3974}));
3975 let mut message: Value = Value::Str("".into());
3976 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)) {
3977 message = Value::Str(". If you want to build OHLCV candles from trade executions data, visit https://github.com/ccxt/ccxt/tree/master/examples/ and see \"build-ohlcv-bars\" file".into());
3978 }
3979 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)));
3980
3981 Value::Null
3982} }
3983
3984 fn watch_ohlcv(&mut self, mut symbol: Value, optional_args: &[Value]) -> impl ::std::future::Future<Output = Value> + Send { async move {
3985 let mut timeframe = get_arg(optional_args, 0, Value::Str("1m".into()));
3986 let mut since = get_arg(optional_args, 1, Value::Null);
3987 let mut limit = get_arg(optional_args, 2, Value::Null);
3988 let mut params = get_arg(optional_args, 3, Value::Map({
3989 let mut m = indexmap::IndexMap::new();
3990 m
3991}));
3992 panic!("{}", crate::exchange_errors::not_supported(format!("{}{}", self.id.clone(), Value::Str(" watchOHLCV() is not supported yet".into()))));
3993
3994 Value::Null
3995} }
3996
3997 fn convert_trading_view_to_ohlcv(&self, mut ohlcvs: Value, optional_args: &[Value]) -> Value {
3998 let mut timestamp = get_arg(optional_args, 0, Value::Str("t".into()));
3999 let mut open = get_arg(optional_args, 1, Value::Str("o".into()));
4000 let mut high = get_arg(optional_args, 2, Value::Str("h".into()));
4001 let mut low = get_arg(optional_args, 3, Value::Str("l".into()));
4002 let mut close = get_arg(optional_args, 4, Value::Str("c".into()));
4003 let mut volume = get_arg(optional_args, 5, Value::Str("v".into()));
4004 let mut ms = get_arg(optional_args, 6, Value::Bool(false));
4005 let mut result: Value = Value::from(vec![]);
4006 let mut timestamps: Value = self.safe_list(ohlcvs.clone(), timestamp, &[Value::from(vec![])]);
4007 let mut opens: Value = self.safe_list(ohlcvs.clone(), open, &[Value::from(vec![])]);
4008 let mut highs: Value = self.safe_list(ohlcvs.clone(), high, &[Value::from(vec![])]);
4009 let mut lows: Value = self.safe_list(ohlcvs.clone(), low, &[Value::from(vec![])]);
4010 let mut closes: Value = self.safe_list(ohlcvs.clone(), close, &[Value::from(vec![])]);
4011 let mut volumes: Value = self.safe_list(ohlcvs, volume, &[Value::from(vec![])]);
4012 {
4013 let mut i: Value = Value::Int(0);
4014 let mut __for_first_105: bool = true;
4015 while { if !__for_first_105 { i = (match (&(i), &(Value::Int(1))) { (Value::Int(x), Value::Int(y)) => Value::Int(x + y), (Value::Int(x), Value::Float(y)) => Value::Float(*x as f64 + *y), (Value::Float(x), Value::Int(y)) => Value::Float(*x + *y as f64), (Value::Float(x), Value::Float(y)) => Value::Float(x + y), _ => Value::Null }); } __for_first_105 = false; i.as_f64().unwrap_or(f64::NAN) < ((timestamps.len() as i64) as f64) } {
4016 append_to_array(&mut result, Value::from(vec![(if is_true(&ms) { self.safe_integer(timestamps.clone(), i.clone(), &[]) } else { self.safe_timestamp(timestamps.clone(), i.clone(), &[]) }), self.safe_value(opens.clone(), i.clone(), &[]), self.safe_value(highs.clone(), i.clone(), &[]), self.safe_value(lows.clone(), i.clone(), &[]), self.safe_value(closes.clone(), i.clone(), &[]), self.safe_value(volumes.clone(), i.clone(), &[])]));
4017 }
4018 }
4019 return result;
4020
4021 Value::Null
4022}
4023
4024 fn convert_ohlcv_to_trading_view(&self, mut ohlcvs: Value, optional_args: &[Value]) -> Value {
4025 let mut timestamp = get_arg(optional_args, 0, Value::Str("t".into()));
4026 let mut open = get_arg(optional_args, 1, Value::Str("o".into()));
4027 let mut high = get_arg(optional_args, 2, Value::Str("h".into()));
4028 let mut low = get_arg(optional_args, 3, Value::Str("l".into()));
4029 let mut close = get_arg(optional_args, 4, Value::Str("c".into()));
4030 let mut volume = get_arg(optional_args, 5, Value::Str("v".into()));
4031 let mut ms = get_arg(optional_args, 6, Value::Bool(false));
4032 let mut result: Value = Value::Map({
4033 let mut m = indexmap::IndexMap::new();
4034 m
4035 });
4036 if let Value::Dict(__d) = &mut result { std::sync::Arc::make_mut(__d).insert(crate::runtime::stringify_param(×tamp), Value::from(vec![])); }
4037 if let Value::Dict(__d) = &mut result { std::sync::Arc::make_mut(__d).insert(crate::runtime::stringify_param(&open), Value::from(vec![])); }
4038 if let Value::Dict(__d) = &mut result { std::sync::Arc::make_mut(__d).insert(crate::runtime::stringify_param(&high), Value::from(vec![])); }
4039 if let Value::Dict(__d) = &mut result { std::sync::Arc::make_mut(__d).insert(crate::runtime::stringify_param(&low), Value::from(vec![])); }
4040 if let Value::Dict(__d) = &mut result { std::sync::Arc::make_mut(__d).insert(crate::runtime::stringify_param(&close), Value::from(vec![])); }
4041 if let Value::Dict(__d) = &mut result { std::sync::Arc::make_mut(__d).insert(crate::runtime::stringify_param(&volume), Value::from(vec![])); }
4042 {
4043 let mut i: Value = Value::Int(0);
4044 let mut __for_first_106: bool = true;
4045 while { if !__for_first_106 { i = (match (&(i), &(Value::Int(1))) { (Value::Int(x), Value::Int(y)) => Value::Int(x + y), (Value::Int(x), Value::Float(y)) => Value::Float(*x as f64 + *y), (Value::Float(x), Value::Int(y)) => Value::Float(*x + *y as f64), (Value::Float(x), Value::Float(y)) => Value::Float(x + y), _ => Value::Null }); } __for_first_106 = false; i.as_f64().unwrap_or(f64::NAN) < ((ohlcvs.len() as i64) as f64) } {
4046 let mut ts: Value = (if is_true(&ms) { ohlcvs.as_array().and_then(|__arr| match &i { Value::Int(__n) => __arr.get(*__n as usize), Value::Str(__s) => __s.parse::<usize>().ok().and_then(|__n| __arr.get(__n)), _ => None }).cloned().unwrap_or(Value::Null).as_array().and_then(|__arr| __arr.get(0)).cloned().unwrap_or(Value::Null) } else { self.parse_to_int((match ((ohlcvs.as_array().and_then(|__arr| match &i { Value::Int(__n) => __arr.get(*__n as usize), Value::Str(__s) => __s.parse::<usize>().ok().and_then(|__n| __arr.get(__n)), _ => None }).cloned().unwrap_or(Value::Null).as_array().and_then(|__arr| __arr.get(0)).cloned().unwrap_or(Value::Null)).as_f64(), (Value::Int(1000)).as_f64()) { (Some(x), Some(y)) if y != 0.0 => Value::Float(x / y), _ => Value::Null })) });
4047 let mut resultTimestamp: Value = get_value(&result, ×tamp);
4048 append_to_array(&mut resultTimestamp, ts);
4049 crate::set_value(&mut result, ×tamp, resultTimestamp);
4050 let mut resultOpen: Value = get_value(&result, &open);
4051 append_to_array(&mut resultOpen, ohlcvs.as_array().and_then(|__arr| match &i { Value::Int(__n) => __arr.get(*__n as usize), Value::Str(__s) => __s.parse::<usize>().ok().and_then(|__n| __arr.get(__n)), _ => None }).cloned().unwrap_or(Value::Null).as_array().and_then(|__arr| __arr.get(1)).cloned().unwrap_or(Value::Null));
4052 crate::set_value(&mut result, &open, resultOpen);
4053 let mut resultHigh: Value = get_value(&result, &high);
4054 append_to_array(&mut resultHigh, ohlcvs.as_array().and_then(|__arr| match &i { Value::Int(__n) => __arr.get(*__n as usize), Value::Str(__s) => __s.parse::<usize>().ok().and_then(|__n| __arr.get(__n)), _ => None }).cloned().unwrap_or(Value::Null).as_array().and_then(|__arr| __arr.get(2)).cloned().unwrap_or(Value::Null));
4055 crate::set_value(&mut result, &high, resultHigh);
4056 let mut resultLow: Value = get_value(&result, &low);
4057 append_to_array(&mut resultLow, ohlcvs.as_array().and_then(|__arr| match &i { Value::Int(__n) => __arr.get(*__n as usize), Value::Str(__s) => __s.parse::<usize>().ok().and_then(|__n| __arr.get(__n)), _ => None }).cloned().unwrap_or(Value::Null).as_array().and_then(|__arr| __arr.get(3)).cloned().unwrap_or(Value::Null));
4058 crate::set_value(&mut result, &low, resultLow);
4059 let mut resultClose: Value = get_value(&result, &close);
4060 append_to_array(&mut resultClose, ohlcvs.as_array().and_then(|__arr| match &i { Value::Int(__n) => __arr.get(*__n as usize), Value::Str(__s) => __s.parse::<usize>().ok().and_then(|__n| __arr.get(__n)), _ => None }).cloned().unwrap_or(Value::Null).as_array().and_then(|__arr| __arr.get(4)).cloned().unwrap_or(Value::Null));
4061 crate::set_value(&mut result, &close, resultClose);
4062 let mut resultVolume: Value = get_value(&result, &volume);
4063 append_to_array(&mut resultVolume, ohlcvs.as_array().and_then(|__arr| match &i { Value::Int(__n) => __arr.get(*__n as usize), Value::Str(__s) => __s.parse::<usize>().ok().and_then(|__n| __arr.get(__n)), _ => None }).cloned().unwrap_or(Value::Null).as_array().and_then(|__arr| __arr.get(5)).cloned().unwrap_or(Value::Null));
4064 crate::set_value(&mut result, &volume, resultVolume);
4065 }
4066 }
4067 return result;
4068
4069 Value::Null
4070}
4071
4072 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 {
4073 let mut startRegex = get_arg(optional_args, 0, Value::Null);
4074 let mut endRegex = get_arg(optional_args, 1, Value::Null);
4075 let mut errorMessage: Value = Value::Str("".into());
4076 let mut options: Value = self.safe_value(self.options.clone(), method, &[Value::Map({
4077 let mut m = indexmap::IndexMap::new();
4078 m
4079 })]);
4080 let mut muteOnFailure: Value = self.safe_bool_k(options.clone(), "webApiMuteFailure", &[Value::Bool(true)]);
4081 {
4082 if !matches!(self.safe_bool_k(options.clone(), "webApiEnable", &[Value::Bool(true)]), Value::Bool(true)) {
4084 return Value::Null;
4085 }
4086 let mut maxRetries: Value = self.safe_integer_k(options, "webApiRetries", &[Value::Int(10)]);
4087 let mut response: Value = Value::Null;
4088 let mut retry: f64 = ((0i64) as f64);
4089 let mut shouldBreak: bool = false;
4090 while retry < maxRetries.as_f64().unwrap_or(f64::NAN) {
4091 {
4092 response = self.call_dynamic_checked(endpointMethod.clone(), vec![(Value::Map({
4093 let mut m = indexmap::IndexMap::new();
4094 m
4095 })).clone()]).await;
4096 shouldBreak = true;
4097 break;
4098 }
4099 if shouldBreak {
4100 break;
4101 }
4102 }
4103 let mut content: Value = response;
4104 if (content == Value::Null) {
4105 panic!("{}", crate::exchange_errors::null_response(format!("{}{}", self.id.clone(), Value::Str(" fetchWebEndpoint() returned empty content".into()))));
4106 }
4107 if (startRegex != Value::Null) {
4108 let mut splitted_by_start: Value = split(&content, &startRegex);
4109 content = get_value(&splitted_by_start, &Value::Int(1)); }
4111 if (content == Value::Null) {
4112 panic!("{}", crate::exchange_errors::null_response(format!("{}{}", self.id.clone(), Value::Str(" fetchWebEndpoint() returned empty content".into()))));
4113 }
4114 if (endRegex != Value::Null) {
4115 let mut splitted_by_end: Value = split(&content, &endRegex);
4116 content = get_value(&splitted_by_end, &Value::Int(0)); }
4118 if (is_equal(&returnAsJson, &Value::Bool(true))) && (matches!(&content, Value::Str(_))) {
4119 let mut jsoned: Value = self.parse_json_value(trim(&content)); if (jsoned != Value::Null) && (jsoned != Value::Null) {
4121 return jsoned;
4122 } else {
4123 panic!("{}", crate::exchange_errors::bad_response("could not parse the response into json"));
4124 }
4125 } else {
4126 return content;
4127 }
4128 }
4129 if (muteOnFailure.as_bool() == Some(true)) {
4130 return Value::Null;
4131 } else {
4132 panic!("{}", crate::exchange_errors::bad_response(errorMessage));
4133 }
4134} }
4135
4136 fn market_ids(&self, optional_args: &[Value]) -> Value {
4137 let mut symbols = get_arg(optional_args, 0, Value::Null);
4138 if (symbols == Value::Null) {
4144 return symbols;
4145 }
4146 let mut result: Value = Value::from(vec![]);
4147 {
4148 let mut i: Value = Value::Int(0);
4149 let mut __for_first_107: bool = true;
4150 while { if !__for_first_107 { i = (match (&(i), &(Value::Int(1))) { (Value::Int(x), Value::Int(y)) => Value::Int(x + y), (Value::Int(x), Value::Float(y)) => Value::Float(*x as f64 + *y), (Value::Float(x), Value::Int(y)) => Value::Float(*x + *y as f64), (Value::Float(x), Value::Float(y)) => Value::Float(x + y), _ => Value::Null }); } __for_first_107 = false; i.as_f64().unwrap_or(f64::NAN) < ((symbols.len() as i64) as f64) } {
4151 let mut id: Value = self.market_id(symbols.as_array().and_then(|__arr| match &i { Value::Int(__n) => __arr.get(*__n as usize), Value::Str(__s) => __s.parse::<usize>().ok().and_then(|__n| __arr.get(__n)), _ => None }).cloned().unwrap_or(Value::Null));
4152 if (id != Value::Null) {
4153 append_to_array(&mut result, id);
4154 }
4155 }
4156 }
4157 return result;
4158
4159 Value::Null
4160}
4161
4162 fn currency_ids(&self, optional_args: &[Value]) -> Value {
4163 let mut codes = get_arg(optional_args, 0, Value::Null);
4164 if (codes == Value::Null) {
4165 return codes;
4166 }
4167 let mut result: Value = Value::from(vec![]);
4168 {
4169 let mut i: Value = Value::Int(0);
4170 let mut __for_first_108: bool = true;
4171 while { if !__for_first_108 { i = (match (&(i), &(Value::Int(1))) { (Value::Int(x), Value::Int(y)) => Value::Int(x + y), (Value::Int(x), Value::Float(y)) => Value::Float(*x as f64 + *y), (Value::Float(x), Value::Int(y)) => Value::Float(*x + *y as f64), (Value::Float(x), Value::Float(y)) => Value::Float(x + y), _ => Value::Null }); } __for_first_108 = false; i.as_f64().unwrap_or(f64::NAN) < ((codes.len() as i64) as f64) } {
4172 let mut id: Value = self.currency_id(codes.as_array().and_then(|__arr| match &i { Value::Int(__n) => __arr.get(*__n as usize), Value::Str(__s) => __s.parse::<usize>().ok().and_then(|__n| __arr.get(__n)), _ => None }).cloned().unwrap_or(Value::Null));
4173 if (id != Value::Null) {
4174 append_to_array(&mut result, id);
4175 }
4176 }
4177 }
4178 return result;
4179
4180 Value::Null
4181}
4182
4183 fn markets_for_symbols(&self, optional_args: &[Value]) -> Value {
4184 let mut symbols = get_arg(optional_args, 0, Value::Null);
4185 if (symbols == Value::Null) {
4186 return Value::Null;
4187 }
4188 let mut result: Value = Value::from(vec![]);
4189 {
4190 let mut i: Value = Value::Int(0);
4191 let mut __for_first_109: bool = true;
4192 while { if !__for_first_109 { i = (match (&(i), &(Value::Int(1))) { (Value::Int(x), Value::Int(y)) => Value::Int(x + y), (Value::Int(x), Value::Float(y)) => Value::Float(*x as f64 + *y), (Value::Float(x), Value::Int(y)) => Value::Float(*x + *y as f64), (Value::Float(x), Value::Float(y)) => Value::Float(x + y), _ => Value::Null }); } __for_first_109 = false; i.as_f64().unwrap_or(f64::NAN) < ((symbols.len() as i64) as f64) } {
4193 append_to_array(&mut result, self.market(symbols.as_array().and_then(|__arr| match &i { Value::Int(__n) => __arr.get(*__n as usize), Value::Str(__s) => __s.parse::<usize>().ok().and_then(|__n| __arr.get(__n)), _ => None }).cloned().unwrap_or(Value::Null)));
4194 }
4195 }
4196 return result;
4197
4198 Value::Null
4199}
4200
4201fn market_symbols(&self, optional_args: &[Value]) -> Value {
4203 let mut symbols = get_arg(optional_args, 0, Value::Null);
4204 let mut type_var = get_arg(optional_args, 1, Value::Null);
4205 let mut allowEmpty = get_arg(optional_args, 2, Value::Bool(true));
4206 let mut sameTypeOnly = get_arg(optional_args, 3, Value::Bool(false));
4207 let mut sameSubTypeOnly = get_arg(optional_args, 4, Value::Bool(false));
4208 if (symbols == Value::Null) {
4218 if !is_true(&allowEmpty) {
4219 panic!("{}", crate::exchange_errors::arguments_required(format!("{}{}", self.id.clone(), Value::Str(" empty list of symbols is not supported".into()))));
4220 }
4221 return symbols;
4222 }
4223 let mut symbolsLength: f64 = ((symbols.len() as i64) as f64);
4224 if (symbolsLength == 0.0) {
4225 if !is_true(&allowEmpty) {
4226 panic!("{}", crate::exchange_errors::arguments_required(format!("{}{}", self.id.clone(), Value::Str(" empty list of symbols is not supported".into()))));
4227 }
4228 return symbols;
4229 }
4230 let mut result: Value = Value::from(vec![]);
4231 let mut marketType: Value = Value::Null;
4232 let mut isLinearSubType: Value = Value::Null;
4233 {
4234 let mut i: Value = Value::Int(0);
4235 let mut __for_first_110: bool = true;
4236 while { if !__for_first_110 { i = (match (&(i), &(Value::Int(1))) { (Value::Int(x), Value::Int(y)) => Value::Int(x + y), (Value::Int(x), Value::Float(y)) => Value::Float(*x as f64 + *y), (Value::Float(x), Value::Int(y)) => Value::Float(*x + *y as f64), (Value::Float(x), Value::Float(y)) => Value::Float(x + y), _ => Value::Null }); } __for_first_110 = false; i.as_f64().unwrap_or(f64::NAN) < ((symbols.len() as i64) as f64) } {
4237 let mut market: Value = self.market(symbols.as_array().and_then(|__arr| match &i { Value::Int(__n) => __arr.get(*__n as usize), Value::Str(__s) => __s.parse::<usize>().ok().and_then(|__n| __arr.get(__n)), _ => None }).cloned().unwrap_or(Value::Null));
4238 if is_true(&sameTypeOnly) && (marketType != Value::Null) {
4239 if (market.as_map().and_then(|__m| __m.get("type")).cloned().unwrap_or(Value::Null).as_str() != marketType.as_str()) {
4240 panic!("{}", crate::exchange_errors::bad_request(format!("{}{}", Value::Str(format!("{}{}", Value::Str(format!("{}{}", Value::Str(format!("{}{}", Value::Str(format!("{}{}", self.id.clone(), Value::Str(" symbols must be of the same type, either ".into())).into()), marketType).into()), Value::Str(" or ".into())).into()), market.as_map().and_then(|__m| __m.get("type")).cloned().unwrap_or(Value::Null)).into()), Value::Str(".".into()))));
4241 }
4242 }
4243 if is_true(&sameSubTypeOnly) && (isLinearSubType != Value::Null) {
4244 if (market.as_map().and_then(|__m| __m.get("linear")).cloned().unwrap_or(Value::Null).as_bool() != isLinearSubType.as_bool()) {
4245 panic!("{}", crate::exchange_errors::bad_request(format!("{}{}", self.id.clone(), Value::Str(" symbols must be of the same subType, either linear or inverse.".into()))));
4246 }
4247 }
4248 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()) {
4249 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()))));
4250 }
4251 marketType = self.safe_string_k(market.clone(), "type", &[]);
4252 if (market.as_map().and_then(|__m| __m.get("spot")).cloned().unwrap_or(Value::Null).as_bool() != Some(true)) {
4253 isLinearSubType = self.safe_bool_k(market.clone(), "linear", &[]);
4254 }
4255 let mut symbol: Value = self.safe_string_k(market, "symbol", &[symbols.as_array().and_then(|__arr| match &i { Value::Int(__n) => __arr.get(*__n as usize), Value::Str(__s) => __s.parse::<usize>().ok().and_then(|__n| __arr.get(__n)), _ => None }).cloned().unwrap_or(Value::Null)]);
4256 append_to_array(&mut result, symbol);
4257 }
4258 }
4259 return result;
4260
4261 Value::Null
4262}
4263
4264 fn market_codes(&self, optional_args: &[Value]) -> Value {
4265 let mut codes = get_arg(optional_args, 0, Value::Null);
4266 if (codes == Value::Null) {
4267 return codes;
4268 }
4269 let mut result: Value = Value::from(vec![]);
4270 {
4271 let mut i: Value = Value::Int(0);
4272 let mut __for_first_111: bool = true;
4273 while { if !__for_first_111 { i = (match (&(i), &(Value::Int(1))) { (Value::Int(x), Value::Int(y)) => Value::Int(x + y), (Value::Int(x), Value::Float(y)) => Value::Float(*x as f64 + *y), (Value::Float(x), Value::Int(y)) => Value::Float(*x + *y as f64), (Value::Float(x), Value::Float(y)) => Value::Float(x + y), _ => Value::Null }); } __for_first_111 = false; i.as_f64().unwrap_or(f64::NAN) < ((codes.len() as i64) as f64) } {
4274 append_to_array(&mut result, self.common_currency_code(codes.as_array().and_then(|__arr| match &i { Value::Int(__n) => __arr.get(*__n as usize), Value::Str(__s) => __s.parse::<usize>().ok().and_then(|__n| __arr.get(__n)), _ => None }).cloned().unwrap_or(Value::Null)));
4275 }
4276 }
4277 return result;
4278
4279 Value::Null
4280}
4281
4282 fn parse_order_book_bids_asks(&self, mut bidasks: Value, optional_args: &[Value]) -> Value {
4283 let mut priceKey = get_arg(optional_args, 0, Value::Int(0));
4284 let mut amountKey = get_arg(optional_args, 1, Value::Int(1));
4285 let mut countOrIdKey = get_arg(optional_args, 2, Value::Int(2));
4286 let mut bidasksValue: Value = self.to_array(bidasks);
4287 let mut result: Value = Value::from(vec![]);
4288 {
4289 let mut i: Value = Value::Int(0);
4290 let mut __for_first_112: bool = true;
4291 while { if !__for_first_112 { i = (match (&(i), &(Value::Int(1))) { (Value::Int(x), Value::Int(y)) => Value::Int(x + y), (Value::Int(x), Value::Float(y)) => Value::Float(*x as f64 + *y), (Value::Float(x), Value::Int(y)) => Value::Float(*x + *y as f64), (Value::Float(x), Value::Float(y)) => Value::Float(x + y), _ => Value::Null }); } __for_first_112 = false; i.as_f64().unwrap_or(f64::NAN) < get_array_length(&bidasksValue).as_f64().unwrap_or(f64::NAN) } {
4292 append_to_array(&mut result, self.parse_order_book_bid_ask(get_value(&bidasksValue, &i), &[priceKey.clone(), amountKey.clone(), countOrIdKey.clone()]));
4293 }
4294 }
4295 return result;
4296
4297 Value::Null
4298}
4299
4300 fn filter_by_key(&self, mut objects: Value, mut key: Value, optional_args: &[Value]) -> Value {
4301 let mut value = get_arg(optional_args, 0, Value::Null);
4302 if (value == Value::Null) {
4303 return objects;
4304 }
4305 let mut result: Value = Value::from(vec![]);
4306 {
4307 let mut i: Value = Value::Int(0);
4308 let mut __for_first_113: bool = true;
4309 while { if !__for_first_113 { i = (match (&(i), &(Value::Int(1))) { (Value::Int(x), Value::Int(y)) => Value::Int(x + y), (Value::Int(x), Value::Float(y)) => Value::Float(*x as f64 + *y), (Value::Float(x), Value::Int(y)) => Value::Float(*x + *y as f64), (Value::Float(x), Value::Float(y)) => Value::Float(x + y), _ => Value::Null }); } __for_first_113 = false; i.as_f64().unwrap_or(f64::NAN) < get_array_length(&objects).as_f64().unwrap_or(f64::NAN) } {
4310 let mut objectValue: Value = self.safe_string(get_value(&objects, &i), key.clone(), &[]);
4311 if (objectValue.as_str() == value.as_str()) {
4312 append_to_array(&mut result, get_value(&objects, &i));
4313 }
4314 }
4315 }
4316 return result;
4317
4318 Value::Null
4319}
4320
4321 fn filter_by_symbol(&self, mut objects: Value, optional_args: &[Value]) -> Value {
4322 let mut symbol = get_arg(optional_args, 0, Value::Null);
4323 return self.filter_by_key(objects, Value::Str("symbol".into()), &[symbol]);
4324
4325 Value::Null
4326}
4327
4328 fn parse_ohlcv(&self, mut ohlcv: Value, optional_args: &[Value]) -> Value {
4329 { 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; } }
4331
4332 let mut market = get_arg(optional_args, 0, Value::Null);
4333 if (matches!(&ohlcv, Value::Arr(_))) {
4334 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), &[])]);
4335 }
4336 return ohlcv;
4337
4338 Value::Null
4339}
4340
4341 fn safe_network(&self, mut network: Value) -> Value {
4342 let mut withdrawEnabled: Value = self.safe_bool_k(network.clone(), "withdraw", &[]);
4343 let mut depositEnabled: Value = self.safe_bool_k(network.clone(), "deposit", &[]);
4344 let mut limits: Value = self.safe_dict_k(network.clone(), "limits", &[]);
4345 let mut withdraw: Value = self.safe_dict_k(limits.clone(), "withdraw", &[]);
4346 let mut deposit: Value = self.safe_dict_k(limits, "deposit", &[]);
4347 let mut isEnabled: Value = withdrawEnabled.clone();
4348 if (withdrawEnabled.as_bool() == Some(true)) {
4349 isEnabled = depositEnabled.clone();
4350 }
4351 return Value::Map({
4352 let mut m = indexmap::IndexMap::new();
4353 m.insert("info".to_string(), crate::value::get_value_k(&network, "info"));
4354 m.insert("id".to_string(), self.safe_string_k(network.clone(), "id", &[]));
4355 m.insert("name".to_string(), self.safe_string_k(network.clone(), "name", &[]));
4356 m.insert("network".to_string(), self.safe_string_k(network.clone(), "network", &[]));
4357 m.insert("active".to_string(), self.safe_bool_k(network.clone(), "active", &[isEnabled]));
4358 m.insert("deposit".to_string(), depositEnabled);
4359 m.insert("withdraw".to_string(), withdrawEnabled);
4360 m.insert("fee".to_string(), self.safe_number_k(network.clone(), "fee", &[]));
4361 m.insert("precision".to_string(), self.safe_number_k(network, "precision", &[]));
4362 m.insert("limits".to_string(), Value::Map({
4363 let mut m = indexmap::IndexMap::new();
4364 m.insert("withdraw".to_string(), Value::Map({
4365 let mut m = indexmap::IndexMap::new();
4366 m.insert("min".to_string(), self.safe_number_k(withdraw.clone(), "min", &[]));
4367 m.insert("max".to_string(), self.safe_number_k(withdraw, "max", &[]));
4368 m
4369}));
4370 m.insert("deposit".to_string(), Value::Map({
4371 let mut m = indexmap::IndexMap::new();
4372 m.insert("min".to_string(), self.safe_number_k(deposit.clone(), "min", &[]));
4373 m.insert("max".to_string(), self.safe_number_k(deposit, "max", &[]));
4374 m
4375}));
4376 m
4377}));
4378 m
4379});
4380
4381 Value::Null
4382}
4383
4384 fn prioritized_network_aliases(&self, optional_args: &[Value]) -> Value {
4385 let mut networkCode = get_arg(optional_args, 0, Value::Null);
4386 let mut currencyCode = get_arg(optional_args, 1, Value::Null);
4387 let mut allowDefault = get_arg(optional_args, 2, Value::Bool(false));
4388 if (networkCode == Value::Null) {
4408 return Value::Null;
4409 }
4410 let mut replacements: Value = self.safe_dict_k(self.options.clone(), "defaultNetworkCodeReplacements", &[Value::Map({
4411 let mut m = indexmap::IndexMap::new();
4412 m
4413})]);
4414 let mut keys: Value = object_keys(&replacements);
4415 {
4416 let mut i: Value = Value::Int(0);
4417 let mut __for_first_114: bool = true;
4418 while { if !__for_first_114 { i = (match (&(i), &(Value::Int(1))) { (Value::Int(x), Value::Int(y)) => Value::Int(x + y), (Value::Int(x), Value::Float(y)) => Value::Float(*x as f64 + *y), (Value::Float(x), Value::Int(y)) => Value::Float(*x + *y as f64), (Value::Float(x), Value::Float(y)) => Value::Float(x + y), _ => Value::Null }); } __for_first_114 = false; i.as_f64().unwrap_or(f64::NAN) < ((keys.len() as i64) as f64) } {
4419 let mut baseCoin: Value = keys.as_array().and_then(|__arr| match &i { Value::Int(__n) => __arr.get(*__n as usize), Value::Str(__s) => __s.parse::<usize>().ok().and_then(|__n| __arr.get(__n)), _ => None }).cloned().unwrap_or(Value::Null);
4420 let mut entry: Value = replacements.as_map().and_then(|__m| baseCoin.as_str().and_then(|__k| __m.get(__k))).cloned().unwrap_or(Value::Null);
4421 let mut primary: Value = crate::value::get_value_k(&entry, "primary");
4422 let mut secondary: Value = crate::value::get_value_k(&entry, "secondary");
4423 if !is_equal(&networkCode, &primary) && !is_equal(&networkCode, &secondary) {
4424 continue;
4425 }
4426 let mut preferPrimary: bool = false;
4428 if (currencyCode.as_str() == baseCoin.as_str()) {
4429 preferPrimary = true; } else if (currencyCode != Value::Null) {
4431 preferPrimary = false; } else if is_true(&allowDefault) {
4433 preferPrimary = crate::value::get_value_k(&entry, "default").as_str() == Some("primary");
4434 } else {
4435 preferPrimary = is_equal(&networkCode, &primary); }
4437 return (if (preferPrimary) { Value::from(vec![primary.clone(), secondary.clone()]) } else { Value::from(vec![secondary, primary]) });
4438 }
4439 }
4440 return Value::from(vec![networkCode.clone(), networkCode.clone()]);
4441
4442 Value::Null
4443}
4444
4445 fn network_code_to_id(&self, mut networkCode: Value, optional_args: &[Value]) -> Value {
4446 let mut currencyCode = get_arg(optional_args, 0, Value::Null);
4447 if (networkCode == Value::Null) {
4457 return Value::Null;
4458 }
4459 let mut networkIdsByCodes: Value = self.safe_dict_k(self.options.clone(), "networks", &[Value::Map({
4460 let mut m = indexmap::IndexMap::new();
4461 m
4462})]);
4463 let mut chainPair: Value = self.prioritized_network_aliases(&[networkCode.clone(), currencyCode.clone(), Value::Bool(false)]);
4465 let mut preferredChain: Value = (if (chainPair == Value::Null) { networkCode.clone() } else { chainPair.as_array().and_then(|__arr| __arr.get(0)).cloned().unwrap_or(Value::Null) });
4466 let mut alternativeChain: Value = (if (chainPair == Value::Null) { networkCode.clone() } else { chainPair.as_array().and_then(|__arr| __arr.get(1)).cloned().unwrap_or(Value::Null) });
4467 let mut networkId: Value = self.safe_string2(networkIdsByCodes, preferredChain, alternativeChain, &[]);
4468 if (networkId != Value::Null) {
4469 return networkId;
4470 }
4471 let mut currenciesToCheck: Value = Value::from(vec![]);
4473 if (currencyCode == Value::Null) {
4474 currenciesToCheck = object_keys(&self.currencies);
4475 } else {
4476 currenciesToCheck = Value::from(vec![self.safe_dict(self.currencies.clone(), currencyCode.clone(), &[])]);
4477 }
4478 {
4479 let mut i: Value = Value::Int(0);
4480 let mut __for_first_115: bool = true;
4481 while { if !__for_first_115 { i = (match (&(i), &(Value::Int(1))) { (Value::Int(x), Value::Int(y)) => Value::Int(x + y), (Value::Int(x), Value::Float(y)) => Value::Float(*x as f64 + *y), (Value::Float(x), Value::Int(y)) => Value::Float(*x + *y as f64), (Value::Float(x), Value::Float(y)) => Value::Float(x + y), _ => Value::Null }); } __for_first_115 = false; i.as_f64().unwrap_or(f64::NAN) < ((currenciesToCheck.len() as i64) as f64) } {
4482 let mut networks: Value = self.safe_dict(currenciesToCheck.as_array().and_then(|__arr| match &i { Value::Int(__n) => __arr.get(*__n as usize), Value::Str(__s) => __s.parse::<usize>().ok().and_then(|__n| __arr.get(__n)), _ => None }).cloned().unwrap_or(Value::Null), Value::Str("networks".into()), &[Value::Map({
4483 let mut m = indexmap::IndexMap::new();
4484 m
4485})]);
4486 if (in_op(&networks, &networkCode)) {
4487 return self.safe_string(networks.as_map().and_then(|__m| networkCode.as_str().and_then(|__k| __m.get(__k))).cloned().unwrap_or(Value::Null), Value::Str("id".into()), &[]);
4488 }
4489 }
4490 }
4491 let mut oldCodes: Value = self.safe_dict_k(self.options.clone(), "backwardSupportedNetworkCodes", &[Value::Map({
4493 let mut m = indexmap::IndexMap::new();
4494 m
4495})]);
4496 if (in_op(&oldCodes, &networkCode)) {
4497 return self.network_code_to_id(oldCodes.as_map().and_then(|__m| networkCode.as_str().and_then(|__k| __m.get(__k))).cloned().unwrap_or(Value::Null), &[currencyCode]);
4498 }
4499 return networkCode;
4500
4501 Value::Null
4502}
4503
4504 fn network_id_to_code(&self, optional_args: &[Value]) -> Value {
4505 let mut networkId = get_arg(optional_args, 0, Value::Null);
4506 let mut currencyCode = get_arg(optional_args, 1, Value::Null);
4507 if (networkId == Value::Null) {
4517 return Value::Null;
4518 }
4519 let mut networkCodesByIds: Value = self.safe_dict_k(self.options.clone(), "networksById", &[Value::Map({
4520 let mut m = indexmap::IndexMap::new();
4521 m
4522})]);
4523 let mut networkCode: Value = self.safe_string(networkCodesByIds, networkId.clone(), &[networkId.clone()]);
4524 let mut chainPair: Value = self.prioritized_network_aliases(&[networkCode.clone(), currencyCode.clone(), Value::Bool(true)]);
4525 if (chainPair == Value::Null) {
4526 return networkCode;
4527 }
4528 let mut preferredChain: Value = chainPair.as_array().and_then(|__arr| __arr.get(0)).cloned().unwrap_or(Value::Null);
4529 let mut alternativeChain: Value = chainPair.as_array().and_then(|__arr| __arr.get(1)).cloned().unwrap_or(Value::Null);
4530 if (currencyCode == Value::Null) {
4533 let mut networkIdsByCodes: Value = self.safe_dict_k(self.options.clone(), "networks", &[Value::Map({
4534 let mut m = indexmap::IndexMap::new();
4535 m
4536})]);
4537 if (in_op(&networkIdsByCodes, &preferredChain)) && (in_op(&networkIdsByCodes, &alternativeChain)) {
4538 return networkCode;
4539 }
4540 }
4541 return preferredChain;
4542
4543 Value::Null
4544}
4545
4546 fn handle_network_code_and_params(&self, mut params: Value) -> Value {
4547 let mut networkCodeInParams: Value = self.safe_string2(params.clone(), Value::Str("networkCode".into()), Value::Str("network".into()), &[]);
4548 let mut paramsOmitted: Value = (if (networkCodeInParams != Value::Null) { self.omit(params.clone(), Value::from(vec![Value::Str("networkCode".into()), Value::Str("network".into())]), &[]) } else { params });
4549 return Value::from(vec![networkCodeInParams, paramsOmitted]);
4550
4551 Value::Null
4552}
4553
4554 fn default_network_code(&self, mut currencyCode: Value) -> Value {
4555 let mut defaultNetworkCode: Value = Value::Null;
4556 let mut defaultNetworks: Value = self.safe_dict_k(self.options.clone(), "defaultNetworks", &[Value::Map({
4557 let mut m = indexmap::IndexMap::new();
4558 m
4559})]);
4560 if (in_op(&defaultNetworks, ¤cyCode)) {
4561 defaultNetworkCode = defaultNetworks.as_map().and_then(|__m| currencyCode.as_str().and_then(|__k| __m.get(__k))).cloned().unwrap_or(Value::Null);
4563 } else {
4564 let mut defaultNetwork: Value = self.safe_string_k(self.options.clone(), "defaultNetwork", &[]);
4566 if (defaultNetwork != Value::Null) {
4567 defaultNetworkCode = defaultNetwork;
4568 }
4569 }
4570 return defaultNetworkCode;
4571
4572 Value::Null
4573}
4574
4575 fn select_network_code_from_unified_networks(&self, mut currencyCode: Value, mut networkCode: Value, mut indexedNetworkEntries: Value) -> Value {
4576 return self.select_network_key_from_networks(currencyCode, networkCode, indexedNetworkEntries, &[Value::Bool(true)]);
4577
4578 Value::Null
4579}
4580
4581 fn select_network_id_from_raw_networks(&self, mut currencyCode: Value, mut networkCode: Value, mut indexedNetworkEntries: Value) -> Value {
4582 return self.select_network_key_from_networks(currencyCode, networkCode, indexedNetworkEntries, &[Value::Bool(false)]);
4583
4584 Value::Null
4585}
4586
4587 fn select_network_key_from_networks(&self, mut currencyCode: Value, mut networkCode: Value, mut indexedNetworkEntries: Value, optional_args: &[Value]) -> Value {
4588 let mut isIndexedByUnifiedNetworkCode = get_arg(optional_args, 0, Value::Bool(false));
4589 let mut chosenNetworkId: Value = Value::Null;
4591 let mut availableNetworkIds: Value = object_keys(&indexedNetworkEntries);
4592 let mut responseNetworksLength: f64 = ((availableNetworkIds.len() as i64) as f64);
4593 if (networkCode != Value::Null) {
4594 if (responseNetworksLength == 0.0) {
4595 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)));
4596 } else {
4597 let mut networkIdOrCode: Value = (if is_true(&isIndexedByUnifiedNetworkCode) { networkCode.clone() } else { self.network_code_to_id(networkCode.clone(), &[currencyCode.clone()]) });
4599 if (networkIdOrCode == Value::Null) {
4600 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)));
4601 }
4602 if (in_op(&indexedNetworkEntries, &networkIdOrCode)) {
4603 chosenNetworkId = networkIdOrCode.clone();
4604 } else {
4605 panic!("{}", crate::exchange_errors::not_supported(format!("{}{}", Value::Str(format!("{}{}", Value::Str(format!("{}{}", Value::Str(format!("{}{}", Value::Str(format!("{}{}", Value::Str(format!("{}{}", self.id.clone(), Value::Str(" - ".into())).into()), networkIdOrCode).into()), Value::Str(" network was not found for ".into())).into()), currencyCode).into()), Value::Str(", use one of ".into())).into()), join(&availableNetworkIds, &Value::Str(", ".into())))));
4606 }
4607 }
4608 } else {
4609 if (responseNetworksLength == 0.0) {
4610 panic!("{}", crate::exchange_errors::not_supported(format!("{}{}", Value::Str(format!("{}{}", self.id.clone(), Value::Str(" - no networks were returned for ".into())).into()), currencyCode)));
4611 } else {
4612 let mut defaultNetworkCode: Value = self.default_network_code(currencyCode.clone());
4614 let mut defaultNetworkId: Value = (if is_true(&isIndexedByUnifiedNetworkCode) { defaultNetworkCode.clone() } else { self.network_code_to_id(defaultNetworkCode, &[currencyCode]) });
4615 if (defaultNetworkId == Value::Null) {
4616 panic!("{}", crate::exchange_errors::exchange_error(format!("{}{}", self.id.clone(), Value::Str(" selectNetworkKeyFromNetworks() missing defaultNetworkId".into()))));
4617 }
4618 if (in_op(&indexedNetworkEntries, &defaultNetworkId)) {
4619 return defaultNetworkId;
4620 }
4621 panic!("{}", crate::exchange_errors::not_supported(format!("{}{}", Value::Str(format!("{}{}", self.id.clone(), Value::Str(" - can not determine the default network, please pass param[\"network\"] one from : ".into())).into()), join(&availableNetworkIds, &Value::Str(", ".into())))));
4622 }
4623 }
4624 return chosenNetworkId;
4625
4626 Value::Null
4627}
4628
4629 fn safe_number2(&self, mut dictionary: Value, mut key1: Value, mut key2: Value, optional_args: &[Value]) -> Value {
4630 let mut d = get_arg(optional_args, 0, Value::Null);
4631 let mut value: Value = self.safe_string2(dictionary, key1, key2, &[]);
4632 return self.parse_number(value, &[d]);
4633
4634 Value::Null
4635}
4636
4637 fn parse_order_book(&self, mut orderbook: Value, mut symbol: Value, optional_args: &[Value]) -> Value {
4638 { let __v = crate::exchange::DerivedExchange::parse_order_book(self, orderbook.clone(), symbol.clone(), crate::runtime::get_arg(optional_args, 0, crate::Value::Null), crate::runtime::get_arg(optional_args, 1, crate::Value::Null), crate::runtime::get_arg(optional_args, 2, crate::Value::Null), crate::runtime::get_arg(optional_args, 3, crate::Value::Null), crate::runtime::get_arg(optional_args, 4, crate::Value::Null), crate::runtime::get_arg(optional_args, 5, crate::Value::Null)); if !matches!(__v, crate::Value::Null) { return __v; } }
4640
4641 let mut timestamp = get_arg(optional_args, 0, Value::Null);
4642 let mut bidsKey = get_arg(optional_args, 1, Value::Str("bids".into()));
4643 let mut asksKey = get_arg(optional_args, 2, Value::Str("asks".into()));
4644 let mut priceKey = get_arg(optional_args, 3, Value::Int(0));
4645 let mut amountKey = get_arg(optional_args, 4, Value::Int(1));
4646 let mut countOrIdKey = get_arg(optional_args, 5, Value::Int(2));
4647 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()]);
4648 let mut asks: Value = self.parse_order_book_bids_asks(self.safe_value(orderbook, asksKey, &[Value::from(vec![])]), &[priceKey, amountKey, countOrIdKey]);
4649 return Value::Map({
4650 let mut m = indexmap::IndexMap::new();
4651 m.insert("symbol".to_string(), symbol);
4652 m.insert("bids".to_string(), self.sort_by(bids, Value::Int(0), &[Value::Bool(true)]));
4653 m.insert("asks".to_string(), self.sort_by(asks, Value::Int(0), &[]));
4654 m.insert("timestamp".to_string(), timestamp.clone());
4655 m.insert("datetime".to_string(), self.iso8601(timestamp));
4656 m.insert("nonce".to_string(), Value::Null);
4657 m
4658});
4659
4660 Value::Null
4661}
4662
4663 fn parse_ohlc_vs(&self, mut ohlcvs: Value, optional_args: &[Value]) -> Value {
4664 let mut market = get_arg(optional_args, 0, Value::Null);
4665 let mut timeframe = get_arg(optional_args, 1, Value::Str("1m".into()));
4666 let mut since = get_arg(optional_args, 2, Value::Null);
4667 let mut limit = get_arg(optional_args, 3, Value::Null);
4668 let mut tail = get_arg(optional_args, 4, Value::Bool(false));
4669 if (ohlcvs == Value::Null) {
4670 return Value::from(vec![]);
4671 }
4672 let mut results: Value = Value::from(vec![]);
4673 {
4674 let mut i: Value = Value::Int(0);
4675 let mut __for_first_116: bool = true;
4676 while { if !__for_first_116 { i = (match (&(i), &(Value::Int(1))) { (Value::Int(x), Value::Int(y)) => Value::Int(x + y), (Value::Int(x), Value::Float(y)) => Value::Float(*x as f64 + *y), (Value::Float(x), Value::Int(y)) => Value::Float(*x + *y as f64), (Value::Float(x), Value::Float(y)) => Value::Float(x + y), _ => Value::Null }); } __for_first_116 = false; i.as_f64().unwrap_or(f64::NAN) < ((ohlcvs.len() as i64) as f64) } {
4677 append_to_array(&mut results, <Self as crate::exchange_generated::ExchangeBase>::parse_ohlcv(self, ohlcvs.as_array().and_then(|__arr| match &i { Value::Int(__n) => __arr.get(*__n as usize), Value::Str(__s) => __s.parse::<usize>().ok().and_then(|__n| __arr.get(__n)), _ => None }).cloned().unwrap_or(Value::Null), &[market.clone()]));
4678 }
4679 }
4680 let mut sorted: Value = self.sort_by(results, Value::Int(0), &[]);
4681 return self.filter_by_since_limit(sorted, &[since, limit, Value::Int(0), tail]);
4682
4683 Value::Null
4684}
4685
4686 fn parse_leverage_tiers(&self, mut response: Value, optional_args: &[Value]) -> Value {
4687 let mut symbols = get_arg(optional_args, 0, Value::Null);
4688 let mut marketIdKey = get_arg(optional_args, 1, Value::Null);
4689 let mut symbolsNormalized: Value = self.market_symbols(&[symbols]);
4691 let mut tiers: Value = Value::Map({
4692 let mut m = indexmap::IndexMap::new();
4693 m
4694 });
4695 let mut symbolsLength: Value = Value::Int(0);
4696 if (symbolsNormalized != Value::Null) {
4697 symbolsLength = Value::Int(symbolsNormalized.len() as i64);
4698 }
4699 let mut noSymbols: bool = (symbolsNormalized == Value::Null) || (symbolsLength.as_f64() == Some(0.0));
4700 if (matches!(&response, Value::Arr(_))) {
4701 {
4702 let mut i: Value = Value::Int(0);
4703 let mut __for_first_117: bool = true;
4704 while { if !__for_first_117 { i = (match (&(i), &(Value::Int(1))) { (Value::Int(x), Value::Int(y)) => Value::Int(x + y), (Value::Int(x), Value::Float(y)) => Value::Float(*x as f64 + *y), (Value::Float(x), Value::Int(y)) => Value::Float(*x + *y as f64), (Value::Float(x), Value::Float(y)) => Value::Float(x + y), _ => Value::Null }); } __for_first_117 = false; i.as_f64().unwrap_or(f64::NAN) < ((response.len() as i64) as f64) } {
4705 let mut item: Value = response.as_array().and_then(|__arr| match &i { Value::Int(__n) => __arr.get(*__n as usize), Value::Str(__s) => __s.parse::<usize>().ok().and_then(|__n| __arr.get(__n)), _ => None }).cloned().unwrap_or(Value::Null);
4706 let mut id: Value = (if (marketIdKey == Value::Null) { Value::Null } else { self.safe_string(item.clone(), marketIdKey.clone(), &[]) });
4707 let mut market: Value = self.safe_market(&[id, Value::Null, Value::Null, Value::Str("swap".into())]);
4708 let mut symbol: Value = market.as_map().and_then(|__m| __m.get("symbol")).cloned().unwrap_or(Value::Null);
4709 let mut contract: Value = self.safe_bool_k(market.clone(), "contract", &[Value::Bool(false)]);
4710 if (contract.as_bool() == Some(true)) && (noSymbols || ((symbolsNormalized != Value::Null) && self.in_array(symbol.clone(), symbolsNormalized.clone()).as_bool() == Some(true))) {
4711 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()])); }
4712 }
4713 }
4714 }
4715 } else {
4716 let mut keys: Value = object_keys(&response);
4717 {
4718 let mut i: Value = Value::Int(0);
4719 let mut __for_first_118: bool = true;
4720 while { if !__for_first_118 { i = (match (&(i), &(Value::Int(1))) { (Value::Int(x), Value::Int(y)) => Value::Int(x + y), (Value::Int(x), Value::Float(y)) => Value::Float(*x as f64 + *y), (Value::Float(x), Value::Int(y)) => Value::Float(*x + *y as f64), (Value::Float(x), Value::Float(y)) => Value::Float(x + y), _ => Value::Null }); } __for_first_118 = false; i.as_f64().unwrap_or(f64::NAN) < ((keys.len() as i64) as f64) } {
4721 let mut marketId: Value = keys.as_array().and_then(|__arr| match &i { Value::Int(__n) => __arr.get(*__n as usize), Value::Str(__s) => __s.parse::<usize>().ok().and_then(|__n| __arr.get(__n)), _ => None }).cloned().unwrap_or(Value::Null);
4722 let mut item: Value = get_value(&response, &marketId);
4723 let mut item: Value = get_value(&response, &marketId);
4724 let mut market: Value = self.safe_market(&[marketId, Value::Null, Value::Null, Value::Str("swap".into())]);
4725 let mut symbol: Value = market.as_map().and_then(|__m| __m.get("symbol")).cloned().unwrap_or(Value::Null);
4726 let mut contract: Value = self.safe_bool_k(market.clone(), "contract", &[Value::Bool(false)]);
4727 if (contract.as_bool() == Some(true)) && (noSymbols || ((symbolsNormalized != Value::Null) && self.in_array(symbol.clone(), symbolsNormalized.clone()).as_bool() == Some(true))) {
4728 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])); }
4729 }
4730 }
4731 }
4732 }
4733 return tiers;
4734
4735 Value::Null
4736}
4737
4738 fn load_trading_limits(&mut self, optional_args: &[Value]) -> impl ::std::future::Future<Output = Value> + Send { async move {
4739 let mut symbols = get_arg(optional_args, 0, Value::Null);
4740 let mut reload = get_arg(optional_args, 1, Value::Bool(false));
4741 let mut params = get_arg(optional_args, 2, Value::Map({
4742 let mut m = indexmap::IndexMap::new();
4743 m
4744}));
4745 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)) {
4746 if is_true(&reload) || !(matches!(&self.options, Value::Dict(__d) if __d.contains_key("limitsLoaded"))) {
4747 let mut response: Value = self.fetch_trading_limits(&[symbols.clone()]).await;
4748 let mut symbolsArray: Value = self.require_value(symbols, &[Value::Str("loadTradingLimits() requires a symbols argument".into())]);
4749 let mut markets: Value = self.markets.clone();
4750 if (markets == Value::Null) {
4751 panic!("{}", crate::exchange_errors::exchange_error(format!("{}{}", self.id.clone(), Value::Str(" markets not loaded".into()))));
4752 }
4753 {
4754 let mut i: Value = Value::Int(0);
4755 let mut __for_first_119: bool = true;
4756 while { if !__for_first_119 { i = (match (&(i), &(Value::Int(1))) { (Value::Int(x), Value::Int(y)) => Value::Int(x + y), (Value::Int(x), Value::Float(y)) => Value::Float(*x as f64 + *y), (Value::Float(x), Value::Int(y)) => Value::Float(*x + *y as f64), (Value::Float(x), Value::Float(y)) => Value::Float(x + y), _ => Value::Null }); } __for_first_119 = false; i.as_f64().unwrap_or(f64::NAN) < get_array_length(&symbolsArray).as_f64().unwrap_or(f64::NAN) } {
4757 let mut symbol: Value = get_value(&symbolsArray, &i);
4758 let mut symbol: Value = get_value(&symbolsArray, &i);
4759 { let __be_tmp = self.deep_extend(get_value(&markets, &symbol), &[get_value(&response, &symbol)]); add_element_to_object(&mut markets, &symbol, __be_tmp); };
4760 }
4761 }
4762 { let __be_tmp = self.milliseconds(); if let Value::Dict(__d) = &mut self.options { std::sync::Arc::make_mut(__d).insert("limitsLoaded".into(), __be_tmp); } }
4763 }
4764 }
4765 return self.markets.clone();
4766
4767 Value::Null
4768} }
4769
4770 fn safe_position(&self, mut position: Value) -> Value {
4771 let mut unrealizedPnlString: Value = self.safe_string_k(position.clone(), "unrealizedPnl", &[]);
4773 let mut initialMarginString: Value = self.safe_string_k(position.clone(), "initialMargin", &[]);
4774 let mut percentage: Value = self.safe_value_k(position.clone(), "percentage", &[]);
4778 if (percentage == Value::Null) && (unrealizedPnlString != Value::Null) && (initialMarginString != Value::Null) {
4779 let mut percentageString: Value = crate::precise::Precise::stringMul(&crate::precise::Precise::stringDivPrec(&unrealizedPnlString, &initialMarginString, &Value::Int(4)), &Value::Str("100".into()));
4781 if let Value::Dict(__d) = &mut position { std::sync::Arc::make_mut(__d).insert("percentage".into(), self.parse_number(percentageString, &[])); }
4782 }
4783 let mut contractSize: Value = self.safe_number_k(position.clone(), "contractSize", &[]);
4785 let mut symbol: Value = self.safe_string_k(position.clone(), "symbol", &[]);
4786 let mut market: Value = Value::Null;
4787 if (symbol != Value::Null) {
4788 market = self.safe_value(self.markets.clone(), symbol, &[]);
4789 }
4790 if (contractSize == Value::Null) && (market != Value::Null) {
4791 contractSize = self.safe_number_k(market, "contractSize", &[]);
4792 if let Value::Dict(__d) = &mut position { std::sync::Arc::make_mut(__d).insert("contractSize".into(), contractSize); }
4793 }
4794 return position;
4795
4796 Value::Null
4797}
4798
4799 fn parse_positions(&self, mut positions: Value, optional_args: &[Value]) -> Value {
4800 let mut symbols = get_arg(optional_args, 0, Value::Null);
4801 let mut params = get_arg(optional_args, 1, Value::Map({
4802 let mut m = indexmap::IndexMap::new();
4803 m
4804}));
4805 let mut symbolsNormalized: Value = self.market_symbols(&[symbols]);
4806 let mut positionsArray: Value = self.to_array(positions);
4807 let mut result: Value = Value::from(vec![]);
4808 {
4809 let mut i: Value = Value::Int(0);
4810 let mut __for_first_120: bool = true;
4811 while { if !__for_first_120 { i = (match (&(i), &(Value::Int(1))) { (Value::Int(x), Value::Int(y)) => Value::Int(x + y), (Value::Int(x), Value::Float(y)) => Value::Float(*x as f64 + *y), (Value::Float(x), Value::Int(y)) => Value::Float(*x + *y as f64), (Value::Float(x), Value::Float(y)) => Value::Float(x + y), _ => Value::Null }); } __for_first_120 = false; i.as_f64().unwrap_or(f64::NAN) < ((positionsArray.len() as i64) as f64) } {
4812 let mut position: Value = self.extend(<Self as crate::exchange_generated::ExchangeBase>::parse_position(self, positionsArray.as_array().and_then(|__arr| match &i { Value::Int(__n) => __arr.get(*__n as usize), Value::Str(__s) => __s.parse::<usize>().ok().and_then(|__n| __arr.get(__n)), _ => None }).cloned().unwrap_or(Value::Null), &[]), &[params.clone()]);
4813 append_to_array(&mut result, position);
4814 }
4815 }
4816 return self.filter_by_array_positions(result, Value::Str("symbol".into()), &[symbolsNormalized]);
4817
4818 Value::Null
4819}
4820
4821 fn parse_adl_rank(&self, mut info: Value, optional_args: &[Value]) -> Value {
4822 { 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; } }
4824
4825 let mut market = get_arg(optional_args, 0, Value::Null);
4826 if (info == Value::Null) {
4827 panic!("{}", crate::exchange_errors::not_supported(format!("{}{}", self.id.clone(), Value::Str(" parseADLRank() is not supported yet".into()))));
4828 }
4829 panic!("{}", crate::exchange_errors::not_supported(format!("{}{}", self.id.clone(), Value::Str(" parseADLRank() is not supported yet".into()))));
4830
4831 Value::Null
4832}
4833
4834 fn parse_adl_ranks(&self, mut ranks: Value, optional_args: &[Value]) -> Value {
4835 let mut symbols = get_arg(optional_args, 0, Value::Null);
4836 let mut params = get_arg(optional_args, 1, Value::Map({
4837 let mut m = indexmap::IndexMap::new();
4838 m
4839}));
4840 let mut symbolsNormalized: Value = self.market_symbols(&[symbols]);
4841 let mut ranksArray: Value = self.to_array(ranks);
4842 let mut result: Value = Value::from(vec![]);
4843 {
4844 let mut i: Value = Value::Int(0);
4845 let mut __for_first_121: bool = true;
4846 while { if !__for_first_121 { i = (match (&(i), &(Value::Int(1))) { (Value::Int(x), Value::Int(y)) => Value::Int(x + y), (Value::Int(x), Value::Float(y)) => Value::Float(*x as f64 + *y), (Value::Float(x), Value::Int(y)) => Value::Float(*x + *y as f64), (Value::Float(x), Value::Float(y)) => Value::Float(x + y), _ => Value::Null }); } __for_first_121 = false; i.as_f64().unwrap_or(f64::NAN) < ((ranksArray.len() as i64) as f64) } {
4847 let mut rank: Value = self.extend(<Self as crate::exchange_generated::ExchangeBase>::parse_adl_rank(self, ranksArray.as_array().and_then(|__arr| match &i { Value::Int(__n) => __arr.get(*__n as usize), Value::Str(__s) => __s.parse::<usize>().ok().and_then(|__n| __arr.get(__n)), _ => None }).cloned().unwrap_or(Value::Null), &[]), &[params.clone()]);
4848 append_to_array(&mut result, rank);
4849 }
4850 }
4851 return self.filter_by_array_positions(result, Value::Str("symbol".into()), &[symbolsNormalized]);
4852
4853 Value::Null
4854}
4855
4856 fn parse_accounts(&self, mut accounts: Value, optional_args: &[Value]) -> Value {
4857 let mut params = get_arg(optional_args, 0, Value::Map({
4858 let mut m = indexmap::IndexMap::new();
4859 m
4860}));
4861 let mut accountsArray: Value = self.to_array(accounts);
4862 let mut result: Value = Value::from(vec![]);
4863 {
4864 let mut i: Value = Value::Int(0);
4865 let mut __for_first_122: bool = true;
4866 while { if !__for_first_122 { i = (match (&(i), &(Value::Int(1))) { (Value::Int(x), Value::Int(y)) => Value::Int(x + y), (Value::Int(x), Value::Float(y)) => Value::Float(*x as f64 + *y), (Value::Float(x), Value::Int(y)) => Value::Float(*x + *y as f64), (Value::Float(x), Value::Float(y)) => Value::Float(x + y), _ => Value::Null }); } __for_first_122 = false; i.as_f64().unwrap_or(f64::NAN) < ((accountsArray.len() as i64) as f64) } {
4867 let mut account: Value = self.extend(<Self as crate::exchange_generated::ExchangeBase>::parse_account(self, accountsArray.as_array().and_then(|__arr| match &i { Value::Int(__n) => __arr.get(*__n as usize), Value::Str(__s) => __s.parse::<usize>().ok().and_then(|__n| __arr.get(__n)), _ => None }).cloned().unwrap_or(Value::Null)), &[params.clone()]);
4868 append_to_array(&mut result, account);
4869 }
4870 }
4871 return result;
4872
4873 Value::Null
4874}
4875
4876 fn parse_trades_helper(&self, mut isWs: Value, mut trades: Value, optional_args: &[Value]) -> Value {
4877 let mut market = get_arg(optional_args, 0, Value::Null);
4878 let mut since = get_arg(optional_args, 1, Value::Null);
4879 let mut limit = get_arg(optional_args, 2, Value::Null);
4880 let mut params = get_arg(optional_args, 3, Value::Map({
4881 let mut m = indexmap::IndexMap::new();
4882 m
4883}));
4884 let mut tradesArray: Value = self.to_array(trades);
4885 let mut result: Value = Value::from(vec![]);
4886 {
4887 let mut i: Value = Value::Int(0);
4888 let mut __for_first_123: bool = true;
4889 while { if !__for_first_123 { i = (match (&(i), &(Value::Int(1))) { (Value::Int(x), Value::Int(y)) => Value::Int(x + y), (Value::Int(x), Value::Float(y)) => Value::Float(*x as f64 + *y), (Value::Float(x), Value::Int(y)) => Value::Float(*x + *y as f64), (Value::Float(x), Value::Float(y)) => Value::Float(x + y), _ => Value::Null }); } __for_first_123 = false; i.as_f64().unwrap_or(f64::NAN) < ((tradesArray.len() as i64) as f64) } {
4890 let mut parsed: Value = Value::Null;
4891 if is_true(&isWs) {
4892 parsed = self.parse_ws_trade(tradesArray.as_array().and_then(|__arr| match &i { Value::Int(__n) => __arr.get(*__n as usize), Value::Str(__s) => __s.parse::<usize>().ok().and_then(|__n| __arr.get(__n)), _ => None }).cloned().unwrap_or(Value::Null), &[market.clone()]);
4893 } else {
4894 parsed = <Self as crate::exchange_generated::ExchangeBase>::parse_trade(self, tradesArray.as_array().and_then(|__arr| match &i { Value::Int(__n) => __arr.get(*__n as usize), Value::Str(__s) => __s.parse::<usize>().ok().and_then(|__n| __arr.get(__n)), _ => None }).cloned().unwrap_or(Value::Null), &[market.clone()]);
4895 }
4896 let mut trade: Value = self.extend(parsed, &[params.clone()]);
4897 append_to_array(&mut result, trade);
4898 }
4899 }
4900 result = self.sort_by2(result.clone(), Value::Str("timestamp".into()), Value::Str("id".into()), &[]);
4901 let mut symbol: Value = self.safe_string_k(market, "symbol", &[]);
4902 return self.filter_by_symbol_since_limit(result, &[symbol, since, limit]);
4903
4904 Value::Null
4905}
4906
4907 fn parse_trades(&self, mut trades: Value, optional_args: &[Value]) -> Value {
4908 let mut market = get_arg(optional_args, 0, Value::Null);
4909 let mut since = get_arg(optional_args, 1, Value::Null);
4910 let mut limit = get_arg(optional_args, 2, Value::Null);
4911 let mut params = get_arg(optional_args, 3, Value::Map({
4912 let mut m = indexmap::IndexMap::new();
4913 m
4914}));
4915 return self.parse_trades_helper(Value::Bool(false), trades, &[market, since, limit, params]);
4916
4917 Value::Null
4918}
4919
4920 fn parse_ws_trades(&self, mut trades: Value, optional_args: &[Value]) -> Value {
4921 let mut market = get_arg(optional_args, 0, Value::Null);
4922 let mut since = get_arg(optional_args, 1, Value::Null);
4923 let mut limit = get_arg(optional_args, 2, Value::Null);
4924 let mut params = get_arg(optional_args, 3, Value::Map({
4925 let mut m = indexmap::IndexMap::new();
4926 m
4927}));
4928 return self.parse_trades_helper(Value::Bool(true), trades, &[market, since, limit, params]);
4929
4930 Value::Null
4931}
4932
4933 fn parse_transactions(&self, mut transactions: Value, optional_args: &[Value]) -> Value {
4934 let mut currency = get_arg(optional_args, 0, Value::Null);
4935 let mut since = get_arg(optional_args, 1, Value::Null);
4936 let mut limit = get_arg(optional_args, 2, Value::Null);
4937 let mut params = get_arg(optional_args, 3, Value::Map({
4938 let mut m = indexmap::IndexMap::new();
4939 m
4940}));
4941 let mut transactionsArray: Value = self.to_array(transactions);
4942 let mut result: Value = Value::from(vec![]);
4943 {
4944 let mut i: Value = Value::Int(0);
4945 let mut __for_first_124: bool = true;
4946 while { if !__for_first_124 { i = (match (&(i), &(Value::Int(1))) { (Value::Int(x), Value::Int(y)) => Value::Int(x + y), (Value::Int(x), Value::Float(y)) => Value::Float(*x as f64 + *y), (Value::Float(x), Value::Int(y)) => Value::Float(*x + *y as f64), (Value::Float(x), Value::Float(y)) => Value::Float(x + y), _ => Value::Null }); } __for_first_124 = false; i.as_f64().unwrap_or(f64::NAN) < ((transactionsArray.len() as i64) as f64) } {
4947 let mut transaction: Value = self.extend(<Self as crate::exchange_generated::ExchangeBase>::parse_transaction(self, transactionsArray.as_array().and_then(|__arr| match &i { Value::Int(__n) => __arr.get(*__n as usize), Value::Str(__s) => __s.parse::<usize>().ok().and_then(|__n| __arr.get(__n)), _ => None }).cloned().unwrap_or(Value::Null), &[currency.clone()]), &[params.clone()]);
4948 append_to_array(&mut result, transaction);
4949 }
4950 }
4951 result = self.sort_by(result.clone(), Value::Str("timestamp".into()), &[]);
4952 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 });
4953 return self.filter_by_currency_since_limit(result, &[code, since, limit]);
4954
4955 Value::Null
4956}
4957
4958 fn parse_transfers(&self, mut transfers: Value, optional_args: &[Value]) -> Value {
4959 let mut currency = get_arg(optional_args, 0, Value::Null);
4960 let mut since = get_arg(optional_args, 1, Value::Null);
4961 let mut limit = get_arg(optional_args, 2, Value::Null);
4962 let mut params = get_arg(optional_args, 3, Value::Map({
4963 let mut m = indexmap::IndexMap::new();
4964 m
4965}));
4966 let mut transfersArray: Value = self.to_array(transfers);
4967 let mut result: Value = Value::from(vec![]);
4968 {
4969 let mut i: Value = Value::Int(0);
4970 let mut __for_first_125: bool = true;
4971 while { if !__for_first_125 { i = (match (&(i), &(Value::Int(1))) { (Value::Int(x), Value::Int(y)) => Value::Int(x + y), (Value::Int(x), Value::Float(y)) => Value::Float(*x as f64 + *y), (Value::Float(x), Value::Int(y)) => Value::Float(*x + *y as f64), (Value::Float(x), Value::Float(y)) => Value::Float(x + y), _ => Value::Null }); } __for_first_125 = false; i.as_f64().unwrap_or(f64::NAN) < ((transfersArray.len() as i64) as f64) } {
4972 let mut transfer: Value = self.extend(<Self as crate::exchange_generated::ExchangeBase>::parse_transfer(self, transfersArray.as_array().and_then(|__arr| match &i { Value::Int(__n) => __arr.get(*__n as usize), Value::Str(__s) => __s.parse::<usize>().ok().and_then(|__n| __arr.get(__n)), _ => None }).cloned().unwrap_or(Value::Null), &[currency.clone()]), &[params.clone()]);
4973 append_to_array(&mut result, transfer);
4974 }
4975 }
4976 result = self.sort_by(result.clone(), Value::Str("timestamp".into()), &[]);
4977 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 });
4978 return self.filter_by_currency_since_limit(result, &[code, since, limit]);
4979
4980 Value::Null
4981}
4982
4983 fn parse_ledger(&self, mut data: Value, optional_args: &[Value]) -> Value {
4984 let mut currency = get_arg(optional_args, 0, Value::Null);
4985 let mut since = get_arg(optional_args, 1, Value::Null);
4986 let mut limit = get_arg(optional_args, 2, Value::Null);
4987 let mut params = get_arg(optional_args, 3, Value::Map({
4988 let mut m = indexmap::IndexMap::new();
4989 m
4990}));
4991 let mut result: Value = Value::from(vec![]);
4992 let mut arrayData: Value = self.to_array(data);
4993 {
4994 let mut i: Value = Value::Int(0);
4995 let mut __for_first_127: bool = true;
4996 while { if !__for_first_127 { i = (match (&(i), &(Value::Int(1))) { (Value::Int(x), Value::Int(y)) => Value::Int(x + y), (Value::Int(x), Value::Float(y)) => Value::Float(*x as f64 + *y), (Value::Float(x), Value::Int(y)) => Value::Float(*x + *y as f64), (Value::Float(x), Value::Float(y)) => Value::Float(x + y), _ => Value::Null }); } __for_first_127 = false; i.as_f64().unwrap_or(f64::NAN) < ((arrayData.len() as i64) as f64) } {
4997 let mut itemOrItems: Value = <Self as crate::exchange_generated::ExchangeBase>::parse_ledger_entry(self, arrayData.as_array().and_then(|__arr| match &i { Value::Int(__n) => __arr.get(*__n as usize), Value::Str(__s) => __s.parse::<usize>().ok().and_then(|__n| __arr.get(__n)), _ => None }).cloned().unwrap_or(Value::Null), &[currency.clone()]);
4998 if (matches!(&itemOrItems, Value::Arr(_))) {
4999 {
5000 let mut j: Value = Value::Int(0);
5001 let mut __for_first_126: bool = true;
5002 while { if !__for_first_126 { j = (match (&(j), &(Value::Int(1))) { (Value::Int(x), Value::Int(y)) => Value::Int(x + y), (Value::Int(x), Value::Float(y)) => Value::Float(*x as f64 + *y), (Value::Float(x), Value::Int(y)) => Value::Float(*x + *y as f64), (Value::Float(x), Value::Float(y)) => Value::Float(x + y), _ => Value::Null }); } __for_first_126 = false; j.as_f64().unwrap_or(f64::NAN) < get_array_length(&itemOrItems).as_f64().unwrap_or(f64::NAN) } {
5003 append_to_array(&mut result, self.extend(get_value(&itemOrItems, &j), &[params.clone()]));
5004 }
5005 }
5006 } else {
5007 append_to_array(&mut result, self.extend(itemOrItems, &[params.clone()]));
5008 }
5009 }
5010 }
5011 result = self.sort_by(result.clone(), Value::Str("timestamp".into()), &[]);
5012 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 });
5013 return self.filter_by_currency_since_limit(result, &[code, since, limit]);
5014
5015 Value::Null
5016}
5017
5018 fn nonce(&self) -> Value {
5019 { let __v = crate::exchange::DerivedExchange::nonce(self, ); if !matches!(__v, crate::Value::Null) { return __v; } }
5021
5022 return self.seconds();
5023
5024 Value::Null
5025}
5026
5027fn incrementing_nonce(&mut self) -> Value {
5035 let mut currentNonce: Value = <Self as crate::exchange_generated::ExchangeBase>::nonce(self, );
5036 self.lock_last_nonce(&[]);
5037 let mut lastNonce: Value = self.safe_integer_k(self.options.clone(), "lastNonce", &[Value::Int(0)]);
5038 let mut result: Value = (if (currentNonce.as_f64().unwrap_or(f64::NAN) > lastNonce.as_f64().unwrap_or(f64::NAN)) { currentNonce } else { (match (&(lastNonce), &(Value::Int(1))) { (Value::Int(x), Value::Int(y)) => Value::Int(x + y), (Value::Int(x), Value::Float(y)) => Value::Float(*x as f64 + *y), (Value::Float(x), Value::Int(y)) => Value::Float(*x + *y as f64), (Value::Float(x), Value::Float(y)) => Value::Float(x + y), _ => Value::Null }) });
5039 if let Value::Dict(__d) = &mut self.options { std::sync::Arc::make_mut(__d).insert("lastNonce".into(), result.clone()); }
5040 self.unlock_last_nonce(&[]);
5041 return result;
5042
5043 Value::Null
5044}
5045
5046 fn set_headers(&self, mut headers: Value) -> Value {
5047 return headers;
5048
5049 Value::Null
5050}
5051
5052 fn currency_id(&self, mut code: Value) -> Value {
5053 if (code == Value::Null) {
5054 return code;
5055 }
5056 let mut currency: Value = self.safe_dict(self.currencies.clone(), code.clone(), &[]);
5057 if (currency == Value::Null) {
5058 currency = self.safe_currency(code.clone(), &[]);
5059 }
5060 if (currency != Value::Null) {
5061 return currency.as_map().and_then(|__m| __m.get("id")).cloned().unwrap_or(Value::Null);
5062 }
5063 return code;
5064
5065 Value::Null
5066}
5067
5068 fn market_id(&self, mut symbol: Value) -> Value {
5069 let mut market: Value = self.market(symbol.clone());
5070 if (market != Value::Null) {
5071 return market.as_map().and_then(|__m| __m.get("id")).cloned().unwrap_or(Value::Null);
5072 }
5073 return symbol;
5074
5075 Value::Null
5076}
5077
5078 fn symbol(&self, mut symbol: Value) -> Value {
5079 if (symbol == Value::Null) {
5080 panic!("{}", crate::exchange_errors::arguments_required(format!("{}{}", self.id.clone(), Value::Str(" symbol() requires a symbol argument".into()))));
5081 }
5082 let mut market: Value = self.market(symbol.clone());
5083 return self.safe_string_k(market, "symbol", &[symbol]);
5084
5085 Value::Null
5086}
5087
5088fn handle_param_string(&self, mut params: Value, mut paramName: Value, optional_args: &[Value]) -> Value {
5091 let mut defaultValue = get_arg(optional_args, 0, Value::Null);
5092 let mut value: Value = self.safe_string(params.clone(), paramName.clone(), &[defaultValue]);
5093 let mut paramsOmitted: Value = (if (value != Value::Null) { self.omit(params.clone(), paramName, &[]) } else { params });
5094 return Value::from(vec![value, paramsOmitted]);
5095
5096 Value::Null
5097}
5098
5099fn handle_param_string2(&self, mut params: Value, mut paramName1: Value, mut paramName2: Value, optional_args: &[Value]) -> Value {
5102 let mut defaultValue = get_arg(optional_args, 0, Value::Null);
5103 let mut value: Value = self.safe_string2(params.clone(), paramName1.clone(), paramName2.clone(), &[defaultValue]);
5104 let mut paramsOmitted: Value = (if (value != Value::Null) { self.omit(params.clone(), Value::from(vec![paramName1, paramName2]), &[]) } else { params });
5105 return Value::from(vec![value, paramsOmitted]);
5106
5107 Value::Null
5108}
5109
5110 fn handle_param_integer(&self, mut params: Value, mut paramName: Value, optional_args: &[Value]) -> Value {
5111 let mut defaultValue = get_arg(optional_args, 0, Value::Null);
5112 let mut value: Value = self.safe_integer(params.clone(), paramName.clone(), &[defaultValue]);
5113 let mut paramsOmitted: Value = (if (value != Value::Null) { self.omit(params.clone(), paramName, &[]) } else { params });
5114 return Value::from(vec![value, paramsOmitted]);
5115
5116 Value::Null
5117}
5118
5119 fn handle_param_integer2(&self, mut params: Value, mut paramName1: Value, mut paramName2: Value, optional_args: &[Value]) -> Value {
5120 let mut defaultValue = get_arg(optional_args, 0, Value::Null);
5121 let mut value: Value = self.safe_integer2(params.clone(), paramName1.clone(), paramName2.clone(), &[defaultValue]);
5122 let mut paramsOmitted: Value = (if (value != Value::Null) { self.omit(params.clone(), Value::from(vec![paramName1, paramName2]), &[]) } else { params });
5123 return Value::from(vec![value, paramsOmitted]);
5124
5125 Value::Null
5126}
5127
5128 fn handle_param_bool(&self, mut params: Value, mut paramName: Value, optional_args: &[Value]) -> Value {
5129 let mut defaultValue = get_arg(optional_args, 0, Value::Null);
5130 let mut value: Value = self.safe_bool(params.clone(), paramName.clone(), &[defaultValue]);
5131 let mut paramsOmitted: Value = (if (value != Value::Null) { self.omit(params.clone(), paramName, &[]) } else { params });
5132 return Value::from(vec![value, paramsOmitted]);
5133
5134 Value::Null
5135}
5136
5137 fn handle_param_bool2(&self, mut params: Value, mut paramName1: Value, mut paramName2: Value, optional_args: &[Value]) -> Value {
5138 let mut defaultValue = get_arg(optional_args, 0, Value::Null);
5139 let mut value: Value = self.safe_bool2(params.clone(), paramName1.clone(), paramName2.clone(), &[defaultValue]);
5140 let mut paramsOmitted: Value = (if (value != Value::Null) { self.omit(params.clone(), Value::from(vec![paramName1, paramName2]), &[]) } else { params });
5141 return Value::from(vec![value, paramsOmitted]);
5142
5143 Value::Null
5144}
5145
5146fn handle_request_network(&self, mut params: Value, mut request: Value, mut exchangeSpecificKey: Value, optional_args: &[Value]) -> Value {
5155 let mut currencyCode = get_arg(optional_args, 0, Value::Null);
5156 let mut isRequired = get_arg(optional_args, 1, Value::Bool(false));
5157 let mut networkCodeparamsNetworkCodeVariable = self.handle_network_code_and_params(params);
5158 let mut networkCode: Value = networkCodeparamsNetworkCodeVariable.as_array().and_then(|__arr| __arr.get(0)).cloned().unwrap_or(Value::Null);
5159 let mut paramsNetworkCode: Value = networkCodeparamsNetworkCodeVariable.as_array().and_then(|__arr| __arr.get(1)).cloned().unwrap_or(Value::Null);
5160 if (networkCode != Value::Null) {
5161 if let Value::Dict(__d) = &mut request { std::sync::Arc::make_mut(__d).insert(crate::runtime::stringify_param(&exchangeSpecificKey), self.network_code_to_id(networkCode, &[currencyCode])); }
5162 } else if is_true(&isRequired) {
5163 panic!("{}", crate::exchange_errors::arguments_required(format!("{}{}", self.id.clone(), Value::Str(" - \"network\" param is required for this request".into()))));
5164 }
5165 return Value::from(vec![request, paramsNetworkCode]);
5166
5167 Value::Null
5168}
5169
5170 fn resolve_path(&self, mut path: Value, mut params: Value) -> Value {
5171 return Value::from(vec![self.implode_params(path.clone(), params.clone()), self.omit(params, self.extract_params(path), &[])]);
5172
5173 Value::Null
5174}
5175
5176 fn get_list_from_object_values(&self, mut objects: Value, mut key: Value) -> Value {
5177 let mut newArray: Value = objects.clone();
5178 if !(matches!(&objects, Value::Arr(_))) {
5179 newArray = self.to_array(objects.clone());
5180 }
5181 let mut results: Value = Value::from(vec![]);
5182 {
5183 let mut i: Value = Value::Int(0);
5184 let mut __for_first_128: bool = true;
5185 while { if !__for_first_128 { i = (match (&(i), &(Value::Int(1))) { (Value::Int(x), Value::Int(y)) => Value::Int(x + y), (Value::Int(x), Value::Float(y)) => Value::Float(*x as f64 + *y), (Value::Float(x), Value::Int(y)) => Value::Float(*x + *y as f64), (Value::Float(x), Value::Float(y)) => Value::Float(x + y), _ => Value::Null }); } __for_first_128 = false; i.as_f64().unwrap_or(f64::NAN) < get_array_length(&newArray).as_f64().unwrap_or(f64::NAN) } {
5186 append_to_array(&mut results, get_value(&get_value(&newArray, &i), &key));
5187 }
5188 }
5189 return results;
5190
5191 Value::Null
5192}
5193
5194 fn get_symbols_for_market_type(&self, optional_args: &[Value]) -> Value {
5195 let mut marketType = get_arg(optional_args, 0, Value::Null);
5196 let mut subType = get_arg(optional_args, 1, Value::Null);
5197 let mut symbolWithActiveStatus = get_arg(optional_args, 2, Value::Bool(true));
5198 let mut symbolWithUnknownStatus = get_arg(optional_args, 3, Value::Bool(true));
5199 let mut filteredMarkets: Value = self.markets.clone();
5200 if (marketType != Value::Null) {
5201 filteredMarkets = self.filter_by(filteredMarkets.clone(), Value::Str("type".into()), marketType, &[]);
5202 }
5203 if (subType != Value::Null) {
5204 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())])]);
5205 filteredMarkets = self.filter_by(filteredMarkets.clone(), Value::Str("subType".into()), subType, &[]);
5206 }
5207 let mut activeStatuses: Value = Value::from(vec![]);
5208 if is_true(&symbolWithActiveStatus) {
5209 append_to_array(&mut activeStatuses, Value::Bool(true));
5210 }
5211 if is_true(&symbolWithUnknownStatus) {
5212 append_to_array(&mut activeStatuses, Value::Null);
5213 }
5214 filteredMarkets = self.filter_by_array(filteredMarkets.clone(), Value::Str("active".into()), &[activeStatuses, Value::Bool(false)]);
5215 return self.get_list_from_object_values(filteredMarkets, Value::Str("symbol".into()));
5216
5217 Value::Null
5218}
5219
5220 fn filter_by_array(&self, mut objects: Value, mut key: Value, optional_args: &[Value]) -> Value {
5221 let mut values = get_arg(optional_args, 0, Value::Null);
5222 let mut indexed = get_arg(optional_args, 1, Value::Bool(true));
5223 let mut objectsValue: Value = self.to_array(objects);
5224 if (values == Value::Null) || (values == Value::Null) || (is_equal(&values, &Value::Bool(false))) || (is_equal(&values, &Value::Int(0))) || (values.as_str() == Some("")) {
5226 if is_true(&indexed) {
5228 return self.index_by(objectsValue.clone(), key.clone());
5229 } else {
5230 return objectsValue;
5231 }
5232 }
5233 let mut results: Value = Value::from(vec![]);
5234 {
5235 let mut i: Value = Value::Int(0);
5236 let mut __for_first_129: bool = true;
5237 while { if !__for_first_129 { i = (match (&(i), &(Value::Int(1))) { (Value::Int(x), Value::Int(y)) => Value::Int(x + y), (Value::Int(x), Value::Float(y)) => Value::Float(*x as f64 + *y), (Value::Float(x), Value::Int(y)) => Value::Float(*x + *y as f64), (Value::Float(x), Value::Float(y)) => Value::Float(x + y), _ => Value::Null }); } __for_first_129 = false; i.as_f64().unwrap_or(f64::NAN) < get_array_length(&objectsValue).as_f64().unwrap_or(f64::NAN) } {
5238 if self.in_array(get_value(&get_value(&objectsValue, &i), &key), values.clone()).as_bool() == Some(true) {
5239 append_to_array(&mut results, get_value(&objectsValue, &i));
5240 }
5241 }
5242 }
5243 if is_true(&indexed) {
5245 return self.index_by(results.clone(), key);
5246 }
5247 return results;
5248
5249 Value::Null
5250}
5251
5252 fn filter_out_by_array(&self, mut objects: Value, mut key: Value, optional_args: &[Value]) -> Value {
5253 let mut values = get_arg(optional_args, 0, Value::Null);
5254 let mut indexed = get_arg(optional_args, 1, Value::Bool(true));
5255 let mut objectsValue: Value = self.to_array(objects);
5256 if (values == Value::Null) || (values == Value::Null) || (is_equal(&values, &Value::Bool(false))) || (is_equal(&values, &Value::Int(0))) || (values.as_str() == Some("")) {
5258 if is_true(&indexed) {
5260 return self.index_by(objectsValue.clone(), key.clone());
5261 } else {
5262 return objectsValue;
5263 }
5264 }
5265 let mut results: Value = Value::from(vec![]);
5266 {
5267 let mut i: Value = Value::Int(0);
5268 let mut __for_first_130: bool = true;
5269 while { if !__for_first_130 { i = (match (&(i), &(Value::Int(1))) { (Value::Int(x), Value::Int(y)) => Value::Int(x + y), (Value::Int(x), Value::Float(y)) => Value::Float(*x as f64 + *y), (Value::Float(x), Value::Int(y)) => Value::Float(*x + *y as f64), (Value::Float(x), Value::Float(y)) => Value::Float(x + y), _ => Value::Null }); } __for_first_130 = false; i.as_f64().unwrap_or(f64::NAN) < get_array_length(&objectsValue).as_f64().unwrap_or(f64::NAN) } {
5270 if !(self.in_array(get_value(&get_value(&objectsValue, &i), &key), values.clone()).as_bool() == Some(true)) {
5271 append_to_array(&mut results, get_value(&objectsValue, &i));
5272 }
5273 }
5274 }
5275 if is_true(&indexed) {
5277 return self.index_by(results.clone(), key);
5278 }
5279 return results;
5280
5281 Value::Null
5282}
5283
5284 fn fetch2(&mut self, mut path: Value, optional_args: &[Value]) -> impl ::std::future::Future<Output = Value> + Send { async move {
5285 let mut api = get_arg(optional_args, 0, Value::Str("public".into()));
5286 let mut method = get_arg(optional_args, 1, Value::Str("GET".into()));
5287 let mut params = get_arg(optional_args, 2, Value::Map({
5288 let mut m = indexmap::IndexMap::new();
5289 m
5290}));
5291 let mut headers = get_arg(optional_args, 3, Value::Null);
5292 let mut body = get_arg(optional_args, 4, Value::Null);
5293 let mut config = get_arg(optional_args, 5, Value::Map({
5294 let mut m = indexmap::IndexMap::new();
5295 m
5296}));
5297 if is_true(&self.enableRateLimit) {
5298 let mut cost: Value = self.calculate_rate_limiter_cost(api.clone(), method.clone(), path.clone(), params.clone(), &[config]);
5299 self.throttle(&[cost]).await;
5300 }
5301 let mut retries: Value = Value::Int(0);
5302 let mut requestParams: Value = params;
5304 let mut retriesMaxRetriesOnFailureparamsMaxRetriesOnFailureVariable = self.handle_option_integer_and_params(requestParams, path.clone(), Value::Str("maxRetriesOnFailure".into()), &[retries]);
5305 let mut retriesMaxRetriesOnFailure: Value = retriesMaxRetriesOnFailureparamsMaxRetriesOnFailureVariable.as_array().and_then(|__arr| __arr.get(0)).cloned().unwrap_or(Value::Null);
5306 let mut paramsMaxRetriesOnFailure: Value = retriesMaxRetriesOnFailureparamsMaxRetriesOnFailureVariable.as_array().and_then(|__arr| __arr.get(1)).cloned().unwrap_or(Value::Null);
5307 let mut retryDelay: Value = Value::Int(0);
5308 let mut retryDelayMaxRetriesOnFailureDelayparamsMaxRetriesOnFailureDelayVariable = self.handle_option_integer_and_params(paramsMaxRetriesOnFailure, path.clone(), Value::Str("maxRetriesOnFailureDelay".into()), &[retryDelay]);
5309 let mut retryDelayMaxRetriesOnFailureDelay: Value = retryDelayMaxRetriesOnFailureDelayparamsMaxRetriesOnFailureDelayVariable.as_array().and_then(|__arr| __arr.get(0)).cloned().unwrap_or(Value::Null);
5310 let mut paramsMaxRetriesOnFailureDelay: Value = retryDelayMaxRetriesOnFailureDelayparamsMaxRetriesOnFailureDelayVariable.as_array().and_then(|__arr| __arr.get(1)).cloned().unwrap_or(Value::Null);
5311 let mut fetchDataCacheEnabled: bool = self.fetchHistoryCacheSize.as_f64().unwrap_or(f64::NAN) > ((0i64) as f64);
5312 {
5313 let mut i: Value = Value::Int(0);
5314 let mut __for_first_131: bool = true;
5315 while { if !__for_first_131 { i = (match (&(i), &(Value::Int(1))) { (Value::Int(x), Value::Int(y)) => Value::Int(x + y), (Value::Int(x), Value::Float(y)) => Value::Float(*x as f64 + *y), (Value::Float(x), Value::Int(y)) => Value::Float(*x + *y as f64), (Value::Float(x), Value::Float(y)) => Value::Float(x + y), _ => Value::Null }); } __for_first_131 = false; i.as_f64().unwrap_or(f64::NAN) < add(&retriesMaxRetriesOnFailure, &Value::Int(1)).as_f64().unwrap_or(f64::NAN) } {
5316 let mut fetchData: Value = Value::Null;
5317 if fetchDataCacheEnabled {
5318 fetchData = Value::Map({
5319 let mut m = indexmap::IndexMap::new();
5320 m.insert("request".to_string(), Value::Null);
5321 m.insert("response".to_string(), Value::Map({
5322 let mut m = indexmap::IndexMap::new();
5323 m.insert("body".to_string(), Value::Null);
5324 m
5325}));
5326 m.insert("error".to_string(), Value::Null);
5327 m
5328 });
5329 }
5330 let _try_result = futures::FutureExt::catch_unwind(std::panic::AssertUnwindSafe(async {
5331 self.set_last_rest_request_timestamp();
5332 let mut request: Value = <Self as crate::exchange_generated::ExchangeBase>::sign(self, path.clone(), &[api.clone(), method.clone(), paramsMaxRetriesOnFailureDelay.clone(), headers.clone(), body.clone()]);
5333 if (fetchData != Value::Null) {
5334 add_element_to_object(&mut fetchData, &Value::Str("request".into()), request.clone());
5335 }
5336 self.set_last_request(request.clone());
5337 let mut response: Value = self.fetch(request.as_map().and_then(|__m| __m.get("url")).cloned().unwrap_or(Value::Null), &[request.as_map().and_then(|__m| __m.get("method")).cloned().unwrap_or(Value::Null), request.as_map().and_then(|__m| __m.get("headers")).cloned().unwrap_or(Value::Null), request.as_map().and_then(|__m| __m.get("body")).cloned().unwrap_or(Value::Null)]).await;
5338 if (fetchData != Value::Null) {
5339 add_element_to_object(get_value_mut(&mut fetchData, &Value::Str("response".into())), &Value::Str("body".into()), response.clone());
5340 self.add_fetch_cache(fetchData.clone());
5341 }
5342 return response;
5343 #[allow(unreachable_code)] { Value::Null }})).await;
5344match _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);
5345 if (fetchData != Value::Null) {
5346 add_element_to_object(&mut fetchData, &Value::Str("error".into()), e.clone());
5347 self.add_fetch_cache(fetchData);
5348 }
5349 if is_instance(&e, &Value::Str("OperationFailed".into())) {
5350 if i.as_f64().unwrap_or(f64::NAN) < retriesMaxRetriesOnFailure.as_f64().unwrap_or(f64::NAN) {
5351 if is_true(&self.verbose) {
5352 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 });
5353 self.log(Value::Str(format!("{}{}", Value::Str(format!("{}{}", Value::Str(format!("{}{}", Value::Str(format!("{}{}", Value::Str(format!("{}{}", Value::Str(format!("{}{}", Value::Str("Request failed with the error: ".into()), to_string_val(&e)).into()), Value::Str(", retrying ".into())).into()), to_string_val(&index)).into()), Value::Str(" of ".into())).into()), to_string_val(&retriesMaxRetriesOnFailure)).into()), Value::Str("...".into())).into()));
5354 }
5355 if (retryDelayMaxRetriesOnFailureDelay != Value::Null) && (retryDelayMaxRetriesOnFailureDelay.as_f64() != Some(0.0)) {
5356 self.sleep(retryDelayMaxRetriesOnFailureDelay.clone()).await;
5357 }
5358 } else {
5359 panic!("{}", e);
5360 }
5361 } else {
5362 panic!("{}", e);
5363 }
5364 } }
5365 }
5366 }
5367 return Value::Null;
5368
5369 Value::Null
5370} }
5371
5372 fn request(&mut self, mut path: Value, optional_args: &[Value]) -> impl ::std::future::Future<Output = Value> + Send { async move {
5373 let mut api = get_arg(optional_args, 0, Value::Str("public".into()));
5374 let mut method = get_arg(optional_args, 1, Value::Str("GET".into()));
5375 let mut params = get_arg(optional_args, 2, Value::Map({
5376 let mut m = indexmap::IndexMap::new();
5377 m
5378}));
5379 let mut headers = get_arg(optional_args, 3, Value::Null);
5380 let mut body = get_arg(optional_args, 4, Value::Null);
5381 let mut config = get_arg(optional_args, 5, Value::Map({
5382 let mut m = indexmap::IndexMap::new();
5383 m
5384}));
5385 return self.fetch2(path, &[api, method, params, headers, body, config]).await;
5386
5387 Value::Null
5388} }
5389
5390 fn load_accounts(&mut self, optional_args: &[Value]) -> impl ::std::future::Future<Output = Value> + Send { async move {
5391 let mut reload = get_arg(optional_args, 0, Value::Bool(false));
5392 let mut params = get_arg(optional_args, 1, Value::Map({
5393 let mut m = indexmap::IndexMap::new();
5394 m
5395}));
5396 if is_true(&reload) {
5397 { let __t = self.fetch_accounts(&[params.clone()]).await; self.accounts = __t; }
5398 } else {
5399 if (self.accounts.clone() != Value::Null) {
5400 return self.accounts.clone();
5401 } else {
5402 { let __t = self.fetch_accounts(&[params]).await; self.accounts = __t; }
5403 }
5404 }
5405 { let __t = self.index_by(self.accounts.clone(), Value::Str("id".into())); self.accountsById = __t; }
5406 return self.accounts.clone();
5407
5408 Value::Null
5409} }
5410
5411 fn build_ohlcvc(&self, mut trades: Value, optional_args: &[Value]) -> Value {
5412 let mut timeframe = get_arg(optional_args, 0, Value::Str("1m".into()));
5413 let mut since = get_arg(optional_args, 1, Value::Int(0));
5414 let mut limit = get_arg(optional_args, 2, Value::Int(2147483647));
5415 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 });
5418 let mut ohlcvs: Value = Value::from(vec![]);
5419 let mut i_timestamp: Value = Value::Int(0);
5420 let mut i_high: Value = Value::Int(2);
5422 let mut i_low: Value = Value::Int(3);
5423 let mut i_close: Value = Value::Int(4);
5424 let mut i_volume: Value = Value::Int(5);
5425 let mut i_count: Value = Value::Int(6);
5426 let mut tradesLength: Value = Value::Int(trades.len() as i64);
5427 let mut oldest: Value = crate::runtime::Math::min(&tradesLength, &limit);
5428 let mut options: Value = self.safe_dict_k(self.options.clone(), "buildOHLCVC", &[Value::Map({
5429 let mut m = indexmap::IndexMap::new();
5430 m
5431})]);
5432 let mut skipZeroPrices: Value = self.safe_bool_k(options, "skipZeroPrices", &[Value::Bool(true)]);
5433 {
5434 let mut i: Value = Value::Int(0);
5435 let mut __for_first_132: bool = true;
5436 while { if !__for_first_132 { i = (match (&(i), &(Value::Int(1))) { (Value::Int(x), Value::Int(y)) => Value::Int(x + y), (Value::Int(x), Value::Float(y)) => Value::Float(*x as f64 + *y), (Value::Float(x), Value::Int(y)) => Value::Float(*x + *y as f64), (Value::Float(x), Value::Float(y)) => Value::Float(x + y), _ => Value::Null }); } __for_first_132 = false; i.as_f64().unwrap_or(f64::NAN) < oldest.as_f64().unwrap_or(f64::NAN) } {
5437 let mut trade: Value = trades.as_array().and_then(|__arr| match &i { Value::Int(__n) => __arr.get(*__n as usize), Value::Str(__s) => __s.parse::<usize>().ok().and_then(|__n| __arr.get(__n)), _ => None }).cloned().unwrap_or(Value::Null);
5438 let mut ts: Value = trade.as_map().and_then(|__m| __m.get("timestamp")).cloned().unwrap_or(Value::Null);
5439 let mut price: Value = trade.as_map().and_then(|__m| __m.get("price")).cloned().unwrap_or(Value::Null);
5440 if (ts == Value::Null) || (price == Value::Null) {
5441 continue;
5442 }
5443 if ts.as_f64().unwrap_or(f64::NAN) < since.as_f64().unwrap_or(f64::NAN) {
5444 continue;
5445 }
5446 if (ts == Value::Null) {
5447 panic!("{}", crate::exchange_errors::exchange_error(format!("{}{}", self.id.clone(), Value::Str(" buildOHLCVC() missing ts".into()))));
5448 }
5449 let mut openingTime: Value = (match (&(math_floor(&(match ((ts).as_f64(), (ms).as_f64()) { (Some(x), Some(y)) if y != 0.0 => Value::Float(x / y), _ => Value::Null }))), &(ms)) { (Value::Int(x), Value::Int(y)) => Value::Int(x * y), (Value::Int(x), Value::Float(y)) => Value::Float(*x as f64 * *y), (Value::Float(x), Value::Int(y)) => Value::Float(*x * *y as f64), (Value::Float(x), Value::Float(y)) => Value::Float(x * y), _ => Value::Null }); if openingTime.as_f64().unwrap_or(f64::NAN) < since.as_f64().unwrap_or(f64::NAN) {
5451 continue;
5452 }
5453 let mut ohlcv_length: Value = Value::Int(ohlcvs.len() as i64);
5454 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 });
5455 if (price == Value::Null) {
5456 panic!("{}", crate::exchange_errors::arguments_required(format!("{}{}", self.id.clone(), Value::Str(" buildOHLCVC() requires a price argument".into()))));
5457 }
5458 if (skipZeroPrices.as_bool() == Some(true)) && !(price.as_f64().unwrap_or(f64::NAN) > ((0i64) as f64)) && !(price.as_f64().unwrap_or(f64::NAN) < ((0i64) as f64)) {
5459 continue;
5460 }
5461 let mut isNewCandle: bool = candle.as_f64() == Value::Int(-1).as_f64();
5462 if !isNewCandle {
5463 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);
5464 if (candleTimestamp == Value::Null) {
5465 panic!("{}", crate::exchange_errors::exchange_error(format!("{}{}", self.id.clone(), Value::Str(" buildOHLCVC() missing candle timestamp".into()))));
5466 }
5467 isNewCandle = openingTime.as_f64().unwrap_or(f64::NAN) >= (match (&(candleTimestamp), &(ms)) { (Value::Int(x), Value::Int(y)) => Value::Int(x + y), (Value::Int(x), Value::Float(y)) => Value::Float(*x as f64 + *y), (Value::Float(x), Value::Int(y)) => Value::Float(*x + *y as f64), (Value::Float(x), Value::Float(y)) => Value::Float(x + y), _ => Value::Null }).as_f64().unwrap_or(f64::NAN);
5468 }
5469 if isNewCandle {
5470 append_to_array(&mut ohlcvs, Value::from(vec![openingTime, price.clone(), price.clone(), price.clone(), price.clone(), trade.as_map().and_then(|__m| __m.get("amount")).cloned().unwrap_or(Value::Null), Value::Int(1)]));
5472 } else {
5473 let mut prevHigh: Value = get_value(&ohlcvs, &candle).as_array().and_then(|__arr| match &i_high { Value::Int(__n) => __arr.get(*__n as usize), Value::Str(__s) => __s.parse::<usize>().ok().and_then(|__n| __arr.get(__n)), _ => None }).cloned().unwrap_or(Value::Null);
5475 let mut prevLow: Value = get_value(&ohlcvs, &candle).as_array().and_then(|__arr| match &i_low { Value::Int(__n) => __arr.get(*__n as usize), Value::Str(__s) => __s.parse::<usize>().ok().and_then(|__n| __arr.get(__n)), _ => None }).cloned().unwrap_or(Value::Null);
5476 let mut prevHighValue: Value = (if (prevHigh == Value::Null) { price.clone() } else { prevHigh });
5477 let mut prevLowValue: Value = (if (prevLow == Value::Null) { price.clone() } else { prevLow });
5478 add_element_to_object(get_value_mut(&mut ohlcvs, &candle), &i_high, crate::runtime::Math::max(&prevHighValue, &price));
5479 add_element_to_object(get_value_mut(&mut ohlcvs, &candle), &i_low, crate::runtime::Math::min(&prevLowValue, &price));
5480 add_element_to_object(get_value_mut(&mut ohlcvs, &candle), &i_close, price);
5481 { let __be_tmp = self.sum(&[get_value(&get_value(&ohlcvs, &candle), &i_volume), trade.as_map().and_then(|__m| __m.get("amount")).cloned().unwrap_or(Value::Null)]); add_element_to_object(get_value_mut(&mut ohlcvs, &candle), &i_volume, __be_tmp); };
5482 { let __be_tmp = self.sum(&[get_value(&get_value(&ohlcvs, &candle), &i_count), Value::Int(1)]); add_element_to_object(get_value_mut(&mut ohlcvs, &candle), &i_count, __be_tmp); };
5483 }
5484 }
5485 }
5486 return ohlcvs;
5487
5488 Value::Null
5489}
5490
5491 fn parse_trading_view_ohlcv(&self, mut ohlcvs: Value, optional_args: &[Value]) -> Value {
5492 let mut market = get_arg(optional_args, 0, Value::Null);
5493 let mut timeframe = get_arg(optional_args, 1, Value::Str("1m".into()));
5494 let mut since = get_arg(optional_args, 2, Value::Null);
5495 let mut limit = get_arg(optional_args, 3, Value::Null);
5496 let mut result: Value = self.convert_trading_view_to_ohlcv(ohlcvs, &[]);
5497 return self.parse_ohlc_vs(result, &[market, timeframe, since, limit]);
5498
5499 Value::Null
5500}
5501
5502 fn fetch_borrow_interest(&mut self, optional_args: &[Value]) -> impl ::std::future::Future<Output = Value> + Send { async move {
5503 let mut code = get_arg(optional_args, 0, Value::Null);
5504 let mut symbol = get_arg(optional_args, 1, Value::Null);
5505 let mut since = get_arg(optional_args, 2, Value::Null);
5506 let mut limit = get_arg(optional_args, 3, Value::Null);
5507 let mut params = get_arg(optional_args, 4, Value::Map({
5508 let mut m = indexmap::IndexMap::new();
5509 m
5510}));
5511 panic!("{}", crate::exchange_errors::not_supported(format!("{}{}", self.id.clone(), Value::Str(" fetchBorrowInterest() is not supported yet".into()))));
5512
5513 Value::Null
5514} }
5515
5516 fn fetch_ledger(&mut self, optional_args: &[Value]) -> impl ::std::future::Future<Output = Value> + Send { async move {
5517 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 {
5519 if !matches!(__v, crate::Value::Null) { return __v; }
5520 }
5521
5522 let mut code = get_arg(optional_args, 0, Value::Null);
5523 let mut since = get_arg(optional_args, 1, Value::Null);
5524 let mut limit = get_arg(optional_args, 2, Value::Null);
5525 let mut params = get_arg(optional_args, 3, Value::Map({
5526 let mut m = indexmap::IndexMap::new();
5527 m
5528}));
5529 panic!("{}", crate::exchange_errors::not_supported(format!("{}{}", self.id.clone(), Value::Str(" fetchLedger() is not supported yet".into()))));
5530
5531 Value::Null
5532} }
5533
5534 fn fetch_ledger_entry(&mut self, mut id: Value, optional_args: &[Value]) -> impl ::std::future::Future<Output = Value> + Send { async move {
5535 let mut code = get_arg(optional_args, 0, Value::Null);
5536 let mut params = get_arg(optional_args, 1, Value::Map({
5537 let mut m = indexmap::IndexMap::new();
5538 m
5539}));
5540 panic!("{}", crate::exchange_errors::not_supported(format!("{}{}", self.id.clone(), Value::Str(" fetchLedgerEntry() is not supported yet".into()))));
5541
5542 Value::Null
5543} }
5544
5545 fn parse_order_book_bid_ask(&self, mut bidask: Value, optional_args: &[Value]) -> Value {
5546 let mut priceKey = get_arg(optional_args, 0, Value::Int(0));
5547 let mut amountKey = get_arg(optional_args, 1, Value::Int(1));
5548 let mut countOrIdKey = get_arg(optional_args, 2, Value::Int(2));
5549 let mut price: Value = self.safe_float(bidask.clone(), priceKey, &[]);
5550 let mut amount: Value = self.safe_float(bidask.clone(), amountKey, &[]);
5551 let mut countOrId: Value = self.safe_integer(bidask, countOrIdKey, &[]);
5552 let mut bidAsk: Value = Value::from(vec![price, amount]);
5553 if (countOrId != Value::Null) {
5554 append_to_array(&mut bidAsk, countOrId);
5555 }
5556 return bidAsk;
5557
5558 Value::Null
5559}
5560
5561 fn safe_currency(&self, mut currencyId: Value, optional_args: &[Value]) -> Value {
5562 let mut currency = get_arg(optional_args, 0, Value::Null);
5563 if (currencyId == Value::Null) && (currency != Value::Null) {
5564 return currency;
5565 }
5566 if (currencyId != Value::Null) && (self.currencies_by_id.clone() != Value::Null) && (in_op(&self.currencies_by_id, ¤cyId)) && (get_value(&self.currencies_by_id, ¤cyId) != Value::Null) {
5567 return get_value(&self.currencies_by_id, ¤cyId);
5568 }
5569 let mut code: Value = currencyId.clone();
5570 if (currencyId != Value::Null) {
5571 code = self.common_currency_code(to_upper(¤cyId));
5572 }
5573 return self.safe_currency_structure(Value::Map({
5574 let mut m = indexmap::IndexMap::new();
5575 m.insert("id".to_string(), currencyId);
5576 m.insert("code".to_string(), code);
5577 m.insert("precision".to_string(), Value::Null);
5578 m
5579}));
5580
5581 Value::Null
5582}
5583
5584 fn safe_market(&self, optional_args: &[Value]) -> Value {
5585 let mut marketId = get_arg(optional_args, 0, Value::Null);
5586 let mut market = get_arg(optional_args, 1, Value::Null);
5587 let mut delimiter = get_arg(optional_args, 2, Value::Null);
5588 let mut marketType = get_arg(optional_args, 3, Value::Null);
5589 if (marketId != Value::Null) {
5590 if (self.markets_by_id.clone() != Value::Null) && (in_op(&self.markets_by_id, &marketId)) {
5591 let mut markets: Value = get_value(&self.markets_by_id, &marketId);
5592 let mut numMarkets: Value = get_array_length(&markets);
5593 if is_equal(&numMarkets, &Value::Int(1)) {
5594 return get_value(&markets, &Value::Int(0));
5595 } else {
5596 if (marketType == Value::Null) && (market == Value::Null) {
5597 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()))));
5598 }
5599 let mut marketTypeResolved: Value = (if (marketType == Value::Null) { self.safe_string_k(market.clone(), "type", &[Value::Str("".into())]) } else { marketType });
5600 {
5601 let mut i: Value = Value::Int(0);
5602 let mut __for_first_133: bool = true;
5603 while { if !__for_first_133 { i = (match (&(i), &(Value::Int(1))) { (Value::Int(x), Value::Int(y)) => Value::Int(x + y), (Value::Int(x), Value::Float(y)) => Value::Float(*x as f64 + *y), (Value::Float(x), Value::Int(y)) => Value::Float(*x + *y as f64), (Value::Float(x), Value::Float(y)) => Value::Float(x + y), _ => Value::Null }); } __for_first_133 = false; i.as_f64().unwrap_or(f64::NAN) < get_array_length(&markets).as_f64().unwrap_or(f64::NAN) } {
5604 let mut currentMarket: Value = get_value(&markets, &i);
5605 let mut currentMarket: Value = get_value(&markets, &i);
5606 if is_equal(&get_value(¤tMarket, &marketTypeResolved), &Value::Bool(true)) {
5607 return currentMarket;
5608 }
5609 }
5610 }
5611 }
5612 } else if (delimiter != Value::Null) && (delimiter.as_str() != Some("")) {
5613 let mut parts: Value = split(&marketId, &delimiter);
5614 let mut partsLength: f64 = ((parts.len() as i64) as f64);
5615 let mut result: Value = self.safe_market_structure(&[Value::Map({
5616 let mut m = indexmap::IndexMap::new();
5617 m.insert("symbol".to_string(), marketId.clone());
5618 m.insert("marketId".to_string(), marketId.clone());
5619 m
5620})]);
5621 if (result == Value::Null) {
5622 panic!("{}", crate::exchange_errors::exchange_error(format!("{}{}", self.id.clone(), Value::Str(" safeMarket() failed to build market structure".into()))));
5623 }
5624 if (partsLength == 2.0) {
5625 let mut baseId: Value = self.safe_string(parts.clone(), Value::Int(0), &[]);
5626 let mut quoteId: Value = self.safe_string(parts, Value::Int(1), &[]);
5627 let mut base: Value = self.safe_currency_code(baseId.clone(), &[]);
5628 let mut quote: Value = self.safe_currency_code(quoteId.clone(), &[]);
5629 if let Value::Dict(__d) = &mut result { std::sync::Arc::make_mut(__d).insert("baseId".into(), baseId); }
5630 if let Value::Dict(__d) = &mut result { std::sync::Arc::make_mut(__d).insert("quoteId".into(), quoteId); }
5631 if (base != Value::Null) {
5632 if let Value::Dict(__d) = &mut result { std::sync::Arc::make_mut(__d).insert("base".into(), base.clone()); }
5633 }
5634 if (quote != Value::Null) {
5635 if let Value::Dict(__d) = &mut result { std::sync::Arc::make_mut(__d).insert("quote".into(), quote.clone()); }
5636 }
5637 if (base != Value::Null) && (quote != Value::Null) {
5638 add_element_to_object(&mut result, &Value::Str("symbol".into()), Value::Str(format!("{}{}", Value::Str(format!("{}{}", base, Value::Str("/".into())).into()), quote).into()));
5639 }
5640 }
5641 return result;
5642 }
5643 }
5644 if (market != Value::Null) {
5645 return market;
5646 }
5647 let mut emptyMarket: Value = self.safe_market_structure(&[Value::Map({
5648 let mut m = indexmap::IndexMap::new();
5649 m.insert("symbol".to_string(), marketId.clone());
5650 m.insert("marketId".to_string(), marketId);
5651 m
5652})]);
5653 if (emptyMarket == Value::Null) {
5654 panic!("{}", crate::exchange_errors::exchange_error(format!("{}{}", self.id.clone(), Value::Str(" safeMarket() failed to build market structure".into()))));
5655 }
5656 return emptyMarket;
5657
5658 Value::Null
5659}
5660
5661 fn market_or_null(&self, optional_args: &[Value]) -> Value {
5662 let mut symbol = get_arg(optional_args, 0, Value::Null);
5663 if (symbol == Value::Null) {
5664 return Value::Null;
5665 }
5666 return self.market(symbol);
5667
5668 Value::Null
5669}
5670
5671 fn check_required_credentials(&self, optional_args: &[Value]) -> Value {
5672 let mut error = get_arg(optional_args, 0, Value::Bool(true));
5673 let mut keys: Value = object_keys(&self.requiredCredentials);
5680 {
5681 let mut i: Value = Value::Int(0);
5682 let mut __for_first_134: bool = true;
5683 while { if !__for_first_134 { i = (match (&(i), &(Value::Int(1))) { (Value::Int(x), Value::Int(y)) => Value::Int(x + y), (Value::Int(x), Value::Float(y)) => Value::Float(*x as f64 + *y), (Value::Float(x), Value::Int(y)) => Value::Float(*x + *y as f64), (Value::Float(x), Value::Float(y)) => Value::Float(x + y), _ => Value::Null }); } __for_first_134 = false; i.as_f64().unwrap_or(f64::NAN) < ((keys.len() as i64) as f64) } {
5684 let mut key: Value = keys.as_array().and_then(|__arr| match &i { Value::Int(__n) => __arr.get(*__n as usize), Value::Str(__s) => __s.parse::<usize>().ok().and_then(|__n| __arr.get(__n)), _ => None }).cloned().unwrap_or(Value::Null);
5685 let mut credentialValue: Value = self.prop(&key);
5686 let mut credentialMissing: bool = (credentialValue == Value::Null) || (credentialValue == Value::Null) || (is_equal(&credentialValue, &Value::Bool(false))) || (credentialValue.as_str() == Some(""));
5687 if (get_value(&self.requiredCredentials, &key).as_bool() == Some(true)) && credentialMissing {
5688 if is_true(&error) {
5689 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()))));
5690 } else {
5691 return Value::Bool(false);
5692 }
5693 }
5694 }
5695 }
5696 return Value::Bool(true);
5697
5698 Value::Null
5699}
5700
5701 fn oath(&self) -> Value {
5702 if (self.twofa.clone() != Value::Null) {
5703 return totp(self.twofa.clone());
5704 } else {
5705 panic!("{}", crate::exchange_errors::exchange_error(format!("{}{}", self.id.clone(), Value::Str(" exchange.twofa has not been set for 2FA Two-Factor Authentication".into()))));
5706 }
5707
5708 Value::Null
5709}
5710
5711 fn fetch_balance(&mut self, optional_args: &[Value]) -> impl ::std::future::Future<Output = Value> + Send { async move {
5712 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 {
5714 if !matches!(__v, crate::Value::Null) { return __v; }
5715 }
5716
5717 let mut params = get_arg(optional_args, 0, Value::Map({
5718 let mut m = indexmap::IndexMap::new();
5719 m
5720}));
5721 panic!("{}", crate::exchange_errors::not_supported(format!("{}{}", self.id.clone(), Value::Str(" fetchBalance() is not supported yet".into()))));
5722
5723 Value::Null
5724} }
5725
5726 fn fetch_balance_ws(&mut self, optional_args: &[Value]) -> impl ::std::future::Future<Output = Value> + Send { async move {
5727 let mut params = get_arg(optional_args, 0, Value::Map({
5728 let mut m = indexmap::IndexMap::new();
5729 m
5730}));
5731 panic!("{}", crate::exchange_errors::not_supported(format!("{}{}", self.id.clone(), Value::Str(" fetchBalanceWs() is not supported yet".into()))));
5732
5733 Value::Null
5734} }
5735
5736 fn parse_balance(&self, mut response: Value) -> Value {
5737 { let __v = crate::exchange::DerivedExchange::parse_balance(self, response); if !matches!(__v, crate::Value::Null) { return __v; } }
5739
5740 panic!("{}", crate::exchange_errors::not_supported(format!("{}{}", self.id.clone(), Value::Str(" parseBalance() is not supported yet".into()))));
5741
5742 Value::Null
5743}
5744
5745 fn watch_balance(&mut self, optional_args: &[Value]) -> impl ::std::future::Future<Output = Value> + Send { async move {
5746 let mut params = get_arg(optional_args, 0, Value::Map({
5747 let mut m = indexmap::IndexMap::new();
5748 m
5749}));
5750 panic!("{}", crate::exchange_errors::not_supported(format!("{}{}", self.id.clone(), Value::Str(" watchBalance() is not supported yet".into()))));
5751
5752 Value::Null
5753} }
5754
5755 fn fetch_partial_balance(&mut self, mut part: Value, optional_args: &[Value]) -> impl ::std::future::Future<Output = Value> + Send { async move {
5756 let mut params = get_arg(optional_args, 0, Value::Map({
5757 let mut m = indexmap::IndexMap::new();
5758 m
5759}));
5760 let mut balance: Value = self.fetch_balance(&[params]).await;
5761 return get_value(&balance, &part);
5762
5763 Value::Null
5764} }
5765
5766 fn fetch_free_balance(&mut self, optional_args: &[Value]) -> impl ::std::future::Future<Output = Value> + Send { async move {
5767 let mut params = get_arg(optional_args, 0, Value::Map({
5768 let mut m = indexmap::IndexMap::new();
5769 m
5770}));
5771 return self.fetch_partial_balance(Value::Str("free".into()), &[params]).await;
5772
5773 Value::Null
5774} }
5775
5776 fn fetch_used_balance(&mut self, optional_args: &[Value]) -> impl ::std::future::Future<Output = Value> + Send { async move {
5777 let mut params = get_arg(optional_args, 0, Value::Map({
5778 let mut m = indexmap::IndexMap::new();
5779 m
5780}));
5781 return self.fetch_partial_balance(Value::Str("used".into()), &[params]).await;
5782
5783 Value::Null
5784} }
5785
5786 fn fetch_total_balance(&mut self, optional_args: &[Value]) -> impl ::std::future::Future<Output = Value> + Send { async move {
5787 let mut params = get_arg(optional_args, 0, Value::Map({
5788 let mut m = indexmap::IndexMap::new();
5789 m
5790}));
5791 return self.fetch_partial_balance(Value::Str("total".into()), &[params]).await;
5792
5793 Value::Null
5794} }
5795
5796 fn fetch_status(&mut self, optional_args: &[Value]) -> impl ::std::future::Future<Output = Value> + Send { async move {
5797 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 {
5799 if !matches!(__v, crate::Value::Null) { return __v; }
5800 }
5801
5802 let mut params = get_arg(optional_args, 0, Value::Map({
5803 let mut m = indexmap::IndexMap::new();
5804 m
5805}));
5806 panic!("{}", crate::exchange_errors::not_supported(format!("{}{}", self.id.clone(), Value::Str(" fetchStatus() is not supported yet".into()))));
5807
5808 Value::Null
5809} }
5810
5811 fn fetch_transaction_fee(&mut self, mut code: Value, optional_args: &[Value]) -> impl ::std::future::Future<Output = Value> + Send { async move {
5812 let mut params = get_arg(optional_args, 0, Value::Map({
5813 let mut m = indexmap::IndexMap::new();
5814 m
5815}));
5816 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)) {
5817 panic!("{}", crate::exchange_errors::not_supported(format!("{}{}", self.id.clone(), Value::Str(" fetchTransactionFee() is not supported yet".into()))));
5818 }
5819 return self.fetch_transaction_fees(&[Value::from(vec![code]), params]).await;
5820
5821 Value::Null
5822} }
5823
5824 fn fetch_transaction_fees(&mut self, optional_args: &[Value]) -> impl ::std::future::Future<Output = Value> + Send { async move {
5825 let mut codes = get_arg(optional_args, 0, Value::Null);
5826 let mut params = get_arg(optional_args, 1, Value::Map({
5827 let mut m = indexmap::IndexMap::new();
5828 m
5829}));
5830 panic!("{}", crate::exchange_errors::not_supported(format!("{}{}", self.id.clone(), Value::Str(" fetchTransactionFees() is not supported yet".into()))));
5831
5832 Value::Null
5833} }
5834
5835 fn fetch_deposit_withdraw_fees(&mut self, optional_args: &[Value]) -> impl ::std::future::Future<Output = Value> + Send { async move {
5836 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 {
5838 if !matches!(__v, crate::Value::Null) { return __v; }
5839 }
5840
5841 let mut codes = get_arg(optional_args, 0, Value::Null);
5842 let mut params = get_arg(optional_args, 1, Value::Map({
5843 let mut m = indexmap::IndexMap::new();
5844 m
5845}));
5846 panic!("{}", crate::exchange_errors::not_supported(format!("{}{}", self.id.clone(), Value::Str(" fetchDepositWithdrawFees() is not supported yet".into()))));
5847
5848 Value::Null
5849} }
5850
5851 fn fetch_deposit_withdraw_fee(&mut self, mut code: Value, optional_args: &[Value]) -> impl ::std::future::Future<Output = Value> + Send { async move {
5852 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 {
5854 if !matches!(__v, crate::Value::Null) { return __v; }
5855 }
5856
5857 let mut params = get_arg(optional_args, 0, Value::Map({
5858 let mut m = indexmap::IndexMap::new();
5859 m
5860}));
5861 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)) {
5862 panic!("{}", crate::exchange_errors::not_supported(format!("{}{}", self.id.clone(), Value::Str(" fetchDepositWithdrawFee() is not supported yet".into()))));
5863 }
5864 let mut fees: Value = self.fetch_deposit_withdraw_fees(&[Value::from(vec![code.clone()]), params]).await;
5865 return self.safe_value(fees, code, &[]);
5866
5867 Value::Null
5868} }
5869
5870 fn get_supported_mapping(&self, mut key: Value, optional_args: &[Value]) -> Value {
5871 let mut mapping = get_arg(optional_args, 0, Value::Map({
5872 let mut m = indexmap::IndexMap::new();
5873 m
5874}));
5875 if (key == Value::Null) {
5876 panic!("{}", crate::exchange_errors::arguments_required(format!("{}{}", self.id.clone(), Value::Str(" getSupportedMapping() requires a key argument".into()))));
5877 }
5878 if (in_op(&mapping, &key)) {
5879 return mapping.as_map().and_then(|__m| key.as_str().and_then(|__k| __m.get(__k))).cloned().unwrap_or(Value::Null);
5880 } else {
5881 let mut keys: Value = object_keys(&mapping);
5882 panic!("{}", crate::exchange_errors::not_supported(format!("{}{}", Value::Str(format!("{}{}", Value::Str(format!("{}{}", Value::Str(format!("{}{}", Value::Str(format!("{}{}", self.id.clone(), Value::Str(" ".into())).into()), key).into()), Value::Str(" does not have a value in mapping".into())).into()), Value::Str(", must be one of ".into())).into()), join(&keys, &Value::Str(", ".into())))));
5883 }
5884
5885 Value::Null
5886}
5887
5888 fn fetch_cross_borrow_rate(&mut self, mut code: Value, optional_args: &[Value]) -> impl ::std::future::Future<Output = Value> + Send { async move {
5889 let mut params = get_arg(optional_args, 0, Value::Map({
5890 let mut m = indexmap::IndexMap::new();
5891 m
5892}));
5893 self.load_markets(&[]).await;
5894 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)) {
5895 panic!("{}", crate::exchange_errors::not_supported(format!("{}{}", self.id.clone(), Value::Str(" fetchCrossBorrowRate() is not supported yet".into()))));
5896 }
5897 let mut borrowRates: Value = self.fetch_cross_borrow_rates(&[params]).await;
5898 let mut rate: Value = self.safe_dict(borrowRates, code.clone(), &[]);
5899 if (rate == Value::Null) {
5900 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)));
5901 }
5902 return rate;
5903
5904 Value::Null
5905} }
5906
5907 fn fetch_isolated_borrow_rate(&mut self, mut symbol: Value, optional_args: &[Value]) -> impl ::std::future::Future<Output = Value> + Send { async move {
5908 let mut params = get_arg(optional_args, 0, Value::Map({
5909 let mut m = indexmap::IndexMap::new();
5910 m
5911}));
5912 self.load_markets(&[]).await;
5913 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)) {
5914 panic!("{}", crate::exchange_errors::not_supported(format!("{}{}", self.id.clone(), Value::Str(" fetchIsolatedBorrowRate() is not supported yet".into()))));
5915 }
5916 let mut borrowRates: Value = self.fetch_isolated_borrow_rates(&[params]).await;
5917 let mut rate: Value = self.safe_dict(borrowRates, symbol.clone(), &[]);
5918 if (rate == Value::Null) {
5919 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)));
5920 }
5921 return rate;
5922
5923 Value::Null
5924} }
5925
5926fn require_value(&self, mut value: Value, optional_args: &[Value]) -> Value {
5929 let mut message = get_arg(optional_args, 0, Value::Null);
5930 if (value == Value::Null) {
5931 let mut errorMessage: Value = (if (message != Value::Null) { message } else { Value::Str("value is required".into()) });
5932 panic!("{}", crate::exchange_errors::arguments_required(format!("{}{}", Value::Str(format!("{}{}", self.id.clone(), Value::Str(" ".into())).into()), errorMessage)));
5933 }
5934 return value;
5935
5936 Value::Null
5937}
5938
5939fn handle_option_and_params(&self, mut params: Value, mut methodName: Value, mut optionName: Value, optional_args: &[Value]) -> Value {
5942 let mut defaultValue = get_arg(optional_args, 0, Value::Null);
5943 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(), &[]);
5947 if (value != Value::Null) {
5948 let mut paramsOmitted: Value = self.omit(params.clone(), Value::from(vec![optionName.clone(), defaultOptionName.clone()]), &[]);
5949 return Value::from(vec![value.clone(), paramsOmitted]);
5950 } else {
5951 let mut callerMethodNameparamsCallerMethodNameVariable = self.handle_param_string(params, Value::Str("callerMethodName".into()), &[methodName]);
5953 let mut callerMethodName: Value = callerMethodNameparamsCallerMethodNameVariable.as_array().and_then(|__arr| __arr.get(0)).cloned().unwrap_or(Value::Null);
5954 let mut paramsCallerMethodName: Value = callerMethodNameparamsCallerMethodNameVariable.as_array().and_then(|__arr| __arr.get(1)).cloned().unwrap_or(Value::Null);
5955 let mut exchangeWideMethodOptions: Value = self.safe_value(self.options.clone(), callerMethodName, &[]);
5957 if (exchangeWideMethodOptions != Value::Null) {
5958 value = self.safe_value2(exchangeWideMethodOptions, optionName.clone(), defaultOptionName.clone(), &[]);
5960 }
5961 if (value == Value::Null) {
5962 value = self.safe_value2(self.options.clone(), optionName, defaultOptionName, &[]);
5964 }
5965 value = (if (value != Value::Null) { value.clone() } else { defaultValue });
5967 return Value::from(vec![value, paramsCallerMethodName]);
5968 }
5969
5970 Value::Null
5971}
5972
5973fn handle_option_and_params2(&self, mut params: Value, mut methodName1: Value, mut optionName1: Value, mut optionName2: Value, optional_args: &[Value]) -> Value {
5976 let mut defaultValue = get_arg(optional_args, 0, Value::Null);
5977 let mut valueparamsOption1Variable = self.handle_option_and_params(params, methodName1.clone(), optionName1, &[]);
5978 let mut value: Value = valueparamsOption1Variable.as_array().and_then(|__arr| __arr.get(0)).cloned().unwrap_or(Value::Null);
5979 let mut paramsOption1: Value = valueparamsOption1Variable.as_array().and_then(|__arr| __arr.get(1)).cloned().unwrap_or(Value::Null);
5980 if (value != Value::Null) {
5981 let mut paramsOmitted: Value = self.omit(paramsOption1.clone(), optionName2.clone(), &[]);
5983 return Value::from(vec![value, paramsOmitted]);
5984 }
5985 return self.handle_option_and_params(paramsOption1, methodName1, optionName2, &[defaultValue]);
5986
5987 Value::Null
5988}
5989
5990fn handle_option_string_and_params(&self, mut params: Value, mut methodName: Value, mut optionName: Value, optional_args: &[Value]) -> Value {
5993 let mut defaultValue = get_arg(optional_args, 0, Value::Null);
5994 let mut valuenewParamsVariable = self.handle_option_and_params(params, methodName.clone(), optionName.clone(), &[defaultValue]);
5996 let mut value: Value = valuenewParamsVariable.as_array().and_then(|__arr| __arr.get(0)).cloned().unwrap_or(Value::Null);
5997 let mut newParams: Value = valuenewParamsVariable.as_array().and_then(|__arr| __arr.get(1)).cloned().unwrap_or(Value::Null);
5998 return Value::from(vec![self.check_option_string(methodName, optionName, value), newParams]);
5999
6000 Value::Null
6001}
6002
6003fn handle_option_string_and_params2(&self, mut params: Value, mut methodName: Value, mut optionName1: Value, mut optionName2: Value, optional_args: &[Value]) -> Value {
6006 let mut defaultValue = get_arg(optional_args, 0, Value::Null);
6007 let mut valuenewParamsVariable = self.handle_option_and_params2(params, methodName.clone(), optionName1.clone(), optionName2, &[defaultValue]);
6008 let mut value: Value = valuenewParamsVariable.as_array().and_then(|__arr| __arr.get(0)).cloned().unwrap_or(Value::Null);
6009 let mut newParams: Value = valuenewParamsVariable.as_array().and_then(|__arr| __arr.get(1)).cloned().unwrap_or(Value::Null);
6010 return Value::from(vec![self.check_option_string(methodName, optionName1, value), newParams]);
6011
6012 Value::Null
6013}
6014
6015fn handle_option_bool_and_params(&self, mut params: Value, mut methodName: Value, mut optionName: Value, optional_args: &[Value]) -> Value {
6018 let mut defaultValue = get_arg(optional_args, 0, Value::Null);
6019 let mut valuenewParamsVariable = self.handle_option_and_params(params, methodName.clone(), optionName.clone(), &[defaultValue]);
6021 let mut value: Value = valuenewParamsVariable.as_array().and_then(|__arr| __arr.get(0)).cloned().unwrap_or(Value::Null);
6022 let mut newParams: Value = valuenewParamsVariable.as_array().and_then(|__arr| __arr.get(1)).cloned().unwrap_or(Value::Null);
6023 return Value::from(vec![self.check_option_bool(methodName, optionName, value), newParams]);
6024
6025 Value::Null
6026}
6027
6028fn handle_option_bool_and_params2(&self, mut params: Value, mut methodName: Value, mut optionName1: Value, mut optionName2: Value, optional_args: &[Value]) -> Value {
6031 let mut defaultValue = get_arg(optional_args, 0, Value::Null);
6032 let mut valuenewParamsVariable = self.handle_option_and_params2(params, methodName.clone(), optionName1.clone(), optionName2, &[defaultValue]);
6033 let mut value: Value = valuenewParamsVariable.as_array().and_then(|__arr| __arr.get(0)).cloned().unwrap_or(Value::Null);
6034 let mut newParams: Value = valuenewParamsVariable.as_array().and_then(|__arr| __arr.get(1)).cloned().unwrap_or(Value::Null);
6035 return Value::from(vec![self.check_option_bool(methodName, optionName1, value), newParams]);
6036
6037 Value::Null
6038}
6039
6040fn handle_option_integer_and_params(&self, mut params: Value, mut methodName: Value, mut optionName: Value, optional_args: &[Value]) -> Value {
6043 let mut defaultValue = get_arg(optional_args, 0, Value::Null);
6044 let mut valuenewParamsVariable = self.handle_option_and_params(params, methodName.clone(), optionName.clone(), &[defaultValue]);
6046 let mut value: Value = valuenewParamsVariable.as_array().and_then(|__arr| __arr.get(0)).cloned().unwrap_or(Value::Null);
6047 let mut newParams: Value = valuenewParamsVariable.as_array().and_then(|__arr| __arr.get(1)).cloned().unwrap_or(Value::Null);
6048 return Value::from(vec![self.check_option_integer(methodName, optionName, value), newParams]);
6049
6050 Value::Null
6051}
6052
6053fn handle_option_integer_and_params2(&self, mut params: Value, mut methodName: Value, mut optionName1: Value, mut optionName2: Value, optional_args: &[Value]) -> Value {
6056 let mut defaultValue = get_arg(optional_args, 0, Value::Null);
6057 let mut valuenewParamsVariable = self.handle_option_and_params2(params, methodName.clone(), optionName1.clone(), optionName2, &[defaultValue]);
6058 let mut value: Value = valuenewParamsVariable.as_array().and_then(|__arr| __arr.get(0)).cloned().unwrap_or(Value::Null);
6059 let mut newParams: Value = valuenewParamsVariable.as_array().and_then(|__arr| __arr.get(1)).cloned().unwrap_or(Value::Null);
6060 return Value::from(vec![self.check_option_integer(methodName, optionName1, value), newParams]);
6061
6062 Value::Null
6063}
6064
6065 fn handle_option(&self, mut methodName: Value, mut optionName: Value, optional_args: &[Value]) -> Value {
6066 let mut defaultValue = get_arg(optional_args, 0, Value::Null);
6067 let mut res: Value = self.handle_option_and_params(Value::Map({
6068 let mut m = indexmap::IndexMap::new();
6069 m
6070}), methodName, optionName, &[defaultValue]);
6071 return self.safe_value(res, Value::Int(0), &[]);
6072
6073 Value::Null
6074}
6075
6076 fn handle_market_type_and_params(&self, mut methodName: Value, optional_args: &[Value]) -> Value {
6077 let mut market = get_arg(optional_args, 0, Value::Null);
6078 let mut params = get_arg(optional_args, 1, Value::Map({
6079 let mut m = indexmap::IndexMap::new();
6080 m
6081}));
6082 let mut defaultValue = get_arg(optional_args, 2, Value::Null);
6083 let mut type_var: Value = self.safe_string2(params.clone(), Value::Str("defaultType".into()), Value::Str("type".into()), &[]);
6097 if (type_var != Value::Null) {
6098 let mut paramsOmitted: Value = self.omit(params.clone(), Value::from(vec![Value::Str("defaultType".into()), Value::Str("type".into())]), &[]);
6099 return Value::from(vec![type_var, paramsOmitted]);
6100 }
6101 if (market != Value::Null) {
6103 return Value::from(vec![market.as_map().and_then(|__m| __m.get("type")).cloned().unwrap_or(Value::Null), params.clone()]);
6104 }
6105 if (defaultValue != Value::Null) {
6107 return Value::from(vec![defaultValue, params.clone()]);
6108 }
6109 let mut methodOptions: Value = self.safe_dict(self.options.clone(), methodName, &[]);
6110 if (methodOptions != Value::Null) {
6111 if matches!(&methodOptions, Value::Str(_)) {
6112 return Value::from(vec![methodOptions.clone(), params.clone()]);
6113 } else {
6114 let mut typeFromMethod: Value = self.safe_string2(methodOptions, Value::Str("defaultType".into()), Value::Str("type".into()), &[]);
6115 if (typeFromMethod != Value::Null) {
6116 return Value::from(vec![typeFromMethod, params.clone()]);
6117 }
6118 }
6119 }
6120 let mut defaultType: Value = self.safe_string2(self.options.clone(), Value::Str("defaultType".into()), Value::Str("type".into()), &[Value::Str("spot".into())]);
6121 return Value::from(vec![defaultType, params]);
6122
6123 Value::Null
6124}
6125
6126 fn handle_sub_type_and_params(&self, mut methodName: Value, optional_args: &[Value]) -> Value {
6127 let mut market = get_arg(optional_args, 0, Value::Null);
6128 let mut params = get_arg(optional_args, 1, Value::Map({
6129 let mut m = indexmap::IndexMap::new();
6130 m
6131}));
6132 let mut defaultValue = get_arg(optional_args, 2, Value::Null);
6133 let mut subType: Value = Value::Null;
6134 let mut subTypeInParams: Value = self.safe_string2(params.clone(), Value::Str("subType".into()), Value::Str("defaultSubType".into()), &[]);
6136 if (subTypeInParams != Value::Null) {
6138 if (subTypeInParams.as_str() == Some("linear")) || (subTypeInParams.as_str() == Some("inverse")) {
6139 subType = subTypeInParams;
6140 }
6141 let mut paramsOmitted: Value = self.omit(params.clone(), Value::from(vec![Value::Str("subType".into()), Value::Str("defaultSubType".into())]), &[]);
6142 return Value::from(vec![subType.clone(), paramsOmitted]);
6143 } else {
6144 if (market != Value::Null) {
6146 if (market.as_map().and_then(|__m| __m.get("linear")).cloned().unwrap_or(Value::Null).as_bool() == Some(true)) {
6147 subType = Value::Str("linear".into());
6148 } else if (market.as_map().and_then(|__m| __m.get("inverse")).cloned().unwrap_or(Value::Null).as_bool() == Some(true)) {
6149 subType = Value::Str("inverse".into());
6150 }
6151 }
6152 if (subType == Value::Null) {
6154 let mut values: Value = self.handle_option_and_params(Value::Map({
6155 let mut m = indexmap::IndexMap::new();
6156 m
6157}), methodName, Value::Str("subType".into()), &[defaultValue]); subType = values.as_array().and_then(|__arr| __arr.get(0)).cloned().unwrap_or(Value::Null);
6159 }
6160 }
6161 return Value::from(vec![subType, params]);
6162
6163 Value::Null
6164}
6165
6166 fn handle_margin_mode_and_params(&self, mut methodName: Value, optional_args: &[Value]) -> Value {
6167 let mut params = get_arg(optional_args, 0, Value::Map({
6168 let mut m = indexmap::IndexMap::new();
6169 m
6170}));
6171 let mut defaultValue = get_arg(optional_args, 1, Value::Null);
6172 return self.handle_option_string_and_params(params, methodName, Value::Str("marginMode".into()), &[defaultValue]);
6173
6174 Value::Null
6175}
6176
6177 fn throw_exactly_matched_exception(&self, mut exact: Value, mut string: Value, mut message: Value) {
6178 if (string == Value::Null) {
6179 return;
6180 }
6181 if (in_op(&exact, &string)) {
6182 panic!("{}", crate::exchange_errors::create_error(&crate::runtime::stringify_param(&(get_value(&exact, &string))), &crate::runtime::stringify_param(&(message))));
6183 }
6184}
6185
6186 fn throw_broadly_matched_exception(&self, mut broad: Value, mut string: Value, mut message: Value) {
6187 let mut broadKey: Value = self.find_broadly_matched_key(broad.clone(), string);
6188 if (broadKey != Value::Null) {
6189 panic!("{}", crate::exchange_errors::create_error(&crate::runtime::stringify_param(&(get_value(&broad, &broadKey))), &crate::runtime::stringify_param(&(message))));
6190 }
6191}
6192
6193 fn find_broadly_matched_key(&self, mut broad: Value, mut string: Value) -> Value {
6194 let mut keys: Value = object_keys(&broad);
6196 {
6197 let mut i: Value = Value::Int(0);
6198 let mut __for_first_135: bool = true;
6199 while { if !__for_first_135 { i = (match (&(i), &(Value::Int(1))) { (Value::Int(x), Value::Int(y)) => Value::Int(x + y), (Value::Int(x), Value::Float(y)) => Value::Float(*x as f64 + *y), (Value::Float(x), Value::Int(y)) => Value::Float(*x + *y as f64), (Value::Float(x), Value::Float(y)) => Value::Float(x + y), _ => Value::Null }); } __for_first_135 = false; i.as_f64().unwrap_or(f64::NAN) < ((keys.len() as i64) as f64) } {
6200 let mut key: Value = keys.as_array().and_then(|__arr| match &i { Value::Int(__n) => __arr.get(*__n as usize), Value::Str(__s) => __s.parse::<usize>().ok().and_then(|__n| __arr.get(__n)), _ => None }).cloned().unwrap_or(Value::Null);
6201 if (string != Value::Null) {
6202 if get_index_of(&string, &key).as_f64().unwrap_or(f64::NAN) >= ((0i64) as f64) {
6203 return key;
6204 }
6205 }
6206 }
6207 }
6208 return Value::Null;
6209
6210 Value::Null
6211}
6212
6213 fn handle_errors(&self, mut statusCode: Value, mut statusText: Value, mut url: Value, mut method: Value, mut responseHeaders: Value, mut responseBody: Value, mut response: Value, mut requestHeaders: Value, mut requestBody: Value) -> Value {
6214 { let __v = crate::exchange::DerivedExchange::handle_errors(self, statusCode, statusText, url, method, responseHeaders, responseBody, response, requestHeaders, requestBody); if !matches!(__v, crate::Value::Null) { return __v; } }
6216
6217 return Value::Null;
6218
6219 Value::Null
6220}
6221
6222 fn calculate_rate_limiter_cost(&self, mut api: Value, mut method: Value, mut path: Value, mut params: Value, optional_args: &[Value]) -> Value {
6223 let mut config = get_arg(optional_args, 0, Value::Map({
6224 let mut m = indexmap::IndexMap::new();
6225 m
6226}));
6227 let __config_empty = indexmap::IndexMap::new();
6228 let config = config.as_map().unwrap_or(&__config_empty);
6229 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) });
6230
6231 Value::Null
6232}
6233
6234 fn fetch_spot_tickers(&mut self, optional_args: &[Value]) -> impl ::std::future::Future<Output = Value> + Send { async move {
6235 let mut symbols = get_arg(optional_args, 0, Value::Null);
6236 let mut params = get_arg(optional_args, 1, Value::Map({
6237 let mut m = indexmap::IndexMap::new();
6238 m
6239}));
6240 panic!("{}", crate::exchange_errors::not_supported(format!("{}{}", self.id.clone(), Value::Str(" fetchSpotTickers() is not supported yet".into()))));
6241
6242 Value::Null
6243} }
6244
6245 fn fetch_contract_tickers(&mut self, optional_args: &[Value]) -> impl ::std::future::Future<Output = Value> + Send { async move {
6246 let mut symbols = get_arg(optional_args, 0, Value::Null);
6247 let mut params = get_arg(optional_args, 1, Value::Map({
6248 let mut m = indexmap::IndexMap::new();
6249 m
6250}));
6251 panic!("{}", crate::exchange_errors::not_supported(format!("{}{}", self.id.clone(), Value::Str(" fetchContractTickers() is not supported yet".into()))));
6252
6253 Value::Null
6254} }
6255
6256 fn fetch_order_books(&mut self, optional_args: &[Value]) -> impl ::std::future::Future<Output = Value> + Send { async move {
6257 let mut symbols = get_arg(optional_args, 0, Value::Null);
6258 let mut limit = get_arg(optional_args, 1, Value::Null);
6259 let mut params = get_arg(optional_args, 2, Value::Map({
6260 let mut m = indexmap::IndexMap::new();
6261 m
6262}));
6263 panic!("{}", crate::exchange_errors::not_supported(format!("{}{}", self.id.clone(), Value::Str(" fetchOrderBooks() is not supported yet".into()))));
6264
6265 Value::Null
6266} }
6267
6268 fn un_watch_tickers(&mut self, optional_args: &[Value]) -> impl ::std::future::Future<Output = Value> + Send { async move {
6269 let mut symbols = get_arg(optional_args, 0, Value::Null);
6270 let mut params = get_arg(optional_args, 1, Value::Map({
6271 let mut m = indexmap::IndexMap::new();
6272 m
6273}));
6274 panic!("{}", crate::exchange_errors::not_supported(format!("{}{}", self.id.clone(), Value::Str(" unWatchTickers() is not supported yet".into()))));
6275
6276 Value::Null
6277} }
6278
6279 fn un_watch_funding_rate(&mut self, mut symbol: Value, optional_args: &[Value]) -> impl ::std::future::Future<Output = Value> + Send { async move {
6280 let mut params = get_arg(optional_args, 0, Value::Map({
6281 let mut m = indexmap::IndexMap::new();
6282 m
6283}));
6284 panic!("{}", crate::exchange_errors::not_supported(format!("{}{}", self.id.clone(), Value::Str(" unWatchFundingRate() is not supported yet".into()))));
6285
6286 Value::Null
6287} }
6288
6289 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 {
6290 let mut params = get_arg(optional_args, 0, Value::Map({
6291 let mut m = indexmap::IndexMap::new();
6292 m
6293}));
6294 panic!("{}", crate::exchange_errors::not_supported(format!("{}{}", self.id.clone(), Value::Str(" createTwapOrder() is not supported yet".into()))));
6295
6296 Value::Null
6297} }
6298
6299 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 {
6300 let mut amount = get_arg(optional_args, 0, Value::Null);
6301 let mut params = get_arg(optional_args, 1, Value::Map({
6302 let mut m = indexmap::IndexMap::new();
6303 m
6304}));
6305 panic!("{}", crate::exchange_errors::not_supported(format!("{}{}", self.id.clone(), Value::Str(" createConvertTrade() is not supported yet".into()))));
6306
6307 Value::Null
6308} }
6309
6310 fn fetch_convert_trade(&mut self, mut id: Value, optional_args: &[Value]) -> impl ::std::future::Future<Output = Value> + Send { async move {
6311 let mut code = get_arg(optional_args, 0, Value::Null);
6312 let mut params = get_arg(optional_args, 1, Value::Map({
6313 let mut m = indexmap::IndexMap::new();
6314 m
6315}));
6316 panic!("{}", crate::exchange_errors::not_supported(format!("{}{}", self.id.clone(), Value::Str(" fetchConvertTrade() is not supported yet".into()))));
6317
6318 Value::Null
6319} }
6320
6321 fn fetch_convert_trade_history(&mut self, optional_args: &[Value]) -> impl ::std::future::Future<Output = Value> + Send { async move {
6322 let mut code = get_arg(optional_args, 0, Value::Null);
6323 let mut since = get_arg(optional_args, 1, Value::Null);
6324 let mut limit = get_arg(optional_args, 2, Value::Null);
6325 let mut params = get_arg(optional_args, 3, Value::Map({
6326 let mut m = indexmap::IndexMap::new();
6327 m
6328}));
6329 panic!("{}", crate::exchange_errors::not_supported(format!("{}{}", self.id.clone(), Value::Str(" fetchConvertTradeHistory() is not supported yet".into()))));
6330
6331 Value::Null
6332} }
6333
6334 fn fetch_position_mode(&mut self, optional_args: &[Value]) -> impl ::std::future::Future<Output = Value> + Send { async move {
6335 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 {
6337 if !matches!(__v, crate::Value::Null) { return __v; }
6338 }
6339
6340 let mut symbol = get_arg(optional_args, 0, Value::Null);
6341 let mut params = get_arg(optional_args, 1, Value::Map({
6342 let mut m = indexmap::IndexMap::new();
6343 m
6344}));
6345 panic!("{}", crate::exchange_errors::not_supported(format!("{}{}", self.id.clone(), Value::Str(" fetchPositionMode() is not supported yet".into()))));
6346
6347 Value::Null
6348} }
6349
6350 fn fetch_adl_rank(&mut self, mut symbol: Value, optional_args: &[Value]) -> impl ::std::future::Future<Output = Value> + Send { async move {
6351 let mut params = get_arg(optional_args, 0, Value::Map({
6352 let mut m = indexmap::IndexMap::new();
6353 m
6354}));
6355 panic!("{}", crate::exchange_errors::not_supported(format!("{}{}", self.id.clone(), Value::Str(" fetchADLRank() is not supported yet".into()))));
6356
6357 Value::Null
6358} }
6359
6360 fn fetch_positions_adl_rank(&mut self, optional_args: &[Value]) -> impl ::std::future::Future<Output = Value> + Send { async move {
6361 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 {
6363 if !matches!(__v, crate::Value::Null) { return __v; }
6364 }
6365
6366 let mut symbols = get_arg(optional_args, 0, Value::Null);
6367 let mut params = get_arg(optional_args, 1, Value::Map({
6368 let mut m = indexmap::IndexMap::new();
6369 m
6370}));
6371 panic!("{}", crate::exchange_errors::not_supported(format!("{}{}", self.id.clone(), Value::Str(" fetchPositionsADLRank() is not supported yet".into()))));
6372
6373 Value::Null
6374} }
6375
6376 fn fetch_position_adl_rank(&mut self, mut symbol: Value, optional_args: &[Value]) -> impl ::std::future::Future<Output = Value> + Send { async move {
6377 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 {
6379 if !matches!(__v, crate::Value::Null) { return __v; }
6380 }
6381
6382 let mut params = get_arg(optional_args, 0, Value::Map({
6383 let mut m = indexmap::IndexMap::new();
6384 m
6385}));
6386 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)) {
6387 self.load_markets(&[]).await;
6388 let mut market: Value = self.market(symbol);
6389 let mut symbolResolved: Value = market.as_map().and_then(|__m| __m.get("symbol")).cloned().unwrap_or(Value::Null);
6390 let mut ranks: Value = self.fetch_positions_adl_rank(&[Value::from(vec![symbolResolved.clone()]), params]).await;
6391 let mut rank: Value = self.safe_dict(ranks, Value::Int(0), &[]);
6392 if (rank == Value::Null) {
6393 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)));
6394 } else {
6395 return rank;
6396 }
6397 } else {
6398 panic!("{}", crate::exchange_errors::not_supported(format!("{}{}", self.id.clone(), Value::Str(" fetchPositionsADLRank() is not supported yet".into()))));
6399 }
6400
6401 Value::Null
6402} }
6403
6404 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 {
6405 let mut price = get_arg(optional_args, 0, Value::Null);
6406 let mut takeProfit = get_arg(optional_args, 1, Value::Null);
6407 let mut stopLoss = get_arg(optional_args, 2, Value::Null);
6408 let mut params = get_arg(optional_args, 3, Value::Map({
6409 let mut m = indexmap::IndexMap::new();
6410 m
6411}));
6412 if (takeProfit == Value::Null) && (stopLoss == Value::Null) {
6413 panic!("{}", crate::exchange_errors::arguments_required(format!("{}{}", self.id.clone(), Value::Str(" createOrderWithTakeProfitAndStopLoss() requires either a takeProfit or stopLoss argument".into()))));
6414 }
6415 if (takeProfit != Value::Null) {
6416 if let Value::Dict(__d) = &mut params { std::sync::Arc::make_mut(__d).insert("takeProfit".into(), Value::Map({
6417 let mut m = indexmap::IndexMap::new();
6418 m.insert("triggerPrice".to_string(), takeProfit);
6419 m
6420})); }
6421 }
6422 if (stopLoss != Value::Null) {
6423 if let Value::Dict(__d) = &mut params { std::sync::Arc::make_mut(__d).insert("stopLoss".into(), Value::Map({
6424 let mut m = indexmap::IndexMap::new();
6425 m.insert("triggerPrice".to_string(), stopLoss);
6426 m
6427})); }
6428 }
6429 let mut takeProfitType: Value = self.safe_string_k(params.clone(), "takeProfitType", &[]);
6430 let mut takeProfitPriceType: Value = self.safe_string_k(params.clone(), "takeProfitPriceType", &[]);
6431 let mut takeProfitLimitPrice: Value = self.safe_string_k(params.clone(), "takeProfitLimitPrice", &[]);
6432 let mut takeProfitAmount: Value = self.safe_string_k(params.clone(), "takeProfitAmount", &[]);
6433 let mut stopLossType: Value = self.safe_string_k(params.clone(), "stopLossType", &[]);
6434 let mut stopLossPriceType: Value = self.safe_string_k(params.clone(), "stopLossPriceType", &[]);
6435 let mut stopLossLimitPrice: Value = self.safe_string_k(params.clone(), "stopLossLimitPrice", &[]);
6436 let mut stopLossAmount: Value = self.safe_string_k(params.clone(), "stopLossAmount", &[]);
6437 if (takeProfitType != Value::Null) {
6438 add_element_to_object(get_value_mut(&mut params, &Value::Str("takeProfit".into())), &Value::Str("type".into()), takeProfitType);
6439 }
6440 if (takeProfitPriceType != Value::Null) {
6441 add_element_to_object(get_value_mut(&mut params, &Value::Str("takeProfit".into())), &Value::Str("priceType".into()), takeProfitPriceType);
6442 }
6443 if (takeProfitLimitPrice != Value::Null) {
6444 add_element_to_object(get_value_mut(&mut params, &Value::Str("takeProfit".into())), &Value::Str("price".into()), self.parse_to_numeric(takeProfitLimitPrice));
6445 }
6446 if (takeProfitAmount != Value::Null) {
6447 add_element_to_object(get_value_mut(&mut params, &Value::Str("takeProfit".into())), &Value::Str("amount".into()), self.parse_to_numeric(takeProfitAmount));
6448 }
6449 if (stopLossType != Value::Null) {
6450 add_element_to_object(get_value_mut(&mut params, &Value::Str("stopLoss".into())), &Value::Str("type".into()), stopLossType);
6451 }
6452 if (stopLossPriceType != Value::Null) {
6453 add_element_to_object(get_value_mut(&mut params, &Value::Str("stopLoss".into())), &Value::Str("priceType".into()), stopLossPriceType);
6454 }
6455 if (stopLossLimitPrice != Value::Null) {
6456 add_element_to_object(get_value_mut(&mut params, &Value::Str("stopLoss".into())), &Value::Str("price".into()), self.parse_to_numeric(stopLossLimitPrice));
6457 }
6458 if (stopLossAmount != Value::Null) {
6459 add_element_to_object(get_value_mut(&mut params, &Value::Str("stopLoss".into())), &Value::Str("amount".into()), self.parse_to_numeric(stopLossAmount));
6460 }
6461 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())]), &[]);
6462 return paramsOmitted;
6463
6464 Value::Null
6465}
6466
6467 fn create_spot_orders(&mut self, mut orders: Value, optional_args: &[Value]) -> impl ::std::future::Future<Output = Value> + Send { async move {
6468 let mut params = get_arg(optional_args, 0, Value::Map({
6469 let mut m = indexmap::IndexMap::new();
6470 m
6471}));
6472 panic!("{}", crate::exchange_errors::not_supported(format!("{}{}", self.id.clone(), Value::Str(" createSpotOrders() is not supported yet".into()))));
6473
6474 Value::Null
6475} }
6476
6477 fn create_contract_orders(&mut self, mut orders: Value, optional_args: &[Value]) -> impl ::std::future::Future<Output = Value> + Send { async move {
6478 let mut params = get_arg(optional_args, 0, Value::Map({
6479 let mut m = indexmap::IndexMap::new();
6480 m
6481}));
6482 panic!("{}", crate::exchange_errors::not_supported(format!("{}{}", self.id.clone(), Value::Str(" createContractOrders() is not supported yet".into()))));
6483
6484 Value::Null
6485} }
6486
6487 fn cancel_spot_order(&mut self, mut id: Value, optional_args: &[Value]) -> impl ::std::future::Future<Output = Value> + Send { async move {
6488 let mut symbol = get_arg(optional_args, 0, Value::Null);
6489 let mut params = get_arg(optional_args, 1, Value::Map({
6490 let mut m = indexmap::IndexMap::new();
6491 m
6492}));
6493 panic!("{}", crate::exchange_errors::not_supported(format!("{}{}", self.id.clone(), Value::Str(" cancelSpotOrder() is not supported yet".into()))));
6494
6495 Value::Null
6496} }
6497
6498 fn cancel_contract_order(&mut self, mut id: Value, optional_args: &[Value]) -> impl ::std::future::Future<Output = Value> + Send { async move {
6499 let mut symbol = get_arg(optional_args, 0, Value::Null);
6500 let mut params = get_arg(optional_args, 1, Value::Map({
6501 let mut m = indexmap::IndexMap::new();
6502 m
6503}));
6504 panic!("{}", crate::exchange_errors::not_supported(format!("{}{}", self.id.clone(), Value::Str(" cancelContractOrder() is not supported yet".into()))));
6505
6506 Value::Null
6507} }
6508
6509 fn cancel_all_spot_orders(&mut self, optional_args: &[Value]) -> impl ::std::future::Future<Output = Value> + Send { async move {
6510 let mut symbol = get_arg(optional_args, 0, Value::Null);
6511 let mut params = get_arg(optional_args, 1, Value::Map({
6512 let mut m = indexmap::IndexMap::new();
6513 m
6514}));
6515 panic!("{}", crate::exchange_errors::not_supported(format!("{}{}", self.id.clone(), Value::Str(" cancelAllSpotOrders() is not supported yet".into()))));
6516
6517 Value::Null
6518} }
6519
6520 fn cancel_all_contract_orders(&mut self, optional_args: &[Value]) -> impl ::std::future::Future<Output = Value> + Send { async move {
6521 let mut symbol = get_arg(optional_args, 0, Value::Null);
6522 let mut params = get_arg(optional_args, 1, Value::Map({
6523 let mut m = indexmap::IndexMap::new();
6524 m
6525}));
6526 panic!("{}", crate::exchange_errors::not_supported(format!("{}{}", self.id.clone(), Value::Str(" cancelAllContractOrders() is not supported yet".into()))));
6527
6528 Value::Null
6529} }
6530
6531 fn cancel_all_orders_after(&mut self, mut timeout: Value, optional_args: &[Value]) -> impl ::std::future::Future<Output = Value> + Send { async move {
6532 let mut params = get_arg(optional_args, 0, Value::Map({
6533 let mut m = indexmap::IndexMap::new();
6534 m
6535}));
6536 panic!("{}", crate::exchange_errors::not_supported(format!("{}{}", self.id.clone(), Value::Str(" cancelAllOrdersAfter() is not supported yet".into()))));
6537
6538 Value::Null
6539} }
6540
6541 fn cancel_orders_for_symbols(&mut self, mut orders: Value, optional_args: &[Value]) -> impl ::std::future::Future<Output = Value> + Send { async move {
6542 let mut params = get_arg(optional_args, 0, Value::Map({
6543 let mut m = indexmap::IndexMap::new();
6544 m
6545}));
6546 panic!("{}", crate::exchange_errors::not_supported(format!("{}{}", self.id.clone(), Value::Str(" cancelOrdersForSymbols() is not supported yet".into()))));
6547
6548 Value::Null
6549} }
6550
6551 fn fetch_my_liquidations(&mut self, optional_args: &[Value]) -> impl ::std::future::Future<Output = Value> + Send { async move {
6552 let mut symbol = get_arg(optional_args, 0, Value::Null);
6553 let mut since = get_arg(optional_args, 1, Value::Null);
6554 let mut limit = get_arg(optional_args, 2, Value::Null);
6555 let mut params = get_arg(optional_args, 3, Value::Map({
6556 let mut m = indexmap::IndexMap::new();
6557 m
6558}));
6559 panic!("{}", crate::exchange_errors::not_supported(format!("{}{}", self.id.clone(), Value::Str(" fetchMyLiquidations() is not supported yet".into()))));
6560
6561 Value::Null
6562} }
6563
6564 fn fetch_liquidations(&mut self, mut symbol: Value, optional_args: &[Value]) -> impl ::std::future::Future<Output = Value> + Send { async move {
6565 let mut since = get_arg(optional_args, 0, Value::Null);
6566 let mut limit = get_arg(optional_args, 1, Value::Null);
6567 let mut params = get_arg(optional_args, 2, Value::Map({
6568 let mut m = indexmap::IndexMap::new();
6569 m
6570}));
6571 panic!("{}", crate::exchange_errors::not_supported(format!("{}{}", self.id.clone(), Value::Str(" fetchLiquidations() is not supported yet".into()))));
6572
6573 Value::Null
6574} }
6575
6576 fn fetch_greeks(&mut self, mut symbol: Value, optional_args: &[Value]) -> impl ::std::future::Future<Output = Value> + Send { async move {
6577 let mut params = get_arg(optional_args, 0, Value::Map({
6578 let mut m = indexmap::IndexMap::new();
6579 m
6580}));
6581 panic!("{}", crate::exchange_errors::not_supported(format!("{}{}", self.id.clone(), Value::Str(" fetchGreeks() is not supported yet".into()))));
6582
6583 Value::Null
6584} }
6585
6586 fn fetch_all_greeks(&mut self, optional_args: &[Value]) -> impl ::std::future::Future<Output = Value> + Send { async move {
6587 let mut symbols = get_arg(optional_args, 0, Value::Null);
6588 let mut params = get_arg(optional_args, 1, Value::Map({
6589 let mut m = indexmap::IndexMap::new();
6590 m
6591}));
6592 panic!("{}", crate::exchange_errors::not_supported(format!("{}{}", self.id.clone(), Value::Str(" fetchAllGreeks() is not supported yet".into()))));
6593
6594 Value::Null
6595} }
6596
6597 fn fetch_option_chain(&mut self, mut code: Value, optional_args: &[Value]) -> impl ::std::future::Future<Output = Value> + Send { async move {
6598 let mut params = get_arg(optional_args, 0, Value::Map({
6599 let mut m = indexmap::IndexMap::new();
6600 m
6601}));
6602 panic!("{}", crate::exchange_errors::not_supported(format!("{}{}", self.id.clone(), Value::Str(" fetchOptionChain() is not supported yet".into()))));
6603
6604 Value::Null
6605} }
6606
6607 fn fetch_option(&mut self, mut symbol: Value, optional_args: &[Value]) -> impl ::std::future::Future<Output = Value> + Send { async move {
6608 let mut params = get_arg(optional_args, 0, Value::Map({
6609 let mut m = indexmap::IndexMap::new();
6610 m
6611}));
6612 panic!("{}", crate::exchange_errors::not_supported(format!("{}{}", self.id.clone(), Value::Str(" fetchOption() is not supported yet".into()))));
6613
6614 Value::Null
6615} }
6616
6617 fn fetch_convert_quote(&mut self, mut fromCode: Value, mut toCode: Value, optional_args: &[Value]) -> impl ::std::future::Future<Output = Value> + Send { async move {
6618 let mut amount = get_arg(optional_args, 0, Value::Null);
6619 let mut params = get_arg(optional_args, 1, Value::Map({
6620 let mut m = indexmap::IndexMap::new();
6621 m
6622}));
6623 panic!("{}", crate::exchange_errors::not_supported(format!("{}{}", self.id.clone(), Value::Str(" fetchConvertQuote() is not supported yet".into()))));
6624
6625 Value::Null
6626} }
6627
6628 fn fetch_deposits_withdrawals(&mut self, optional_args: &[Value]) -> impl ::std::future::Future<Output = Value> + Send { async move {
6629 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 {
6631 if !matches!(__v, crate::Value::Null) { return __v; }
6632 }
6633
6634 let mut code = get_arg(optional_args, 0, Value::Null);
6635 let mut since = get_arg(optional_args, 1, Value::Null);
6636 let mut limit = get_arg(optional_args, 2, Value::Null);
6637 let mut params = get_arg(optional_args, 3, Value::Map({
6638 let mut m = indexmap::IndexMap::new();
6639 m
6640}));
6641 panic!("{}", crate::exchange_errors::not_supported(format!("{}{}", self.id.clone(), Value::Str(" fetchDepositsWithdrawals() is not supported yet".into()))));
6642
6643 Value::Null
6644} }
6645
6646 fn fetch_deposits(&mut self, optional_args: &[Value]) -> impl ::std::future::Future<Output = Value> + Send { async move {
6647 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 {
6649 if !matches!(__v, crate::Value::Null) { return __v; }
6650 }
6651
6652 let mut code = get_arg(optional_args, 0, Value::Null);
6653 let mut since = get_arg(optional_args, 1, Value::Null);
6654 let mut limit = get_arg(optional_args, 2, Value::Null);
6655 let mut params = get_arg(optional_args, 3, Value::Map({
6656 let mut m = indexmap::IndexMap::new();
6657 m
6658}));
6659 panic!("{}", crate::exchange_errors::not_supported(format!("{}{}", self.id.clone(), Value::Str(" fetchDeposits() is not supported yet".into()))));
6660
6661 Value::Null
6662} }
6663
6664 fn fetch_withdrawals(&mut self, optional_args: &[Value]) -> impl ::std::future::Future<Output = Value> + Send { async move {
6665 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 {
6667 if !matches!(__v, crate::Value::Null) { return __v; }
6668 }
6669
6670 let mut code = get_arg(optional_args, 0, Value::Null);
6671 let mut since = get_arg(optional_args, 1, Value::Null);
6672 let mut limit = get_arg(optional_args, 2, Value::Null);
6673 let mut params = get_arg(optional_args, 3, Value::Map({
6674 let mut m = indexmap::IndexMap::new();
6675 m
6676}));
6677 panic!("{}", crate::exchange_errors::not_supported(format!("{}{}", self.id.clone(), Value::Str(" fetchWithdrawals() is not supported yet".into()))));
6678
6679 Value::Null
6680} }
6681
6682 fn fetch_deposits_ws(&mut self, optional_args: &[Value]) -> impl ::std::future::Future<Output = Value> + Send { async move {
6683 let mut code = get_arg(optional_args, 0, Value::Null);
6684 let mut since = get_arg(optional_args, 1, Value::Null);
6685 let mut limit = get_arg(optional_args, 2, Value::Null);
6686 let mut params = get_arg(optional_args, 3, Value::Map({
6687 let mut m = indexmap::IndexMap::new();
6688 m
6689}));
6690 panic!("{}", crate::exchange_errors::not_supported(format!("{}{}", self.id.clone(), Value::Str(" fetchDepositsWs() is not supported yet".into()))));
6691
6692 Value::Null
6693} }
6694
6695 fn fetch_withdrawals_ws(&mut self, optional_args: &[Value]) -> impl ::std::future::Future<Output = Value> + Send { async move {
6696 let mut code = get_arg(optional_args, 0, Value::Null);
6697 let mut since = get_arg(optional_args, 1, Value::Null);
6698 let mut limit = get_arg(optional_args, 2, Value::Null);
6699 let mut params = get_arg(optional_args, 3, Value::Map({
6700 let mut m = indexmap::IndexMap::new();
6701 m
6702}));
6703 panic!("{}", crate::exchange_errors::not_supported(format!("{}{}", self.id.clone(), Value::Str(" fetchWithdrawalsWs() is not supported yet".into()))));
6704
6705 Value::Null
6706} }
6707
6708 fn fetch_funding_rate_history(&mut self, optional_args: &[Value]) -> impl ::std::future::Future<Output = Value> + Send { async move {
6709 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 {
6711 if !matches!(__v, crate::Value::Null) { return __v; }
6712 }
6713
6714 let mut symbol = get_arg(optional_args, 0, Value::Null);
6715 let mut since = get_arg(optional_args, 1, Value::Null);
6716 let mut limit = get_arg(optional_args, 2, Value::Null);
6717 let mut params = get_arg(optional_args, 3, Value::Map({
6718 let mut m = indexmap::IndexMap::new();
6719 m
6720}));
6721 panic!("{}", crate::exchange_errors::not_supported(format!("{}{}", self.id.clone(), Value::Str(" fetchFundingRateHistory() is not supported yet".into()))));
6722
6723 Value::Null
6724} }
6725
6726 fn fetch_funding_history(&mut self, optional_args: &[Value]) -> impl ::std::future::Future<Output = Value> + Send { async move {
6727 let mut symbol = get_arg(optional_args, 0, Value::Null);
6728 let mut since = get_arg(optional_args, 1, Value::Null);
6729 let mut limit = get_arg(optional_args, 2, Value::Null);
6730 let mut params = get_arg(optional_args, 3, Value::Map({
6731 let mut m = indexmap::IndexMap::new();
6732 m
6733}));
6734 panic!("{}", crate::exchange_errors::not_supported(format!("{}{}", self.id.clone(), Value::Str(" fetchFundingHistory() is not supported yet".into()))));
6735
6736 Value::Null
6737} }
6738
6739 fn parse_last_price(&self, mut price: Value, optional_args: &[Value]) -> Value {
6740 { 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; } }
6742
6743 let mut market = get_arg(optional_args, 0, Value::Null);
6744 panic!("{}", crate::exchange_errors::not_supported(format!("{}{}", self.id.clone(), Value::Str(" parseLastPrice() is not supported yet".into()))));
6745
6746 Value::Null
6747}
6748
6749 fn fetch_deposit_address(&mut self, mut code: Value, optional_args: &[Value]) -> impl ::std::future::Future<Output = Value> + Send { async move {
6750 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 {
6752 if !matches!(__v, crate::Value::Null) { return __v; }
6753 }
6754
6755 let mut params = get_arg(optional_args, 0, Value::Map({
6756 let mut m = indexmap::IndexMap::new();
6757 m
6758}));
6759 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)) {
6760 let mut depositAddresses: Value = self.fetch_deposit_addresses(&[Value::from(vec![code.clone()]), params.clone()]).await;
6761 let mut depositAddress: Value = self.safe_value(depositAddresses, code.clone(), &[]);
6762 if (depositAddress == Value::Null) {
6763 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()))));
6764 } else {
6765 return depositAddress;
6766 }
6767 } 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)) {
6768 let mut network: Value = self.safe_string_k(params.clone(), "network", &[]);
6769 let mut paramsOmitted: Value = self.omit(params, Value::Str("network".into()), &[]);
6770 let mut addressStructures: Value = self.fetch_deposit_addresses_by_network(code, &[paramsOmitted]).await;
6771 if (network != Value::Null) {
6772 return self.safe_dict(addressStructures.clone(), network, &[]);
6773 } else {
6774 let mut keys: Value = object_keys(&addressStructures);
6775 let mut key: Value = keys.as_array().and_then(|__arr| __arr.get(0)).cloned().unwrap_or(Value::Null);
6776 return self.safe_dict(addressStructures, key, &[]);
6777 }
6778 } else {
6779 panic!("{}", crate::exchange_errors::not_supported(format!("{}{}", self.id.clone(), Value::Str(" fetchDepositAddress() is not supported yet".into()))));
6780 }
6781
6782 Value::Null
6783} }
6784
6785 fn fetch_contract_deposit_address(&mut self, mut code: Value, optional_args: &[Value]) -> impl ::std::future::Future<Output = Value> + Send { async move {
6786 let mut params = get_arg(optional_args, 0, Value::Map({
6787 let mut m = indexmap::IndexMap::new();
6788 m
6789}));
6790 panic!("{}", crate::exchange_errors::not_supported(format!("{}{}", self.id.clone(), Value::Str(" fetchContractDepositAddress() is not supported yet".into()))));
6791
6792 Value::Null
6793} }
6794
6795 fn account(&self) -> Value {
6796 return Value::Map({
6797 let mut m = indexmap::IndexMap::new();
6798 m.insert("free".to_string(), Value::Null);
6799 m.insert("used".to_string(), Value::Null);
6800 m.insert("total".to_string(), Value::Null);
6801 m
6802});
6803
6804 Value::Null
6805}
6806
6807fn merge_balance_account(&self, mut result: Value, mut code: Value, mut account: Value) -> Value {
6817 if !(in_op(&result, &code)) {
6818 if let Value::Dict(__d) = &mut result { std::sync::Arc::make_mut(__d).insert(crate::runtime::stringify_param(&code), account.clone()); }
6819 return result;
6820 }
6821 let mut fields: Value = Value::from(vec![Value::Str("free".into()), Value::Str("used".into()), Value::Str("total".into()), Value::Str("debt".into())]);
6822 {
6823 let mut i: Value = Value::Int(0);
6824 let mut __for_first_136: bool = true;
6825 while { if !__for_first_136 { i = (match (&(i), &(Value::Int(1))) { (Value::Int(x), Value::Int(y)) => Value::Int(x + y), (Value::Int(x), Value::Float(y)) => Value::Float(*x as f64 + *y), (Value::Float(x), Value::Int(y)) => Value::Float(*x + *y as f64), (Value::Float(x), Value::Float(y)) => Value::Float(x + y), _ => Value::Null }); } __for_first_136 = false; i.as_f64().unwrap_or(f64::NAN) < ((fields.len() as i64) as f64) } {
6826 let mut field: Value = fields.as_array().and_then(|__arr| match &i { Value::Int(__n) => __arr.get(*__n as usize), Value::Str(__s) => __s.parse::<usize>().ok().and_then(|__n| __arr.get(__n)), _ => None }).cloned().unwrap_or(Value::Null);
6827 let mut current: Value = self.safe_string(result.as_map().and_then(|__m| code.as_str().and_then(|__k| __m.get(__k))).cloned().unwrap_or(Value::Null), field.clone(), &[]);
6828 let mut incoming: Value = self.safe_string(account.clone(), field.clone(), &[]);
6829 if (current == Value::Null) {
6830 add_element_to_object(get_value_mut(&mut result, &code), &field, incoming.clone());
6831 } else if (incoming != Value::Null) {
6832 add_element_to_object(get_value_mut(&mut result, &code), &field, crate::precise::Precise::stringAdd(¤t, &incoming));
6833 }
6834 }
6835 }
6836 return result;
6837
6838 Value::Null
6839}
6840
6841 fn common_currency_code(&self, mut code: Value) -> Value {
6842 if !is_true(&self.substituteCommonCurrencyCodes) {
6843 return code;
6844 }
6845 return self.safe_string(self.commonCurrencies.clone(), code.clone(), &[code.clone()]);
6846
6847 Value::Null
6848}
6849
6850 fn currency(&self, mut code: Value) -> Value {
6851 if (code == Value::Null) {
6852 panic!("{}", crate::exchange_errors::arguments_required(format!("{}{}", self.id.clone(), Value::Str(" currency() requires a code argument".into()))));
6853 }
6854 let mut keys: Value = object_keys(&self.currencies);
6855 let mut numCurrencies: f64 = ((keys.len() as i64) as f64);
6856 if (numCurrencies == 0.0) {
6857 panic!("{}", crate::exchange_errors::exchange_error(format!("{}{}", self.id.clone(), Value::Str(" currencies not loaded".into()))));
6858 }
6859 if matches!(&code, Value::Str(_)) {
6860 let mut currencies: Value = self.currencies.clone();
6861 let mut currenciesById: Value = self.currencies_by_id.clone();
6862 if (in_op(¤cies, &code)) {
6863 return currencies.as_map().and_then(|__m| code.as_str().and_then(|__k| __m.get(__k))).cloned().unwrap_or(Value::Null);
6864 } else if (currenciesById != Value::Null) && (in_op(¤ciesById, &code)) {
6865 return currenciesById.as_map().and_then(|__m| code.as_str().and_then(|__k| __m.get(__k))).cloned().unwrap_or(Value::Null);
6866 }
6867 }
6868 panic!("{}", crate::exchange_errors::exchange_error(format!("{}{}", Value::Str(format!("{}{}", self.id.clone(), Value::Str(" does not have currency code ".into())).into()), code)));
6869
6870 Value::Null
6871}
6872
6873 fn market(&self, mut symbol: Value) -> Value {
6874 if (symbol == Value::Null) {
6875 panic!("{}", crate::exchange_errors::arguments_required(format!("{}{}", self.id.clone(), Value::Str(" market() requires a symbol argument".into()))));
6876 }
6877 let mut markets: Value = self.markets.clone();
6878 if (markets == Value::Null) {
6879 panic!("{}", crate::exchange_errors::exchange_error(format!("{}{}", self.id.clone(), Value::Str(" markets not loaded".into()))));
6880 }
6881 let mut marketsById: Value = self.markets_by_id.clone();
6882 if (in_op(&markets, &symbol)) {
6883 return get_value(&markets, &symbol);
6884 } else if (marketsById != Value::Null) && (in_op(&marketsById, &symbol)) {
6885 let mut marketsList: Value = get_value(&marketsById, &symbol);
6886 let mut marketsList: Value = get_value(&marketsById, &symbol);
6887 let mut defaultType: Value = self.safe_string2(self.options.clone(), Value::Str("defaultType".into()), Value::Str("defaultSubType".into()), &[Value::Str("spot".into())]);
6888 {
6889 let mut i: Value = Value::Int(0);
6890 let mut __for_first_137: bool = true;
6891 while { if !__for_first_137 { i = (match (&(i), &(Value::Int(1))) { (Value::Int(x), Value::Int(y)) => Value::Int(x + y), (Value::Int(x), Value::Float(y)) => Value::Float(*x as f64 + *y), (Value::Float(x), Value::Int(y)) => Value::Float(*x + *y as f64), (Value::Float(x), Value::Float(y)) => Value::Float(x + y), _ => Value::Null }); } __for_first_137 = false; i.as_f64().unwrap_or(f64::NAN) < get_array_length(&marketsList).as_f64().unwrap_or(f64::NAN) } {
6892 let mut market: Value = get_value(&marketsList, &i);
6893 let mut market: Value = get_value(&marketsList, &i);
6894 if is_equal(&get_value(&market, &defaultType), &Value::Bool(true)) {
6895 return market;
6896 }
6897 }
6898 }
6899 return get_value(&marketsList, &Value::Int(0));
6900 } else if (ends_with(&symbol, &Value::Str("-C".into()))) || (ends_with(&symbol, &Value::Str("-P".into()))) || (starts_with(&symbol, &Value::Str("C-".into()))) || (starts_with(&symbol, &Value::Str("P-".into()))) {
6901 return <Self as crate::exchange_generated::ExchangeBase>::create_expired_option_market(self, symbol.clone());
6902 }
6903 panic!("{}", crate::exchange_errors::bad_symbol(format!("{}{}", Value::Str(format!("{}{}", self.id.clone(), Value::Str(" does not have market symbol ".into())).into()), symbol)));
6904
6905 Value::Null
6906}
6907
6908 fn create_expired_option_market(&self, mut symbol: Value) -> Value {
6909 { let __v = crate::exchange::DerivedExchange::create_expired_option_market(self, symbol); if !matches!(__v, crate::Value::Null) { return __v; } }
6911
6912 panic!("{}", crate::exchange_errors::not_supported(format!("{}{}", self.id.clone(), Value::Str(" createExpiredOptionMarket () is not supported yet".into()))));
6913
6914 Value::Null
6915}
6916
6917 fn is_leveraged_currency(&self, mut currencyCode: Value, optional_args: &[Value]) -> Value {
6918 let mut checkBaseCoin = get_arg(optional_args, 0, Value::Bool(false));
6919 let mut existingCurrencies = get_arg(optional_args, 1, Value::Null);
6920 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())]);
6921 {
6922 let mut i: Value = Value::Int(0);
6923 let mut __for_first_138: bool = true;
6924 while { if !__for_first_138 { i = (match (&(i), &(Value::Int(1))) { (Value::Int(x), Value::Int(y)) => Value::Int(x + y), (Value::Int(x), Value::Float(y)) => Value::Float(*x as f64 + *y), (Value::Float(x), Value::Int(y)) => Value::Float(*x + *y as f64), (Value::Float(x), Value::Float(y)) => Value::Float(x + y), _ => Value::Null }); } __for_first_138 = false; i.as_f64().unwrap_or(f64::NAN) < ((leverageSuffixes.len() as i64) as f64) } {
6925 let mut leverageSuffix: Value = leverageSuffixes.as_array().and_then(|__arr| match &i { Value::Int(__n) => __arr.get(*__n as usize), Value::Str(__s) => __s.parse::<usize>().ok().and_then(|__n| __arr.get(__n)), _ => None }).cloned().unwrap_or(Value::Null);
6926 let mut endsWithSuffix: bool = ends_with(¤cyCode, &leverageSuffix);
6927 if endsWithSuffix {
6928 if !is_true(&checkBaseCoin) {
6929 return Value::Bool(true);
6930 } else {
6931 let mut baseCurrencyCode: Value = replace_str(¤cyCode, &leverageSuffix, &Value::Str("".into()));
6933 if (existingCurrencies != Value::Null) && (in_op(&existingCurrencies, &baseCurrencyCode)) {
6934 return Value::Bool(true);
6935 }
6936 }
6937 }
6938 }
6939 }
6940 return Value::Bool(false);
6941
6942 Value::Null
6943}
6944
6945 fn handle_withdraw_tag_and_params(&self, mut tag: Value, mut params: Value) -> Value {
6946 let mut paramsExtended: Value = params.clone();
6947 let mut tagValue: Value = tag.clone();
6948 if is_true(&self.is_dictionary(tag.clone())) {
6949 paramsExtended = self.extend(tag, &[params]);
6950 tagValue = Value::Null;
6951 }
6952 let mut tagResolved: Value = (if (tagValue == Value::Null) { self.safe_string_k(paramsExtended.clone(), "tag", &[]) } else { tagValue.clone() });
6953 let mut tagFromParams: bool = (tagValue == Value::Null) && (tagResolved != Value::Null);
6954 let mut paramsOmitted: Value = paramsExtended.clone();
6955 if tagFromParams {
6956 paramsOmitted = self.omit(paramsExtended, Value::Str("tag".into()), &[]);
6957 }
6958 return Value::from(vec![tagResolved, paramsOmitted]);
6959
6960 Value::Null
6961}
6962
6963 fn cost_to_precision(&self, mut symbol: Value, mut cost: Value) -> Value {
6964 if (cost == Value::Null) {
6965 return Value::Null;
6966 }
6967 let mut market: Value = self.market(symbol);
6968 return self.decimal_to_precision(cost, Value::Int(crate::runtime::TRUNCATE), self.safe_string2(market.as_map().and_then(|__m| __m.get("precision")).cloned().unwrap_or(Value::Null), Value::Str("cost".into()), Value::Str("price".into()), &[]), &[self.precisionMode.clone(), self.paddingMode.clone()]);
6969
6970 Value::Null
6971}
6972
6973 fn price_to_precision(&self, mut symbol: Value, mut price: Value) -> Value {
6974 if (price == Value::Null) {
6975 return Value::Null;
6976 }
6977 let mut market: Value = self.market(symbol);
6978 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()]);
6979 if (result.as_str() == Some("0")) {
6980 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));
6981 if (pricePrecision == Value::Null) {
6982 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()))));
6983 }
6984 panic!("{}", crate::exchange_errors::invalid_order(format!("{}{}", Value::Str(format!("{}{}", Value::Str(format!("{}{}", Value::Str(format!("{}{}", self.id.clone(), Value::Str(" price of ".into())).into()), market.as_map().and_then(|__m| __m.get("symbol")).cloned().unwrap_or(Value::Null)).into()), Value::Str(" must be greater than minimum price precision of ".into())).into()), pricePrecision)));
6985 }
6986 return result;
6987
6988 Value::Null
6989}
6990
6991 fn amount_to_precision(&self, mut symbol: Value, mut amount: Value) -> Value {
6992 if (amount == Value::Null) {
6993 return Value::Null;
6994 }
6995 let mut market: Value = self.market(symbol);
6996 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()]);
6997 if (result.as_str() == Some("0")) {
6998 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));
6999 if (amountPrecision == Value::Null) {
7000 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()))));
7001 }
7002 panic!("{}", crate::exchange_errors::invalid_order(format!("{}{}", Value::Str(format!("{}{}", Value::Str(format!("{}{}", Value::Str(format!("{}{}", self.id.clone(), Value::Str(" amount of ".into())).into()), market.as_map().and_then(|__m| __m.get("symbol")).cloned().unwrap_or(Value::Null)).into()), Value::Str(" must be greater than minimum amount precision of ".into())).into()), amountPrecision)));
7003 }
7004 return result;
7005
7006 Value::Null
7007}
7008
7009 fn fee_to_precision(&self, mut symbol: Value, mut fee: Value) -> Value {
7010 if (fee == Value::Null) {
7011 return Value::Null;
7012 }
7013 let mut market: Value = self.market(symbol);
7014 return self.decimal_to_precision(fee, Value::Int(crate::runtime::ROUND), market.as_map().and_then(|__m| __m.get("precision")).cloned().unwrap_or(Value::Null).as_map().and_then(|__m| __m.get("price")).cloned().unwrap_or(Value::Null), &[self.precisionMode.clone(), self.paddingMode.clone()]);
7015
7016 Value::Null
7017}
7018
7019 fn currency_to_precision(&self, mut code: Value, mut fee: Value, optional_args: &[Value]) -> Value {
7020 let mut networkCode = get_arg(optional_args, 0, Value::Null);
7021 if (code == Value::Null) {
7022 panic!("{}", crate::exchange_errors::arguments_required(format!("{}{}", self.id.clone(), Value::Str(" currencyToPrecision() requires a code argument".into()))));
7023 }
7024 let mut currency: Value = get_value(&self.currencies, &code);
7025 let mut precision: Value = self.safe_value_k(currency.clone(), "precision", &[]);
7026 if (networkCode != Value::Null) {
7027 let mut networks: Value = self.safe_dict_k(currency, "networks", &[Value::Map({
7028 let mut m = indexmap::IndexMap::new();
7029 m
7030})]);
7031 let mut networkItem: Value = self.safe_dict(networks, networkCode, &[Value::Map({
7032 let mut m = indexmap::IndexMap::new();
7033 m
7034})]);
7035 precision = self.safe_value_k(networkItem, "precision", &[precision.clone()]);
7036 }
7037 if (precision == Value::Null) {
7038 return self.force_string(fee.clone());
7039 } else {
7040 let mut roundingMode: Value = self.safe_integer_k(self.options.clone(), "currencyToPrecisionRoundingMode", &[Value::Int(crate::runtime::ROUND)]);
7041 return self.decimal_to_precision(fee, roundingMode, precision, &[self.precisionMode.clone(), self.paddingMode.clone()]);
7042 }
7043
7044 Value::Null
7045}
7046
7047 fn force_string(&self, mut value: Value) -> Value {
7048 if !matches!(&value, Value::Str(_)) {
7049 return self.number_to_string(value.clone());
7050 }
7051 return value;
7052
7053 Value::Null
7054}
7055
7056 fn is_tick_precision(&self) -> Value {
7057 return Value::Bool(self.precisionMode.as_f64() == Value::Int(crate::runtime::TICK_SIZE).as_f64());
7058
7059 Value::Null
7060}
7061
7062 fn is_significant_precision(&self) -> Value {
7063 return Value::Bool(self.precisionMode.as_f64() == Value::Int(crate::runtime::SIGNIFICANT_DIGITS).as_f64());
7064
7065 Value::Null
7066}
7067
7068 fn safe_number(&self, mut obj: Value, mut key: Value, optional_args: &[Value]) -> Value {
7069 let mut defaultNumber = get_arg(optional_args, 0, Value::Null);
7070 let mut value: Value = self.safe_string(obj, key, &[]);
7071 return self.parse_number(value, &[defaultNumber]);
7072
7073 Value::Null
7074}
7075
7076 fn safe_number_n(&self, mut obj: Value, mut arr: Value, optional_args: &[Value]) -> Value {
7077 let mut defaultNumber = get_arg(optional_args, 0, Value::Null);
7078 let mut value: Value = self.safe_string_n(obj, arr, &[]);
7079 return self.parse_number(value, &[defaultNumber]);
7080
7081 Value::Null
7082}
7083
7084 fn parse_precision(&self, optional_args: &[Value]) -> Value {
7085 let mut precision = get_arg(optional_args, 0, Value::Null);
7086 if (precision == Value::Null) {
7093 return Value::Null;
7094 }
7095 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 });
7096 if (precisionNumber.as_f64() == Some(0.0)) {
7097 return Value::Str("1".into());
7098 }
7099 if precisionNumber.as_f64().unwrap_or(f64::NAN) > ((0i64) as f64) {
7100 let mut parsedPrecision: Value = Value::Str("0.".into());
7101 {
7102 let mut i: Value = Value::Int(0);
7103 let mut __for_first_139: bool = true;
7104 while { if !__for_first_139 { i = (match (&(i), &(Value::Int(1))) { (Value::Int(x), Value::Int(y)) => Value::Int(x + y), (Value::Int(x), Value::Float(y)) => Value::Float(*x as f64 + *y), (Value::Float(x), Value::Int(y)) => Value::Float(*x + *y as f64), (Value::Float(x), Value::Float(y)) => Value::Float(x + y), _ => Value::Null }); } __for_first_139 = false; i.as_f64().unwrap_or(f64::NAN) < (match (&(precisionNumber), &(Value::Int(1))) { (Value::Int(x), Value::Int(y)) => Value::Int(x - y), (Value::Int(x), Value::Float(y)) => Value::Float(*x as f64 - *y), (Value::Float(x), Value::Int(y)) => Value::Float(*x - *y as f64), (Value::Float(x), Value::Float(y)) => Value::Float(x - y), _ => Value::Null }).as_f64().unwrap_or(f64::NAN) } {
7105 parsedPrecision = Value::Str(format!("{}{}", parsedPrecision, Value::Str("0".into())).into());
7106 }
7107 }
7108 return Value::Str(format!("{}{}", parsedPrecision, Value::Str("1".into())).into());
7109 } else {
7110 let mut parsedPrecision: Value = Value::Str("1".into());
7111 {
7112 let mut i: Value = Value::Int(0);
7113 let mut __for_first_140: bool = true;
7114 while { if !__for_first_140 { i = (match (&(i), &(Value::Int(1))) { (Value::Int(x), Value::Int(y)) => Value::Int(x + y), (Value::Int(x), Value::Float(y)) => Value::Float(*x as f64 + *y), (Value::Float(x), Value::Int(y)) => Value::Float(*x + *y as f64), (Value::Float(x), Value::Float(y)) => Value::Float(x + y), _ => Value::Null }); } __for_first_140 = false; i.as_f64().unwrap_or(f64::NAN) < (match (&((match (&(precisionNumber), &(Value::Int(-1))) { (Value::Int(x), Value::Int(y)) => Value::Int(x * y), (Value::Int(x), Value::Float(y)) => Value::Float(*x as f64 * *y), (Value::Float(x), Value::Int(y)) => Value::Float(*x * *y as f64), (Value::Float(x), Value::Float(y)) => Value::Float(x * y), _ => Value::Null })), &(Value::Int(1))) { (Value::Int(x), Value::Int(y)) => Value::Int(x - y), (Value::Int(x), Value::Float(y)) => Value::Float(*x as f64 - *y), (Value::Float(x), Value::Int(y)) => Value::Float(*x - *y as f64), (Value::Float(x), Value::Float(y)) => Value::Float(x - y), _ => Value::Null }).as_f64().unwrap_or(f64::NAN) } {
7115 parsedPrecision = Value::Str(format!("{}{}", parsedPrecision, Value::Str("0".into())).into());
7116 }
7117 }
7118 return Value::Str(format!("{}{}", parsedPrecision, Value::Str("0".into())).into());
7119 }
7120
7121 Value::Null
7122}
7123
7124 fn integer_precision_to_amount(&self, mut precision: Value) -> Value {
7125 if (precision == Value::Null) {
7133 return Value::Null;
7134 }
7135 if is_true(&crate::precise::Precise::stringGe(&precision, &Value::Str("0".into()))) {
7136 return self.parse_precision(&[precision.clone()]);
7137 } else {
7138 let mut positivePrecisionString: Value = crate::precise::Precise::stringAbs(&precision);
7139 if (positivePrecisionString == Value::Null) {
7140 return Value::Null;
7141 }
7142 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 });
7143 let mut parsedPrecision: Value = Value::Str("1".into());
7144 {
7145 let mut i: Value = Value::Int(0);
7146 let mut __for_first_141: bool = true;
7147 while { if !__for_first_141 { i = (match (&(i), &(Value::Int(1))) { (Value::Int(x), Value::Int(y)) => Value::Int(x + y), (Value::Int(x), Value::Float(y)) => Value::Float(*x as f64 + *y), (Value::Float(x), Value::Int(y)) => Value::Float(*x + *y as f64), (Value::Float(x), Value::Float(y)) => Value::Float(x + y), _ => Value::Null }); } __for_first_141 = false; i.as_f64().unwrap_or(f64::NAN) < (match (&(positivePrecision), &(Value::Int(1))) { (Value::Int(x), Value::Int(y)) => Value::Int(x - y), (Value::Int(x), Value::Float(y)) => Value::Float(*x as f64 - *y), (Value::Float(x), Value::Int(y)) => Value::Float(*x - *y as f64), (Value::Float(x), Value::Float(y)) => Value::Float(x - y), _ => Value::Null }).as_f64().unwrap_or(f64::NAN) } {
7148 parsedPrecision = Value::Str(format!("{}{}", parsedPrecision, Value::Str("0".into())).into());
7149 }
7150 }
7151 return Value::Str(format!("{}{}", parsedPrecision, Value::Str("0".into())).into());
7152 }
7153}
7154
7155 fn load_time_difference(&mut self, optional_args: &[Value]) -> impl ::std::future::Future<Output = Value> + Send { async move {
7156 let mut params = get_arg(optional_args, 0, Value::Map({
7157 let mut m = indexmap::IndexMap::new();
7158 m
7159}));
7160 let mut serverTime: Value = self.fetch_time(&[params]).await;
7161 let mut after: Value = self.milliseconds();
7162 if (serverTime == Value::Null) {
7163 panic!("{}", crate::exchange_errors::exchange_error(format!("{}{}", self.id.clone(), Value::Str(" loadTimeDifference() missing serverTime".into()))));
7164 }
7165 if let Value::Dict(__d) = &mut self.options { std::sync::Arc::make_mut(__d).insert("timeDifference".into(), (match (&(after), &(serverTime)) { (Value::Int(x), Value::Int(y)) => Value::Int(x - y), (Value::Int(x), Value::Float(y)) => Value::Float(*x as f64 - *y), (Value::Float(x), Value::Int(y)) => Value::Float(*x - *y as f64), (Value::Float(x), Value::Float(y)) => Value::Float(x - y), _ => Value::Null })); }
7166 return self.options.as_map().and_then(|__m| __m.get("timeDifference")).cloned().unwrap_or(Value::Null);
7167
7168 Value::Null
7169} }
7170
7171 fn implode_hostname(&self, mut url: Value) -> Value {
7172 return self.implode_params(url, Value::Map({
7173 let mut m = indexmap::IndexMap::new();
7174 m.insert("hostname".to_string(), self.hostname.clone());
7175 m
7176}));
7177
7178 Value::Null
7179}
7180
7181 fn fetch_market_leverage_tiers(&mut self, mut symbol: Value, optional_args: &[Value]) -> impl ::std::future::Future<Output = Value> + Send { async move {
7182 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 {
7184 if !matches!(__v, crate::Value::Null) { return __v; }
7185 }
7186
7187 let mut params = get_arg(optional_args, 0, Value::Map({
7188 let mut m = indexmap::IndexMap::new();
7189 m
7190}));
7191 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)) {
7192 let mut market: Value = self.market(symbol.clone());
7193 if (market.as_map().and_then(|__m| __m.get("contract")).cloned().unwrap_or(Value::Null).as_bool() != Some(true)) {
7194 panic!("{}", crate::exchange_errors::bad_symbol(format!("{}{}", self.id.clone(), Value::Str(" fetchMarketLeverageTiers() supports contract markets only".into()))));
7195 }
7196 let mut tiers: Value = self.fetch_leverage_tiers(&[Value::from(vec![symbol.clone()])]).await;
7197 return self.safe_value(tiers, symbol, &[]);
7198 } else {
7199 panic!("{}", crate::exchange_errors::not_supported(format!("{}{}", self.id.clone(), Value::Str(" fetchMarketLeverageTiers() is not supported yet".into()))));
7200 }
7201
7202 Value::Null
7203} }
7204
7205 fn create_sub_account(&mut self, mut name: Value, optional_args: &[Value]) -> impl ::std::future::Future<Output = Value> + Send { async move {
7206 let mut params = get_arg(optional_args, 0, Value::Map({
7207 let mut m = indexmap::IndexMap::new();
7208 m
7209}));
7210 panic!("{}", crate::exchange_errors::not_supported(format!("{}{}", self.id.clone(), Value::Str(" createSubAccount() is not supported yet".into()))));
7211
7212 Value::Null
7213} }
7214
7215 fn safe_currency_code(&self, mut currencyId: Value, optional_args: &[Value]) -> Value {
7216 let mut currency = get_arg(optional_args, 0, Value::Null);
7217 let mut currencyResolved: Value = self.safe_currency(currencyId, &[currency]);
7218 return currencyResolved.as_map().and_then(|__m| __m.get("code")).cloned().unwrap_or(Value::Null);
7219
7220 Value::Null
7221}
7222
7223 fn filter_by_symbol_since_limit(&self, mut array: Value, optional_args: &[Value]) -> Value {
7224 let mut symbol = get_arg(optional_args, 0, Value::Null);
7225 let mut since = get_arg(optional_args, 1, Value::Null);
7226 let mut limit = get_arg(optional_args, 2, Value::Null);
7227 let mut tail = get_arg(optional_args, 3, Value::Bool(false));
7228 return self.filter_by_value_since_limit(array, Value::Str("symbol".into()), &[symbol, since, limit, Value::Str("timestamp".into()), tail]);
7229
7230 Value::Null
7231}
7232
7233 fn filter_by_currency_since_limit(&self, mut array: Value, optional_args: &[Value]) -> Value {
7234 let mut code = get_arg(optional_args, 0, Value::Null);
7235 let mut since = get_arg(optional_args, 1, Value::Null);
7236 let mut limit = get_arg(optional_args, 2, Value::Null);
7237 let mut tail = get_arg(optional_args, 3, Value::Bool(false));
7238 return self.filter_by_value_since_limit(array, Value::Str("currency".into()), &[code, since, limit, Value::Str("timestamp".into()), tail]);
7239
7240 Value::Null
7241}
7242
7243 fn filter_by_symbols_since_limit(&self, mut array: Value, optional_args: &[Value]) -> Value {
7244 let mut symbols = get_arg(optional_args, 0, Value::Null);
7245 let mut since = get_arg(optional_args, 1, Value::Null);
7246 let mut limit = get_arg(optional_args, 2, Value::Null);
7247 let mut tail = get_arg(optional_args, 3, Value::Bool(false));
7248 let mut result: Value = self.filter_by_array(array, Value::Str("symbol".into()), &[symbols, Value::Bool(false)]);
7249 return self.filter_by_since_limit(result, &[since, limit, Value::Str("timestamp".into()), tail]);
7250
7251 Value::Null
7252}
7253
7254 fn parse_last_prices(&self, mut pricesData: Value, optional_args: &[Value]) -> Value {
7255 let mut symbols = get_arg(optional_args, 0, Value::Null);
7256 let mut params = get_arg(optional_args, 1, Value::Map({
7257 let mut m = indexmap::IndexMap::new();
7258 m
7259}));
7260 let mut results: Value = Value::from(vec![]);
7280 if (matches!(&pricesData, Value::Arr(_))) {
7281 {
7282 let mut i: Value = Value::Int(0);
7283 let mut __for_first_142: bool = true;
7284 while { if !__for_first_142 { i = (match (&(i), &(Value::Int(1))) { (Value::Int(x), Value::Int(y)) => Value::Int(x + y), (Value::Int(x), Value::Float(y)) => Value::Float(*x as f64 + *y), (Value::Float(x), Value::Int(y)) => Value::Float(*x + *y as f64), (Value::Float(x), Value::Float(y)) => Value::Float(x + y), _ => Value::Null }); } __for_first_142 = false; i.as_f64().unwrap_or(f64::NAN) < ((pricesData.len() as i64) as f64) } {
7285 let mut priceData: Value = self.extend(<Self as crate::exchange_generated::ExchangeBase>::parse_last_price(self, pricesData.as_array().and_then(|__arr| match &i { Value::Int(__n) => __arr.get(*__n as usize), Value::Str(__s) => __s.parse::<usize>().ok().and_then(|__n| __arr.get(__n)), _ => None }).cloned().unwrap_or(Value::Null), &[]), &[params.clone()]);
7286 append_to_array(&mut results, priceData.clone());
7287 }
7288 }
7289 } else {
7290 let mut marketIds: Value = object_keys(&pricesData);
7291 {
7292 let mut i: Value = Value::Int(0);
7293 let mut __for_first_143: bool = true;
7294 while { if !__for_first_143 { i = (match (&(i), &(Value::Int(1))) { (Value::Int(x), Value::Int(y)) => Value::Int(x + y), (Value::Int(x), Value::Float(y)) => Value::Float(*x as f64 + *y), (Value::Float(x), Value::Int(y)) => Value::Float(*x + *y as f64), (Value::Float(x), Value::Float(y)) => Value::Float(x + y), _ => Value::Null }); } __for_first_143 = false; i.as_f64().unwrap_or(f64::NAN) < ((marketIds.len() as i64) as f64) } {
7295 let mut marketId: Value = marketIds.as_array().and_then(|__arr| match &i { Value::Int(__n) => __arr.get(*__n as usize), Value::Str(__s) => __s.parse::<usize>().ok().and_then(|__n| __arr.get(__n)), _ => None }).cloned().unwrap_or(Value::Null);
7296 let mut market: Value = self.safe_market(&[marketId.clone()]);
7297 let mut priceData: Value = self.extend(<Self as crate::exchange_generated::ExchangeBase>::parse_last_price(self, get_value(&pricesData, &marketId), &[market]), &[params.clone()]);
7298 append_to_array(&mut results, priceData);
7299 }
7300 }
7301 }
7302 let mut symbolsNormalized: Value = self.market_symbols(&[symbols]);
7303 return self.filter_by_array(results, Value::Str("symbol".into()), &[symbolsNormalized]);
7304
7305 Value::Null
7306}
7307
7308 fn parse_tickers(&self, mut tickers: Value, optional_args: &[Value]) -> Value {
7309 let mut symbols = get_arg(optional_args, 0, Value::Null);
7310 let mut params = get_arg(optional_args, 1, Value::Map({
7311 let mut m = indexmap::IndexMap::new();
7312 m
7313}));
7314 let mut results: Value = Value::from(vec![]);
7337 if (matches!(&tickers, Value::Arr(_))) {
7338 {
7339 let mut i: Value = Value::Int(0);
7340 let mut __for_first_144: bool = true;
7341 while { if !__for_first_144 { i = (match (&(i), &(Value::Int(1))) { (Value::Int(x), Value::Int(y)) => Value::Int(x + y), (Value::Int(x), Value::Float(y)) => Value::Float(*x as f64 + *y), (Value::Float(x), Value::Int(y)) => Value::Float(*x + *y as f64), (Value::Float(x), Value::Float(y)) => Value::Float(x + y), _ => Value::Null }); } __for_first_144 = false; i.as_f64().unwrap_or(f64::NAN) < ((tickers.len() as i64) as f64) } {
7342 let mut parsedTicker: Value = <Self as crate::exchange_generated::ExchangeBase>::parse_ticker(self, tickers.as_array().and_then(|__arr| match &i { Value::Int(__n) => __arr.get(*__n as usize), Value::Str(__s) => __s.parse::<usize>().ok().and_then(|__n| __arr.get(__n)), _ => None }).cloned().unwrap_or(Value::Null), &[]);
7343 let mut ticker: Value = self.extend(parsedTicker, &[params.clone()]);
7344 append_to_array(&mut results, ticker.clone());
7345 }
7346 }
7347 } else {
7348 let mut marketIds: Value = object_keys(&tickers);
7349 {
7350 let mut i: Value = Value::Int(0);
7351 let mut __for_first_145: bool = true;
7352 while { if !__for_first_145 { i = (match (&(i), &(Value::Int(1))) { (Value::Int(x), Value::Int(y)) => Value::Int(x + y), (Value::Int(x), Value::Float(y)) => Value::Float(*x as f64 + *y), (Value::Float(x), Value::Int(y)) => Value::Float(*x + *y as f64), (Value::Float(x), Value::Float(y)) => Value::Float(x + y), _ => Value::Null }); } __for_first_145 = false; i.as_f64().unwrap_or(f64::NAN) < ((marketIds.len() as i64) as f64) } {
7353 let mut marketId: Value = marketIds.as_array().and_then(|__arr| match &i { Value::Int(__n) => __arr.get(*__n as usize), Value::Str(__s) => __s.parse::<usize>().ok().and_then(|__n| __arr.get(__n)), _ => None }).cloned().unwrap_or(Value::Null);
7354 let mut market: Value = self.safe_market(&[marketId.clone()]);
7355 let mut parsed: Value = <Self as crate::exchange_generated::ExchangeBase>::parse_ticker(self, get_value(&tickers, &marketId), &[market]);
7356 let mut ticker: Value = self.extend(parsed, &[params.clone()]);
7357 append_to_array(&mut results, ticker);
7358 }
7359 }
7360 }
7361 let mut symbolsNormalized: Value = self.market_symbols(&[symbols]);
7362 return self.filter_by_array_tickers(results, Value::Str("symbol".into()), &[symbolsNormalized]);
7363
7364 Value::Null
7365}
7366
7367 fn parse_deposit_addresses(&self, mut addresses: Value, optional_args: &[Value]) -> Value {
7368 let mut codes = get_arg(optional_args, 0, Value::Null);
7369 let mut indexed = get_arg(optional_args, 1, Value::Bool(true));
7370 let mut params = get_arg(optional_args, 2, Value::Map({
7371 let mut m = indexmap::IndexMap::new();
7372 m
7373}));
7374 let mut result: Value = Value::from(vec![]);
7375 {
7376 let mut i: Value = Value::Int(0);
7377 let mut __for_first_146: bool = true;
7378 while { if !__for_first_146 { i = (match (&(i), &(Value::Int(1))) { (Value::Int(x), Value::Int(y)) => Value::Int(x + y), (Value::Int(x), Value::Float(y)) => Value::Float(*x as f64 + *y), (Value::Float(x), Value::Int(y)) => Value::Float(*x + *y as f64), (Value::Float(x), Value::Float(y)) => Value::Float(x + y), _ => Value::Null }); } __for_first_146 = false; i.as_f64().unwrap_or(f64::NAN) < get_array_length(&addresses).as_f64().unwrap_or(f64::NAN) } {
7379 let mut address: Value = self.extend(<Self as crate::exchange_generated::ExchangeBase>::parse_deposit_address(self, get_value(&addresses, &i), &[]), &[params.clone()]);
7380 append_to_array(&mut result, address);
7381 }
7382 }
7383 if (codes != Value::Null) {
7384 result = self.filter_by_array(result.clone(), Value::Str("currency".into()), &[codes, Value::Bool(false)]);
7385 }
7386 if is_true(&indexed) {
7387 result = self.filter_by_array(result.clone(), Value::Str("currency".into()), &[Value::Null, indexed.clone()]);
7388 }
7389 return result;
7390
7391 Value::Null
7392}
7393
7394 fn parse_borrow_interests(&self, mut response: Value, optional_args: &[Value]) -> Value {
7395 let mut market = get_arg(optional_args, 0, Value::Null);
7396 let mut interests: Value = Value::from(vec![]);
7397 {
7398 let mut i: Value = Value::Int(0);
7399 let mut __for_first_147: bool = true;
7400 while { if !__for_first_147 { i = (match (&(i), &(Value::Int(1))) { (Value::Int(x), Value::Int(y)) => Value::Int(x + y), (Value::Int(x), Value::Float(y)) => Value::Float(*x as f64 + *y), (Value::Float(x), Value::Int(y)) => Value::Float(*x + *y as f64), (Value::Float(x), Value::Float(y)) => Value::Float(x + y), _ => Value::Null }); } __for_first_147 = false; i.as_f64().unwrap_or(f64::NAN) < get_array_length(&response).as_f64().unwrap_or(f64::NAN) } {
7401 let mut row: Value = get_value(&response, &i);
7402 let mut row: Value = get_value(&response, &i);
7403 append_to_array(&mut interests, <Self as crate::exchange_generated::ExchangeBase>::parse_borrow_interest(self, row, &[market.clone()]));
7404 }
7405 }
7406 return interests;
7407
7408 Value::Null
7409}
7410
7411 fn parse_borrow_rate(&self, mut info: Value, optional_args: &[Value]) -> Value {
7412 { 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; } }
7414
7415 let mut currency = get_arg(optional_args, 0, Value::Null);
7416 panic!("{}", crate::exchange_errors::not_supported(format!("{}{}", self.id.clone(), Value::Str(" parseBorrowRate() is not supported yet".into()))));
7417
7418 Value::Null
7419}
7420
7421 fn parse_borrow_rate_history(&self, mut response: Value, mut code: Value, mut since: Value, mut limit: Value) -> Value {
7422 let mut result: Value = Value::from(vec![]);
7423 {
7424 let mut i: Value = Value::Int(0);
7425 let mut __for_first_148: bool = true;
7426 while { if !__for_first_148 { i = (match (&(i), &(Value::Int(1))) { (Value::Int(x), Value::Int(y)) => Value::Int(x + y), (Value::Int(x), Value::Float(y)) => Value::Float(*x as f64 + *y), (Value::Float(x), Value::Int(y)) => Value::Float(*x + *y as f64), (Value::Float(x), Value::Float(y)) => Value::Float(x + y), _ => Value::Null }); } __for_first_148 = false; i.as_f64().unwrap_or(f64::NAN) < get_array_length(&response).as_f64().unwrap_or(f64::NAN) } {
7427 let mut item: Value = get_value(&response, &i);
7428 let mut item: Value = get_value(&response, &i);
7429 let mut borrowRate: Value = <Self as crate::exchange_generated::ExchangeBase>::parse_borrow_rate(self, item, &[]);
7430 append_to_array(&mut result, borrowRate);
7431 }
7432 }
7433 let mut sorted: Value = self.sort_by(result, Value::Str("timestamp".into()), &[]);
7434 return self.filter_by_currency_since_limit(sorted, &[code, since, limit]);
7435
7436 Value::Null
7437}
7438
7439 fn parse_isolated_borrow_rates(&self, mut info: Value) -> Value {
7440 let mut result: Value = Value::Map({
7441 let mut m = indexmap::IndexMap::new();
7442 m
7443 });
7444 {
7445 let mut i: Value = Value::Int(0);
7446 let mut __for_first_149: bool = true;
7447 while { if !__for_first_149 { i = (match (&(i), &(Value::Int(1))) { (Value::Int(x), Value::Int(y)) => Value::Int(x + y), (Value::Int(x), Value::Float(y)) => Value::Float(*x as f64 + *y), (Value::Float(x), Value::Int(y)) => Value::Float(*x + *y as f64), (Value::Float(x), Value::Float(y)) => Value::Float(x + y), _ => Value::Null }); } __for_first_149 = false; i.as_f64().unwrap_or(f64::NAN) < get_array_length(&info).as_f64().unwrap_or(f64::NAN) } {
7448 let mut item: Value = get_value(&info, &i);
7449 let mut item: Value = get_value(&info, &i);
7450 let mut borrowRate: Value = self.parse_isolated_borrow_rate(item, &[]);
7451 let mut symbol: Value = self.safe_string_k(borrowRate.clone(), "symbol", &[]);
7452 if let Value::Dict(__d) = &mut result { std::sync::Arc::make_mut(__d).insert(crate::runtime::stringify_param(&symbol), borrowRate); }
7453 }
7454 }
7455 return result;
7456
7457 Value::Null
7458}
7459
7460 fn parse_funding_rate_histories(&self, mut response: Value, optional_args: &[Value]) -> Value {
7461 let mut market = get_arg(optional_args, 0, Value::Null);
7462 let mut since = get_arg(optional_args, 1, Value::Null);
7463 let mut limit = get_arg(optional_args, 2, Value::Null);
7464 let mut rates: Value = Value::from(vec![]);
7465 {
7466 let mut i: Value = Value::Int(0);
7467 let mut __for_first_150: bool = true;
7468 while { if !__for_first_150 { i = (match (&(i), &(Value::Int(1))) { (Value::Int(x), Value::Int(y)) => Value::Int(x + y), (Value::Int(x), Value::Float(y)) => Value::Float(*x as f64 + *y), (Value::Float(x), Value::Int(y)) => Value::Float(*x + *y as f64), (Value::Float(x), Value::Float(y)) => Value::Float(x + y), _ => Value::Null }); } __for_first_150 = false; i.as_f64().unwrap_or(f64::NAN) < get_array_length(&response).as_f64().unwrap_or(f64::NAN) } {
7469 let mut entry: Value = get_value(&response, &i);
7470 let mut entry: Value = get_value(&response, &i);
7471 append_to_array(&mut rates, <Self as crate::exchange_generated::ExchangeBase>::parse_funding_rate_history(self, entry, &[market.clone()]));
7472 }
7473 }
7474 let mut sorted: Value = self.sort_by(rates, Value::Str("timestamp".into()), &[]);
7475 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) });
7476 return self.filter_by_symbol_since_limit(sorted, &[symbol, since, limit]);
7477
7478 Value::Null
7479}
7480
7481 fn safe_symbol(&self, mut marketId: Value, optional_args: &[Value]) -> Value {
7482 let mut market = get_arg(optional_args, 0, Value::Null);
7483 let mut delimiter = get_arg(optional_args, 1, Value::Null);
7484 let mut marketType = get_arg(optional_args, 2, Value::Null);
7485 let mut marketResolved: Value = self.safe_market(&[marketId, market, delimiter, marketType]);
7486 return marketResolved.as_map().and_then(|__m| __m.get("symbol")).cloned().unwrap_or(Value::Null);
7487
7488 Value::Null
7489}
7490
7491 fn parse_funding_rate(&self, mut contract: Value, optional_args: &[Value]) -> Value {
7492 { 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; } }
7494
7495 let mut market = get_arg(optional_args, 0, Value::Null);
7496 panic!("{}", crate::exchange_errors::not_supported(format!("{}{}", self.id.clone(), Value::Str(" parseFundingRate() is not supported yet".into()))));
7497
7498 Value::Null
7499}
7500
7501 fn parse_funding_rates(&self, mut response: Value, optional_args: &[Value]) -> Value {
7502 let mut symbols = get_arg(optional_args, 0, Value::Null);
7503 let mut fundingRates: Value = Value::Map({
7504 let mut m = indexmap::IndexMap::new();
7505 m
7506 });
7507 {
7508 let mut i: Value = Value::Int(0);
7509 let mut __for_first_151: bool = true;
7510 while { if !__for_first_151 { i = (match (&(i), &(Value::Int(1))) { (Value::Int(x), Value::Int(y)) => Value::Int(x + y), (Value::Int(x), Value::Float(y)) => Value::Float(*x as f64 + *y), (Value::Float(x), Value::Int(y)) => Value::Float(*x + *y as f64), (Value::Float(x), Value::Float(y)) => Value::Float(x + y), _ => Value::Null }); } __for_first_151 = false; i.as_f64().unwrap_or(f64::NAN) < get_array_length(&response).as_f64().unwrap_or(f64::NAN) } {
7511 let mut entry: Value = get_value(&response, &i);
7512 let mut entry: Value = get_value(&response, &i);
7513 let mut parsed: Value = <Self as crate::exchange_generated::ExchangeBase>::parse_funding_rate(self, entry, &[]);
7514 if (parsed.as_map().and_then(|__m| __m.get("symbol")).cloned().unwrap_or(Value::Null) != Value::Null) {
7515 add_element_to_object(&mut fundingRates, &parsed.as_map().and_then(|__m| __m.get("symbol")).cloned().unwrap_or(Value::Null), parsed.clone());
7516 }
7517 }
7518 }
7519 return self.index_by(self.filter_by_array(fundingRates, Value::Str("symbol".into()), &[symbols, Value::Bool(false)]), Value::Str("symbol".into()));
7520
7521 Value::Null
7522}
7523
7524 fn parse_long_short_ratio(&self, mut info: Value, optional_args: &[Value]) -> Value {
7525 let mut market = get_arg(optional_args, 0, Value::Null);
7526 panic!("{}", crate::exchange_errors::not_supported(format!("{}{}", self.id.clone(), Value::Str(" parseLongShortRatio() is not supported yet".into()))));
7527
7528 Value::Null
7529}
7530
7531 fn parse_long_short_ratio_history(&self, mut response: Value, optional_args: &[Value]) -> Value {
7532 let mut market = get_arg(optional_args, 0, Value::Null);
7533 let mut since = get_arg(optional_args, 1, Value::Null);
7534 let mut limit = get_arg(optional_args, 2, Value::Null);
7535 let mut rates: Value = Value::from(vec![]);
7536 {
7537 let mut i: Value = Value::Int(0);
7538 let mut __for_first_152: bool = true;
7539 while { if !__for_first_152 { i = (match (&(i), &(Value::Int(1))) { (Value::Int(x), Value::Int(y)) => Value::Int(x + y), (Value::Int(x), Value::Float(y)) => Value::Float(*x as f64 + *y), (Value::Float(x), Value::Int(y)) => Value::Float(*x + *y as f64), (Value::Float(x), Value::Float(y)) => Value::Float(x + y), _ => Value::Null }); } __for_first_152 = false; i.as_f64().unwrap_or(f64::NAN) < get_array_length(&response).as_f64().unwrap_or(f64::NAN) } {
7540 let mut entry: Value = get_value(&response, &i);
7541 let mut entry: Value = get_value(&response, &i);
7542 append_to_array(&mut rates, self.parse_long_short_ratio(entry, &[market.clone()]));
7543 }
7544 }
7545 let mut sorted: Value = self.sort_by(rates, Value::Str("timestamp".into()), &[]);
7546 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) });
7547 return self.filter_by_symbol_since_limit(sorted, &[symbol, since, limit]);
7548
7549 Value::Null
7550}
7551
7552 fn handle_trigger_prices_and_params(&self, mut symbol: Value, mut params: Value, optional_args: &[Value]) -> Value {
7553 let mut omitParams = get_arg(optional_args, 0, Value::Bool(true));
7554 let mut triggerPrice: Value = self.safe_string2(params.clone(), Value::Str("triggerPrice".into()), Value::Str("stopPrice".into()), &[]);
7556 let mut triggerPriceStr: Value = Value::Null;
7557 let mut stopLossPrice: Value = self.safe_string_k(params.clone(), "stopLossPrice", &[]);
7558 let mut stopLossPriceStr: Value = Value::Null;
7559 let mut takeProfitPrice: Value = self.safe_string_k(params.clone(), "takeProfitPrice", &[]);
7560 let mut takeProfitPriceStr: Value = Value::Null;
7561 let mut keysToOmit: Value = Value::from(vec![]);
7563 if (triggerPrice != Value::Null) {
7564 if is_true(&omitParams) {
7565 append_to_array(&mut keysToOmit, Value::Str("triggerPrice".into()));
7566 append_to_array(&mut keysToOmit, Value::Str("stopPrice".into()));
7567 }
7568 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 }));
7569 }
7570 if (stopLossPrice != Value::Null) {
7571 if is_true(&omitParams) {
7572 append_to_array(&mut keysToOmit, Value::Str("stopLossPrice".into()));
7573 }
7574 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 }));
7575 }
7576 if (takeProfitPrice != Value::Null) {
7577 if is_true(&omitParams) {
7578 append_to_array(&mut keysToOmit, Value::Str("takeProfitPrice".into()));
7579 }
7580 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 }));
7581 }
7582 let mut keysToOmitLength: f64 = ((keysToOmit.len() as i64) as f64);
7583 let mut paramsOmitted: Value = (if (keysToOmitLength > ((0i64) as f64)) { self.omit(params.clone(), keysToOmit, &[]) } else { params });
7584 return Value::from(vec![triggerPriceStr, stopLossPriceStr, takeProfitPriceStr, paramsOmitted]);
7585
7586 Value::Null
7587}
7588
7589 fn handle_trigger_direction_and_params(&self, mut params: Value, optional_args: &[Value]) -> Value {
7590 let mut exchangeSpecificKey = get_arg(optional_args, 0, Value::Null);
7591 let mut allowEmpty = get_arg(optional_args, 1, Value::Bool(false));
7592 let mut triggerDirection: Value = self.safe_string_k(params.clone(), "triggerDirection", &[]);
7598 let mut exchangeSpecificDefined: bool = (exchangeSpecificKey != Value::Null) && (in_op(¶ms, &exchangeSpecificKey));
7599 let mut paramsOmitted: Value = (if (triggerDirection != Value::Null) { self.omit(params.clone(), Value::Str("triggerDirection".into()), &[]) } else { params });
7600 if !(self.in_array(triggerDirection.clone(), Value::from(vec![Value::Str("ascending".into()), Value::Str("descending".into()), Value::Str("up".into()), Value::Str("down".into()), Value::Str("above".into()), Value::Str("below".into())])).as_bool() == Some(true)) && !exchangeSpecificDefined && !is_true(&allowEmpty) {
7604 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()))));
7605 }
7606 if (triggerDirection.as_str() == Some("up")) || (triggerDirection.as_str() == Some("above")) {
7608 triggerDirection = Value::Str("ascending".into());
7609 } else if (triggerDirection.as_str() == Some("down")) || (triggerDirection.as_str() == Some("below")) {
7610 triggerDirection = Value::Str("descending".into());
7611 }
7612 return Value::from(vec![triggerDirection, paramsOmitted]);
7613
7614 Value::Null
7615}
7616
7617 fn handle_trigger_and_params(&self, mut params: Value) -> Value {
7618 let mut isTrigger: Value = self.safe_bool2(params.clone(), Value::Str("trigger".into()), Value::Str("stop".into()), &[]);
7619 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 });
7620 return Value::from(vec![isTrigger, paramsOmitted]);
7621
7622 Value::Null
7623}
7624
7625 fn is_trigger_order(&self, mut params: Value) -> Value {
7626 return self.handle_trigger_and_params(params);
7627
7628 Value::Null
7629}
7630
7631 fn is_post_only(&self, mut isMarketOrder: Value, mut exchangeSpecificParam: Value, optional_args: &[Value]) -> Value {
7632 let mut params = get_arg(optional_args, 0, Value::Map({
7633 let mut m = indexmap::IndexMap::new();
7634 m
7635}));
7636 let mut timeInForce: Value = self.safe_string_upper_k(params.clone(), "timeInForce", &[]);
7645 let mut postOnly: Value = self.safe_bool2(params, Value::Str("postOnly".into()), Value::Str("post_only".into()), &[Value::Bool(false)]);
7646 let mut ioc: bool = timeInForce.as_str() == Some("IOC");
7648 let mut fok: bool = timeInForce.as_str() == Some("FOK");
7649 let mut timeInForcePostOnly: Value = Value::Bool(timeInForce.as_str() == Some("PO"));
7650 if (postOnly.as_bool() != Some(true)) {
7651 postOnly = timeInForcePostOnly;
7652 }
7653 if (postOnly.as_bool() != Some(true)) {
7654 postOnly = exchangeSpecificParam;
7655 }
7656 if (postOnly.as_bool() == Some(true)) {
7657 if ioc || fok {
7658 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)));
7659 } else if is_true(&isMarketOrder) {
7660 panic!("{}", crate::exchange_errors::invalid_order(format!("{}{}", self.id.clone(), Value::Str(" market orders cannot be postOnly".into()))));
7661 } else {
7662 return Value::Bool(true);
7663 }
7664 } else {
7665 return Value::Bool(false);
7666 }
7667
7668 Value::Null
7669}
7670
7671 fn handle_post_only(&self, mut isMarketOrder: Value, mut exchangeSpecificPostOnlyOption: Value, optional_args: &[Value]) -> Value {
7672 let mut params = get_arg(optional_args, 0, Value::Map({
7673 let mut m = indexmap::IndexMap::new();
7674 m
7675}));
7676 let mut timeInForce: Value = self.safe_string_upper_k(params.clone(), "timeInForce", &[]);
7685 let mut postOnly: Value = self.safe_bool_k(params.clone(), "postOnly", &[Value::Bool(false)]);
7686 let mut ioc: bool = timeInForce.as_str() == Some("IOC");
7687 let mut fok: bool = timeInForce.as_str() == Some("FOK");
7688 let mut po: Value = Value::Bool(timeInForce.as_str() == Some("PO"));
7689 if (postOnly.as_bool() != Some(true)) {
7690 postOnly = po.clone();
7691 }
7692 if (postOnly.as_bool() != Some(true)) {
7693 postOnly = exchangeSpecificPostOnlyOption;
7694 }
7695 if (postOnly.as_bool() == Some(true)) {
7696 if ioc || fok {
7697 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)));
7698 } else if is_true(&isMarketOrder) {
7699 panic!("{}", crate::exchange_errors::invalid_order(format!("{}{}", self.id.clone(), Value::Str(" market orders cannot be postOnly".into()))));
7700 } else {
7701 let mut keysToOmit: Value = Value::Null;
7702 if matches!(&po, Value::Bool(true)) {
7703 keysToOmit = Value::from(vec![Value::Str("timeInForce".into()), Value::Str("postOnly".into())]);
7704 } else {
7705 keysToOmit = Value::from(vec![Value::Str("postOnly".into())]);
7706 }
7707 let mut paramsOmitted: Value = self.omit(params.clone(), keysToOmit, &[]);
7708 return Value::from(vec![Value::Bool(true), paramsOmitted]);
7709 }
7710 }
7711 return Value::from(vec![Value::Bool(false), params]);
7712
7713 Value::Null
7714}
7715
7716 fn fetch_last_prices(&mut self, optional_args: &[Value]) -> impl ::std::future::Future<Output = Value> + Send { async move {
7717 let mut symbols = get_arg(optional_args, 0, Value::Null);
7718 let mut params = get_arg(optional_args, 1, Value::Map({
7719 let mut m = indexmap::IndexMap::new();
7720 m
7721}));
7722 panic!("{}", crate::exchange_errors::not_supported(format!("{}{}", self.id.clone(), Value::Str(" fetchLastPrices() is not supported yet".into()))));
7723
7724 Value::Null
7725} }
7726
7727 fn fetch_trading_fees(&mut self, optional_args: &[Value]) -> impl ::std::future::Future<Output = Value> + Send { async move {
7728 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 {
7730 if !matches!(__v, crate::Value::Null) { return __v; }
7731 }
7732
7733 let mut params = get_arg(optional_args, 0, Value::Map({
7734 let mut m = indexmap::IndexMap::new();
7735 m
7736}));
7737 panic!("{}", crate::exchange_errors::not_supported(format!("{}{}", self.id.clone(), Value::Str(" fetchTradingFees() is not supported yet".into()))));
7738
7739 Value::Null
7740} }
7741
7742 fn fetch_trading_fees_ws(&mut self, optional_args: &[Value]) -> impl ::std::future::Future<Output = Value> + Send { async move {
7743 let mut params = get_arg(optional_args, 0, Value::Map({
7744 let mut m = indexmap::IndexMap::new();
7745 m
7746}));
7747 panic!("{}", crate::exchange_errors::not_supported(format!("{}{}", self.id.clone(), Value::Str(" fetchTradingFeesWs() is not supported yet".into()))));
7748
7749 Value::Null
7750} }
7751
7752 fn fetch_convert_currencies(&mut self, optional_args: &[Value]) -> impl ::std::future::Future<Output = Value> + Send { async move {
7753 let mut params = get_arg(optional_args, 0, Value::Map({
7754 let mut m = indexmap::IndexMap::new();
7755 m
7756}));
7757 panic!("{}", crate::exchange_errors::not_supported(format!("{}{}", self.id.clone(), Value::Str(" fetchConvertCurrencies() is not supported yet".into()))));
7758
7759 Value::Null
7760} }
7761
7762 fn parse_open_interest(&self, mut interest: Value, optional_args: &[Value]) -> Value {
7763 { 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; } }
7765
7766 let mut market = get_arg(optional_args, 0, Value::Null);
7767 panic!("{}", crate::exchange_errors::not_supported(format!("{}{}", self.id.clone(), Value::Str(" parseOpenInterest () is not supported yet".into()))));
7768
7769 Value::Null
7770}
7771
7772 fn parse_open_interests(&self, mut response: Value, optional_args: &[Value]) -> Value {
7773 let mut symbols = get_arg(optional_args, 0, Value::Null);
7774 let mut result: Value = Value::Map({
7775 let mut m = indexmap::IndexMap::new();
7776 m
7777 });
7778 {
7779 let mut i: Value = Value::Int(0);
7780 let mut __for_first_153: bool = true;
7781 while { if !__for_first_153 { i = (match (&(i), &(Value::Int(1))) { (Value::Int(x), Value::Int(y)) => Value::Int(x + y), (Value::Int(x), Value::Float(y)) => Value::Float(*x as f64 + *y), (Value::Float(x), Value::Int(y)) => Value::Float(*x + *y as f64), (Value::Float(x), Value::Float(y)) => Value::Float(x + y), _ => Value::Null }); } __for_first_153 = false; i.as_f64().unwrap_or(f64::NAN) < get_array_length(&response).as_f64().unwrap_or(f64::NAN) } {
7782 let mut entry: Value = get_value(&response, &i);
7783 let mut entry: Value = get_value(&response, &i);
7784 let mut parsed: Value = <Self as crate::exchange_generated::ExchangeBase>::parse_open_interest(self, entry, &[]);
7785 if (parsed.as_map().and_then(|__m| __m.get("symbol")).cloned().unwrap_or(Value::Null) != Value::Null) {
7786 add_element_to_object(&mut result, &parsed.as_map().and_then(|__m| __m.get("symbol")).cloned().unwrap_or(Value::Null), parsed.clone());
7787 }
7788 }
7789 }
7790 return self.filter_by_array(result, Value::Str("symbol".into()), &[symbols]);
7791
7792 Value::Null
7793}
7794
7795 fn parse_open_interests_history(&self, mut response: Value, optional_args: &[Value]) -> Value {
7796 let mut market = get_arg(optional_args, 0, Value::Null);
7797 let mut since = get_arg(optional_args, 1, Value::Null);
7798 let mut limit = get_arg(optional_args, 2, Value::Null);
7799 let mut interests: Value = Value::from(vec![]);
7800 {
7801 let mut i: Value = Value::Int(0);
7802 let mut __for_first_154: bool = true;
7803 while { if !__for_first_154 { i = (match (&(i), &(Value::Int(1))) { (Value::Int(x), Value::Int(y)) => Value::Int(x + y), (Value::Int(x), Value::Float(y)) => Value::Float(*x as f64 + *y), (Value::Float(x), Value::Int(y)) => Value::Float(*x + *y as f64), (Value::Float(x), Value::Float(y)) => Value::Float(x + y), _ => Value::Null }); } __for_first_154 = false; i.as_f64().unwrap_or(f64::NAN) < get_array_length(&response).as_f64().unwrap_or(f64::NAN) } {
7804 let mut entry: Value = get_value(&response, &i);
7805 let mut entry: Value = get_value(&response, &i);
7806 let mut interest: Value = <Self as crate::exchange_generated::ExchangeBase>::parse_open_interest(self, entry, &[market.clone()]);
7807 append_to_array(&mut interests, interest);
7808 }
7809 }
7810 let mut sorted: Value = self.sort_by(interests, Value::Str("timestamp".into()), &[]);
7811 let mut symbol: Value = self.safe_string_k(market, "symbol", &[]);
7812 return self.filter_by_symbol_since_limit(sorted, &[symbol, since, limit]);
7813
7814 Value::Null
7815}
7816
7817 fn fetch_funding_rate(&mut self, mut symbol: Value, optional_args: &[Value]) -> impl ::std::future::Future<Output = Value> + Send { async move {
7818 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 {
7820 if !matches!(__v, crate::Value::Null) { return __v; }
7821 }
7822
7823 let mut params = get_arg(optional_args, 0, Value::Map({
7824 let mut m = indexmap::IndexMap::new();
7825 m
7826}));
7827 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)) {
7828 self.load_markets(&[]).await;
7829 let mut market: Value = self.market(symbol);
7830 let mut symbolResolved: Value = market.as_map().and_then(|__m| __m.get("symbol")).cloned().unwrap_or(Value::Null);
7831 if (market.as_map().and_then(|__m| __m.get("contract")).cloned().unwrap_or(Value::Null).as_bool() != Some(true)) {
7832 panic!("{}", crate::exchange_errors::bad_symbol(format!("{}{}", self.id.clone(), Value::Str(" fetchFundingRate() supports contract markets only".into()))));
7833 }
7834 let mut rates: Value = self.fetch_funding_rates(&[Value::from(vec![symbolResolved.clone()]), params]).await;
7835 let mut rate: Value = self.safe_dict(rates, symbolResolved.clone(), &[]);
7836 if (rate == Value::Null) {
7837 panic!("{}", crate::exchange_errors::null_response(format!("{}{}", Value::Str(format!("{}{}", self.id.clone(), Value::Str(" fetchFundingRate () returned no data for ".into())).into()), symbolResolved)));
7838 } else {
7839 return rate;
7840 }
7841 } else {
7842 panic!("{}", crate::exchange_errors::not_supported(format!("{}{}", self.id.clone(), Value::Str(" fetchFundingRate () is not supported yet".into()))));
7843 }
7844
7845 Value::Null
7846} }
7847
7848 fn fetch_funding_interval(&mut self, mut symbol: Value, optional_args: &[Value]) -> impl ::std::future::Future<Output = Value> + Send { async move {
7849 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 {
7851 if !matches!(__v, crate::Value::Null) { return __v; }
7852 }
7853
7854 let mut params = get_arg(optional_args, 0, Value::Map({
7855 let mut m = indexmap::IndexMap::new();
7856 m
7857}));
7858 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)) {
7859 self.load_markets(&[]).await;
7860 let mut market: Value = self.market(symbol);
7861 let mut symbolResolved: Value = market.as_map().and_then(|__m| __m.get("symbol")).cloned().unwrap_or(Value::Null);
7862 if (market.as_map().and_then(|__m| __m.get("contract")).cloned().unwrap_or(Value::Null).as_bool() != Some(true)) {
7863 panic!("{}", crate::exchange_errors::bad_symbol(format!("{}{}", self.id.clone(), Value::Str(" fetchFundingInterval() supports contract markets only".into()))));
7864 }
7865 let mut rates: Value = self.fetch_funding_intervals(&[Value::from(vec![symbolResolved.clone()]), params]).await;
7866 let mut rate: Value = self.safe_dict(rates, symbolResolved.clone(), &[]);
7867 if (rate == Value::Null) {
7868 panic!("{}", crate::exchange_errors::null_response(format!("{}{}", Value::Str(format!("{}{}", self.id.clone(), Value::Str(" fetchFundingInterval() returned no data for ".into())).into()), symbolResolved)));
7869 } else {
7870 return rate;
7871 }
7872 } else {
7873 panic!("{}", crate::exchange_errors::not_supported(format!("{}{}", self.id.clone(), Value::Str(" fetchFundingInterval() is not supported yet".into()))));
7874 }
7875
7876 Value::Null
7877} }
7878
7879 fn fetch_mark_ohlcv(&mut self, mut symbol: Value, optional_args: &[Value]) -> impl ::std::future::Future<Output = Value> + Send { async move {
7880 let mut timeframe = get_arg(optional_args, 0, Value::Str("1m".into()));
7881 let mut since = get_arg(optional_args, 1, Value::Null);
7882 let mut limit = get_arg(optional_args, 2, Value::Null);
7883 let mut params = get_arg(optional_args, 3, Value::Map({
7884 let mut m = indexmap::IndexMap::new();
7885 m
7886}));
7887 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)) {
7899 let mut request: Value = Value::Map({
7900 let mut m = indexmap::IndexMap::new();
7901 m.insert("price".to_string(), Value::Str("mark".into()));
7902 m
7903 });
7904 return self.fetch_ohlcv(symbol, &[timeframe, since, limit, self.extend(request, &[params])]).await;
7905 } else {
7906 panic!("{}", crate::exchange_errors::not_supported(format!("{}{}", self.id.clone(), Value::Str(" fetchMarkOHLCV () is not supported yet".into()))));
7907 }
7908} }
7909
7910 fn fetch_index_ohlcv(&mut self, mut symbol: Value, optional_args: &[Value]) -> impl ::std::future::Future<Output = Value> + Send { async move {
7911 let mut timeframe = get_arg(optional_args, 0, Value::Str("1m".into()));
7912 let mut since = get_arg(optional_args, 1, Value::Null);
7913 let mut limit = get_arg(optional_args, 2, Value::Null);
7914 let mut params = get_arg(optional_args, 3, Value::Map({
7915 let mut m = indexmap::IndexMap::new();
7916 m
7917}));
7918 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)) {
7930 let mut request: Value = Value::Map({
7931 let mut m = indexmap::IndexMap::new();
7932 m.insert("price".to_string(), Value::Str("index".into()));
7933 m
7934 });
7935 return self.fetch_ohlcv(symbol, &[timeframe, since, limit, self.extend(request, &[params])]).await;
7936 } else {
7937 panic!("{}", crate::exchange_errors::not_supported(format!("{}{}", self.id.clone(), Value::Str(" fetchIndexOHLCV () is not supported yet".into()))));
7938 }
7939} }
7940
7941 fn fetch_premium_index_ohlcv(&mut self, mut symbol: Value, optional_args: &[Value]) -> impl ::std::future::Future<Output = Value> + Send { async move {
7942 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 {
7944 if !matches!(__v, crate::Value::Null) { return __v; }
7945 }
7946
7947 let mut timeframe = get_arg(optional_args, 0, Value::Str("1m".into()));
7948 let mut since = get_arg(optional_args, 1, Value::Null);
7949 let mut limit = get_arg(optional_args, 2, Value::Null);
7950 let mut params = get_arg(optional_args, 3, Value::Map({
7951 let mut m = indexmap::IndexMap::new();
7952 m
7953}));
7954 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)) {
7966 let mut request: Value = Value::Map({
7967 let mut m = indexmap::IndexMap::new();
7968 m.insert("price".to_string(), Value::Str("premiumIndex".into()));
7969 m
7970 });
7971 return self.fetch_ohlcv(symbol, &[timeframe, since, limit, self.extend(request, &[params])]).await;
7972 } else {
7973 panic!("{}", crate::exchange_errors::not_supported(format!("{}{}", self.id.clone(), Value::Str(" fetchPremiumIndexOHLCV () is not supported yet".into()))));
7974 }
7975} }
7976
7977 fn handle_time_in_force(&self, optional_args: &[Value]) -> Value {
7978 let mut params = get_arg(optional_args, 0, Value::Map({
7979 let mut m = indexmap::IndexMap::new();
7980 m
7981}));
7982 let mut timeInForce: Value = self.safe_string_upper_k(params, "timeInForce", &[]); if (timeInForce != Value::Null) {
7990 let mut exchangeValue: Value = self.safe_string(self.options.as_map().and_then(|__m| __m.get("timeInForce")).cloned().unwrap_or(Value::Null), timeInForce.clone(), &[]);
7991 if (exchangeValue == Value::Null) {
7992 panic!("{}", crate::exchange_errors::exchange_error(format!("{}{}", Value::Str(format!("{}{}", Value::Str(format!("{}{}", self.id.clone(), Value::Str(" does not support timeInForce \"".into())).into()), timeInForce).into()), Value::Str("\"".into()))));
7993 }
7994 return exchangeValue;
7995 }
7996 return Value::Null;
7997
7998 Value::Null
7999}
8000
8001 fn convert_type_to_account(&self, mut account: Value) -> Value {
8002 let mut accountsByType: Value = self.safe_dict_k(self.options.clone(), "accountsByType", &[Value::Map({
8010 let mut m = indexmap::IndexMap::new();
8011 m
8012})]);
8013 let mut lowercaseAccount: Value = to_lower(&account);
8014 if (in_op(&accountsByType, &lowercaseAccount)) {
8015 return get_value(&accountsByType, &lowercaseAccount);
8016 }
8017 let mut markets: Value = self.markets.clone();
8018 let mut marketsById: Value = self.markets_by_id.clone();
8019 if ((markets != Value::Null) && (in_op(&markets, &account))) || ((marketsById != Value::Null) && (in_op(&marketsById, &account))) {
8020 let mut market: Value = self.market(account.clone());
8021 return market.as_map().and_then(|__m| __m.get("id")).cloned().unwrap_or(Value::Null);
8022 } else {
8023 return account;
8024 }
8025
8026 Value::Null
8027}
8028
8029 fn check_required_argument(&self, mut methodName: Value, mut argument: Value, mut argumentName: Value, optional_args: &[Value]) {
8030 let mut options = get_arg(optional_args, 0, Value::from(vec![]));
8031 let mut optionsLength: f64 = ((options.len() as i64) as f64);
8041 if (argument == Value::Null) || ((optionsLength > ((0i64) as f64)) && (!(self.in_array(argument, options.clone()).as_bool() == Some(true)))) {
8042 let mut messageOptions: Value = join(&options, &Value::Str(", ".into()));
8043 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());
8044 if (messageOptions.as_str() != Some("")) {
8045 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());
8046 }
8047 panic!("{}", crate::exchange_errors::arguments_required(message));
8048 }
8049}
8050
8051 fn check_required_margin_argument(&self, mut methodName: Value, mut symbol: Value, mut marginMode: Value) {
8052 if (marginMode.as_str() == Some("isolated")) && (symbol == Value::Null) {
8060 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()))));
8061 } else if (marginMode.as_str() == Some("cross")) && (symbol != Value::Null) {
8062 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()))));
8063 }
8064}
8065
8066 fn parse_deposit_withdraw_fees(&self, mut response: Value, optional_args: &[Value]) -> Value {
8067 let mut codes = get_arg(optional_args, 0, Value::Null);
8068 let mut currencyIdKey = get_arg(optional_args, 1, Value::Null);
8069 let mut depositWithdrawFees: Value = Value::Map({
8078 let mut m = indexmap::IndexMap::new();
8079 m
8080 });
8081 let mut isArray: bool = matches!(&response, Value::Arr(_));
8082 let mut responseKeys: Value = response.clone();
8083 if !isArray {
8084 responseKeys = object_keys(&response);
8085 }
8086 {
8087 let mut i: Value = Value::Int(0);
8088 let mut __for_first_155: bool = true;
8089 while { if !__for_first_155 { i = (match (&(i), &(Value::Int(1))) { (Value::Int(x), Value::Int(y)) => Value::Int(x + y), (Value::Int(x), Value::Float(y)) => Value::Float(*x as f64 + *y), (Value::Float(x), Value::Int(y)) => Value::Float(*x + *y as f64), (Value::Float(x), Value::Float(y)) => Value::Float(x + y), _ => Value::Null }); } __for_first_155 = false; i.as_f64().unwrap_or(f64::NAN) < get_array_length(&responseKeys).as_f64().unwrap_or(f64::NAN) } {
8090 let mut entry: Value = get_value(&responseKeys, &i);
8091 let mut entry: Value = get_value(&responseKeys, &i);
8092 let mut dictionary: Value = (if isArray { entry.clone() } else { get_value(&response, &entry) });
8093 let mut currencyId: Value = entry;
8094 if isArray {
8095 currencyId = (if (currencyIdKey == Value::Null) { Value::Null } else { self.safe_string(dictionary.clone(), currencyIdKey.clone(), &[]) });
8096 }
8097 let mut currency: Value = self.safe_currency(currencyId, &[]);
8098 let mut code: Value = self.safe_string_k(currency.clone(), "code", &[]);
8099 if (codes == Value::Null) || self.in_array(code.clone(), codes.clone()).as_bool() == Some(true) {
8100 if let Value::Dict(__d) = &mut depositWithdrawFees { std::sync::Arc::make_mut(__d).insert(crate::runtime::stringify_param(&code), <Self as crate::exchange_generated::ExchangeBase>::parse_deposit_withdraw_fee(self, dictionary, &[currency])); }
8101 }
8102 }
8103 }
8104 return depositWithdrawFees;
8105
8106 Value::Null
8107}
8108
8109 fn parse_deposit_withdraw_fee(&self, mut fee: Value, optional_args: &[Value]) -> Value {
8110 { 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; } }
8112
8113 let mut currency = get_arg(optional_args, 0, Value::Null);
8114 panic!("{}", crate::exchange_errors::not_supported(format!("{}{}", self.id.clone(), Value::Str(" parseDepositWithdrawFee() is not supported yet".into()))));
8115
8116 Value::Null
8117}
8118
8119 fn deposit_withdraw_fee(&self, mut info: Value) -> Value {
8120 return Value::Map({
8121 let mut m = indexmap::IndexMap::new();
8122 m.insert("info".to_string(), info);
8123 m.insert("withdraw".to_string(), Value::Map({
8124 let mut m = indexmap::IndexMap::new();
8125 m.insert("fee".to_string(), Value::Null);
8126 m.insert("percentage".to_string(), Value::Null);
8127 m
8128}));
8129 m.insert("deposit".to_string(), Value::Map({
8130 let mut m = indexmap::IndexMap::new();
8131 m.insert("fee".to_string(), Value::Null);
8132 m.insert("percentage".to_string(), Value::Null);
8133 m
8134}));
8135 m.insert("networks".to_string(), Value::Map({
8136 let mut m = indexmap::IndexMap::new();
8137 m
8138}));
8139 m
8140});
8141
8142 Value::Null
8143}
8144
8145 fn assign_default_deposit_withdraw_fees(&self, mut fee: Value, optional_args: &[Value]) -> Value {
8146 let mut currency = get_arg(optional_args, 0, Value::Null);
8147 let __currency_empty = indexmap::IndexMap::new();
8148 let currency = currency.as_map().unwrap_or(&__currency_empty);
8149 let mut networkKeys: Value = object_keys(&crate::value::get_value_k(&fee, "networks"));
8158 let mut numNetworks: f64 = ((networkKeys.len() as i64) as f64);
8159 if (numNetworks == 1.0) {
8160 { let __be_tmp = crate::value::get_value_k(&get_value(&crate::value::get_value_k(&fee, "networks"), &networkKeys.as_array().and_then(|__arr| __arr.get(0)).cloned().unwrap_or(Value::Null)), "withdraw"); add_element_to_object(&mut fee, &Value::Str("withdraw".into()), __be_tmp); };
8161 { let __be_tmp = crate::value::get_value_k(&get_value(&crate::value::get_value_k(&fee, "networks"), &networkKeys.as_array().and_then(|__arr| __arr.get(0)).cloned().unwrap_or(Value::Null)), "deposit"); add_element_to_object(&mut fee, &Value::Str("deposit".into()), __be_tmp); };
8162 return fee;
8163 }
8164 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 });
8165 {
8166 let mut i: Value = Value::Int(0);
8167 let mut __for_first_156: bool = true;
8168 while { if !__for_first_156 { i = (match (&(i), &(Value::Int(1))) { (Value::Int(x), Value::Int(y)) => Value::Int(x + y), (Value::Int(x), Value::Float(y)) => Value::Float(*x as f64 + *y), (Value::Float(x), Value::Int(y)) => Value::Float(*x + *y as f64), (Value::Float(x), Value::Float(y)) => Value::Float(x + y), _ => Value::Null }); } __for_first_156 = false; i.as_f64().unwrap_or(f64::NAN) < numNetworks } {
8169 let mut network: Value = networkKeys.as_array().and_then(|__arr| match &i { Value::Int(__n) => __arr.get(*__n as usize), Value::Str(__s) => __s.parse::<usize>().ok().and_then(|__n| __arr.get(__n)), _ => None }).cloned().unwrap_or(Value::Null);
8170 if (network.as_str() == currencyCode.as_str()) {
8171 { let __be_tmp = crate::value::get_value_k(&get_value(&crate::value::get_value_k(&fee, "networks"), &networkKeys.as_array().and_then(|__arr| match &i { Value::Int(__n) => __arr.get(*__n as usize), Value::Str(__s) => __s.parse::<usize>().ok().and_then(|__n| __arr.get(__n)), _ => None }).cloned().unwrap_or(Value::Null)), "withdraw"); add_element_to_object(&mut fee, &Value::Str("withdraw".into()), __be_tmp); };
8172 { let __be_tmp = crate::value::get_value_k(&get_value(&crate::value::get_value_k(&fee, "networks"), &networkKeys.as_array().and_then(|__arr| match &i { Value::Int(__n) => __arr.get(*__n as usize), Value::Str(__s) => __s.parse::<usize>().ok().and_then(|__n| __arr.get(__n)), _ => None }).cloned().unwrap_or(Value::Null)), "deposit"); add_element_to_object(&mut fee, &Value::Str("deposit".into()), __be_tmp); };
8173 }
8174 }
8175 }
8176 return fee;
8177
8178 Value::Null
8179}
8180
8181 fn parse_income(&self, mut info: Value, optional_args: &[Value]) -> Value {
8182 { 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; } }
8184
8185 let mut market = get_arg(optional_args, 0, Value::Null);
8186 panic!("{}", crate::exchange_errors::not_supported(format!("{}{}", self.id.clone(), Value::Str(" parseIncome () is not supported yet".into()))));
8187
8188 Value::Null
8189}
8190
8191 fn parse_incomes(&self, mut incomes: Value, optional_args: &[Value]) -> Value {
8192 let mut market = get_arg(optional_args, 0, Value::Null);
8193 let mut since = get_arg(optional_args, 1, Value::Null);
8194 let mut limit = get_arg(optional_args, 2, Value::Null);
8195 let mut result: Value = Value::from(vec![]);
8206 {
8207 let mut i: Value = Value::Int(0);
8208 let mut __for_first_157: bool = true;
8209 while { if !__for_first_157 { i = (match (&(i), &(Value::Int(1))) { (Value::Int(x), Value::Int(y)) => Value::Int(x + y), (Value::Int(x), Value::Float(y)) => Value::Float(*x as f64 + *y), (Value::Float(x), Value::Int(y)) => Value::Float(*x + *y as f64), (Value::Float(x), Value::Float(y)) => Value::Float(x + y), _ => Value::Null }); } __for_first_157 = false; i.as_f64().unwrap_or(f64::NAN) < get_array_length(&incomes).as_f64().unwrap_or(f64::NAN) } {
8210 let mut entry: Value = get_value(&incomes, &i);
8211 let mut entry: Value = get_value(&incomes, &i);
8212 let mut parsed: Value = <Self as crate::exchange_generated::ExchangeBase>::parse_income(self, entry, &[market.clone()]);
8213 append_to_array(&mut result, parsed);
8214 }
8215 }
8216 let mut sorted: Value = self.sort_by(result, Value::Str("timestamp".into()), &[]);
8217 let mut symbol: Value = self.safe_string_k(market, "symbol", &[]);
8218 return self.filter_by_symbol_since_limit(sorted, &[symbol, since, limit]);
8219
8220 Value::Null
8221}
8222
8223 fn get_market_from_symbols(&self, optional_args: &[Value]) -> Value {
8224 let mut symbols = get_arg(optional_args, 0, Value::Null);
8225 if (symbols == Value::Null) {
8231 return Value::Null;
8232 }
8233 let mut firstMarket: Value = self.safe_string(symbols, Value::Int(0), &[]);
8234 if (firstMarket == Value::Null) {
8235 return Value::Null;
8236 }
8237 let mut market: Value = self.market(firstMarket);
8238 return market;
8239
8240 Value::Null
8241}
8242
8243 fn parse_ws_ohlc_vs(&self, mut ohlcvs: Value, optional_args: &[Value]) -> Value {
8244 let mut market = get_arg(optional_args, 0, Value::Null);
8245 let mut timeframe = get_arg(optional_args, 1, Value::Str("1m".into()));
8246 let mut since = get_arg(optional_args, 2, Value::Null);
8247 let mut limit = get_arg(optional_args, 3, Value::Null);
8248 let mut results: Value = Value::from(vec![]);
8249 {
8250 let mut i: Value = Value::Int(0);
8251 let mut __for_first_158: bool = true;
8252 while { if !__for_first_158 { i = (match (&(i), &(Value::Int(1))) { (Value::Int(x), Value::Int(y)) => Value::Int(x + y), (Value::Int(x), Value::Float(y)) => Value::Float(*x as f64 + *y), (Value::Float(x), Value::Int(y)) => Value::Float(*x + *y as f64), (Value::Float(x), Value::Float(y)) => Value::Float(x + y), _ => Value::Null }); } __for_first_158 = false; i.as_f64().unwrap_or(f64::NAN) < ((ohlcvs.len() as i64) as f64) } {
8253 append_to_array(&mut results, self.parse_ws_ohlcv(ohlcvs.as_array().and_then(|__arr| match &i { Value::Int(__n) => __arr.get(*__n as usize), Value::Str(__s) => __s.parse::<usize>().ok().and_then(|__n| __arr.get(__n)), _ => None }).cloned().unwrap_or(Value::Null), &[market.clone()]));
8254 }
8255 }
8256 return results;
8257
8258 Value::Null
8259}
8260
8261 fn fetch_transactions(&mut self, optional_args: &[Value]) -> impl ::std::future::Future<Output = Value> + Send { async move {
8262 let mut code = get_arg(optional_args, 0, Value::Null);
8263 let mut since = get_arg(optional_args, 1, Value::Null);
8264 let mut limit = get_arg(optional_args, 2, Value::Null);
8265 let mut params = get_arg(optional_args, 3, Value::Map({
8266 let mut m = indexmap::IndexMap::new();
8267 m
8268}));
8269 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)) {
8281 return self.fetch_deposits_withdrawals(&[code, since, limit, params]).await;
8282 } else {
8283 panic!("{}", crate::exchange_errors::not_supported(format!("{}{}", self.id.clone(), Value::Str(" fetchTransactions () is not supported yet".into()))));
8284 }
8285} }
8286
8287 fn filter_by_array_positions(&self, mut objects: Value, mut key: Value, optional_args: &[Value]) -> Value {
8288 let mut values = get_arg(optional_args, 0, Value::Null);
8289 return self.to_array(self.filter_by_array(objects, key, &[values, Value::Bool(false)]));
8290
8291 Value::Null
8292}
8293
8294 fn filter_by_array_tickers(&self, mut objects: Value, mut key: Value, optional_args: &[Value]) -> Value {
8295 let mut values = get_arg(optional_args, 0, Value::Null);
8296 return self.index_by(self.filter_by_array(objects, key.clone(), &[values, Value::Bool(false)]), key);
8297
8298 Value::Null
8299}
8300
8301 fn filter_by_array_adl_ranks(&self, mut objects: Value, mut key: Value, optional_args: &[Value]) -> Value {
8302 let mut values = get_arg(optional_args, 0, Value::Null);
8303 let mut indexed = get_arg(optional_args, 1, Value::Bool(true));
8304 return self.filter_by_array(objects, key, &[values, indexed]);
8305
8306 Value::Null
8307}
8308
8309 fn create_ohlcv_object(&self, mut symbol: Value, mut timeframe: Value, mut data: Value) -> Value {
8310 let mut res: Value = Value::Map({
8311 let mut m = indexmap::IndexMap::new();
8312 m
8313 });
8314 if let Value::Dict(__d) = &mut res { std::sync::Arc::make_mut(__d).insert(crate::runtime::stringify_param(&symbol), Value::Map({
8315 let mut m = indexmap::IndexMap::new();
8316 m
8317})); }
8318 add_element_to_object(get_value_mut(&mut res, &symbol), &timeframe, data);
8319 return res;
8320
8321 Value::Null
8322}
8323
8324 fn handle_max_entries_per_request_and_params(&self, mut method: Value, optional_args: &[Value]) -> Value {
8325 let mut maxEntriesPerRequest = get_arg(optional_args, 0, Value::Null);
8326 let mut params = get_arg(optional_args, 1, Value::Map({
8327 let mut m = indexmap::IndexMap::new();
8328 m
8329}));
8330 let mut newMaxEntriesPerRequestparamsMaxEntriesPerRequestVariable = self.handle_option_integer_and_params(params, method, Value::Str("maxEntriesPerRequest".into()), &[]);
8331 let mut newMaxEntriesPerRequest: Value = newMaxEntriesPerRequestparamsMaxEntriesPerRequestVariable.as_array().and_then(|__arr| __arr.get(0)).cloned().unwrap_or(Value::Null);
8332 let mut paramsMaxEntriesPerRequest: Value = newMaxEntriesPerRequestparamsMaxEntriesPerRequestVariable.as_array().and_then(|__arr| __arr.get(1)).cloned().unwrap_or(Value::Null);
8333 let mut maxEntriesPerRequestOption: Value = (if (newMaxEntriesPerRequest != Value::Null) { newMaxEntriesPerRequest } else { maxEntriesPerRequest });
8334 let mut maxEntriesPerRequestResolved: Value = (if (maxEntriesPerRequestOption == Value::Null) { Value::Int(1000) } else { maxEntriesPerRequestOption }); return Value::from(vec![maxEntriesPerRequestResolved, paramsMaxEntriesPerRequest]);
8336
8337 Value::Null
8338}
8339
8340 fn fetch_paginated_call_dynamic(&mut self, mut method: Value, optional_args: &[Value]) -> impl ::std::future::Future<Output = Value> + Send { async move {
8341 let mut symbol = get_arg(optional_args, 0, Value::Null);
8342 let mut since = get_arg(optional_args, 1, Value::Null);
8343 let mut limit = get_arg(optional_args, 2, Value::Null);
8344 let mut params = get_arg(optional_args, 3, Value::Map({
8345 let mut m = indexmap::IndexMap::new();
8346 m
8347}));
8348 let mut maxEntriesPerRequest = get_arg(optional_args, 4, Value::Null);
8349 let mut removeRepeated = get_arg(optional_args, 5, Value::Bool(true));
8350 let mut maxCalls: Value = Value::Int(10);
8351 let mut maxCallsPaginationCallsparamsPaginationCallsVariable = self.handle_option_integer_and_params(params, method.clone(), Value::Str("paginationCalls".into()), &[maxCalls]);
8352 let mut maxCallsPaginationCalls: Value = maxCallsPaginationCallsparamsPaginationCallsVariable.as_array().and_then(|__arr| __arr.get(0)).cloned().unwrap_or(Value::Null);
8353 let mut paramsPaginationCalls: Value = maxCallsPaginationCallsparamsPaginationCallsVariable.as_array().and_then(|__arr| __arr.get(1)).cloned().unwrap_or(Value::Null);
8354 let mut maxRetries: Value = Value::Int(3);
8355 let mut maxRetriesOptionparamsMaxRetriesVariable = self.handle_option_integer_and_params(paramsPaginationCalls, method.clone(), Value::Str("maxRetries".into()), &[maxRetries]);
8356 let mut maxRetriesOption: Value = maxRetriesOptionparamsMaxRetriesVariable.as_array().and_then(|__arr| __arr.get(0)).cloned().unwrap_or(Value::Null);
8357 let mut paramsMaxRetries: Value = maxRetriesOptionparamsMaxRetriesVariable.as_array().and_then(|__arr| __arr.get(1)).cloned().unwrap_or(Value::Null);
8358 let mut paginationDirectionparamsPaginationDirectionVariable = self.handle_option_and_params(paramsMaxRetries, method.clone(), Value::Str("paginationDirection".into()), &[Value::Str("backward".into())]);
8359 let mut paginationDirection: Value = paginationDirectionparamsPaginationDirectionVariable.as_array().and_then(|__arr| __arr.get(0)).cloned().unwrap_or(Value::Null);
8360 let mut paramsPaginationDirection: Value = paginationDirectionparamsPaginationDirectionVariable.as_array().and_then(|__arr| __arr.get(1)).cloned().unwrap_or(Value::Null);
8361 let mut paginationTimestamp: Value = Value::Null;
8362 let mut removeRepeatedOptionparamsRemoveRepeatedVariable = self.handle_option_and_params(paramsPaginationDirection, method.clone(), Value::Str("removeRepeated".into()), &[removeRepeated]);
8363 let mut removeRepeatedOption: Value = removeRepeatedOptionparamsRemoveRepeatedVariable.as_array().and_then(|__arr| __arr.get(0)).cloned().unwrap_or(Value::Null);
8364 let mut paramsRemoveRepeated: Value = removeRepeatedOptionparamsRemoveRepeatedVariable.as_array().and_then(|__arr| __arr.get(1)).cloned().unwrap_or(Value::Null);
8365 let mut calls: Value = Value::Int(0);
8366 let mut result: Value = Value::from(vec![]);
8367 let mut errors: Value = Value::Int(0);
8368 let mut until: Value = self.safe_integer_n(paramsRemoveRepeated.clone(), Value::from(vec![Value::Str("until".into()), Value::Str("untill".into()), Value::Str("till".into())]), &[]); let mut maxEntriesPerRequestOptionparamsMaxEntriesPerRequestVariable = self.handle_max_entries_per_request_and_params(method.clone(), &[maxEntriesPerRequest, paramsRemoveRepeated]);
8370 let mut maxEntriesPerRequestOption: Value = maxEntriesPerRequestOptionparamsMaxEntriesPerRequestVariable.as_array().and_then(|__arr| __arr.get(0)).cloned().unwrap_or(Value::Null);
8371 let mut paramsMaxEntriesPerRequest: Value = maxEntriesPerRequestOptionparamsMaxEntriesPerRequestVariable.as_array().and_then(|__arr| __arr.get(1)).cloned().unwrap_or(Value::Null);
8372 if (paginationDirection.as_str() == Some("forward")) {
8373 if (since == Value::Null) {
8374 panic!("{}", crate::exchange_errors::arguments_required(format!("{}{}", self.id.clone(), Value::Str(" pagination requires a since argument when paginationDirection set to forward".into()))));
8375 }
8376 paginationTimestamp = since.clone();
8377 }
8378 while (calls.as_f64().unwrap_or(f64::NAN) < maxCallsPaginationCalls.as_f64().unwrap_or(f64::NAN)) {
8379 calls = (match (&(calls), &(Value::Int(1))) { (Value::Int(x), Value::Int(y)) => Value::Int(x + y), (Value::Int(x), Value::Float(y)) => Value::Float(*x as f64 + *y), (Value::Float(x), Value::Int(y)) => Value::Float(*x + *y as f64), (Value::Float(x), Value::Float(y)) => Value::Float(x + y), _ => Value::Null });
8380 {
8381 if (paginationDirection.as_str() == Some("backward")) {
8382 if (paginationTimestamp != Value::Null) {
8385 add_element_to_object(&mut paramsMaxEntriesPerRequest, &Value::Str("until".into()), (match (&(paginationTimestamp), &(Value::Int(1))) { (Value::Int(x), Value::Int(y)) => Value::Int(x - y), (Value::Int(x), Value::Float(y)) => Value::Float(*x as f64 - *y), (Value::Float(x), Value::Int(y)) => Value::Float(*x - *y as f64), (Value::Float(x), Value::Float(y)) => Value::Float(x - y), _ => Value::Null }));
8386 }
8387 let mut response: Value = self.call_dynamic_checked(method.clone(), vec![(symbol).clone(), (Value::Null).clone(), (maxEntriesPerRequestOption).clone(), (paramsMaxEntriesPerRequest).clone()]).await;
8388 let mut responseLength: Value = get_array_length(&response);
8389 if is_true(&self.verbose) {
8390 let mut backwardMessage: Value = Value::Str(format!("{}{}", Value::Str(format!("{}{}", Value::Str(format!("{}{}", Value::Str(format!("{}{}", Value::Str(format!("{}{}", Value::Str("Dynamic pagination call ".into()), self.number_to_string(calls.clone())).into()), Value::Str(" method ".into())).into()), method).into()), Value::Str(" response length ".into())).into()), self.number_to_string(responseLength.clone())).into());
8391 if (paginationTimestamp != Value::Null) {
8392 backwardMessage = Value::Str(format!("{}{}", backwardMessage, Value::Str(format!("{}{}", Value::Str(" timestamp ".into()), self.number_to_string(paginationTimestamp.clone())).into())).into());
8393 }
8394 self.log(backwardMessage);
8395 }
8396 if (responseLength.as_f64() == Some(0.0)) {
8397 break;
8398 }
8399 errors = Value::Int(0);
8400 result = self.array_concat(result.clone(), response.clone());
8401 let mut firstElement: Value = self.safe_value(response.clone(), Value::Int(0), &[]);
8402 paginationTimestamp = self.safe_integer2(firstElement, Value::Str("timestamp".into()), Value::Int(0), &[]);
8403 if (paginationTimestamp == Value::Null) {
8404 break;
8405 }
8406 if (since != Value::Null) && (paginationTimestamp.as_f64().unwrap_or(f64::NAN) <= since.as_f64().unwrap_or(f64::NAN)) {
8407 break;
8408 }
8409 } else {
8410 let mut response: Value = self.call_dynamic_checked(method.clone(), vec![(symbol).clone(), (paginationTimestamp).clone(), (maxEntriesPerRequestOption).clone(), (paramsMaxEntriesPerRequest).clone()]).await;
8412 let mut responseLength: Value = get_array_length(&response);
8413 if is_true(&self.verbose) {
8414 let mut forwardMessage: Value = Value::Str(format!("{}{}", Value::Str(format!("{}{}", Value::Str(format!("{}{}", Value::Str(format!("{}{}", Value::Str(format!("{}{}", Value::Str("Dynamic pagination call ".into()), self.number_to_string(calls.clone())).into()), Value::Str(" method ".into())).into()), method).into()), Value::Str(" response length ".into())).into()), self.number_to_string(responseLength.clone())).into());
8415 if (paginationTimestamp != Value::Null) {
8416 forwardMessage = Value::Str(format!("{}{}", forwardMessage, Value::Str(format!("{}{}", Value::Str(" timestamp ".into()), self.number_to_string(paginationTimestamp.clone())).into())).into());
8417 }
8418 self.log(forwardMessage);
8419 }
8420 if (responseLength.as_f64() == Some(0.0)) {
8421 break;
8422 }
8423 errors = Value::Int(0);
8424 result = self.array_concat(result.clone(), response.clone());
8425 let mut last: Value = self.safe_value(response, (match (&(responseLength), &(Value::Int(1))) { (Value::Int(x), Value::Int(y)) => Value::Int(x - y), (Value::Int(x), Value::Float(y)) => Value::Float(*x as f64 - *y), (Value::Float(x), Value::Int(y)) => Value::Float(*x - *y as f64), (Value::Float(x), Value::Float(y)) => Value::Float(x - y), _ => Value::Null }), &[]);
8426 let mut lastTimestamp: Value = self.safe_integer_k(last, "timestamp", &[Value::Int(0)]);
8427 if (lastTimestamp == Value::Null) {
8428 break;
8429 }
8430 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 });
8431 paginationTimestamp = nextPaginationTimestamp.clone();
8432 if (until != Value::Null) && (nextPaginationTimestamp.as_f64().unwrap_or(f64::NAN) >= until.as_f64().unwrap_or(f64::NAN)) {
8433 break;
8434 }
8435 }
8436 }
8437 }
8438 let mut uniqueResults: Value = result.clone();
8439 if is_true(&removeRepeatedOption) {
8440 uniqueResults = self.remove_repeated_elements_from_array(result, &[]);
8441 }
8442 let mut key: Value = (if (method.as_str() == Some("fetchOHLCV")) { Value::Int(0) } else { Value::Str("timestamp".into()) });
8443 let mut sortedRes: Value = self.sort_by(uniqueResults, key.clone(), &[]);
8444 return self.filter_by_since_limit(sortedRes, &[since, limit, key]);
8445
8446 Value::Null
8447} }
8448
8449 fn safe_deterministic_call(&mut self, mut method: Value, optional_args: &[Value]) -> impl ::std::future::Future<Output = Value> + Send { async move {
8450 let mut symbol = get_arg(optional_args, 0, Value::Null);
8451 let mut since = get_arg(optional_args, 1, Value::Null);
8452 let mut limit = get_arg(optional_args, 2, Value::Null);
8453 let mut timeframe = get_arg(optional_args, 3, Value::Null);
8454 let mut params = get_arg(optional_args, 4, Value::Map({
8455 let mut m = indexmap::IndexMap::new();
8456 m
8457}));
8458 let mut maxRetries: Value = Value::Int(3);
8459 let mut maxRetriesOptionparamsMaxRetriesVariable = self.handle_option_integer_and_params(params, method.clone(), Value::Str("maxRetries".into()), &[maxRetries]);
8460 let mut maxRetriesOption: Value = maxRetriesOptionparamsMaxRetriesVariable.as_array().and_then(|__arr| __arr.get(0)).cloned().unwrap_or(Value::Null);
8461 let mut paramsMaxRetries: Value = maxRetriesOptionparamsMaxRetriesVariable.as_array().and_then(|__arr| __arr.get(1)).cloned().unwrap_or(Value::Null);
8462 let mut errors: Value = Value::Int(0);
8463 while is_less_than_or_equal(&errors, &maxRetriesOption) {
8464 let _try_result = futures::FutureExt::catch_unwind(std::panic::AssertUnwindSafe(async {
8465 if ((timeframe != Value::Null) && (timeframe.as_str() != Some(""))) && (method.as_str() != Some("fetchFundingRateHistory")) {
8466 return self.call_dynamic_checked(method.clone(), vec![(symbol).clone(), (timeframe).clone(), (since).clone(), (limit).clone(), (paramsMaxRetries).clone()]).await;
8467 } else {
8468 return self.call_dynamic_checked(method.clone(), vec![(symbol).clone(), (since).clone(), (limit).clone(), (paramsMaxRetries).clone()]).await;
8469 }
8470 #[allow(unreachable_code)] { Value::Null }})).await;
8471match _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);
8472 if matches!(&e, Value::Str(__s) if __s.contains("[RateLimitExceeded]")) {
8473 panic!("{}", e);
8474 }
8475 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 });
8476 if errors.as_f64().unwrap_or(f64::NAN) > maxRetriesOption.as_f64().unwrap_or(f64::NAN) {
8477 panic!("{}", e);
8478 }
8479 } }
8480 }
8481 return Value::from(vec![]);
8482
8483 Value::Null
8484} }
8485
8486 fn fetch_paginated_call_deterministic(&mut self, mut method: Value, optional_args: &[Value]) -> impl ::std::future::Future<Output = Value> + Send { async move {
8487 let mut symbol = get_arg(optional_args, 0, Value::Null);
8488 let mut since = get_arg(optional_args, 1, Value::Null);
8489 let mut limit = get_arg(optional_args, 2, Value::Null);
8490 let mut timeframe = get_arg(optional_args, 3, Value::Null);
8491 let mut params = get_arg(optional_args, 4, Value::Map({
8492 let mut m = indexmap::IndexMap::new();
8493 m
8494}));
8495 let mut maxEntriesPerRequest = get_arg(optional_args, 5, Value::Null);
8496 let mut maxCalls: Value = Value::Int(10);
8497 let mut maxCallsPaginationCallsparamsPaginationCallsVariable = self.handle_option_integer_and_params(params, method.clone(), Value::Str("paginationCalls".into()), &[maxCalls]);
8498 let mut maxCallsPaginationCalls: Value = maxCallsPaginationCallsparamsPaginationCallsVariable.as_array().and_then(|__arr| __arr.get(0)).cloned().unwrap_or(Value::Null);
8499 let mut paramsPaginationCalls: Value = maxCallsPaginationCallsparamsPaginationCallsVariable.as_array().and_then(|__arr| __arr.get(1)).cloned().unwrap_or(Value::Null);
8500 let mut maxEntriesPerRequestOptionparamsMaxEntriesPerRequestVariable = self.handle_max_entries_per_request_and_params(method.clone(), &[maxEntriesPerRequest, paramsPaginationCalls]);
8501 let mut maxEntriesPerRequestOption: Value = maxEntriesPerRequestOptionparamsMaxEntriesPerRequestVariable.as_array().and_then(|__arr| __arr.get(0)).cloned().unwrap_or(Value::Null);
8502 let mut paramsMaxEntriesPerRequest: Value = maxEntriesPerRequestOptionparamsMaxEntriesPerRequestVariable.as_array().and_then(|__arr| __arr.get(1)).cloned().unwrap_or(Value::Null);
8503 let mut paramsOmitted: Value = self.omit(paramsMaxEntriesPerRequest, Value::Str("paginationDirection".into()), &[]);
8507 let mut current: Value = self.milliseconds();
8508 let mut tasks: Value = Value::from(vec![]);
8509 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 });
8510 let mut maxEntriesPerRequestValue: Value = self.require_value(maxEntriesPerRequestOption, &[Value::Str("fetchPaginatedCallDeterministic() maxEntriesPerRequest is required".into())]);
8511 let mut step: Value = multiply(&time, &maxEntriesPerRequestValue);
8512 let mut until: Value = self.safe_integer2(paramsOmitted.clone(), Value::Str("until".into()), Value::Str("till".into()), &[]); let mut currentSince: Value = (match (&((match (&(current), &((multiply(&maxCallsPaginationCalls, &step)))) { (Value::Int(x), Value::Int(y)) => Value::Int(x - y), (Value::Int(x), Value::Float(y)) => Value::Float(*x as f64 - *y), (Value::Float(x), Value::Int(y)) => Value::Float(*x - *y as f64), (Value::Float(x), Value::Float(y)) => Value::Float(x - y), _ => Value::Null })), &(Value::Int(1))) { (Value::Int(x), Value::Int(y)) => Value::Int(x - y), (Value::Int(x), Value::Float(y)) => Value::Float(*x as f64 - *y), (Value::Float(x), Value::Int(y)) => Value::Float(*x - *y as f64), (Value::Float(x), Value::Float(y)) => Value::Float(x - y), _ => Value::Null });
8514 if (since != Value::Null) {
8515 if (until != Value::Null) {
8516 currentSince = since.clone();
8521 } else {
8522 currentSince = crate::runtime::Math::max(¤tSince, &since);
8523 }
8524 } else {
8525 currentSince = crate::runtime::Math::max(¤tSince, &Value::Int(1241440531000)); }
8527 if (until != Value::Null) {
8528 if (since == Value::Null) {
8529 panic!("{}", crate::exchange_errors::arguments_required(format!("{}{}", self.id.clone(), Value::Str(" fetchPaginatedCallDeterministic() requires a since argument when until is set".into()))));
8530 }
8531 let mut requiredCalls: Value = math_ceil(&(match ((((match (&(until), &(since)) { (Value::Int(x), Value::Int(y)) => Value::Int(x - y), (Value::Int(x), Value::Float(y)) => Value::Float(*x as f64 - *y), (Value::Float(x), Value::Int(y)) => Value::Float(*x - *y as f64), (Value::Float(x), Value::Float(y)) => Value::Float(x - y), _ => Value::Null }))).as_f64(), (step).as_f64()) { (Some(x), Some(y)) if y != 0.0 => Value::Float(x / y), _ => Value::Null }));
8532 if requiredCalls.as_f64().unwrap_or(f64::NAN) > maxCallsPaginationCalls.as_f64().unwrap_or(f64::NAN) {
8533 panic!("{}", crate::exchange_errors::bad_request(format!("{}{}", Value::Str(format!("{}{}", Value::Str(format!("{}{}", Value::Str(format!("{}{}", self.id.clone(), Value::Str(" the number of required calls is greater than the max number of calls allowed, either increase the paginationCalls or decrease the since-until gap. Current paginationCalls limit is ".into())).into()), to_string_val(&maxCallsPaginationCalls)).into()), Value::Str(" required calls is ".into())).into()), to_string_val(&requiredCalls))));
8534 }
8535 }
8536 {
8537 let mut i: Value = Value::Int(0);
8538 let mut __for_first_159: bool = true;
8539 while { if !__for_first_159 { i = (match (&(i), &(Value::Int(1))) { (Value::Int(x), Value::Int(y)) => Value::Int(x + y), (Value::Int(x), Value::Float(y)) => Value::Float(*x as f64 + *y), (Value::Float(x), Value::Int(y)) => Value::Float(*x + *y as f64), (Value::Float(x), Value::Float(y)) => Value::Float(x + y), _ => Value::Null }); } __for_first_159 = false; i.as_f64().unwrap_or(f64::NAN) < maxCallsPaginationCalls.as_f64().unwrap_or(f64::NAN) } {
8540 if (until != Value::Null) && (currentSince.as_f64().unwrap_or(f64::NAN) >= until.as_f64().unwrap_or(f64::NAN)) {
8541 break;
8542 }
8543 if currentSince.as_f64().unwrap_or(f64::NAN) >= current.as_f64().unwrap_or(f64::NAN) {
8544 break;
8545 }
8546 append_to_array(&mut tasks, self.safe_deterministic_call(method.clone(), &[symbol.clone(), currentSince.clone(), maxEntriesPerRequestValue.clone(), timeframe.clone(), paramsOmitted.clone()]).await);
8547 currentSince = (match (&((match (&(currentSince), &(step)) { (Value::Int(x), Value::Int(y)) => Value::Int(x + y), (Value::Int(x), Value::Float(y)) => Value::Float(*x as f64 + *y), (Value::Float(x), Value::Int(y)) => Value::Float(*x + *y as f64), (Value::Float(x), Value::Float(y)) => Value::Float(x + y), _ => Value::Null })), &(Value::Int(1))) { (Value::Int(x), Value::Int(y)) => Value::Int(x - y), (Value::Int(x), Value::Float(y)) => Value::Float(*x as f64 - *y), (Value::Float(x), Value::Int(y)) => Value::Float(*x - *y as f64), (Value::Float(x), Value::Float(y)) => Value::Float(x - y), _ => Value::Null });
8548 }
8549 }
8550 let mut results: Value = promise_all(&tasks).await;
8551 let mut result: Value = Value::from(vec![]);
8552 {
8553 let mut i: Value = Value::Int(0);
8554 let mut __for_first_160: bool = true;
8555 while { if !__for_first_160 { i = (match (&(i), &(Value::Int(1))) { (Value::Int(x), Value::Int(y)) => Value::Int(x + y), (Value::Int(x), Value::Float(y)) => Value::Float(*x as f64 + *y), (Value::Float(x), Value::Int(y)) => Value::Float(*x + *y as f64), (Value::Float(x), Value::Float(y)) => Value::Float(x + y), _ => Value::Null }); } __for_first_160 = false; i.as_f64().unwrap_or(f64::NAN) < ((results.len() as i64) as f64) } {
8556 result = self.array_concat(result.clone(), results.as_array().and_then(|__arr| match &i { Value::Int(__n) => __arr.get(*__n as usize), Value::Str(__s) => __s.parse::<usize>().ok().and_then(|__n| __arr.get(__n)), _ => None }).cloned().unwrap_or(Value::Null));
8557 }
8558 }
8559 let mut uniqueResults: Value = self.remove_repeated_elements_from_array(result, &[]);
8560 let mut key: Value = (if (method.as_str() == Some("fetchOHLCV")) { Value::Int(0) } else { Value::Str("timestamp".into()) });
8561 return self.filter_by_since_limit(uniqueResults, &[since, limit, key]);
8562
8563 Value::Null
8564} }
8565
8566fn fetch_paginated_call_cursor(&mut self, mut method: Value, optional_args: &[Value]) -> impl ::std::future::Future<Output = Value> + Send { async move {
8569 let mut symbol = get_arg(optional_args, 0, Value::Null);
8570 let mut since = get_arg(optional_args, 1, Value::Null);
8571 let mut limit = get_arg(optional_args, 2, Value::Null);
8572 let mut params = get_arg(optional_args, 3, Value::Map({
8573 let mut m = indexmap::IndexMap::new();
8574 m
8575}));
8576 let mut cursorReceived = get_arg(optional_args, 4, Value::Null);
8577 let mut cursorSent = get_arg(optional_args, 5, Value::Null);
8578 let mut cursorIncrement = get_arg(optional_args, 6, Value::Null);
8579 let mut maxEntriesPerRequest = get_arg(optional_args, 7, Value::Null);
8580 let mut maxCalls: Value = Value::Int(10);
8581 let mut maxCallsPaginationCallsparamsPaginationCallsVariable = self.handle_option_integer_and_params(params, method.clone(), Value::Str("paginationCalls".into()), &[maxCalls]);
8582 let mut maxCallsPaginationCalls: Value = maxCallsPaginationCallsparamsPaginationCallsVariable.as_array().and_then(|__arr| __arr.get(0)).cloned().unwrap_or(Value::Null);
8583 let mut paramsPaginationCalls: Value = maxCallsPaginationCallsparamsPaginationCallsVariable.as_array().and_then(|__arr| __arr.get(1)).cloned().unwrap_or(Value::Null);
8584 let mut maxRetries: Value = Value::Int(3);
8585 let mut maxRetriesOptionparamsMaxRetriesVariable = self.handle_option_integer_and_params(paramsPaginationCalls, method.clone(), Value::Str("maxRetries".into()), &[maxRetries]);
8586 let mut maxRetriesOption: Value = maxRetriesOptionparamsMaxRetriesVariable.as_array().and_then(|__arr| __arr.get(0)).cloned().unwrap_or(Value::Null);
8587 let mut paramsMaxRetries: Value = maxRetriesOptionparamsMaxRetriesVariable.as_array().and_then(|__arr| __arr.get(1)).cloned().unwrap_or(Value::Null);
8588 let mut maxEntriesPerRequestOptionparamsMaxEntriesPerRequestVariable = self.handle_max_entries_per_request_and_params(method.clone(), &[maxEntriesPerRequest, paramsMaxRetries]);
8589 let mut maxEntriesPerRequestOption: Value = maxEntriesPerRequestOptionparamsMaxEntriesPerRequestVariable.as_array().and_then(|__arr| __arr.get(0)).cloned().unwrap_or(Value::Null);
8590 let mut paramsMaxEntriesPerRequest: Value = maxEntriesPerRequestOptionparamsMaxEntriesPerRequestVariable.as_array().and_then(|__arr| __arr.get(1)).cloned().unwrap_or(Value::Null);
8591 let mut cursorValue: Value = Value::Null;
8592 let mut i: Value = Value::Int(0);
8593 let mut errors: Value = Value::Int(0);
8594 let mut result: Value = Value::from(vec![]);
8595 let mut timeframe: Value = self.safe_string_k(paramsMaxEntriesPerRequest.clone(), "timeframe", &[]);
8596 let mut paramsOmitted: Value = self.omit(paramsMaxEntriesPerRequest, Value::Str("timeframe".into()), &[]); while i.as_f64().unwrap_or(f64::NAN) < maxCallsPaginationCalls.as_f64().unwrap_or(f64::NAN) {
8598 {
8599 if (cursorValue != Value::Null) {
8600 if (cursorIncrement != Value::Null) {
8601 cursorValue = (match (&(self.parse_to_int(cursorValue.clone())), &(cursorIncrement)) { (Value::Int(x), Value::Int(y)) => Value::Int(x + y), (Value::Int(x), Value::Float(y)) => Value::Float(*x as f64 + *y), (Value::Float(x), Value::Int(y)) => Value::Float(*x + *y as f64), (Value::Float(x), Value::Float(y)) => Value::Float(x + y), _ => Value::Null });
8602 }
8603 add_element_to_object(&mut paramsOmitted, &cursorSent, cursorValue.clone());
8604 }
8605 let mut response: Value = Value::Null;
8606 if (method.as_str() == Some("fetchAccounts")) {
8607 response = self.call_dynamic_checked(method.clone(), vec![(paramsOmitted).clone()]).await;
8608 } else if (method.as_str() == Some("getLeverageTiersPaginated")) || (method.as_str() == Some("fetchPositions")) {
8609 response = self.call_dynamic_checked(method.clone(), vec![(symbol).clone(), (paramsOmitted).clone()]).await;
8610 } else if (method.as_str() == Some("fetchOpenInterestHistory")) {
8611 if !matches!(&symbol, Value::Str(_)) {
8612 panic!("{}", crate::exchange_errors::arguments_required(format!("{}{}", self.id.clone(), Value::Str(" fetchPaginatedCallCursor() requires a symbol argument".into()))));
8613 }
8614 if (timeframe == Value::Null) {
8615 panic!("{}", crate::exchange_errors::arguments_required(format!("{}{}", self.id.clone(), Value::Str(" fetchPaginatedCallCursor() requires a timeframe argument".into()))));
8616 }
8617 response = self.call_dynamic_checked(method.clone(), vec![(symbol).clone(), (timeframe).clone(), (since).clone(), (maxEntriesPerRequestOption).clone(), (paramsOmitted).clone()]).await;
8618 } else {
8619 response = self.call_dynamic_checked(method.clone(), vec![(symbol).clone(), (since).clone(), (maxEntriesPerRequestOption).clone(), (paramsOmitted).clone()]).await;
8620 }
8621 errors = Value::Int(0);
8622 if (response == Value::Null) {
8623 panic!("{}", crate::exchange_errors::null_response(format!("{}{}", self.id.clone(), Value::Str(" fetchPaginatedCallCursor() returned empty response".into()))));
8624 }
8625 let mut responseLength: Value = Value::Int(response.len() as i64);
8626 if is_true(&self.verbose) {
8627 let mut cursorString: Value = (if (cursorValue == Value::Null) { Value::Str("".into()) } else { cursorValue.clone() });
8628 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 }));
8629 let mut cursorMessage: Value = add(&Value::Str(format!("{}{}", Value::Str(format!("{}{}", Value::Str(format!("{}{}", Value::Str(format!("{}{}", Value::Str(format!("{}{}", Value::Str(format!("{}{}", Value::Str("Cursor pagination call ".into()), to_string_val(&iteration)).into()), Value::Str(" method ".into())).into()), method).into()), Value::Str(" response length ".into())).into()), to_string_val(&responseLength)).into()), Value::Str(" cursor ".into())).into()), &cursorString);
8630 self.log(cursorMessage);
8631 }
8632 if (responseLength.as_f64() == Some(0.0)) {
8633 break;
8634 }
8635 if (response != Value::Null) {
8636 result = self.array_concat(result.clone(), response.clone());
8637 }
8638 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 }), &[]);
8639 cursorValue = Value::Null; {
8642 let mut j: Value = Value::Int(0);
8643 let mut __for_first_161: bool = true;
8644 while { if !__for_first_161 { j = (match (&(j), &(Value::Int(1))) { (Value::Int(x), Value::Int(y)) => Value::Int(x + y), (Value::Int(x), Value::Float(y)) => Value::Float(*x as f64 + *y), (Value::Float(x), Value::Int(y)) => Value::Float(*x + *y as f64), (Value::Float(x), Value::Float(y)) => Value::Float(x + y), _ => Value::Null }); } __for_first_161 = false; j.as_f64().unwrap_or(f64::NAN) < responseLength.as_f64().unwrap_or(f64::NAN) } {
8645 let mut index: Value = (match (&((match (&(responseLength), &(j)) { (Value::Int(x), Value::Int(y)) => Value::Int(x - y), (Value::Int(x), Value::Float(y)) => Value::Float(*x as f64 - *y), (Value::Float(x), Value::Int(y)) => Value::Float(*x - *y as f64), (Value::Float(x), Value::Float(y)) => Value::Float(x - y), _ => Value::Null })), &(Value::Int(1))) { (Value::Int(x), Value::Int(y)) => Value::Int(x - y), (Value::Int(x), Value::Float(y)) => Value::Float(*x as f64 - *y), (Value::Float(x), Value::Int(y)) => Value::Float(*x - *y as f64), (Value::Float(x), Value::Float(y)) => Value::Float(x - y), _ => Value::Null });
8646 let mut entry: Value = self.safe_dict(response.clone(), index, &[]);
8647 let mut info: Value = self.safe_dict_k(entry, "info", &[]);
8648 let mut cursor: Value = (if (cursorReceived == Value::Null) { Value::Null } else { self.safe_value(info, cursorReceived.clone(), &[]) });
8649 if (cursor != Value::Null) {
8650 cursorValue = cursor;
8651 break;
8652 }
8653 }
8654 }
8655 if (cursorValue == Value::Null) {
8656 break;
8657 }
8658 let mut lastTimestamp: Value = self.safe_integer_k(last, "timestamp", &[]);
8659 if (since == Value::Null) {
8660 panic!("{}", crate::exchange_errors::arguments_required(format!("{}{}", self.id.clone(), Value::Str(" fetchPaginatedCallCursor() requires a since argument".into()))));
8661 }
8662 if (lastTimestamp != Value::Null) && lastTimestamp.as_f64().unwrap_or(f64::NAN) < since.as_f64().unwrap_or(f64::NAN) {
8663 break;
8664 }
8665 }
8666 i = (match (&(i), &(Value::Int(1))) { (Value::Int(x), Value::Int(y)) => Value::Int(x + y), (Value::Int(x), Value::Float(y)) => Value::Float(*x as f64 + *y), (Value::Float(x), Value::Int(y)) => Value::Float(*x + *y as f64), (Value::Float(x), Value::Float(y)) => Value::Float(x + y), _ => Value::Null });
8667 }
8668 let mut sorted: Value = self.sort_cursor_paginated_result(result);
8669 let mut key: Value = (if (method.as_str() == Some("fetchOHLCV")) { Value::Int(0) } else { Value::Str("timestamp".into()) });
8670 return self.filter_by_since_limit(sorted, &[since, limit, key]);
8671
8672 Value::Null
8673} }
8674
8675 fn fetch_paginated_call_incremental(&mut self, mut method: Value, optional_args: &[Value]) -> impl ::std::future::Future<Output = Value> + Send { async move {
8676 let mut symbol = get_arg(optional_args, 0, Value::Null);
8677 let mut since = get_arg(optional_args, 1, Value::Null);
8678 let mut limit = get_arg(optional_args, 2, Value::Null);
8679 let mut params = get_arg(optional_args, 3, Value::Map({
8680 let mut m = indexmap::IndexMap::new();
8681 m
8682}));
8683 let mut pageKey = get_arg(optional_args, 4, Value::Null);
8684 let mut maxEntriesPerRequest = get_arg(optional_args, 5, Value::Null);
8685 let mut maxCalls: Value = Value::Int(10);
8686 let mut maxCallsPaginationCallsparamsPaginationCallsVariable = self.handle_option_integer_and_params(params, method.clone(), Value::Str("paginationCalls".into()), &[maxCalls]);
8687 let mut maxCallsPaginationCalls: Value = maxCallsPaginationCallsparamsPaginationCallsVariable.as_array().and_then(|__arr| __arr.get(0)).cloned().unwrap_or(Value::Null);
8688 let mut paramsPaginationCalls: Value = maxCallsPaginationCallsparamsPaginationCallsVariable.as_array().and_then(|__arr| __arr.get(1)).cloned().unwrap_or(Value::Null);
8689 let mut maxRetries: Value = Value::Int(3);
8690 let mut maxRetriesOptionparamsMaxRetriesVariable = self.handle_option_integer_and_params(paramsPaginationCalls, method.clone(), Value::Str("maxRetries".into()), &[maxRetries]);
8691 let mut maxRetriesOption: Value = maxRetriesOptionparamsMaxRetriesVariable.as_array().and_then(|__arr| __arr.get(0)).cloned().unwrap_or(Value::Null);
8692 let mut paramsMaxRetries: Value = maxRetriesOptionparamsMaxRetriesVariable.as_array().and_then(|__arr| __arr.get(1)).cloned().unwrap_or(Value::Null);
8693 let mut maxEntriesPerRequestOptionparamsMaxEntriesPerRequestVariable = self.handle_max_entries_per_request_and_params(method.clone(), &[maxEntriesPerRequest, paramsMaxRetries]);
8694 let mut maxEntriesPerRequestOption: Value = maxEntriesPerRequestOptionparamsMaxEntriesPerRequestVariable.as_array().and_then(|__arr| __arr.get(0)).cloned().unwrap_or(Value::Null);
8695 let mut paramsMaxEntriesPerRequest: Value = maxEntriesPerRequestOptionparamsMaxEntriesPerRequestVariable.as_array().and_then(|__arr| __arr.get(1)).cloned().unwrap_or(Value::Null);
8696 let mut i: Value = Value::Int(0);
8697 let mut errors: Value = Value::Int(0);
8698 let mut result: Value = Value::from(vec![]);
8699 while i.as_f64().unwrap_or(f64::NAN) < maxCallsPaginationCalls.as_f64().unwrap_or(f64::NAN) {
8700 {
8701 add_element_to_object(&mut paramsMaxEntriesPerRequest, &pageKey, (match (&(i), &(Value::Int(1))) { (Value::Int(x), Value::Int(y)) => Value::Int(x + y), (Value::Int(x), Value::Float(y)) => Value::Float(*x as f64 + *y), (Value::Float(x), Value::Int(y)) => Value::Float(*x + *y as f64), (Value::Float(x), Value::Float(y)) => Value::Float(x + y), _ => Value::Null }));
8702 let mut response: Value = self.call_dynamic_checked(method.clone(), vec![(symbol).clone(), (since).clone(), (maxEntriesPerRequestOption).clone(), (paramsMaxEntriesPerRequest).clone()]).await;
8703 errors = Value::Int(0);
8704 let mut responseLength: Value = get_array_length(&response);
8705 if is_true(&self.verbose) {
8706 let mut iteration: Value = to_string_val(&((match (&(i), &(Value::Int(1))) { (Value::Int(x), Value::Int(y)) => Value::Int(x + y), (Value::Int(x), Value::Float(y)) => Value::Float(*x as f64 + *y), (Value::Float(x), Value::Int(y)) => Value::Float(*x + *y as f64), (Value::Float(x), Value::Float(y)) => Value::Float(x + y), _ => Value::Null })));
8707 let mut incrementalMessage: Value = Value::Str(format!("{}{}", Value::Str(format!("{}{}", Value::Str(format!("{}{}", Value::Str(format!("{}{}", Value::Str(format!("{}{}", Value::Str("Incremental pagination call ".into()), iteration).into()), Value::Str(" method ".into())).into()), method).into()), Value::Str(" response length ".into())).into()), to_string_val(&responseLength)).into());
8708 self.log(incrementalMessage);
8709 }
8710 if (responseLength.as_f64() == Some(0.0)) {
8711 break;
8712 }
8713 result = self.array_concat(result.clone(), response);
8714 }
8715 i = (match (&(i), &(Value::Int(1))) { (Value::Int(x), Value::Int(y)) => Value::Int(x + y), (Value::Int(x), Value::Float(y)) => Value::Float(*x as f64 + *y), (Value::Float(x), Value::Int(y)) => Value::Float(*x + *y as f64), (Value::Float(x), Value::Float(y)) => Value::Float(x + y), _ => Value::Null });
8716 }
8717 let mut sorted: Value = self.sort_cursor_paginated_result(result);
8718 let mut key: Value = (if (method.as_str() == Some("fetchOHLCV")) { Value::Int(0) } else { Value::Str("timestamp".into()) });
8719 return self.filter_by_since_limit(sorted, &[since, limit, key]);
8720
8721 Value::Null
8722} }
8723
8724 fn sort_cursor_paginated_result(&self, mut result: Value) -> Value {
8725 let mut first: Value = self.safe_value(result.clone(), Value::Int(0), &[]);
8726 if (first != Value::Null) {
8727 if (in_op(&first, &Value::Str("timestamp".into()))) {
8728 return self.sort_by(result.clone(), Value::Str("timestamp".into()), &[Value::Bool(true)]);
8729 }
8730 if (in_op(&first, &Value::Str("id".into()))) {
8731 return self.sort_by(result.clone(), Value::Str("id".into()), &[Value::Bool(true)]);
8732 }
8733 }
8734 return result;
8735
8736 Value::Null
8737}
8738
8739 fn remove_repeated_elements_from_array(&self, mut input: Value, optional_args: &[Value]) -> Value {
8740 let mut fallbackToTimestamp = get_arg(optional_args, 0, Value::Bool(true));
8741 let mut uniqueDic: Value = Value::Map({
8742 let mut m = indexmap::IndexMap::new();
8743 m
8744 });
8745 let mut uniqueResult: Value = Value::from(vec![]);
8746 {
8747 let mut i: Value = Value::Int(0);
8748 let mut __for_first_162: bool = true;
8749 while { if !__for_first_162 { i = (match (&(i), &(Value::Int(1))) { (Value::Int(x), Value::Int(y)) => Value::Int(x + y), (Value::Int(x), Value::Float(y)) => Value::Float(*x as f64 + *y), (Value::Float(x), Value::Int(y)) => Value::Float(*x + *y as f64), (Value::Float(x), Value::Float(y)) => Value::Float(x + y), _ => Value::Null }); } __for_first_162 = false; i.as_f64().unwrap_or(f64::NAN) < get_array_length(&input).as_f64().unwrap_or(f64::NAN) } {
8750 let mut entry: Value = get_value(&input, &i);
8751 let mut entry: Value = get_value(&input, &i);
8752 let mut uniqValue: Value = (if is_true(&fallbackToTimestamp) { self.safe_string_n(entry.clone(), Value::from(vec![Value::Str("id".into()), Value::Str("timestamp".into()), Value::Int(0)]), &[]) } else { self.safe_string_k(entry.clone(), "id", &[]) });
8753 if (uniqValue != Value::Null) && !(in_op(&uniqueDic, &uniqValue)) {
8754 if let Value::Dict(__d) = &mut uniqueDic { std::sync::Arc::make_mut(__d).insert(crate::runtime::stringify_param(&uniqValue), Value::Int(1)); }
8755 append_to_array(&mut uniqueResult, entry);
8756 }
8757 }
8758 }
8759 let mut valuesLength: f64 = ((uniqueResult.len() as i64) as f64);
8760 if valuesLength > ((0i64) as f64) {
8761 return uniqueResult;
8762 }
8763 return input;
8764
8765 Value::Null
8766}
8767
8768 fn remove_repeated_trades_from_array(&self, mut input: Value) -> Value {
8769 let mut uniqueResult: Value = Value::Map({
8770 let mut m = indexmap::IndexMap::new();
8771 m
8772 });
8773 {
8774 let mut i: Value = Value::Int(0);
8775 let mut __for_first_163: bool = true;
8776 while { if !__for_first_163 { i = (match (&(i), &(Value::Int(1))) { (Value::Int(x), Value::Int(y)) => Value::Int(x + y), (Value::Int(x), Value::Float(y)) => Value::Float(*x as f64 + *y), (Value::Float(x), Value::Int(y)) => Value::Float(*x + *y as f64), (Value::Float(x), Value::Float(y)) => Value::Float(x + y), _ => Value::Null }); } __for_first_163 = false; i.as_f64().unwrap_or(f64::NAN) < get_array_length(&input).as_f64().unwrap_or(f64::NAN) } {
8777 let mut entry: Value = get_value(&input, &i);
8778 let mut entry: Value = get_value(&input, &i);
8779 let mut id: Value = self.safe_string_k(entry.clone(), "id", &[]);
8780 if (id == Value::Null) {
8781 let mut price: Value = self.safe_string_k(entry.clone(), "price", &[]);
8782 let mut amount: Value = self.safe_string_k(entry.clone(), "amount", &[]);
8783 let mut timestamp: Value = self.safe_string_k(entry.clone(), "timestamp", &[]);
8784 let mut side: Value = self.safe_string_k(entry.clone(), "side", &[]);
8785 if (timestamp == Value::Null) {
8787 panic!("{}", crate::exchange_errors::exchange_error(format!("{}{}", self.id.clone(), Value::Str(" removeRepeatedTradesFromArray() missing timestamp".into()))));
8788 }
8789 id = Value::Str(format!("{}{}", Value::Str(format!("{}{}", Value::Str("t_".into()), to_string_val(×tamp)).into()), Value::Str("_".into())).into());
8791 if (side != Value::Null) {
8792 id = Value::Str(format!("{}{}", id, side).into());
8793 }
8794 id = Value::Str(format!("{}{}", id, Value::Str("_".into())).into());
8795 if (price != Value::Null) {
8796 id = Value::Str(format!("{}{}", id, price).into());
8797 }
8798 id = Value::Str(format!("{}{}", id, Value::Str("_".into())).into());
8799 if (amount != Value::Null) {
8800 id = Value::Str(format!("{}{}", id, amount).into());
8801 }
8802 }
8803 if (id != Value::Null) && !(in_op(&uniqueResult, &id)) {
8804 if let Value::Dict(__d) = &mut uniqueResult { std::sync::Arc::make_mut(__d).insert(crate::runtime::stringify_param(&id), entry); }
8805 }
8806 }
8807 }
8808 let mut values: Value = object_values(&uniqueResult);
8809 return values;
8810
8811 Value::Null
8812}
8813
8814 fn remove_keys_from_dict(&self, mut dict: Value, mut removeKeys: Value) -> Value {
8815 let mut keys: Value = object_keys(&dict);
8816 let mut newDict: Value = Value::Map({
8817 let mut m = indexmap::IndexMap::new();
8818 m
8819 });
8820 {
8821 let mut i: Value = Value::Int(0);
8822 let mut __for_first_164: bool = true;
8823 while { if !__for_first_164 { i = (match (&(i), &(Value::Int(1))) { (Value::Int(x), Value::Int(y)) => Value::Int(x + y), (Value::Int(x), Value::Float(y)) => Value::Float(*x as f64 + *y), (Value::Float(x), Value::Int(y)) => Value::Float(*x + *y as f64), (Value::Float(x), Value::Float(y)) => Value::Float(x + y), _ => Value::Null }); } __for_first_164 = false; i.as_f64().unwrap_or(f64::NAN) < ((keys.len() as i64) as f64) } {
8824 let mut key: Value = keys.as_array().and_then(|__arr| match &i { Value::Int(__n) => __arr.get(*__n as usize), Value::Str(__s) => __s.parse::<usize>().ok().and_then(|__n| __arr.get(__n)), _ => None }).cloned().unwrap_or(Value::Null);
8825 if !(self.in_array(key.clone(), removeKeys.clone()).as_bool() == Some(true)) {
8826 if let Value::Dict(__d) = &mut newDict { std::sync::Arc::make_mut(__d).insert(crate::runtime::stringify_param(&key), dict.as_map().and_then(|__m| key.as_str().and_then(|__k| __m.get(__k))).cloned().unwrap_or(Value::Null)); }
8827 }
8828 }
8829 }
8830 return newDict;
8831
8832 Value::Null
8833}
8834
8835 fn handle_until_option(&self, mut key: Value, mut request: Value, mut params: Value, optional_args: &[Value]) -> Value {
8836 let mut multiplier = get_arg(optional_args, 0, Value::Int(1));
8837 let mut until: Value = self.safe_integer2(params.clone(), Value::Str("until".into()), Value::Str("till".into()), &[]);
8838 if (until != Value::Null) {
8839 if let Value::Dict(__d) = &mut request { std::sync::Arc::make_mut(__d).insert(crate::runtime::stringify_param(&key), self.parse_to_int((match (&(until), &(multiplier)) { (Value::Int(x), Value::Int(y)) => Value::Int(x * y), (Value::Int(x), Value::Float(y)) => Value::Float(*x as f64 * *y), (Value::Float(x), Value::Int(y)) => Value::Float(*x * *y as f64), (Value::Float(x), Value::Float(y)) => Value::Float(x * y), _ => Value::Null }))); }
8840 }
8841 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 });
8842 return Value::from(vec![request, paramsOmitted]);
8843
8844 Value::Null
8845}
8846
8847 fn safe_open_interest(&self, mut interest: Value, optional_args: &[Value]) -> Value {
8848 let mut market = get_arg(optional_args, 0, Value::Null);
8849 let mut symbol: Value = self.safe_string_k(interest.clone(), "symbol", &[]);
8850 if (symbol == Value::Null) {
8851 symbol = self.safe_string_k(market, "symbol", &[]);
8852 }
8853 return self.extend(interest.clone(), &[Value::Map({
8854 let mut m = indexmap::IndexMap::new();
8855 m.insert("symbol".to_string(), symbol);
8856 m.insert("baseVolume".to_string(), self.safe_number_k(interest.clone(), "baseVolume", &[]));
8857 m.insert("quoteVolume".to_string(), self.safe_number_k(interest.clone(), "quoteVolume", &[]));
8858 m.insert("openInterestAmount".to_string(), self.safe_number_k(interest.clone(), "openInterestAmount", &[]));
8859 m.insert("openInterestValue".to_string(), self.safe_number_k(interest.clone(), "openInterestValue", &[]));
8860 m.insert("timestamp".to_string(), self.safe_integer_k(interest.clone(), "timestamp", &[]));
8861 m.insert("datetime".to_string(), self.safe_string_k(interest.clone(), "datetime", &[]));
8862 m.insert("info".to_string(), self.safe_value_k(interest, "info", &[]));
8863 m
8864})]);
8865
8866 Value::Null
8867}
8868
8869 fn parse_liquidation(&self, mut liquidation: Value, optional_args: &[Value]) -> Value {
8870 { 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; } }
8872
8873 let mut market = get_arg(optional_args, 0, Value::Null);
8874 panic!("{}", crate::exchange_errors::not_supported(format!("{}{}", self.id.clone(), Value::Str(" parseLiquidation () is not supported yet".into()))));
8875
8876 Value::Null
8877}
8878
8879 fn parse_liquidations(&self, mut liquidations: Value, optional_args: &[Value]) -> Value {
8880 let mut market = get_arg(optional_args, 0, Value::Null);
8881 let mut since = get_arg(optional_args, 1, Value::Null);
8882 let mut limit = get_arg(optional_args, 2, Value::Null);
8883 let mut result: Value = Value::from(vec![]);
8894 {
8895 let mut i: Value = Value::Int(0);
8896 let mut __for_first_165: bool = true;
8897 while { if !__for_first_165 { i = (match (&(i), &(Value::Int(1))) { (Value::Int(x), Value::Int(y)) => Value::Int(x + y), (Value::Int(x), Value::Float(y)) => Value::Float(*x as f64 + *y), (Value::Float(x), Value::Int(y)) => Value::Float(*x + *y as f64), (Value::Float(x), Value::Float(y)) => Value::Float(x + y), _ => Value::Null }); } __for_first_165 = false; i.as_f64().unwrap_or(f64::NAN) < ((liquidations.len() as i64) as f64) } {
8898 let mut entry: Value = liquidations.as_array().and_then(|__arr| match &i { Value::Int(__n) => __arr.get(*__n as usize), Value::Str(__s) => __s.parse::<usize>().ok().and_then(|__n| __arr.get(__n)), _ => None }).cloned().unwrap_or(Value::Null);
8899 let mut parsed: Value = <Self as crate::exchange_generated::ExchangeBase>::parse_liquidation(self, entry, &[market.clone()]);
8900 append_to_array(&mut result, parsed);
8901 }
8902 }
8903 let mut sorted: Value = self.sort_by(result, Value::Str("timestamp".into()), &[]);
8904 let mut symbol: Value = self.safe_string_k(market, "symbol", &[]);
8905 return self.filter_by_symbol_since_limit(sorted, &[symbol, since, limit]);
8906
8907 Value::Null
8908}
8909
8910 fn parse_greeks(&self, mut greeks: Value, optional_args: &[Value]) -> Value {
8911 { 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; } }
8913
8914 let mut market = get_arg(optional_args, 0, Value::Null);
8915 panic!("{}", crate::exchange_errors::not_supported(format!("{}{}", self.id.clone(), Value::Str(" parseGreeks () is not supported yet".into()))));
8916
8917 Value::Null
8918}
8919
8920 fn parse_all_greeks(&self, mut greeks: Value, optional_args: &[Value]) -> Value {
8921 let mut symbols = get_arg(optional_args, 0, Value::Null);
8922 let mut params = get_arg(optional_args, 1, Value::Map({
8923 let mut m = indexmap::IndexMap::new();
8924 m
8925}));
8926 let mut results: Value = Value::from(vec![]);
8930 if (matches!(&greeks, Value::Arr(_))) {
8931 {
8932 let mut i: Value = Value::Int(0);
8933 let mut __for_first_166: bool = true;
8934 while { if !__for_first_166 { i = (match (&(i), &(Value::Int(1))) { (Value::Int(x), Value::Int(y)) => Value::Int(x + y), (Value::Int(x), Value::Float(y)) => Value::Float(*x as f64 + *y), (Value::Float(x), Value::Int(y)) => Value::Float(*x + *y as f64), (Value::Float(x), Value::Float(y)) => Value::Float(x + y), _ => Value::Null }); } __for_first_166 = false; i.as_f64().unwrap_or(f64::NAN) < ((greeks.len() as i64) as f64) } {
8935 let mut parsedTicker: Value = <Self as crate::exchange_generated::ExchangeBase>::parse_greeks(self, greeks.as_array().and_then(|__arr| match &i { Value::Int(__n) => __arr.get(*__n as usize), Value::Str(__s) => __s.parse::<usize>().ok().and_then(|__n| __arr.get(__n)), _ => None }).cloned().unwrap_or(Value::Null), &[]);
8936 let mut greek: Value = self.extend(parsedTicker, &[params.clone()]);
8937 append_to_array(&mut results, greek.clone());
8938 }
8939 }
8940 } else {
8941 let mut marketIds: Value = object_keys(&greeks);
8942 {
8943 let mut i: Value = Value::Int(0);
8944 let mut __for_first_167: bool = true;
8945 while { if !__for_first_167 { i = (match (&(i), &(Value::Int(1))) { (Value::Int(x), Value::Int(y)) => Value::Int(x + y), (Value::Int(x), Value::Float(y)) => Value::Float(*x as f64 + *y), (Value::Float(x), Value::Int(y)) => Value::Float(*x + *y as f64), (Value::Float(x), Value::Float(y)) => Value::Float(x + y), _ => Value::Null }); } __for_first_167 = false; i.as_f64().unwrap_or(f64::NAN) < ((marketIds.len() as i64) as f64) } {
8946 let mut marketId: Value = marketIds.as_array().and_then(|__arr| match &i { Value::Int(__n) => __arr.get(*__n as usize), Value::Str(__s) => __s.parse::<usize>().ok().and_then(|__n| __arr.get(__n)), _ => None }).cloned().unwrap_or(Value::Null);
8947 let mut market: Value = self.safe_market(&[marketId.clone()]);
8948 let mut parsed: Value = <Self as crate::exchange_generated::ExchangeBase>::parse_greeks(self, get_value(&greeks, &marketId), &[market]);
8949 let mut greek: Value = self.extend(parsed, &[params.clone()]);
8950 append_to_array(&mut results, greek);
8951 }
8952 }
8953 }
8954 let mut symbolsNormalized: Value = self.market_symbols(&[symbols]);
8955 return self.filter_by_array(results, Value::Str("symbol".into()), &[symbolsNormalized]);
8956
8957 Value::Null
8958}
8959
8960 fn parse_option(&self, mut chain: Value, optional_args: &[Value]) -> Value {
8961 let mut currency = get_arg(optional_args, 0, Value::Null);
8962 let mut market = get_arg(optional_args, 1, Value::Null);
8963 panic!("{}", crate::exchange_errors::not_supported(format!("{}{}", self.id.clone(), Value::Str(" parseOption () is not supported yet".into()))));
8964
8965 Value::Null
8966}
8967
8968 fn parse_option_chain(&self, mut response: Value, optional_args: &[Value]) -> Value {
8969 let mut currencyKey = get_arg(optional_args, 0, Value::Null);
8970 let mut symbolKey = get_arg(optional_args, 1, Value::Null);
8971 let mut optionStructures: Value = Value::Map({
8972 let mut m = indexmap::IndexMap::new();
8973 m
8974 });
8975 {
8976 let mut i: Value = Value::Int(0);
8977 let mut __for_first_168: bool = true;
8978 while { if !__for_first_168 { i = (match (&(i), &(Value::Int(1))) { (Value::Int(x), Value::Int(y)) => Value::Int(x + y), (Value::Int(x), Value::Float(y)) => Value::Float(*x as f64 + *y), (Value::Float(x), Value::Int(y)) => Value::Float(*x + *y as f64), (Value::Float(x), Value::Float(y)) => Value::Float(x + y), _ => Value::Null }); } __for_first_168 = false; i.as_f64().unwrap_or(f64::NAN) < ((response.len() as i64) as f64) } {
8979 let mut info: Value = response.as_array().and_then(|__arr| match &i { Value::Int(__n) => __arr.get(*__n as usize), Value::Str(__s) => __s.parse::<usize>().ok().and_then(|__n| __arr.get(__n)), _ => None }).cloned().unwrap_or(Value::Null);
8980 let mut currencyId: Value = (if (currencyKey == Value::Null) { Value::Null } else { self.safe_string(info.clone(), currencyKey.clone(), &[]) });
8981 let mut currency: Value = self.safe_currency(currencyId, &[]);
8982 let mut marketId: Value = (if (symbolKey == Value::Null) { Value::Null } else { self.safe_string(info.clone(), symbolKey.clone(), &[]) });
8983 let mut market: Value = self.safe_market(&[marketId, Value::Null, Value::Null, Value::Str("option".into())]);
8984 add_element_to_object(&mut optionStructures, &market.as_map().and_then(|__m| __m.get("symbol")).cloned().unwrap_or(Value::Null), self.parse_option(info, &[currency, market.clone()]));
8985 }
8986 }
8987 return optionStructures;
8988
8989 Value::Null
8990}
8991
8992 fn parse_margin_modes(&self, mut response: Value, optional_args: &[Value]) -> Value {
8993 let mut symbols = get_arg(optional_args, 0, Value::Null);
8994 let mut symbolKey = get_arg(optional_args, 1, Value::Null);
8995 let mut marketType = get_arg(optional_args, 2, Value::Null);
8996 let mut marginModeStructures: Value = Value::Map({
8997 let mut m = indexmap::IndexMap::new();
8998 m
8999 });
9000 let mut marketTypeResolved: Value = (if (marketType == Value::Null) { Value::Str("swap".into()) } else { marketType }); {
9002 let mut i: Value = Value::Int(0);
9003 let mut __for_first_169: bool = true;
9004 while { if !__for_first_169 { i = (match (&(i), &(Value::Int(1))) { (Value::Int(x), Value::Int(y)) => Value::Int(x + y), (Value::Int(x), Value::Float(y)) => Value::Float(*x as f64 + *y), (Value::Float(x), Value::Int(y)) => Value::Float(*x + *y as f64), (Value::Float(x), Value::Float(y)) => Value::Float(x + y), _ => Value::Null }); } __for_first_169 = false; i.as_f64().unwrap_or(f64::NAN) < ((response.len() as i64) as f64) } {
9005 let mut info: Value = response.as_array().and_then(|__arr| match &i { Value::Int(__n) => __arr.get(*__n as usize), Value::Str(__s) => __s.parse::<usize>().ok().and_then(|__n| __arr.get(__n)), _ => None }).cloned().unwrap_or(Value::Null);
9006 let mut marketId: Value = (if (symbolKey == Value::Null) { Value::Null } else { self.safe_string(info.clone(), symbolKey.clone(), &[]) });
9007 let mut market: Value = self.safe_market(&[marketId, Value::Null, Value::Null, marketTypeResolved.clone()]);
9008 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) {
9009 add_element_to_object(&mut marginModeStructures, &market.as_map().and_then(|__m| __m.get("symbol")).cloned().unwrap_or(Value::Null), <Self as crate::exchange_generated::ExchangeBase>::parse_margin_mode(self, info, &[market.clone()]));
9010 }
9011 }
9012 }
9013 return marginModeStructures;
9014
9015 Value::Null
9016}
9017
9018 fn parse_margin_mode(&self, mut marginMode: Value, optional_args: &[Value]) -> Value {
9019 { 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; } }
9021
9022 let mut market = get_arg(optional_args, 0, Value::Null);
9023 panic!("{}", crate::exchange_errors::not_supported(format!("{}{}", self.id.clone(), Value::Str(" parseMarginMode () is not supported yet".into()))));
9024
9025 Value::Null
9026}
9027
9028 fn parse_leverages(&self, mut response: Value, optional_args: &[Value]) -> Value {
9029 let mut symbols = get_arg(optional_args, 0, Value::Null);
9030 let mut symbolKey = get_arg(optional_args, 1, Value::Null);
9031 let mut marketType = get_arg(optional_args, 2, Value::Null);
9032 let mut leverageStructures: Value = Value::Map({
9033 let mut m = indexmap::IndexMap::new();
9034 m
9035 });
9036 let mut marketTypeResolved: Value = (if (marketType == Value::Null) { Value::Str("swap".into()) } else { marketType }); {
9038 let mut i: Value = Value::Int(0);
9039 let mut __for_first_170: bool = true;
9040 while { if !__for_first_170 { i = (match (&(i), &(Value::Int(1))) { (Value::Int(x), Value::Int(y)) => Value::Int(x + y), (Value::Int(x), Value::Float(y)) => Value::Float(*x as f64 + *y), (Value::Float(x), Value::Int(y)) => Value::Float(*x + *y as f64), (Value::Float(x), Value::Float(y)) => Value::Float(x + y), _ => Value::Null }); } __for_first_170 = false; i.as_f64().unwrap_or(f64::NAN) < ((response.len() as i64) as f64) } {
9041 let mut info: Value = response.as_array().and_then(|__arr| match &i { Value::Int(__n) => __arr.get(*__n as usize), Value::Str(__s) => __s.parse::<usize>().ok().and_then(|__n| __arr.get(__n)), _ => None }).cloned().unwrap_or(Value::Null);
9042 let mut marketId: Value = (if (symbolKey == Value::Null) { Value::Null } else { self.safe_string(info.clone(), symbolKey.clone(), &[]) });
9043 let mut market: Value = self.safe_market(&[marketId, Value::Null, Value::Null, marketTypeResolved.clone()]);
9044 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) {
9045 add_element_to_object(&mut leverageStructures, &market.as_map().and_then(|__m| __m.get("symbol")).cloned().unwrap_or(Value::Null), <Self as crate::exchange_generated::ExchangeBase>::parse_leverage(self, info, &[market.clone()]));
9046 }
9047 }
9048 }
9049 return leverageStructures;
9050
9051 Value::Null
9052}
9053
9054 fn parse_leverage(&self, mut leverage: Value, optional_args: &[Value]) -> Value {
9055 { 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; } }
9057
9058 let mut market = get_arg(optional_args, 0, Value::Null);
9059 panic!("{}", crate::exchange_errors::not_supported(format!("{}{}", self.id.clone(), Value::Str(" parseLeverage () is not supported yet".into()))));
9060
9061 Value::Null
9062}
9063
9064 fn parse_conversions(&self, mut conversions: Value, optional_args: &[Value]) -> Value {
9065 let mut code = get_arg(optional_args, 0, Value::Null);
9066 let mut fromCurrencyKey = get_arg(optional_args, 1, Value::Null);
9067 let mut toCurrencyKey = get_arg(optional_args, 2, Value::Null);
9068 let mut since = get_arg(optional_args, 3, Value::Null);
9069 let mut limit = get_arg(optional_args, 4, Value::Null);
9070 let mut params = get_arg(optional_args, 5, Value::Map({
9071 let mut m = indexmap::IndexMap::new();
9072 m
9073}));
9074 let mut conversionsArray: Value = self.to_array(conversions);
9075 let mut result: Value = Value::from(vec![]);
9076 let mut fromCurrency: Value = Value::Null;
9077 let mut toCurrency: Value = Value::Null;
9078 {
9079 let mut i: Value = Value::Int(0);
9080 let mut __for_first_171: bool = true;
9081 while { if !__for_first_171 { i = (match (&(i), &(Value::Int(1))) { (Value::Int(x), Value::Int(y)) => Value::Int(x + y), (Value::Int(x), Value::Float(y)) => Value::Float(*x as f64 + *y), (Value::Float(x), Value::Int(y)) => Value::Float(*x + *y as f64), (Value::Float(x), Value::Float(y)) => Value::Float(x + y), _ => Value::Null }); } __for_first_171 = false; i.as_f64().unwrap_or(f64::NAN) < ((conversionsArray.len() as i64) as f64) } {
9082 let mut entry: Value = conversionsArray.as_array().and_then(|__arr| match &i { Value::Int(__n) => __arr.get(*__n as usize), Value::Str(__s) => __s.parse::<usize>().ok().and_then(|__n| __arr.get(__n)), _ => None }).cloned().unwrap_or(Value::Null);
9083 let mut fromId: Value = (if (fromCurrencyKey == Value::Null) { Value::Null } else { self.safe_string(entry.clone(), fromCurrencyKey.clone(), &[]) });
9084 let mut toId: Value = (if (toCurrencyKey == Value::Null) { Value::Null } else { self.safe_string(entry.clone(), toCurrencyKey.clone(), &[]) });
9085 if (fromId != Value::Null) {
9086 fromCurrency = self.safe_currency(fromId, &[]);
9087 }
9088 if (toId != Value::Null) {
9089 toCurrency = self.safe_currency(toId, &[]);
9090 }
9091 let mut conversion: Value = self.extend(<Self as crate::exchange_generated::ExchangeBase>::parse_conversion(self, entry, &[fromCurrency.clone(), toCurrency.clone()]), &[params.clone()]);
9092 append_to_array(&mut result, conversion);
9093 }
9094 }
9095 let mut sorted: Value = self.sort_by(result, Value::Str("timestamp".into()), &[]);
9096 if (code == Value::Null) {
9097 return self.filter_by_since_limit(sorted.clone(), &[since.clone(), limit.clone()]);
9098 }
9099 let mut currency: Value = self.safe_currency(code, &[]);
9100 if (currency == Value::Null) {
9101 panic!("{}", crate::exchange_errors::exchange_error(format!("{}{}", self.id.clone(), Value::Str(" parseConversions() could not resolve currency".into()))));
9102 }
9103 let mut currencyCode: Value = currency.as_map().and_then(|__m| __m.get("code")).cloned().unwrap_or(Value::Null);
9104 let mut fromConversion: Value = self.filter_by(sorted.clone(), Value::Str("fromCurrency".into()), currencyCode.clone(), &[]);
9105 let mut toConversion: Value = self.filter_by(sorted, Value::Str("toCurrency".into()), currencyCode, &[]);
9106 let mut both: Value = self.array_concat(fromConversion, toConversion);
9107 return self.filter_by_since_limit(both, &[since, limit]);
9108
9109 Value::Null
9110}
9111
9112 fn parse_conversion(&self, mut conversion: Value, optional_args: &[Value]) -> Value {
9113 { 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; } }
9115
9116 let mut fromCurrency = get_arg(optional_args, 0, Value::Null);
9117 let mut toCurrency = get_arg(optional_args, 1, Value::Null);
9118 if (conversion == Value::Null) {
9119 panic!("{}", crate::exchange_errors::not_supported(format!("{}{}", self.id.clone(), Value::Str(" parseConversion () is not supported yet".into()))));
9120 }
9121 panic!("{}", crate::exchange_errors::not_supported(format!("{}{}", self.id.clone(), Value::Str(" parseConversion () is not supported yet".into()))));
9122
9123 Value::Null
9124}
9125
9126 fn convert_expire_date(&self, mut date: Value) -> Value {
9127 if (date == Value::Null) {
9128 return Value::Null;
9129 }
9130 let mut year: Value = date.as_str().map(|__s| { let __c: Vec<char> = __s.chars().collect(); let __l = __c.len() as i64; let __i = __l.min(0); let __j = __l.min(2); if __i <= __j { __c[__i as usize..__j as usize].iter().collect::<String>() } else { String::new() } }).map(|__s| Value::Str(__s.into())).unwrap_or(Value::Null);
9132 let mut month: Value = date.as_str().map(|__s| { let __c: Vec<char> = __s.chars().collect(); let __l = __c.len() as i64; let __i = __l.min(2); let __j = __l.min(4); if __i <= __j { __c[__i as usize..__j as usize].iter().collect::<String>() } else { String::new() } }).map(|__s| Value::Str(__s.into())).unwrap_or(Value::Null);
9133 let mut day: Value = date.as_str().map(|__s| { let __c: Vec<char> = __s.chars().collect(); let __l = __c.len() as i64; let __i = __l.min(4); let __j = __l.min(6); if __i <= __j { __c[__i as usize..__j as usize].iter().collect::<String>() } else { String::new() } }).map(|__s| Value::Str(__s.into())).unwrap_or(Value::Null);
9134 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());
9137 return reconstructedDate;
9138
9139 Value::Null
9140}
9141
9142 fn convert_expire_date_to_market_id_date(&self, mut date: Value) -> Value {
9143 if (date == Value::Null) {
9144 return Value::Null;
9145 }
9146 let mut year: Value = date.as_str().map(|__s| { let __c: Vec<char> = __s.chars().collect(); let __l = __c.len() as i64; let __i = __l.min(0); let __j = __l.min(2); if __i <= __j { __c[__i as usize..__j as usize].iter().collect::<String>() } else { String::new() } }).map(|__s| Value::Str(__s.into())).unwrap_or(Value::Null);
9148 let mut monthRaw: Value = date.as_str().map(|__s| { let __c: Vec<char> = __s.chars().collect(); let __l = __c.len() as i64; let __i = __l.min(2); let __j = __l.min(4); if __i <= __j { __c[__i as usize..__j as usize].iter().collect::<String>() } else { String::new() } }).map(|__s| Value::Str(__s.into())).unwrap_or(Value::Null);
9149 let mut month: Value = Value::Null;
9150 let mut day: Value = date.as_str().map(|__s| { let __c: Vec<char> = __s.chars().collect(); let __l = __c.len() as i64; let __i = __l.min(4); let __j = __l.min(6); if __i <= __j { __c[__i as usize..__j as usize].iter().collect::<String>() } else { String::new() } }).map(|__s| Value::Str(__s.into())).unwrap_or(Value::Null);
9151 if (monthRaw.as_str() == Some("01")) {
9152 month = Value::Str("JAN".into());
9153 } else if (monthRaw.as_str() == Some("02")) {
9154 month = Value::Str("FEB".into());
9155 } else if (monthRaw.as_str() == Some("03")) {
9156 month = Value::Str("MAR".into());
9157 } else if (monthRaw.as_str() == Some("04")) {
9158 month = Value::Str("APR".into());
9159 } else if (monthRaw.as_str() == Some("05")) {
9160 month = Value::Str("MAY".into());
9161 } else if (monthRaw.as_str() == Some("06")) {
9162 month = Value::Str("JUN".into());
9163 } else if (monthRaw.as_str() == Some("07")) {
9164 month = Value::Str("JUL".into());
9165 } else if (monthRaw.as_str() == Some("08")) {
9166 month = Value::Str("AUG".into());
9167 } else if (monthRaw.as_str() == Some("09")) {
9168 month = Value::Str("SEP".into());
9169 } else if (monthRaw.as_str() == Some("10")) {
9170 month = Value::Str("OCT".into());
9171 } else if (monthRaw.as_str() == Some("11")) {
9172 month = Value::Str("NOV".into());
9173 } else if (monthRaw.as_str() == Some("12")) {
9174 month = Value::Str("DEC".into());
9175 }
9176 if (month == Value::Null) {
9177 panic!("{}", crate::exchange_errors::bad_symbol(format!("{}{}", Value::Str(format!("{}{}", self.id.clone(), Value::Str(" invalid expiry date ".into())).into()), date)));
9178 }
9179 let mut reconstructedDate: Value = Value::Str(format!("{}{}", Value::Str(format!("{}{}", day, month).into()), year).into());
9180 return reconstructedDate;
9181
9182 Value::Null
9183}
9184
9185 fn convert_market_id_expire_date(&self, mut date: Value) -> Value {
9186 if (date == Value::Null) {
9187 return Value::Null;
9188 }
9189 let mut monthMappping: Value = Value::Map({
9191 let mut m = indexmap::IndexMap::new();
9192 m.insert("JAN".to_string(), Value::Str("01".into()));
9193 m.insert("FEB".to_string(), Value::Str("02".into()));
9194 m.insert("MAR".to_string(), Value::Str("03".into()));
9195 m.insert("APR".to_string(), Value::Str("04".into()));
9196 m.insert("MAY".to_string(), Value::Str("05".into()));
9197 m.insert("JUN".to_string(), Value::Str("06".into()));
9198 m.insert("JUL".to_string(), Value::Str("07".into()));
9199 m.insert("AUG".to_string(), Value::Str("08".into()));
9200 m.insert("SEP".to_string(), Value::Str("09".into()));
9201 m.insert("OCT".to_string(), Value::Str("10".into()));
9202 m.insert("NOV".to_string(), Value::Str("11".into()));
9203 m.insert("DEC".to_string(), Value::Str("12".into()));
9204 m
9205 });
9206 let mut datePadded: Value = date.clone();
9208 if (Value::Int(date.len() as i64).as_f64() == Some(6.0)) {
9209 datePadded = Value::Str(format!("{}{}", Value::Str("0".into()), date).into());
9210 }
9211 let mut year: Value = datePadded.as_str().map(|__s| { let __c: Vec<char> = __s.chars().collect(); let __l = __c.len() as i64; let __i = __l.min(0); let __j = __l.min(2); if __i <= __j { __c[__i as usize..__j as usize].iter().collect::<String>() } else { String::new() } }).map(|__s| Value::Str(__s.into())).unwrap_or(Value::Null);
9212 let mut monthName: Value = datePadded.as_str().map(|__s| { let __c: Vec<char> = __s.chars().collect(); let __l = __c.len() as i64; let __i = __l.min(2); let __j = __l.min(5); if __i <= __j { __c[__i as usize..__j as usize].iter().collect::<String>() } else { String::new() } }).map(|__s| Value::Str(__s.into())).unwrap_or(Value::Null);
9213 let mut month: Value = self.safe_string(monthMappping, monthName, &[]);
9214 let mut day: Value = datePadded.as_str().map(|__s| { let __c: Vec<char> = __s.chars().collect(); let __l = __c.len() as i64; let __i = __l.min(5); let __j = __l.min(7); if __i <= __j { __c[__i as usize..__j as usize].iter().collect::<String>() } else { String::new() } }).map(|__s| Value::Str(__s.into())).unwrap_or(Value::Null);
9215 if (month == Value::Null) {
9216 panic!("{}", crate::exchange_errors::bad_symbol(format!("{}{}", Value::Str(format!("{}{}", self.id.clone(), Value::Str(" invalid expiry date ".into())).into()), date)));
9217 }
9218 let mut reconstructedDate: Value = Value::Str(format!("{}{}", Value::Str(format!("{}{}", day, month).into()), year).into());
9219 return reconstructedDate;
9220
9221 Value::Null
9222}
9223
9224 fn load_markets_and_sign_in(&mut self) -> impl ::std::future::Future<Output = Value> + Send { async move {
9225 promise_all(&Value::from(vec![self.load_markets(&[]).await, self.sign_in(&[]).await])).await;
9226
9227 Value::Null
9228} }
9229
9230 fn parse_margin_modification(&self, mut data: Value, optional_args: &[Value]) -> Value {
9231 { 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; } }
9233
9234 let mut market = get_arg(optional_args, 0, Value::Null);
9235 if (data == Value::Null) {
9236 panic!("{}", crate::exchange_errors::not_supported(format!("{}{}", self.id.clone(), Value::Str(" parseMarginModification() is not supported yet".into()))));
9237 }
9238 panic!("{}", crate::exchange_errors::not_supported(format!("{}{}", self.id.clone(), Value::Str(" parseMarginModification() is not supported yet".into()))));
9239
9240 Value::Null
9241}
9242
9243 fn parse_margin_modifications(&self, mut response: Value, optional_args: &[Value]) -> Value {
9244 let mut symbols = get_arg(optional_args, 0, Value::Null);
9245 let mut symbolKey = get_arg(optional_args, 1, Value::Null);
9246 let mut marketType = get_arg(optional_args, 2, Value::Null);
9247 let mut marginModifications: Value = Value::from(vec![]);
9248 if (response == Value::Null) {
9249 return marginModifications;
9250 }
9251 {
9252 let mut i: Value = Value::Int(0);
9253 let mut __for_first_172: bool = true;
9254 while { if !__for_first_172 { i = (match (&(i), &(Value::Int(1))) { (Value::Int(x), Value::Int(y)) => Value::Int(x + y), (Value::Int(x), Value::Float(y)) => Value::Float(*x as f64 + *y), (Value::Float(x), Value::Int(y)) => Value::Float(*x + *y as f64), (Value::Float(x), Value::Float(y)) => Value::Float(x + y), _ => Value::Null }); } __for_first_172 = false; i.as_f64().unwrap_or(f64::NAN) < ((response.len() as i64) as f64) } {
9255 let mut info: Value = response.as_array().and_then(|__arr| match &i { Value::Int(__n) => __arr.get(*__n as usize), Value::Str(__s) => __s.parse::<usize>().ok().and_then(|__n| __arr.get(__n)), _ => None }).cloned().unwrap_or(Value::Null);
9256 let mut marketId: Value = (if (symbolKey == Value::Null) { Value::Null } else { self.safe_string(info.clone(), symbolKey.clone(), &[]) });
9257 let mut market: Value = self.safe_market(&[marketId, Value::Null, Value::Null, marketType.clone()]);
9258 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) {
9259 append_to_array(&mut marginModifications, <Self as crate::exchange_generated::ExchangeBase>::parse_margin_modification(self, info, &[market]));
9260 }
9261 }
9262 }
9263 return marginModifications;
9264
9265 Value::Null
9266}
9267
9268 fn fetch_transfer(&mut self, mut id: Value, optional_args: &[Value]) -> impl ::std::future::Future<Output = Value> + Send { async move {
9269 let mut code = get_arg(optional_args, 0, Value::Null);
9270 let mut params = get_arg(optional_args, 1, Value::Map({
9271 let mut m = indexmap::IndexMap::new();
9272 m
9273}));
9274 panic!("{}", crate::exchange_errors::not_supported(format!("{}{}", self.id.clone(), Value::Str(" fetchTransfer () is not supported yet".into()))));
9275
9276 Value::Null
9277} }
9278
9279 fn fetch_transfers(&mut self, optional_args: &[Value]) -> impl ::std::future::Future<Output = Value> + Send { async move {
9280 let mut code = get_arg(optional_args, 0, Value::Null);
9281 let mut since = get_arg(optional_args, 1, Value::Null);
9282 let mut limit = get_arg(optional_args, 2, Value::Null);
9283 let mut params = get_arg(optional_args, 3, Value::Map({
9284 let mut m = indexmap::IndexMap::new();
9285 m
9286}));
9287 panic!("{}", crate::exchange_errors::not_supported(format!("{}{}", self.id.clone(), Value::Str(" fetchTransfers () is not supported yet".into()))));
9288
9289 Value::Null
9290} }
9291
9292 fn un_watch_ohlcv(&mut self, mut symbol: Value, optional_args: &[Value]) -> impl ::std::future::Future<Output = Value> + Send { async move {
9293 let mut timeframe = get_arg(optional_args, 0, Value::Str("1m".into()));
9294 let mut params = get_arg(optional_args, 1, Value::Map({
9295 let mut m = indexmap::IndexMap::new();
9296 m
9297}));
9298 panic!("{}", crate::exchange_errors::not_supported(format!("{}{}", self.id.clone(), Value::Str(" unWatchOHLCV () is not supported yet".into()))));
9299
9300 Value::Null
9301} }
9302
9303 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 {
9304 let mut tag = get_arg(optional_args, 0, Value::Null);
9305 let mut params = get_arg(optional_args, 1, Value::Map({
9306 let mut m = indexmap::IndexMap::new();
9307 m
9308}));
9309 panic!("{}", crate::exchange_errors::not_supported(format!("{}{}", self.id.clone(), Value::Str(" withdrawWs () is not supported yet".into()))));
9310
9311 Value::Null
9312} }
9313
9314 fn un_watch_my_trades(&mut self, optional_args: &[Value]) -> impl ::std::future::Future<Output = Value> + Send { async move {
9315 let mut symbol = get_arg(optional_args, 0, Value::Null);
9316 let mut params = get_arg(optional_args, 1, Value::Map({
9317 let mut m = indexmap::IndexMap::new();
9318 m
9319}));
9320 panic!("{}", crate::exchange_errors::not_supported(format!("{}{}", self.id.clone(), Value::Str(" unWatchMyTrades () is not supported yet".into()))));
9321
9322 Value::Null
9323} }
9324
9325 fn fetch_orders_by_status_ws(&mut self, mut status: Value, optional_args: &[Value]) -> impl ::std::future::Future<Output = Value> + Send { async move {
9326 let mut symbol = get_arg(optional_args, 0, Value::Null);
9327 let mut since = get_arg(optional_args, 1, Value::Null);
9328 let mut limit = get_arg(optional_args, 2, Value::Null);
9329 let mut params = get_arg(optional_args, 3, Value::Map({
9330 let mut m = indexmap::IndexMap::new();
9331 m
9332}));
9333 panic!("{}", crate::exchange_errors::not_supported(format!("{}{}", self.id.clone(), Value::Str(" fetchOrdersByStatusWs () is not supported yet".into()))));
9334
9335 Value::Null
9336} }
9337
9338 fn un_watch_bids_asks(&mut self, optional_args: &[Value]) -> impl ::std::future::Future<Output = Value> + Send { async move {
9339 let mut symbols = get_arg(optional_args, 0, Value::Null);
9340 let mut params = get_arg(optional_args, 1, Value::Map({
9341 let mut m = indexmap::IndexMap::new();
9342 m
9343}));
9344 panic!("{}", crate::exchange_errors::not_supported(format!("{}{}", self.id.clone(), Value::Str(" unWatchBidsAsks () is not supported yet".into()))));
9345
9346 Value::Null
9347} }
9348
9349 fn clean_unsubscription(&self, mut client: Value, mut subHash: Value, mut unsubHash: Value, optional_args: &[Value]) {
9350 let mut subHashIsPrefix = get_arg(optional_args, 0, Value::Bool(false));
9351 if (unsubHash != Value::Null) && (in_op(&get_value(&client, &Value::Str("subscriptions".into())), &unsubHash)) {
9352 remove(&mut get_value(&client, &Value::Str("subscriptions".into())), &unsubHash);
9353 }
9354 if !is_true(&subHashIsPrefix) {
9355 if (subHash != Value::Null) && (in_op(&get_value(&client, &Value::Str("subscriptions".into())), &subHash)) {
9356 remove(&mut get_value(&client, &Value::Str("subscriptions".into())), &subHash);
9357 }
9358 if (subHash != Value::Null) && (in_op(&get_value(&client, &Value::Str("futures".into())), &subHash)) {
9359 let mut error = crate::exchange_errors::unsubscribe_error(format!("{}{}", Value::Str(format!("{}{}", self.id.clone(), Value::Str(" ".into())).into()), subHash));
9360 client.reject(&[Value::from(error.clone()), subHash.clone()]);
9361 }
9362 } else {
9363 let mut clientSubscriptions: Value = object_keys(&get_value(&client, &Value::Str("subscriptions".into())));
9364 {
9365 let mut i: Value = Value::Int(0);
9366 let mut __for_first_173: bool = true;
9367 while { if !__for_first_173 { i = (match (&(i), &(Value::Int(1))) { (Value::Int(x), Value::Int(y)) => Value::Int(x + y), (Value::Int(x), Value::Float(y)) => Value::Float(*x as f64 + *y), (Value::Float(x), Value::Int(y)) => Value::Float(*x + *y as f64), (Value::Float(x), Value::Float(y)) => Value::Float(x + y), _ => Value::Null }); } __for_first_173 = false; i.as_f64().unwrap_or(f64::NAN) < ((clientSubscriptions.len() as i64) as f64) } {
9368 let mut sub: Value = clientSubscriptions.as_array().and_then(|__arr| match &i { Value::Int(__n) => __arr.get(*__n as usize), Value::Str(__s) => __s.parse::<usize>().ok().and_then(|__n| __arr.get(__n)), _ => None }).cloned().unwrap_or(Value::Null);
9369 if (sub != Value::Null) && (subHash != Value::Null) && (starts_with(&sub, &subHash)) {
9370 remove(&mut get_value(&client, &Value::Str("subscriptions".into())), &sub);
9371 }
9372 }
9373 }
9374 let mut clientFutures: Value = object_keys(&get_value(&client, &Value::Str("futures".into())));
9375 {
9376 let mut i: Value = Value::Int(0);
9377 let mut __for_first_174: bool = true;
9378 while { if !__for_first_174 { i = (match (&(i), &(Value::Int(1))) { (Value::Int(x), Value::Int(y)) => Value::Int(x + y), (Value::Int(x), Value::Float(y)) => Value::Float(*x as f64 + *y), (Value::Float(x), Value::Int(y)) => Value::Float(*x + *y as f64), (Value::Float(x), Value::Float(y)) => Value::Float(x + y), _ => Value::Null }); } __for_first_174 = false; i.as_f64().unwrap_or(f64::NAN) < ((clientFutures.len() as i64) as f64) } {
9379 let mut future: Value = clientFutures.as_array().and_then(|__arr| match &i { Value::Int(__n) => __arr.get(*__n as usize), Value::Str(__s) => __s.parse::<usize>().ok().and_then(|__n| __arr.get(__n)), _ => None }).cloned().unwrap_or(Value::Null);
9380 if (future != Value::Null) && (subHash != Value::Null) && (starts_with(&future, &subHash)) {
9381 let mut error = crate::exchange_errors::unsubscribe_error(format!("{}{}", Value::Str(format!("{}{}", self.id.clone(), Value::Str(" ".into())).into()), future));
9382 client.reject(&[Value::from(error), future.clone()]);
9383 }
9384 }
9385 }
9386 }
9387 client.resolve(&[Value::Bool(true), unsubHash]);
9388}
9389
9390 fn clean_cache(&mut self, mut subscription: Value) {
9391 let __subscription_empty = indexmap::IndexMap::new();
9392 let subscription = subscription.as_map().unwrap_or(&__subscription_empty);
9393 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);
9394 let mut symbols: Value = (match subscription.get("symbols") { Some(__v) if matches!(__v, Value::Arr(_)) => __v.clone(), _ => Value::from(vec![]) });
9395 let mut symbolsLength: f64 = ((symbols.len() as i64) as f64);
9396 if (topic.as_deref() == Some("ohlcv")) {
9397 let mut symbolsAndTimeframes: Value = (match subscription.get("symbolsAndTimeframes") { Some(__v) if matches!(__v, Value::Arr(_)) => __v.clone(), _ => Value::from(vec![]) });
9398 {
9399 let mut i: Value = Value::Int(0);
9400 let mut __for_first_175: bool = true;
9401 while { if !__for_first_175 { i = (match (&(i), &(Value::Int(1))) { (Value::Int(x), Value::Int(y)) => Value::Int(x + y), (Value::Int(x), Value::Float(y)) => Value::Float(*x as f64 + *y), (Value::Float(x), Value::Int(y)) => Value::Float(*x + *y as f64), (Value::Float(x), Value::Float(y)) => Value::Float(x + y), _ => Value::Null }); } __for_first_175 = false; i.as_f64().unwrap_or(f64::NAN) < ((symbolsAndTimeframes.len() as i64) as f64) } {
9402 let mut symbolAndTimeFrame: Value = get_value(&symbolsAndTimeframes, &i);
9403 let mut symbolAndTimeFrame: Value = get_value(&symbolsAndTimeframes, &i);
9404 let mut symbol: Value = self.safe_string(symbolAndTimeFrame.clone(), Value::Int(0), &[]);
9405 let mut timeframe: Value = self.safe_string(symbolAndTimeFrame, Value::Int(1), &[]);
9406 if (symbol == Value::Null) {
9407 panic!("{}", crate::exchange_errors::arguments_required(format!("{}{}", self.id.clone(), Value::Str(" cleanCache() requires a symbol argument".into()))));
9408 }
9409 if (timeframe == Value::Null) {
9410 panic!("{}", crate::exchange_errors::arguments_required(format!("{}{}", self.id.clone(), Value::Str(" cleanCache() requires a timeframe argument".into()))));
9411 }
9412 if (self.ohlcvs.clone() != Value::Null) && (in_op(&self.ohlcvs, &symbol)) {
9413 if (in_op(&get_value(&self.ohlcvs, &symbol), &timeframe)) {
9414 remove(&mut get_value(&self.ohlcvs, &symbol), &timeframe);
9415 }
9416 }
9417 }
9418 }
9419 } else if symbolsLength > ((0i64) as f64) {
9420 {
9421 let mut i: Value = Value::Int(0);
9422 let mut __for_first_176: bool = true;
9423 while { if !__for_first_176 { i = (match (&(i), &(Value::Int(1))) { (Value::Int(x), Value::Int(y)) => Value::Int(x + y), (Value::Int(x), Value::Float(y)) => Value::Float(*x as f64 + *y), (Value::Float(x), Value::Int(y)) => Value::Float(*x + *y as f64), (Value::Float(x), Value::Float(y)) => Value::Float(x + y), _ => Value::Null }); } __for_first_176 = false; i.as_f64().unwrap_or(f64::NAN) < ((symbols.len() as i64) as f64) } {
9424 let mut symbol: Value = get_value(&symbols, &i);
9425 let mut symbol: Value = get_value(&symbols, &i);
9426 if (topic.as_deref() == Some("trades")) {
9427 if (in_op(&self.trades, &symbol)) {
9428 remove(&mut self.trades.clone(), &symbol);
9429 }
9430 } else if (topic.as_deref() == Some("orderbook")) {
9431 if (in_op(&self.orderbooks, &symbol)) {
9432 remove(&mut self.orderbooks.clone(), &symbol);
9433 }
9434 } else if (topic.as_deref() == Some("ticker")) {
9435 if (in_op(&self.tickers, &symbol)) {
9436 remove(&mut self.tickers.clone(), &symbol);
9437 }
9438 } else if (topic.as_deref() == Some("bidsasks")) {
9439 if (in_op(&self.bidsasks, &symbol)) {
9440 remove(&mut self.bidsasks.clone(), &symbol);
9441 }
9442 }
9443 }
9444 }
9445 } else {
9446 if (topic.as_deref() == Some("myTrades")) && (self.myTrades.clone() != Value::Null) {
9447 self.myTrades = Value::Null;
9448 } else if (topic.as_deref() == Some("orders")) && (self.orders.clone() != Value::Null) {
9449 self.orders = Value::Null;
9450 } else if (topic.as_deref() == Some("positions")) && (self.positions.clone() != Value::Null) {
9451 self.positions = Value::Null;
9452 let mut clients: Value = object_values(&self.clients);
9453 {
9454 let mut i: Value = Value::Int(0);
9455 let mut __for_first_177: bool = true;
9456 while { if !__for_first_177 { i = (match (&(i), &(Value::Int(1))) { (Value::Int(x), Value::Int(y)) => Value::Int(x + y), (Value::Int(x), Value::Float(y)) => Value::Float(*x as f64 + *y), (Value::Float(x), Value::Int(y)) => Value::Float(*x + *y as f64), (Value::Float(x), Value::Float(y)) => Value::Float(x + y), _ => Value::Null }); } __for_first_177 = false; i.as_f64().unwrap_or(f64::NAN) < ((clients.len() as i64) as f64) } {
9457 let mut client: Value = clients.as_array().and_then(|__arr| match &i { Value::Int(__n) => __arr.get(*__n as usize), Value::Str(__s) => __s.parse::<usize>().ok().and_then(|__n| __arr.get(__n)), _ => None }).cloned().unwrap_or(Value::Null);
9458 let mut futures: Value = get_value(&client, &Value::Str("futures".into()));
9459 if (futures != Value::Null) && (matches!(&futures, Value::Dict(__d) if __d.contains_key("fetchPositionsSnapshot"))) {
9460 remove(&mut futures, &Value::Str("fetchPositionsSnapshot".into()));
9461 }
9462 }
9463 }
9464 } else if ((topic.as_deref() == Some("ticker")) || (topic.as_deref() == Some("markPrice"))) && (self.tickers.clone() != Value::Null) {
9465 let mut tickerSymbols: Value = object_keys(&self.tickers);
9466 {
9467 let mut i: Value = Value::Int(0);
9468 let mut __for_first_178: bool = true;
9469 while { if !__for_first_178 { i = (match (&(i), &(Value::Int(1))) { (Value::Int(x), Value::Int(y)) => Value::Int(x + y), (Value::Int(x), Value::Float(y)) => Value::Float(*x as f64 + *y), (Value::Float(x), Value::Int(y)) => Value::Float(*x + *y as f64), (Value::Float(x), Value::Float(y)) => Value::Float(x + y), _ => Value::Null }); } __for_first_178 = false; i.as_f64().unwrap_or(f64::NAN) < ((tickerSymbols.len() as i64) as f64) } {
9470 let mut tickerSymbol: Value = tickerSymbols.as_array().and_then(|__arr| match &i { Value::Int(__n) => __arr.get(*__n as usize), Value::Str(__s) => __s.parse::<usize>().ok().and_then(|__n| __arr.get(__n)), _ => None }).cloned().unwrap_or(Value::Null);
9471 if (in_op(&self.tickers, &tickerSymbol)) {
9472 remove(&mut self.tickers.clone(), &tickerSymbol);
9473 }
9474 }
9475 }
9476 } else if (topic.as_deref() == Some("bidsasks")) && (self.bidsasks.clone() != Value::Null) {
9477 let mut bidsaskSymbols: Value = object_keys(&self.bidsasks);
9478 {
9479 let mut i: Value = Value::Int(0);
9480 let mut __for_first_179: bool = true;
9481 while { if !__for_first_179 { i = (match (&(i), &(Value::Int(1))) { (Value::Int(x), Value::Int(y)) => Value::Int(x + y), (Value::Int(x), Value::Float(y)) => Value::Float(*x as f64 + *y), (Value::Float(x), Value::Int(y)) => Value::Float(*x + *y as f64), (Value::Float(x), Value::Float(y)) => Value::Float(x + y), _ => Value::Null }); } __for_first_179 = false; i.as_f64().unwrap_or(f64::NAN) < ((bidsaskSymbols.len() as i64) as f64) } {
9482 let mut bidsaskSymbol: Value = bidsaskSymbols.as_array().and_then(|__arr| match &i { Value::Int(__n) => __arr.get(*__n as usize), Value::Str(__s) => __s.parse::<usize>().ok().and_then(|__n| __arr.get(__n)), _ => None }).cloned().unwrap_or(Value::Null);
9483 if (in_op(&self.bidsasks, &bidsaskSymbol)) {
9484 remove(&mut self.bidsasks.clone(), &bidsaskSymbol);
9485 }
9486 }
9487 }
9488 }
9489 }
9490}
9491
9492 fn timeframe_from_milliseconds(&self, mut ms: Value) -> Value {
9493 if ms.as_f64().unwrap_or(f64::NAN) <= ((0i64) as f64) {
9494 return Value::Str("".into());
9495 }
9496 let mut second: Value = Value::Int(1000);
9497 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 });
9498 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 });
9499 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 });
9500 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 });
9501 if (mod_val(&ms, &week).as_f64() == Some(0.0)) {
9502 return add(&((match ((ms).as_f64(), (week).as_f64()) { (Some(x), Some(y)) if y != 0.0 => Value::Float(x / y), _ => Value::Null })), &Value::Str("w".into()));
9503 }
9504 if (mod_val(&ms, &day).as_f64() == Some(0.0)) {
9505 return add(&((match ((ms).as_f64(), (day).as_f64()) { (Some(x), Some(y)) if y != 0.0 => Value::Float(x / y), _ => Value::Null })), &Value::Str("d".into()));
9506 }
9507 if (mod_val(&ms, &hour).as_f64() == Some(0.0)) {
9508 return add(&((match ((ms).as_f64(), (hour).as_f64()) { (Some(x), Some(y)) if y != 0.0 => Value::Float(x / y), _ => Value::Null })), &Value::Str("h".into()));
9509 }
9510 if (mod_val(&ms, &minute).as_f64() == Some(0.0)) {
9511 return add(&((match ((ms).as_f64(), (minute).as_f64()) { (Some(x), Some(y)) if y != 0.0 => Value::Float(x / y), _ => Value::Null })), &Value::Str("m".into()));
9512 }
9513 if (mod_val(&ms, &second).as_f64() == Some(0.0)) {
9514 return add(&((match ((ms).as_f64(), (second).as_f64()) { (Some(x), Some(y)) if y != 0.0 => Value::Float(x / y), _ => Value::Null })), &Value::Str("s".into()));
9515 }
9516 return Value::Str("".into());
9517
9518 Value::Null
9519}
9520
9521 fn is_uta_enabled(&mut self, optional_args: &[Value]) -> impl ::std::future::Future<Output = Value> + Send { async move {
9522 let mut params = get_arg(optional_args, 0, Value::Map({
9523 let mut m = indexmap::IndexMap::new();
9524 m
9525}));
9526 return Value::Bool(false);
9527
9528 Value::Null
9529} }
9530 fn close_position(&mut self, mut symbol: Value, optional_args: &[Value]) -> impl ::std::future::Future<Output = Value> + Send { async move {
9531 let mut side = get_arg(optional_args, 0, Value::Null);
9532 let mut params = get_arg(optional_args, 1, Value::Map({
9533 let mut m = indexmap::IndexMap::new();
9534 m
9535}));
9536 panic!("{}", crate::exchange_errors::not_supported(format!("{}{}", self.id.clone(), Value::Str(" closePosition() is not supported yet".into()))));
9537
9538 Value::Null
9539} }
9540
9541 fn close_all_positions(&mut self, optional_args: &[Value]) -> impl ::std::future::Future<Output = Value> + Send { async move {
9542 let mut params = get_arg(optional_args, 0, Value::Map({
9543 let mut m = indexmap::IndexMap::new();
9544 m
9545}));
9546 panic!("{}", crate::exchange_errors::not_supported(format!("{}{}", self.id.clone(), Value::Str(" closeAllPositions() is not supported yet".into()))));
9547
9548 Value::Null
9549} }
9550
9551 fn edit_orders(&mut self, mut orders: Value, optional_args: &[Value]) -> impl ::std::future::Future<Output = Value> + Send { async move {
9552 let mut params = get_arg(optional_args, 0, Value::Map({
9553 let mut m = indexmap::IndexMap::new();
9554 m
9555}));
9556 panic!("{}", crate::exchange_errors::not_supported(format!("{}{}", self.id.clone(), Value::Str(" editOrders() is not supported yet".into()))));
9557
9558 Value::Null
9559} }
9560
9561 fn fetch_canceled_and_closed_orders(&mut self, optional_args: &[Value]) -> impl ::std::future::Future<Output = Value> + Send { async move {
9562 let mut symbol = get_arg(optional_args, 0, Value::Null);
9563 let mut since = get_arg(optional_args, 1, Value::Null);
9564 let mut limit = get_arg(optional_args, 2, Value::Null);
9565 let mut params = get_arg(optional_args, 3, Value::Map({
9566 let mut m = indexmap::IndexMap::new();
9567 m
9568}));
9569 panic!("{}", crate::exchange_errors::not_supported(format!("{}{}", self.id.clone(), Value::Str(" fetchCanceledAndClosedOrders() is not supported yet".into()))));
9570
9571 Value::Null
9572} }
9573
9574 fn fetch_position_history(&mut self, mut symbol: Value, optional_args: &[Value]) -> impl ::std::future::Future<Output = Value> + Send { async move {
9575 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 {
9577 if !matches!(__v, crate::Value::Null) { return __v; }
9578 }
9579
9580 let mut since = get_arg(optional_args, 0, Value::Null);
9581 let mut limit = get_arg(optional_args, 1, Value::Null);
9582 let mut params = get_arg(optional_args, 2, Value::Map({
9583 let mut m = indexmap::IndexMap::new();
9584 m
9585}));
9586 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)) {
9597 let mut positions: Value = self.fetch_positions_history(&[Value::from(vec![symbol]), since, limit, params]).await;
9598 return positions;
9599 } else {
9600 panic!("{}", crate::exchange_errors::not_supported(format!("{}{}", self.id.clone(), Value::Str(" fetchPositionHistory () is not supported yet".into()))));
9601 }
9602} }
9603
9604 fn fetch_positions_history(&mut self, optional_args: &[Value]) -> impl ::std::future::Future<Output = Value> + Send { async move {
9605 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 {
9607 if !matches!(__v, crate::Value::Null) { return __v; }
9608 }
9609
9610 let mut symbols = get_arg(optional_args, 0, Value::Null);
9611 let mut since = get_arg(optional_args, 1, Value::Null);
9612 let mut limit = get_arg(optional_args, 2, Value::Null);
9613 let mut params = get_arg(optional_args, 3, Value::Map({
9614 let mut m = indexmap::IndexMap::new();
9615 m
9616}));
9617 panic!("{}", crate::exchange_errors::not_supported(format!("{}{}", self.id.clone(), Value::Str(" fetchPositionsHistory () is not supported yet".into()))));
9618
9619 Value::Null
9620} }
9621
9622 fn fetch_positions_risk(&mut self, optional_args: &[Value]) -> impl ::std::future::Future<Output = Value> + Send { async move {
9623 let mut symbols = get_arg(optional_args, 0, Value::Null);
9624 let mut params = get_arg(optional_args, 1, Value::Map({
9625 let mut m = indexmap::IndexMap::new();
9626 m
9627}));
9628 panic!("{}", crate::exchange_errors::not_supported(format!("{}{}", self.id.clone(), Value::Str(" fetchPositionsRisk() is not supported yet".into()))));
9629
9630 Value::Null
9631} }
9632
9633 fn fetch_positions_for_symbol(&mut self, mut symbol: Value, optional_args: &[Value]) -> impl ::std::future::Future<Output = Value> + Send { async move {
9634 let mut params = get_arg(optional_args, 0, Value::Map({
9635 let mut m = indexmap::IndexMap::new();
9636 m
9637}));
9638 panic!("{}", crate::exchange_errors::not_supported(format!("{}{}", self.id.clone(), Value::Str(" fetchPositionsForSymbol() is not supported yet".into()))));
9639
9640 Value::Null
9641} }
9642
9643 fn fetch_positions_for_symbol_ws(&mut self, mut symbol: Value, optional_args: &[Value]) -> impl ::std::future::Future<Output = Value> + Send { async move {
9644 let mut params = get_arg(optional_args, 0, Value::Map({
9645 let mut m = indexmap::IndexMap::new();
9646 m
9647}));
9648 panic!("{}", crate::exchange_errors::not_supported(format!("{}{}", self.id.clone(), Value::Str(" fetchPositionsForSymbol() is not supported yet".into()))));
9649
9650 Value::Null
9651} }
9652
9653 fn watch_position(&mut self, optional_args: &[Value]) -> impl ::std::future::Future<Output = Value> + Send { async move {
9654 let mut symbol = get_arg(optional_args, 0, Value::Null);
9655 let mut params = get_arg(optional_args, 1, Value::Map({
9656 let mut m = indexmap::IndexMap::new();
9657 m
9658}));
9659 panic!("{}", crate::exchange_errors::not_supported(format!("{}{}", self.id.clone(), Value::Str(" watchPosition() is not supported yet".into()))));
9660
9661 Value::Null
9662} }
9663
9664 fn watch_my_trades_for_symbols(&mut self, mut symbols: Value, optional_args: &[Value]) -> impl ::std::future::Future<Output = Value> + Send { async move {
9665 let mut since = get_arg(optional_args, 0, Value::Null);
9666 let mut limit = get_arg(optional_args, 1, Value::Null);
9667 let mut params = get_arg(optional_args, 2, Value::Map({
9668 let mut m = indexmap::IndexMap::new();
9669 m
9670}));
9671 panic!("{}", crate::exchange_errors::not_supported(format!("{}{}", self.id.clone(), Value::Str(" watchMyTradesForSymbols() is not supported yet".into()))));
9672
9673 Value::Null
9674} }
9675
9676 fn watch_trades_for_symbols(&mut self, mut symbols: Value, optional_args: &[Value]) -> impl ::std::future::Future<Output = Value> + Send { async move {
9677 let mut since = get_arg(optional_args, 0, Value::Null);
9678 let mut limit = get_arg(optional_args, 1, Value::Null);
9679 let mut params = get_arg(optional_args, 2, Value::Map({
9680 let mut m = indexmap::IndexMap::new();
9681 m
9682}));
9683 panic!("{}", crate::exchange_errors::not_supported(format!("{}{}", self.id.clone(), Value::Str(" watchTradesForSymbols() is not supported yet".into()))));
9684
9685 Value::Null
9686} }
9687
9688 fn fetch_bids_asks(&mut self, optional_args: &[Value]) -> impl ::std::future::Future<Output = Value> + Send { async move {
9689 let mut symbols = get_arg(optional_args, 0, Value::Null);
9690 let mut params = get_arg(optional_args, 1, Value::Map({
9691 let mut m = indexmap::IndexMap::new();
9692 m
9693}));
9694 panic!("{}", crate::exchange_errors::not_supported(format!("{}{}", self.id.clone(), Value::Str(" fetchBidsAsks() is not supported yet".into()))));
9695
9696 Value::Null
9697} }
9698
9699 fn fetch_mark_price(&mut self, mut symbol: Value, optional_args: &[Value]) -> impl ::std::future::Future<Output = Value> + Send { async move {
9700 let mut params = get_arg(optional_args, 0, Value::Map({
9701 let mut m = indexmap::IndexMap::new();
9702 m
9703}));
9704 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)) {
9705 self.load_markets(&[]).await;
9706 let mut market: Value = self.market(symbol);
9707 let mut symbolResolved: Value = market.as_map().and_then(|__m| __m.get("symbol")).cloned().unwrap_or(Value::Null);
9708 let mut tickers: Value = self.fetch_mark_prices(&[Value::from(vec![symbolResolved.clone()]), params]).await;
9709 let mut ticker: Value = self.safe_dict(tickers, symbolResolved.clone(), &[]);
9710 if (ticker == Value::Null) {
9711 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)));
9712 } else {
9713 return ticker;
9714 }
9715 } else {
9716 panic!("{}", crate::exchange_errors::not_supported(format!("{}{}", self.id.clone(), Value::Str(" fetchMarkPrices() is not supported yet".into()))));
9717 }
9718
9719 Value::Null
9720} }
9721
9722 fn fetch_mark_prices(&mut self, optional_args: &[Value]) -> impl ::std::future::Future<Output = Value> + Send { async move {
9723 let mut symbols = get_arg(optional_args, 0, Value::Null);
9724 let mut params = get_arg(optional_args, 1, Value::Map({
9725 let mut m = indexmap::IndexMap::new();
9726 m
9727}));
9728 panic!("{}", crate::exchange_errors::not_supported(format!("{}{}", self.id.clone(), Value::Str(" fetchMarkPrices() is not supported yet".into()))));
9729
9730 Value::Null
9731} }
9732
9733 fn watch_bids_asks(&mut self, optional_args: &[Value]) -> impl ::std::future::Future<Output = Value> + Send { async move {
9734 let mut symbols = get_arg(optional_args, 0, Value::Null);
9735 let mut params = get_arg(optional_args, 1, Value::Map({
9736 let mut m = indexmap::IndexMap::new();
9737 m
9738}));
9739 panic!("{}", crate::exchange_errors::not_supported(format!("{}{}", self.id.clone(), Value::Str(" watchBidsAsks() is not supported yet".into()))));
9740
9741 Value::Null
9742} }
9743
9744 fn watch_mark_price(&mut self, mut symbol: Value, optional_args: &[Value]) -> impl ::std::future::Future<Output = Value> + Send { async move {
9745 let mut params = get_arg(optional_args, 0, Value::Map({
9746 let mut m = indexmap::IndexMap::new();
9747 m
9748}));
9749 panic!("{}", crate::exchange_errors::not_supported(format!("{}{}", self.id.clone(), Value::Str(" watchMarkPrice () is not supported yet".into()))));
9750
9751 Value::Null
9752} }
9753
9754 fn watch_mark_prices(&mut self, optional_args: &[Value]) -> impl ::std::future::Future<Output = Value> + Send { async move {
9755 let mut symbols = get_arg(optional_args, 0, Value::Null);
9756 let mut params = get_arg(optional_args, 1, Value::Map({
9757 let mut m = indexmap::IndexMap::new();
9758 m
9759}));
9760 panic!("{}", crate::exchange_errors::not_supported(format!("{}{}", self.id.clone(), Value::Str(" watchMarkPrices () is not supported yet".into()))));
9761
9762 Value::Null
9763} }
9764
9765 fn fetch_l3_order_book(&mut self, mut symbol: Value, optional_args: &[Value]) -> impl ::std::future::Future<Output = Value> + Send { async move {
9766 let mut limit = get_arg(optional_args, 0, Value::Null);
9767 let mut params = get_arg(optional_args, 1, Value::Map({
9768 let mut m = indexmap::IndexMap::new();
9769 m
9770}));
9771 panic!("{}", crate::exchange_errors::bad_request(format!("{}{}", self.id.clone(), Value::Str(" fetchL3OrderBook() is not supported yet".into()))));
9772
9773 Value::Null
9774} }
9775
9776 fn watch_order_book_for_symbols(&mut self, mut symbols: Value, optional_args: &[Value]) -> impl ::std::future::Future<Output = Value> + Send { async move {
9777 let mut limit = get_arg(optional_args, 0, Value::Null);
9778 let mut params = get_arg(optional_args, 1, Value::Map({
9779 let mut m = indexmap::IndexMap::new();
9780 m
9781}));
9782 panic!("{}", crate::exchange_errors::not_supported(format!("{}{}", self.id.clone(), Value::Str(" watchOrderBookForSymbols() is not supported yet".into()))));
9783
9784 Value::Null
9785} }
9786
9787 fn watch_orders_for_symbols(&mut self, mut symbols: Value, optional_args: &[Value]) -> impl ::std::future::Future<Output = Value> + Send { async move {
9788 let mut since = get_arg(optional_args, 0, Value::Null);
9789 let mut limit = get_arg(optional_args, 1, Value::Null);
9790 let mut params = get_arg(optional_args, 2, Value::Map({
9791 let mut m = indexmap::IndexMap::new();
9792 m
9793}));
9794 panic!("{}", crate::exchange_errors::not_supported(format!("{}{}", self.id.clone(), Value::Str(" watchOrdersForSymbols() is not supported yet".into()))));
9795
9796 Value::Null
9797} }
9798
9799 fn cancel_all_orders_ws(&mut self, optional_args: &[Value]) -> impl ::std::future::Future<Output = Value> + Send { async move {
9800 let mut symbol = get_arg(optional_args, 0, Value::Null);
9801 let mut params = get_arg(optional_args, 1, Value::Map({
9802 let mut m = indexmap::IndexMap::new();
9803 m
9804}));
9805 panic!("{}", crate::exchange_errors::not_supported(format!("{}{}", self.id.clone(), Value::Str(" cancelAllOrdersWs() is not supported yet".into()))));
9806
9807 Value::Null
9808} }
9809
9810 fn cancel_order_ws(&mut self, mut id: Value, optional_args: &[Value]) -> impl ::std::future::Future<Output = Value> + Send { async move {
9811 let mut symbol = get_arg(optional_args, 0, Value::Null);
9812 let mut params = get_arg(optional_args, 1, Value::Map({
9813 let mut m = indexmap::IndexMap::new();
9814 m
9815}));
9816 panic!("{}", crate::exchange_errors::not_supported(format!("{}{}", self.id.clone(), Value::Str(" cancelOrderWs() is not supported yet".into()))));
9817
9818 Value::Null
9819} }
9820
9821 fn cancel_orders_ws(&mut self, mut ids: Value, optional_args: &[Value]) -> impl ::std::future::Future<Output = Value> + Send { async move {
9822 let mut symbol = get_arg(optional_args, 0, Value::Null);
9823 let mut params = get_arg(optional_args, 1, Value::Map({
9824 let mut m = indexmap::IndexMap::new();
9825 m
9826}));
9827 panic!("{}", crate::exchange_errors::not_supported(format!("{}{}", self.id.clone(), Value::Str(" cancelOrdersWs() is not supported yet".into()))));
9828
9829 Value::Null
9830} }
9831
9832 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 {
9833 let mut params = get_arg(optional_args, 0, Value::Map({
9834 let mut m = indexmap::IndexMap::new();
9835 m
9836}));
9837 return self.create_order_ws(symbol, Value::Str("limit".into()), Value::Str("buy".into()), amount, &[price, params]).await;
9838
9839 Value::Null
9840} }
9841
9842 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 {
9843 let mut params = get_arg(optional_args, 0, Value::Map({
9844 let mut m = indexmap::IndexMap::new();
9845 m
9846}));
9847 return self.create_order_ws(symbol, Value::Str("limit".into()), side, amount, &[price, params]).await;
9848
9849 Value::Null
9850} }
9851
9852 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 {
9853 let mut params = get_arg(optional_args, 0, Value::Map({
9854 let mut m = indexmap::IndexMap::new();
9855 m
9856}));
9857 return self.create_order_ws(symbol, Value::Str("limit".into()), Value::Str("sell".into()), amount, &[price, params]).await;
9858
9859 Value::Null
9860} }
9861
9862 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 {
9863 let mut params = get_arg(optional_args, 0, Value::Map({
9864 let mut m = indexmap::IndexMap::new();
9865 m
9866}));
9867 return self.create_order_ws(symbol, Value::Str("market".into()), Value::Str("buy".into()), amount, &[Value::Null, params]).await;
9868
9869 Value::Null
9870} }
9871
9872 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 {
9873 let mut params = get_arg(optional_args, 0, Value::Map({
9874 let mut m = indexmap::IndexMap::new();
9875 m
9876}));
9877 if ((self.has.as_map().and_then(|__m| __m.get("createMarketOrderWithCostWs")).cloned().unwrap_or(Value::Null) != Value::Null) && (self.has.as_map().and_then(|__m| __m.get("createMarketOrderWithCostWs")).cloned().unwrap_or(Value::Null).as_bool() != Some(false))) || (((self.has.as_map().and_then(|__m| __m.get("createMarketBuyOrderWithCostWs")).cloned().unwrap_or(Value::Null) != Value::Null) && (self.has.as_map().and_then(|__m| __m.get("createMarketBuyOrderWithCostWs")).cloned().unwrap_or(Value::Null).as_bool() != Some(false))) && ((self.has.as_map().and_then(|__m| __m.get("createMarketSellOrderWithCostWs")).cloned().unwrap_or(Value::Null) != Value::Null) && (self.has.as_map().and_then(|__m| __m.get("createMarketSellOrderWithCostWs")).cloned().unwrap_or(Value::Null).as_bool() != Some(false)))) {
9888 return self.create_order_ws(symbol, Value::Str("market".into()), side, cost, &[Value::Int(1), params]).await;
9889 }
9890 panic!("{}", crate::exchange_errors::not_supported(format!("{}{}", self.id.clone(), Value::Str(" createMarketOrderWithCostWs() is not supported yet".into()))));
9891
9892 Value::Null
9893} }
9894
9895 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 {
9896 let mut price = get_arg(optional_args, 0, Value::Null);
9897 let mut params = get_arg(optional_args, 1, Value::Map({
9898 let mut m = indexmap::IndexMap::new();
9899 m
9900}));
9901 return self.create_order_ws(symbol, Value::Str("market".into()), side, amount, &[price, params]).await;
9902
9903 Value::Null
9904} }
9905
9906 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 {
9907 let mut params = get_arg(optional_args, 0, Value::Map({
9908 let mut m = indexmap::IndexMap::new();
9909 m
9910}));
9911 return self.create_order_ws(symbol, Value::Str("market".into()), Value::Str("sell".into()), amount, &[Value::Null, params]).await;
9912
9913 Value::Null
9914} }
9915
9916 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 {
9917 let mut price = get_arg(optional_args, 0, Value::Null);
9918 let mut takeProfit = get_arg(optional_args, 1, Value::Null);
9919 let mut stopLoss = get_arg(optional_args, 2, Value::Null);
9920 let mut params = get_arg(optional_args, 3, Value::Map({
9921 let mut m = indexmap::IndexMap::new();
9922 m
9923}));
9924 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()]);
9947 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)) {
9948 return self.create_order_ws(symbol, type_var, side, amount, &[price, paramsValue]).await;
9949 }
9950 panic!("{}", crate::exchange_errors::not_supported(format!("{}{}", self.id.clone(), Value::Str(" createOrderWithTakeProfitAndStopLossWs() is not supported yet".into()))));
9951
9952 Value::Null
9953} }
9954
9955 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 {
9956 let mut price = get_arg(optional_args, 0, Value::Null);
9957 let mut params = get_arg(optional_args, 1, Value::Map({
9958 let mut m = indexmap::IndexMap::new();
9959 m
9960}));
9961 panic!("{}", crate::exchange_errors::not_supported(format!("{}{}", self.id.clone(), Value::Str(" createOrderWs() is not supported yet".into()))));
9962
9963 Value::Null
9964} }
9965
9966 fn create_orders_ws(&mut self, mut orders: Value, optional_args: &[Value]) -> impl ::std::future::Future<Output = Value> + Send { async move {
9967 let mut params = get_arg(optional_args, 0, Value::Map({
9968 let mut m = indexmap::IndexMap::new();
9969 m
9970}));
9971 panic!("{}", crate::exchange_errors::not_supported(format!("{}{}", self.id.clone(), Value::Str(" createOrdersWs () is not supported yet".into()))));
9972
9973 Value::Null
9974} }
9975
9976 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 {
9977 let mut price = get_arg(optional_args, 0, Value::Null);
9978 let mut params = get_arg(optional_args, 1, Value::Map({
9979 let mut m = indexmap::IndexMap::new();
9980 m
9981}));
9982 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)) {
9983 panic!("{}", crate::exchange_errors::not_supported(format!("{}{}", self.id.clone(), Value::Str(" createPostOnlyOrderWs() is not supported yet".into()))));
9984 }
9985 let mut query: Value = self.extend(params, &[Value::Map({
9986 let mut m = indexmap::IndexMap::new();
9987 m.insert("postOnly".to_string(), Value::Bool(true));
9988 m
9989 })]);
9990 return self.create_order_ws(symbol, type_var, side, amount, &[price, query]).await;
9991
9992 Value::Null
9993} }
9994
9995 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 {
9996 let mut price = get_arg(optional_args, 0, Value::Null);
9997 let mut params = get_arg(optional_args, 1, Value::Map({
9998 let mut m = indexmap::IndexMap::new();
9999 m
10000}));
10001 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)) {
10002 panic!("{}", crate::exchange_errors::not_supported(format!("{}{}", self.id.clone(), Value::Str(" createReduceOnlyOrderWs() is not supported yet".into()))));
10003 }
10004 let mut query: Value = self.extend(params, &[Value::Map({
10005 let mut m = indexmap::IndexMap::new();
10006 m.insert("reduceOnly".to_string(), Value::Bool(true));
10007 m
10008 })]);
10009 return self.create_order_ws(symbol, type_var, side, amount, &[price, query]).await;
10010
10011 Value::Null
10012} }
10013
10014 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 {
10015 let mut params = get_arg(optional_args, 0, Value::Map({
10016 let mut m = indexmap::IndexMap::new();
10017 m
10018}));
10019 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)) {
10020 panic!("{}", crate::exchange_errors::not_supported(format!("{}{}", self.id.clone(), Value::Str(" createStopLimitOrderWs() is not supported yet".into()))));
10021 }
10022 let mut query: Value = self.extend(params, &[Value::Map({
10023 let mut m = indexmap::IndexMap::new();
10024 m.insert("stopPrice".to_string(), triggerPrice);
10025 m
10026 })]);
10027 return self.create_order_ws(symbol, Value::Str("limit".into()), side, amount, &[price, query]).await;
10028
10029 Value::Null
10030} }
10031
10032 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 {
10033 let mut price = get_arg(optional_args, 0, Value::Null);
10034 let mut stopLossPrice = get_arg(optional_args, 1, Value::Null);
10035 let mut params = get_arg(optional_args, 2, Value::Map({
10036 let mut m = indexmap::IndexMap::new();
10037 m
10038}));
10039 if (stopLossPrice == Value::Null) {
10053 panic!("{}", crate::exchange_errors::arguments_required(format!("{}{}", self.id.clone(), Value::Str(" createStopLossOrderWs() requires a stopLossPrice argument".into()))));
10054 }
10055 let mut paramsExtended: Value = self.extend(params, &[Value::Map({
10056 let mut m = indexmap::IndexMap::new();
10057 m.insert("stopLossPrice".to_string(), stopLossPrice);
10058 m
10059 })]);
10060 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)) {
10061 return self.create_order_ws(symbol, type_var, side, amount, &[price, paramsExtended]).await;
10062 }
10063 panic!("{}", crate::exchange_errors::not_supported(format!("{}{}", self.id.clone(), Value::Str(" createStopLossOrderWs() is not supported yet".into()))));
10064
10065 Value::Null
10066} }
10067
10068 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 {
10069 let mut params = get_arg(optional_args, 0, Value::Map({
10070 let mut m = indexmap::IndexMap::new();
10071 m
10072}));
10073 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)) {
10074 panic!("{}", crate::exchange_errors::not_supported(format!("{}{}", self.id.clone(), Value::Str(" createStopMarketOrderWs() is not supported yet".into()))));
10075 }
10076 let mut query: Value = self.extend(params, &[Value::Map({
10077 let mut m = indexmap::IndexMap::new();
10078 m.insert("stopPrice".to_string(), triggerPrice);
10079 m
10080 })]);
10081 return self.create_order_ws(symbol, Value::Str("market".into()), side, amount, &[Value::Null, query]).await;
10082
10083 Value::Null
10084} }
10085
10086 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 {
10087 let mut price = get_arg(optional_args, 0, Value::Null);
10088 let mut triggerPrice = get_arg(optional_args, 1, Value::Null);
10089 let mut params = get_arg(optional_args, 2, Value::Map({
10090 let mut m = indexmap::IndexMap::new();
10091 m
10092}));
10093 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)) {
10094 panic!("{}", crate::exchange_errors::not_supported(format!("{}{}", self.id.clone(), Value::Str(" createStopOrderWs() is not supported yet".into()))));
10095 }
10096 if (triggerPrice == Value::Null) {
10097 panic!("{}", crate::exchange_errors::arguments_required(format!("{}{}", self.id.clone(), Value::Str(" createStopOrderWs() requires a stopPrice argument".into()))));
10098 }
10099 let mut query: Value = self.extend(params, &[Value::Map({
10100 let mut m = indexmap::IndexMap::new();
10101 m.insert("stopPrice".to_string(), triggerPrice);
10102 m
10103 })]);
10104 return self.create_order_ws(symbol, type_var, side, amount, &[price, query]).await;
10105
10106 Value::Null
10107} }
10108
10109 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 {
10110 let mut price = get_arg(optional_args, 0, Value::Null);
10111 let mut takeProfitPrice = get_arg(optional_args, 1, Value::Null);
10112 let mut params = get_arg(optional_args, 2, Value::Map({
10113 let mut m = indexmap::IndexMap::new();
10114 m
10115}));
10116 if (takeProfitPrice == Value::Null) {
10130 panic!("{}", crate::exchange_errors::arguments_required(format!("{}{}", self.id.clone(), Value::Str(" createTakeProfitOrderWs() requires a takeProfitPrice argument".into()))));
10131 }
10132 let mut paramsExtended: Value = self.extend(params, &[Value::Map({
10133 let mut m = indexmap::IndexMap::new();
10134 m.insert("takeProfitPrice".to_string(), takeProfitPrice);
10135 m
10136 })]);
10137 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)) {
10138 return self.create_order_ws(symbol, type_var, side, amount, &[price, paramsExtended]).await;
10139 }
10140 panic!("{}", crate::exchange_errors::not_supported(format!("{}{}", self.id.clone(), Value::Str(" createTakeProfitOrderWs() is not supported yet".into()))));
10141
10142 Value::Null
10143} }
10144
10145 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 {
10146 let mut price = get_arg(optional_args, 0, Value::Null);
10147 let mut trailingAmount = get_arg(optional_args, 1, Value::Null);
10148 let mut trailingTriggerPrice = get_arg(optional_args, 2, Value::Null);
10149 let mut params = get_arg(optional_args, 3, Value::Map({
10150 let mut m = indexmap::IndexMap::new();
10151 m
10152}));
10153 if (trailingAmount == Value::Null) {
10168 panic!("{}", crate::exchange_errors::arguments_required(format!("{}{}", self.id.clone(), Value::Str(" createTrailingAmountOrderWs() requires a trailingAmount argument".into()))));
10169 }
10170 if let Value::Dict(__d) = &mut params { std::sync::Arc::make_mut(__d).insert("trailingAmount".into(), trailingAmount); }
10171 if (trailingTriggerPrice != Value::Null) {
10172 if let Value::Dict(__d) = &mut params { std::sync::Arc::make_mut(__d).insert("trailingTriggerPrice".into(), trailingTriggerPrice); }
10173 }
10174 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)) {
10175 return self.create_order_ws(symbol, type_var, side, amount, &[price, params]).await;
10176 }
10177 panic!("{}", crate::exchange_errors::not_supported(format!("{}{}", self.id.clone(), Value::Str(" createTrailingAmountOrderWs() is not supported yet".into()))));
10178
10179 Value::Null
10180} }
10181
10182 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 {
10183 let mut price = get_arg(optional_args, 0, Value::Null);
10184 let mut trailingPercent = get_arg(optional_args, 1, Value::Null);
10185 let mut trailingTriggerPrice = get_arg(optional_args, 2, Value::Null);
10186 let mut params = get_arg(optional_args, 3, Value::Map({
10187 let mut m = indexmap::IndexMap::new();
10188 m
10189}));
10190 if (trailingPercent == Value::Null) {
10205 panic!("{}", crate::exchange_errors::arguments_required(format!("{}{}", self.id.clone(), Value::Str(" createTrailingPercentOrderWs() requires a trailingPercent argument".into()))));
10206 }
10207 if let Value::Dict(__d) = &mut params { std::sync::Arc::make_mut(__d).insert("trailingPercent".into(), trailingPercent); }
10208 if (trailingTriggerPrice != Value::Null) {
10209 if let Value::Dict(__d) = &mut params { std::sync::Arc::make_mut(__d).insert("trailingTriggerPrice".into(), trailingTriggerPrice); }
10210 }
10211 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)) {
10212 return self.create_order_ws(symbol, type_var, side, amount, &[price, params]).await;
10213 }
10214 panic!("{}", crate::exchange_errors::not_supported(format!("{}{}", self.id.clone(), Value::Str(" createTrailingPercentOrderWs() is not supported yet".into()))));
10215
10216 Value::Null
10217} }
10218
10219 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 {
10220 let mut price = get_arg(optional_args, 0, Value::Null);
10221 let mut triggerPrice = get_arg(optional_args, 1, Value::Null);
10222 let mut params = get_arg(optional_args, 2, Value::Map({
10223 let mut m = indexmap::IndexMap::new();
10224 m
10225}));
10226 if (triggerPrice == Value::Null) {
10240 panic!("{}", crate::exchange_errors::arguments_required(format!("{}{}", self.id.clone(), Value::Str(" createTriggerOrderWs() requires a triggerPrice argument".into()))));
10241 }
10242 let mut paramsExtended: Value = self.extend(params, &[Value::Map({
10243 let mut m = indexmap::IndexMap::new();
10244 m.insert("triggerPrice".to_string(), triggerPrice);
10245 m
10246 })]);
10247 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)) {
10248 return self.create_order_ws(symbol, type_var, side, amount, &[price, paramsExtended]).await;
10249 }
10250 panic!("{}", crate::exchange_errors::not_supported(format!("{}{}", self.id.clone(), Value::Str(" createTriggerOrderWs() is not supported yet".into()))));
10251
10252 Value::Null
10253} }
10254
10255 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 {
10256 let mut amount = get_arg(optional_args, 0, Value::Null);
10257 let mut price = get_arg(optional_args, 1, Value::Null);
10258 let mut params = get_arg(optional_args, 2, Value::Map({
10259 let mut m = indexmap::IndexMap::new();
10260 m
10261}));
10262 self.cancel_order_ws(id, &[symbol.clone()]).await;
10263 return self.create_order_ws(symbol, type_var, side, amount, &[price, params]).await;
10264
10265 Value::Null
10266} }
10267
10268 fn fetch_closed_orders_ws(&mut self, optional_args: &[Value]) -> impl ::std::future::Future<Output = Value> + Send { async move {
10269 let mut symbol = get_arg(optional_args, 0, Value::Null);
10270 let mut since = get_arg(optional_args, 1, Value::Null);
10271 let mut limit = get_arg(optional_args, 2, Value::Null);
10272 let mut params = get_arg(optional_args, 3, Value::Map({
10273 let mut m = indexmap::IndexMap::new();
10274 m
10275}));
10276 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)) {
10277 let mut orders: Value = self.fetch_orders_ws(&[symbol, since, limit, params]).await;
10278 return self.filter_by(orders, Value::Str("status".into()), Value::Str("closed".into()), &[]);
10279 }
10280 panic!("{}", crate::exchange_errors::not_supported(format!("{}{}", self.id.clone(), Value::Str(" fetchClosedOrdersWs() is not supported yet".into()))));
10281
10282 Value::Null
10283} }
10284
10285 fn fetch_my_trades_ws(&mut self, optional_args: &[Value]) -> impl ::std::future::Future<Output = Value> + Send { async move {
10286 let mut symbol = get_arg(optional_args, 0, Value::Null);
10287 let mut since = get_arg(optional_args, 1, Value::Null);
10288 let mut limit = get_arg(optional_args, 2, Value::Null);
10289 let mut params = get_arg(optional_args, 3, Value::Map({
10290 let mut m = indexmap::IndexMap::new();
10291 m
10292}));
10293 panic!("{}", crate::exchange_errors::not_supported(format!("{}{}", self.id.clone(), Value::Str(" fetchMyTradesWs() is not supported yet".into()))));
10294
10295 Value::Null
10296} }
10297
10298 fn fetch_open_orders_ws(&mut self, optional_args: &[Value]) -> impl ::std::future::Future<Output = Value> + Send { async move {
10299 let mut symbol = get_arg(optional_args, 0, Value::Null);
10300 let mut since = get_arg(optional_args, 1, Value::Null);
10301 let mut limit = get_arg(optional_args, 2, Value::Null);
10302 let mut params = get_arg(optional_args, 3, Value::Map({
10303 let mut m = indexmap::IndexMap::new();
10304 m
10305}));
10306 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)) {
10307 let mut orders: Value = self.fetch_orders_ws(&[symbol, since, limit, params]).await;
10308 return self.filter_by(orders, Value::Str("status".into()), Value::Str("open".into()), &[]);
10309 }
10310 panic!("{}", crate::exchange_errors::not_supported(format!("{}{}", self.id.clone(), Value::Str(" fetchOpenOrdersWs() is not supported yet".into()))));
10311
10312 Value::Null
10313} }
10314
10315 fn fetch_order_book_ws(&mut self, mut symbol: Value, optional_args: &[Value]) -> impl ::std::future::Future<Output = Value> + Send { async move {
10316 let mut limit = get_arg(optional_args, 0, Value::Null);
10317 let mut params = get_arg(optional_args, 1, Value::Map({
10318 let mut m = indexmap::IndexMap::new();
10319 m
10320}));
10321 panic!("{}", crate::exchange_errors::not_supported(format!("{}{}", self.id.clone(), Value::Str(" fetchOrderBookWs() is not supported yet".into()))));
10322
10323 Value::Null
10324} }
10325
10326 fn fetch_order_ws(&mut self, mut id: Value, optional_args: &[Value]) -> impl ::std::future::Future<Output = Value> + Send { async move {
10327 let mut symbol = get_arg(optional_args, 0, Value::Null);
10328 let mut params = get_arg(optional_args, 1, Value::Map({
10329 let mut m = indexmap::IndexMap::new();
10330 m
10331}));
10332 panic!("{}", crate::exchange_errors::not_supported(format!("{}{}", self.id.clone(), Value::Str(" fetchOrderWs() is not supported yet".into()))));
10333
10334 Value::Null
10335} }
10336
10337 fn fetch_orders_ws(&mut self, optional_args: &[Value]) -> impl ::std::future::Future<Output = Value> + Send { async move {
10338 let mut symbol = get_arg(optional_args, 0, Value::Null);
10339 let mut since = get_arg(optional_args, 1, Value::Null);
10340 let mut limit = get_arg(optional_args, 2, Value::Null);
10341 let mut params = get_arg(optional_args, 3, Value::Map({
10342 let mut m = indexmap::IndexMap::new();
10343 m
10344}));
10345 panic!("{}", crate::exchange_errors::not_supported(format!("{}{}", self.id.clone(), Value::Str(" fetchOrdersWs() is not supported yet".into()))));
10346
10347 Value::Null
10348} }
10349
10350 fn fetch_position_ws(&mut self, mut symbol: Value, optional_args: &[Value]) -> impl ::std::future::Future<Output = Value> + Send { async move {
10351 let mut params = get_arg(optional_args, 0, Value::Map({
10352 let mut m = indexmap::IndexMap::new();
10353 m
10354}));
10355 panic!("{}", crate::exchange_errors::not_supported(format!("{}{}", self.id.clone(), Value::Str(" fetchPositionWs() is not supported yet".into()))));
10356
10357 Value::Null
10358} }
10359
10360 fn fetch_positions_ws(&mut self, optional_args: &[Value]) -> impl ::std::future::Future<Output = Value> + Send { async move {
10361 let mut symbols = get_arg(optional_args, 0, Value::Null);
10362 let mut params = get_arg(optional_args, 1, Value::Map({
10363 let mut m = indexmap::IndexMap::new();
10364 m
10365}));
10366 panic!("{}", crate::exchange_errors::not_supported(format!("{}{}", self.id.clone(), Value::Str(" fetchPositions() is not supported yet".into()))));
10367
10368 Value::Null
10369} }
10370
10371 fn fetch_ticker_ws(&mut self, mut symbol: Value, optional_args: &[Value]) -> impl ::std::future::Future<Output = Value> + Send { async move {
10372 let mut params = get_arg(optional_args, 0, Value::Map({
10373 let mut m = indexmap::IndexMap::new();
10374 m
10375}));
10376 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)) {
10377 self.load_markets(&[]).await;
10378 let mut market: Value = self.market(symbol);
10379 let mut symbolResolved: Value = market.as_map().and_then(|__m| __m.get("symbol")).cloned().unwrap_or(Value::Null);
10380 let mut tickers: Value = self.fetch_tickers_ws(&[Value::from(vec![symbolResolved.clone()]), params]).await;
10381 let mut ticker: Value = self.safe_dict(tickers, symbolResolved.clone(), &[]);
10382 if (ticker == Value::Null) {
10383 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)));
10384 } else {
10385 return ticker;
10386 }
10387 } else {
10388 panic!("{}", crate::exchange_errors::not_supported(format!("{}{}", self.id.clone(), Value::Str(" fetchTickerWs() is not supported yet".into()))));
10389 }
10390
10391 Value::Null
10392} }
10393
10394 fn fetch_tickers_ws(&mut self, optional_args: &[Value]) -> impl ::std::future::Future<Output = Value> + Send { async move {
10395 let mut symbols = get_arg(optional_args, 0, Value::Null);
10396 let mut params = get_arg(optional_args, 1, Value::Map({
10397 let mut m = indexmap::IndexMap::new();
10398 m
10399}));
10400 panic!("{}", crate::exchange_errors::not_supported(format!("{}{}", self.id.clone(), Value::Str(" fetchTickersWs() is not supported yet".into()))));
10401
10402 Value::Null
10403} }
10404
10405 fn fetch_trades_ws(&mut self, mut symbol: Value, optional_args: &[Value]) -> impl ::std::future::Future<Output = Value> + Send { async move {
10406 let mut since = get_arg(optional_args, 0, Value::Null);
10407 let mut limit = get_arg(optional_args, 1, Value::Null);
10408 let mut params = get_arg(optional_args, 2, Value::Map({
10409 let mut m = indexmap::IndexMap::new();
10410 m
10411}));
10412 panic!("{}", crate::exchange_errors::not_supported(format!("{}{}", self.id.clone(), Value::Str(" fetchTradesWs() is not supported yet".into()))));
10413
10414 Value::Null
10415} }
10416
10417
10418 fn fetch_trades(&mut self, mut symbol: Value, optional_args: &[Value]) -> impl ::std::future::Future<Output = Value> + Send { async move {
10419 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 {
10421 if !matches!(__v, crate::Value::Null) { return __v; }
10422 }
10423
10424 let mut since = get_arg(optional_args, 0, Value::Null);
10425 let mut limit = get_arg(optional_args, 1, Value::Null);
10426 let mut params = get_arg(optional_args, 2, Value::Map({
10427 let mut m = indexmap::IndexMap::new();
10428 m
10429}));
10430 panic!("{}", crate::exchange_errors::not_supported(format!("{}{}", self.id.clone(), Value::Str(" fetchTrades() is not supported yet".into()))));
10431
10432 Value::Null
10433} }
10434
10435 fn watch_trades(&mut self, mut symbol: Value, optional_args: &[Value]) -> impl ::std::future::Future<Output = Value> + Send { async move {
10436 let mut since = get_arg(optional_args, 0, Value::Null);
10437 let mut limit = get_arg(optional_args, 1, Value::Null);
10438 let mut params = get_arg(optional_args, 2, Value::Map({
10439 let mut m = indexmap::IndexMap::new();
10440 m
10441}));
10442 panic!("{}", crate::exchange_errors::not_supported(format!("{}{}", self.id.clone(), Value::Str(" watchTrades() is not supported yet".into()))));
10443
10444 Value::Null
10445} }
10446
10447 fn fetch_order_book(&mut self, mut symbol: Value, optional_args: &[Value]) -> impl ::std::future::Future<Output = Value> + Send { async move {
10448 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 {
10450 if !matches!(__v, crate::Value::Null) { return __v; }
10451 }
10452
10453 let mut limit = get_arg(optional_args, 0, Value::Null);
10454 let mut params = get_arg(optional_args, 1, Value::Map({
10455 let mut m = indexmap::IndexMap::new();
10456 m
10457}));
10458 panic!("{}", crate::exchange_errors::not_supported(format!("{}{}", self.id.clone(), Value::Str(" fetchOrderBook() is not supported yet".into()))));
10459
10460 Value::Null
10461} }
10462
10463 fn fetch_rest_order_book_safe(&mut self, mut symbol: Value, optional_args: &[Value]) -> impl ::std::future::Future<Output = Value> + Send { async move {
10464 let mut limit = get_arg(optional_args, 0, Value::Null);
10465 let mut params = get_arg(optional_args, 1, Value::Map({
10466 let mut m = indexmap::IndexMap::new();
10467 m
10468}));
10469 let mut fetchSnapshotMaxRetries: Value = self.handle_option(Value::Str("watchOrderBook".into()), Value::Str("maxRetries".into()), &[Value::Int(3)]);
10470 {
10471 let mut i: Value = Value::Int(0);
10472 let mut __for_first_180: bool = true;
10473 while { if !__for_first_180 { i = (match (&(i), &(Value::Int(1))) { (Value::Int(x), Value::Int(y)) => Value::Int(x + y), (Value::Int(x), Value::Float(y)) => Value::Float(*x as f64 + *y), (Value::Float(x), Value::Int(y)) => Value::Float(*x + *y as f64), (Value::Float(x), Value::Float(y)) => Value::Float(x + y), _ => Value::Null }); } __for_first_180 = false; i.as_f64().unwrap_or(f64::NAN) < fetchSnapshotMaxRetries.as_f64().unwrap_or(f64::NAN) } {
10474 let _try_result = futures::FutureExt::catch_unwind(std::panic::AssertUnwindSafe(async {
10475 let mut orderBook: Value = self.fetch_order_book(symbol.clone(), &[limit.clone(), params.clone()]).await;
10476 return orderBook;
10477 #[allow(unreachable_code)] { Value::Null }})).await;
10478match _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);
10479 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) {
10480 panic!("{}", e);
10481 }
10482 } }
10483 }
10484 }
10485 return Value::Null;
10486
10487 Value::Null
10488} }
10489
10490 fn watch_order_book(&mut self, mut symbol: Value, optional_args: &[Value]) -> impl ::std::future::Future<Output = Value> + Send { async move {
10491 let mut limit = get_arg(optional_args, 0, Value::Null);
10492 let mut params = get_arg(optional_args, 1, Value::Map({
10493 let mut m = indexmap::IndexMap::new();
10494 m
10495}));
10496 panic!("{}", crate::exchange_errors::not_supported(format!("{}{}", self.id.clone(), Value::Str(" watchOrderBook() is not supported yet".into()))));
10497
10498 Value::Null
10499} }
10500
10501 fn fetch_open_interest(&mut self, mut symbol: Value, optional_args: &[Value]) -> impl ::std::future::Future<Output = Value> + Send { async move {
10502 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 {
10504 if !matches!(__v, crate::Value::Null) { return __v; }
10505 }
10506
10507 let mut params = get_arg(optional_args, 0, Value::Map({
10508 let mut m = indexmap::IndexMap::new();
10509 m
10510}));
10511 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)) {
10512 let mut openInterests: Value = self.fetch_open_interests(&[Value::from(vec![symbol.clone()]), params]).await;
10513 let mut openInterest: Value = self.safe_dict(openInterests, symbol, &[]);
10514 return openInterest;
10515 } else {
10516 panic!("{}", crate::exchange_errors::not_supported(format!("{}{}", self.id.clone(), Value::Str(" fetchOpenInterest() is not supported yet".into()))));
10517 }
10518
10519 Value::Null
10520} }
10521
10522 fn fetch_l2_order_book(&mut self, mut symbol: Value, optional_args: &[Value]) -> impl ::std::future::Future<Output = Value> + Send { async move {
10523 let mut limit = get_arg(optional_args, 0, Value::Null);
10524 let mut params = get_arg(optional_args, 1, Value::Map({
10525 let mut m = indexmap::IndexMap::new();
10526 m
10527}));
10528 let mut orderbook: Value = self.fetch_order_book(symbol, &[limit, params]).await;
10529 return self.extend(orderbook.clone(), &[Value::Map({
10530 let mut m = indexmap::IndexMap::new();
10531 m.insert("asks".to_string(), self.sort_by(self.aggregate(orderbook.as_map().and_then(|__m| __m.get("asks")).cloned().unwrap_or(Value::Null)), Value::Int(0), &[]));
10532 m.insert("bids".to_string(), self.sort_by(self.aggregate(orderbook.as_map().and_then(|__m| __m.get("bids")).cloned().unwrap_or(Value::Null)), Value::Int(0), &[Value::Bool(true)]));
10533 m
10534})]);
10535
10536 Value::Null
10537} }
10538
10539 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 {
10540 let mut price = get_arg(optional_args, 0, Value::Null);
10541 let mut params = get_arg(optional_args, 1, Value::Map({
10542 let mut m = indexmap::IndexMap::new();
10543 m
10544}));
10545 return self.edit_limit_order(id, symbol, Value::Str("buy".into()), amount, &[price, params]).await;
10546
10547 Value::Null
10548} }
10549
10550 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 {
10551 let mut price = get_arg(optional_args, 0, Value::Null);
10552 let mut params = get_arg(optional_args, 1, Value::Map({
10553 let mut m = indexmap::IndexMap::new();
10554 m
10555}));
10556 return self.edit_limit_order(id, symbol, Value::Str("sell".into()), amount, &[price, params]).await;
10557
10558 Value::Null
10559} }
10560
10561 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 {
10562 let mut price = get_arg(optional_args, 0, Value::Null);
10563 let mut params = get_arg(optional_args, 1, Value::Map({
10564 let mut m = indexmap::IndexMap::new();
10565 m
10566}));
10567 return self.edit_order(id, symbol, Value::Str("limit".into()), side, &[amount, price, params]).await;
10568
10569 Value::Null
10570} }
10571
10572 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 {
10573 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 {
10575 if !matches!(__v, crate::Value::Null) { return __v; }
10576 }
10577
10578 let mut amount = get_arg(optional_args, 0, Value::Null);
10579 let mut price = get_arg(optional_args, 1, Value::Null);
10580 let mut params = get_arg(optional_args, 2, Value::Map({
10581 let mut m = indexmap::IndexMap::new();
10582 m
10583}));
10584 self.cancel_order(id, &[symbol.clone()]).await;
10585 return self.create_order(symbol, type_var, side, amount, &[price, params]).await;
10586
10587 Value::Null
10588} }
10589
10590 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 {
10591 let mut amount = get_arg(optional_args, 0, Value::Null);
10592 let mut price = get_arg(optional_args, 1, Value::Null);
10593 let mut params = get_arg(optional_args, 2, Value::Map({
10594 let mut m = indexmap::IndexMap::new();
10595 m
10596}));
10597 let mut extendedParams: Value = self.extend(params, &[Value::Map({
10598 let mut m = indexmap::IndexMap::new();
10599 m.insert("clientOrderId".to_string(), clientOrderId);
10600 m
10601 })]);
10602 return self.edit_order(Value::Str("".into()), symbol, type_var, side, &[amount, price, extendedParams]).await;
10603
10604 Value::Null
10605} }
10606
10607 fn fetch_position(&mut self, mut symbol: Value, optional_args: &[Value]) -> impl ::std::future::Future<Output = Value> + Send { async move {
10608 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 {
10610 if !matches!(__v, crate::Value::Null) { return __v; }
10611 }
10612
10613 let mut params = get_arg(optional_args, 0, Value::Map({
10614 let mut m = indexmap::IndexMap::new();
10615 m
10616}));
10617 panic!("{}", crate::exchange_errors::not_supported(format!("{}{}", self.id.clone(), Value::Str(" fetchPosition() is not supported yet".into()))));
10618
10619 Value::Null
10620} }
10621
10622 fn watch_positions(&mut self, optional_args: &[Value]) -> impl ::std::future::Future<Output = Value> + Send { async move {
10623 let mut symbols = get_arg(optional_args, 0, Value::Null);
10624 let mut since = get_arg(optional_args, 1, Value::Null);
10625 let mut limit = get_arg(optional_args, 2, Value::Null);
10626 let mut params = get_arg(optional_args, 3, Value::Map({
10627 let mut m = indexmap::IndexMap::new();
10628 m
10629}));
10630 panic!("{}", crate::exchange_errors::not_supported(format!("{}{}", self.id.clone(), Value::Str(" watchPositions() is not supported yet".into()))));
10631
10632 Value::Null
10633} }
10634
10635 fn watch_position_for_symbols(&mut self, optional_args: &[Value]) -> impl ::std::future::Future<Output = Value> + Send { async move {
10636 let mut symbols = get_arg(optional_args, 0, Value::Null);
10637 let mut since = get_arg(optional_args, 1, Value::Null);
10638 let mut limit = get_arg(optional_args, 2, Value::Null);
10639 let mut params = get_arg(optional_args, 3, Value::Map({
10640 let mut m = indexmap::IndexMap::new();
10641 m
10642}));
10643 return self.watch_positions(&[symbols, since, limit, params]).await;
10644
10645 Value::Null
10646} }
10647
10648 fn fetch_positions(&mut self, optional_args: &[Value]) -> impl ::std::future::Future<Output = Value> + Send { async move {
10649 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 {
10651 if !matches!(__v, crate::Value::Null) { return __v; }
10652 }
10653
10654 let mut symbols = get_arg(optional_args, 0, Value::Null);
10655 let mut params = get_arg(optional_args, 1, Value::Map({
10656 let mut m = indexmap::IndexMap::new();
10657 m
10658}));
10659 panic!("{}", crate::exchange_errors::not_supported(format!("{}{}", self.id.clone(), Value::Str(" fetchPositions() is not supported yet".into()))));
10660
10661 Value::Null
10662} }
10663
10664 fn fetch_ticker(&mut self, mut symbol: Value, optional_args: &[Value]) -> impl ::std::future::Future<Output = Value> + Send { async move {
10665 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 {
10667 if !matches!(__v, crate::Value::Null) { return __v; }
10668 }
10669
10670 let mut params = get_arg(optional_args, 0, Value::Map({
10671 let mut m = indexmap::IndexMap::new();
10672 m
10673}));
10674 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)) {
10675 self.load_markets(&[]).await;
10676 let mut market: Value = self.market(symbol);
10677 let mut symbolResolved: Value = market.as_map().and_then(|__m| __m.get("symbol")).cloned().unwrap_or(Value::Null);
10678 let mut tickers: Value = self.fetch_tickers(&[Value::from(vec![symbolResolved.clone()]), params]).await;
10679 let mut ticker: Value = self.safe_dict(tickers, symbolResolved.clone(), &[]);
10680 if (ticker == Value::Null) {
10681 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)));
10682 } else {
10683 return ticker;
10684 }
10685 } else {
10686 panic!("{}", crate::exchange_errors::not_supported(format!("{}{}", self.id.clone(), Value::Str(" fetchTicker() is not supported yet".into()))));
10687 }
10688
10689 Value::Null
10690} }
10691
10692 fn watch_ticker(&mut self, mut symbol: Value, optional_args: &[Value]) -> impl ::std::future::Future<Output = Value> + Send { async move {
10693 let mut params = get_arg(optional_args, 0, Value::Map({
10694 let mut m = indexmap::IndexMap::new();
10695 m
10696}));
10697 panic!("{}", crate::exchange_errors::not_supported(format!("{}{}", self.id.clone(), Value::Str(" watchTicker() is not supported yet".into()))));
10698
10699 Value::Null
10700} }
10701
10702 fn fetch_tickers(&mut self, optional_args: &[Value]) -> impl ::std::future::Future<Output = Value> + Send { async move {
10703 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 {
10705 if !matches!(__v, crate::Value::Null) { return __v; }
10706 }
10707
10708 let mut symbols = get_arg(optional_args, 0, Value::Null);
10709 let mut params = get_arg(optional_args, 1, Value::Map({
10710 let mut m = indexmap::IndexMap::new();
10711 m
10712}));
10713 panic!("{}", crate::exchange_errors::not_supported(format!("{}{}", self.id.clone(), Value::Str(" fetchTickers() is not supported yet".into()))));
10714
10715 Value::Null
10716} }
10717
10718 fn watch_tickers(&mut self, optional_args: &[Value]) -> impl ::std::future::Future<Output = Value> + Send { async move {
10719 let mut symbols = get_arg(optional_args, 0, Value::Null);
10720 let mut params = get_arg(optional_args, 1, Value::Map({
10721 let mut m = indexmap::IndexMap::new();
10722 m
10723}));
10724 panic!("{}", crate::exchange_errors::not_supported(format!("{}{}", self.id.clone(), Value::Str(" watchTickers() is not supported yet".into()))));
10725
10726 Value::Null
10727} }
10728
10729 fn fetch_order(&mut self, mut id: Value, optional_args: &[Value]) -> impl ::std::future::Future<Output = Value> + Send { async move {
10730 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 {
10732 if !matches!(__v, crate::Value::Null) { return __v; }
10733 }
10734
10735 let mut symbol = get_arg(optional_args, 0, Value::Null);
10736 let mut params = get_arg(optional_args, 1, Value::Map({
10737 let mut m = indexmap::IndexMap::new();
10738 m
10739}));
10740 panic!("{}", crate::exchange_errors::not_supported(format!("{}{}", self.id.clone(), Value::Str(" fetchOrder() is not supported yet".into()))));
10741
10742 Value::Null
10743} }
10744
10745fn fetch_order_with_client_order_id(&mut self, mut clientOrderId: Value, optional_args: &[Value]) -> impl ::std::future::Future<Output = Value> + Send { async move {
10755 let mut symbol = get_arg(optional_args, 0, Value::Null);
10756 let mut params = get_arg(optional_args, 1, Value::Map({
10757 let mut m = indexmap::IndexMap::new();
10758 m
10759}));
10760 let mut extendedParams: Value = self.extend(params, &[Value::Map({
10761 let mut m = indexmap::IndexMap::new();
10762 m.insert("clientOrderId".to_string(), clientOrderId);
10763 m
10764 })]);
10765 return self.fetch_order(Value::Str("".into()), &[symbol, extendedParams]).await;
10766
10767 Value::Null
10768} }
10769
10770 fn fetch_order_status(&mut self, mut id: Value, optional_args: &[Value]) -> impl ::std::future::Future<Output = Value> + Send { async move {
10771 let mut symbol = get_arg(optional_args, 0, Value::Null);
10772 let mut params = get_arg(optional_args, 1, Value::Map({
10773 let mut m = indexmap::IndexMap::new();
10774 m
10775}));
10776 let mut order: Value = self.fetch_order(id, &[symbol, params]).await;
10779 return order.as_map().and_then(|__m| __m.get("status")).cloned().unwrap_or(Value::Null);
10780
10781 Value::Null
10782} }
10783
10784 fn fetch_unified_order(&mut self, mut order: Value, optional_args: &[Value]) -> impl ::std::future::Future<Output = Value> + Send { async move {
10785 let mut params = get_arg(optional_args, 0, Value::Map({
10786 let mut m = indexmap::IndexMap::new();
10787 m
10788}));
10789 return self.fetch_order(self.safe_string_k(order.clone(), "id", &[]), &[self.safe_string_k(order, "symbol", &[]), params]).await;
10790
10791 Value::Null
10792} }
10793
10794 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 {
10795 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 {
10797 if !matches!(__v, crate::Value::Null) { return __v; }
10798 }
10799
10800 let mut price = get_arg(optional_args, 0, Value::Null);
10801 let mut params = get_arg(optional_args, 1, Value::Map({
10802 let mut m = indexmap::IndexMap::new();
10803 m
10804}));
10805 panic!("{}", crate::exchange_errors::not_supported(format!("{}{}", self.id.clone(), Value::Str(" createOrder() is not supported yet".into()))));
10806
10807 Value::Null
10808} }
10809
10810 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 {
10811 let mut price = get_arg(optional_args, 0, Value::Null);
10812 let mut trailingAmount = get_arg(optional_args, 1, Value::Null);
10813 let mut trailingTriggerPrice = get_arg(optional_args, 2, Value::Null);
10814 let mut params = get_arg(optional_args, 3, Value::Map({
10815 let mut m = indexmap::IndexMap::new();
10816 m
10817}));
10818 if (trailingAmount == Value::Null) {
10833 panic!("{}", crate::exchange_errors::arguments_required(format!("{}{}", self.id.clone(), Value::Str(" createTrailingAmountOrder() requires a trailingAmount argument".into()))));
10834 }
10835 if let Value::Dict(__d) = &mut params { std::sync::Arc::make_mut(__d).insert("trailingAmount".into(), trailingAmount); }
10836 if (trailingTriggerPrice != Value::Null) {
10837 if let Value::Dict(__d) = &mut params { std::sync::Arc::make_mut(__d).insert("trailingTriggerPrice".into(), trailingTriggerPrice); }
10838 }
10839 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)) {
10840 return self.create_order(symbol, type_var, side, amount, &[price, params]).await;
10841 }
10842 panic!("{}", crate::exchange_errors::not_supported(format!("{}{}", self.id.clone(), Value::Str(" createTrailingAmountOrder() is not supported yet".into()))));
10843
10844 Value::Null
10845} }
10846
10847 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 {
10848 let mut price = get_arg(optional_args, 0, Value::Null);
10849 let mut trailingPercent = get_arg(optional_args, 1, Value::Null);
10850 let mut trailingTriggerPrice = get_arg(optional_args, 2, Value::Null);
10851 let mut params = get_arg(optional_args, 3, Value::Map({
10852 let mut m = indexmap::IndexMap::new();
10853 m
10854}));
10855 if (trailingPercent == Value::Null) {
10870 panic!("{}", crate::exchange_errors::arguments_required(format!("{}{}", self.id.clone(), Value::Str(" createTrailingPercentOrder() requires a trailingPercent argument".into()))));
10871 }
10872 if let Value::Dict(__d) = &mut params { std::sync::Arc::make_mut(__d).insert("trailingPercent".into(), trailingPercent); }
10873 if (trailingTriggerPrice != Value::Null) {
10874 if let Value::Dict(__d) = &mut params { std::sync::Arc::make_mut(__d).insert("trailingTriggerPrice".into(), trailingTriggerPrice); }
10875 }
10876 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)) {
10877 return self.create_order(symbol, type_var, side, amount, &[price, params]).await;
10878 }
10879 panic!("{}", crate::exchange_errors::not_supported(format!("{}{}", self.id.clone(), Value::Str(" createTrailingPercentOrder() is not supported yet".into()))));
10880
10881 Value::Null
10882} }
10883
10884 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 {
10885 let mut params = get_arg(optional_args, 0, Value::Map({
10886 let mut m = indexmap::IndexMap::new();
10887 m
10888}));
10889 if ((self.has.as_map().and_then(|__m| __m.get("createMarketOrderWithCost")).cloned().unwrap_or(Value::Null) != Value::Null) && (self.has.as_map().and_then(|__m| __m.get("createMarketOrderWithCost")).cloned().unwrap_or(Value::Null).as_bool() != Some(false))) || (((self.has.as_map().and_then(|__m| __m.get("createMarketBuyOrderWithCost")).cloned().unwrap_or(Value::Null) != Value::Null) && (self.has.as_map().and_then(|__m| __m.get("createMarketBuyOrderWithCost")).cloned().unwrap_or(Value::Null).as_bool() != Some(false))) && ((self.has.as_map().and_then(|__m| __m.get("createMarketSellOrderWithCost")).cloned().unwrap_or(Value::Null) != Value::Null) && (self.has.as_map().and_then(|__m| __m.get("createMarketSellOrderWithCost")).cloned().unwrap_or(Value::Null).as_bool() != Some(false)))) {
10900 return self.create_order(symbol, Value::Str("market".into()), side, cost, &[Value::Int(1), params]).await;
10901 }
10902 panic!("{}", crate::exchange_errors::not_supported(format!("{}{}", self.id.clone(), Value::Str(" createMarketOrderWithCost() is not supported yet".into()))));
10903
10904 Value::Null
10905} }
10906
10907 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 {
10908 let mut params = get_arg(optional_args, 0, Value::Map({
10909 let mut m = indexmap::IndexMap::new();
10910 m
10911}));
10912 if (is_equal(&self.options.as_map().and_then(|__m| __m.get("createMarketBuyOrderRequiresPrice")).cloned().unwrap_or(Value::Null), &Value::Bool(true))) || ((self.has.as_map().and_then(|__m| __m.get("createMarketBuyOrderWithCost")).cloned().unwrap_or(Value::Null) != Value::Null) && (self.has.as_map().and_then(|__m| __m.get("createMarketBuyOrderWithCost")).cloned().unwrap_or(Value::Null).as_bool() != Some(false))) {
10922 return self.create_order(symbol, Value::Str("market".into()), Value::Str("buy".into()), cost, &[Value::Int(1), params]).await;
10923 }
10924 panic!("{}", crate::exchange_errors::not_supported(format!("{}{}", self.id.clone(), Value::Str(" createMarketBuyOrderWithCost() is not supported yet".into()))));
10925
10926 Value::Null
10927} }
10928
10929 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 {
10930 let mut params = get_arg(optional_args, 0, Value::Map({
10931 let mut m = indexmap::IndexMap::new();
10932 m
10933}));
10934 if (is_equal(&self.options.as_map().and_then(|__m| __m.get("createMarketSellOrderRequiresPrice")).cloned().unwrap_or(Value::Null), &Value::Bool(true))) || ((self.has.as_map().and_then(|__m| __m.get("createMarketSellOrderWithCost")).cloned().unwrap_or(Value::Null) != Value::Null) && (self.has.as_map().and_then(|__m| __m.get("createMarketSellOrderWithCost")).cloned().unwrap_or(Value::Null).as_bool() != Some(false))) {
10944 return self.create_order(symbol, Value::Str("market".into()), Value::Str("sell".into()), cost, &[Value::Int(1), params]).await;
10945 }
10946 panic!("{}", crate::exchange_errors::not_supported(format!("{}{}", self.id.clone(), Value::Str(" createMarketSellOrderWithCost() is not supported yet".into()))));
10947
10948 Value::Null
10949} }
10950
10951 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 {
10952 let mut price = get_arg(optional_args, 0, Value::Null);
10953 let mut triggerPrice = get_arg(optional_args, 1, Value::Null);
10954 let mut params = get_arg(optional_args, 2, Value::Map({
10955 let mut m = indexmap::IndexMap::new();
10956 m
10957}));
10958 if (triggerPrice == Value::Null) {
10972 panic!("{}", crate::exchange_errors::arguments_required(format!("{}{}", self.id.clone(), Value::Str(" createTriggerOrder() requires a triggerPrice argument".into()))));
10973 }
10974 let mut paramsExtended: Value = self.extend(params, &[Value::Map({
10975 let mut m = indexmap::IndexMap::new();
10976 m.insert("triggerPrice".to_string(), triggerPrice);
10977 m
10978 })]);
10979 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)) {
10980 return self.create_order(symbol, type_var, side, amount, &[price, paramsExtended]).await;
10981 }
10982 panic!("{}", crate::exchange_errors::not_supported(format!("{}{}", self.id.clone(), Value::Str(" createTriggerOrder() is not supported yet".into()))));
10983
10984 Value::Null
10985} }
10986
10987 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 {
10988 let mut price = get_arg(optional_args, 0, Value::Null);
10989 let mut stopLossPrice = get_arg(optional_args, 1, Value::Null);
10990 let mut params = get_arg(optional_args, 2, Value::Map({
10991 let mut m = indexmap::IndexMap::new();
10992 m
10993}));
10994 if (stopLossPrice == Value::Null) {
11008 panic!("{}", crate::exchange_errors::arguments_required(format!("{}{}", self.id.clone(), Value::Str(" createStopLossOrder() requires a stopLossPrice argument".into()))));
11009 }
11010 let mut paramsExtended: Value = self.extend(params, &[Value::Map({
11011 let mut m = indexmap::IndexMap::new();
11012 m.insert("stopLossPrice".to_string(), stopLossPrice);
11013 m
11014 })]);
11015 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)) {
11016 return self.create_order(symbol, type_var, side, amount, &[price, paramsExtended]).await;
11017 }
11018 panic!("{}", crate::exchange_errors::not_supported(format!("{}{}", self.id.clone(), Value::Str(" createStopLossOrder() is not supported yet".into()))));
11019
11020 Value::Null
11021} }
11022
11023 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 {
11024 let mut price = get_arg(optional_args, 0, Value::Null);
11025 let mut takeProfitPrice = get_arg(optional_args, 1, Value::Null);
11026 let mut params = get_arg(optional_args, 2, Value::Map({
11027 let mut m = indexmap::IndexMap::new();
11028 m
11029}));
11030 if (takeProfitPrice == Value::Null) {
11044 panic!("{}", crate::exchange_errors::arguments_required(format!("{}{}", self.id.clone(), Value::Str(" createTakeProfitOrder() requires a takeProfitPrice argument".into()))));
11045 }
11046 let mut paramsExtended: Value = self.extend(params, &[Value::Map({
11047 let mut m = indexmap::IndexMap::new();
11048 m.insert("takeProfitPrice".to_string(), takeProfitPrice);
11049 m
11050 })]);
11051 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)) {
11052 return self.create_order(symbol, type_var, side, amount, &[price, paramsExtended]).await;
11053 }
11054 panic!("{}", crate::exchange_errors::not_supported(format!("{}{}", self.id.clone(), Value::Str(" createTakeProfitOrder() is not supported yet".into()))));
11055
11056 Value::Null
11057} }
11058
11059 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 {
11060 let mut price = get_arg(optional_args, 0, Value::Null);
11061 let mut takeProfit = get_arg(optional_args, 1, Value::Null);
11062 let mut stopLoss = get_arg(optional_args, 2, Value::Null);
11063 let mut params = get_arg(optional_args, 3, Value::Map({
11064 let mut m = indexmap::IndexMap::new();
11065 m
11066}));
11067 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()]);
11090 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)) {
11091 return self.create_order(symbol, type_var, side, amount, &[price, paramsValue]).await;
11092 }
11093 panic!("{}", crate::exchange_errors::not_supported(format!("{}{}", self.id.clone(), Value::Str(" createOrderWithTakeProfitAndStopLoss() is not supported yet".into()))));
11094
11095 Value::Null
11096} }
11097
11098 fn create_orders(&mut self, mut orders: Value, optional_args: &[Value]) -> impl ::std::future::Future<Output = Value> + Send { async move {
11099 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 {
11101 if !matches!(__v, crate::Value::Null) { return __v; }
11102 }
11103
11104 let mut params = get_arg(optional_args, 0, Value::Map({
11105 let mut m = indexmap::IndexMap::new();
11106 m
11107}));
11108 panic!("{}", crate::exchange_errors::not_supported(format!("{}{}", self.id.clone(), Value::Str(" createOrders() is not supported yet".into()))));
11109
11110 Value::Null
11111} }
11112
11113 fn cancel_order(&mut self, mut id: Value, optional_args: &[Value]) -> impl ::std::future::Future<Output = Value> + Send { async move {
11114 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 {
11116 if !matches!(__v, crate::Value::Null) { return __v; }
11117 }
11118
11119 let mut symbol = get_arg(optional_args, 0, Value::Null);
11120 let mut params = get_arg(optional_args, 1, Value::Map({
11121 let mut m = indexmap::IndexMap::new();
11122 m
11123}));
11124 panic!("{}", crate::exchange_errors::not_supported(format!("{}{}", self.id.clone(), Value::Str(" cancelOrder() is not supported yet".into()))));
11125
11126 Value::Null
11127} }
11128
11129fn cancel_order_with_client_order_id(&mut self, mut clientOrderId: Value, optional_args: &[Value]) -> impl ::std::future::Future<Output = Value> + Send { async move {
11139 let mut symbol = get_arg(optional_args, 0, Value::Null);
11140 let mut params = get_arg(optional_args, 1, Value::Map({
11141 let mut m = indexmap::IndexMap::new();
11142 m
11143}));
11144 let mut extendedParams: Value = self.extend(params, &[Value::Map({
11145 let mut m = indexmap::IndexMap::new();
11146 m.insert("clientOrderId".to_string(), clientOrderId);
11147 m
11148 })]);
11149 return self.cancel_order(Value::Str("".into()), &[symbol, extendedParams]).await;
11150
11151 Value::Null
11152} }
11153
11154 fn cancel_orders(&mut self, mut ids: Value, optional_args: &[Value]) -> impl ::std::future::Future<Output = Value> + Send { async move {
11155 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 {
11157 if !matches!(__v, crate::Value::Null) { return __v; }
11158 }
11159
11160 let mut symbol = get_arg(optional_args, 0, Value::Null);
11161 let mut params = get_arg(optional_args, 1, Value::Map({
11162 let mut m = indexmap::IndexMap::new();
11163 m
11164}));
11165 panic!("{}", crate::exchange_errors::not_supported(format!("{}{}", self.id.clone(), Value::Str(" cancelOrders() is not supported yet".into()))));
11166
11167 Value::Null
11168} }
11169
11170fn cancel_orders_with_client_order_ids(&mut self, mut clientOrderIds: Value, optional_args: &[Value]) -> impl ::std::future::Future<Output = Value> + Send { async move {
11180 let mut symbol = get_arg(optional_args, 0, Value::Null);
11181 let mut params = get_arg(optional_args, 1, Value::Map({
11182 let mut m = indexmap::IndexMap::new();
11183 m
11184}));
11185 let mut extendedParams: Value = self.extend(params, &[Value::Map({
11186 let mut m = indexmap::IndexMap::new();
11187 m.insert("clientOrderIds".to_string(), clientOrderIds);
11188 m
11189 })]);
11190 return self.cancel_orders(Value::from(vec![]), &[symbol, extendedParams]).await;
11191
11192 Value::Null
11193} }
11194
11195 fn cancel_all_orders(&mut self, optional_args: &[Value]) -> impl ::std::future::Future<Output = Value> + Send { async move {
11196 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 {
11198 if !matches!(__v, crate::Value::Null) { return __v; }
11199 }
11200
11201 let mut symbol = get_arg(optional_args, 0, Value::Null);
11202 let mut params = get_arg(optional_args, 1, Value::Map({
11203 let mut m = indexmap::IndexMap::new();
11204 m
11205}));
11206 panic!("{}", crate::exchange_errors::not_supported(format!("{}{}", self.id.clone(), Value::Str(" cancelAllOrders() is not supported yet".into()))));
11207
11208 Value::Null
11209} }
11210
11211 fn cancel_unified_order(&mut self, mut order: Value, optional_args: &[Value]) -> impl ::std::future::Future<Output = Value> + Send { async move {
11212 let mut params = get_arg(optional_args, 0, Value::Map({
11213 let mut m = indexmap::IndexMap::new();
11214 m
11215}));
11216 return self.cancel_order(self.safe_string_k(order.clone(), "id", &[]), &[self.safe_string_k(order, "symbol", &[]), params]).await;
11217
11218 Value::Null
11219} }
11220
11221 fn fetch_orders(&mut self, optional_args: &[Value]) -> impl ::std::future::Future<Output = Value> + Send { async move {
11222 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 {
11224 if !matches!(__v, crate::Value::Null) { return __v; }
11225 }
11226
11227 let mut symbol = get_arg(optional_args, 0, Value::Null);
11228 let mut since = get_arg(optional_args, 1, Value::Null);
11229 let mut limit = get_arg(optional_args, 2, Value::Null);
11230 let mut params = get_arg(optional_args, 3, Value::Map({
11231 let mut m = indexmap::IndexMap::new();
11232 m
11233}));
11234 if ((self.has.as_map().and_then(|__m| __m.get("fetchOpenOrders")).cloned().unwrap_or(Value::Null) != Value::Null) && (self.has.as_map().and_then(|__m| __m.get("fetchOpenOrders")).cloned().unwrap_or(Value::Null).as_bool() != Some(false))) && ((self.has.as_map().and_then(|__m| __m.get("fetchClosedOrders")).cloned().unwrap_or(Value::Null) != Value::Null) && (self.has.as_map().and_then(|__m| __m.get("fetchClosedOrders")).cloned().unwrap_or(Value::Null).as_bool() != Some(false))) {
11235 panic!("{}", crate::exchange_errors::not_supported(format!("{}{}", self.id.clone(), Value::Str(" fetchOrders() is not supported yet, consider using fetchOpenOrders() and fetchClosedOrders() instead".into()))));
11236 }
11237 panic!("{}", crate::exchange_errors::not_supported(format!("{}{}", self.id.clone(), Value::Str(" fetchOrders() is not supported yet".into()))));
11238
11239 Value::Null
11240} }
11241
11242 fn fetch_order_trades(&mut self, mut id: Value, optional_args: &[Value]) -> impl ::std::future::Future<Output = Value> + Send { async move {
11243 let mut symbol = get_arg(optional_args, 0, Value::Null);
11244 let mut since = get_arg(optional_args, 1, Value::Null);
11245 let mut limit = get_arg(optional_args, 2, Value::Null);
11246 let mut params = get_arg(optional_args, 3, Value::Map({
11247 let mut m = indexmap::IndexMap::new();
11248 m
11249}));
11250 panic!("{}", crate::exchange_errors::not_supported(format!("{}{}", self.id.clone(), Value::Str(" fetchOrderTrades() is not supported yet".into()))));
11251
11252 Value::Null
11253} }
11254
11255 fn watch_orders(&mut self, optional_args: &[Value]) -> impl ::std::future::Future<Output = Value> + Send { async move {
11256 let mut symbol = get_arg(optional_args, 0, Value::Null);
11257 let mut since = get_arg(optional_args, 1, Value::Null);
11258 let mut limit = get_arg(optional_args, 2, Value::Null);
11259 let mut params = get_arg(optional_args, 3, Value::Map({
11260 let mut m = indexmap::IndexMap::new();
11261 m
11262}));
11263 panic!("{}", crate::exchange_errors::not_supported(format!("{}{}", self.id.clone(), Value::Str(" watchOrders() is not supported yet".into()))));
11264
11265 Value::Null
11266} }
11267
11268 fn fetch_open_orders(&mut self, optional_args: &[Value]) -> impl ::std::future::Future<Output = Value> + Send { async move {
11269 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 {
11271 if !matches!(__v, crate::Value::Null) { return __v; }
11272 }
11273
11274 let mut symbol = get_arg(optional_args, 0, Value::Null);
11275 let mut since = get_arg(optional_args, 1, Value::Null);
11276 let mut limit = get_arg(optional_args, 2, Value::Null);
11277 let mut params = get_arg(optional_args, 3, Value::Map({
11278 let mut m = indexmap::IndexMap::new();
11279 m
11280}));
11281 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)) {
11282 let mut orders: Value = self.fetch_orders(&[symbol, since, limit, params]).await;
11283 return self.filter_by(orders, Value::Str("status".into()), Value::Str("open".into()), &[]);
11284 }
11285 panic!("{}", crate::exchange_errors::not_supported(format!("{}{}", self.id.clone(), Value::Str(" fetchOpenOrders() is not supported yet".into()))));
11286
11287 Value::Null
11288} }
11289
11290 fn fetch_closed_orders(&mut self, optional_args: &[Value]) -> impl ::std::future::Future<Output = Value> + Send { async move {
11291 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 {
11293 if !matches!(__v, crate::Value::Null) { return __v; }
11294 }
11295
11296 let mut symbol = get_arg(optional_args, 0, Value::Null);
11297 let mut since = get_arg(optional_args, 1, Value::Null);
11298 let mut limit = get_arg(optional_args, 2, Value::Null);
11299 let mut params = get_arg(optional_args, 3, Value::Map({
11300 let mut m = indexmap::IndexMap::new();
11301 m
11302}));
11303 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)) {
11304 let mut orders: Value = self.fetch_orders(&[symbol, since, limit, params]).await;
11305 return self.filter_by(orders, Value::Str("status".into()), Value::Str("closed".into()), &[]);
11306 }
11307 panic!("{}", crate::exchange_errors::not_supported(format!("{}{}", self.id.clone(), Value::Str(" fetchClosedOrders() is not supported yet".into()))));
11308
11309 Value::Null
11310} }
11311
11312 fn fetch_canceled_orders(&mut self, optional_args: &[Value]) -> impl ::std::future::Future<Output = Value> + Send { async move {
11313 let mut symbol = get_arg(optional_args, 0, Value::Null);
11314 let mut since = get_arg(optional_args, 1, Value::Null);
11315 let mut limit = get_arg(optional_args, 2, Value::Null);
11316 let mut params = get_arg(optional_args, 3, Value::Map({
11317 let mut m = indexmap::IndexMap::new();
11318 m
11319}));
11320 panic!("{}", crate::exchange_errors::not_supported(format!("{}{}", self.id.clone(), Value::Str(" fetchCanceledOrders() is not supported yet".into()))));
11321
11322 Value::Null
11323} }
11324
11325 fn fetch_my_trades(&mut self, optional_args: &[Value]) -> impl ::std::future::Future<Output = Value> + Send { async move {
11326 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 {
11328 if !matches!(__v, crate::Value::Null) { return __v; }
11329 }
11330
11331 let mut symbol = get_arg(optional_args, 0, Value::Null);
11332 let mut since = get_arg(optional_args, 1, Value::Null);
11333 let mut limit = get_arg(optional_args, 2, Value::Null);
11334 let mut params = get_arg(optional_args, 3, Value::Map({
11335 let mut m = indexmap::IndexMap::new();
11336 m
11337}));
11338 panic!("{}", crate::exchange_errors::not_supported(format!("{}{}", self.id.clone(), Value::Str(" fetchMyTrades() is not supported yet".into()))));
11339
11340 Value::Null
11341} }
11342
11343 fn watch_my_trades(&mut self, optional_args: &[Value]) -> impl ::std::future::Future<Output = Value> + Send { async move {
11344 let mut symbol = get_arg(optional_args, 0, Value::Null);
11345 let mut since = get_arg(optional_args, 1, Value::Null);
11346 let mut limit = get_arg(optional_args, 2, Value::Null);
11347 let mut params = get_arg(optional_args, 3, Value::Map({
11348 let mut m = indexmap::IndexMap::new();
11349 m
11350}));
11351 panic!("{}", crate::exchange_errors::not_supported(format!("{}{}", self.id.clone(), Value::Str(" watchMyTrades() is not supported yet".into()))));
11352
11353 Value::Null
11354} }
11355
11356 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 {
11357 let mut params = get_arg(optional_args, 0, Value::Map({
11358 let mut m = indexmap::IndexMap::new();
11359 m
11360}));
11361 return self.create_order(symbol, Value::Str("limit".into()), side, amount, &[price, params]).await;
11362
11363 Value::Null
11364} }
11365
11366 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 {
11367 let mut price = get_arg(optional_args, 0, Value::Null);
11368 let mut params = get_arg(optional_args, 1, Value::Map({
11369 let mut m = indexmap::IndexMap::new();
11370 m
11371}));
11372 return self.create_order(symbol, Value::Str("market".into()), side, amount, &[price, params]).await;
11373
11374 Value::Null
11375} }
11376
11377 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 {
11378 let mut params = get_arg(optional_args, 0, Value::Map({
11379 let mut m = indexmap::IndexMap::new();
11380 m
11381}));
11382 return self.create_order(symbol, Value::Str("limit".into()), Value::Str("buy".into()), amount, &[price, params]).await;
11383
11384 Value::Null
11385} }
11386
11387 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 {
11388 let mut params = get_arg(optional_args, 0, Value::Map({
11389 let mut m = indexmap::IndexMap::new();
11390 m
11391}));
11392 return self.create_order(symbol, Value::Str("limit".into()), Value::Str("sell".into()), amount, &[price, params]).await;
11393
11394 Value::Null
11395} }
11396
11397 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 {
11398 let mut params = get_arg(optional_args, 0, Value::Map({
11399 let mut m = indexmap::IndexMap::new();
11400 m
11401}));
11402 return self.create_order(symbol, Value::Str("market".into()), Value::Str("buy".into()), amount, &[Value::Null, params]).await;
11403
11404 Value::Null
11405} }
11406
11407 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 {
11408 let mut params = get_arg(optional_args, 0, Value::Map({
11409 let mut m = indexmap::IndexMap::new();
11410 m
11411}));
11412 return self.create_order(symbol, Value::Str("market".into()), Value::Str("sell".into()), amount, &[Value::Null, params]).await;
11413
11414 Value::Null
11415} }
11416
11417 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 {
11418 let mut price = 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 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)) {
11424 panic!("{}", crate::exchange_errors::not_supported(format!("{}{}", self.id.clone(), Value::Str(" createPostOnlyOrder() is not supported yet".into()))));
11425 }
11426 let mut query: Value = self.extend(params, &[Value::Map({
11427 let mut m = indexmap::IndexMap::new();
11428 m.insert("postOnly".to_string(), Value::Bool(true));
11429 m
11430 })]);
11431 return self.create_order(symbol, type_var, side, amount, &[price, query]).await;
11432
11433 Value::Null
11434} }
11435
11436 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 {
11437 let mut price = get_arg(optional_args, 0, Value::Null);
11438 let mut params = get_arg(optional_args, 1, Value::Map({
11439 let mut m = indexmap::IndexMap::new();
11440 m
11441}));
11442 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)) {
11443 panic!("{}", crate::exchange_errors::not_supported(format!("{}{}", self.id.clone(), Value::Str(" createReduceOnlyOrder() is not supported yet".into()))));
11444 }
11445 let mut query: Value = self.extend(params, &[Value::Map({
11446 let mut m = indexmap::IndexMap::new();
11447 m.insert("reduceOnly".to_string(), Value::Bool(true));
11448 m
11449 })]);
11450 return self.create_order(symbol, type_var, side, amount, &[price, query]).await;
11451
11452 Value::Null
11453} }
11454
11455 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 {
11456 let mut price = get_arg(optional_args, 0, Value::Null);
11457 let mut triggerPrice = get_arg(optional_args, 1, Value::Null);
11458 let mut params = get_arg(optional_args, 2, Value::Map({
11459 let mut m = indexmap::IndexMap::new();
11460 m
11461}));
11462 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)) {
11463 panic!("{}", crate::exchange_errors::not_supported(format!("{}{}", self.id.clone(), Value::Str(" createStopOrder() is not supported yet".into()))));
11464 }
11465 if (triggerPrice == Value::Null) {
11466 panic!("{}", crate::exchange_errors::arguments_required(format!("{}{}", self.id.clone(), Value::Str(" create_stop_order() requires a stopPrice argument".into()))));
11467 }
11468 let mut query: Value = self.extend(params, &[Value::Map({
11469 let mut m = indexmap::IndexMap::new();
11470 m.insert("stopPrice".to_string(), triggerPrice);
11471 m
11472 })]);
11473 return self.create_order(symbol, type_var, side, amount, &[price, query]).await;
11474
11475 Value::Null
11476} }
11477
11478 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 {
11479 let mut params = get_arg(optional_args, 0, Value::Map({
11480 let mut m = indexmap::IndexMap::new();
11481 m
11482}));
11483 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)) {
11484 panic!("{}", crate::exchange_errors::not_supported(format!("{}{}", self.id.clone(), Value::Str(" createStopLimitOrder() is not supported yet".into()))));
11485 }
11486 let mut query: Value = self.extend(params, &[Value::Map({
11487 let mut m = indexmap::IndexMap::new();
11488 m.insert("stopPrice".to_string(), triggerPrice);
11489 m
11490 })]);
11491 return self.create_order(symbol, Value::Str("limit".into()), side, amount, &[price, query]).await;
11492
11493 Value::Null
11494} }
11495
11496 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 {
11497 let mut params = get_arg(optional_args, 0, Value::Map({
11498 let mut m = indexmap::IndexMap::new();
11499 m
11500}));
11501 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)) {
11502 panic!("{}", crate::exchange_errors::not_supported(format!("{}{}", self.id.clone(), Value::Str(" createStopMarketOrder() is not supported yet".into()))));
11503 }
11504 let mut query: Value = self.extend(params, &[Value::Map({
11505 let mut m = indexmap::IndexMap::new();
11506 m.insert("stopPrice".to_string(), triggerPrice);
11507 m
11508 })]);
11509 return self.create_order(symbol, Value::Str("market".into()), side, amount, &[Value::Null, query]).await;
11510
11511 Value::Null
11512} }
11513
11514 fn fetch_trading_fee(&mut self, mut symbol: Value, optional_args: &[Value]) -> impl ::std::future::Future<Output = Value> + Send { async move {
11515 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 {
11517 if !matches!(__v, crate::Value::Null) { return __v; }
11518 }
11519
11520 let mut params = get_arg(optional_args, 0, Value::Map({
11521 let mut m = indexmap::IndexMap::new();
11522 m
11523}));
11524 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)) {
11525 panic!("{}", crate::exchange_errors::not_supported(format!("{}{}", self.id.clone(), Value::Str(" fetchTradingFee() is not supported yet".into()))));
11526 }
11527 let mut fees: Value = self.fetch_trading_fees(&[params]).await;
11528 let mut fee: Value = self.safe_dict(fees, symbol, &[]);
11529 return fee;
11530
11531 Value::Null
11532} }
11533 fn call_dynamic_base<'a>(&'a mut self, method: &'a str, args: Vec<crate::Value>)
11535 -> std::pin::Pin<Box<dyn std::future::Future<Output = crate::Value> + Send + 'a>>
11536 {
11537 Box::pin(async move {
11538 match method {
11539 "account" => self.account(),
11540 "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)),
11541 "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,
11542 "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)),
11543 "arrays_concat" => self.arrays_concat(args.get(0).cloned().unwrap_or(crate::Value::Null)),
11544 "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())..]),
11545 "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,
11546 "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,
11547 "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,
11548 "build_ohlcvc" => self.build_ohlcvc(args.get(0).cloned().unwrap_or(crate::Value::Null), &args[1.min(args.len())..]),
11549 "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())..]),
11550 "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())..]),
11551 "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())..]),
11552 "call_method" => self.call_method(args.get(0).cloned().unwrap_or(crate::Value::Null), &args[1.min(args.len())..]).await,
11553 "cancel_all_contract_orders" => self.cancel_all_contract_orders(&args[..]).await,
11554 "cancel_all_orders" => self.cancel_all_orders(&args[..]).await,
11555 "cancel_all_orders_after" => self.cancel_all_orders_after(args.get(0).cloned().unwrap_or(crate::Value::Null), &args[1.min(args.len())..]).await,
11556 "cancel_all_orders_ws" => self.cancel_all_orders_ws(&args[..]).await,
11557 "cancel_all_spot_orders" => self.cancel_all_spot_orders(&args[..]).await,
11558 "cancel_contract_order" => self.cancel_contract_order(args.get(0).cloned().unwrap_or(crate::Value::Null), &args[1.min(args.len())..]).await,
11559 "cancel_order" => self.cancel_order(args.get(0).cloned().unwrap_or(crate::Value::Null), &args[1.min(args.len())..]).await,
11560 "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,
11561 "cancel_order_ws" => self.cancel_order_ws(args.get(0).cloned().unwrap_or(crate::Value::Null), &args[1.min(args.len())..]).await,
11562 "cancel_orders" => self.cancel_orders(args.get(0).cloned().unwrap_or(crate::Value::Null), &args[1.min(args.len())..]).await,
11563 "cancel_orders_for_symbols" => self.cancel_orders_for_symbols(args.get(0).cloned().unwrap_or(crate::Value::Null), &args[1.min(args.len())..]).await,
11564 "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,
11565 "cancel_orders_ws" => self.cancel_orders_ws(args.get(0).cloned().unwrap_or(crate::Value::Null), &args[1.min(args.len())..]).await,
11566 "cancel_spot_order" => self.cancel_spot_order(args.get(0).cloned().unwrap_or(crate::Value::Null), &args[1.min(args.len())..]).await,
11567 "cancel_unified_order" => self.cancel_unified_order(args.get(0).cloned().unwrap_or(crate::Value::Null), &args[1.min(args.len())..]).await,
11568 "check_address" => self.check_address(&args[..]),
11569 "check_proxy_settings" => self.check_proxy_settings(&args[..]),
11570 "check_proxy_url_settings" => self.check_proxy_url_settings(&args[..]),
11571 "check_required_credentials" => self.check_required_credentials(&args[..]),
11572 "check_ws_proxy_settings" => self.check_ws_proxy_settings(),
11573 "close_all_positions" => self.close_all_positions(&args[..]).await,
11574 "close_position" => self.close_position(args.get(0).cloned().unwrap_or(crate::Value::Null), &args[1.min(args.len())..]).await,
11575 "common_currency_code" => self.common_currency_code(args.get(0).cloned().unwrap_or(crate::Value::Null)),
11576 "convert_expire_date" => self.convert_expire_date(args.get(0).cloned().unwrap_or(crate::Value::Null)),
11577 "convert_expire_date_to_market_id_date" => self.convert_expire_date_to_market_id_date(args.get(0).cloned().unwrap_or(crate::Value::Null)),
11578 "convert_market_id_expire_date" => self.convert_market_id_expire_date(args.get(0).cloned().unwrap_or(crate::Value::Null)),
11579 "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())..]),
11580 "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())..]),
11581 "convert_type_to_account" => self.convert_type_to_account(args.get(0).cloned().unwrap_or(crate::Value::Null)),
11582 "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)),
11583 "create_ccxt_trade_id" => self.create_ccxt_trade_id(&args[..]),
11584 "create_contract_orders" => self.create_contract_orders(args.get(0).cloned().unwrap_or(crate::Value::Null), &args[1.min(args.len())..]).await,
11585 "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,
11586 "create_deposit_address" => self.create_deposit_address(args.get(0).cloned().unwrap_or(crate::Value::Null), &args[1.min(args.len())..]).await,
11587 "create_expired_option_market" => <Self as crate::exchange_generated::ExchangeBase>::create_expired_option_market(self, args.get(0).cloned().unwrap_or(crate::Value::Null)),
11588 "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,
11589 "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,
11590 "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,
11591 "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,
11592 "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,
11593 "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,
11594 "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,
11595 "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,
11596 "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,
11597 "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,
11598 "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,
11599 "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,
11600 "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,
11601 "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,
11602 "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,
11603 "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,
11604 "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)),
11605 "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,
11606 "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,
11607 "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,
11608 "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,
11609 "create_orders" => self.create_orders(args.get(0).cloned().unwrap_or(crate::Value::Null), &args[1.min(args.len())..]).await,
11610 "create_orders_ws" => self.create_orders_ws(args.get(0).cloned().unwrap_or(crate::Value::Null), &args[1.min(args.len())..]).await,
11611 "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,
11612 "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,
11613 "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,
11614 "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,
11615 "create_spot_orders" => self.create_spot_orders(args.get(0).cloned().unwrap_or(crate::Value::Null), &args[1.min(args.len())..]).await,
11616 "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,
11617 "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,
11618 "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,
11619 "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,
11620 "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,
11621 "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,
11622 "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,
11623 "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,
11624 "create_sub_account" => self.create_sub_account(args.get(0).cloned().unwrap_or(crate::Value::Null), &args[1.min(args.len())..]).await,
11625 "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,
11626 "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,
11627 "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,
11628 "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,
11629 "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,
11630 "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,
11631 "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,
11632 "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,
11633 "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,
11634 "currency" => self.currency(args.get(0).cloned().unwrap_or(crate::Value::Null)),
11635 "currency_id" => self.currency_id(args.get(0).cloned().unwrap_or(crate::Value::Null)),
11636 "currency_ids" => self.currency_ids(&args[..]),
11637 "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())..]),
11638 "default_network_code" => self.default_network_code(args.get(0).cloned().unwrap_or(crate::Value::Null)),
11639 "deposit_withdraw_fee" => self.deposit_withdraw_fee(args.get(0).cloned().unwrap_or(crate::Value::Null)),
11640 "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,
11641 "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,
11642 "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,
11643 "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,
11644 "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,
11645 "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,
11646 "edit_orders" => self.edit_orders(args.get(0).cloned().unwrap_or(crate::Value::Null), &args[1.min(args.len())..]).await,
11647 "feature_value" => self.feature_value(args.get(0).cloned().unwrap_or(crate::Value::Null), &args[1.min(args.len())..]),
11648 "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())..]),
11649 "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())..]),
11650 "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)),
11651 "fetch" => self.fetch(args.get(0).cloned().unwrap_or(crate::Value::Null), &args[1.min(args.len())..]).await,
11652 "fetch2" => self.fetch2(args.get(0).cloned().unwrap_or(crate::Value::Null), &args[1.min(args.len())..]).await,
11653 "fetch_accounts" => self.fetch_accounts(&args[..]).await,
11654 "fetch_adl_rank" => self.fetch_adl_rank(args.get(0).cloned().unwrap_or(crate::Value::Null), &args[1.min(args.len())..]).await,
11655 "fetch_all_greeks" => self.fetch_all_greeks(&args[..]).await,
11656 "fetch_balance" => self.fetch_balance(&args[..]).await,
11657 "fetch_balance_ws" => self.fetch_balance_ws(&args[..]).await,
11658 "fetch_bids_asks" => self.fetch_bids_asks(&args[..]).await,
11659 "fetch_borrow_interest" => self.fetch_borrow_interest(&args[..]).await,
11660 "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,
11661 "fetch_canceled_and_closed_orders" => self.fetch_canceled_and_closed_orders(&args[..]).await,
11662 "fetch_canceled_orders" => self.fetch_canceled_orders(&args[..]).await,
11663 "fetch_closed_orders" => self.fetch_closed_orders(&args[..]).await,
11664 "fetch_closed_orders_ws" => self.fetch_closed_orders_ws(&args[..]).await,
11665 "fetch_contract_deposit_address" => self.fetch_contract_deposit_address(args.get(0).cloned().unwrap_or(crate::Value::Null), &args[1.min(args.len())..]).await,
11666 "fetch_contract_ohlcv" => self.fetch_contract_ohlcv(args.get(0).cloned().unwrap_or(crate::Value::Null), &args[1.min(args.len())..]).await,
11667 "fetch_contract_tickers" => self.fetch_contract_tickers(&args[..]).await,
11668 "fetch_convert_currencies" => self.fetch_convert_currencies(&args[..]).await,
11669 "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,
11670 "fetch_convert_trade" => self.fetch_convert_trade(args.get(0).cloned().unwrap_or(crate::Value::Null), &args[1.min(args.len())..]).await,
11671 "fetch_convert_trade_history" => self.fetch_convert_trade_history(&args[..]).await,
11672 "fetch_cross_borrow_rate" => self.fetch_cross_borrow_rate(args.get(0).cloned().unwrap_or(crate::Value::Null), &args[1.min(args.len())..]).await,
11673 "fetch_cross_borrow_rates" => self.fetch_cross_borrow_rates(&args[..]).await,
11674 "fetch_deposit_address" => self.fetch_deposit_address(args.get(0).cloned().unwrap_or(crate::Value::Null), &args[1.min(args.len())..]).await,
11675 "fetch_deposit_addresses" => self.fetch_deposit_addresses(&args[..]).await,
11676 "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,
11677 "fetch_deposit_withdraw_fee" => self.fetch_deposit_withdraw_fee(args.get(0).cloned().unwrap_or(crate::Value::Null), &args[1.min(args.len())..]).await,
11678 "fetch_deposit_withdraw_fees" => self.fetch_deposit_withdraw_fees(&args[..]).await,
11679 "fetch_deposits" => self.fetch_deposits(&args[..]).await,
11680 "fetch_deposits_withdrawals" => self.fetch_deposits_withdrawals(&args[..]).await,
11681 "fetch_deposits_ws" => self.fetch_deposits_ws(&args[..]).await,
11682 "fetch_free_balance" => self.fetch_free_balance(&args[..]).await,
11683 "fetch_funding_history" => self.fetch_funding_history(&args[..]).await,
11684 "fetch_funding_interval" => self.fetch_funding_interval(args.get(0).cloned().unwrap_or(crate::Value::Null), &args[1.min(args.len())..]).await,
11685 "fetch_funding_intervals" => self.fetch_funding_intervals(&args[..]).await,
11686 "fetch_funding_rate" => self.fetch_funding_rate(args.get(0).cloned().unwrap_or(crate::Value::Null), &args[1.min(args.len())..]).await,
11687 "fetch_funding_rate_history" => self.fetch_funding_rate_history(&args[..]).await,
11688 "fetch_funding_rates" => self.fetch_funding_rates(&args[..]).await,
11689 "fetch_greeks" => self.fetch_greeks(args.get(0).cloned().unwrap_or(crate::Value::Null), &args[1.min(args.len())..]).await,
11690 "fetch_index_ohlcv" => self.fetch_index_ohlcv(args.get(0).cloned().unwrap_or(crate::Value::Null), &args[1.min(args.len())..]).await,
11691 "fetch_isolated_borrow_rate" => self.fetch_isolated_borrow_rate(args.get(0).cloned().unwrap_or(crate::Value::Null), &args[1.min(args.len())..]).await,
11692 "fetch_isolated_borrow_rates" => self.fetch_isolated_borrow_rates(&args[..]).await,
11693 "fetch_l2_order_book" => self.fetch_l2_order_book(args.get(0).cloned().unwrap_or(crate::Value::Null), &args[1.min(args.len())..]).await,
11694 "fetch_l3_order_book" => self.fetch_l3_order_book(args.get(0).cloned().unwrap_or(crate::Value::Null), &args[1.min(args.len())..]).await,
11695 "fetch_last_prices" => self.fetch_last_prices(&args[..]).await,
11696 "fetch_ledger" => self.fetch_ledger(&args[..]).await,
11697 "fetch_ledger_entry" => self.fetch_ledger_entry(args.get(0).cloned().unwrap_or(crate::Value::Null), &args[1.min(args.len())..]).await,
11698 "fetch_leverage" => self.fetch_leverage(args.get(0).cloned().unwrap_or(crate::Value::Null), &args[1.min(args.len())..]).await,
11699 "fetch_leverage_tiers" => self.fetch_leverage_tiers(&args[..]).await,
11700 "fetch_leverages" => self.fetch_leverages(&args[..]).await,
11701 "fetch_liquidations" => self.fetch_liquidations(args.get(0).cloned().unwrap_or(crate::Value::Null), &args[1.min(args.len())..]).await,
11702 "fetch_long_short_ratio" => self.fetch_long_short_ratio(args.get(0).cloned().unwrap_or(crate::Value::Null), &args[1.min(args.len())..]).await,
11703 "fetch_long_short_ratio_history" => self.fetch_long_short_ratio_history(&args[..]).await,
11704 "fetch_margin_adjustment_history" => self.fetch_margin_adjustment_history(&args[..]).await,
11705 "fetch_margin_mode" => self.fetch_margin_mode(args.get(0).cloned().unwrap_or(crate::Value::Null), &args[1.min(args.len())..]).await,
11706 "fetch_margin_modes" => self.fetch_margin_modes(&args[..]).await,
11707 "fetch_mark_ohlcv" => self.fetch_mark_ohlcv(args.get(0).cloned().unwrap_or(crate::Value::Null), &args[1.min(args.len())..]).await,
11708 "fetch_mark_price" => self.fetch_mark_price(args.get(0).cloned().unwrap_or(crate::Value::Null), &args[1.min(args.len())..]).await,
11709 "fetch_mark_prices" => self.fetch_mark_prices(&args[..]).await,
11710 "fetch_market_leverage_tiers" => self.fetch_market_leverage_tiers(args.get(0).cloned().unwrap_or(crate::Value::Null), &args[1.min(args.len())..]).await,
11711 "fetch_my_liquidations" => self.fetch_my_liquidations(&args[..]).await,
11712 "fetch_my_trades" => self.fetch_my_trades(&args[..]).await,
11713 "fetch_my_trades_ws" => self.fetch_my_trades_ws(&args[..]).await,
11714 "fetch_ohlcv" => self.fetch_ohlcv(args.get(0).cloned().unwrap_or(crate::Value::Null), &args[1.min(args.len())..]).await,
11715 "fetch_ohlcv_ws" => self.fetch_ohlcv_ws(args.get(0).cloned().unwrap_or(crate::Value::Null), &args[1.min(args.len())..]).await,
11716 "fetch_open_interest" => self.fetch_open_interest(args.get(0).cloned().unwrap_or(crate::Value::Null), &args[1.min(args.len())..]).await,
11717 "fetch_open_interest_history" => self.fetch_open_interest_history(args.get(0).cloned().unwrap_or(crate::Value::Null), &args[1.min(args.len())..]).await,
11718 "fetch_open_interests" => self.fetch_open_interests(&args[..]).await,
11719 "fetch_open_orders" => self.fetch_open_orders(&args[..]).await,
11720 "fetch_open_orders_ws" => self.fetch_open_orders_ws(&args[..]).await,
11721 "fetch_option" => self.fetch_option(args.get(0).cloned().unwrap_or(crate::Value::Null), &args[1.min(args.len())..]).await,
11722 "fetch_option_chain" => self.fetch_option_chain(args.get(0).cloned().unwrap_or(crate::Value::Null), &args[1.min(args.len())..]).await,
11723 "fetch_order" => self.fetch_order(args.get(0).cloned().unwrap_or(crate::Value::Null), &args[1.min(args.len())..]).await,
11724 "fetch_order_book" => self.fetch_order_book(args.get(0).cloned().unwrap_or(crate::Value::Null), &args[1.min(args.len())..]).await,
11725 "fetch_order_book_ws" => self.fetch_order_book_ws(args.get(0).cloned().unwrap_or(crate::Value::Null), &args[1.min(args.len())..]).await,
11726 "fetch_order_books" => self.fetch_order_books(&args[..]).await,
11727 "fetch_order_status" => self.fetch_order_status(args.get(0).cloned().unwrap_or(crate::Value::Null), &args[1.min(args.len())..]).await,
11728 "fetch_order_trades" => self.fetch_order_trades(args.get(0).cloned().unwrap_or(crate::Value::Null), &args[1.min(args.len())..]).await,
11729 "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,
11730 "fetch_order_ws" => self.fetch_order_ws(args.get(0).cloned().unwrap_or(crate::Value::Null), &args[1.min(args.len())..]).await,
11731 "fetch_orders" => self.fetch_orders(&args[..]).await,
11732 "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,
11733 "fetch_orders_ws" => self.fetch_orders_ws(&args[..]).await,
11734 "fetch_paginated_call_cursor" => self.fetch_paginated_call_cursor(args.get(0).cloned().unwrap_or(crate::Value::Null), &args[1.min(args.len())..]).await,
11735 "fetch_paginated_call_deterministic" => self.fetch_paginated_call_deterministic(args.get(0).cloned().unwrap_or(crate::Value::Null), &args[1.min(args.len())..]).await,
11736 "fetch_paginated_call_dynamic" => self.fetch_paginated_call_dynamic(args.get(0).cloned().unwrap_or(crate::Value::Null), &args[1.min(args.len())..]).await,
11737 "fetch_paginated_call_incremental" => self.fetch_paginated_call_incremental(args.get(0).cloned().unwrap_or(crate::Value::Null), &args[1.min(args.len())..]).await,
11738 "fetch_partial_balance" => self.fetch_partial_balance(args.get(0).cloned().unwrap_or(crate::Value::Null), &args[1.min(args.len())..]).await,
11739 "fetch_payment_methods" => self.fetch_payment_methods(&args[..]).await,
11740 "fetch_position" => self.fetch_position(args.get(0).cloned().unwrap_or(crate::Value::Null), &args[1.min(args.len())..]).await,
11741 "fetch_position_adl_rank" => self.fetch_position_adl_rank(args.get(0).cloned().unwrap_or(crate::Value::Null), &args[1.min(args.len())..]).await,
11742 "fetch_position_history" => self.fetch_position_history(args.get(0).cloned().unwrap_or(crate::Value::Null), &args[1.min(args.len())..]).await,
11743 "fetch_position_mode" => self.fetch_position_mode(&args[..]).await,
11744 "fetch_position_ws" => self.fetch_position_ws(args.get(0).cloned().unwrap_or(crate::Value::Null), &args[1.min(args.len())..]).await,
11745 "fetch_positions" => self.fetch_positions(&args[..]).await,
11746 "fetch_positions_adl_rank" => self.fetch_positions_adl_rank(&args[..]).await,
11747 "fetch_positions_for_symbol" => self.fetch_positions_for_symbol(args.get(0).cloned().unwrap_or(crate::Value::Null), &args[1.min(args.len())..]).await,
11748 "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,
11749 "fetch_positions_history" => self.fetch_positions_history(&args[..]).await,
11750 "fetch_positions_risk" => self.fetch_positions_risk(&args[..]).await,
11751 "fetch_positions_ws" => self.fetch_positions_ws(&args[..]).await,
11752 "fetch_premium_index_ohlcv" => self.fetch_premium_index_ohlcv(args.get(0).cloned().unwrap_or(crate::Value::Null), &args[1.min(args.len())..]).await,
11753 "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,
11754 "fetch_spot_ohlcv" => self.fetch_spot_ohlcv(args.get(0).cloned().unwrap_or(crate::Value::Null), &args[1.min(args.len())..]).await,
11755 "fetch_spot_tickers" => self.fetch_spot_tickers(&args[..]).await,
11756 "fetch_status" => self.fetch_status(&args[..]).await,
11757 "fetch_ticker" => self.fetch_ticker(args.get(0).cloned().unwrap_or(crate::Value::Null), &args[1.min(args.len())..]).await,
11758 "fetch_ticker_ws" => self.fetch_ticker_ws(args.get(0).cloned().unwrap_or(crate::Value::Null), &args[1.min(args.len())..]).await,
11759 "fetch_tickers" => self.fetch_tickers(&args[..]).await,
11760 "fetch_tickers_ws" => self.fetch_tickers_ws(&args[..]).await,
11761 "fetch_time" => self.fetch_time(&args[..]).await,
11762 "fetch_total_balance" => self.fetch_total_balance(&args[..]).await,
11763 "fetch_trades" => self.fetch_trades(args.get(0).cloned().unwrap_or(crate::Value::Null), &args[1.min(args.len())..]).await,
11764 "fetch_trades_ws" => self.fetch_trades_ws(args.get(0).cloned().unwrap_or(crate::Value::Null), &args[1.min(args.len())..]).await,
11765 "fetch_trading_fee" => self.fetch_trading_fee(args.get(0).cloned().unwrap_or(crate::Value::Null), &args[1.min(args.len())..]).await,
11766 "fetch_trading_fees" => self.fetch_trading_fees(&args[..]).await,
11767 "fetch_trading_fees_ws" => self.fetch_trading_fees_ws(&args[..]).await,
11768 "fetch_trading_limits" => self.fetch_trading_limits(&args[..]).await,
11769 "fetch_transaction_fee" => self.fetch_transaction_fee(args.get(0).cloned().unwrap_or(crate::Value::Null), &args[1.min(args.len())..]).await,
11770 "fetch_transaction_fees" => self.fetch_transaction_fees(&args[..]).await,
11771 "fetch_transactions" => self.fetch_transactions(&args[..]).await,
11772 "fetch_transfer" => self.fetch_transfer(args.get(0).cloned().unwrap_or(crate::Value::Null), &args[1.min(args.len())..]).await,
11773 "fetch_transfers" => self.fetch_transfers(&args[..]).await,
11774 "fetch_unified_order" => self.fetch_unified_order(args.get(0).cloned().unwrap_or(crate::Value::Null), &args[1.min(args.len())..]).await,
11775 "fetch_used_balance" => self.fetch_used_balance(&args[..]).await,
11776 "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,
11777 "fetch_withdrawals" => self.fetch_withdrawals(&args[..]).await,
11778 "fetch_withdrawals_ws" => self.fetch_withdrawals_ws(&args[..]).await,
11779 "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())..]),
11780 "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())..]),
11781 "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())..]),
11782 "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())..]),
11783 "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())..]),
11784 "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())..]),
11785 "filter_by_limit" => self.filter_by_limit(args.get(0).cloned().unwrap_or(crate::Value::Null), &args[1.min(args.len())..]),
11786 "filter_by_since_limit" => self.filter_by_since_limit(args.get(0).cloned().unwrap_or(crate::Value::Null), &args[1.min(args.len())..]),
11787 "filter_by_symbol" => self.filter_by_symbol(args.get(0).cloned().unwrap_or(crate::Value::Null), &args[1.min(args.len())..]),
11788 "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())..]),
11789 "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())..]),
11790 "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())..]),
11791 "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())..]),
11792 "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)),
11793 "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)),
11794 "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)),
11795 "find_timeframe" => self.find_timeframe(args.get(0).cloned().unwrap_or(crate::Value::Null), &args[1.min(args.len())..]),
11796 "force_string" => self.force_string(args.get(0).cloned().unwrap_or(crate::Value::Null)),
11797 "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)),
11798 "get_default_options" => self.get_default_options(),
11799 "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)),
11800 "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)),
11801 "get_market_from_symbols" => self.get_market_from_symbols(&args[..]),
11802 "get_supported_mapping" => self.get_supported_mapping(args.get(0).cloned().unwrap_or(crate::Value::Null), &args[1.min(args.len())..]),
11803 "get_symbols_for_market_type" => self.get_symbols_for_market_type(&args[..]),
11804 "handle_errors" => <Self as crate::exchange_generated::ExchangeBase>::handle_errors(self, args.get(0).cloned().unwrap_or(crate::Value::Null), args.get(1).cloned().unwrap_or(crate::Value::Null), args.get(2).cloned().unwrap_or(crate::Value::Null), args.get(3).cloned().unwrap_or(crate::Value::Null), args.get(4).cloned().unwrap_or(crate::Value::Null), args.get(5).cloned().unwrap_or(crate::Value::Null), args.get(6).cloned().unwrap_or(crate::Value::Null), args.get(7).cloned().unwrap_or(crate::Value::Null), args.get(8).cloned().unwrap_or(crate::Value::Null)),
11805 "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())..]),
11806 "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())..]),
11807 "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())..]),
11808 "handle_network_code_and_params" => self.handle_network_code_and_params(args.get(0).cloned().unwrap_or(crate::Value::Null)),
11809 "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())..]),
11810 "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())..]),
11811 "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())..]),
11812 "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())..]),
11813 "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())..]),
11814 "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())..]),
11815 "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())..]),
11816 "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())..]),
11817 "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())..]),
11818 "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())..]),
11819 "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())..]),
11820 "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())..]),
11821 "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())..]),
11822 "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())..]),
11823 "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())..]),
11824 "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())..]),
11825 "handle_request_network" => self.handle_request_network(args.get(0).cloned().unwrap_or(crate::Value::Null), args.get(1).cloned().unwrap_or(crate::Value::Null), args.get(2).cloned().unwrap_or(crate::Value::Null), &args[3.min(args.len())..]),
11826 "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())..]),
11827 "handle_time_in_force" => self.handle_time_in_force(&args[..]),
11828 "handle_trigger_and_params" => self.handle_trigger_and_params(args.get(0).cloned().unwrap_or(crate::Value::Null)),
11829 "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())..]),
11830 "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())..]),
11831 "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())..]),
11832 "handle_withdraw_tag_and_params" => self.handle_withdraw_tag_and_params(args.get(0).cloned().unwrap_or(crate::Value::Null), args.get(1).cloned().unwrap_or(crate::Value::Null)),
11833 "implode_hostname" => self.implode_hostname(args.get(0).cloned().unwrap_or(crate::Value::Null)),
11834 "incrementing_nonce" => self.incrementing_nonce(),
11835 "integer_precision_to_amount" => self.integer_precision_to_amount(args.get(0).cloned().unwrap_or(crate::Value::Null)),
11836 "invert_flat_string_dictionary" => self.invert_flat_string_dictionary(args.get(0).cloned().unwrap_or(crate::Value::Null)),
11837 "is_empty_string" => self.is_empty_string(args.get(0).cloned().unwrap_or(crate::Value::Null)),
11838 "is_leveraged_currency" => self.is_leveraged_currency(args.get(0).cloned().unwrap_or(crate::Value::Null), &args[1.min(args.len())..]),
11839 "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())..]),
11840 "is_round_number" => self.is_round_number(args.get(0).cloned().unwrap_or(crate::Value::Null)),
11841 "is_significant_precision" => self.is_significant_precision(),
11842 "is_tick_precision" => self.is_tick_precision(),
11843 "is_trigger_order" => self.is_trigger_order(args.get(0).cloned().unwrap_or(crate::Value::Null)),
11844 "is_uta_enabled" => self.is_uta_enabled(&args[..]).await,
11845 "load_accounts" => self.load_accounts(&args[..]).await,
11846 "load_markets" => self.load_markets(&args[..]).await,
11847 "load_markets_and_sign_in" => self.load_markets_and_sign_in().await,
11848 "load_time_difference" => self.load_time_difference(&args[..]).await,
11849 "load_trading_limits" => self.load_trading_limits(&args[..]).await,
11850 "market" => self.market(args.get(0).cloned().unwrap_or(crate::Value::Null)),
11851 "market_codes" => self.market_codes(&args[..]),
11852 "market_id" => self.market_id(args.get(0).cloned().unwrap_or(crate::Value::Null)),
11853 "market_ids" => self.market_ids(&args[..]),
11854 "market_or_null" => self.market_or_null(&args[..]),
11855 "market_symbols" => self.market_symbols(&args[..]),
11856 "markets_for_symbols" => self.markets_for_symbols(&args[..]),
11857 "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)),
11858 "network_code_to_id" => self.network_code_to_id(args.get(0).cloned().unwrap_or(crate::Value::Null), &args[1.min(args.len())..]),
11859 "network_id_to_code" => self.network_id_to_code(&args[..]),
11860 "nonce" => <Self as crate::exchange_generated::ExchangeBase>::nonce(self),
11861 "oath" => self.oath(),
11862 "orderbook_checksum_message" => self.orderbook_checksum_message(args.get(0).cloned().unwrap_or(crate::Value::Null)),
11863 "parse_account" => <Self as crate::exchange_generated::ExchangeBase>::parse_account(self, args.get(0).cloned().unwrap_or(crate::Value::Null)),
11864 "parse_accounts" => self.parse_accounts(args.get(0).cloned().unwrap_or(crate::Value::Null), &args[1.min(args.len())..]),
11865 "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())..]),
11866 "parse_adl_ranks" => self.parse_adl_ranks(args.get(0).cloned().unwrap_or(crate::Value::Null), &args[1.min(args.len())..]),
11867 "parse_all_greeks" => self.parse_all_greeks(args.get(0).cloned().unwrap_or(crate::Value::Null), &args[1.min(args.len())..]),
11868 "parse_balance" => <Self as crate::exchange_generated::ExchangeBase>::parse_balance(self, args.get(0).cloned().unwrap_or(crate::Value::Null)),
11869 "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())..]),
11870 "parse_borrow_interests" => self.parse_borrow_interests(args.get(0).cloned().unwrap_or(crate::Value::Null), &args[1.min(args.len())..]),
11871 "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())..]),
11872 "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)),
11873 "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())..]),
11874 "parse_conversions" => self.parse_conversions(args.get(0).cloned().unwrap_or(crate::Value::Null), &args[1.min(args.len())..]),
11875 "parse_currencies" => self.parse_currencies(args.get(0).cloned().unwrap_or(crate::Value::Null)),
11876 "parse_currency" => <Self as crate::exchange_generated::ExchangeBase>::parse_currency(self, args.get(0).cloned().unwrap_or(crate::Value::Null)),
11877 "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())..]),
11878 "parse_deposit_addresses" => self.parse_deposit_addresses(args.get(0).cloned().unwrap_or(crate::Value::Null), &args[1.min(args.len())..]),
11879 "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())..]),
11880 "parse_deposit_withdraw_fees" => self.parse_deposit_withdraw_fees(args.get(0).cloned().unwrap_or(crate::Value::Null), &args[1.min(args.len())..]),
11881 "parse_fee_numeric" => self.parse_fee_numeric(args.get(0).cloned().unwrap_or(crate::Value::Null)),
11882 "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())..]),
11883 "parse_funding_rate_histories" => self.parse_funding_rate_histories(args.get(0).cloned().unwrap_or(crate::Value::Null), &args[1.min(args.len())..]),
11884 "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())..]),
11885 "parse_funding_rates" => self.parse_funding_rates(args.get(0).cloned().unwrap_or(crate::Value::Null), &args[1.min(args.len())..]),
11886 "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())..]),
11887 "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())..]),
11888 "parse_incomes" => self.parse_incomes(args.get(0).cloned().unwrap_or(crate::Value::Null), &args[1.min(args.len())..]),
11889 "parse_isolated_borrow_rate" => self.parse_isolated_borrow_rate(args.get(0).cloned().unwrap_or(crate::Value::Null), &args[1.min(args.len())..]),
11890 "parse_isolated_borrow_rates" => self.parse_isolated_borrow_rates(args.get(0).cloned().unwrap_or(crate::Value::Null)),
11891 "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())..]),
11892 "parse_last_prices" => self.parse_last_prices(args.get(0).cloned().unwrap_or(crate::Value::Null), &args[1.min(args.len())..]),
11893 "parse_ledger" => self.parse_ledger(args.get(0).cloned().unwrap_or(crate::Value::Null), &args[1.min(args.len())..]),
11894 "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())..]),
11895 "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())..]),
11896 "parse_leverage_tiers" => self.parse_leverage_tiers(args.get(0).cloned().unwrap_or(crate::Value::Null), &args[1.min(args.len())..]),
11897 "parse_leverages" => self.parse_leverages(args.get(0).cloned().unwrap_or(crate::Value::Null), &args[1.min(args.len())..]),
11898 "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())..]),
11899 "parse_liquidations" => self.parse_liquidations(args.get(0).cloned().unwrap_or(crate::Value::Null), &args[1.min(args.len())..]),
11900 "parse_long_short_ratio" => self.parse_long_short_ratio(args.get(0).cloned().unwrap_or(crate::Value::Null), &args[1.min(args.len())..]),
11901 "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())..]),
11902 "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())..]),
11903 "parse_margin_modes" => self.parse_margin_modes(args.get(0).cloned().unwrap_or(crate::Value::Null), &args[1.min(args.len())..]),
11904 "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())..]),
11905 "parse_margin_modifications" => self.parse_margin_modifications(args.get(0).cloned().unwrap_or(crate::Value::Null), &args[1.min(args.len())..]),
11906 "parse_market" => <Self as crate::exchange_generated::ExchangeBase>::parse_market(self, args.get(0).cloned().unwrap_or(crate::Value::Null)),
11907 "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())..]),
11908 "parse_markets" => self.parse_markets(args.get(0).cloned().unwrap_or(crate::Value::Null)),
11909 "parse_ohlc_vs" => self.parse_ohlc_vs(args.get(0).cloned().unwrap_or(crate::Value::Null), &args[1.min(args.len())..]),
11910 "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())..]),
11911 "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())..]),
11912 "parse_open_interests" => self.parse_open_interests(args.get(0).cloned().unwrap_or(crate::Value::Null), &args[1.min(args.len())..]),
11913 "parse_open_interests_history" => self.parse_open_interests_history(args.get(0).cloned().unwrap_or(crate::Value::Null), &args[1.min(args.len())..]),
11914 "parse_option" => self.parse_option(args.get(0).cloned().unwrap_or(crate::Value::Null), &args[1.min(args.len())..]),
11915 "parse_option_chain" => self.parse_option_chain(args.get(0).cloned().unwrap_or(crate::Value::Null), &args[1.min(args.len())..]),
11916 "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())..]),
11917 "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())..]),
11918 "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())..]),
11919 "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())..]),
11920 "parse_orders" => self.parse_orders(args.get(0).cloned().unwrap_or(crate::Value::Null), &args[1.min(args.len())..]),
11921 "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())..]),
11922 "parse_positions" => self.parse_positions(args.get(0).cloned().unwrap_or(crate::Value::Null), &args[1.min(args.len())..]),
11923 "parse_precision" => self.parse_precision(&args[..]),
11924 "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())..]),
11925 "parse_tickers" => self.parse_tickers(args.get(0).cloned().unwrap_or(crate::Value::Null), &args[1.min(args.len())..]),
11926 "parse_to_int" => self.parse_to_int(args.get(0).cloned().unwrap_or(crate::Value::Null)),
11927 "parse_to_numeric" => self.parse_to_numeric(args.get(0).cloned().unwrap_or(crate::Value::Null)),
11928 "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())..]),
11929 "parse_trades" => self.parse_trades(args.get(0).cloned().unwrap_or(crate::Value::Null), &args[1.min(args.len())..]),
11930 "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())..]),
11931 "parse_trading_view_ohlcv" => self.parse_trading_view_ohlcv(args.get(0).cloned().unwrap_or(crate::Value::Null), &args[1.min(args.len())..]),
11932 "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())..]),
11933 "parse_transactions" => self.parse_transactions(args.get(0).cloned().unwrap_or(crate::Value::Null), &args[1.min(args.len())..]),
11934 "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())..]),
11935 "parse_transfers" => self.parse_transfers(args.get(0).cloned().unwrap_or(crate::Value::Null), &args[1.min(args.len())..]),
11936 "parse_ws_ohlc_vs" => self.parse_ws_ohlc_vs(args.get(0).cloned().unwrap_or(crate::Value::Null), &args[1.min(args.len())..]),
11937 "parse_ws_ohlcv" => self.parse_ws_ohlcv(args.get(0).cloned().unwrap_or(crate::Value::Null), &args[1.min(args.len())..]),
11938 "parse_ws_order" => self.parse_ws_order(args.get(0).cloned().unwrap_or(crate::Value::Null), &args[1.min(args.len())..]),
11939 "parse_ws_order_trade" => self.parse_ws_order_trade(args.get(0).cloned().unwrap_or(crate::Value::Null), &args[1.min(args.len())..]),
11940 "parse_ws_trade" => self.parse_ws_trade(args.get(0).cloned().unwrap_or(crate::Value::Null), &args[1.min(args.len())..]),
11941 "parse_ws_trades" => self.parse_ws_trades(args.get(0).cloned().unwrap_or(crate::Value::Null), &args[1.min(args.len())..]),
11942 "parsed_fee_and_fees" => self.parsed_fee_and_fees(args.get(0).cloned().unwrap_or(crate::Value::Null)),
11943 "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)),
11944 "prioritized_network_aliases" => self.prioritized_network_aliases(&args[..]),
11945 "reduce_fees_by_currency" => self.reduce_fees_by_currency(args.get(0).cloned().unwrap_or(crate::Value::Null)),
11946 "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,
11947 "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)),
11948 "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())..]),
11949 "remove_repeated_trades_from_array" => self.remove_repeated_trades_from_array(args.get(0).cloned().unwrap_or(crate::Value::Null)),
11950 "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,
11951 "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,
11952 "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,
11953 "request" => self.request(args.get(0).cloned().unwrap_or(crate::Value::Null), &args[1.min(args.len())..]).await,
11954 "require_value" => self.require_value(args.get(0).cloned().unwrap_or(crate::Value::Null), &args[1.min(args.len())..]),
11955 "resolve_path" => self.resolve_path(args.get(0).cloned().unwrap_or(crate::Value::Null), args.get(1).cloned().unwrap_or(crate::Value::Null)),
11956 "safe_balance" => self.safe_balance(args.get(0).cloned().unwrap_or(crate::Value::Null)),
11957 "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())..]),
11958 "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())..]),
11959 "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())..]),
11960 "safe_currency" => self.safe_currency(args.get(0).cloned().unwrap_or(crate::Value::Null), &args[1.min(args.len())..]),
11961 "safe_currency_code" => self.safe_currency_code(args.get(0).cloned().unwrap_or(crate::Value::Null), &args[1.min(args.len())..]),
11962 "safe_currency_structure" => self.safe_currency_structure(args.get(0).cloned().unwrap_or(crate::Value::Null)),
11963 "safe_deterministic_call" => self.safe_deterministic_call(args.get(0).cloned().unwrap_or(crate::Value::Null), &args[1.min(args.len())..]).await,
11964 "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())..]),
11965 "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())..]),
11966 "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())..]),
11967 "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())..]),
11968 "safe_ledger_entry" => self.safe_ledger_entry(args.get(0).cloned().unwrap_or(crate::Value::Null), &args[1.min(args.len())..]),
11969 "safe_liquidation" => self.safe_liquidation(args.get(0).cloned().unwrap_or(crate::Value::Null), &args[1.min(args.len())..]),
11970 "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())..]),
11971 "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())..]),
11972 "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())..]),
11973 "safe_market" => self.safe_market(&args[..]),
11974 "safe_market_structure" => self.safe_market_structure(&args[..]),
11975 "safe_network" => self.safe_network(args.get(0).cloned().unwrap_or(crate::Value::Null)),
11976 "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())..]),
11977 "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())..]),
11978 "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())..]),
11979 "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())..]),
11980 "safe_open_interest" => self.safe_open_interest(args.get(0).cloned().unwrap_or(crate::Value::Null), &args[1.min(args.len())..]),
11981 "safe_order" => self.safe_order(args.get(0).cloned().unwrap_or(crate::Value::Null), &args[1.min(args.len())..]),
11982 "safe_position" => self.safe_position(args.get(0).cloned().unwrap_or(crate::Value::Null)),
11983 "safe_symbol" => self.safe_symbol(args.get(0).cloned().unwrap_or(crate::Value::Null), &args[1.min(args.len())..]),
11984 "safe_ticker" => self.safe_ticker(args.get(0).cloned().unwrap_or(crate::Value::Null), &args[1.min(args.len())..]),
11985 "safe_trade" => self.safe_trade(args.get(0).cloned().unwrap_or(crate::Value::Null), &args[1.min(args.len())..]),
11986 "select_network_code_from_unified_networks" => self.select_network_code_from_unified_networks(args.get(0).cloned().unwrap_or(crate::Value::Null), args.get(1).cloned().unwrap_or(crate::Value::Null), args.get(2).cloned().unwrap_or(crate::Value::Null)),
11987 "select_network_id_from_raw_networks" => self.select_network_id_from_raw_networks(args.get(0).cloned().unwrap_or(crate::Value::Null), args.get(1).cloned().unwrap_or(crate::Value::Null), args.get(2).cloned().unwrap_or(crate::Value::Null)),
11988 "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())..]),
11989 "set_headers" => self.set_headers(args.get(0).cloned().unwrap_or(crate::Value::Null)),
11990 "set_leverage" => self.set_leverage(args.get(0).cloned().unwrap_or(crate::Value::Null), &args[1.min(args.len())..]).await,
11991 "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,
11992 "set_margin_mode" => self.set_margin_mode(args.get(0).cloned().unwrap_or(crate::Value::Null), &args[1.min(args.len())..]).await,
11993 "set_markets" => self.set_markets(args.get(0).cloned().unwrap_or(crate::Value::Null), &args[1.min(args.len())..]),
11994 "set_markets_from_exchange" => self.set_markets_from_exchange(args.get(0).cloned().unwrap_or(crate::Value::Null)),
11995 "set_position_mode" => self.set_position_mode(args.get(0).cloned().unwrap_or(crate::Value::Null), &args[1.min(args.len())..]).await,
11996 "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())..]),
11997 "sign" => <Self as crate::exchange_generated::ExchangeBase>::sign(self, args.get(0).cloned().unwrap_or(crate::Value::Null), &args[1.min(args.len())..]),
11998 "sign_in" => self.sign_in(&args[..]).await,
11999 "sort_cursor_paginated_result" => self.sort_cursor_paginated_result(args.get(0).cloned().unwrap_or(crate::Value::Null)),
12000 "string_to_base16" => self.string_to_base16(args.get(0).cloned().unwrap_or(crate::Value::Null)),
12001 "symbol" => self.symbol(args.get(0).cloned().unwrap_or(crate::Value::Null)),
12002 "timeframe_from_milliseconds" => self.timeframe_from_milliseconds(args.get(0).cloned().unwrap_or(crate::Value::Null)),
12003 "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,
12004 "un_watch_bids_asks" => self.un_watch_bids_asks(&args[..]).await,
12005 "un_watch_funding_rate" => self.un_watch_funding_rate(args.get(0).cloned().unwrap_or(crate::Value::Null), &args[1.min(args.len())..]).await,
12006 "un_watch_funding_rates" => self.un_watch_funding_rates(&args[..]).await,
12007 "un_watch_mark_price" => self.un_watch_mark_price(args.get(0).cloned().unwrap_or(crate::Value::Null), &args[1.min(args.len())..]).await,
12008 "un_watch_mark_prices" => self.un_watch_mark_prices(&args[..]).await,
12009 "un_watch_my_trades" => self.un_watch_my_trades(&args[..]).await,
12010 "un_watch_ohlcv" => self.un_watch_ohlcv(args.get(0).cloned().unwrap_or(crate::Value::Null), &args[1.min(args.len())..]).await,
12011 "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,
12012 "un_watch_order_book" => self.un_watch_order_book(args.get(0).cloned().unwrap_or(crate::Value::Null), &args[1.min(args.len())..]).await,
12013 "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,
12014 "un_watch_orders" => self.un_watch_orders(&args[..]).await,
12015 "un_watch_positions" => self.un_watch_positions(&args[..]).await,
12016 "un_watch_ticker" => self.un_watch_ticker(args.get(0).cloned().unwrap_or(crate::Value::Null), &args[1.min(args.len())..]).await,
12017 "un_watch_tickers" => self.un_watch_tickers(&args[..]).await,
12018 "un_watch_trades" => self.un_watch_trades(args.get(0).cloned().unwrap_or(crate::Value::Null), &args[1.min(args.len())..]).await,
12019 "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,
12020 "url_encoder_for_proxy_url" => self.url_encoder_for_proxy_url(args.get(0).cloned().unwrap_or(crate::Value::Null)),
12021 "watch_balance" => self.watch_balance(&args[..]).await,
12022 "watch_bids_asks" => self.watch_bids_asks(&args[..]).await,
12023 "watch_funding_rate" => self.watch_funding_rate(args.get(0).cloned().unwrap_or(crate::Value::Null), &args[1.min(args.len())..]).await,
12024 "watch_funding_rates" => self.watch_funding_rates(&args[..]).await,
12025 "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,
12026 "watch_liquidations" => self.watch_liquidations(args.get(0).cloned().unwrap_or(crate::Value::Null), &args[1.min(args.len())..]).await,
12027 "watch_liquidations_for_symbols" => self.watch_liquidations_for_symbols(args.get(0).cloned().unwrap_or(crate::Value::Null), &args[1.min(args.len())..]).await,
12028 "watch_mark_price" => self.watch_mark_price(args.get(0).cloned().unwrap_or(crate::Value::Null), &args[1.min(args.len())..]).await,
12029 "watch_mark_prices" => self.watch_mark_prices(&args[..]).await,
12030 "watch_my_liquidations" => self.watch_my_liquidations(args.get(0).cloned().unwrap_or(crate::Value::Null), &args[1.min(args.len())..]).await,
12031 "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,
12032 "watch_my_trades" => self.watch_my_trades(&args[..]).await,
12033 "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,
12034 "watch_ohlcv" => self.watch_ohlcv(args.get(0).cloned().unwrap_or(crate::Value::Null), &args[1.min(args.len())..]).await,
12035 "watch_ohlcv_for_symbols" => self.watch_ohlcv_for_symbols(args.get(0).cloned().unwrap_or(crate::Value::Null), &args[1.min(args.len())..]).await,
12036 "watch_order_book" => self.watch_order_book(args.get(0).cloned().unwrap_or(crate::Value::Null), &args[1.min(args.len())..]).await,
12037 "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,
12038 "watch_orders" => self.watch_orders(&args[..]).await,
12039 "watch_orders_for_symbols" => self.watch_orders_for_symbols(args.get(0).cloned().unwrap_or(crate::Value::Null), &args[1.min(args.len())..]).await,
12040 "watch_position" => self.watch_position(&args[..]).await,
12041 "watch_position_for_symbols" => self.watch_position_for_symbols(&args[..]).await,
12042 "watch_positions" => self.watch_positions(&args[..]).await,
12043 "watch_ticker" => self.watch_ticker(args.get(0).cloned().unwrap_or(crate::Value::Null), &args[1.min(args.len())..]).await,
12044 "watch_tickers" => self.watch_tickers(&args[..]).await,
12045 "watch_trades" => self.watch_trades(args.get(0).cloned().unwrap_or(crate::Value::Null), &args[1.min(args.len())..]).await,
12046 "watch_trades_for_symbols" => self.watch_trades_for_symbols(args.get(0).cloned().unwrap_or(crate::Value::Null), &args[1.min(args.len())..]).await,
12047 "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,
12048 "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,
12049 _ => {
12063 if self.internals.implicit_api.is_empty() {
12064 self.build_implicit_api();
12065 }
12066 if self.internals.implicit_api.contains_key(method) {
12067 self.call_method(crate::Value::Str(method.to_string().into()), &args[..]).await
12068 } else {
12069 self.internals.dynamic_dispatch_miss = Some(method.to_string());
12070 crate::Value::Null
12071 }
12072 }
12073 }
12074 })
12075 }
12076}