1#![allow(unused, non_snake_case, clippy::all)]
9
10use crate::Value;
11use crate::ExchangeError;
12use crate::exchange::Exchange;
13use crate::exchange::ExchangeRuntime;
14
15
16
17use crate::runtime::*;
18
19pub trait ExchangeBase:
20 crate::exchange::DerivedExchange
21 + std::ops::DerefMut<Target = Exchange>
22 + Send
23 + Sized
24{
25 fn call_dynamic<'a>(&'a mut self, method: &'a str, args: Vec<crate::Value>)
29 -> std::pin::Pin<Box<dyn std::future::Future<Output = crate::Value> + Send + 'a>>;
30
31 fn dispatch_to_derived<'a>(&'a mut self, method: &'a str, args: Vec<crate::Value>)
36 -> std::pin::Pin<Box<dyn std::future::Future<Output = Option<crate::Value>> + Send + 'a>>
37 {
38 Box::pin(async move {
39 if !self.dispatch_guard_enter(method) { return None; }
40 let out = futures::FutureExt::catch_unwind(
41 std::panic::AssertUnwindSafe(self.call_dynamic(method, args))
42 ).await;
43 self.dispatch_guard_exit();
44 match out {
45 Ok(v) => Some(v),
46 Err(p) => std::panic::resume_unwind(p),
47 }
48 })
49 }
50
51 fn is_dictionary(&self, value: crate::Value) -> crate::Value {
56 crate::Value::Bool(
57 !crate::runtime::is_equal(&value, &crate::Value::Null)
58 && crate::runtime::is_object(&value)
59 && !crate::runtime::is_array(&value)
60 )
61 }
62
63
64 fn describe(&self) -> Value {
65 return Value::Map({
66 let mut m = indexmap::IndexMap::new();
67 m.insert("id".to_string(), self.id.clone());
68 m.insert("name".to_string(), self.name.clone());
69 m.insert("countries".to_string(), self.countries.clone());
70 m.insert("enableRateLimit".to_string(), self.enableRateLimit.clone());
71 m.insert("rateLimit".to_string(), self.rateLimit.clone());
72 m.insert("rateLimiterAlgorithm".to_string(), self.rateLimiterAlgorithm.clone());
73 m.insert("timeout".to_string(), self.timeout.clone());
74 m.insert("certified".to_string(), self.certified.clone());
75 m.insert("pro".to_string(), self.pro.clone());
76 m.insert("alias".to_string(), self.alias.clone());
77 m.insert("dex".to_string(), Value::Bool(false));
78 m.insert("has".to_string(), Value::Map({
79 let mut m = indexmap::IndexMap::new();
80 m.insert("publicAPI".to_string(), Value::Bool(true));
81 m.insert("privateAPI".to_string(), Value::Bool(true));
82 m.insert("CORS".to_string(), Value::Null);
83 m.insert("sandbox".to_string(), Value::Null);
84 m.insert("spot".to_string(), Value::Null);
85 m.insert("margin".to_string(), Value::Null);
86 m.insert("swap".to_string(), Value::Null);
87 m.insert("future".to_string(), Value::Null);
88 m.insert("option".to_string(), Value::Null);
89 m.insert("index".to_string(), Value::Null);
90 m.insert("addMargin".to_string(), Value::Null);
91 m.insert("borrowCrossMargin".to_string(), Value::Null);
92 m.insert("borrowIsolatedMargin".to_string(), Value::Null);
93 m.insert("borrowMargin".to_string(), Value::Null);
94 m.insert("cancelAllOrders".to_string(), Value::Null);
95 m.insert("cancelAllOrdersWs".to_string(), Value::Null);
96 m.insert("cancelOrder".to_string(), Value::Bool(true));
97 m.insert("cancelOrderWithClientOrderId".to_string(), Value::Null);
98 m.insert("cancelOrderWs".to_string(), Value::Null);
99 m.insert("cancelOrders".to_string(), Value::Null);
100 m.insert("cancelOrdersWithClientOrderId".to_string(), Value::Null);
101 m.insert("cancelOrdersWs".to_string(), Value::Null);
102 m.insert("closeAllPositions".to_string(), Value::Null);
103 m.insert("closePosition".to_string(), Value::Null);
104 m.insert("createDepositAddress".to_string(), Value::Null);
105 m.insert("createLimitBuyOrder".to_string(), Value::Null);
106 m.insert("createLimitBuyOrderWs".to_string(), Value::Null);
107 m.insert("createLimitOrder".to_string(), Value::Bool(true));
108 m.insert("createLimitOrderWs".to_string(), Value::Null);
109 m.insert("createLimitSellOrder".to_string(), Value::Null);
110 m.insert("createLimitSellOrderWs".to_string(), Value::Null);
111 m.insert("createMarketBuyOrder".to_string(), Value::Null);
112 m.insert("createMarketBuyOrderWs".to_string(), Value::Null);
113 m.insert("createMarketBuyOrderWithCost".to_string(), Value::Null);
114 m.insert("createMarketBuyOrderWithCostWs".to_string(), Value::Null);
115 m.insert("createMarketOrder".to_string(), Value::Bool(true));
116 m.insert("createMarketOrderWs".to_string(), Value::Bool(true));
117 m.insert("createMarketOrderWithCost".to_string(), Value::Null);
118 m.insert("createMarketOrderWithCostWs".to_string(), Value::Null);
119 m.insert("createMarketSellOrder".to_string(), Value::Null);
120 m.insert("createMarketSellOrderWs".to_string(), Value::Null);
121 m.insert("createMarketSellOrderWithCost".to_string(), Value::Null);
122 m.insert("createMarketSellOrderWithCostWs".to_string(), Value::Null);
123 m.insert("createOrder".to_string(), Value::Bool(true));
124 m.insert("createOrderWs".to_string(), Value::Null);
125 m.insert("createOrders".to_string(), Value::Null);
126 m.insert("createOrderWithTakeProfitAndStopLoss".to_string(), Value::Null);
127 m.insert("createOrderWithTakeProfitAndStopLossWs".to_string(), Value::Null);
128 m.insert("createPostOnlyOrder".to_string(), Value::Null);
129 m.insert("createPostOnlyOrderWs".to_string(), Value::Null);
130 m.insert("createReduceOnlyOrder".to_string(), Value::Null);
131 m.insert("createReduceOnlyOrderWs".to_string(), Value::Null);
132 m.insert("createStopLimitOrder".to_string(), Value::Null);
133 m.insert("createStopLimitOrderWs".to_string(), Value::Null);
134 m.insert("createStopLossOrder".to_string(), Value::Null);
135 m.insert("createStopLossOrderWs".to_string(), Value::Null);
136 m.insert("createStopMarketOrder".to_string(), Value::Null);
137 m.insert("createStopMarketOrderWs".to_string(), Value::Null);
138 m.insert("createStopOrder".to_string(), Value::Null);
139 m.insert("createStopOrderWs".to_string(), Value::Null);
140 m.insert("createTakeProfitOrder".to_string(), Value::Null);
141 m.insert("createTakeProfitOrderWs".to_string(), Value::Null);
142 m.insert("createTrailingAmountOrder".to_string(), Value::Null);
143 m.insert("createTrailingAmountOrderWs".to_string(), Value::Null);
144 m.insert("createTrailingPercentOrder".to_string(), Value::Null);
145 m.insert("createTrailingPercentOrderWs".to_string(), Value::Null);
146 m.insert("createTriggerOrder".to_string(), Value::Null);
147 m.insert("createTriggerOrderWs".to_string(), Value::Null);
148 m.insert("deposit".to_string(), Value::Null);
149 m.insert("editOrder".to_string(), Value::Str("emulated".to_string()));
150 m.insert("editOrderWithClientOrderId".to_string(), Value::Null);
151 m.insert("editOrders".to_string(), Value::Null);
152 m.insert("editOrderWs".to_string(), Value::Null);
153 m.insert("fetchAccounts".to_string(), Value::Null);
154 m.insert("fetchADLRank".to_string(), Value::Null);
155 m.insert("fetchBalance".to_string(), Value::Bool(true));
156 m.insert("fetchBalanceWs".to_string(), Value::Null);
157 m.insert("fetchBidsAsks".to_string(), Value::Null);
158 m.insert("fetchBorrowInterest".to_string(), Value::Null);
159 m.insert("fetchBorrowRate".to_string(), Value::Null);
160 m.insert("fetchBorrowRateHistories".to_string(), Value::Null);
161 m.insert("fetchBorrowRateHistory".to_string(), Value::Null);
162 m.insert("fetchBorrowRates".to_string(), Value::Null);
163 m.insert("fetchBorrowRatesPerSymbol".to_string(), Value::Null);
164 m.insert("fetchCanceledAndClosedOrders".to_string(), Value::Null);
165 m.insert("fetchCanceledOrders".to_string(), Value::Null);
166 m.insert("fetchClosedOrder".to_string(), Value::Null);
167 m.insert("fetchClosedOrders".to_string(), Value::Null);
168 m.insert("fetchClosedOrdersWs".to_string(), Value::Null);
169 m.insert("fetchConvertCurrencies".to_string(), Value::Null);
170 m.insert("fetchConvertQuote".to_string(), Value::Null);
171 m.insert("fetchConvertTrade".to_string(), Value::Null);
172 m.insert("fetchConvertTradeHistory".to_string(), Value::Null);
173 m.insert("fetchCrossBorrowRate".to_string(), Value::Null);
174 m.insert("fetchCrossBorrowRates".to_string(), Value::Null);
175 m.insert("fetchCurrencies".to_string(), Value::Str("emulated".to_string()));
176 m.insert("fetchCurrenciesWs".to_string(), Value::Str("emulated".to_string()));
177 m.insert("fetchDeposit".to_string(), Value::Null);
178 m.insert("fetchDepositAddress".to_string(), Value::Null);
179 m.insert("fetchDepositAddresses".to_string(), Value::Null);
180 m.insert("fetchDepositAddressesByNetwork".to_string(), Value::Null);
181 m.insert("fetchDeposits".to_string(), Value::Null);
182 m.insert("fetchDepositsWithdrawals".to_string(), Value::Null);
183 m.insert("fetchDepositsWs".to_string(), Value::Null);
184 m.insert("fetchDepositWithdrawFee".to_string(), Value::Null);
185 m.insert("fetchDepositWithdrawFees".to_string(), Value::Null);
186 m.insert("fetchFundingHistory".to_string(), Value::Null);
187 m.insert("fetchFundingRate".to_string(), Value::Null);
188 m.insert("fetchFundingRateHistory".to_string(), Value::Null);
189 m.insert("fetchFundingInterval".to_string(), Value::Null);
190 m.insert("fetchFundingIntervals".to_string(), Value::Null);
191 m.insert("fetchFundingRates".to_string(), Value::Null);
192 m.insert("fetchGreeks".to_string(), Value::Null);
193 m.insert("fetchIndexOHLCV".to_string(), Value::Null);
194 m.insert("fetchIsolatedBorrowRate".to_string(), Value::Null);
195 m.insert("fetchIsolatedBorrowRates".to_string(), Value::Null);
196 m.insert("fetchMarginAdjustmentHistory".to_string(), Value::Null);
197 m.insert("fetchIsolatedPositions".to_string(), Value::Null);
198 m.insert("fetchL2OrderBook".to_string(), Value::Bool(true));
199 m.insert("fetchL3OrderBook".to_string(), Value::Null);
200 m.insert("fetchLastPrices".to_string(), Value::Null);
201 m.insert("fetchLedger".to_string(), Value::Null);
202 m.insert("fetchLedgerEntry".to_string(), Value::Null);
203 m.insert("fetchLeverage".to_string(), Value::Null);
204 m.insert("fetchLeverages".to_string(), Value::Null);
205 m.insert("fetchLeverageTiers".to_string(), Value::Null);
206 m.insert("fetchLiquidations".to_string(), Value::Null);
207 m.insert("fetchLongShortRatio".to_string(), Value::Null);
208 m.insert("fetchLongShortRatioHistory".to_string(), Value::Null);
209 m.insert("fetchMarginMode".to_string(), Value::Null);
210 m.insert("fetchMarginModes".to_string(), Value::Null);
211 m.insert("fetchMarketLeverageTiers".to_string(), Value::Null);
212 m.insert("fetchMarkets".to_string(), Value::Bool(true));
213 m.insert("fetchMarketsWs".to_string(), Value::Null);
214 m.insert("fetchMarkOHLCV".to_string(), Value::Null);
215 m.insert("fetchMyLiquidations".to_string(), Value::Null);
216 m.insert("fetchMySettlementHistory".to_string(), Value::Null);
217 m.insert("fetchMyTrades".to_string(), Value::Null);
218 m.insert("fetchMyTradesWs".to_string(), Value::Null);
219 m.insert("fetchOHLCV".to_string(), Value::Null);
220 m.insert("fetchOHLCVWs".to_string(), Value::Null);
221 m.insert("fetchOpenInterest".to_string(), Value::Null);
222 m.insert("fetchOpenInterests".to_string(), Value::Null);
223 m.insert("fetchOpenInterestHistory".to_string(), Value::Null);
224 m.insert("fetchOpenOrder".to_string(), Value::Null);
225 m.insert("fetchOpenOrders".to_string(), Value::Null);
226 m.insert("fetchOpenOrdersWs".to_string(), Value::Null);
227 m.insert("fetchOption".to_string(), Value::Null);
228 m.insert("fetchOptionChain".to_string(), Value::Null);
229 m.insert("fetchOrder".to_string(), Value::Null);
230 m.insert("fetchOrderWithClientOrderId".to_string(), Value::Null);
231 m.insert("fetchOrderBook".to_string(), Value::Bool(true));
232 m.insert("fetchOrderBooks".to_string(), Value::Null);
233 m.insert("fetchOrderBookWs".to_string(), Value::Null);
234 m.insert("fetchOrders".to_string(), Value::Null);
235 m.insert("fetchOrdersByStatus".to_string(), Value::Null);
236 m.insert("fetchOrdersWs".to_string(), Value::Null);
237 m.insert("fetchOrderTrades".to_string(), Value::Null);
238 m.insert("fetchOrderWs".to_string(), Value::Null);
239 m.insert("fetchPosition".to_string(), Value::Null);
240 m.insert("fetchPositionADLRank".to_string(), Value::Null);
241 m.insert("fetchPositionsADLRank".to_string(), Value::Null);
242 m.insert("fetchPositionHistory".to_string(), Value::Null);
243 m.insert("fetchPositionsHistory".to_string(), Value::Null);
244 m.insert("fetchPositionWs".to_string(), Value::Null);
245 m.insert("fetchPositionMode".to_string(), Value::Null);
246 m.insert("fetchPositions".to_string(), Value::Null);
247 m.insert("fetchPositionsWs".to_string(), Value::Null);
248 m.insert("fetchPositionsForSymbol".to_string(), Value::Null);
249 m.insert("fetchPositionsForSymbolWs".to_string(), Value::Null);
250 m.insert("fetchPositionsRisk".to_string(), Value::Null);
251 m.insert("fetchPremiumIndexOHLCV".to_string(), Value::Null);
252 m.insert("fetchSettlementHistory".to_string(), Value::Null);
253 m.insert("fetchStatus".to_string(), Value::Null);
254 m.insert("fetchTicker".to_string(), Value::Bool(true));
255 m.insert("fetchTickerWs".to_string(), Value::Null);
256 m.insert("fetchTickers".to_string(), Value::Null);
257 m.insert("fetchMarkPrices".to_string(), Value::Null);
258 m.insert("fetchTickersWs".to_string(), Value::Null);
259 m.insert("fetchTime".to_string(), Value::Null);
260 m.insert("fetchTrades".to_string(), Value::Bool(true));
261 m.insert("fetchTradesWs".to_string(), Value::Null);
262 m.insert("fetchTradingFee".to_string(), Value::Null);
263 m.insert("fetchTradingFees".to_string(), Value::Null);
264 m.insert("fetchTradingFeesWs".to_string(), Value::Null);
265 m.insert("fetchTradingLimits".to_string(), Value::Null);
266 m.insert("fetchTransactionFee".to_string(), Value::Null);
267 m.insert("fetchTransactionFees".to_string(), Value::Null);
268 m.insert("fetchTransactions".to_string(), Value::Null);
269 m.insert("fetchTransfer".to_string(), Value::Null);
270 m.insert("fetchTransfers".to_string(), Value::Null);
271 m.insert("fetchUnderlyingAssets".to_string(), Value::Null);
272 m.insert("fetchVolatilityHistory".to_string(), Value::Null);
273 m.insert("fetchWithdrawAddresses".to_string(), Value::Null);
274 m.insert("fetchWithdrawal".to_string(), Value::Null);
275 m.insert("fetchWithdrawals".to_string(), Value::Null);
276 m.insert("fetchWithdrawalsWs".to_string(), Value::Null);
277 m.insert("fetchWithdrawalWhitelist".to_string(), Value::Null);
278 m.insert("reduceMargin".to_string(), Value::Null);
279 m.insert("repayCrossMargin".to_string(), Value::Null);
280 m.insert("repayIsolatedMargin".to_string(), Value::Null);
281 m.insert("setLeverage".to_string(), Value::Null);
282 m.insert("setMargin".to_string(), Value::Null);
283 m.insert("setMarginMode".to_string(), Value::Null);
284 m.insert("setPositionMode".to_string(), Value::Null);
285 m.insert("signIn".to_string(), Value::Null);
286 m.insert("transfer".to_string(), Value::Null);
287 m.insert("watchBalance".to_string(), Value::Null);
288 m.insert("watchMyTrades".to_string(), Value::Null);
289 m.insert("watchOHLCV".to_string(), Value::Null);
290 m.insert("watchOHLCVForSymbols".to_string(), Value::Null);
291 m.insert("watchOrderBook".to_string(), Value::Null);
292 m.insert("watchBidsAsks".to_string(), Value::Null);
293 m.insert("watchOrderBookForSymbols".to_string(), Value::Null);
294 m.insert("watchOrders".to_string(), Value::Null);
295 m.insert("watchOrdersForSymbols".to_string(), Value::Null);
296 m.insert("watchPosition".to_string(), Value::Null);
297 m.insert("watchPositions".to_string(), Value::Null);
298 m.insert("watchStatus".to_string(), Value::Null);
299 m.insert("watchTicker".to_string(), Value::Null);
300 m.insert("watchTickers".to_string(), Value::Null);
301 m.insert("watchTrades".to_string(), Value::Null);
302 m.insert("watchTradesForSymbols".to_string(), Value::Null);
303 m.insert("watchLiquidations".to_string(), Value::Null);
304 m.insert("watchLiquidationsForSymbols".to_string(), Value::Null);
305 m.insert("watchMyLiquidations".to_string(), Value::Null);
306 m.insert("unWatchOrders".to_string(), Value::Null);
307 m.insert("unWatchTrades".to_string(), Value::Null);
308 m.insert("unWatchTradesForSymbols".to_string(), Value::Null);
309 m.insert("unWatchOHLCVForSymbols".to_string(), Value::Null);
310 m.insert("unWatchOrderBookForSymbols".to_string(), Value::Null);
311 m.insert("unWatchPositions".to_string(), Value::Null);
312 m.insert("unWatchOrderBook".to_string(), Value::Null);
313 m.insert("unWatchTickers".to_string(), Value::Null);
314 m.insert("unWatchMyTrades".to_string(), Value::Null);
315 m.insert("unWatchTicker".to_string(), Value::Null);
316 m.insert("unWatchOHLCV".to_string(), Value::Null);
317 m.insert("watchMyLiquidationsForSymbols".to_string(), Value::Null);
318 m.insert("withdraw".to_string(), Value::Null);
319 m.insert("ws".to_string(), Value::Null);
320 m
321}));
322 m.insert("urls".to_string(), Value::Map({
323 let mut m = indexmap::IndexMap::new();
324 m.insert("logo".to_string(), Value::Null);
325 m.insert("api".to_string(), Value::Null);
326 m.insert("test".to_string(), Value::Null);
327 m.insert("www".to_string(), Value::Null);
328 m.insert("doc".to_string(), Value::Null);
329 m.insert("api_management".to_string(), Value::Null);
330 m.insert("fees".to_string(), Value::Null);
331 m.insert("referral".to_string(), Value::Null);
332 m
333}));
334 m.insert("api".to_string(), Value::Null);
335 m.insert("requiredCredentials".to_string(), Value::Map({
336 let mut m = indexmap::IndexMap::new();
337 m.insert("apiKey".to_string(), Value::Bool(true));
338 m.insert("secret".to_string(), Value::Bool(true));
339 m.insert("uid".to_string(), Value::Bool(false));
340 m.insert("accountId".to_string(), Value::Bool(false));
341 m.insert("login".to_string(), Value::Bool(false));
342 m.insert("password".to_string(), Value::Bool(false));
343 m.insert("twofa".to_string(), Value::Bool(false));
344 m.insert("privateKey".to_string(), Value::Bool(false));
345 m.insert("walletAddress".to_string(), Value::Bool(false));
346 m.insert("token".to_string(), Value::Bool(false));
347 m
348}));
349 m.insert("markets".to_string(), Value::Null);
350 m.insert("currencies".to_string(), Value::Map({
351 let mut m = indexmap::IndexMap::new();
352 m
353}));
354 m.insert("timeframes".to_string(), Value::Null);
355 m.insert("fees".to_string(), Value::Map({
356 let mut m = indexmap::IndexMap::new();
357 m.insert("trading".to_string(), Value::Map({
358 let mut m = indexmap::IndexMap::new();
359 m.insert("tierBased".to_string(), Value::Null);
360 m.insert("percentage".to_string(), Value::Null);
361 m.insert("taker".to_string(), Value::Null);
362 m.insert("maker".to_string(), Value::Null);
363 m
364}));
365 m.insert("funding".to_string(), Value::Map({
366 let mut m = indexmap::IndexMap::new();
367 m.insert("tierBased".to_string(), Value::Null);
368 m.insert("percentage".to_string(), Value::Null);
369 m.insert("withdraw".to_string(), Value::Map({
370 let mut m = indexmap::IndexMap::new();
371 m
372}));
373 m.insert("deposit".to_string(), Value::Map({
374 let mut m = indexmap::IndexMap::new();
375 m
376}));
377 m
378}));
379 m
380}));
381 m.insert("status".to_string(), Value::Map({
382 let mut m = indexmap::IndexMap::new();
383 m.insert("status".to_string(), Value::Str("ok".to_string()));
384 m.insert("updated".to_string(), Value::Null);
385 m.insert("eta".to_string(), Value::Null);
386 m.insert("url".to_string(), Value::Null);
387 m.insert("info".to_string(), Value::Null);
388 m
389}));
390 m.insert("exceptions".to_string(), Value::Null);
391 m.insert("httpExceptions".to_string(), Value::Map({
392 let mut m = indexmap::IndexMap::new();
393 m.insert("422".to_string(), Value::Str("ExchangeError".to_string()).clone());
394 m.insert("418".to_string(), Value::Str("DDoSProtection".to_string()).clone());
395 m.insert("429".to_string(), Value::Str("RateLimitExceeded".to_string()).clone());
396 m.insert("404".to_string(), Value::Str("ExchangeNotAvailable".to_string()).clone());
397 m.insert("409".to_string(), Value::Str("ExchangeNotAvailable".to_string()).clone());
398 m.insert("410".to_string(), Value::Str("ExchangeNotAvailable".to_string()).clone());
399 m.insert("451".to_string(), Value::Str("ExchangeNotAvailable".to_string()).clone());
400 m.insert("500".to_string(), Value::Str("ExchangeNotAvailable".to_string()).clone());
401 m.insert("501".to_string(), Value::Str("ExchangeNotAvailable".to_string()).clone());
402 m.insert("502".to_string(), Value::Str("ExchangeNotAvailable".to_string()).clone());
403 m.insert("520".to_string(), Value::Str("ExchangeNotAvailable".to_string()).clone());
404 m.insert("521".to_string(), Value::Str("ExchangeNotAvailable".to_string()).clone());
405 m.insert("522".to_string(), Value::Str("ExchangeNotAvailable".to_string()).clone());
406 m.insert("525".to_string(), Value::Str("ExchangeNotAvailable".to_string()).clone());
407 m.insert("526".to_string(), Value::Str("ExchangeNotAvailable".to_string()).clone());
408 m.insert("400".to_string(), Value::Str("ExchangeNotAvailable".to_string()).clone());
409 m.insert("403".to_string(), Value::Str("ExchangeNotAvailable".to_string()).clone());
410 m.insert("405".to_string(), Value::Str("ExchangeNotAvailable".to_string()).clone());
411 m.insert("503".to_string(), Value::Str("ExchangeNotAvailable".to_string()).clone());
412 m.insert("530".to_string(), Value::Str("ExchangeNotAvailable".to_string()).clone());
413 m.insert("408".to_string(), Value::Str("RequestTimeout".to_string()).clone());
414 m.insert("504".to_string(), Value::Str("RequestTimeout".to_string()).clone());
415 m.insert("401".to_string(), Value::Str("AuthenticationError".to_string()).clone());
416 m.insert("407".to_string(), Value::Str("AuthenticationError".to_string()).clone());
417 m.insert("511".to_string(), Value::Str("AuthenticationError".to_string()).clone());
418 m
419}));
420 m.insert("commonCurrencies".to_string(), Value::Map({
421 let mut m = indexmap::IndexMap::new();
422 m.insert("XBT".to_string(), Value::Str("BTC".to_string()));
423 m.insert("BCHSV".to_string(), Value::Str("BSV".to_string()));
424 m
425}));
426 m.insert("precisionMode".to_string(), Value::Int(crate::runtime::TICK_SIZE));
427 m.insert("paddingMode".to_string(), Value::Int(crate::runtime::NO_PADDING));
428 m.insert("limits".to_string(), Value::Map({
429 let mut m = indexmap::IndexMap::new();
430 m.insert("leverage".to_string(), Value::Map({
431 let mut m = indexmap::IndexMap::new();
432 m.insert("min".to_string(), Value::Null);
433 m.insert("max".to_string(), Value::Null);
434 m
435}));
436 m.insert("amount".to_string(), Value::Map({
437 let mut m = indexmap::IndexMap::new();
438 m.insert("min".to_string(), Value::Null);
439 m.insert("max".to_string(), Value::Null);
440 m
441}));
442 m.insert("price".to_string(), Value::Map({
443 let mut m = indexmap::IndexMap::new();
444 m.insert("min".to_string(), Value::Null);
445 m.insert("max".to_string(), Value::Null);
446 m
447}));
448 m.insert("cost".to_string(), Value::Map({
449 let mut m = indexmap::IndexMap::new();
450 m.insert("min".to_string(), Value::Null);
451 m.insert("max".to_string(), Value::Null);
452 m
453}));
454 m
455}));
456 m.insert("rollingWindowSize".to_string(), Value::Int(60000));
457 m
458});
459
460 Value::Null
461}
462
463 fn clean_rest_data(&mut self) {
464 self.ids = Value::Null;
465 self.markets = Value::Null;
466 self.markets_by_id = Value::Null;
467 self.symbols = Value::List(vec![]);
468 self.codes = Value::Null;
469 { let __t = self.create_safe_dictionary(&[]); self.currencies = __t; }
470 self.currencies_by_id = Value::Null;
471 self.baseCurrencies = Value::Null;
472 self.quoteCurrencies = Value::Null;
473 self.last_http_response = Value::Null;
474 self.last_response_headers = Value::Null;
476 self.last_request_headers = Value::Null;
477}
478
479 fn clean_ws_data(&mut self) {
480 { let __t = self.create_safe_dictionary(&[Value::Bool(true)]); self.balance = __t; }
481 { let __t = self.create_safe_dictionary(&[Value::Bool(true)]); self.orderbooks = __t; }
482 { let __t = self.create_safe_dictionary(&[Value::Bool(true)]); self.tickers = __t; }
483 self.liquidations = Value::Null;
484 self.myLiquidations = Value::Null;
485 self.orders = Value::Null;
486 { let __t = self.create_safe_dictionary(&[Value::Bool(true)]); self.trades = __t; }
487 { let __t = self.create_safe_dictionary(&[]); self.transactions = __t; }
488 { let __t = self.create_safe_dictionary(&[Value::Bool(true)]); self.ohlcvs = __t; }
489 self.myTrades = Value::Null;
490 self.positions = Value::Null;
491}
492
493 fn safe_bool_n(&self, mut dictionaryOrList: Value, mut keys: Value, optional_args: &[Value]) -> Value {
494 let mut defaultValue = get_arg(optional_args, 0, Value::Null);
495 let mut value: Value = self.safe_value_n(dictionaryOrList.clone(), keys.clone(), &[defaultValue.clone()]);
502 if is_bool(&value) {
503 return value;
504 }
505 return defaultValue;
506
507 Value::Null
508}
509
510 fn safe_bool2(&self, mut dictionaryOrList: Value, mut key1: Value, mut key2: Value, optional_args: &[Value]) -> Value {
511 let mut defaultValue = get_arg(optional_args, 0, Value::Null);
512 let mut value: Value = self.safe_value(dictionaryOrList.clone(), key1.clone(), &[]);
519 if is_bool(&value) {
520 return value;
521 }
522 let mut value2: Value = self.safe_value(dictionaryOrList.clone(), key2.clone(), &[]);
523 if is_bool(&value2) {
524 return value2;
525 }
526 return defaultValue;
527
528 Value::Null
529}
530
531 fn safe_bool(&self, mut dictionaryOrList: Value, mut key: Value, optional_args: &[Value]) -> Value {
532 let mut defaultValue = get_arg(optional_args, 0, Value::Null);
533 let mut value: Value = self.safe_value(dictionaryOrList.clone(), key.clone(), &[defaultValue.clone()]);
540 if is_bool(&value) {
541 return value;
542 }
543 return defaultValue;
544
545 Value::Null
546}
547
548 fn safe_dict_n(&self, mut dictionaryOrList: Value, mut keys: Value, optional_args: &[Value]) -> Value {
549 let mut defaultValue = get_arg(optional_args, 0, Value::Null);
550 let mut value: Value = self.safe_value_n(dictionaryOrList.clone(), keys.clone(), &[defaultValue.clone()]);
557 if is_equal(&value, &Value::Null) {
558 return defaultValue;
559 }
560 if is_true(&self.is_dictionary(value.clone())) {
561 return value;
562 }
563 return defaultValue;
564
565 Value::Null
566}
567
568 fn safe_dict(&self, mut dictionaryOrList: Value, mut key: Value, optional_args: &[Value]) -> Value {
569 let mut defaultValue = get_arg(optional_args, 0, Value::Null);
570 let mut value: Value = self.safe_value(dictionaryOrList.clone(), key.clone(), &[defaultValue.clone()]);
577 if is_equal(&value, &Value::Null) {
578 return defaultValue;
579 }
580 if is_true(&self.is_dictionary(value.clone())) {
581 return value;
582 }
583 return defaultValue;
584
585 Value::Null
586}
587
588 fn safe_dict2(&self, mut dictionaryOrList: Value, mut key1: Value, mut key2: Value, optional_args: &[Value]) -> Value {
589 let mut defaultValue = get_arg(optional_args, 0, Value::Null);
590 let mut value: Value = self.safe_value(dictionaryOrList.clone(), key1.clone(), &[]);
597 if is_true(&self.is_dictionary(value.clone())) {
598 return value;
599 }
600 let mut value2: Value = self.safe_value(dictionaryOrList.clone(), key2.clone(), &[]);
601 if is_true(&self.is_dictionary(value2.clone())) {
602 return value2;
603 }
604 return defaultValue;
605
606 Value::Null
607}
608
609 fn safe_list_n(&self, mut dictionaryOrList: Value, mut keys: Value, optional_args: &[Value]) -> Value {
610 let mut defaultValue = get_arg(optional_args, 0, Value::Null);
611 let mut value: Value = self.safe_value_n(dictionaryOrList.clone(), keys.clone(), &[defaultValue.clone()]);
618 if is_equal(&value, &Value::Null) {
619 return defaultValue;
620 }
621 if is_true(&Value::Bool(is_array(&value))) {
622 return value;
623 }
624 return defaultValue;
625
626 Value::Null
627}
628
629 fn safe_list2(&self, mut dictionaryOrList: Value, mut key1: Value, mut key2: Value, optional_args: &[Value]) -> Value {
630 let mut defaultValue = get_arg(optional_args, 0, Value::Null);
631 let mut value: Value = self.safe_value(dictionaryOrList.clone(), key1.clone(), &[]);
638 if is_true(&(!is_equal(&value, &Value::Null))) && is_true(&Value::Bool(is_array(&value))) {
639 return value;
640 }
641 let mut value2: Value = self.safe_value(dictionaryOrList.clone(), key2.clone(), &[]);
642 if is_true(&(!is_equal(&value2, &Value::Null))) && is_true(&Value::Bool(is_array(&value2))) {
643 return value2;
644 }
645 return defaultValue;
646
647 Value::Null
648}
649
650 fn safe_list(&self, mut dictionaryOrList: Value, mut key: Value, optional_args: &[Value]) -> Value {
651 let mut defaultValue = get_arg(optional_args, 0, Value::Null);
652 let mut value: Value = self.safe_value(dictionaryOrList.clone(), key.clone(), &[defaultValue.clone()]);
659 if is_equal(&value, &Value::Null) {
660 return defaultValue;
661 }
662 if is_true(&Value::Bool(is_array(&value))) {
663 return value;
664 }
665 return defaultValue;
666
667 Value::Null
668}
669
670 fn store_by_key(&self, mut dict: Value, mut key: Value, mut value: Value) {
671 let mut k: Value = key.clone();
677 if !is_equal(&k, &Value::Null) {
678 add_element_to_object(&mut dict, &k, value.clone());
679 }
680}
681
682 fn handle_deltas(&self, mut orderbook: Value, mut deltas: Value) {
683 {
684 let mut i: Value = Value::Int(0);
685 let mut __for_first_71: bool = true;
686 while { if !__for_first_71 { i = add(&i, &Value::Int(1)); } __for_first_71 = false; is_less_than(&i, &get_array_length(&deltas)) } {
687 self.handle_delta(orderbook.clone(), get_value(&deltas, &i));
688 }
689 }
690}
691
692 fn handle_delta(&self, mut bookside: Value, mut delta: Value) {
693 panic!("{}", crate::exchange_errors::not_supported(add(&self.id, &Value::Str(" handleDelta not supported yet".to_string()))));
694}
695
696 fn handle_deltas_with_keys(&self, mut bookSide: Value, mut deltas: Value, optional_args: &[Value]) {
697 let mut priceKey = get_arg(optional_args, 0, Value::Int(0));
698 let mut amountKey = get_arg(optional_args, 1, Value::Int(1));
699 let mut countOrIdKey = get_arg(optional_args, 2, Value::Int(2));
700 {
701 let mut i: Value = Value::Int(0);
702 let mut __for_first_72: bool = true;
703 while { if !__for_first_72 { i = add(&i, &Value::Int(1)); } __for_first_72 = false; is_less_than(&i, &get_array_length(&deltas)) } {
704 let mut bidAsk: Value = self.parse_order_book_bid_ask(get_value(&deltas, &i), &[priceKey.clone(), amountKey.clone(), countOrIdKey.clone()]);
705 bookSide.store_array(bidAsk);
706 }
707 }
708}
709
710 fn get_cache_index(&self, mut orderbook: Value, mut deltas: Value) -> Value {
711 return negate(&Value::Int(1));
712
713 Value::Null
714}
715
716 fn arrays_concat(&self, mut arraysOfArrays: Value) -> Value {
717 let mut result: Value = Value::List(vec![]);
718 {
719 let mut i: Value = Value::Int(0);
720 let mut __for_first_73: bool = true;
721 while { if !__for_first_73 { i = add(&i, &Value::Int(1)); } __for_first_73 = false; is_less_than(&i, &get_array_length(&arraysOfArrays)) } {
722 result = self.array_concat(result.clone(), get_value(&arraysOfArrays, &i));
723 }
724 }
725 return result;
726
727 Value::Null
728}
729
730 fn find_timeframe(&self, mut timeframe: Value, optional_args: &[Value]) -> Value {
731 let mut timeframes = get_arg(optional_args, 0, Value::Null);
732 if is_equal(&timeframes, &Value::Null) {
733 timeframes = self.timeframes.clone();
734 }
735 let mut keys: Value = object_keys(&timeframes);
736 {
737 let mut i: Value = Value::Int(0);
738 let mut __for_first_74: bool = true;
739 while { if !__for_first_74 { i = add(&i, &Value::Int(1)); } __for_first_74 = false; is_less_than(&i, &get_array_length(&keys)) } {
740 let mut key: Value = get_value(&keys, &i);
741 let mut key: Value = get_value(&keys, &i);
742 if is_equal(&get_value(&timeframes, &key), &timeframe) {
743 return key;
744 }
745 }
746 }
747 return Value::Null;
748
749 Value::Null
750}
751
752 fn check_proxy_url_settings(&self, optional_args: &[Value]) -> Value {
753 let mut url = get_arg(optional_args, 0, Value::Null);
754 let mut method = get_arg(optional_args, 1, Value::Null);
755 let mut headers = get_arg(optional_args, 2, Value::Null);
756 let mut body = get_arg(optional_args, 3, Value::Null);
757 let mut usedProxies: Value = Value::List(vec![]);
758 let mut proxyUrl: Value = Value::Null;
759 if !is_equal(&self.proxyUrl, &Value::Null) {
760 append_to_array(&mut usedProxies, Value::Str("proxyUrl".to_string()));
761 proxyUrl = self.proxyUrl.clone();
762 }
763 if !is_equal(&self.proxy_url, &Value::Null) {
764 append_to_array(&mut usedProxies, Value::Str("proxy_url".to_string()));
765 proxyUrl = self.proxy_url.clone();
766 }
767 if !is_equal(&self.proxyUrlCallback, &Value::Null) {
768 append_to_array(&mut usedProxies, Value::Str("proxyUrlCallback".to_string()));
769 proxyUrl = self.proxy_url_callback_fn(url.clone(), method.clone(), headers.clone(), body.clone());
770 }
771 if !is_equal(&self.proxy_url_callback, &Value::Null) {
772 append_to_array(&mut usedProxies, Value::Str("proxy_url_callback".to_string()));
773 proxyUrl = self.proxy_url_callback_fn(url.clone(), method.clone(), headers.clone(), body.clone());
774 }
775 if !is_equal(&self.proxy, &Value::Null) {
777 append_to_array(&mut usedProxies, Value::Str("proxy".to_string()));
778 if is_function(&self.proxy) {
779 proxyUrl = self.proxy_fn(url.clone(), method.clone(), headers.clone(), body.clone());
780 } else {
781 proxyUrl = self.proxy.clone();
782 }
783 }
784 let mut length: Value = get_array_length(&usedProxies);
785 if is_greater_than(&length, &Value::Int(1)) {
786 let mut joinedProxyNames: Value = join(&usedProxies, &Value::Str(",".to_string()));
787 panic!("{}", crate::exchange_errors::invalid_proxy_settings(add(&add(&add(&self.id, &Value::Str(" you have multiple conflicting proxy settings (".to_string())), &joinedProxyNames), &Value::Str("), please use only one from : proxyUrl, proxy_url, proxyUrlCallback, proxy_url_callback".to_string()))));
788 }
789 return proxyUrl;
790
791 Value::Null
792}
793
794 fn url_encoder_for_proxy_url(&self, mut targetUrl: Value) -> Value {
795 let mut includesQuery: bool = is_greater_than_or_equal(&get_index_of(&targetUrl, &Value::Str("?".to_string())), &Value::Int(0));
797 let mut finalUrl: Value = ternary(is_true(&includesQuery), self.encode_uri_component(targetUrl.clone()), targetUrl.clone());
798 return finalUrl;
799
800 Value::Null
801}
802
803 fn check_proxy_settings(&self, optional_args: &[Value]) -> Value {
804 let mut url = get_arg(optional_args, 0, Value::Null);
805 let mut method = get_arg(optional_args, 1, Value::Null);
806 let mut headers = get_arg(optional_args, 2, Value::Null);
807 let mut body = get_arg(optional_args, 3, Value::Null);
808 let mut usedProxies: Value = Value::List(vec![]);
809 let mut httpProxy: Value = Value::Null;
810 let mut httpsProxy: Value = Value::Null;
811 let mut socksProxy: Value = Value::Null;
812 let mut isHttpProxyDefined: Value = self.value_is_defined(self.httpProxy.clone());
814 let mut isHttp_proxy_defined: Value = self.value_is_defined(self.http_proxy.clone());
815 if is_true(&isHttpProxyDefined) || is_true(&isHttp_proxy_defined) {
816 append_to_array(&mut usedProxies, Value::Str("httpProxy".to_string()));
817 httpProxy = ternary(is_true(&isHttpProxyDefined), self.httpProxy.clone(), self.http_proxy.clone());
818 }
819 let mut ishttpProxyCallbackDefined: Value = self.value_is_defined(self.httpProxyCallback.clone());
820 let mut ishttp_proxy_callback_defined: Value = self.value_is_defined(self.http_proxy_callback.clone());
821 if is_true(&ishttpProxyCallbackDefined) || is_true(&ishttp_proxy_callback_defined) {
822 append_to_array(&mut usedProxies, Value::Str("httpProxyCallback".to_string()));
823 httpProxy = ternary(is_true(&ishttpProxyCallbackDefined), self.http_proxy_callback_fn(url.clone(), method.clone(), headers.clone(), body.clone()), self.http_proxy_callback_fn(url.clone(), method.clone(), headers.clone(), body.clone()));
824 }
825 let mut isHttpsProxyDefined: Value = self.value_is_defined(self.httpsProxy.clone());
827 let mut isHttps_proxy_defined: Value = self.value_is_defined(self.https_proxy.clone());
828 if is_true(&isHttpsProxyDefined) || is_true(&isHttps_proxy_defined) {
829 append_to_array(&mut usedProxies, Value::Str("httpsProxy".to_string()));
830 httpsProxy = ternary(is_true(&isHttpsProxyDefined), self.httpsProxy.clone(), self.https_proxy.clone());
831 }
832 let mut ishttpsProxyCallbackDefined: Value = self.value_is_defined(self.httpsProxyCallback.clone());
833 let mut ishttps_proxy_callback_defined: Value = self.value_is_defined(self.https_proxy_callback.clone());
834 if is_true(&ishttpsProxyCallbackDefined) || is_true(&ishttps_proxy_callback_defined) {
835 append_to_array(&mut usedProxies, Value::Str("httpsProxyCallback".to_string()));
836 httpsProxy = ternary(is_true(&ishttpsProxyCallbackDefined), self.https_proxy_callback_fn(url.clone(), method.clone(), headers.clone(), body.clone()), self.https_proxy_callback_fn(url.clone(), method.clone(), headers.clone(), body.clone()));
837 }
838 let mut isSocksProxyDefined: Value = self.value_is_defined(self.socksProxy.clone());
840 let mut isSocks_proxy_defined: Value = self.value_is_defined(self.socks_proxy.clone());
841 if is_true(&isSocksProxyDefined) || is_true(&isSocks_proxy_defined) {
842 append_to_array(&mut usedProxies, Value::Str("socksProxy".to_string()));
843 socksProxy = ternary(is_true(&isSocksProxyDefined), self.socksProxy.clone(), self.socks_proxy.clone());
844 }
845 let mut issocksProxyCallbackDefined: Value = self.value_is_defined(self.socksProxyCallback.clone());
846 let mut issocks_proxy_callback_defined: Value = self.value_is_defined(self.socks_proxy_callback.clone());
847 if is_true(&issocksProxyCallbackDefined) || is_true(&issocks_proxy_callback_defined) {
848 append_to_array(&mut usedProxies, Value::Str("socksProxyCallback".to_string()));
849 socksProxy = ternary(is_true(&issocksProxyCallbackDefined), self.socks_proxy_callback_fn(url.clone(), method.clone(), headers.clone(), body.clone()), self.socks_proxy_callback_fn(url.clone(), method.clone(), headers.clone(), body.clone()));
850 }
851 let mut length: Value = get_array_length(&usedProxies);
853 if is_greater_than(&length, &Value::Int(1)) {
854 let mut joinedProxyNames: Value = join(&usedProxies, &Value::Str(",".to_string()));
855 panic!("{}", crate::exchange_errors::invalid_proxy_settings(add(&add(&add(&self.id, &Value::Str(" you have multiple conflicting proxy settings (".to_string())), &joinedProxyNames), &Value::Str("), please use only one from: httpProxy, httpsProxy, httpProxyCallback, httpsProxyCallback, socksProxy, socksProxyCallback".to_string()))));
856 }
857 return Value::List(vec![httpProxy.clone(), httpsProxy.clone(), socksProxy.clone()]);
858
859 Value::Null
860}
861
862 fn check_ws_proxy_settings(&self) -> Value {
863 let mut usedProxies: Value = Value::List(vec![]);
864 let mut wsProxy: Value = Value::Null;
865 let mut wssProxy: Value = Value::Null;
866 let mut wsSocksProxy: Value = Value::Null;
867 let mut isWsProxyDefined: Value = self.value_is_defined(self.wsProxy.clone());
869 let mut is_ws_proxy_defined: Value = self.value_is_defined(self.ws_proxy.clone());
870 if is_true(&isWsProxyDefined) || is_true(&is_ws_proxy_defined) {
871 append_to_array(&mut usedProxies, Value::Str("wsProxy".to_string()));
872 wsProxy = ternary(is_true(&(isWsProxyDefined)), self.wsProxy.clone(), self.ws_proxy.clone());
873 }
874 let mut isWssProxyDefined: Value = self.value_is_defined(self.wssProxy.clone());
876 let mut is_wss_proxy_defined: Value = self.value_is_defined(self.wss_proxy.clone());
877 if is_true(&isWssProxyDefined) || is_true(&is_wss_proxy_defined) {
878 append_to_array(&mut usedProxies, Value::Str("wssProxy".to_string()));
879 wssProxy = ternary(is_true(&(isWssProxyDefined)), self.wssProxy.clone(), self.wss_proxy.clone());
880 }
881 let mut isWsSocksProxyDefined: Value = self.value_is_defined(self.wsSocksProxy.clone());
883 let mut is_ws_socks_proxy_defined: Value = self.value_is_defined(self.ws_socks_proxy.clone());
884 if is_true(&isWsSocksProxyDefined) || is_true(&is_ws_socks_proxy_defined) {
885 append_to_array(&mut usedProxies, Value::Str("wsSocksProxy".to_string()));
886 wsSocksProxy = ternary(is_true(&(isWsSocksProxyDefined)), self.wsSocksProxy.clone(), self.ws_socks_proxy.clone());
887 }
888 let mut length: Value = get_array_length(&usedProxies);
890 if is_greater_than(&length, &Value::Int(1)) {
891 let mut joinedProxyNames: Value = join(&usedProxies, &Value::Str(",".to_string()));
892 panic!("{}", crate::exchange_errors::invalid_proxy_settings(add(&add(&add(&self.id, &Value::Str(" you have multiple conflicting proxy settings (".to_string())), &joinedProxyNames), &Value::Str("), please use only one from: wsProxy, wssProxy, wsSocksProxy".to_string()))));
893 }
894 return Value::List(vec![wsProxy.clone(), wssProxy.clone(), wsSocksProxy.clone()]);
895
896 Value::Null
897}
898
899 fn check_conflicting_proxies(&self, mut proxyAgentSet: Value, mut proxyUrlSet: Value) {
900 let mut proxyAgentIsSet: bool = is_true(&(!is_equal(&proxyAgentSet, &Value::Null))) && is_true(&(!is_equal(&proxyAgentSet, &Value::Null))) && is_true(&(!is_equal(&proxyAgentSet, &Value::Str("".to_string()))));
901 let mut proxyUrlIsSet: bool = is_true(&(!is_equal(&proxyUrlSet, &Value::Null))) && is_true(&(!is_equal(&proxyUrlSet, &Value::Null))) && is_true(&(!is_equal(&proxyUrlSet, &Value::Str("".to_string()))));
902 if is_true(&proxyAgentIsSet) && is_true(&proxyUrlIsSet) {
903 panic!("{}", crate::exchange_errors::invalid_proxy_settings(add(&self.id, &Value::Str(" you have multiple conflicting proxy settings, please use only one from : proxyUrl, httpProxy, httpsProxy, socksProxy".to_string()))));
904 }
905}
906
907 fn check_address(&self, optional_args: &[Value]) -> Value {
908 let mut address = get_arg(optional_args, 0, Value::Null);
909 if is_equal(&address, &Value::Null) {
910 panic!("{}", crate::exchange_errors::invalid_address(add(&self.id, &Value::Str(" address is undefined".to_string()))));
911 }
912 let mut uniqChars: Value = (self.unique(self.string_to_chars_array(address.clone())));
914 let mut length: Value = get_array_length(&uniqChars); if is_equal(&length, &Value::Int(1)) || is_less_than(&get_array_length(&address), &self.minFundingAddressLength) || is_greater_than(&get_index_of(&address, &Value::Str(" ".to_string())), &negate(&Value::Int(1))) {
916 panic!("{}", crate::exchange_errors::invalid_address(add(&add(&add(&add(&add(&self.id, &Value::Str(" address is invalid or has less than ".to_string())), &to_string_val(&self.minFundingAddressLength)), &Value::Str(" characters: \"".to_string())), &to_string_val(&address)), &Value::Str("\"".to_string()))));
917 }
918 return address;
919
920 Value::Null
921}
922
923 fn find_message_hashes(&self, mut client: Value, mut element: Value) -> Value {
924 let mut result: Value = Value::List(vec![]);
925 let mut messageHashes: Value = object_keys(&get_value(&client, &Value::Str("futures".to_string())));
926 {
927 let mut i: Value = Value::Int(0);
928 let mut __for_first_75: bool = true;
929 while { if !__for_first_75 { i = add(&i, &Value::Int(1)); } __for_first_75 = false; is_less_than(&i, &get_array_length(&messageHashes)) } {
930 let mut messageHash: Value = get_value(&messageHashes, &i);
931 let mut messageHash: Value = get_value(&messageHashes, &i);
932 if is_greater_than_or_equal(&get_index_of(&messageHash, &element), &Value::Int(0)) {
933 append_to_array(&mut result, messageHash.clone());
934 }
935 }
936 }
937 return result;
938
939 Value::Null
940}
941
942 fn filter_by_limit(&self, mut array: Value, optional_args: &[Value]) -> Value {
943 let mut limit = get_arg(optional_args, 0, Value::Null);
944 let mut key = get_arg(optional_args, 1, Value::Str("timestamp".to_string()));
945 let mut fromStart = get_arg(optional_args, 2, Value::Bool(false));
946 if is_true(&self.value_is_defined(limit.clone())) {
947 let mut arrayLength: Value = get_array_length(&array);
948 if is_greater_than(&arrayLength, &Value::Int(0)) {
949 let mut ascending: bool = true;
950 if is_true(&(Value::Bool(in_op(&get_value(&array, &Value::Int(0)), &key)))) {
951 let mut first: Value = get_value(&get_value(&array, &Value::Int(0)), &key);
952 let mut last: Value = get_value(&get_value(&array, &subtract(&arrayLength, &Value::Int(1))), &key);
953 if !is_equal(&first, &Value::Null) && !is_equal(&last, &Value::Null) {
954 ascending = is_less_than_or_equal(&first, &last); }
956 }
957 if is_true(&fromStart) {
958 if is_greater_than(&limit, &arrayLength) {
959 limit = arrayLength.clone();
960 }
961 if is_true(&ascending) {
963 array = self.array_slice(array.clone(), Value::Int(0), &[limit.clone()]);
964 } else {
965 array = self.array_slice(array.clone(), negate(&limit), &[]);
966 }
967 } else {
968 if is_true(&ascending) {
970 array = self.array_slice(array.clone(), negate(&limit), &[]);
971 } else {
972 array = self.array_slice(array.clone(), Value::Int(0), &[limit.clone()]);
973 }
974 }
975 }
976 }
977 return array;
978
979 Value::Null
980}
981
982 fn filter_by_since_limit(&self, mut array: Value, optional_args: &[Value]) -> Value {
983 let mut since = get_arg(optional_args, 0, Value::Null);
984 let mut limit = get_arg(optional_args, 1, Value::Null);
985 let mut key = get_arg(optional_args, 2, Value::Str("timestamp".to_string()));
986 let mut tail = get_arg(optional_args, 3, Value::Bool(false));
987 if is_equal(&array, &Value::Null) {
988 return Value::List(vec![]);
989 }
990 let mut sinceIsDefined: Value = self.value_is_defined(since.clone());
991 let mut parsedArray: Value = self.to_array(array.clone());
992 let mut result: Value = parsedArray.clone();
993 if is_true(&sinceIsDefined) {
994 result = Value::List(vec![]);
995 {
996 let mut i: Value = Value::Int(0);
997 let mut __for_first_76: bool = true;
998 while { if !__for_first_76 { i = add(&i, &Value::Int(1)); } __for_first_76 = false; is_less_than(&i, &get_array_length(&parsedArray)) } {
999 let mut entry: Value = get_value(&parsedArray, &i);
1000 let mut entry: Value = get_value(&parsedArray, &i);
1001 let mut value: Value = self.safe_value(entry.clone(), key.clone(), &[]);
1002 if is_true(&(!is_equal(&value, &Value::Null))) && is_true(&(!is_equal(&value, &Value::Null))) && is_true(&(!is_equal(&value, &Value::Int(0)))) && is_true(&(is_greater_than_or_equal(&value, &since))) {
1003 append_to_array(&mut result, entry.clone());
1004 }
1005 }
1006 }
1007 }
1008 if is_true(&tail) && !is_equal(&limit, &Value::Null) {
1009 return self.array_slice(result.clone(), negate(&limit), &[]);
1010 }
1011 let mut shouldFilterFromStart: Value = Value::Bool(!is_true(&tail) && is_true(&sinceIsDefined));
1014 return self.filter_by_limit(result.clone(), &[limit.clone(), key.clone(), shouldFilterFromStart.clone()]);
1015
1016 Value::Null
1017}
1018
1019 fn filter_by_value_since_limit(&self, mut array: Value, mut field: Value, optional_args: &[Value]) -> Value {
1020 let mut value = get_arg(optional_args, 0, Value::Null);
1021 let mut since = get_arg(optional_args, 1, Value::Null);
1022 let mut limit = get_arg(optional_args, 2, Value::Null);
1023 let mut key = get_arg(optional_args, 3, Value::Str("timestamp".to_string()));
1024 let mut tail = get_arg(optional_args, 4, Value::Bool(false));
1025 let mut valueIsDefined: Value = self.value_is_defined(value.clone());
1026 let mut sinceIsDefined: Value = self.value_is_defined(since.clone());
1027 let mut parsedArray: Value = self.to_array(array.clone());
1028 let mut result: Value = parsedArray.clone();
1029 if is_true(&valueIsDefined) || is_true(&sinceIsDefined) {
1031 result = Value::List(vec![]);
1032 {
1033 let mut i: Value = Value::Int(0);
1034 let mut __for_first_77: bool = true;
1035 while { if !__for_first_77 { i = add(&i, &Value::Int(1)); } __for_first_77 = false; is_less_than(&i, &get_array_length(&parsedArray)) } {
1036 let mut entry: Value = get_value(&parsedArray, &i);
1037 let mut entry: Value = get_value(&parsedArray, &i);
1038 let mut entryFiledEqualValue: Value = Value::Bool(is_equal(&self.safe_value(entry.clone(), field.clone(), &[]), &value));
1041 let mut firstCondition: Value = ternary(is_true(&valueIsDefined), entryFiledEqualValue.clone(), Value::Bool(true));
1042 let mut entryKeyValue: Value = self.safe_value(entry.clone(), key.clone(), &[]);
1043 let mut entryKeyGESince: Value = Value::Bool(is_true(&(!is_equal(&entryKeyValue, &Value::Null))) && is_true(&(!is_equal(&entryKeyValue, &Value::Null))) && is_true(&(!is_equal(&entryKeyValue, &Value::Int(0)))) && is_true(&(!is_equal(&since, &Value::Null))) && is_true(&(is_greater_than_or_equal(&entryKeyValue, &since))));
1044 let mut secondCondition: Value = ternary(is_true(&sinceIsDefined), entryKeyGESince.clone(), Value::Bool(true));
1045 if is_true(&firstCondition) && is_true(&secondCondition) {
1046 append_to_array(&mut result, entry.clone());
1047 }
1048 }
1049 }
1050 }
1051 if is_true(&tail) && !is_equal(&limit, &Value::Null) {
1052 return self.array_slice(result.clone(), negate(&limit), &[]);
1053 }
1054 return self.filter_by_limit(result.clone(), &[limit.clone(), key.clone(), sinceIsDefined.clone()]);
1055
1056 Value::Null
1057}
1058
1059fn set_sandbox_mode(&mut self, mut enabled: Value) {
1066 if is_true(&enabled) {
1067 if is_true(&Value::Bool(in_op(&self.urls, &Value::Str("test".to_string())))) {
1068 if is_string(&get_value(&self.urls, &Value::Str("api".to_string()))) {
1069 { let __be_tmp = get_value(&self.urls, &Value::Str("api".to_string())); add_element_to_object(&mut self.urls, &Value::Str("apiBackup".to_string()), __be_tmp); };
1070 { let __be_tmp = get_value(&self.urls, &Value::Str("test".to_string())); add_element_to_object(&mut self.urls, &Value::Str("api".to_string()), __be_tmp); };
1071 } else {
1072 { let __be_tmp = self.clone_value(get_value(&self.urls, &Value::Str("api".to_string()))); add_element_to_object(&mut self.urls, &Value::Str("apiBackup".to_string()), __be_tmp); };
1073 { let __be_tmp = self.clone_value(get_value(&self.urls, &Value::Str("test".to_string()))); add_element_to_object(&mut self.urls, &Value::Str("api".to_string()), __be_tmp); };
1074 }
1075 } else {
1076 panic!("{}", crate::exchange_errors::not_supported(add(&self.id, &Value::Str(" does not have a sandbox URL".to_string()))));
1077 }
1078 self.isSandboxModeEnabled = Value::Bool(true);
1080 } else if is_true(&Value::Bool(in_op(&self.urls, &Value::Str("apiBackup".to_string())))) {
1081 if is_string(&get_value(&self.urls, &Value::Str("api".to_string()))) {
1082 { let __be_tmp = get_value(&self.urls, &Value::Str("apiBackup".to_string())); add_element_to_object(&mut self.urls, &Value::Str("api".to_string()), __be_tmp); };
1083 } else {
1084 { let __be_tmp = self.clone_value(get_value(&self.urls, &Value::Str("apiBackup".to_string()))); add_element_to_object(&mut self.urls, &Value::Str("api".to_string()), __be_tmp); };
1085 }
1086 let mut newUrls: Value = self.omit(self.urls.clone(), Value::Str("apiBackup".to_string()), &[]);
1087 self.urls = newUrls.clone();
1088 self.isSandboxModeEnabled = Value::Bool(false);
1090 }
1091}
1092
1093fn enable_demo_trading(&mut self, mut enable: Value) {
1100 if is_true(&self.isSandboxModeEnabled) {
1101 panic!("{}", crate::exchange_errors::not_supported(add(&self.id, &Value::Str(" demo trading does not support in sandbox environment. Please check https://www.binance.com/en/support/faq/detail/9be58f73e5e14338809e3b705b9687dd to see the differences".to_string()))));
1102 }
1103 if is_true(&enable) {
1104 { let __be_tmp = get_value(&self.urls, &Value::Str("api".to_string())); add_element_to_object(&mut self.urls, &Value::Str("apiBackupDemoTrading".to_string()), __be_tmp); };
1105 { let __be_tmp = get_value(&self.urls, &Value::Str("demo".to_string())); add_element_to_object(&mut self.urls, &Value::Str("api".to_string()), __be_tmp); };
1106 } else if is_true(&Value::Bool(in_op(&self.urls, &Value::Str("apiBackupDemoTrading".to_string())))) {
1107 { let __be_tmp = get_value(&self.urls, &Value::Str("apiBackupDemoTrading".to_string())); add_element_to_object(&mut self.urls, &Value::Str("api".to_string()), __be_tmp); };
1108 let mut newUrls: Value = self.omit(self.urls.clone(), Value::Str("apiBackupDemoTrading".to_string()), &[]);
1109 self.urls = newUrls.clone();
1110 }
1111 add_element_to_object(&mut self.options, &Value::Str("enableDemoTrading".to_string()), enable.clone());
1112}
1113
1114 fn sign(&self, mut path: Value, optional_args: &[Value]) -> Value {
1115 { let __v = crate::exchange::DerivedExchange::sign(self, path.clone(), crate::runtime::get_arg(optional_args, 0, crate::Value::Null), crate::runtime::get_arg(optional_args, 1, crate::Value::Null), crate::runtime::get_arg(optional_args, 2, crate::Value::Null), crate::runtime::get_arg(optional_args, 3, crate::Value::Null), crate::runtime::get_arg(optional_args, 4, crate::Value::Null)); if !matches!(__v, crate::Value::Null) { return __v; } }
1117
1118 let mut api = get_arg(optional_args, 0, Value::Str("public".to_string()));
1119 let mut method = get_arg(optional_args, 1, Value::Str("GET".to_string()));
1120 let mut params = get_arg(optional_args, 2, Value::Map({
1121 let mut m = indexmap::IndexMap::new();
1122 m
1123}));
1124 let mut headers = get_arg(optional_args, 3, Value::Null);
1125 let mut body = get_arg(optional_args, 4, Value::Null);
1126 return Value::Map({
1127 let mut m = indexmap::IndexMap::new();
1128 m.insert("url".to_string(), Value::Null);
1129 m.insert("method".to_string(), Value::Null);
1130 m.insert("headers".to_string(), Value::Null);
1131 m.insert("body".to_string(), Value::Null);
1132 m
1133});
1134
1135 Value::Null
1136}
1137
1138 fn fetch_accounts(&mut self, optional_args: &[Value]) -> impl ::std::future::Future<Output = Value> + Send { async move {
1139 let mut params = get_arg(optional_args, 0, Value::Map({
1140 let mut m = indexmap::IndexMap::new();
1141 m
1142}));
1143 panic!("{}", crate::exchange_errors::not_supported(add(&self.id, &Value::Str(" fetchAccounts() is not supported yet".to_string()))));
1144
1145 Value::Null
1146} }
1147
1148 fn watch_liquidations(&mut self, mut symbol: Value, optional_args: &[Value]) -> impl ::std::future::Future<Output = Value> + Send { async move {
1149 let mut since = get_arg(optional_args, 0, Value::Null);
1150 let mut limit = get_arg(optional_args, 1, Value::Null);
1151 let mut params = get_arg(optional_args, 2, Value::Map({
1152 let mut m = indexmap::IndexMap::new();
1153 m
1154}));
1155 if !is_equal(&get_value(&self.has, &Value::Str("watchLiquidationsForSymbols".to_string())), &Value::Null) && !is_equal(&get_value(&self.has, &Value::Str("watchLiquidationsForSymbols".to_string())), &Value::Bool(false)) {
1156 return self.watch_liquidations_for_symbols(Value::List(vec![symbol.clone()]), &[since.clone(), limit.clone(), params.clone()]).await;
1157 }
1158 panic!("{}", crate::exchange_errors::not_supported(add(&self.id, &Value::Str(" watchLiquidations() is not supported yet".to_string()))));
1159
1160 Value::Null
1161} }
1162
1163 fn watch_liquidations_for_symbols(&mut self, mut symbols: Value, optional_args: &[Value]) -> impl ::std::future::Future<Output = Value> + Send { async move {
1164 let mut since = get_arg(optional_args, 0, Value::Null);
1165 let mut limit = get_arg(optional_args, 1, Value::Null);
1166 let mut params = get_arg(optional_args, 2, Value::Map({
1167 let mut m = indexmap::IndexMap::new();
1168 m
1169}));
1170 panic!("{}", crate::exchange_errors::not_supported(add(&self.id, &Value::Str(" watchLiquidationsForSymbols() is not supported yet".to_string()))));
1171
1172 Value::Null
1173} }
1174
1175 fn watch_my_liquidations(&mut self, mut symbol: Value, optional_args: &[Value]) -> impl ::std::future::Future<Output = Value> + Send { async move {
1176 let mut since = get_arg(optional_args, 0, Value::Null);
1177 let mut limit = get_arg(optional_args, 1, Value::Null);
1178 let mut params = get_arg(optional_args, 2, Value::Map({
1179 let mut m = indexmap::IndexMap::new();
1180 m
1181}));
1182 if !is_equal(&get_value(&self.has, &Value::Str("watchMyLiquidationsForSymbols".to_string())), &Value::Null) && !is_equal(&get_value(&self.has, &Value::Str("watchMyLiquidationsForSymbols".to_string())), &Value::Bool(false)) {
1183 return self.watch_my_liquidations_for_symbols(Value::List(vec![symbol.clone()]), &[since.clone(), limit.clone(), params.clone()]).await;
1184 }
1185 panic!("{}", crate::exchange_errors::not_supported(add(&self.id, &Value::Str(" watchMyLiquidations() is not supported yet".to_string()))));
1186
1187 Value::Null
1188} }
1189
1190 fn watch_my_liquidations_for_symbols(&mut self, mut symbols: Value, optional_args: &[Value]) -> impl ::std::future::Future<Output = Value> + Send { async move {
1191 let mut since = get_arg(optional_args, 0, Value::Null);
1192 let mut limit = get_arg(optional_args, 1, Value::Null);
1193 let mut params = get_arg(optional_args, 2, Value::Map({
1194 let mut m = indexmap::IndexMap::new();
1195 m
1196}));
1197 panic!("{}", crate::exchange_errors::not_supported(add(&self.id, &Value::Str(" watchMyLiquidationsForSymbols() is not supported yet".to_string()))));
1198
1199 Value::Null
1200} }
1201
1202 fn un_watch_orders(&mut self, optional_args: &[Value]) -> impl ::std::future::Future<Output = Value> + Send { async move {
1203 let mut symbol = get_arg(optional_args, 0, Value::Null);
1204 let mut params = get_arg(optional_args, 1, Value::Map({
1205 let mut m = indexmap::IndexMap::new();
1206 m
1207}));
1208 panic!("{}", crate::exchange_errors::not_supported(add(&self.id, &Value::Str(" unWatchOrders() is not supported yet".to_string()))));
1209
1210 Value::Null
1211} }
1212
1213 fn un_watch_trades(&mut self, mut symbol: Value, optional_args: &[Value]) -> impl ::std::future::Future<Output = Value> + Send { async move {
1214 let mut params = get_arg(optional_args, 0, Value::Map({
1215 let mut m = indexmap::IndexMap::new();
1216 m
1217}));
1218 panic!("{}", crate::exchange_errors::not_supported(add(&self.id, &Value::Str(" unWatchTrades() is not supported yet".to_string()))));
1219
1220 Value::Null
1221} }
1222
1223 fn un_watch_trades_for_symbols(&mut self, mut symbols: Value, optional_args: &[Value]) -> impl ::std::future::Future<Output = Value> + Send { async move {
1224 let mut params = get_arg(optional_args, 0, Value::Map({
1225 let mut m = indexmap::IndexMap::new();
1226 m
1227}));
1228 panic!("{}", crate::exchange_errors::not_supported(add(&self.id, &Value::Str(" unWatchTradesForSymbols() is not supported yet".to_string()))));
1229
1230 Value::Null
1231} }
1232
1233 fn watch_ohlcv_for_symbols(&mut self, mut symbolsAndTimeframes: Value, optional_args: &[Value]) -> impl ::std::future::Future<Output = Value> + Send { async move {
1234 let mut since = get_arg(optional_args, 0, Value::Null);
1235 let mut limit = get_arg(optional_args, 1, Value::Null);
1236 let mut params = get_arg(optional_args, 2, Value::Map({
1237 let mut m = indexmap::IndexMap::new();
1238 m
1239}));
1240 panic!("{}", crate::exchange_errors::not_supported(add(&self.id, &Value::Str(" watchOHLCVForSymbols() is not supported yet".to_string()))));
1241
1242 Value::Null
1243} }
1244
1245 fn un_watch_ohlcv_for_symbols(&mut self, mut symbolsAndTimeframes: Value, optional_args: &[Value]) -> impl ::std::future::Future<Output = Value> + Send { async move {
1246 let mut params = get_arg(optional_args, 0, Value::Map({
1247 let mut m = indexmap::IndexMap::new();
1248 m
1249}));
1250 panic!("{}", crate::exchange_errors::not_supported(add(&self.id, &Value::Str(" unWatchOHLCVForSymbols() is not supported yet".to_string()))));
1251
1252 Value::Null
1253} }
1254
1255 fn un_watch_order_book_for_symbols(&mut self, mut symbols: Value, optional_args: &[Value]) -> impl ::std::future::Future<Output = Value> + Send { async move {
1256 let mut params = get_arg(optional_args, 0, Value::Map({
1257 let mut m = indexmap::IndexMap::new();
1258 m
1259}));
1260 panic!("{}", crate::exchange_errors::not_supported(add(&self.id, &Value::Str(" unWatchOrderBookForSymbols() is not supported yet".to_string()))));
1261
1262 Value::Null
1263} }
1264
1265 fn un_watch_positions(&mut self, optional_args: &[Value]) -> impl ::std::future::Future<Output = Value> + Send { async move {
1266 let mut symbols = get_arg(optional_args, 0, Value::Null);
1267 let mut params = get_arg(optional_args, 1, Value::Map({
1268 let mut m = indexmap::IndexMap::new();
1269 m
1270}));
1271 panic!("{}", crate::exchange_errors::not_supported(add(&self.id, &Value::Str(" unWatchPositions() is not supported yet".to_string()))));
1272
1273 Value::Null
1274} }
1275
1276 fn un_watch_ticker(&mut self, mut symbol: Value, optional_args: &[Value]) -> impl ::std::future::Future<Output = Value> + Send { async move {
1277 let mut params = get_arg(optional_args, 0, Value::Map({
1278 let mut m = indexmap::IndexMap::new();
1279 m
1280}));
1281 panic!("{}", crate::exchange_errors::not_supported(add(&self.id, &Value::Str(" unWatchTicker() is not supported yet".to_string()))));
1282
1283 Value::Null
1284} }
1285
1286 fn un_watch_mark_price(&mut self, mut symbol: Value, optional_args: &[Value]) -> impl ::std::future::Future<Output = Value> + Send { async move {
1287 let mut params = get_arg(optional_args, 0, Value::Map({
1288 let mut m = indexmap::IndexMap::new();
1289 m
1290}));
1291 panic!("{}", crate::exchange_errors::not_supported(add(&self.id, &Value::Str(" unWatchMarkPrice() is not supported yet".to_string()))));
1292
1293 Value::Null
1294} }
1295
1296 fn un_watch_mark_prices(&mut self, optional_args: &[Value]) -> impl ::std::future::Future<Output = Value> + Send { async move {
1297 let mut symbols = get_arg(optional_args, 0, Value::Null);
1298 let mut params = get_arg(optional_args, 1, Value::Map({
1299 let mut m = indexmap::IndexMap::new();
1300 m
1301}));
1302 panic!("{}", crate::exchange_errors::not_supported(add(&self.id, &Value::Str(" unWatchMarkPrices() is not supported yet".to_string()))));
1303
1304 Value::Null
1305} }
1306
1307 fn fetch_deposit_addresses(&mut self, optional_args: &[Value]) -> impl ::std::future::Future<Output = Value> + Send { async move {
1308 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 {
1310 if !matches!(__v, crate::Value::Null) { return __v; }
1311 }
1312
1313 let mut codes = get_arg(optional_args, 0, Value::Null);
1314 let mut params = get_arg(optional_args, 1, Value::Map({
1315 let mut m = indexmap::IndexMap::new();
1316 m
1317}));
1318 panic!("{}", crate::exchange_errors::not_supported(add(&self.id, &Value::Str(" fetchDepositAddresses() is not supported yet".to_string()))));
1319
1320 Value::Null
1321} }
1322
1323 fn fetch_margin_mode(&mut self, mut symbol: Value, optional_args: &[Value]) -> impl ::std::future::Future<Output = Value> + Send { async move {
1324 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 {
1326 if !matches!(__v, crate::Value::Null) { return __v; }
1327 }
1328
1329 let mut params = get_arg(optional_args, 0, Value::Map({
1330 let mut m = indexmap::IndexMap::new();
1331 m
1332}));
1333 if !is_equal(&get_value(&self.has, &Value::Str("fetchMarginModes".to_string())), &Value::Null) && !is_equal(&get_value(&self.has, &Value::Str("fetchMarginModes".to_string())), &Value::Bool(false)) {
1334 let mut marginModes: Value = self.fetch_margin_modes(&[Value::List(vec![symbol.clone()]), params.clone()]).await;
1335 return self.safe_dict(marginModes.clone(), symbol.clone(), &[]);
1336 } else {
1337 panic!("{}", crate::exchange_errors::not_supported(add(&self.id, &Value::Str(" fetchMarginMode() is not supported yet".to_string()))));
1338 }
1339
1340 Value::Null
1341} }
1342
1343 fn fetch_margin_modes(&mut self, optional_args: &[Value]) -> impl ::std::future::Future<Output = Value> + Send { async move {
1344 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 {
1346 if !matches!(__v, crate::Value::Null) { return __v; }
1347 }
1348
1349 let mut symbols = get_arg(optional_args, 0, Value::Null);
1350 let mut params = get_arg(optional_args, 1, Value::Map({
1351 let mut m = indexmap::IndexMap::new();
1352 m
1353}));
1354 panic!("{}", crate::exchange_errors::not_supported(add(&self.id, &Value::Str(" fetchMarginModes () is not supported yet".to_string()))));
1355
1356 Value::Null
1357} }
1358
1359 fn un_watch_order_book(&mut self, mut symbol: Value, optional_args: &[Value]) -> impl ::std::future::Future<Output = Value> + Send { async move {
1360 let mut params = get_arg(optional_args, 0, Value::Map({
1361 let mut m = indexmap::IndexMap::new();
1362 m
1363}));
1364 panic!("{}", crate::exchange_errors::not_supported(add(&self.id, &Value::Str(" unWatchOrderBook() is not supported yet".to_string()))));
1365
1366 Value::Null
1367} }
1368
1369 fn fetch_time(&mut self, optional_args: &[Value]) -> impl ::std::future::Future<Output = Value> + Send { async move {
1370 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 {
1372 if !matches!(__v, crate::Value::Null) { return __v; }
1373 }
1374
1375 let mut params = get_arg(optional_args, 0, Value::Map({
1376 let mut m = indexmap::IndexMap::new();
1377 m
1378}));
1379 panic!("{}", crate::exchange_errors::not_supported(add(&self.id, &Value::Str(" fetchTime() is not supported yet".to_string()))));
1380
1381 Value::Null
1382} }
1383
1384 fn fetch_trading_limits(&mut self, optional_args: &[Value]) -> impl ::std::future::Future<Output = Value> + Send { async move {
1385 let mut symbols = get_arg(optional_args, 0, Value::Null);
1386 let mut params = get_arg(optional_args, 1, Value::Map({
1387 let mut m = indexmap::IndexMap::new();
1388 m
1389}));
1390 panic!("{}", crate::exchange_errors::not_supported(add(&self.id, &Value::Str(" fetchTradingLimits() is not supported yet".to_string()))));
1391
1392 Value::Null
1393} }
1394
1395 fn parse_currency(&self, mut rawCurrency: Value) -> Value {
1396 { let __v = crate::exchange::DerivedExchange::parse_currency(self, rawCurrency.clone()); if !matches!(__v, crate::Value::Null) { return __v; } }
1398
1399 panic!("{}", crate::exchange_errors::not_supported(add(&self.id, &Value::Str(" parseCurrency() is not supported yet".to_string()))));
1400
1401 Value::Null
1402}
1403
1404 fn parse_currencies(&self, mut rawCurrencies: Value) -> Value {
1405 let mut result: Value = Value::Map({
1406 let mut m = indexmap::IndexMap::new();
1407 m
1408 });
1409 let mut arr: Value = self.to_array(rawCurrencies.clone());
1410 {
1411 let mut i: Value = Value::Int(0);
1412 let mut __for_first_78: bool = true;
1413 while { if !__for_first_78 { i = add(&i, &Value::Int(1)); } __for_first_78 = false; is_less_than(&i, &get_array_length(&arr)) } {
1414 let mut parsed: Value = <Self as crate::exchange_generated::ExchangeBase>::parse_currency(self, get_value(&arr, &i));
1415 if is_equal(&parsed, &Value::Null) {
1416 continue;
1417 }
1418 let mut code: Value = get_value(&parsed, &Value::Str("code".to_string()));
1419 add_element_to_object(&mut result, &code, parsed.clone());
1420 }
1421 }
1422 return result;
1423
1424 Value::Null
1425}
1426
1427 fn parse_market(&self, mut market: Value) -> Value {
1428 { let __v = crate::exchange::DerivedExchange::parse_market(self, market.clone()); if !matches!(__v, crate::Value::Null) { return __v; } }
1430
1431 panic!("{}", crate::exchange_errors::not_supported(add(&self.id, &Value::Str(" parseMarket() is not supported yet".to_string()))));
1432
1433 Value::Null
1434}
1435
1436 fn parse_markets(&self, mut markets: Value) -> Value {
1437 let mut result: Value = Value::List(vec![]);
1438 {
1439 let mut i: Value = Value::Int(0);
1440 let mut __for_first_79: bool = true;
1441 while { if !__for_first_79 { i = add(&i, &Value::Int(1)); } __for_first_79 = false; is_less_than(&i, &get_array_length(&markets)) } {
1442 append_to_array(&mut result, <Self as crate::exchange_generated::ExchangeBase>::parse_market(self, get_value(&markets, &i)));
1443 }
1444 }
1445 return result;
1446
1447 Value::Null
1448}
1449
1450 fn parse_ticker(&self, mut ticker: Value, optional_args: &[Value]) -> Value {
1451 { let __v = crate::exchange::DerivedExchange::parse_ticker(self, ticker.clone(), crate::runtime::get_arg(optional_args, 0, crate::Value::Null)); if !matches!(__v, crate::Value::Null) { return __v; } }
1453
1454 let mut market = get_arg(optional_args, 0, Value::Null);
1455 panic!("{}", crate::exchange_errors::not_supported(add(&self.id, &Value::Str(" parseTicker() is not supported yet".to_string()))));
1456
1457 Value::Null
1458}
1459
1460 fn parse_deposit_address(&self, mut depositAddress: Value, optional_args: &[Value]) -> Value {
1461 { let __v = crate::exchange::DerivedExchange::parse_deposit_address(self, depositAddress.clone(), crate::runtime::get_arg(optional_args, 0, crate::Value::Null)); if !matches!(__v, crate::Value::Null) { return __v; } }
1463
1464 let mut currency = get_arg(optional_args, 0, Value::Null);
1465 panic!("{}", crate::exchange_errors::not_supported(add(&self.id, &Value::Str(" parseDepositAddress() is not supported yet".to_string()))));
1466
1467 Value::Null
1468}
1469
1470 fn parse_trade(&self, mut trade: Value, optional_args: &[Value]) -> Value {
1471 { let __v = crate::exchange::DerivedExchange::parse_trade(self, trade.clone(), crate::runtime::get_arg(optional_args, 0, crate::Value::Null)); if !matches!(__v, crate::Value::Null) { return __v; } }
1473
1474 let mut market = get_arg(optional_args, 0, Value::Null);
1475 panic!("{}", crate::exchange_errors::not_supported(add(&self.id, &Value::Str(" parseTrade() is not supported yet".to_string()))));
1476
1477 Value::Null
1478}
1479
1480 fn parse_transaction(&self, mut transaction: Value, optional_args: &[Value]) -> Value {
1481 { let __v = crate::exchange::DerivedExchange::parse_transaction(self, transaction.clone(), crate::runtime::get_arg(optional_args, 0, crate::Value::Null)); if !matches!(__v, crate::Value::Null) { return __v; } }
1483
1484 let mut currency = get_arg(optional_args, 0, Value::Null);
1485 panic!("{}", crate::exchange_errors::not_supported(add(&self.id, &Value::Str(" parseTransaction() is not supported yet".to_string()))));
1486
1487 Value::Null
1488}
1489
1490 fn parse_transfer(&self, mut transfer: Value, optional_args: &[Value]) -> Value {
1491 { 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; } }
1493
1494 let mut currency = get_arg(optional_args, 0, Value::Null);
1495 if is_equal(&transfer, &Value::Null) {
1496 panic!("{}", crate::exchange_errors::not_supported(add(&self.id, &Value::Str(" parseTransfer() is not supported yet".to_string()))));
1497 }
1498 panic!("{}", crate::exchange_errors::not_supported(add(&self.id, &Value::Str(" parseTransfer() is not supported yet".to_string()))));
1499
1500 Value::Null
1501}
1502
1503 fn parse_account(&self, mut account: Value) -> Value {
1504 { let __v = crate::exchange::DerivedExchange::parse_account(self, account.clone()); if !matches!(__v, crate::Value::Null) { return __v; } }
1506
1507 panic!("{}", crate::exchange_errors::not_supported(add(&self.id, &Value::Str(" parseAccount() is not supported yet".to_string()))));
1508
1509 Value::Null
1510}
1511
1512 fn parse_ledger_entry(&self, mut item: Value, optional_args: &[Value]) -> Value {
1513 { let __v = crate::exchange::DerivedExchange::parse_ledger_entry(self, item.clone(), crate::runtime::get_arg(optional_args, 0, crate::Value::Null)); if !matches!(__v, crate::Value::Null) { return __v; } }
1515
1516 let mut currency = get_arg(optional_args, 0, Value::Null);
1517 panic!("{}", crate::exchange_errors::not_supported(add(&self.id, &Value::Str(" parseLedgerEntry() is not supported yet".to_string()))));
1518
1519 Value::Null
1520}
1521
1522 fn parse_order(&self, mut order: Value, optional_args: &[Value]) -> Value {
1523 { let __v = crate::exchange::DerivedExchange::parse_order(self, order.clone(), crate::runtime::get_arg(optional_args, 0, crate::Value::Null)); if !matches!(__v, crate::Value::Null) { return __v; } }
1525
1526 let mut market = get_arg(optional_args, 0, Value::Null);
1527 panic!("{}", crate::exchange_errors::not_supported(add(&self.id, &Value::Str(" parseOrder() is not supported yet".to_string()))));
1528
1529 Value::Null
1530}
1531
1532 fn fetch_cross_borrow_rates(&mut self, optional_args: &[Value]) -> impl ::std::future::Future<Output = Value> + Send { async move {
1533 let mut params = get_arg(optional_args, 0, Value::Map({
1534 let mut m = indexmap::IndexMap::new();
1535 m
1536}));
1537 panic!("{}", crate::exchange_errors::not_supported(add(&self.id, &Value::Str(" fetchCrossBorrowRates() is not supported yet".to_string()))));
1538
1539 Value::Null
1540} }
1541
1542 fn fetch_isolated_borrow_rates(&mut self, optional_args: &[Value]) -> impl ::std::future::Future<Output = Value> + Send { async move {
1543 let mut params = get_arg(optional_args, 0, Value::Map({
1544 let mut m = indexmap::IndexMap::new();
1545 m
1546}));
1547 panic!("{}", crate::exchange_errors::not_supported(add(&self.id, &Value::Str(" fetchIsolatedBorrowRates() is not supported yet".to_string()))));
1548
1549 Value::Null
1550} }
1551
1552 fn parse_market_leverage_tiers(&self, mut info: Value, optional_args: &[Value]) -> Value {
1553 { let __v = crate::exchange::DerivedExchange::parse_market_leverage_tiers(self, info.clone(), crate::runtime::get_arg(optional_args, 0, crate::Value::Null)); if !matches!(__v, crate::Value::Null) { return __v; } }
1555
1556 let mut market = get_arg(optional_args, 0, Value::Null);
1557 panic!("{}", crate::exchange_errors::not_supported(add(&self.id, &Value::Str(" parseMarketLeverageTiers() is not supported yet".to_string()))));
1558
1559 Value::Null
1560}
1561
1562 fn fetch_leverage_tiers(&mut self, optional_args: &[Value]) -> impl ::std::future::Future<Output = Value> + Send { async move {
1563 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 {
1565 if !matches!(__v, crate::Value::Null) { return __v; }
1566 }
1567
1568 let mut symbols = get_arg(optional_args, 0, Value::Null);
1569 let mut params = get_arg(optional_args, 1, Value::Map({
1570 let mut m = indexmap::IndexMap::new();
1571 m
1572}));
1573 panic!("{}", crate::exchange_errors::not_supported(add(&self.id, &Value::Str(" fetchLeverageTiers() is not supported yet".to_string()))));
1574
1575 Value::Null
1576} }
1577
1578 fn parse_position(&self, mut position: Value, optional_args: &[Value]) -> Value {
1579 { let __v = crate::exchange::DerivedExchange::parse_position(self, position.clone(), crate::runtime::get_arg(optional_args, 0, crate::Value::Null)); if !matches!(__v, crate::Value::Null) { return __v; } }
1581
1582 let mut market = get_arg(optional_args, 0, Value::Null);
1583 panic!("{}", crate::exchange_errors::not_supported(add(&self.id, &Value::Str(" parsePosition() is not supported yet".to_string()))));
1584
1585 Value::Null
1586}
1587
1588 fn parse_funding_rate_history(&self, mut info: Value, optional_args: &[Value]) -> Value {
1589 { let __v = crate::exchange::DerivedExchange::parse_funding_rate_history(self, info.clone(), crate::runtime::get_arg(optional_args, 0, crate::Value::Null)); if !matches!(__v, crate::Value::Null) { return __v; } }
1591
1592 let mut market = get_arg(optional_args, 0, Value::Null);
1593 panic!("{}", crate::exchange_errors::not_supported(add(&self.id, &Value::Str(" parseFundingRateHistory() is not supported yet".to_string()))));
1594
1595 Value::Null
1596}
1597
1598 fn parse_borrow_interest(&self, mut info: Value, optional_args: &[Value]) -> Value {
1599 { let __v = crate::exchange::DerivedExchange::parse_borrow_interest(self, info.clone(), crate::runtime::get_arg(optional_args, 0, crate::Value::Null)); if !matches!(__v, crate::Value::Null) { return __v; } }
1601
1602 let mut market = get_arg(optional_args, 0, Value::Null);
1603 panic!("{}", crate::exchange_errors::not_supported(add(&self.id, &Value::Str(" parseBorrowInterest() is not supported yet".to_string()))));
1604
1605 Value::Null
1606}
1607
1608 fn parse_isolated_borrow_rate(&self, mut info: Value, optional_args: &[Value]) -> Value {
1609 let mut market = get_arg(optional_args, 0, Value::Null);
1610 panic!("{}", crate::exchange_errors::not_supported(add(&self.id, &Value::Str(" parseIsolatedBorrowRate() is not supported yet".to_string()))));
1611
1612 Value::Null
1613}
1614
1615 fn parse_ws_trade(&self, mut trade: Value, optional_args: &[Value]) -> Value {
1616 let mut market = get_arg(optional_args, 0, Value::Null);
1617 panic!("{}", crate::exchange_errors::not_supported(add(&self.id, &Value::Str(" parseWsTrade() is not supported yet".to_string()))));
1618
1619 Value::Null
1620}
1621
1622 fn parse_ws_order(&self, mut order: Value, optional_args: &[Value]) -> Value {
1623 let mut market = get_arg(optional_args, 0, Value::Null);
1624 panic!("{}", crate::exchange_errors::not_supported(add(&self.id, &Value::Str(" parseWsOrder() is not supported yet".to_string()))));
1625
1626 Value::Null
1627}
1628
1629 fn parse_ws_order_trade(&self, mut trade: Value, optional_args: &[Value]) -> Value {
1630 let mut market = get_arg(optional_args, 0, Value::Null);
1631 panic!("{}", crate::exchange_errors::not_supported(add(&self.id, &Value::Str(" parseWsOrderTrade() is not supported yet".to_string()))));
1632
1633 Value::Null
1634}
1635
1636 fn parse_ws_ohlcv(&self, mut ohlcv: Value, optional_args: &[Value]) -> Value {
1637 let mut market = get_arg(optional_args, 0, Value::Null);
1638 return <Self as crate::exchange_generated::ExchangeBase>::parse_ohlcv(self, ohlcv.clone(), &[market.clone()]);
1639
1640 Value::Null
1641}
1642
1643 fn fetch_funding_rates(&mut self, optional_args: &[Value]) -> impl ::std::future::Future<Output = Value> + Send { async move {
1644 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 {
1646 if !matches!(__v, crate::Value::Null) { return __v; }
1647 }
1648
1649 let mut symbols = get_arg(optional_args, 0, Value::Null);
1650 let mut params = get_arg(optional_args, 1, Value::Map({
1651 let mut m = indexmap::IndexMap::new();
1652 m
1653}));
1654 panic!("{}", crate::exchange_errors::not_supported(add(&self.id, &Value::Str(" fetchFundingRates() is not supported yet".to_string()))));
1655
1656 Value::Null
1657} }
1658
1659 fn fetch_funding_intervals(&mut self, optional_args: &[Value]) -> impl ::std::future::Future<Output = Value> + Send { async move {
1660 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 {
1662 if !matches!(__v, crate::Value::Null) { return __v; }
1663 }
1664
1665 let mut symbols = get_arg(optional_args, 0, Value::Null);
1666 let mut params = get_arg(optional_args, 1, Value::Map({
1667 let mut m = indexmap::IndexMap::new();
1668 m
1669}));
1670 panic!("{}", crate::exchange_errors::not_supported(add(&self.id, &Value::Str(" fetchFundingIntervals() is not supported yet".to_string()))));
1671
1672 Value::Null
1673} }
1674
1675 fn watch_funding_rate(&mut self, mut symbol: Value, optional_args: &[Value]) -> impl ::std::future::Future<Output = Value> + Send { async move {
1676 let mut params = get_arg(optional_args, 0, Value::Map({
1677 let mut m = indexmap::IndexMap::new();
1678 m
1679}));
1680 panic!("{}", crate::exchange_errors::not_supported(add(&self.id, &Value::Str(" watchFundingRate() is not supported yet".to_string()))));
1681
1682 Value::Null
1683} }
1684
1685 fn watch_funding_rates(&mut self, optional_args: &[Value]) -> impl ::std::future::Future<Output = Value> + Send { async move {
1686 let mut symbols = get_arg(optional_args, 0, Value::Null);
1687 let mut params = get_arg(optional_args, 1, Value::Map({
1688 let mut m = indexmap::IndexMap::new();
1689 m
1690}));
1691 panic!("{}", crate::exchange_errors::not_supported(add(&self.id, &Value::Str(" watchFundingRates() is not supported yet".to_string()))));
1692
1693 Value::Null
1694} }
1695
1696 fn un_watch_funding_rates(&mut self, optional_args: &[Value]) -> impl ::std::future::Future<Output = Value> + Send { async move {
1697 let mut symbols = get_arg(optional_args, 0, Value::Null);
1698 let mut params = get_arg(optional_args, 1, Value::Map({
1699 let mut m = indexmap::IndexMap::new();
1700 m
1701}));
1702 panic!("{}", crate::exchange_errors::not_supported(add(&self.id, &Value::Str(" unWatchFundingRates() is not supported yet".to_string()))));
1703
1704 Value::Null
1705} }
1706
1707 fn watch_funding_rates_for_symbols(&mut self, mut symbols: Value, optional_args: &[Value]) -> impl ::std::future::Future<Output = Value> + Send { async move {
1708 let mut params = get_arg(optional_args, 0, Value::Map({
1709 let mut m = indexmap::IndexMap::new();
1710 m
1711}));
1712 return self.watch_funding_rates(&[symbols.clone(), params.clone()]).await;
1713
1714 Value::Null
1715} }
1716
1717 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 {
1718 if let Some(__v) = self.dispatch_to_derived("transfer", { let mut __args: Vec<crate::Value> = Vec::new(); __args.push(code.clone()); __args.push(amount.clone()); __args.push(fromAccount.clone()); __args.push(toAccount.clone()); __args.extend_from_slice(optional_args); __args }).await {
1720 if !matches!(__v, crate::Value::Null) { return __v; }
1721 }
1722
1723 let mut params = get_arg(optional_args, 0, Value::Map({
1724 let mut m = indexmap::IndexMap::new();
1725 m
1726}));
1727 panic!("{}", crate::exchange_errors::not_supported(add(&self.id, &Value::Str(" transfer() is not supported yet".to_string()))));
1728
1729 Value::Null
1730} }
1731
1732 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 {
1733 if let Some(__v) = self.dispatch_to_derived("withdraw", { let mut __args: Vec<crate::Value> = Vec::new(); __args.push(code.clone()); __args.push(amount.clone()); __args.push(address.clone()); __args.extend_from_slice(optional_args); __args }).await {
1735 if !matches!(__v, crate::Value::Null) { return __v; }
1736 }
1737
1738 let mut tag = get_arg(optional_args, 0, Value::Null);
1739 let mut params = get_arg(optional_args, 1, Value::Map({
1740 let mut m = indexmap::IndexMap::new();
1741 m
1742}));
1743 panic!("{}", crate::exchange_errors::not_supported(add(&self.id, &Value::Str(" withdraw() is not supported yet".to_string()))));
1744
1745 Value::Null
1746} }
1747
1748 fn create_deposit_address(&mut self, mut code: Value, optional_args: &[Value]) -> impl ::std::future::Future<Output = Value> + Send { async move {
1749 let mut params = get_arg(optional_args, 0, Value::Map({
1750 let mut m = indexmap::IndexMap::new();
1751 m
1752}));
1753 panic!("{}", crate::exchange_errors::not_supported(add(&self.id, &Value::Str(" createDepositAddress() is not supported yet".to_string()))));
1754
1755 Value::Null
1756} }
1757
1758 fn set_leverage(&mut self, mut leverage: Value, optional_args: &[Value]) -> impl ::std::future::Future<Output = Value> + Send { async move {
1759 if let Some(__v) = self.dispatch_to_derived("set_leverage", { let mut __args: Vec<crate::Value> = Vec::new(); __args.push(leverage.clone()); __args.extend_from_slice(optional_args); __args }).await {
1761 if !matches!(__v, crate::Value::Null) { return __v; }
1762 }
1763
1764 let mut symbol = get_arg(optional_args, 0, Value::Null);
1765 let mut params = get_arg(optional_args, 1, Value::Map({
1766 let mut m = indexmap::IndexMap::new();
1767 m
1768}));
1769 panic!("{}", crate::exchange_errors::not_supported(add(&self.id, &Value::Str(" setLeverage() is not supported yet".to_string()))));
1770
1771 Value::Null
1772} }
1773
1774 fn fetch_leverage(&mut self, mut symbol: Value, optional_args: &[Value]) -> impl ::std::future::Future<Output = Value> + Send { async move {
1775 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 {
1777 if !matches!(__v, crate::Value::Null) { return __v; }
1778 }
1779
1780 let mut params = get_arg(optional_args, 0, Value::Map({
1781 let mut m = indexmap::IndexMap::new();
1782 m
1783}));
1784 if !is_equal(&get_value(&self.has, &Value::Str("fetchLeverages".to_string())), &Value::Null) && !is_equal(&get_value(&self.has, &Value::Str("fetchLeverages".to_string())), &Value::Bool(false)) {
1785 let mut leverages: Value = self.fetch_leverages(&[Value::List(vec![symbol.clone()]), params.clone()]).await;
1786 return self.safe_dict(leverages.clone(), symbol.clone(), &[]);
1787 } else {
1788 panic!("{}", crate::exchange_errors::not_supported(add(&self.id, &Value::Str(" fetchLeverage() is not supported yet".to_string()))));
1789 }
1790
1791 Value::Null
1792} }
1793
1794 fn fetch_leverages(&mut self, optional_args: &[Value]) -> impl ::std::future::Future<Output = Value> + Send { async move {
1795 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 {
1797 if !matches!(__v, crate::Value::Null) { return __v; }
1798 }
1799
1800 let mut symbols = get_arg(optional_args, 0, Value::Null);
1801 let mut params = get_arg(optional_args, 1, Value::Map({
1802 let mut m = indexmap::IndexMap::new();
1803 m
1804}));
1805 panic!("{}", crate::exchange_errors::not_supported(add(&self.id, &Value::Str(" fetchLeverages() is not supported yet".to_string()))));
1806
1807 Value::Null
1808} }
1809
1810 fn set_position_mode(&mut self, mut hedged: Value, optional_args: &[Value]) -> impl ::std::future::Future<Output = Value> + Send { async move {
1811 if let Some(__v) = self.dispatch_to_derived("set_position_mode", { let mut __args: Vec<crate::Value> = Vec::new(); __args.push(hedged.clone()); __args.extend_from_slice(optional_args); __args }).await {
1813 if !matches!(__v, crate::Value::Null) { return __v; }
1814 }
1815
1816 let mut symbol = get_arg(optional_args, 0, Value::Null);
1817 let mut params = get_arg(optional_args, 1, Value::Map({
1818 let mut m = indexmap::IndexMap::new();
1819 m
1820}));
1821 panic!("{}", crate::exchange_errors::not_supported(add(&self.id, &Value::Str(" setPositionMode() is not supported yet".to_string()))));
1822
1823 Value::Null
1824} }
1825
1826 fn add_margin(&mut self, mut symbol: Value, mut amount: Value, optional_args: &[Value]) -> impl ::std::future::Future<Output = Value> + Send { async move {
1827 if let Some(__v) = self.dispatch_to_derived("add_margin", { let mut __args: Vec<crate::Value> = Vec::new(); __args.push(symbol.clone()); __args.push(amount.clone()); __args.extend_from_slice(optional_args); __args }).await {
1829 if !matches!(__v, crate::Value::Null) { return __v; }
1830 }
1831
1832 let mut params = get_arg(optional_args, 0, Value::Map({
1833 let mut m = indexmap::IndexMap::new();
1834 m
1835}));
1836 panic!("{}", crate::exchange_errors::not_supported(add(&self.id, &Value::Str(" addMargin() is not supported yet".to_string()))));
1837
1838 Value::Null
1839} }
1840
1841 fn reduce_margin(&mut self, mut symbol: Value, mut amount: Value, optional_args: &[Value]) -> impl ::std::future::Future<Output = Value> + Send { async move {
1842 if let Some(__v) = self.dispatch_to_derived("reduce_margin", { let mut __args: Vec<crate::Value> = Vec::new(); __args.push(symbol.clone()); __args.push(amount.clone()); __args.extend_from_slice(optional_args); __args }).await {
1844 if !matches!(__v, crate::Value::Null) { return __v; }
1845 }
1846
1847 let mut params = get_arg(optional_args, 0, Value::Map({
1848 let mut m = indexmap::IndexMap::new();
1849 m
1850}));
1851 panic!("{}", crate::exchange_errors::not_supported(add(&self.id, &Value::Str(" reduceMargin() is not supported yet".to_string()))));
1852
1853 Value::Null
1854} }
1855
1856 fn set_margin(&mut self, mut symbol: Value, mut amount: Value, optional_args: &[Value]) -> impl ::std::future::Future<Output = Value> + Send { async move {
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(add(&self.id, &Value::Str(" setMargin() is not supported yet".to_string()))));
1862
1863 Value::Null
1864} }
1865
1866 fn fetch_long_short_ratio(&mut self, mut symbol: Value, optional_args: &[Value]) -> impl ::std::future::Future<Output = Value> + Send { async move {
1867 let mut timeframe = get_arg(optional_args, 0, Value::Null);
1868 let mut params = get_arg(optional_args, 1, Value::Map({
1869 let mut m = indexmap::IndexMap::new();
1870 m
1871}));
1872 panic!("{}", crate::exchange_errors::not_supported(add(&self.id, &Value::Str(" fetchLongShortRatio() is not supported yet".to_string()))));
1873
1874 Value::Null
1875} }
1876
1877 fn fetch_long_short_ratio_history(&mut self, optional_args: &[Value]) -> impl ::std::future::Future<Output = Value> + Send { async move {
1878 let mut symbol = get_arg(optional_args, 0, Value::Null);
1879 let mut timeframe = get_arg(optional_args, 1, Value::Null);
1880 let mut since = get_arg(optional_args, 2, Value::Null);
1881 let mut limit = get_arg(optional_args, 3, Value::Null);
1882 let mut params = get_arg(optional_args, 4, Value::Map({
1883 let mut m = indexmap::IndexMap::new();
1884 m
1885}));
1886 panic!("{}", crate::exchange_errors::not_supported(add(&self.id, &Value::Str(" fetchLongShortRatioHistory() is not supported yet".to_string()))));
1887
1888 Value::Null
1889} }
1890
1891 fn fetch_margin_adjustment_history(&mut self, optional_args: &[Value]) -> impl ::std::future::Future<Output = Value> + Send { async move {
1892 let mut symbol = get_arg(optional_args, 0, Value::Null);
1893 let mut type_var = get_arg(optional_args, 1, Value::Null);
1894 let mut since = get_arg(optional_args, 2, Value::Null);
1895 let mut limit = get_arg(optional_args, 3, Value::Null);
1896 let mut params = get_arg(optional_args, 4, Value::Map({
1897 let mut m = indexmap::IndexMap::new();
1898 m
1899}));
1900 panic!("{}", crate::exchange_errors::not_supported(add(&self.id, &Value::Str(" fetchMarginAdjustmentHistory() is not supported yet".to_string()))));
1901
1902 Value::Null
1903} }
1904
1905 fn set_margin_mode(&mut self, mut marginMode: Value, optional_args: &[Value]) -> impl ::std::future::Future<Output = Value> + Send { async move {
1906 if let Some(__v) = self.dispatch_to_derived("set_margin_mode", { let mut __args: Vec<crate::Value> = Vec::new(); __args.push(marginMode.clone()); __args.extend_from_slice(optional_args); __args }).await {
1908 if !matches!(__v, crate::Value::Null) { return __v; }
1909 }
1910
1911 let mut symbol = get_arg(optional_args, 0, Value::Null);
1912 let mut params = get_arg(optional_args, 1, Value::Map({
1913 let mut m = indexmap::IndexMap::new();
1914 m
1915}));
1916 panic!("{}", crate::exchange_errors::not_supported(add(&self.id, &Value::Str(" setMarginMode() is not supported yet".to_string()))));
1917
1918 Value::Null
1919} }
1920
1921 fn fetch_deposit_addresses_by_network(&mut self, mut code: Value, optional_args: &[Value]) -> impl ::std::future::Future<Output = Value> + Send { async move {
1922 if let Some(__v) = self.dispatch_to_derived("fetch_deposit_addresses_by_network", { let mut __args: Vec<crate::Value> = Vec::new(); __args.push(code.clone()); __args.extend_from_slice(optional_args); __args }).await {
1924 if !matches!(__v, crate::Value::Null) { return __v; }
1925 }
1926
1927 let mut params = get_arg(optional_args, 0, Value::Map({
1928 let mut m = indexmap::IndexMap::new();
1929 m
1930}));
1931 panic!("{}", crate::exchange_errors::not_supported(add(&self.id, &Value::Str(" fetchDepositAddressesByNetwork() is not supported yet".to_string()))));
1932
1933 Value::Null
1934} }
1935
1936 fn fetch_open_interest_history(&mut self, mut symbol: Value, optional_args: &[Value]) -> impl ::std::future::Future<Output = Value> + Send { async move {
1937 let mut timeframe = get_arg(optional_args, 0, Value::Str("1h".to_string()));
1938 let mut since = get_arg(optional_args, 1, Value::Null);
1939 let mut limit = get_arg(optional_args, 2, Value::Null);
1940 let mut params = get_arg(optional_args, 3, Value::Map({
1941 let mut m = indexmap::IndexMap::new();
1942 m
1943}));
1944 panic!("{}", crate::exchange_errors::not_supported(add(&self.id, &Value::Str(" fetchOpenInterestHistory() is not supported yet".to_string()))));
1945
1946 Value::Null
1947} }
1948
1949 fn fetch_open_interests(&mut self, optional_args: &[Value]) -> impl ::std::future::Future<Output = Value> + Send { async move {
1950 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 {
1952 if !matches!(__v, crate::Value::Null) { return __v; }
1953 }
1954
1955 let mut symbols = get_arg(optional_args, 0, Value::Null);
1956 let mut params = get_arg(optional_args, 1, Value::Map({
1957 let mut m = indexmap::IndexMap::new();
1958 m
1959}));
1960 panic!("{}", crate::exchange_errors::not_supported(add(&self.id, &Value::Str(" fetchOpenInterests() is not supported yet".to_string()))));
1961
1962 Value::Null
1963} }
1964
1965 fn sign_in(&mut self, optional_args: &[Value]) -> impl ::std::future::Future<Output = Value> + Send { async move {
1966 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 {
1968 if !matches!(__v, crate::Value::Null) { return __v; }
1969 }
1970
1971 let mut params = get_arg(optional_args, 0, Value::Map({
1972 let mut m = indexmap::IndexMap::new();
1973 m
1974}));
1975 panic!("{}", crate::exchange_errors::not_supported(add(&self.id, &Value::Str(" signIn() is not supported yet".to_string()))));
1976
1977 Value::Null
1978} }
1979
1980 fn fetch_payment_methods(&mut self, optional_args: &[Value]) -> impl ::std::future::Future<Output = Value> + Send { async move {
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(add(&self.id, &Value::Str(" fetchPaymentMethods() is not supported yet".to_string()))));
1986
1987 Value::Null
1988} }
1989
1990 fn parse_to_int(&self, mut number: Value) -> Value {
1991 let mut stringifiedNumber: Value = self.number_to_string(number.clone());
1997 let mut convertedNumber: Value = crate::runtime::parse_float(&stringifiedNumber);
1998 return crate::runtime::parse_int(&convertedNumber);
1999
2000 Value::Null
2001}
2002
2003 fn parse_to_numeric(&self, mut number: Value) -> Value {
2004 let mut stringVersion: Value = self.number_to_string(number.clone()); if is_greater_than_or_equal(&get_index_of(&stringVersion, &Value::Str(".".to_string())), &Value::Int(0)) {
2010 return crate::runtime::parse_float(&stringVersion);
2011 }
2012 return crate::runtime::parse_int(&stringVersion);
2013
2014 Value::Null
2015}
2016
2017 fn is_round_number(&self, mut value: Value) -> Value {
2018 let mut res: Value = self.parse_to_numeric((mod_val(&value, &Value::Int(1))));
2021 return Value::Bool(is_equal(&res, &Value::Int(0)));
2022
2023 Value::Null
2024}
2025
2026 fn is_empty_string(&self, mut value: Value) -> Value {
2027 return Value::Bool(!is_true(&self.value_is_defined(value.clone())) || is_equal(&value, &Value::Str("".to_string())));
2028
2029 Value::Null
2030}
2031
2032 fn safe_number_omit_zero(&self, mut obj: Value, mut key: Value, optional_args: &[Value]) -> Value {
2033 let mut defaultValue = get_arg(optional_args, 0, Value::Null);
2034 let mut value: Value = self.safe_string(obj.clone(), key.clone(), &[]);
2035 let mut final_val: Value = self.parse_number(self.omit_zero(value.clone()), &[]);
2036 return ternary(is_true(&(is_equal(&final_val, &Value::Null))), defaultValue.clone(), final_val.clone());
2037
2038 Value::Null
2039}
2040
2041 fn safe_integer_omit_zero(&self, mut obj: Value, mut key: Value, optional_args: &[Value]) -> Value {
2042 let mut defaultValue = get_arg(optional_args, 0, Value::Null);
2043 let mut timestamp: Value = self.safe_integer(obj.clone(), key.clone(), &[defaultValue.clone()]);
2044 if is_equal(×tamp, &Value::Null) || is_equal(×tamp, &Value::Int(0)) {
2045 return Value::Null;
2046 }
2047 return timestamp;
2048
2049 Value::Null
2050}
2051
2052 fn after_construct(&mut self) {
2053 self.create_networks_by_id_object();
2055 self.features_generator();
2056 if !is_equal(&self.markets, &Value::Null) {
2058 self.set_markets(self.markets.clone(), &[]);
2059 }
2060 self.init_rest_rate_limiter();
2062 let mut isSandbox: Value = self.safe_bool2(self.options.clone(), Value::Str("sandbox".to_string()), Value::Str("testnet".to_string()), &[Value::Bool(false)]);
2064 if is_equal(&isSandbox, &Value::Bool(true)) {
2065 self.set_sandbox_mode(isSandbox.clone());
2066 }
2067}
2068
2069 fn init_rest_rate_limiter(&mut self) {
2070 if is_equal(&self.rateLimit, &Value::Null) || is_true(&(!is_equal(&self.id, &Value::Null) && is_equal(&self.rateLimit, &negate(&Value::Int(1))))) {
2071 panic!("{}", crate::exchange_errors::exchange_error(add(&self.id, &Value::Str(".rateLimit property is not configured".to_string()))));
2072 }
2073 let mut refillRate: Value = self.MAX_VALUE.clone();
2074 if is_greater_than(&self.rateLimit, &Value::Int(0)) {
2075 refillRate = divide(&Value::Int(1), &self.rateLimit);
2076 }
2077 let mut useLeaky: bool = is_true(&(is_equal(&self.rollingWindowSize, &Value::Int(0)))) || is_true(&(is_equal(&self.rateLimiterAlgorithm, &Value::Str("leakyBucket".to_string()))));
2078 let mut algorithm: Value = ternary(is_true(&useLeaky), Value::Str("leakyBucket".to_string()), Value::Str("rollingWindow".to_string()));
2079 let mut defaultBucket: Value = Value::Map({
2080 let mut m = indexmap::IndexMap::new();
2081 m.insert("delay".to_string(), Value::Float(0.001));
2082 m.insert("capacity".to_string(), Value::Int(1));
2083 m.insert("cost".to_string(), Value::Int(1));
2084 m.insert("refillRate".to_string(), refillRate.clone());
2085 m.insert("algorithm".to_string(), algorithm.clone());
2086 m.insert("windowSize".to_string(), self.rollingWindowSize.clone());
2087 m.insert("rateLimit".to_string(), self.rateLimit.clone());
2088 m
2089 });
2090 let mut existingBucket: Value = ternary(is_true(&(is_equal(&self.tokenBucket, &Value::Null))), Value::Map({
2091 let mut m = indexmap::IndexMap::new();
2092 m
2093}), self.tokenBucket.clone());
2094 { let __t = self.extend(defaultBucket.clone(), &[existingBucket.clone()]); self.tokenBucket = __t; }
2095 self.init_throttler();
2096}
2097
2098 fn features_generator(&mut self) {
2099 if is_equal(&self.features, &Value::Null) {
2114 return;
2115 }
2116 let mut initialFeatures: Value = self.features.clone();
2118 self.features = Value::Map({
2119 let mut m = indexmap::IndexMap::new();
2120 m
2121 });
2122 let mut unifiedMarketTypes: Value = Value::List(vec![Value::Str("spot".to_string()), Value::Str("swap".to_string()), Value::Str("future".to_string()), Value::Str("option".to_string())]);
2123 let mut subTypes: Value = Value::List(vec![Value::Str("linear".to_string()), Value::Str("inverse".to_string())]);
2124 {
2125 let mut i: Value = Value::Int(0);
2126 let mut __for_first_81: bool = true;
2127 while { if !__for_first_81 { i = add(&i, &Value::Int(1)); } __for_first_81 = false; is_less_than(&i, &get_array_length(&unifiedMarketTypes)) } {
2128 let mut marketType: Value = get_value(&unifiedMarketTypes, &i);
2129 let mut marketType: Value = get_value(&unifiedMarketTypes, &i);
2130 if !is_true(&(Value::Bool(in_op(&initialFeatures, &marketType)))) {
2132 add_element_to_object(&mut self.features, &marketType, Value::Null);
2133 } else {
2134 if is_equal(&marketType, &Value::Str("spot".to_string())) {
2135 { let __be_tmp = self.features_mapper(initialFeatures.clone(), marketType.clone(), &[]); add_element_to_object(&mut self.features, &marketType, __be_tmp); };
2136 } else {
2137 add_element_to_object(&mut self.features, &marketType, Value::Map({
2138 let mut m = indexmap::IndexMap::new();
2139 m
2140}));
2141 {
2142 let mut j: Value = Value::Int(0);
2143 let mut __for_first_80: bool = true;
2144 while { if !__for_first_80 { j = add(&j, &Value::Int(1)); } __for_first_80 = false; is_less_than(&j, &get_array_length(&subTypes)) } {
2145 let mut subType: Value = get_value(&subTypes, &j);
2146 let mut subType: Value = get_value(&subTypes, &j);
2147 { 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); };
2148 }
2149 }
2150 }
2151 }
2152 }
2153 }
2154}
2155
2156 fn features_mapper(&mut self, mut initialFeatures: Value, mut marketType: Value, optional_args: &[Value]) -> Value {
2157 let mut subType = get_arg(optional_args, 0, Value::Null);
2158 let mut featuresObj: Value = ternary(is_true(&(!is_equal(&subType, &Value::Null))), get_value(&get_value(&initialFeatures, &marketType), &subType), get_value(&initialFeatures, &marketType));
2159 if is_equal(&featuresObj, &Value::Null) {
2161 return Value::Null;
2162 }
2163 let mut extendsStr: Value = self.safe_string_k(featuresObj.clone(), "extends", &[]);
2164 if !is_equal(&extendsStr, &Value::Null) {
2165 featuresObj = self.omit(featuresObj.clone(), Value::Str("extends".to_string()), &[]);
2166 let mut extendObj: Value = self.features_mapper(initialFeatures.clone(), extendsStr.clone(), &[]);
2167 featuresObj = self.deep_extend(extendObj.clone(), &[featuresObj.clone()]);
2168 }
2169 if is_true(&Value::Bool(in_op(&featuresObj, &Value::Str("createOrder".to_string())))) {
2174 let mut value: Value = self.safe_dict(get_value(&featuresObj, &Value::Str("createOrder".to_string())), Value::Str("attachedStopLossTakeProfit".to_string()), &[]);
2175 add_element_to_object(get_value_mut(&mut featuresObj, &Value::Str("createOrder".to_string())), &Value::Str("stopLoss".to_string()), value.clone());
2176 add_element_to_object(get_value_mut(&mut featuresObj, &Value::Str("createOrder".to_string())), &Value::Str("takeProfit".to_string()), value.clone());
2177 if is_equal(&marketType, &Value::Str("spot".to_string())) {
2178 add_element_to_object(get_value_mut(&mut featuresObj, &Value::Str("createOrder".to_string())), &Value::Str("hedged".to_string()), Value::Bool(false));
2180 if !is_true(&(Value::Bool(in_op(&get_value(&featuresObj, &Value::Str("createOrder".to_string())), &Value::Str("leverage".to_string()))))) {
2182 add_element_to_object(get_value_mut(&mut featuresObj, &Value::Str("createOrder".to_string())), &Value::Str("leverage".to_string()), Value::Bool(false));
2183 }
2184 }
2185 if is_equal(&self.safe_bool(get_value(&get_value(&featuresObj, &Value::Str("createOrder".to_string())), &Value::Str("timeInForce".to_string())), Value::Str("GTC".to_string()), &[]), &Value::Null) {
2187 add_element_to_object(get_value_mut(get_value_mut(&mut featuresObj, &Value::Str("createOrder".to_string())), &Value::Str("timeInForce".to_string())), &Value::Str("GTC".to_string()), Value::Bool(true));
2188 }
2189 }
2190 let mut keys: Value = object_keys(&featuresObj);
2192 {
2193 let mut i: Value = Value::Int(0);
2194 let mut __for_first_82: bool = true;
2195 while { if !__for_first_82 { i = add(&i, &Value::Int(1)); } __for_first_82 = false; is_less_than(&i, &get_array_length(&keys)) } {
2196 let mut key: Value = get_value(&keys, &i);
2197 let mut key: Value = get_value(&keys, &i);
2198 let mut featureBlock: Value = get_value(&featuresObj, &key);
2199 let mut featureBlock: Value = get_value(&featuresObj, &key);
2200 if !is_true(&self.in_array(key.clone(), Value::List(vec![Value::Str("sandbox".to_string())]))) && !is_equal(&featureBlock, &Value::Null) {
2201 if !is_true(&(Value::Bool(in_op(&featureBlock, &Value::Str("symbolRequired".to_string()))))) {
2203 add_element_to_object(&mut featureBlock, &Value::Str("symbolRequired".to_string()), self.in_array(key.clone(), Value::List(vec![Value::Str("createOrder".to_string()), Value::Str("createOrders".to_string()), Value::Str("fetchOHLCV".to_string())])));
2204 }
2205 }
2206 }
2207 }
2208 return featuresObj;
2209
2210 Value::Null
2211}
2212
2213 fn feature_value(&self, mut symbol: Value, optional_args: &[Value]) -> Value {
2214 let mut methodName = get_arg(optional_args, 0, Value::Null);
2215 let mut paramName = get_arg(optional_args, 1, Value::Null);
2216 let mut defaultValue = get_arg(optional_args, 2, Value::Null);
2217 let mut market: Value = self.market(symbol.clone());
2228 return self.feature_value_by_type(get_value(&market, &Value::Str("type".to_string())), get_value(&market, &Value::Str("subType".to_string())), &[methodName.clone(), paramName.clone(), defaultValue.clone()]);
2229
2230 Value::Null
2231}
2232
2233 fn feature_value_by_type(&self, mut marketType: Value, mut subType: Value, optional_args: &[Value]) -> Value {
2234 let mut methodName = get_arg(optional_args, 0, Value::Null);
2235 let mut paramName = get_arg(optional_args, 1, Value::Null);
2236 let mut defaultValue = get_arg(optional_args, 2, Value::Null);
2237 if is_equal(&self.features, &Value::Null) {
2250 return defaultValue;
2251 }
2252 if is_equal(&marketType, &Value::Null) {
2253 return defaultValue;
2254 }
2255 if !is_true(&(Value::Bool(in_op(&self.features, &marketType)))) {
2257 return defaultValue;
2258 }
2259 if is_equal(&get_value(&self.features, &marketType), &Value::Null) {
2261 return defaultValue;
2262 }
2263 let mut methodsContainer: Value = get_value(&self.features, &marketType);
2264 if is_equal(&subType, &Value::Null) {
2265 if !is_equal(&marketType, &Value::Str("spot".to_string())) {
2266 return defaultValue;
2267 }
2268 } else {
2269 if !is_true(&(Value::Bool(in_op(&get_value(&self.features, &marketType), &subType)))) {
2270 return defaultValue;
2271 }
2272 if is_equal(&get_value(&get_value(&self.features, &marketType), &subType), &Value::Null) {
2274 return defaultValue;
2275 }
2276 methodsContainer = get_value(&get_value(&self.features, &marketType), &subType);
2277 }
2278 if is_equal(&methodName, &Value::Null) {
2280 return ternary(is_true(&(!is_equal(&defaultValue, &Value::Null))), defaultValue.clone(), methodsContainer.clone());
2281 }
2282 if !is_true(&(Value::Bool(in_op(&methodsContainer, &methodName)))) {
2283 return defaultValue;
2284 }
2285 let mut methodDict: Value = get_value(&methodsContainer, &methodName);
2286 let mut methodDict: Value = get_value(&methodsContainer, &methodName);
2287 if is_equal(&methodDict, &Value::Null) {
2288 return defaultValue;
2289 }
2290 if is_equal(¶mName, &Value::Null) {
2292 return ternary(is_true(&(!is_equal(&defaultValue, &Value::Null))), defaultValue.clone(), methodDict.clone());
2293 }
2294 let mut splited: Value = split(¶mName, &Value::Str(".".to_string())); let mut parentKey: Value = get_value(&splited, &Value::Int(0));
2296 let mut subKey: Value = self.safe_string(splited.clone(), Value::Int(1), &[]);
2297 if !is_true(&(Value::Bool(in_op(&methodDict, &parentKey)))) {
2298 return defaultValue;
2299 }
2300 let mut dictionary: Value = self.safe_dict(methodDict.clone(), parentKey.clone(), &[]);
2301 if is_equal(&dictionary, &Value::Null) {
2302 return get_value(&methodDict, &parentKey);
2303 } else {
2304 if is_equal(&subKey, &Value::Null) {
2306 return get_value(&methodDict, &parentKey);
2307 }
2308 if !is_true(&(Value::Bool(in_op(&get_value(&methodDict, &parentKey), &subKey)))) {
2310 return defaultValue;
2311 }
2312 return get_value(&get_value(&methodDict, &parentKey), &subKey);
2313 }
2314
2315 Value::Null
2316}
2317
2318 fn orderbook_checksum_message(&self, mut symbol: Value) -> Value {
2319 return add(&add(&symbol, &Value::Str(" : ".to_string())), &Value::Str("orderbook data checksum validation failed. You can reconnect by calling watchOrderBook again or you can mute the error by setting exchange.options[\"watchOrderBook\"][\"checksum\"] = false".to_string()));
2320
2321 Value::Null
2322}
2323
2324 fn create_networks_by_id_object(&mut self) {
2325 let mut networkIdsToCodesGenerated: Value = self.invert_flat_string_dictionary(self.safe_value_k(self.options.clone(), "networks", &[Value::Map({
2327 let mut m = indexmap::IndexMap::new();
2328 m
2329 })])); { let __be_tmp = self.extend(networkIdsToCodesGenerated.clone(), &[self.safe_value_k(self.options.clone(), "networksById", &[Value::Map({
2331 let mut m = indexmap::IndexMap::new();
2332 m
2333})])]); add_element_to_object(&mut self.options, &Value::Str("networksById".to_string()), __be_tmp); }; }
2335
2336 fn get_default_options(&self) -> Value {
2337 return Value::Map({
2338 let mut m = indexmap::IndexMap::new();
2339 m.insert("defaultNetworkCodeReplacements".to_string(), Value::Map({
2340 let mut m = indexmap::IndexMap::new();
2341 m.insert("ETH".to_string(), Value::Map({
2342 let mut m = indexmap::IndexMap::new();
2343 m.insert("primary".to_string(), Value::Str("ETH".to_string()));
2344 m.insert("secondary".to_string(), Value::Str("ERC20".to_string()));
2345 m.insert("default".to_string(), Value::Str("secondary".to_string()));
2346 m
2347}));
2348 m.insert("CRO".to_string(), Value::Map({
2349 let mut m = indexmap::IndexMap::new();
2350 m.insert("primary".to_string(), Value::Str("CRONOS".to_string()));
2351 m.insert("secondary".to_string(), Value::Str("CRC20".to_string()));
2352 m.insert("default".to_string(), Value::Str("secondary".to_string()));
2353 m
2354}));
2355 m.insert("TRX".to_string(), Value::Map({
2356 let mut m = indexmap::IndexMap::new();
2357 m.insert("primary".to_string(), Value::Str("TRX".to_string()));
2358 m.insert("secondary".to_string(), Value::Str("TRC20".to_string()));
2359 m.insert("default".to_string(), Value::Str("secondary".to_string()));
2360 m
2361}));
2362 m.insert("BTC".to_string(), Value::Map({
2363 let mut m = indexmap::IndexMap::new();
2364 m.insert("primary".to_string(), Value::Str("BTC".to_string()));
2365 m.insert("secondary".to_string(), Value::Str("BRC20".to_string()));
2366 m.insert("default".to_string(), Value::Str("primary".to_string()));
2367 m
2368}));
2369 m
2370}));
2371 m.insert("backwardSupportedNetworkCodes".to_string(), Value::Map({
2372 let mut m = indexmap::IndexMap::new();
2373 m.insert("ARB".to_string(), Value::Str("ARBITRUM".to_string()));
2374 m.insert("ARBONE".to_string(), Value::Str("ARBITRUM".to_string()));
2375 m.insert("ARBNOVA".to_string(), Value::Str("ARBITRUM_NOVA".to_string()));
2376 m
2377}));
2378 m
2379});
2380
2381 Value::Null
2382}
2383
2384 fn safe_ledger_entry(&self, mut entry: Value, optional_args: &[Value]) -> Value {
2385 let mut currency = get_arg(optional_args, 0, Value::Null);
2386 currency = self.safe_currency(Value::Null, &[currency.clone()]);
2387 let mut direction: Value = self.safe_string_k(entry.clone(), "direction", &[]);
2388 let mut before: Value = self.safe_string_k(entry.clone(), "before", &[]);
2389 let mut after: Value = self.safe_string_k(entry.clone(), "after", &[]);
2390 let mut amount: Value = self.safe_string_k(entry.clone(), "amount", &[]);
2391 if !is_equal(&amount, &Value::Null) {
2392 if is_equal(&before, &Value::Null) && !is_equal(&after, &Value::Null) {
2393 before = crate::precise::Precise::stringSub(&after, &amount);
2394 } else if !is_equal(&before, &Value::Null) && is_equal(&after, &Value::Null) {
2395 after = crate::precise::Precise::stringAdd(&before, &amount);
2396 }
2397 }
2398 if !is_equal(&before, &Value::Null) && !is_equal(&after, &Value::Null) {
2399 if is_equal(&direction, &Value::Null) {
2400 if is_true(&crate::precise::Precise::stringGt(&before, &after)) {
2401 direction = Value::Str("out".to_string());
2402 }
2403 if is_true(&crate::precise::Precise::stringGt(&after, &before)) {
2404 direction = Value::Str("in".to_string());
2405 }
2406 }
2407 }
2408 let mut fee: Value = self.safe_value_k(entry.clone(), "fee", &[]);
2409 if !is_equal(&fee, &Value::Null) {
2410 { let __be_tmp = self.safe_number_k(fee.clone(), "cost", &[]); add_element_to_object(&mut fee, &Value::Str("cost".to_string()), __be_tmp); };
2411 }
2412 let mut timestamp: Value = self.safe_integer_k(entry.clone(), "timestamp", &[]);
2413 let mut info: Value = self.safe_dict_k(entry.clone(), "info", &[Value::Map({
2414 let mut m = indexmap::IndexMap::new();
2415 m
2416})]);
2417 return Value::Map({
2418 let mut m = indexmap::IndexMap::new();
2419 m.insert("id".to_string(), self.safe_string_k(entry.clone(), "id", &[]));
2420 m.insert("timestamp".to_string(), timestamp.clone());
2421 m.insert("datetime".to_string(), self.iso8601(timestamp.clone()));
2422 m.insert("direction".to_string(), direction.clone());
2423 m.insert("account".to_string(), self.safe_string_k(entry.clone(), "account", &[]));
2424 m.insert("referenceId".to_string(), self.safe_string_k(entry.clone(), "referenceId", &[]));
2425 m.insert("referenceAccount".to_string(), self.safe_string_k(entry.clone(), "referenceAccount", &[]));
2426 m.insert("type".to_string(), self.safe_string_k(entry.clone(), "type", &[]));
2427 m.insert("currency".to_string(), get_value(¤cy, &Value::Str("code".to_string())));
2428 m.insert("amount".to_string(), self.parse_number(amount.clone(), &[]));
2429 m.insert("before".to_string(), self.parse_number(before.clone(), &[]));
2430 m.insert("after".to_string(), self.parse_number(after.clone(), &[]));
2431 m.insert("status".to_string(), self.safe_string_k(entry.clone(), "status", &[]));
2432 m.insert("fee".to_string(), fee.clone());
2433 m.insert("info".to_string(), info.clone());
2434 m
2435});
2436
2437 Value::Null
2438}
2439
2440 fn safe_currency_structure(&self, mut currency: Value) -> Value {
2441 let mut networks: Value = self.safe_dict_k(currency.clone(), "networks", &[Value::Map({
2443 let mut m = indexmap::IndexMap::new();
2444 m
2445})]);
2446 let mut keys: Value = object_keys(&networks);
2447 let mut length: Value = get_array_length(&keys);
2448 if !is_equal(&length, &Value::Int(0)) {
2449 {
2450 let mut i: Value = Value::Int(0);
2451 let mut __for_first_83: bool = true;
2452 while { if !__for_first_83 { i = add(&i, &Value::Int(1)); } __for_first_83 = false; is_less_than(&i, &length) } {
2453 let mut key: Value = get_value(&keys, &i);
2454 let mut key: Value = get_value(&keys, &i);
2455 let mut network: Value = get_value(&networks, &key);
2456 let mut network: Value = get_value(&networks, &key);
2457 let mut deposit: Value = self.safe_bool_k(network.clone(), "deposit", &[]);
2458 let mut currencyDeposit: Value = self.safe_bool_k(currency.clone(), "deposit", &[]);
2459 if is_equal(¤cyDeposit, &Value::Null) || is_true(&(is_equal(&deposit, &Value::Bool(true)))) {
2460 add_element_to_object(&mut currency, &Value::Str("deposit".to_string()), deposit.clone());
2461 }
2462 let mut withdraw: Value = self.safe_bool_k(network.clone(), "withdraw", &[]);
2463 let mut currencyWithdraw: Value = self.safe_bool_k(currency.clone(), "withdraw", &[]);
2464 if is_equal(¤cyWithdraw, &Value::Null) || is_true(&(is_equal(&withdraw, &Value::Bool(true)))) {
2465 add_element_to_object(&mut currency, &Value::Str("withdraw".to_string()), withdraw.clone());
2466 }
2467 let mut fee: Value = self.safe_string_k(network.clone(), "fee", &[]);
2469 let mut feeMain: Value = self.safe_string_k(currency.clone(), "fee", &[]);
2470 if is_equal(&feeMain, &Value::Null) || is_true(&crate::precise::Precise::stringLt(&fee, &feeMain)) {
2471 add_element_to_object(&mut currency, &Value::Str("fee".to_string()), self.parse_number(fee.clone(), &[]));
2472 }
2473 let mut precision: Value = self.safe_string_k(network.clone(), "precision", &[]);
2475 let mut precisionMain: Value = self.safe_string_k(currency.clone(), "precision", &[]);
2476 if is_equal(&precisionMain, &Value::Null) || is_true(&crate::precise::Precise::stringGt(&precision, &precisionMain)) {
2477 add_element_to_object(&mut currency, &Value::Str("precision".to_string()), self.parse_number(precision.clone(), &[]));
2478 }
2479 let mut limits: Value = self.safe_dict_k(network.clone(), "limits", &[]);
2481 let mut limitsMain: Value = self.safe_dict_k(currency.clone(), "limits", &[]);
2482 if is_equal(&limitsMain, &Value::Null) {
2483 add_element_to_object(&mut currency, &Value::Str("limits".to_string()), Value::Map({
2484 let mut m = indexmap::IndexMap::new();
2485 m
2486}));
2487 }
2488 let mut limitsDeposit: Value = self.safe_dict_k(limits.clone(), "deposit", &[]);
2490 let mut limitsDepositMain: Value = self.safe_dict_k(limitsMain.clone(), "deposit", &[]);
2491 if is_equal(&limitsDepositMain, &Value::Null) {
2492 add_element_to_object(get_value_mut(&mut currency, &Value::Str("limits".to_string())), &Value::Str("deposit".to_string()), Value::Map({
2493 let mut m = indexmap::IndexMap::new();
2494 m
2495}));
2496 }
2497 let mut limitsDepositMin: Value = self.safe_string_k(limitsDeposit.clone(), "min", &[]);
2498 let mut limitsDepositMax: Value = self.safe_string_k(limitsDeposit.clone(), "max", &[]);
2499 let mut limitsDepositMinMain: Value = self.safe_string_k(limitsDepositMain.clone(), "min", &[]);
2500 let mut limitsDepositMaxMain: Value = self.safe_string_k(limitsDepositMain.clone(), "max", &[]);
2501 if is_equal(&limitsDepositMinMain, &Value::Null) || is_true(&crate::precise::Precise::stringLt(&limitsDepositMin, &limitsDepositMinMain)) {
2503 add_element_to_object(get_value_mut(get_value_mut(&mut currency, &Value::Str("limits".to_string())), &Value::Str("deposit".to_string())), &Value::Str("min".to_string()), self.parse_number(limitsDepositMin.clone(), &[]));
2504 }
2505 if is_equal(&limitsDepositMaxMain, &Value::Null) || is_true(&crate::precise::Precise::stringGt(&limitsDepositMax, &limitsDepositMaxMain)) {
2507 add_element_to_object(get_value_mut(get_value_mut(&mut currency, &Value::Str("limits".to_string())), &Value::Str("deposit".to_string())), &Value::Str("max".to_string()), self.parse_number(limitsDepositMax.clone(), &[]));
2508 }
2509 let mut limitsWithdraw: Value = self.safe_dict_k(limits.clone(), "withdraw", &[]);
2511 let mut limitsWithdrawMain: Value = self.safe_dict_k(limitsMain.clone(), "withdraw", &[]);
2512 if is_equal(&limitsWithdrawMain, &Value::Null) {
2513 add_element_to_object(get_value_mut(&mut currency, &Value::Str("limits".to_string())), &Value::Str("withdraw".to_string()), Value::Map({
2514 let mut m = indexmap::IndexMap::new();
2515 m
2516}));
2517 }
2518 let mut limitsWithdrawMin: Value = self.safe_string_k(limitsWithdraw.clone(), "min", &[]);
2519 let mut limitsWithdrawMax: Value = self.safe_string_k(limitsWithdraw.clone(), "max", &[]);
2520 let mut limitsWithdrawMinMain: Value = self.safe_string_k(limitsWithdrawMain.clone(), "min", &[]);
2521 let mut limitsWithdrawMaxMain: Value = self.safe_string_k(limitsWithdrawMain.clone(), "max", &[]);
2522 if is_equal(&limitsWithdrawMinMain, &Value::Null) || is_true(&crate::precise::Precise::stringLt(&limitsWithdrawMin, &limitsWithdrawMinMain)) {
2524 add_element_to_object(get_value_mut(get_value_mut(&mut currency, &Value::Str("limits".to_string())), &Value::Str("withdraw".to_string())), &Value::Str("min".to_string()), self.parse_number(limitsWithdrawMin.clone(), &[]));
2525 }
2526 if is_equal(&limitsWithdrawMaxMain, &Value::Null) || is_true(&crate::precise::Precise::stringGt(&limitsWithdrawMax, &limitsWithdrawMaxMain)) {
2528 add_element_to_object(get_value_mut(get_value_mut(&mut currency, &Value::Str("limits".to_string())), &Value::Str("withdraw".to_string())), &Value::Str("max".to_string()), self.parse_number(limitsWithdrawMax.clone(), &[]));
2529 }
2530 }
2531 }
2532 }
2533 return self.extend(Value::Map({
2534 let mut m = indexmap::IndexMap::new();
2535 m.insert("info".to_string(), Value::Null);
2536 m.insert("id".to_string(), Value::Null);
2537 m.insert("numericId".to_string(), Value::Null);
2538 m.insert("code".to_string(), Value::Null);
2539 m.insert("precision".to_string(), Value::Null);
2540 m.insert("type".to_string(), Value::Null);
2541 m.insert("name".to_string(), Value::Null);
2542 m.insert("active".to_string(), Value::Null);
2543 m.insert("deposit".to_string(), Value::Null);
2544 m.insert("withdraw".to_string(), Value::Null);
2545 m.insert("fee".to_string(), Value::Null);
2546 m.insert("fees".to_string(), Value::Map({
2547 let mut m = indexmap::IndexMap::new();
2548 m
2549}));
2550 m.insert("networks".to_string(), Value::Map({
2551 let mut m = indexmap::IndexMap::new();
2552 m
2553}));
2554 m.insert("limits".to_string(), Value::Map({
2555 let mut m = indexmap::IndexMap::new();
2556 m.insert("deposit".to_string(), Value::Map({
2557 let mut m = indexmap::IndexMap::new();
2558 m.insert("min".to_string(), Value::Null);
2559 m.insert("max".to_string(), Value::Null);
2560 m
2561}));
2562 m.insert("withdraw".to_string(), Value::Map({
2563 let mut m = indexmap::IndexMap::new();
2564 m.insert("min".to_string(), Value::Null);
2565 m.insert("max".to_string(), Value::Null);
2566 m
2567}));
2568 m
2569}));
2570 m
2571}), &[currency.clone()]);
2572
2573 Value::Null
2574}
2575
2576 fn safe_market_structure(&self, optional_args: &[Value]) -> Value {
2577 let mut market = get_arg(optional_args, 0, Value::Null);
2578 let mut cleanStructure: Value = Value::Map({
2579 let mut m = indexmap::IndexMap::new();
2580 m.insert("id".to_string(), Value::Null);
2581 m.insert("lowercaseId".to_string(), Value::Null);
2582 m.insert("symbol".to_string(), Value::Null);
2583 m.insert("base".to_string(), Value::Null);
2584 m.insert("quote".to_string(), Value::Null);
2585 m.insert("settle".to_string(), Value::Null);
2586 m.insert("baseId".to_string(), Value::Null);
2587 m.insert("quoteId".to_string(), Value::Null);
2588 m.insert("settleId".to_string(), Value::Null);
2589 m.insert("type".to_string(), Value::Null);
2590 m.insert("spot".to_string(), Value::Null);
2591 m.insert("margin".to_string(), Value::Null);
2592 m.insert("swap".to_string(), Value::Null);
2593 m.insert("future".to_string(), Value::Null);
2594 m.insert("option".to_string(), Value::Null);
2595 m.insert("index".to_string(), Value::Null);
2596 m.insert("active".to_string(), Value::Null);
2597 m.insert("contract".to_string(), Value::Null);
2598 m.insert("linear".to_string(), Value::Null);
2599 m.insert("inverse".to_string(), Value::Null);
2600 m.insert("subType".to_string(), Value::Null);
2601 m.insert("taker".to_string(), Value::Null);
2602 m.insert("maker".to_string(), Value::Null);
2603 m.insert("contractSize".to_string(), Value::Null);
2604 m.insert("expiry".to_string(), Value::Null);
2605 m.insert("expiryDatetime".to_string(), Value::Null);
2606 m.insert("strike".to_string(), Value::Null);
2607 m.insert("optionType".to_string(), Value::Null);
2608 m.insert("precision".to_string(), Value::Map({
2609 let mut m = indexmap::IndexMap::new();
2610 m.insert("amount".to_string(), Value::Null);
2611 m.insert("price".to_string(), Value::Null);
2612 m.insert("cost".to_string(), Value::Null);
2613 m.insert("base".to_string(), Value::Null);
2614 m.insert("quote".to_string(), Value::Null);
2615 m
2616}));
2617 m.insert("limits".to_string(), Value::Map({
2618 let mut m = indexmap::IndexMap::new();
2619 m.insert("leverage".to_string(), Value::Map({
2620 let mut m = indexmap::IndexMap::new();
2621 m.insert("min".to_string(), Value::Null);
2622 m.insert("max".to_string(), Value::Null);
2623 m
2624}));
2625 m.insert("amount".to_string(), Value::Map({
2626 let mut m = indexmap::IndexMap::new();
2627 m.insert("min".to_string(), Value::Null);
2628 m.insert("max".to_string(), Value::Null);
2629 m
2630}));
2631 m.insert("price".to_string(), Value::Map({
2632 let mut m = indexmap::IndexMap::new();
2633 m.insert("min".to_string(), Value::Null);
2634 m.insert("max".to_string(), Value::Null);
2635 m
2636}));
2637 m.insert("cost".to_string(), Value::Map({
2638 let mut m = indexmap::IndexMap::new();
2639 m.insert("min".to_string(), Value::Null);
2640 m.insert("max".to_string(), Value::Null);
2641 m
2642}));
2643 m
2644}));
2645 m.insert("marginModes".to_string(), Value::Map({
2646 let mut m = indexmap::IndexMap::new();
2647 m.insert("cross".to_string(), Value::Null);
2648 m.insert("isolated".to_string(), Value::Null);
2649 m
2650}));
2651 m.insert("created".to_string(), Value::Null);
2652 m.insert("info".to_string(), Value::Null);
2653 m
2654 });
2655 if !is_equal(&market, &Value::Null) {
2656 let mut result: Value = self.extend(cleanStructure.clone(), &[market.clone()]);
2657 if is_equal(&get_value(&result, &Value::Str("spot".to_string())), &Value::Bool(true)) {
2659 if is_equal(&get_value(&result, &Value::Str("contract".to_string())), &Value::Null) {
2660 add_element_to_object(&mut result, &Value::Str("contract".to_string()), Value::Bool(false));
2661 }
2662 if is_equal(&get_value(&result, &Value::Str("swap".to_string())), &Value::Null) {
2663 add_element_to_object(&mut result, &Value::Str("swap".to_string()), Value::Bool(false));
2664 }
2665 if is_equal(&get_value(&result, &Value::Str("future".to_string())), &Value::Null) {
2666 add_element_to_object(&mut result, &Value::Str("future".to_string()), Value::Bool(false));
2667 }
2668 if is_equal(&get_value(&result, &Value::Str("option".to_string())), &Value::Null) {
2669 add_element_to_object(&mut result, &Value::Str("option".to_string()), Value::Bool(false));
2670 }
2671 if is_equal(&get_value(&result, &Value::Str("index".to_string())), &Value::Null) {
2672 add_element_to_object(&mut result, &Value::Str("index".to_string()), Value::Bool(false));
2673 }
2674 }
2675 return result;
2676 }
2677 return self.extend(cleanStructure.clone(), &[]);
2678
2679 Value::Null
2680}
2681
2682 fn set_markets(&mut self, mut markets: Value, optional_args: &[Value]) -> Value {
2683 let mut currencies = get_arg(optional_args, 0, Value::Null);
2684 let mut values: Value = Value::List(vec![]);
2685 { let __t = self.create_safe_dictionary(&[]); self.markets_by_id = __t; }
2686 let mut marketValues: Value = self.sort_by(self.to_array(markets.clone()), Value::Str("spot".to_string()), &[Value::Bool(true), Value::Bool(true)]);
2689 {
2690 let mut i: Value = Value::Int(0);
2691 let mut __for_first_85: bool = true;
2692 while { if !__for_first_85 { i = add(&i, &Value::Int(1)); } __for_first_85 = false; is_less_than(&i, &get_array_length(&marketValues)) } {
2693 let mut value: Value = get_value(&marketValues, &i);
2694 let mut value: Value = get_value(&marketValues, &i);
2695 if is_true(&Value::Bool(in_op(&self.markets_by_id, &get_value(&value, &Value::Str("id".to_string()))))) {
2696 let mut marketsByIdArray: Value = get_value(&self.markets_by_id, &get_value(&value, &Value::Str("id".to_string())));
2697 append_to_array(&mut marketsByIdArray, value.clone());
2698 add_element_to_object(&mut self.markets_by_id, &get_value(&value, &Value::Str("id".to_string())), marketsByIdArray.clone());
2699 } else {
2700 add_element_to_object(&mut self.markets_by_id, &get_value(&value, &Value::Str("id".to_string())), Value::List(vec![value.clone()]));
2701 }
2702 let mut valueDefined: Value = Value::Map({
2706 let mut m = indexmap::IndexMap::new();
2707 m
2708 });
2709 let mut valueKeys: Value = object_keys(&value);
2710 {
2711 let mut j: Value = Value::Int(0);
2712 let mut __for_first_84: bool = true;
2713 while { if !__for_first_84 { j = add(&j, &Value::Int(1)); } __for_first_84 = false; is_less_than(&j, &get_array_length(&valueKeys)) } {
2714 let mut valueKey: Value = get_value(&valueKeys, &j);
2715 let mut valueKey: Value = get_value(&valueKeys, &j);
2716 if !is_equal(&get_value(&value, &valueKey), &Value::Null) {
2717 add_element_to_object(&mut valueDefined, &valueKey, get_value(&value, &valueKey));
2718 }
2719 }
2720 }
2721 let mut market: Value = self.deep_extend(self.safe_market_structure(&[]), &[Value::Map({
2722 let mut m = indexmap::IndexMap::new();
2723 m.insert("precision".to_string(), self.precision.clone());
2724 m.insert("limits".to_string(), self.limits.clone());
2725 m
2726 }), get_value(&self.fees, &Value::Str("trading".to_string())), valueDefined.clone()]);
2727 if is_equal(&get_value(&market, &Value::Str("linear".to_string())), &Value::Bool(true)) {
2728 add_element_to_object(&mut market, &Value::Str("subType".to_string()), Value::Str("linear".to_string()));
2729 } else if is_equal(&get_value(&market, &Value::Str("inverse".to_string())), &Value::Bool(true)) {
2730 add_element_to_object(&mut market, &Value::Str("subType".to_string()), Value::Str("inverse".to_string()));
2731 } else {
2732 add_element_to_object(&mut market, &Value::Str("subType".to_string()), Value::Null);
2733 }
2734 append_to_array(&mut values, market.clone());
2735 }
2736 }
2737 { let __t = self.map_to_safe_map(self.index_by(values.clone(), Value::Str("symbol".to_string()))); self.markets = __t; }
2738 let mut marketsSortedBySymbol: Value = self.keysort(self.markets.clone(), &[]);
2739 let mut marketsSortedById: Value = self.keysort(self.markets_by_id.clone(), &[]);
2740 self.symbols = object_keys(&marketsSortedBySymbol);
2741 self.ids = object_keys(&marketsSortedById);
2742 let mut numCurrencies: Value = Value::Int(0);
2743 if !is_equal(¤cies, &Value::Null) {
2744 let mut keys: Value = object_keys(¤cies);
2745 numCurrencies = get_array_length(&keys);
2746 }
2747 if is_greater_than(&numCurrencies, &Value::Int(0)) {
2748 { let __t = self.map_to_safe_map(self.deep_extend(self.currencies.clone(), &[currencies.clone()])); self.currencies = __t; }
2750 } else {
2751 let mut baseCurrencies: Value = Value::List(vec![]);
2752 let mut quoteCurrencies: Value = Value::List(vec![]);
2753 {
2754 let mut i: Value = Value::Int(0);
2755 let mut __for_first_86: bool = true;
2756 while { if !__for_first_86 { i = add(&i, &Value::Int(1)); } __for_first_86 = false; is_less_than(&i, &get_array_length(&values)) } {
2757 let mut market: Value = get_value(&values, &i);
2758 let mut market: Value = get_value(&values, &i);
2759 let mut defaultCurrencyPrecision: Value = ternary(is_true(&(is_equal(&self.precisionMode, &Value::Int(crate::runtime::DECIMAL_PLACES)))), Value::Int(8), self.parse_number(Value::Str("1e-8".to_string()), &[]));
2760 let mut marketPrecision: Value = self.safe_dict_k(market.clone(), "precision", &[Value::Map({
2761 let mut m = indexmap::IndexMap::new();
2762 m
2763})]);
2764 if is_true(&Value::Bool(in_op(&market, &Value::Str("base".to_string())))) {
2765 let mut currency: Value = self.safe_currency_structure(Value::Map({
2766 let mut m = indexmap::IndexMap::new();
2767 m.insert("id".to_string(), self.safe_string2(market.clone(), Value::Str("baseId".to_string()), Value::Str("base".to_string()), &[]));
2768 m.insert("numericId".to_string(), self.safe_integer_k(market.clone(), "baseNumericId", &[]));
2769 m.insert("code".to_string(), self.safe_string_k(market.clone(), "base", &[]));
2770 m.insert("precision".to_string(), self.safe_value2(marketPrecision.clone(), Value::Str("base".to_string()), Value::Str("amount".to_string()), &[defaultCurrencyPrecision.clone()]));
2771 m
2772 }));
2773 append_to_array(&mut baseCurrencies, currency.clone());
2774 }
2775 if is_true(&Value::Bool(in_op(&market, &Value::Str("quote".to_string())))) {
2776 let mut currency: Value = self.safe_currency_structure(Value::Map({
2777 let mut m = indexmap::IndexMap::new();
2778 m.insert("id".to_string(), self.safe_string2(market.clone(), Value::Str("quoteId".to_string()), Value::Str("quote".to_string()), &[]));
2779 m.insert("numericId".to_string(), self.safe_integer_k(market.clone(), "quoteNumericId", &[]));
2780 m.insert("code".to_string(), self.safe_string_k(market.clone(), "quote", &[]));
2781 m.insert("precision".to_string(), self.safe_value2(marketPrecision.clone(), Value::Str("quote".to_string()), Value::Str("price".to_string()), &[defaultCurrencyPrecision.clone()]));
2782 m
2783 }));
2784 append_to_array(&mut quoteCurrencies, currency.clone());
2785 }
2786 }
2787 }
2788 baseCurrencies = self.sort_by(baseCurrencies.clone(), Value::Str("code".to_string()), &[Value::Bool(false), Value::Str("".to_string())]);
2789 quoteCurrencies = self.sort_by(quoteCurrencies.clone(), Value::Str("code".to_string()), &[Value::Bool(false), Value::Str("".to_string())]);
2790 { let __t = self.map_to_safe_map(self.index_by(baseCurrencies.clone(), Value::Str("code".to_string()))); self.baseCurrencies = __t; }
2791 { let __t = self.map_to_safe_map(self.index_by(quoteCurrencies.clone(), Value::Str("code".to_string()))); self.quoteCurrencies = __t; }
2792 let mut allCurrencies: Value = self.array_concat(baseCurrencies.clone(), quoteCurrencies.clone());
2793 let mut groupedCurrencies: Value = self.group_by(allCurrencies.clone(), Value::Str("code".to_string()), &[]);
2794 let mut codes: Value = object_keys(&groupedCurrencies);
2795 let mut resultingCurrencies: Value = Value::List(vec![]);
2796 {
2797 let mut i: Value = Value::Int(0);
2798 let mut __for_first_88: bool = true;
2799 while { if !__for_first_88 { i = add(&i, &Value::Int(1)); } __for_first_88 = false; is_less_than(&i, &get_array_length(&codes)) } {
2800 let mut code: Value = get_value(&codes, &i);
2801 let mut code: Value = get_value(&codes, &i);
2802 let mut groupedCurrenciesCode: Value = self.safe_list(groupedCurrencies.clone(), code.clone(), &[Value::List(vec![])]);
2803 let mut highestPrecisionCurrency: Value = self.safe_value(groupedCurrenciesCode.clone(), Value::Int(0), &[]);
2804 {
2805 let mut j: Value = Value::Int(1);
2806 let mut __for_first_87: bool = true;
2807 while { if !__for_first_87 { j = add(&j, &Value::Int(1)); } __for_first_87 = false; is_less_than(&j, &get_array_length(&groupedCurrenciesCode)) } {
2808 let mut currentCurrency: Value = get_value(&groupedCurrenciesCode, &j);
2809 let mut currentCurrency: Value = get_value(&groupedCurrenciesCode, &j);
2810 if is_equal(&self.precisionMode, &Value::Int(crate::runtime::TICK_SIZE)) {
2811 highestPrecisionCurrency = ternary(is_true(&(is_less_than(&get_value(¤tCurrency, &Value::Str("precision".to_string())), &get_value(&highestPrecisionCurrency, &Value::Str("precision".to_string()))))), currentCurrency.clone(), highestPrecisionCurrency.clone());
2812 } else {
2813 highestPrecisionCurrency = ternary(is_true(&(is_greater_than(&get_value(¤tCurrency, &Value::Str("precision".to_string())), &get_value(&highestPrecisionCurrency, &Value::Str("precision".to_string()))))), currentCurrency.clone(), highestPrecisionCurrency.clone());
2814 }
2815 }
2816 }
2817 append_to_array(&mut resultingCurrencies, highestPrecisionCurrency.clone());
2818 }
2819 }
2820 let mut sortedCurrencies: Value = self.sort_by(resultingCurrencies.clone(), Value::Str("code".to_string()), &[]);
2821 { let __t = self.map_to_safe_map(self.deep_extend(self.currencies.clone(), &[self.index_by(sortedCurrencies.clone(), Value::Str("code".to_string()))])); self.currencies = __t; }
2822 }
2823 { let __t = self.index_by_safe(self.currencies.clone(), Value::Str("id".to_string())); self.currencies_by_id = __t; }
2824 let mut currenciesSortedByCode: Value = self.keysort(self.currencies.clone(), &[]);
2825 self.codes = object_keys(¤ciesSortedByCode);
2826 if is_equal(&self.markets, &Value::Null) {
2827 panic!("{}", crate::exchange_errors::exchange_error(add(&self.id, &Value::Str(" setMarkets() markets not set".to_string()))));
2828 }
2829 return self.markets.clone();
2830
2831 Value::Null
2832}
2833
2834 fn set_markets_from_exchange(&mut self, mut sourceExchange: Value) -> Value {
2835 if !is_equal(&self.id, &get_value(&sourceExchange, &Value::Str("id".to_string()))) {
2837 panic!("{}", crate::exchange_errors::arguments_required(add(&add(&add(&self.id, &Value::Str(" shareMarkets() can only share markets with exchanges of the same type (got ".to_string())), &get_value(&sourceExchange, &Value::Str("id".to_string()))), &Value::Str(")".to_string()))));
2838 }
2839 if is_true(&(is_equal(&get_value(&sourceExchange, &Value::Str("markets".to_string())), &Value::Null))) || is_true(&(is_equal(&get_value(&sourceExchange, &Value::Str("markets".to_string())), &Value::Null))) {
2841 panic!("{}", crate::exchange_errors::exchange_error(Value::Str("setMarketsFromExchange() source exchange must have loaded markets first. Can call by using loadMarkets function".to_string())));
2842 }
2843 self.markets = get_value(&sourceExchange, &Value::Str("markets".to_string()));
2845 self.markets_by_id = get_value(&sourceExchange, &Value::Str("markets_by_id".to_string()));
2846 self.symbols = get_value(&sourceExchange, &Value::Str("symbols".to_string()));
2847 self.ids = get_value(&sourceExchange, &Value::Str("ids".to_string()));
2848 self.currencies = get_value(&sourceExchange, &Value::Str("currencies".to_string()));
2849 self.currencies_by_id = get_value(&sourceExchange, &Value::Str("currencies_by_id".to_string()));
2850 self.baseCurrencies = get_value(&sourceExchange, &Value::Str("baseCurrencies".to_string()));
2851 self.quoteCurrencies = get_value(&sourceExchange, &Value::Str("quoteCurrencies".to_string()));
2852 self.codes = get_value(&sourceExchange, &Value::Str("codes".to_string()));
2853 let mut sourceExchangeHelpers: Value = self.safe_list(get_value(&sourceExchange, &Value::Str("options".to_string())), Value::Str("marketHelperProps".to_string()), &[Value::List(vec![])]);
2855 {
2856 let mut i: Value = Value::Int(0);
2857 let mut __for_first_89: bool = true;
2858 while { if !__for_first_89 { i = add(&i, &Value::Int(1)); } __for_first_89 = false; is_less_than(&i, &get_array_length(&sourceExchangeHelpers)) } {
2859 let mut helper: Value = get_value(&sourceExchangeHelpers, &i);
2860 let mut helper: Value = get_value(&sourceExchangeHelpers, &i);
2861 if !is_equal(&get_value(&get_value(&sourceExchange, &Value::Str("options".to_string())), &helper), &Value::Null) {
2862 add_element_to_object(&mut self.options, &helper, get_value(&get_value(&sourceExchange, &Value::Str("options".to_string())), &helper));
2863 }
2864 }
2865 }
2866 return Value::Null;
2867
2868 Value::Null
2869}
2870
2871 fn get_describe_for_extended_ws_exchange(&self, mut currentRestInstance: Value, mut parentRestInstance: Value, mut wsBaseDescribe: Value) -> Value {
2872 let mut extendedRestDescribe: Value = self.deep_extend(parentRestInstance.describe(), &[currentRestInstance.describe()]);
2873 let mut superWithRestDescribe: Value = self.deep_extend(extendedRestDescribe.clone(), &[wsBaseDescribe.clone()]);
2874 return superWithRestDescribe;
2875
2876 Value::Null
2877}
2878
2879 fn safe_balance(&self, mut balance: Value) -> Value {
2880 let mut balances: Value = self.omit(balance.clone(), Value::List(vec![Value::Str("info".to_string()), Value::Str("timestamp".to_string()), Value::Str("datetime".to_string()), Value::Str("free".to_string()), Value::Str("used".to_string()), Value::Str("total".to_string())]), &[]);
2881 let mut codes: Value = object_keys(&balances);
2882 add_element_to_object(&mut balance, &Value::Str("free".to_string()), Value::Map({
2883 let mut m = indexmap::IndexMap::new();
2884 m
2885}));
2886 add_element_to_object(&mut balance, &Value::Str("used".to_string()), Value::Map({
2887 let mut m = indexmap::IndexMap::new();
2888 m
2889}));
2890 add_element_to_object(&mut balance, &Value::Str("total".to_string()), Value::Map({
2891 let mut m = indexmap::IndexMap::new();
2892 m
2893}));
2894 let mut debtBalance: Value = Value::Map({
2895 let mut m = indexmap::IndexMap::new();
2896 m
2897 });
2898 {
2899 let mut i: Value = Value::Int(0);
2900 let mut __for_first_90: bool = true;
2901 while { if !__for_first_90 { i = add(&i, &Value::Int(1)); } __for_first_90 = false; is_less_than(&i, &get_array_length(&codes)) } {
2902 let mut code: Value = get_value(&codes, &i);
2903 let mut code: Value = get_value(&codes, &i);
2904 let mut total: Value = self.safe_string_k(get_value(&balance, &code), "total", &[]);
2905 let mut free: Value = self.safe_string_k(get_value(&balance, &code), "free", &[]);
2906 let mut used: Value = self.safe_string_k(get_value(&balance, &code), "used", &[]);
2907 let mut debt: Value = self.safe_string_k(get_value(&balance, &code), "debt", &[]);
2908 if is_true(&(is_equal(&total, &Value::Null))) && is_true(&(!is_equal(&free, &Value::Null))) && is_true(&(!is_equal(&used, &Value::Null))) {
2909 total = crate::precise::Precise::stringAdd(&free, &used);
2910 }
2911 if is_true(&(is_equal(&free, &Value::Null))) && is_true(&(!is_equal(&total, &Value::Null))) && is_true(&(!is_equal(&used, &Value::Null))) {
2912 free = crate::precise::Precise::stringSub(&total, &used);
2913 }
2914 if is_true(&(is_equal(&used, &Value::Null))) && is_true(&(!is_equal(&total, &Value::Null))) && is_true(&(!is_equal(&free, &Value::Null))) {
2915 used = crate::precise::Precise::stringSub(&total, &free);
2916 }
2917 add_element_to_object(get_value_mut(&mut balance, &code), &Value::Str("free".to_string()), self.parse_number(free.clone(), &[]));
2918 add_element_to_object(get_value_mut(&mut balance, &code), &Value::Str("used".to_string()), self.parse_number(used.clone(), &[]));
2919 add_element_to_object(get_value_mut(&mut balance, &code), &Value::Str("total".to_string()), self.parse_number(total.clone(), &[]));
2920 { let __be_tmp = get_value(&get_value(&balance, &code), &Value::Str("free".to_string())); add_element_to_object(get_value_mut(&mut balance, &Value::Str("free".to_string())), &code, __be_tmp); };
2921 { let __be_tmp = get_value(&get_value(&balance, &code), &Value::Str("used".to_string())); add_element_to_object(get_value_mut(&mut balance, &Value::Str("used".to_string())), &code, __be_tmp); };
2922 { let __be_tmp = get_value(&get_value(&balance, &code), &Value::Str("total".to_string())); add_element_to_object(get_value_mut(&mut balance, &Value::Str("total".to_string())), &code, __be_tmp); };
2923 if !is_equal(&debt, &Value::Null) {
2924 add_element_to_object(get_value_mut(&mut balance, &code), &Value::Str("debt".to_string()), self.parse_number(debt.clone(), &[]));
2925 add_element_to_object(&mut debtBalance, &code, get_value(&get_value(&balance, &code), &Value::Str("debt".to_string())));
2926 }
2927 }
2928 }
2929 let mut debtBalanceArray: Value = object_keys(&debtBalance);
2930 let mut length: Value = get_array_length(&debtBalanceArray);
2931 if is_true(&(!is_equal(&length, &Value::Null))) && is_true(&(!is_equal(&length, &Value::Int(0)))) {
2932 add_element_to_object(&mut balance, &Value::Str("debt".to_string()), debtBalance.clone());
2933 }
2934 return balance;
2935
2936 Value::Null
2937}
2938
2939 fn safe_order(&self, mut order: Value, optional_args: &[Value]) -> Value {
2940 let mut market = get_arg(optional_args, 0, Value::Null);
2941 if is_equal(&order, &Value::Null) {
2944 order = Value::Map({
2945 let mut m = indexmap::IndexMap::new();
2946 m
2947 });
2948 }
2949 let mut amount: Value = self.omit_zero(self.safe_string_k(order.clone(), "amount", &[]));
2950 let mut remaining: Value = self.safe_string_k(order.clone(), "remaining", &[]);
2951 let mut filled: Value = self.safe_string_k(order.clone(), "filled", &[]);
2952 let mut cost: Value = self.safe_string_k(order.clone(), "cost", &[]);
2953 let mut average: Value = self.omit_zero(self.safe_string_k(order.clone(), "average", &[]));
2954 let mut price: Value = self.omit_zero(self.safe_string_k(order.clone(), "price", &[]));
2955 let mut lastTradeTimeTimestamp: Value = self.safe_integer_k(order.clone(), "lastTradeTimestamp", &[]);
2956 let mut symbol: Value = self.safe_string_k(order.clone(), "symbol", &[]);
2957 let mut side: Value = self.safe_string_k(order.clone(), "side", &[]);
2958 let mut status: Value = self.safe_string_k(order.clone(), "status", &[]);
2959 let mut parseFilled: bool = is_equal(&filled, &Value::Null);
2960 let mut parseCost: bool = is_equal(&cost, &Value::Null);
2961 let mut parseLastTradeTimeTimestamp: bool = is_equal(&lastTradeTimeTimestamp, &Value::Null);
2962 let mut fee: Value = self.safe_value_k(order.clone(), "fee", &[]);
2963 let mut parseFee: bool = is_equal(&fee, &Value::Null);
2964 let mut parseFees: bool = is_equal(&self.safe_value_k(order.clone(), "fees", &[]), &Value::Null);
2965 let mut parseSymbol: bool = is_equal(&symbol, &Value::Null);
2966 let mut parseSide: bool = is_equal(&side, &Value::Null);
2967 let mut shouldParseFees: bool = is_true(&parseFee) || is_true(&parseFees);
2968 let mut fees: Value = self.safe_list_k(order.clone(), "fees", &[Value::List(vec![])]);
2969 let mut trades: Value = Value::List(vec![]);
2970 let mut isTriggerOrSLTpOrder: bool = is_true(&(!is_equal(&self.safe_string_k(order.clone(), "triggerPrice", &[]), &Value::Null) || is_true(&(!is_equal(&self.safe_string_k(order.clone(), "stopLossPrice", &[]), &Value::Null))))) || is_true(&(!is_equal(&self.safe_string_k(order.clone(), "takeProfitPrice", &[]), &Value::Null)));
2971 if is_true(&parseFilled) || is_true(&parseCost) || is_true(&shouldParseFees) {
2972 let mut rawTrades: Value = self.safe_value_k(order.clone(), "trades", &[trades.clone()]);
2973 let mut firstTrade: Value = self.safe_value(rawTrades.clone(), Value::Int(0), &[]);
2978 let mut tradesAreParsed: bool = is_true(&(!is_equal(&firstTrade, &Value::Null))) && is_true(&(Value::Bool(in_op(&firstTrade, &Value::Str("info".to_string()))))) && is_true(&(Value::Bool(in_op(&firstTrade, &Value::Str("id".to_string())))));
2980 if !is_true(&tradesAreParsed) {
2981 trades = self.parse_trades(rawTrades.clone(), &[market.clone()]);
2982 } else {
2983 trades = rawTrades.clone();
2984 }
2985 let mut tradesLength: Value = Value::Int(0);
2987 let mut isArray: bool = is_array(&trades);
2988 if is_true(&isArray) {
2989 tradesLength = get_array_length(&trades);
2990 }
2991 if is_true(&isArray) && is_true(&(is_greater_than(&tradesLength, &Value::Int(0)))) {
2992 if is_equal(&get_value(&order, &Value::Str("symbol".to_string())), &Value::Null) {
2994 add_element_to_object(&mut order, &Value::Str("symbol".to_string()), get_value(&get_value(&trades, &Value::Int(0)), &Value::Str("symbol".to_string())));
2995 }
2996 if is_equal(&get_value(&order, &Value::Str("side".to_string())), &Value::Null) {
2997 add_element_to_object(&mut order, &Value::Str("side".to_string()), get_value(&get_value(&trades, &Value::Int(0)), &Value::Str("side".to_string())));
2998 }
2999 if is_equal(&get_value(&order, &Value::Str("type".to_string())), &Value::Null) {
3000 add_element_to_object(&mut order, &Value::Str("type".to_string()), get_value(&get_value(&trades, &Value::Int(0)), &Value::Str("type".to_string())));
3001 }
3002 if is_equal(&get_value(&order, &Value::Str("id".to_string())), &Value::Null) {
3003 add_element_to_object(&mut order, &Value::Str("id".to_string()), get_value(&get_value(&trades, &Value::Int(0)), &Value::Str("order".to_string())));
3004 }
3005 if is_true(&parseFilled) {
3006 filled = Value::Str("0".to_string());
3007 }
3008 if is_true(&parseCost) {
3009 cost = Value::Str("0".to_string());
3010 }
3011 {
3012 let mut i: Value = Value::Int(0);
3013 let mut __for_first_92: bool = true;
3014 while { if !__for_first_92 { i = add(&i, &Value::Int(1)); } __for_first_92 = false; is_less_than(&i, &get_array_length(&trades)) } {
3015 let mut trade: Value = get_value(&trades, &i);
3016 let mut trade: Value = get_value(&trades, &i);
3017 let mut tradeAmount: Value = self.safe_string_k(trade.clone(), "amount", &[]);
3018 if is_true(&parseFilled) && is_true(&(!is_equal(&tradeAmount, &Value::Null))) {
3019 filled = crate::precise::Precise::stringAdd(&filled, &tradeAmount);
3020 }
3021 let mut tradeCost: Value = self.safe_string_k(trade.clone(), "cost", &[]);
3022 if is_true(&parseCost) && is_true(&(!is_equal(&tradeCost, &Value::Null))) {
3023 cost = crate::precise::Precise::stringAdd(&cost, &tradeCost);
3024 }
3025 if is_true(&parseSymbol) {
3026 symbol = self.safe_string_k(trade.clone(), "symbol", &[]);
3027 }
3028 if is_true(&parseSide) {
3029 side = self.safe_string_k(trade.clone(), "side", &[]);
3030 }
3031 let mut tradeTimestamp: Value = self.safe_value_k(trade.clone(), "timestamp", &[]);
3032 if is_true(&parseLastTradeTimeTimestamp) && is_true(&(!is_equal(&tradeTimestamp, &Value::Null))) {
3033 if is_equal(&lastTradeTimeTimestamp, &Value::Null) {
3034 lastTradeTimeTimestamp = tradeTimestamp.clone();
3035 } else {
3036 lastTradeTimeTimestamp = crate::runtime::Math::max(&lastTradeTimeTimestamp, &tradeTimestamp);
3037 }
3038 }
3039 if is_true(&shouldParseFees) {
3040 let mut tradeFees: Value = self.safe_value_k(trade.clone(), "fees", &[]);
3041 if !is_equal(&tradeFees, &Value::Null) {
3042 {
3043 let mut j: Value = Value::Int(0);
3044 let mut __for_first_91: bool = true;
3045 while { if !__for_first_91 { j = add(&j, &Value::Int(1)); } __for_first_91 = false; is_less_than(&j, &get_array_length(&tradeFees)) } {
3046 let mut tradeFee: Value = get_value(&tradeFees, &j);
3047 let mut tradeFee: Value = get_value(&tradeFees, &j);
3048 append_to_array(&mut fees, self.extend(Value::Map({
3049 let mut m = indexmap::IndexMap::new();
3050 m
3051 }), &[tradeFee.clone()]));
3052 }
3053 }
3054 } else {
3055 let mut tradeFee: Value = self.safe_value_k(trade.clone(), "fee", &[]);
3056 if !is_equal(&tradeFee, &Value::Null) {
3057 append_to_array(&mut fees, self.extend(Value::Map({
3058 let mut m = indexmap::IndexMap::new();
3059 m
3060 }), &[tradeFee.clone()]));
3061 }
3062 }
3063 }
3064 }
3065 }
3066 }
3067 }
3068 if is_true(&shouldParseFees) {
3069 let mut reducedFees: Value = fees.clone();
3070 if is_true(&self.reduceFees) {
3071 reducedFees = self.reduce_fees_by_currency(fees.clone());
3072 }
3073 if is_equal(&reducedFees, &Value::Null) {
3074 reducedFees = Value::List(vec![]);
3075 }
3076 let mut reducedLength: Value = get_array_length(&reducedFees);
3077 {
3078 let mut i: Value = Value::Int(0);
3079 let mut __for_first_93: bool = true;
3080 while { if !__for_first_93 { i = add(&i, &Value::Int(1)); } __for_first_93 = false; is_less_than(&i, &reducedLength) } {
3081 { let __be_tmp = self.safe_number_k(get_value(&reducedFees, &i), "cost", &[]); add_element_to_object(get_value_mut(&mut reducedFees, &i), &Value::Str("cost".to_string()), __be_tmp); };
3082 if is_true(&Value::Bool(in_op(&get_value(&reducedFees, &i), &Value::Str("rate".to_string())))) {
3083 { let __be_tmp = self.safe_number_k(get_value(&reducedFees, &i), "rate", &[]); add_element_to_object(get_value_mut(&mut reducedFees, &i), &Value::Str("rate".to_string()), __be_tmp); };
3084 }
3085 }
3086 }
3087 if !is_true(&parseFee) && is_true(&(is_equal(&reducedLength, &Value::Int(0)))) {
3088 let mut feeCopy: Value = self.deep_extend(fee.clone(), &[]);
3090 { let __be_tmp = self.safe_number_k(feeCopy.clone(), "cost", &[]); add_element_to_object(&mut feeCopy, &Value::Str("cost".to_string()), __be_tmp); };
3091 if is_true(&Value::Bool(in_op(&feeCopy, &Value::Str("rate".to_string())))) {
3092 { let __be_tmp = self.safe_number_k(feeCopy.clone(), "rate", &[]); add_element_to_object(&mut feeCopy, &Value::Str("rate".to_string()), __be_tmp); };
3093 }
3094 append_to_array(&mut reducedFees, feeCopy.clone());
3095 }
3096 add_element_to_object(&mut order, &Value::Str("fees".to_string()), reducedFees.clone());
3097 if is_true(&parseFee) && is_true(&(is_equal(&reducedLength, &Value::Int(1)))) {
3098 add_element_to_object(&mut order, &Value::Str("fee".to_string()), get_value(&reducedFees, &Value::Int(0)));
3099 }
3100 }
3101 if is_equal(&amount, &Value::Null) {
3102 if !is_equal(&filled, &Value::Null) && !is_equal(&remaining, &Value::Null) {
3104 amount = crate::precise::Precise::stringAdd(&filled, &remaining);
3105 } else if is_equal(&status, &Value::Str("closed".to_string())) {
3106 amount = filled.clone();
3107 }
3108 }
3109 if is_equal(&filled, &Value::Null) {
3110 if !is_equal(&amount, &Value::Null) && !is_equal(&remaining, &Value::Null) {
3111 filled = crate::precise::Precise::stringSub(&amount, &remaining);
3112 } else if is_equal(&status, &Value::Str("closed".to_string())) && !is_equal(&amount, &Value::Null) {
3113 filled = amount.clone();
3114 }
3115 }
3116 if is_equal(&remaining, &Value::Null) {
3117 if !is_equal(&amount, &Value::Null) && !is_equal(&filled, &Value::Null) {
3118 remaining = crate::precise::Precise::stringSub(&amount, &filled);
3119 } else if is_equal(&status, &Value::Str("closed".to_string())) {
3120 remaining = Value::Str("0".to_string());
3121 }
3122 }
3123 let mut inverse: Value = self.safe_bool_k(market.clone(), "inverse", &[Value::Bool(false)]);
3125 let mut contractSize: Value = self.number_to_string(self.safe_value_k(market.clone(), "contractSize", &[Value::Int(1)]));
3126 if is_equal(&average, &Value::Null) {
3132 if is_true(&(!is_equal(&filled, &Value::Null))) && is_true(&(!is_equal(&cost, &Value::Null))) && is_true(&crate::precise::Precise::stringGt(&filled, &Value::Str("0".to_string()))) {
3133 let mut filledTimesContractSize: Value = crate::precise::Precise::stringMul(&filled, &contractSize);
3134 if is_equal(&inverse, &Value::Bool(true)) {
3135 average = crate::precise::Precise::stringDiv(&filledTimesContractSize, &cost);
3136 } else {
3137 average = crate::precise::Precise::stringDiv(&cost, &filledTimesContractSize);
3138 }
3139 }
3140 }
3141 let mut costPriceExists: bool = is_true(&(!is_equal(&average, &Value::Null))) || is_true(&(!is_equal(&price, &Value::Null)));
3148 if is_true(&parseCost) && is_true(&(!is_equal(&filled, &Value::Null))) && is_true(&costPriceExists) {
3149 let mut multiplyPrice: Value = Value::Null;
3150 if is_equal(&average, &Value::Null) {
3151 multiplyPrice = price.clone();
3152 } else {
3153 multiplyPrice = average.clone();
3154 }
3155 let mut filledTimesContractSize: Value = crate::precise::Precise::stringMul(&filled, &contractSize);
3157 if is_equal(&inverse, &Value::Bool(true)) {
3158 cost = crate::precise::Precise::stringDiv(&filledTimesContractSize, &multiplyPrice);
3159 } else {
3160 cost = crate::precise::Precise::stringMul(&filledTimesContractSize, &multiplyPrice);
3161 }
3162 }
3163 let mut orderType: Value = self.safe_value_k(order.clone(), "type", &[]);
3165 let mut emptyPrice: bool = is_true(&(is_equal(&price, &Value::Null))) || is_true(&crate::precise::Precise::stringEquals(&price, &Value::Str("0".to_string())));
3166 if is_true(&emptyPrice) && is_true(&(is_equal(&orderType, &Value::Str("market".to_string())))) {
3167 price = average.clone();
3168 }
3169 {
3170 let mut i: Value = Value::Int(0);
3171 let mut __for_first_95: bool = true;
3172 while { if !__for_first_95 { i = add(&i, &Value::Int(1)); } __for_first_95 = false; is_less_than(&i, &get_array_length(&trades)) } {
3173 let mut entry: Value = get_value(&trades, &i);
3174 let mut entry: Value = get_value(&trades, &i);
3175 { let __be_tmp = self.safe_number_k(entry.clone(), "amount", &[]); add_element_to_object(&mut entry, &Value::Str("amount".to_string()), __be_tmp); };
3176 { let __be_tmp = self.safe_number_k(entry.clone(), "price", &[]); add_element_to_object(&mut entry, &Value::Str("price".to_string()), __be_tmp); };
3177 { let __be_tmp = self.safe_number_k(entry.clone(), "cost", &[]); add_element_to_object(&mut entry, &Value::Str("cost".to_string()), __be_tmp); };
3178 let mut tradeFee: Value = self.safe_dict_k(entry.clone(), "fee", &[Value::Map({
3179 let mut m = indexmap::IndexMap::new();
3180 m
3181})]);
3182 { let __be_tmp = self.safe_number_k(tradeFee.clone(), "cost", &[]); add_element_to_object(&mut tradeFee, &Value::Str("cost".to_string()), __be_tmp); };
3183 if is_true(&Value::Bool(in_op(&tradeFee, &Value::Str("rate".to_string())))) {
3184 { let __be_tmp = self.safe_number_k(tradeFee.clone(), "rate", &[]); add_element_to_object(&mut tradeFee, &Value::Str("rate".to_string()), __be_tmp); };
3185 }
3186 let mut entryFees: Value = self.safe_list_k(entry.clone(), "fees", &[Value::List(vec![])]);
3187 {
3188 let mut j: Value = Value::Int(0);
3189 let mut __for_first_94: bool = true;
3190 while { if !__for_first_94 { j = add(&j, &Value::Int(1)); } __for_first_94 = false; is_less_than(&j, &get_array_length(&entryFees)) } {
3191 { let __be_tmp = self.safe_number_k(get_value(&entryFees, &j), "cost", &[]); add_element_to_object(get_value_mut(&mut entryFees, &j), &Value::Str("cost".to_string()), __be_tmp); };
3192 }
3193 }
3194 add_element_to_object(&mut entry, &Value::Str("fees".to_string()), entryFees.clone());
3195 add_element_to_object(&mut entry, &Value::Str("fee".to_string()), tradeFee.clone());
3196 }
3197 }
3198 let mut timeInForce: Value = self.safe_string_k(order.clone(), "timeInForce", &[]);
3199 let mut postOnly: Value = self.safe_value_k(order.clone(), "postOnly", &[]);
3200 if is_equal(&timeInForce, &Value::Null) {
3202 if !is_true(&isTriggerOrSLTpOrder) && is_true(&(is_equal(&self.safe_string_k(order.clone(), "type", &[]), &Value::Str("market".to_string())))) {
3203 timeInForce = Value::Str("IOC".to_string());
3204 }
3205 if is_equal(&postOnly, &Value::Bool(true)) {
3207 timeInForce = Value::Str("PO".to_string());
3208 }
3209 } else if is_equal(&postOnly, &Value::Null) {
3210 postOnly = Value::Bool(is_equal(&timeInForce, &Value::Str("PO".to_string())));
3212 }
3213 let mut timestamp: Value = self.safe_integer_k(order.clone(), "timestamp", &[]);
3214 let mut lastUpdateTimestamp: Value = self.safe_integer_k(order.clone(), "lastUpdateTimestamp", &[]);
3215 let mut datetime: Value = self.safe_string_k(order.clone(), "datetime", &[]);
3216 if is_equal(&datetime, &Value::Null) {
3217 datetime = self.iso8601(timestamp.clone());
3218 }
3219 let mut triggerPrice: Value = self.parse_number(self.safe_string2(order.clone(), Value::Str("triggerPrice".to_string()), Value::Str("stopPrice".to_string()), &[]), &[]);
3220 let mut takeProfitPrice: Value = self.parse_number(self.safe_string_k(order.clone(), "takeProfitPrice", &[]), &[]);
3221 let mut stopLossPrice: Value = self.parse_number(self.safe_string_k(order.clone(), "stopLossPrice", &[]), &[]);
3222 return self.extend(order.clone(), &[Value::Map({
3223 let mut m = indexmap::IndexMap::new();
3224 m.insert("id".to_string(), self.safe_string_k(order.clone(), "id", &[]));
3225 m.insert("clientOrderId".to_string(), self.safe_string_k(order.clone(), "clientOrderId", &[]));
3226 m.insert("timestamp".to_string(), timestamp.clone());
3227 m.insert("datetime".to_string(), datetime.clone());
3228 m.insert("symbol".to_string(), symbol.clone());
3229 m.insert("type".to_string(), self.safe_string_k(order.clone(), "type", &[]));
3230 m.insert("side".to_string(), side.clone());
3231 m.insert("lastTradeTimestamp".to_string(), lastTradeTimeTimestamp.clone());
3232 m.insert("lastUpdateTimestamp".to_string(), lastUpdateTimestamp.clone());
3233 m.insert("price".to_string(), self.parse_number(price.clone(), &[]));
3234 m.insert("amount".to_string(), self.parse_number(amount.clone(), &[]));
3235 m.insert("cost".to_string(), self.parse_number(cost.clone(), &[]));
3236 m.insert("average".to_string(), self.parse_number(average.clone(), &[]));
3237 m.insert("filled".to_string(), self.parse_number(filled.clone(), &[]));
3238 m.insert("remaining".to_string(), self.parse_number(remaining.clone(), &[]));
3239 m.insert("timeInForce".to_string(), timeInForce.clone());
3240 m.insert("postOnly".to_string(), postOnly.clone());
3241 m.insert("trades".to_string(), trades.clone());
3242 m.insert("reduceOnly".to_string(), self.safe_value_k(order.clone(), "reduceOnly", &[]));
3243 m.insert("stopPrice".to_string(), triggerPrice.clone());
3244 m.insert("triggerPrice".to_string(), triggerPrice.clone());
3245 m.insert("takeProfitPrice".to_string(), takeProfitPrice.clone());
3246 m.insert("stopLossPrice".to_string(), stopLossPrice.clone());
3247 m.insert("status".to_string(), status.clone());
3248 m.insert("fee".to_string(), self.safe_value_k(order.clone(), "fee", &[]));
3249 m
3250})]);
3251
3252 Value::Null
3253}
3254
3255 fn parse_orders(&self, mut orders: Value, optional_args: &[Value]) -> Value {
3256 let mut market = get_arg(optional_args, 0, Value::Null);
3257 let mut since = get_arg(optional_args, 1, Value::Null);
3258 let mut limit = get_arg(optional_args, 2, Value::Null);
3259 let mut params = get_arg(optional_args, 3, Value::Map({
3260 let mut m = indexmap::IndexMap::new();
3261 m
3262}));
3263 if is_equal(&orders, &Value::Null) {
3285 return Value::List(vec![]);
3286 }
3287 let mut results: Value = Value::List(vec![]);
3288 if is_true(&Value::Bool(is_array(&orders))) {
3289 {
3290 let mut i: Value = Value::Int(0);
3291 let mut __for_first_96: bool = true;
3292 while { if !__for_first_96 { i = add(&i, &Value::Int(1)); } __for_first_96 = false; is_less_than(&i, &get_array_length(&orders)) } {
3293 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.clone(), &[params.clone()]);
3295 append_to_array(&mut results, order.clone());
3296 }
3297 }
3298 } else {
3299 let mut ids: Value = object_keys(&orders);
3300 {
3301 let mut i: Value = Value::Int(0);
3302 let mut __for_first_97: bool = true;
3303 while { if !__for_first_97 { i = add(&i, &Value::Int(1)); } __for_first_97 = false; is_less_than(&i, &get_array_length(&ids)) } {
3304 let mut id: Value = get_value(&ids, &i);
3305 let mut id: Value = get_value(&ids, &i);
3306 let mut idExtended: Value = self.extend(Value::Map({
3307 let mut m = indexmap::IndexMap::new();
3308 m.insert("id".to_string(), id.clone());
3309 m
3310 }), &[get_value(&orders, &id)]);
3311 let mut parsedOrder: Value = <Self as crate::exchange_generated::ExchangeBase>::parse_order(self, idExtended.clone(), &[market.clone()]); let mut order: Value = self.extend(parsedOrder.clone(), &[params.clone()]);
3313 append_to_array(&mut results, order.clone());
3314 }
3315 }
3316 }
3317 results = self.sort_by(results.clone(), Value::Str("timestamp".to_string()), &[]);
3318 let mut symbol: Value = self.safe_string_k(market.clone(), "symbol", &[]);
3319 return self.filter_by_symbol_since_limit(results.clone(), &[symbol.clone(), since.clone(), limit.clone()]);
3320
3321 Value::Null
3322}
3323
3324 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 {
3325 let mut takerOrMaker = get_arg(optional_args, 0, Value::Str("taker".to_string()));
3326 let mut feeRate = get_arg(optional_args, 1, Value::Null);
3327 let mut params = get_arg(optional_args, 2, Value::Map({
3328 let mut m = indexmap::IndexMap::new();
3329 m
3330}));
3331 if is_equal(&type_var, &Value::Str("market".to_string())) && is_equal(&takerOrMaker, &Value::Str("maker".to_string())) {
3332 panic!("{}", crate::exchange_errors::arguments_required(add(&self.id, &Value::Str(" calculateFee() - you have provided incompatible arguments - \"market\" type order can not be \"maker\". Change either the \"type\" or the \"takerOrMaker\" argument to calculate the fee.".to_string()))));
3333 }
3334 let mut markets: Value = self.markets.clone();
3335 if is_equal(&markets, &Value::Null) {
3336 panic!("{}", crate::exchange_errors::exchange_error(add(&self.id, &Value::Str(" markets not loaded".to_string()))));
3337 }
3338 let mut market: Value = get_value(&markets, &symbol);
3339 let mut market: Value = get_value(&markets, &symbol);
3340 let mut feeSide: Value = self.safe_string_k(market.clone(), "feeSide", &[Value::Str("quote".to_string())]);
3341 let mut useQuote: Value = Value::Null;
3342 if is_equal(&feeSide, &Value::Str("get".to_string())) {
3343 useQuote = Value::Bool(is_equal(&side, &Value::Str("sell".to_string())));
3345 } else if is_equal(&feeSide, &Value::Str("give".to_string())) {
3346 useQuote = Value::Bool(is_equal(&side, &Value::Str("buy".to_string())));
3348 } else {
3349 useQuote = Value::Bool(is_equal(&feeSide, &Value::Str("quote".to_string())));
3351 }
3352 let mut cost: Value = self.number_to_string(amount.clone());
3353 let mut key: Value = Value::Null;
3354 if is_true(&useQuote) {
3355 let mut priceString: Value = self.number_to_string(price.clone());
3356 cost = crate::precise::Precise::stringMul(&cost, &priceString);
3357 key = Value::Str("quote".to_string());
3358 } else {
3359 key = Value::Str("base".to_string());
3360 }
3361 if !is_equal(&get_value(&market, &Value::Str("spot".to_string())), &Value::Bool(true)) {
3363 key = Value::Str("settle".to_string());
3364 }
3365 if is_equal(&type_var, &Value::Str("market".to_string())) {
3367 takerOrMaker = Value::Str("taker".to_string());
3368 }
3369 let mut rate: Value = ternary(is_true(&(!is_equal(&feeRate, &Value::Null))), self.number_to_string(feeRate.clone()), self.safe_string(market.clone(), takerOrMaker.clone(), &[]));
3370 cost = crate::precise::Precise::stringMul(&cost, &rate);
3371 return Value::Map({
3372 let mut m = indexmap::IndexMap::new();
3373 m.insert("type".to_string(), takerOrMaker.clone());
3374 m.insert("currency".to_string(), get_value(&market, &key));
3375 m.insert("rate".to_string(), self.parse_number(rate.clone(), &[]));
3376 m.insert("cost".to_string(), self.parse_number(cost.clone(), &[]));
3377 m
3378});
3379
3380 Value::Null
3381}
3382
3383 fn calculate_fee(&self, mut symbol: Value, mut type_var: Value, mut side: Value, mut amount: Value, mut price: Value, optional_args: &[Value]) -> Value {
3384 let mut takerOrMaker = get_arg(optional_args, 0, Value::Str("taker".to_string()));
3385 let mut params = get_arg(optional_args, 1, Value::Map({
3386 let mut m = indexmap::IndexMap::new();
3387 m
3388}));
3389 return self.calculate_fee_with_rate(symbol.clone(), type_var.clone(), side.clone(), amount.clone(), price.clone(), &[takerOrMaker.clone(), Value::Null, params.clone()]);
3390
3391 Value::Null
3392}
3393
3394 fn safe_liquidation(&self, mut liquidation: Value, optional_args: &[Value]) -> Value {
3395 let mut market = get_arg(optional_args, 0, Value::Null);
3396 let mut contracts: Value = self.safe_string_k(liquidation.clone(), "contracts", &[]);
3397 let mut contractSize: Value = self.safe_string_k(market.clone(), "contractSize", &[]);
3398 let mut price: Value = self.safe_string_k(liquidation.clone(), "price", &[]);
3399 let mut baseValue: Value = self.safe_string_k(liquidation.clone(), "baseValue", &[]);
3400 let mut quoteValue: Value = self.safe_string_k(liquidation.clone(), "quoteValue", &[]);
3401 if is_true(&(is_equal(&baseValue, &Value::Null))) && is_true(&(!is_equal(&contracts, &Value::Null))) && is_true(&(!is_equal(&contractSize, &Value::Null))) && is_true(&(!is_equal(&price, &Value::Null))) {
3402 baseValue = crate::precise::Precise::stringMul(&contracts, &contractSize);
3403 }
3404 if is_true(&(is_equal("eValue, &Value::Null))) && is_true(&(!is_equal(&baseValue, &Value::Null))) && is_true(&(!is_equal(&price, &Value::Null))) {
3405 quoteValue = crate::precise::Precise::stringMul(&baseValue, &price);
3406 }
3407 add_element_to_object(&mut liquidation, &Value::Str("contracts".to_string()), self.parse_number(contracts.clone(), &[]));
3408 add_element_to_object(&mut liquidation, &Value::Str("contractSize".to_string()), self.parse_number(contractSize.clone(), &[]));
3409 add_element_to_object(&mut liquidation, &Value::Str("price".to_string()), self.parse_number(price.clone(), &[]));
3410 add_element_to_object(&mut liquidation, &Value::Str("baseValue".to_string()), self.parse_number(baseValue.clone(), &[]));
3411 add_element_to_object(&mut liquidation, &Value::Str("quoteValue".to_string()), self.parse_number(quoteValue.clone(), &[]));
3412 return liquidation;
3413
3414 Value::Null
3415}
3416
3417 fn safe_trade(&self, mut trade: Value, optional_args: &[Value]) -> Value {
3418 let mut market = get_arg(optional_args, 0, Value::Null);
3419 let mut amount: Value = self.safe_string_k(trade.clone(), "amount", &[]);
3420 let mut price: Value = self.safe_string_k(trade.clone(), "price", &[]);
3421 let mut cost: Value = self.safe_string_k(trade.clone(), "cost", &[]);
3422 if is_equal(&cost, &Value::Null) {
3423 let mut contractSize: Value = self.safe_string_k(market.clone(), "contractSize", &[]);
3425 let mut multiplyPrice: Value = price.clone();
3426 if !is_equal(&contractSize, &Value::Null) {
3427 let mut inverse: Value = self.safe_bool_k(market.clone(), "inverse", &[Value::Bool(false)]);
3428 if is_equal(&inverse, &Value::Bool(true)) {
3429 multiplyPrice = crate::precise::Precise::stringDiv(&Value::Str("1".to_string()), &price);
3430 }
3431 multiplyPrice = crate::precise::Precise::stringMul(&multiplyPrice, &contractSize);
3432 }
3433 cost = crate::precise::Precise::stringMul(&multiplyPrice, &amount);
3434 }
3435 let mut resultFeeresultFeesVariable = self.parsed_fee_and_fees(trade.clone());
3436 let mut resultFee: Value = get_value(&resultFeeresultFeesVariable, &Value::Int(0));
3437 let mut resultFees: Value = get_value(&resultFeeresultFeesVariable, &Value::Int(1));
3438 add_element_to_object(&mut trade, &Value::Str("fee".to_string()), resultFee.clone());
3439 add_element_to_object(&mut trade, &Value::Str("fees".to_string()), resultFees.clone());
3440 add_element_to_object(&mut trade, &Value::Str("amount".to_string()), self.parse_number(amount.clone(), &[]));
3441 add_element_to_object(&mut trade, &Value::Str("price".to_string()), self.parse_number(price.clone(), &[]));
3442 add_element_to_object(&mut trade, &Value::Str("cost".to_string()), self.parse_number(cost.clone(), &[]));
3443 return trade;
3444
3445 Value::Null
3446}
3447
3448 fn create_ccxt_trade_id(&self, optional_args: &[Value]) -> Value {
3449 let mut timestamp = get_arg(optional_args, 0, Value::Null);
3450 let mut side = get_arg(optional_args, 1, Value::Null);
3451 let mut amount = get_arg(optional_args, 2, Value::Null);
3452 let mut price = get_arg(optional_args, 3, Value::Null);
3453 let mut takerOrMaker = get_arg(optional_args, 4, Value::Null);
3454 let mut id: Value = Value::Null;
3456 if !is_equal(×tamp, &Value::Null) {
3457 id = self.number_to_string(timestamp.clone());
3458 if !is_equal(&side, &Value::Null) {
3459 id = add(&id, &add(&Value::Str("-".to_string()), &side));
3460 }
3461 if !is_equal(&amount, &Value::Null) {
3462 id = add(&id, &add(&Value::Str("-".to_string()), &self.number_to_string(amount.clone())));
3463 }
3464 if !is_equal(&price, &Value::Null) {
3465 id = add(&id, &add(&Value::Str("-".to_string()), &self.number_to_string(price.clone())));
3466 }
3467 if !is_equal(&takerOrMaker, &Value::Null) {
3468 id = add(&id, &add(&Value::Str("-".to_string()), &takerOrMaker));
3469 }
3470 }
3471 return id;
3472
3473 Value::Null
3474}
3475
3476 fn parsed_fee_and_fees(&self, mut container: Value) -> Value {
3477 let mut fee: Value = self.safe_dict_k(container.clone(), "fee", &[]);
3478 let mut fees: Value = self.safe_list_k(container.clone(), "fees", &[]);
3479 let mut feeDefined: bool = !is_equal(&fee, &Value::Null);
3480 let mut feesDefined: bool = !is_equal(&fees, &Value::Null);
3481 let mut shouldParseFees: bool = is_true(&feeDefined) || is_true(&feesDefined);
3483 if is_true(&shouldParseFees) {
3484 if is_true(&feeDefined) {
3485 fee = self.parse_fee_numeric(fee.clone());
3486 }
3487 if !is_true(&feesDefined) {
3488 fees = Value::List(vec![fee.clone()]);
3490 }
3491 let mut reducedFees: Value = fees.clone();
3493 if is_true(&self.reduceFees) {
3494 reducedFees = self.reduce_fees_by_currency(fees.clone());
3495 }
3496 if is_equal(&reducedFees, &Value::Null) {
3497 reducedFees = Value::List(vec![]);
3498 }
3499 let mut reducedLength: Value = get_array_length(&reducedFees);
3500 {
3501 let mut i: Value = Value::Int(0);
3502 let mut __for_first_98: bool = true;
3503 while { if !__for_first_98 { i = add(&i, &Value::Int(1)); } __for_first_98 = false; is_less_than(&i, &reducedLength) } {
3504 { let __be_tmp = self.parse_fee_numeric(get_value(&reducedFees, &i)); add_element_to_object(&mut reducedFees, &i, __be_tmp); };
3505 }
3506 }
3507 fees = reducedFees.clone();
3508 if is_equal(&reducedLength, &Value::Int(1)) {
3509 fee = get_value(&reducedFees, &Value::Int(0));
3510 } else if is_equal(&reducedLength, &Value::Int(0)) {
3511 fee = Value::Null;
3512 }
3513 }
3514 if is_equal(&fee, &Value::Null) {
3516 fee = Value::Map({
3517 let mut m = indexmap::IndexMap::new();
3518 m.insert("cost".to_string(), Value::Null);
3519 m.insert("currency".to_string(), Value::Null);
3520 m
3521 });
3522 }
3523 if is_equal(&fees, &Value::Null) {
3524 fees = Value::List(vec![]);
3525 }
3526 return Value::List(vec![fee.clone(), fees.clone()]);
3527
3528 Value::Null
3529}
3530
3531 fn parse_fee_numeric(&self, mut fee: Value) -> Value {
3532 { let __be_tmp = self.safe_number_k(fee.clone(), "cost", &[]); add_element_to_object(&mut fee, &Value::Str("cost".to_string()), __be_tmp); }; if is_true(&Value::Bool(in_op(&fee, &Value::Str("rate".to_string())))) {
3534 { let __be_tmp = self.safe_number_k(fee.clone(), "rate", &[]); add_element_to_object(&mut fee, &Value::Str("rate".to_string()), __be_tmp); };
3535 }
3536 return fee;
3537
3538 Value::Null
3539}
3540
3541 fn find_nearest_ceiling(&self, mut arr: Value, mut providedValue: Value) -> Value {
3542 let mut length: Value = get_array_length(&arr);
3544 {
3545 let mut i: Value = Value::Int(0);
3546 let mut __for_first_99: bool = true;
3547 while { if !__for_first_99 { i = add(&i, &Value::Int(1)); } __for_first_99 = false; is_less_than(&i, &length) } {
3548 let mut current: Value = get_value(&arr, &i);
3549 let mut current: Value = get_value(&arr, &i);
3550 if is_less_than_or_equal(&providedValue, ¤t) {
3551 return current;
3552 }
3553 }
3554 }
3555 return get_value(&arr, &subtract(&length, &Value::Int(1)));
3556
3557 Value::Null
3558}
3559
3560 fn add_key_in_array_items(&self, mut obj: Value, mut keyName: Value) -> Value {
3561 let mut result: Value = Value::List(vec![]);
3562 let mut keys: Value = object_keys(&obj);
3563 {
3564 let mut i: Value = Value::Int(0);
3565 let mut __for_first_100: bool = true;
3566 while { if !__for_first_100 { i = add(&i, &Value::Int(1)); } __for_first_100 = false; is_less_than(&i, &get_array_length(&keys)) } {
3567 let mut key: Value = get_value(&keys, &i);
3568 let mut key: Value = get_value(&keys, &i);
3569 let mut item: Value = get_value(&obj, &key);
3570 let mut item: Value = get_value(&obj, &key);
3571 if is_equal(&item, &Value::Null) {
3572 continue;
3573 }
3574 let mut itemWithKey: Value = self.extend(Value::Map({
3575 let mut m = indexmap::IndexMap::new();
3576 m
3577 }), &[item.clone()]);
3578 add_element_to_object(&mut itemWithKey, &keyName, key.clone());
3579 append_to_array(&mut result, itemWithKey.clone());
3580 }
3581 }
3582 return result;
3583
3584 Value::Null
3585}
3586
3587 fn invert_flat_string_dictionary(&self, mut dict: Value) -> Value {
3588 let mut reversed: Value = Value::Map({
3589 let mut m = indexmap::IndexMap::new();
3590 m
3591 });
3592 let mut keys: Value = object_keys(&dict);
3593 {
3594 let mut i: Value = Value::Int(0);
3595 let mut __for_first_101: bool = true;
3596 while { if !__for_first_101 { i = add(&i, &Value::Int(1)); } __for_first_101 = false; is_less_than(&i, &get_array_length(&keys)) } {
3597 let mut key: Value = get_value(&keys, &i);
3598 let mut key: Value = get_value(&keys, &i);
3599 let mut value: Value = get_value(&dict, &key);
3600 let mut value: Value = get_value(&dict, &key);
3601 if is_string(&value) {
3602 add_element_to_object(&mut reversed, &value, key.clone());
3603 }
3604 }
3605 }
3606 return reversed;
3607
3608 Value::Null
3609}
3610
3611 fn string_to_base16(&self, mut str_val: Value) -> Value {
3612 return add(&Value::Str("0x".to_string()), &self.binary_to_base16(self.base64_to_binary(self.string_to_base64(str_val.clone(), &[]), &[]), &[]));
3613
3614 Value::Null
3615}
3616
3617 fn reduce_fees_by_currency(&self, mut fees: Value) -> Value {
3618 let mut reduced: Value = Value::Map({
3664 let mut m = indexmap::IndexMap::new();
3665 m
3666 });
3667 {
3668 let mut i: Value = Value::Int(0);
3669 let mut __for_first_102: bool = true;
3670 while { if !__for_first_102 { i = add(&i, &Value::Int(1)); } __for_first_102 = false; is_less_than(&i, &get_array_length(&fees)) } {
3671 let mut fee: Value = get_value(&fees, &i);
3672 let mut fee: Value = get_value(&fees, &i);
3673 let mut code: Value = self.safe_string_k(fee.clone(), "currency", &[]);
3674 let mut feeCurrencyCode: Value = ternary(is_true(&(!is_equal(&code, &Value::Null))), code.clone(), to_string_val(&i));
3675 if !is_equal(&feeCurrencyCode, &Value::Null) {
3676 let mut rate: Value = self.safe_string_k(fee.clone(), "rate", &[]);
3677 let mut cost: Value = self.safe_string_k(fee.clone(), "cost", &[]);
3678 if is_equal(&cost, &Value::Null) {
3679 continue;
3680 }
3681 if !is_true(&(Value::Bool(in_op(&reduced, &feeCurrencyCode)))) {
3682 add_element_to_object(&mut reduced, &feeCurrencyCode, Value::Map({
3683 let mut m = indexmap::IndexMap::new();
3684 m
3685}));
3686 }
3687 let mut rateKey: Value = ternary(is_true(&(is_equal(&rate, &Value::Null))), Value::Str("".to_string()), rate.clone());
3688 if is_true(&Value::Bool(in_op(&get_value(&reduced, &feeCurrencyCode), &rateKey))) {
3689 { let __be_tmp = crate::precise::Precise::stringAdd(&get_value(&get_value(&get_value(&reduced, &feeCurrencyCode), &rateKey), &Value::Str("cost".to_string())), &cost); add_element_to_object(get_value_mut(get_value_mut(&mut reduced, &feeCurrencyCode), &rateKey), &Value::Str("cost".to_string()), __be_tmp); };
3690 } else {
3691 add_element_to_object(get_value_mut(&mut reduced, &feeCurrencyCode), &rateKey, Value::Map({
3692 let mut m = indexmap::IndexMap::new();
3693 m.insert("currency".to_string(), code.clone());
3694 m.insert("cost".to_string(), cost.clone());
3695 m
3696}));
3697 if !is_equal(&rate, &Value::Null) {
3698 add_element_to_object(get_value_mut(get_value_mut(&mut reduced, &feeCurrencyCode), &rateKey), &Value::Str("rate".to_string()), rate.clone());
3699 }
3700 }
3701 }
3702 }
3703 }
3704 let mut result: Value = Value::List(vec![]);
3705 let mut feeValues: Value = object_values(&reduced);
3706 {
3707 let mut i: Value = Value::Int(0);
3708 let mut __for_first_103: bool = true;
3709 while { if !__for_first_103 { i = add(&i, &Value::Int(1)); } __for_first_103 = false; is_less_than(&i, &get_array_length(&feeValues)) } {
3710 let mut reducedFeeValues: Value = object_values(&get_value(&feeValues, &i));
3711 result = self.array_concat(result.clone(), reducedFeeValues.clone());
3712 }
3713 }
3714 return result;
3715
3716 Value::Null
3717}
3718
3719 fn safe_ticker(&self, mut ticker: Value, optional_args: &[Value]) -> Value {
3720 let mut market = get_arg(optional_args, 0, Value::Null);
3721 let mut open: Value = self.omit_zero(self.safe_string_k(ticker.clone(), "open", &[]));
3722 let mut close: Value = self.omit_zero(self.safe_string2(ticker.clone(), Value::Str("close".to_string()), Value::Str("last".to_string()), &[]));
3723 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", &[]));
3725 let mut average: Value = self.omit_zero(self.safe_string_k(ticker.clone(), "average", &[]));
3726 let mut vwap: Value = self.safe_string_k(ticker.clone(), "vwap", &[]);
3727 let mut baseVolume: Value = self.safe_string_k(ticker.clone(), "baseVolume", &[]);
3728 let mut quoteVolume: Value = self.safe_string_k(ticker.clone(), "quoteVolume", &[]);
3729 if is_equal(&vwap, &Value::Null) {
3730 vwap = crate::precise::Precise::stringDiv(&self.omit_zero(quoteVolume.clone()), &baseVolume);
3731 }
3732 if !is_equal(&change, &Value::Null) {
3734 if is_equal(&close, &Value::Null) && !is_equal(&average, &Value::Null) {
3735 close = crate::precise::Precise::stringAdd(&average, &crate::precise::Precise::stringDiv(&change, &Value::Str("2".to_string())));
3736 }
3737 if is_equal(&open, &Value::Null) && !is_equal(&close, &Value::Null) {
3738 open = crate::precise::Precise::stringSub(&close, &change);
3739 }
3740 } else if !is_equal(&percentage, &Value::Null) {
3741 if is_equal(&close, &Value::Null) && !is_equal(&average, &Value::Null) {
3742 let mut openAddClose: Value = crate::precise::Precise::stringMul(&average, &Value::Str("2".to_string()));
3743 let mut denominator: Value = crate::precise::Precise::stringAdd(&Value::Str("2".to_string()), &crate::precise::Precise::stringDiv(&percentage, &Value::Str("100".to_string())));
3745 let mut calcOpen: Value = ternary(is_true(&(!is_equal(&open, &Value::Null))), open.clone(), crate::precise::Precise::stringDiv(&openAddClose, &denominator));
3746 close = crate::precise::Precise::stringMul(&calcOpen, &crate::precise::Precise::stringAdd(&Value::Str("1".to_string()), &crate::precise::Precise::stringDiv(&percentage, &Value::Str("100".to_string()))));
3747 }
3748 if is_equal(&open, &Value::Null) && !is_equal(&close, &Value::Null) {
3749 open = crate::precise::Precise::stringDiv(&close, &crate::precise::Precise::stringAdd(&Value::Str("1".to_string()), &crate::precise::Precise::stringDiv(&percentage, &Value::Str("100".to_string()))));
3750 }
3751 }
3752 if is_equal(&change, &Value::Null) {
3754 if !is_equal(&close, &Value::Null) && !is_equal(&open, &Value::Null) {
3755 change = crate::precise::Precise::stringSub(&close, &open);
3756 } else if !is_equal(&close, &Value::Null) && !is_equal(&percentage, &Value::Null) {
3757 change = crate::precise::Precise::stringMul(&crate::precise::Precise::stringDiv(&percentage, &Value::Str("100".to_string())), &crate::precise::Precise::stringDiv(&close, &Value::Str("100".to_string())));
3758 } else if !is_equal(&open, &Value::Null) && !is_equal(&percentage, &Value::Null) {
3759 change = crate::precise::Precise::stringMul(&open, &crate::precise::Precise::stringDiv(&percentage, &Value::Str("100".to_string())));
3760 }
3761 }
3762 if !is_equal(&open, &Value::Null) {
3764 if is_equal(&percentage, &Value::Null) && !is_equal(&change, &Value::Null) {
3766 percentage = crate::precise::Precise::stringMul(&crate::precise::Precise::stringDiv(&change, &open), &Value::Str("100".to_string()));
3767 }
3768 if is_equal(&close, &Value::Null) && !is_equal(&change, &Value::Null) {
3770 close = crate::precise::Precise::stringAdd(&open, &change);
3771 }
3772 if is_equal(&close, &Value::Null) && !is_equal(&average, &Value::Null) {
3774 close = crate::precise::Precise::stringMul(&average, &Value::Str("2".to_string()));
3775 }
3776 if is_equal(&average, &Value::Null) && !is_equal(&close, &Value::Null) {
3778 let mut precision: Value = Value::Int(18);
3779 if !is_equal(&market, &Value::Null) && is_true(&self.is_tick_precision()) {
3780 let mut marketPrecision: Value = self.safe_dict_k(market.clone(), "precision", &[]);
3781 let mut precisionPrice: Value = self.safe_string_k(marketPrecision.clone(), "price", &[]);
3782 if !is_equal(&precisionPrice, &Value::Null) {
3783 precision = self.precision_from_string(precisionPrice.clone());
3784 }
3785 }
3786 average = crate::precise::Precise::stringDivPrec(&crate::precise::Precise::stringAdd(&open, &close), &Value::Str("2".to_string()), &precision);
3787 }
3788 }
3789 let mut closeParsed: Value = self.parse_number(self.omit_zero(close.clone()), &[]);
3792 return self.extend(ticker.clone(), &[Value::Map({
3793 let mut m = indexmap::IndexMap::new();
3794 m.insert("bid".to_string(), self.parse_number(self.omit_zero(self.safe_string_k(ticker.clone(), "bid", &[])), &[]));
3795 m.insert("bidVolume".to_string(), self.safe_number_k(ticker.clone(), "bidVolume", &[]));
3796 m.insert("ask".to_string(), self.parse_number(self.omit_zero(self.safe_string_k(ticker.clone(), "ask", &[])), &[]));
3797 m.insert("askVolume".to_string(), self.safe_number_k(ticker.clone(), "askVolume", &[]));
3798 m.insert("high".to_string(), self.parse_number(self.omit_zero(self.safe_string_k(ticker.clone(), "high", &[])), &[]));
3799 m.insert("low".to_string(), self.parse_number(self.omit_zero(self.safe_string_k(ticker.clone(), "low", &[])), &[]));
3800 m.insert("open".to_string(), self.parse_number(self.omit_zero(open.clone()), &[]));
3801 m.insert("close".to_string(), closeParsed.clone());
3802 m.insert("last".to_string(), closeParsed.clone());
3803 m.insert("change".to_string(), self.parse_number(change.clone(), &[]));
3804 m.insert("percentage".to_string(), self.parse_number(percentage.clone(), &[]));
3805 m.insert("average".to_string(), self.parse_number(average.clone(), &[]));
3806 m.insert("vwap".to_string(), self.parse_number(vwap.clone(), &[]));
3807 m.insert("baseVolume".to_string(), self.parse_number(baseVolume.clone(), &[]));
3808 m.insert("quoteVolume".to_string(), self.parse_number(quoteVolume.clone(), &[]));
3809 m.insert("previousClose".to_string(), self.safe_number_k(ticker.clone(), "previousClose", &[]));
3810 m.insert("indexPrice".to_string(), self.safe_number_k(ticker.clone(), "indexPrice", &[]));
3811 m.insert("markPrice".to_string(), self.safe_number_k(ticker.clone(), "markPrice", &[]));
3812 m
3813})]);
3814
3815 Value::Null
3816}
3817
3818 fn fetch_borrow_rate(&mut self, mut code: Value, mut amount: Value, optional_args: &[Value]) -> impl ::std::future::Future<Output = Value> + Send { async move {
3819 let mut params = get_arg(optional_args, 0, Value::Map({
3820 let mut m = indexmap::IndexMap::new();
3821 m
3822}));
3823 panic!("{}", crate::exchange_errors::not_supported(add(&self.id, &Value::Str(" fetchBorrowRate is deprecated, please use fetchCrossBorrowRate or fetchIsolatedBorrowRate instead".to_string()))));
3824
3825 Value::Null
3826} }
3827
3828 fn repay_cross_margin(&mut self, mut code: Value, mut amount: Value, optional_args: &[Value]) -> impl ::std::future::Future<Output = Value> + Send { async move {
3829 if let Some(__v) = self.dispatch_to_derived("repay_cross_margin", { let mut __args: Vec<crate::Value> = Vec::new(); __args.push(code.clone()); __args.push(amount.clone()); __args.extend_from_slice(optional_args); __args }).await {
3831 if !matches!(__v, crate::Value::Null) { return __v; }
3832 }
3833
3834 let mut params = get_arg(optional_args, 0, Value::Map({
3835 let mut m = indexmap::IndexMap::new();
3836 m
3837}));
3838 panic!("{}", crate::exchange_errors::not_supported(add(&self.id, &Value::Str(" repayCrossMargin is not support yet".to_string()))));
3839
3840 Value::Null
3841} }
3842
3843 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 {
3844 if let Some(__v) = self.dispatch_to_derived("repay_isolated_margin", { let mut __args: Vec<crate::Value> = Vec::new(); __args.push(symbol.clone()); __args.push(code.clone()); __args.push(amount.clone()); __args.extend_from_slice(optional_args); __args }).await {
3846 if !matches!(__v, crate::Value::Null) { return __v; }
3847 }
3848
3849 let mut params = get_arg(optional_args, 0, Value::Map({
3850 let mut m = indexmap::IndexMap::new();
3851 m
3852}));
3853 panic!("{}", crate::exchange_errors::not_supported(add(&self.id, &Value::Str(" repayIsolatedMargin is not support yet".to_string()))));
3854
3855 Value::Null
3856} }
3857
3858 fn borrow_cross_margin(&mut self, mut code: Value, mut amount: Value, optional_args: &[Value]) -> impl ::std::future::Future<Output = Value> + Send { async move {
3859 if let Some(__v) = self.dispatch_to_derived("borrow_cross_margin", { let mut __args: Vec<crate::Value> = Vec::new(); __args.push(code.clone()); __args.push(amount.clone()); __args.extend_from_slice(optional_args); __args }).await {
3861 if !matches!(__v, crate::Value::Null) { return __v; }
3862 }
3863
3864 let mut params = get_arg(optional_args, 0, Value::Map({
3865 let mut m = indexmap::IndexMap::new();
3866 m
3867}));
3868 panic!("{}", crate::exchange_errors::not_supported(add(&self.id, &Value::Str(" borrowCrossMargin is not support yet".to_string()))));
3869
3870 Value::Null
3871} }
3872
3873 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 {
3874 if let Some(__v) = self.dispatch_to_derived("borrow_isolated_margin", { let mut __args: Vec<crate::Value> = Vec::new(); __args.push(symbol.clone()); __args.push(code.clone()); __args.push(amount.clone()); __args.extend_from_slice(optional_args); __args }).await {
3876 if !matches!(__v, crate::Value::Null) { return __v; }
3877 }
3878
3879 let mut params = get_arg(optional_args, 0, Value::Map({
3880 let mut m = indexmap::IndexMap::new();
3881 m
3882}));
3883 panic!("{}", crate::exchange_errors::not_supported(add(&self.id, &Value::Str(" borrowIsolatedMargin is not support yet".to_string()))));
3884
3885 Value::Null
3886} }
3887
3888 fn borrow_margin(&mut self, mut code: Value, mut amount: Value, optional_args: &[Value]) -> impl ::std::future::Future<Output = Value> + Send { async move {
3889 let mut symbol = get_arg(optional_args, 0, Value::Null);
3890 let mut params = get_arg(optional_args, 1, Value::Map({
3891 let mut m = indexmap::IndexMap::new();
3892 m
3893}));
3894 panic!("{}", crate::exchange_errors::not_supported(add(&self.id, &Value::Str(" borrowMargin is deprecated, please use borrowCrossMargin or borrowIsolatedMargin instead".to_string()))));
3895
3896 Value::Null
3897} }
3898
3899 fn repay_margin(&mut self, mut code: Value, mut amount: Value, optional_args: &[Value]) -> impl ::std::future::Future<Output = Value> + Send { async move {
3900 let mut symbol = get_arg(optional_args, 0, Value::Null);
3901 let mut params = get_arg(optional_args, 1, Value::Map({
3902 let mut m = indexmap::IndexMap::new();
3903 m
3904}));
3905 panic!("{}", crate::exchange_errors::not_supported(add(&self.id, &Value::Str(" repayMargin is deprecated, please use repayCrossMargin or repayIsolatedMargin instead".to_string()))));
3906
3907 Value::Null
3908} }
3909
3910 fn fetch_ohlcv(&mut self, mut symbol: Value, optional_args: &[Value]) -> impl ::std::future::Future<Output = Value> + Send { async move {
3911 if let Some(__v) = self.dispatch_to_derived("fetch_ohlcv", { let mut __args: Vec<crate::Value> = Vec::new(); __args.push(symbol.clone()); __args.extend_from_slice(optional_args); __args }).await {
3913 if !matches!(__v, crate::Value::Null) { return __v; }
3914 }
3915
3916 let mut timeframe = get_arg(optional_args, 0, Value::Str("1m".to_string()));
3917 let mut since = get_arg(optional_args, 1, Value::Null);
3918 let mut limit = get_arg(optional_args, 2, Value::Null);
3919 let mut params = get_arg(optional_args, 3, Value::Map({
3920 let mut m = indexmap::IndexMap::new();
3921 m
3922}));
3923 let mut message: Value = Value::Str("".to_string());
3924 if !is_equal(&get_value(&self.has, &Value::Str("fetchTrades".to_string())), &Value::Null) && !is_equal(&get_value(&self.has, &Value::Str("fetchTrades".to_string())), &Value::Bool(false)) {
3925 message = Value::Str(". If you want to build OHLCV candles from trade executions data, visit https://github.com/ccxt/ccxt/tree/master/examples/ and see \"build-ohlcv-bars\" file".to_string());
3926 }
3927 panic!("{}", crate::exchange_errors::not_supported(add(&add(&self.id, &Value::Str(" fetchOHLCV() is not supported yet".to_string())), &message)));
3928
3929 Value::Null
3930} }
3931
3932 fn fetch_spot_ohlcv(&mut self, mut symbol: Value, optional_args: &[Value]) -> impl ::std::future::Future<Output = Value> + Send { async move {
3933 let mut timeframe = get_arg(optional_args, 0, Value::Str("1m".to_string()));
3934 let mut since = get_arg(optional_args, 1, Value::Null);
3935 let mut limit = get_arg(optional_args, 2, Value::Null);
3936 let mut params = get_arg(optional_args, 3, Value::Map({
3937 let mut m = indexmap::IndexMap::new();
3938 m
3939}));
3940 panic!("{}", crate::exchange_errors::not_supported(add(&self.id, &Value::Str(" fetchSpotOHLCV() is not supported yet".to_string()))));
3941
3942 Value::Null
3943} }
3944
3945 fn fetch_contract_ohlcv(&mut self, mut symbol: Value, optional_args: &[Value]) -> impl ::std::future::Future<Output = Value> + Send { async move {
3946 let mut timeframe = get_arg(optional_args, 0, Value::Str("1m".to_string()));
3947 let mut since = get_arg(optional_args, 1, Value::Null);
3948 let mut limit = get_arg(optional_args, 2, Value::Null);
3949 let mut params = get_arg(optional_args, 3, Value::Map({
3950 let mut m = indexmap::IndexMap::new();
3951 m
3952}));
3953 panic!("{}", crate::exchange_errors::not_supported(add(&self.id, &Value::Str(" fetchContractOHLCV() is not supported yet".to_string()))));
3954
3955 Value::Null
3956} }
3957
3958 fn fetch_ohlcv_ws(&mut self, mut symbol: Value, optional_args: &[Value]) -> impl ::std::future::Future<Output = Value> + Send { async move {
3959 let mut timeframe = get_arg(optional_args, 0, Value::Str("1m".to_string()));
3960 let mut since = get_arg(optional_args, 1, Value::Null);
3961 let mut limit = get_arg(optional_args, 2, Value::Null);
3962 let mut params = get_arg(optional_args, 3, Value::Map({
3963 let mut m = indexmap::IndexMap::new();
3964 m
3965}));
3966 let mut message: Value = Value::Str("".to_string());
3967 if !is_equal(&get_value(&self.has, &Value::Str("fetchTradesWs".to_string())), &Value::Null) && !is_equal(&get_value(&self.has, &Value::Str("fetchTradesWs".to_string())), &Value::Bool(false)) {
3968 message = Value::Str(". If you want to build OHLCV candles from trade executions data, visit https://github.com/ccxt/ccxt/tree/master/examples/ and see \"build-ohlcv-bars\" file".to_string());
3969 }
3970 panic!("{}", crate::exchange_errors::not_supported(add(&add(&self.id, &Value::Str(" fetchOHLCVWs() is not supported yet. Try using fetchOHLCV instead.".to_string())), &message)));
3971
3972 Value::Null
3973} }
3974
3975 fn watch_ohlcv(&mut self, mut symbol: Value, optional_args: &[Value]) -> impl ::std::future::Future<Output = Value> + Send { async move {
3976 let mut timeframe = get_arg(optional_args, 0, Value::Str("1m".to_string()));
3977 let mut since = get_arg(optional_args, 1, Value::Null);
3978 let mut limit = get_arg(optional_args, 2, Value::Null);
3979 let mut params = get_arg(optional_args, 3, Value::Map({
3980 let mut m = indexmap::IndexMap::new();
3981 m
3982}));
3983 panic!("{}", crate::exchange_errors::not_supported(add(&self.id, &Value::Str(" watchOHLCV() is not supported yet".to_string()))));
3984
3985 Value::Null
3986} }
3987
3988 fn convert_trading_view_to_ohlcv(&self, mut ohlcvs: Value, optional_args: &[Value]) -> Value {
3989 let mut timestamp = get_arg(optional_args, 0, Value::Str("t".to_string()));
3990 let mut open = get_arg(optional_args, 1, Value::Str("o".to_string()));
3991 let mut high = get_arg(optional_args, 2, Value::Str("h".to_string()));
3992 let mut low = get_arg(optional_args, 3, Value::Str("l".to_string()));
3993 let mut close = get_arg(optional_args, 4, Value::Str("c".to_string()));
3994 let mut volume = get_arg(optional_args, 5, Value::Str("v".to_string()));
3995 let mut ms = get_arg(optional_args, 6, Value::Bool(false));
3996 let mut result: Value = Value::List(vec![]);
3997 let mut timestamps: Value = self.safe_list(ohlcvs.clone(), timestamp.clone(), &[Value::List(vec![])]);
3998 let mut opens: Value = self.safe_list(ohlcvs.clone(), open.clone(), &[Value::List(vec![])]);
3999 let mut highs: Value = self.safe_list(ohlcvs.clone(), high.clone(), &[Value::List(vec![])]);
4000 let mut lows: Value = self.safe_list(ohlcvs.clone(), low.clone(), &[Value::List(vec![])]);
4001 let mut closes: Value = self.safe_list(ohlcvs.clone(), close.clone(), &[Value::List(vec![])]);
4002 let mut volumes: Value = self.safe_list(ohlcvs.clone(), volume.clone(), &[Value::List(vec![])]);
4003 {
4004 let mut i: Value = Value::Int(0);
4005 let mut __for_first_104: bool = true;
4006 while { if !__for_first_104 { i = add(&i, &Value::Int(1)); } __for_first_104 = false; is_less_than(&i, &get_array_length(×tamps)) } {
4007 append_to_array(&mut result, Value::List(vec![ternary(is_true(&ms), self.safe_integer(timestamps.clone(), i.clone(), &[]), self.safe_timestamp(timestamps.clone(), i.clone(), &[])), self.safe_value(opens.clone(), i.clone(), &[]), self.safe_value(highs.clone(), i.clone(), &[]), self.safe_value(lows.clone(), i.clone(), &[]), self.safe_value(closes.clone(), i.clone(), &[]), self.safe_value(volumes.clone(), i.clone(), &[])]));
4008 }
4009 }
4010 return result;
4011
4012 Value::Null
4013}
4014
4015 fn convert_ohlcv_to_trading_view(&self, mut ohlcvs: Value, optional_args: &[Value]) -> Value {
4016 let mut timestamp = get_arg(optional_args, 0, Value::Str("t".to_string()));
4017 let mut open = get_arg(optional_args, 1, Value::Str("o".to_string()));
4018 let mut high = get_arg(optional_args, 2, Value::Str("h".to_string()));
4019 let mut low = get_arg(optional_args, 3, Value::Str("l".to_string()));
4020 let mut close = get_arg(optional_args, 4, Value::Str("c".to_string()));
4021 let mut volume = get_arg(optional_args, 5, Value::Str("v".to_string()));
4022 let mut ms = get_arg(optional_args, 6, Value::Bool(false));
4023 let mut result: Value = Value::Map({
4024 let mut m = indexmap::IndexMap::new();
4025 m
4026 });
4027 add_element_to_object(&mut result, ×tamp, Value::List(vec![]));
4028 add_element_to_object(&mut result, &open, Value::List(vec![]));
4029 add_element_to_object(&mut result, &high, Value::List(vec![]));
4030 add_element_to_object(&mut result, &low, Value::List(vec![]));
4031 add_element_to_object(&mut result, &close, Value::List(vec![]));
4032 add_element_to_object(&mut result, &volume, Value::List(vec![]));
4033 {
4034 let mut i: Value = Value::Int(0);
4035 let mut __for_first_105: bool = true;
4036 while { if !__for_first_105 { i = add(&i, &Value::Int(1)); } __for_first_105 = false; is_less_than(&i, &get_array_length(&ohlcvs)) } {
4037 let mut ts: Value = ternary(is_true(&ms), get_value(&get_value(&ohlcvs, &i), &Value::Int(0)), self.parse_to_int(divide(&get_value(&get_value(&ohlcvs, &i), &Value::Int(0)), &Value::Int(1000))));
4038 let mut resultTimestamp: Value = get_value(&result, ×tamp);
4039 append_to_array(&mut resultTimestamp, ts.clone());
4040 crate::set_value(&mut result, ×tamp, resultTimestamp.clone());
4041 let mut resultOpen: Value = get_value(&result, &open);
4042 append_to_array(&mut resultOpen, get_value(&get_value(&ohlcvs, &i), &Value::Int(1)));
4043 crate::set_value(&mut result, &open, resultOpen.clone());
4044 let mut resultHigh: Value = get_value(&result, &high);
4045 append_to_array(&mut resultHigh, get_value(&get_value(&ohlcvs, &i), &Value::Int(2)));
4046 crate::set_value(&mut result, &high, resultHigh.clone());
4047 let mut resultLow: Value = get_value(&result, &low);
4048 append_to_array(&mut resultLow, get_value(&get_value(&ohlcvs, &i), &Value::Int(3)));
4049 crate::set_value(&mut result, &low, resultLow.clone());
4050 let mut resultClose: Value = get_value(&result, &close);
4051 append_to_array(&mut resultClose, get_value(&get_value(&ohlcvs, &i), &Value::Int(4)));
4052 crate::set_value(&mut result, &close, resultClose.clone());
4053 let mut resultVolume: Value = get_value(&result, &volume);
4054 append_to_array(&mut resultVolume, get_value(&get_value(&ohlcvs, &i), &Value::Int(5)));
4055 crate::set_value(&mut result, &volume, resultVolume.clone());
4056 }
4057 }
4058 return result;
4059
4060 Value::Null
4061}
4062
4063 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 {
4064 let mut startRegex = get_arg(optional_args, 0, Value::Null);
4065 let mut endRegex = get_arg(optional_args, 1, Value::Null);
4066 let mut errorMessage: Value = Value::Str("".to_string());
4067 let mut options: Value = self.safe_value(self.options.clone(), method.clone(), &[Value::Map({
4068 let mut m = indexmap::IndexMap::new();
4069 m
4070 })]);
4071 let mut muteOnFailure: Value = self.safe_bool_k(options.clone(), "webApiMuteFailure", &[Value::Bool(true)]);
4072 {
4073 if !is_true(&self.safe_bool_k(options.clone(), "webApiEnable", &[Value::Bool(true)])) {
4075 return Value::Null;
4076 }
4077 let mut maxRetries: Value = self.safe_value_k(options.clone(), "webApiRetries", &[Value::Int(10)]);
4078 let mut response: Value = Value::Null;
4079 let mut retry: Value = Value::Int(0);
4080 let mut shouldBreak: bool = false;
4081 while is_less_than(&retry, &maxRetries) {
4082 {
4083 response = self.call_method(endpointMethod.clone(), &[Value::Map({
4084 let mut m = indexmap::IndexMap::new();
4085 m
4086 })]).await;
4087 shouldBreak = true;
4088 break;
4089 }
4090 if is_true(&shouldBreak) {
4091 break;
4092 }
4093 }
4094 let mut content: Value = response.clone();
4095 if is_equal(&content, &Value::Null) {
4096 panic!("{}", crate::exchange_errors::null_response(add(&self.id, &Value::Str(" fetchWebEndpoint() returned empty content".to_string()))));
4097 }
4098 if !is_equal(&startRegex, &Value::Null) {
4099 let mut splitted_by_start: Value = split(&content, &startRegex);
4100 content = get_value(&splitted_by_start, &Value::Int(1)); }
4102 if is_equal(&content, &Value::Null) {
4103 panic!("{}", crate::exchange_errors::null_response(add(&self.id, &Value::Str(" fetchWebEndpoint() returned empty content".to_string()))));
4104 }
4105 if !is_equal(&endRegex, &Value::Null) {
4106 let mut splitted_by_end: Value = split(&content, &endRegex);
4107 content = get_value(&splitted_by_end, &Value::Int(0)); }
4109 if is_true(&(is_equal(&returnAsJson, &Value::Bool(true)))) && is_true(&(is_string(&content))) {
4110 let mut jsoned: Value = self.parse_json_value(trim(&content)); if is_true(&(!is_equal(&jsoned, &Value::Null))) && is_true(&(!is_equal(&jsoned, &Value::Null))) {
4112 return jsoned.clone();
4113 } else {
4114 panic!("{}", crate::exchange_errors::bad_response(Value::Str("could not parse the response into json".to_string())));
4115 }
4116 } else {
4117 return content.clone();
4118 }
4119 }
4120 if is_equal(&muteOnFailure, &Value::Bool(true)) {
4121 return Value::Null;
4122 } else {
4123 panic!("{}", crate::exchange_errors::bad_response(errorMessage));
4124 }
4125} }
4126
4127 fn market_ids(&self, optional_args: &[Value]) -> Value {
4128 let mut symbols = get_arg(optional_args, 0, Value::Null);
4129 if is_equal(&symbols, &Value::Null) {
4135 return symbols;
4136 }
4137 let mut result: Value = Value::List(vec![]);
4138 {
4139 let mut i: Value = Value::Int(0);
4140 let mut __for_first_106: bool = true;
4141 while { if !__for_first_106 { i = add(&i, &Value::Int(1)); } __for_first_106 = false; is_less_than(&i, &get_array_length(&symbols)) } {
4142 let mut id: Value = self.market_id(get_value(&symbols, &i));
4143 if !is_equal(&id, &Value::Null) {
4144 append_to_array(&mut result, id.clone());
4145 }
4146 }
4147 }
4148 return result;
4149
4150 Value::Null
4151}
4152
4153 fn currency_ids(&self, optional_args: &[Value]) -> Value {
4154 let mut codes = get_arg(optional_args, 0, Value::Null);
4155 if is_equal(&codes, &Value::Null) {
4156 return codes;
4157 }
4158 let mut result: Value = Value::List(vec![]);
4159 {
4160 let mut i: Value = Value::Int(0);
4161 let mut __for_first_107: bool = true;
4162 while { if !__for_first_107 { i = add(&i, &Value::Int(1)); } __for_first_107 = false; is_less_than(&i, &get_array_length(&codes)) } {
4163 let mut id: Value = self.currency_id(get_value(&codes, &i));
4164 if !is_equal(&id, &Value::Null) {
4165 append_to_array(&mut result, id.clone());
4166 }
4167 }
4168 }
4169 return result;
4170
4171 Value::Null
4172}
4173
4174 fn markets_for_symbols(&self, optional_args: &[Value]) -> Value {
4175 let mut symbols = get_arg(optional_args, 0, Value::Null);
4176 if is_equal(&symbols, &Value::Null) {
4177 return Value::Null;
4178 }
4179 let mut result: Value = Value::List(vec![]);
4180 {
4181 let mut i: Value = Value::Int(0);
4182 let mut __for_first_108: bool = true;
4183 while { if !__for_first_108 { i = add(&i, &Value::Int(1)); } __for_first_108 = false; is_less_than(&i, &get_array_length(&symbols)) } {
4184 append_to_array(&mut result, self.market(get_value(&symbols, &i)));
4185 }
4186 }
4187 return result;
4188
4189 Value::Null
4190}
4191
4192fn market_symbols(&self, optional_args: &[Value]) -> Value {
4194 let mut symbols = get_arg(optional_args, 0, Value::Null);
4195 let mut type_var = get_arg(optional_args, 1, Value::Null);
4196 let mut allowEmpty = get_arg(optional_args, 2, Value::Bool(true));
4197 let mut sameTypeOnly = get_arg(optional_args, 3, Value::Bool(false));
4198 let mut sameSubTypeOnly = get_arg(optional_args, 4, Value::Bool(false));
4199 if is_equal(&symbols, &Value::Null) {
4209 if !is_true(&allowEmpty) {
4210 panic!("{}", crate::exchange_errors::arguments_required(add(&self.id, &Value::Str(" empty list of symbols is not supported".to_string()))));
4211 }
4212 return symbols;
4213 }
4214 let mut symbolsLength: Value = get_array_length(&symbols);
4215 if is_equal(&symbolsLength, &Value::Int(0)) {
4216 if !is_true(&allowEmpty) {
4217 panic!("{}", crate::exchange_errors::arguments_required(add(&self.id, &Value::Str(" empty list of symbols is not supported".to_string()))));
4218 }
4219 return symbols;
4220 }
4221 let mut result: Value = Value::List(vec![]);
4222 let mut marketType: Value = Value::Null;
4223 let mut isLinearSubType: Value = Value::Null;
4224 {
4225 let mut i: Value = Value::Int(0);
4226 let mut __for_first_109: bool = true;
4227 while { if !__for_first_109 { i = add(&i, &Value::Int(1)); } __for_first_109 = false; is_less_than(&i, &get_array_length(&symbols)) } {
4228 let mut market: Value = self.market(get_value(&symbols, &i));
4229 if is_true(&sameTypeOnly) && is_true(&(!is_equal(&marketType, &Value::Null))) {
4230 if !is_equal(&get_value(&market, &Value::Str("type".to_string())), &marketType) {
4231 panic!("{}", crate::exchange_errors::bad_request(add(&add(&add(&add(&add(&self.id, &Value::Str(" symbols must be of the same type, either ".to_string())), &marketType), &Value::Str(" or ".to_string())), &get_value(&market, &Value::Str("type".to_string()))), &Value::Str(".".to_string()))));
4232 }
4233 }
4234 if is_true(&sameSubTypeOnly) && is_true(&(!is_equal(&isLinearSubType, &Value::Null))) {
4235 if !is_equal(&get_value(&market, &Value::Str("linear".to_string())), &isLinearSubType) {
4236 panic!("{}", crate::exchange_errors::bad_request(add(&self.id, &Value::Str(" symbols must be of the same subType, either linear or inverse.".to_string()))));
4237 }
4238 }
4239 if !is_equal(&type_var, &Value::Null) && !is_equal(&get_value(&market, &Value::Str("type".to_string())), &type_var) {
4240 panic!("{}", crate::exchange_errors::bad_request(add(&add(&add(&self.id, &Value::Str(" symbols must be of the same type ".to_string())), &type_var), &Value::Str(". If the type is incorrect you can change it in options or the params of the request".to_string()))));
4241 }
4242 marketType = get_value(&market, &Value::Str("type".to_string()));
4243 if !is_equal(&get_value(&market, &Value::Str("spot".to_string())), &Value::Bool(true)) {
4244 isLinearSubType = get_value(&market, &Value::Str("linear".to_string()));
4245 }
4246 let mut symbol: Value = self.safe_string_k(market.clone(), "symbol", &[get_value(&symbols, &i)]);
4247 append_to_array(&mut result, symbol.clone());
4248 }
4249 }
4250 return result;
4251
4252 Value::Null
4253}
4254
4255 fn market_codes(&self, optional_args: &[Value]) -> Value {
4256 let mut codes = get_arg(optional_args, 0, Value::Null);
4257 if is_equal(&codes, &Value::Null) {
4258 return codes;
4259 }
4260 let mut result: Value = Value::List(vec![]);
4261 {
4262 let mut i: Value = Value::Int(0);
4263 let mut __for_first_110: bool = true;
4264 while { if !__for_first_110 { i = add(&i, &Value::Int(1)); } __for_first_110 = false; is_less_than(&i, &get_array_length(&codes)) } {
4265 append_to_array(&mut result, self.common_currency_code(get_value(&codes, &i)));
4266 }
4267 }
4268 return result;
4269
4270 Value::Null
4271}
4272
4273 fn parse_order_book_bids_asks(&self, mut bidasks: Value, optional_args: &[Value]) -> Value {
4274 let mut priceKey = get_arg(optional_args, 0, Value::Int(0));
4275 let mut amountKey = get_arg(optional_args, 1, Value::Int(1));
4276 let mut countOrIdKey = get_arg(optional_args, 2, Value::Int(2));
4277 bidasks = self.to_array(bidasks.clone());
4278 let mut result: Value = Value::List(vec![]);
4279 {
4280 let mut i: Value = Value::Int(0);
4281 let mut __for_first_111: bool = true;
4282 while { if !__for_first_111 { i = add(&i, &Value::Int(1)); } __for_first_111 = false; is_less_than(&i, &get_array_length(&bidasks)) } {
4283 append_to_array(&mut result, self.parse_order_book_bid_ask(get_value(&bidasks, &i), &[priceKey.clone(), amountKey.clone(), countOrIdKey.clone()]));
4284 }
4285 }
4286 return result;
4287
4288 Value::Null
4289}
4290
4291 fn filter_by_key(&self, mut objects: Value, mut key: Value, optional_args: &[Value]) -> Value {
4292 let mut value = get_arg(optional_args, 0, Value::Null);
4293 if is_equal(&value, &Value::Null) {
4294 return objects;
4295 }
4296 let mut result: Value = Value::List(vec![]);
4297 {
4298 let mut i: Value = Value::Int(0);
4299 let mut __for_first_112: bool = true;
4300 while { if !__for_first_112 { i = add(&i, &Value::Int(1)); } __for_first_112 = false; is_less_than(&i, &get_array_length(&objects)) } {
4301 let mut objectValue: Value = self.safe_string(get_value(&objects, &i), key.clone(), &[]);
4302 if is_equal(&objectValue, &value) {
4303 append_to_array(&mut result, get_value(&objects, &i));
4304 }
4305 }
4306 }
4307 return result;
4308
4309 Value::Null
4310}
4311
4312 fn filter_by_symbol(&self, mut objects: Value, optional_args: &[Value]) -> Value {
4313 let mut symbol = get_arg(optional_args, 0, Value::Null);
4314 return self.filter_by_key(objects.clone(), Value::Str("symbol".to_string()), &[symbol.clone()]);
4315
4316 Value::Null
4317}
4318
4319 fn parse_ohlcv(&self, mut ohlcv: Value, optional_args: &[Value]) -> Value {
4320 { 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; } }
4322
4323 let mut market = get_arg(optional_args, 0, Value::Null);
4324 if is_true(&Value::Bool(is_array(&ohlcv))) {
4325 return Value::List(vec![self.safe_integer(ohlcv.clone(), Value::Int(0), &[]), self.safe_number(ohlcv.clone(), Value::Int(1), &[]), self.safe_number(ohlcv.clone(), Value::Int(2), &[]), self.safe_number(ohlcv.clone(), Value::Int(3), &[]), self.safe_number(ohlcv.clone(), Value::Int(4), &[]), self.safe_number(ohlcv.clone(), Value::Int(5), &[])]);
4326 }
4327 return ohlcv;
4328
4329 Value::Null
4330}
4331
4332 fn safe_network(&self, mut network: Value) -> Value {
4333 let mut withdrawEnabled: Value = self.safe_bool_k(network.clone(), "withdraw", &[]);
4334 let mut depositEnabled: Value = self.safe_bool_k(network.clone(), "deposit", &[]);
4335 let mut limits: Value = self.safe_dict_k(network.clone(), "limits", &[]);
4336 let mut withdraw: Value = self.safe_dict_k(limits.clone(), "withdraw", &[]);
4337 let mut deposit: Value = self.safe_dict_k(limits.clone(), "deposit", &[]);
4338 let mut isEnabled: Value = withdrawEnabled.clone();
4339 if is_equal(&withdrawEnabled, &Value::Bool(true)) {
4340 isEnabled = depositEnabled.clone();
4341 }
4342 return Value::Map({
4343 let mut m = indexmap::IndexMap::new();
4344 m.insert("info".to_string(), get_value(&network, &Value::Str("info".to_string())));
4345 m.insert("id".to_string(), self.safe_string_k(network.clone(), "id", &[]));
4346 m.insert("name".to_string(), self.safe_string_k(network.clone(), "name", &[]));
4347 m.insert("network".to_string(), self.safe_string_k(network.clone(), "network", &[]));
4348 m.insert("active".to_string(), self.safe_bool_k(network.clone(), "active", &[isEnabled.clone()]));
4349 m.insert("deposit".to_string(), depositEnabled.clone());
4350 m.insert("withdraw".to_string(), withdrawEnabled.clone());
4351 m.insert("fee".to_string(), self.safe_number_k(network.clone(), "fee", &[]));
4352 m.insert("precision".to_string(), self.safe_number_k(network.clone(), "precision", &[]));
4353 m.insert("limits".to_string(), Value::Map({
4354 let mut m = indexmap::IndexMap::new();
4355 m.insert("withdraw".to_string(), Value::Map({
4356 let mut m = indexmap::IndexMap::new();
4357 m.insert("min".to_string(), self.safe_number_k(withdraw.clone(), "min", &[]));
4358 m.insert("max".to_string(), self.safe_number_k(withdraw.clone(), "max", &[]));
4359 m
4360}));
4361 m.insert("deposit".to_string(), Value::Map({
4362 let mut m = indexmap::IndexMap::new();
4363 m.insert("min".to_string(), self.safe_number_k(deposit.clone(), "min", &[]));
4364 m.insert("max".to_string(), self.safe_number_k(deposit.clone(), "max", &[]));
4365 m
4366}));
4367 m
4368}));
4369 m
4370});
4371
4372 Value::Null
4373}
4374
4375 fn prioritized_network_aliases(&self, optional_args: &[Value]) -> Value {
4376 let mut networkCode = get_arg(optional_args, 0, Value::Null);
4377 let mut currencyCode = get_arg(optional_args, 1, Value::Null);
4378 let mut allowDefault = get_arg(optional_args, 2, Value::Bool(false));
4379 if is_equal(&networkCode, &Value::Null) {
4399 return Value::Null;
4400 }
4401 let mut replacements: Value = self.safe_dict_k(self.options.clone(), "defaultNetworkCodeReplacements", &[Value::Map({
4402 let mut m = indexmap::IndexMap::new();
4403 m
4404})]);
4405 let mut keys: Value = object_keys(&replacements);
4406 {
4407 let mut i: Value = Value::Int(0);
4408 let mut __for_first_113: bool = true;
4409 while { if !__for_first_113 { i = add(&i, &Value::Int(1)); } __for_first_113 = false; is_less_than(&i, &get_array_length(&keys)) } {
4410 let mut baseCoin: Value = get_value(&keys, &i);
4411 let mut baseCoin: Value = get_value(&keys, &i);
4412 let mut entry: Value = get_value(&replacements, &baseCoin);
4413 let mut entry: Value = get_value(&replacements, &baseCoin);
4414 let mut primary: Value = get_value(&entry, &Value::Str("primary".to_string()));
4415 let mut secondary: Value = get_value(&entry, &Value::Str("secondary".to_string()));
4416 if !is_equal(&networkCode, &primary) && !is_equal(&networkCode, &secondary) {
4417 continue;
4418 }
4419 let mut preferPrimary: Value = Value::Bool(false);
4421 if is_equal(¤cyCode, &baseCoin) {
4422 preferPrimary = Value::Bool(true); } else if !is_equal(¤cyCode, &Value::Null) {
4424 preferPrimary = Value::Bool(false); } else if is_true(&allowDefault) {
4426 preferPrimary = Value::Bool(is_equal(&get_value(&entry, &Value::Str("default".to_string())), &Value::Str("primary".to_string())));
4427 } else {
4428 preferPrimary = Value::Bool(is_equal(&networkCode, &primary)); }
4430 return ternary(is_true(&(preferPrimary)), Value::List(vec![primary.clone(), secondary.clone()]), Value::List(vec![secondary.clone(), primary.clone()]));
4431 }
4432 }
4433 return Value::List(vec![networkCode.clone(), networkCode.clone()]);
4434
4435 Value::Null
4436}
4437
4438 fn network_code_to_id(&self, mut networkCode: Value, optional_args: &[Value]) -> Value {
4439 let mut currencyCode = get_arg(optional_args, 0, Value::Null);
4440 if is_equal(&networkCode, &Value::Null) {
4450 return Value::Null;
4451 }
4452 let mut networkIdsByCodes: Value = self.safe_dict_k(self.options.clone(), "networks", &[Value::Map({
4453 let mut m = indexmap::IndexMap::new();
4454 m
4455})]);
4456 let mut chainPair: Value = self.prioritized_network_aliases(&[networkCode.clone(), currencyCode.clone(), Value::Bool(false)]);
4458 let mut preferredChain: Value = ternary(is_true(&(is_equal(&chainPair, &Value::Null))), networkCode.clone(), get_value(&chainPair, &Value::Int(0)));
4459 let mut alternativeChain: Value = ternary(is_true(&(is_equal(&chainPair, &Value::Null))), networkCode.clone(), get_value(&chainPair, &Value::Int(1)));
4460 let mut networkId: Value = self.safe_string2(networkIdsByCodes.clone(), preferredChain.clone(), alternativeChain.clone(), &[]);
4461 if !is_equal(&networkId, &Value::Null) {
4462 return networkId;
4463 }
4464 let mut currenciesToCheck: Value = Value::List(vec![]);
4466 if is_equal(¤cyCode, &Value::Null) {
4467 currenciesToCheck = object_keys(&self.currencies);
4468 } else {
4469 currenciesToCheck = Value::List(vec![self.safe_dict(self.currencies.clone(), currencyCode.clone(), &[])]);
4470 }
4471 {
4472 let mut i: Value = Value::Int(0);
4473 let mut __for_first_114: bool = true;
4474 while { if !__for_first_114 { i = add(&i, &Value::Int(1)); } __for_first_114 = false; is_less_than(&i, &get_array_length(¤ciesToCheck)) } {
4475 let mut networks: Value = self.safe_dict_k(get_value(¤ciesToCheck, &i), "networks", &[Value::Map({
4476 let mut m = indexmap::IndexMap::new();
4477 m
4478})]);
4479 if is_true(&Value::Bool(in_op(&networks, &networkCode))) {
4480 return self.safe_string_k(get_value(&networks, &networkCode), "id", &[]);
4481 }
4482 }
4483 }
4484 let mut oldCodes: Value = self.safe_dict_k(self.options.clone(), "backwardSupportedNetworkCodes", &[Value::Map({
4486 let mut m = indexmap::IndexMap::new();
4487 m
4488})]);
4489 if is_true(&Value::Bool(in_op(&oldCodes, &networkCode))) {
4490 return self.network_code_to_id(get_value(&oldCodes, &networkCode), &[currencyCode.clone()]);
4491 }
4492 return networkCode;
4493
4494 Value::Null
4495}
4496
4497 fn network_id_to_code(&self, optional_args: &[Value]) -> Value {
4498 let mut networkId = get_arg(optional_args, 0, Value::Null);
4499 let mut currencyCode = get_arg(optional_args, 1, Value::Null);
4500 if is_equal(&networkId, &Value::Null) {
4510 return Value::Null;
4511 }
4512 let mut networkCodesByIds: Value = self.safe_dict_k(self.options.clone(), "networksById", &[Value::Map({
4513 let mut m = indexmap::IndexMap::new();
4514 m
4515})]);
4516 let mut networkCode: Value = self.safe_string(networkCodesByIds.clone(), networkId.clone(), &[networkId.clone()]);
4517 let mut chainPair: Value = self.prioritized_network_aliases(&[networkCode.clone(), currencyCode.clone(), Value::Bool(true)]);
4518 if is_equal(&chainPair, &Value::Null) {
4519 return networkCode;
4520 }
4521 let mut preferredChain: Value = get_value(&chainPair, &Value::Int(0));
4522 let mut alternativeChain: Value = get_value(&chainPair, &Value::Int(1));
4523 if is_equal(¤cyCode, &Value::Null) {
4526 let mut networkIdsByCodes: Value = self.safe_dict_k(self.options.clone(), "networks", &[Value::Map({
4527 let mut m = indexmap::IndexMap::new();
4528 m
4529})]);
4530 if is_true(&(Value::Bool(in_op(&networkIdsByCodes, &preferredChain)))) && is_true(&(Value::Bool(in_op(&networkIdsByCodes, &alternativeChain)))) {
4531 return networkCode;
4532 }
4533 }
4534 return preferredChain;
4535
4536 Value::Null
4537}
4538
4539 fn handle_network_code_and_params(&self, mut params: Value) -> Value {
4540 let mut networkCodeInParams: Value = self.safe_string2(params.clone(), Value::Str("networkCode".to_string()), Value::Str("network".to_string()), &[]);
4541 if !is_equal(&networkCodeInParams, &Value::Null) {
4542 params = self.omit(params.clone(), Value::List(vec![Value::Str("networkCode".to_string()), Value::Str("network".to_string())]), &[]);
4543 }
4544 return Value::List(vec![networkCodeInParams.clone(), params.clone()]);
4545
4546 Value::Null
4547}
4548
4549 fn default_network_code(&self, mut currencyCode: Value) -> Value {
4550 let mut defaultNetworkCode: Value = Value::Null;
4551 let mut defaultNetworks: Value = self.safe_dict_k(self.options.clone(), "defaultNetworks", &[Value::Map({
4552 let mut m = indexmap::IndexMap::new();
4553 m
4554})]);
4555 if is_true(&Value::Bool(in_op(&defaultNetworks, ¤cyCode))) {
4556 defaultNetworkCode = get_value(&defaultNetworks, ¤cyCode);
4558 } else {
4559 let mut defaultNetwork: Value = self.safe_string_k(self.options.clone(), "defaultNetwork", &[]);
4561 if !is_equal(&defaultNetwork, &Value::Null) {
4562 defaultNetworkCode = defaultNetwork.clone();
4563 }
4564 }
4565 return defaultNetworkCode;
4566
4567 Value::Null
4568}
4569
4570 fn select_network_code_from_unified_networks(&self, mut currencyCode: Value, mut networkCode: Value, mut indexedNetworkEntries: Value) -> Value {
4571 return self.select_network_key_from_networks(currencyCode.clone(), networkCode.clone(), indexedNetworkEntries.clone(), &[Value::Bool(true)]);
4572
4573 Value::Null
4574}
4575
4576 fn select_network_id_from_raw_networks(&self, mut currencyCode: Value, mut networkCode: Value, mut indexedNetworkEntries: Value) -> Value {
4577 return self.select_network_key_from_networks(currencyCode.clone(), networkCode.clone(), indexedNetworkEntries.clone(), &[Value::Bool(false)]);
4578
4579 Value::Null
4580}
4581
4582 fn select_network_key_from_networks(&self, mut currencyCode: Value, mut networkCode: Value, mut indexedNetworkEntries: Value, optional_args: &[Value]) -> Value {
4583 let mut isIndexedByUnifiedNetworkCode = get_arg(optional_args, 0, Value::Bool(false));
4584 let mut chosenNetworkId: Value = Value::Null;
4586 let mut availableNetworkIds: Value = object_keys(&indexedNetworkEntries);
4587 let mut responseNetworksLength: Value = get_array_length(&availableNetworkIds);
4588 if !is_equal(&networkCode, &Value::Null) {
4589 if is_equal(&responseNetworksLength, &Value::Int(0)) {
4590 panic!("{}", crate::exchange_errors::not_supported(add(&add(&add(&add(&self.id, &Value::Str(" - ".to_string())), &networkCode), &Value::Str(" network did not return any result for ".to_string())), ¤cyCode)));
4591 } else {
4592 let mut networkIdOrCode: Value = ternary(is_true(&isIndexedByUnifiedNetworkCode), networkCode.clone(), self.network_code_to_id(networkCode.clone(), &[currencyCode.clone()]));
4594 if is_true(&Value::Bool(in_op(&indexedNetworkEntries, &networkIdOrCode))) {
4595 chosenNetworkId = networkIdOrCode.clone();
4596 } else {
4597 panic!("{}", crate::exchange_errors::not_supported(add(&add(&add(&add(&add(&add(&self.id, &Value::Str(" - ".to_string())), &networkIdOrCode), &Value::Str(" network was not found for ".to_string())), ¤cyCode), &Value::Str(", use one of ".to_string())), &join(&availableNetworkIds, &Value::Str(", ".to_string())))));
4598 }
4599 }
4600 } else {
4601 if is_equal(&responseNetworksLength, &Value::Int(0)) {
4602 panic!("{}", crate::exchange_errors::not_supported(add(&add(&self.id, &Value::Str(" - no networks were returned for ".to_string())), ¤cyCode)));
4603 } else {
4604 let mut defaultNetworkCode: Value = self.default_network_code(currencyCode.clone());
4606 let mut defaultNetworkId: Value = ternary(is_true(&isIndexedByUnifiedNetworkCode), defaultNetworkCode.clone(), self.network_code_to_id(defaultNetworkCode.clone(), &[currencyCode.clone()]));
4607 if is_equal(&defaultNetworkId, &Value::Null) {
4608 panic!("{}", crate::exchange_errors::exchange_error(add(&self.id, &Value::Str(" selectNetworkKeyFromNetworks() missing defaultNetworkId".to_string()))));
4609 }
4610 if is_true(&Value::Bool(in_op(&indexedNetworkEntries, &defaultNetworkId))) {
4611 return defaultNetworkId;
4612 }
4613 panic!("{}", crate::exchange_errors::not_supported(add(&add(&self.id, &Value::Str(" - can not determine the default network, please pass param[\"network\"] one from : ".to_string())), &join(&availableNetworkIds, &Value::Str(", ".to_string())))));
4614 }
4615 }
4616 return chosenNetworkId;
4617
4618 Value::Null
4619}
4620
4621 fn safe_number2(&self, mut dictionary: Value, mut key1: Value, mut key2: Value, optional_args: &[Value]) -> Value {
4622 let mut d = get_arg(optional_args, 0, Value::Null);
4623 let mut value: Value = self.safe_string2(dictionary.clone(), key1.clone(), key2.clone(), &[]);
4624 return self.parse_number(value.clone(), &[d.clone()]);
4625
4626 Value::Null
4627}
4628
4629 fn parse_order_book(&self, mut orderbook: Value, mut symbol: Value, optional_args: &[Value]) -> Value {
4630 { 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; } }
4632
4633 let mut timestamp = get_arg(optional_args, 0, Value::Null);
4634 let mut bidsKey = get_arg(optional_args, 1, Value::Str("bids".to_string()));
4635 let mut asksKey = get_arg(optional_args, 2, Value::Str("asks".to_string()));
4636 let mut priceKey = get_arg(optional_args, 3, Value::Int(0));
4637 let mut amountKey = get_arg(optional_args, 4, Value::Int(1));
4638 let mut countOrIdKey = get_arg(optional_args, 5, Value::Int(2));
4639 if is_equal(&orderbook, &Value::Null) {
4640 orderbook = Value::Map({
4641 let mut m = indexmap::IndexMap::new();
4642 m
4643 });
4644 }
4645 let mut bids: Value = self.parse_order_book_bids_asks(self.safe_value(orderbook.clone(), bidsKey.clone(), &[Value::List(vec![])]), &[priceKey.clone(), amountKey.clone(), countOrIdKey.clone()]);
4646 let mut asks: Value = self.parse_order_book_bids_asks(self.safe_value(orderbook.clone(), asksKey.clone(), &[Value::List(vec![])]), &[priceKey.clone(), amountKey.clone(), countOrIdKey.clone()]);
4647 return Value::Map({
4648 let mut m = indexmap::IndexMap::new();
4649 m.insert("symbol".to_string(), symbol.clone());
4650 m.insert("bids".to_string(), self.sort_by(bids.clone(), Value::Int(0), &[Value::Bool(true)]));
4651 m.insert("asks".to_string(), self.sort_by(asks.clone(), Value::Int(0), &[]));
4652 m.insert("timestamp".to_string(), timestamp.clone());
4653 m.insert("datetime".to_string(), self.iso8601(timestamp.clone()));
4654 m.insert("nonce".to_string(), Value::Null);
4655 m
4656});
4657
4658 Value::Null
4659}
4660
4661 fn parse_ohlc_vs(&self, mut ohlcvs: Value, optional_args: &[Value]) -> Value {
4662 let mut market = get_arg(optional_args, 0, Value::Null);
4663 let mut timeframe = get_arg(optional_args, 1, Value::Str("1m".to_string()));
4664 let mut since = get_arg(optional_args, 2, Value::Null);
4665 let mut limit = get_arg(optional_args, 3, Value::Null);
4666 let mut tail = get_arg(optional_args, 4, Value::Bool(false));
4667 if is_equal(&ohlcvs, &Value::Null) {
4668 return Value::List(vec![]);
4669 }
4670 let mut results: Value = Value::List(vec![]);
4671 {
4672 let mut i: Value = Value::Int(0);
4673 let mut __for_first_115: bool = true;
4674 while { if !__for_first_115 { i = add(&i, &Value::Int(1)); } __for_first_115 = false; is_less_than(&i, &get_array_length(&ohlcvs)) } {
4675 append_to_array(&mut results, <Self as crate::exchange_generated::ExchangeBase>::parse_ohlcv(self, get_value(&ohlcvs, &i), &[market.clone()]));
4676 }
4677 }
4678 let mut sorted: Value = self.sort_by(results.clone(), Value::Int(0), &[]);
4679 return self.filter_by_since_limit(sorted.clone(), &[since.clone(), limit.clone(), Value::Int(0), tail.clone()]);
4680
4681 Value::Null
4682}
4683
4684 fn parse_leverage_tiers(&self, mut response: Value, optional_args: &[Value]) -> Value {
4685 let mut symbols = get_arg(optional_args, 0, Value::Null);
4686 let mut marketIdKey = get_arg(optional_args, 1, Value::Null);
4687 symbols = self.market_symbols(&[symbols.clone()]);
4689 let mut tiers: Value = Value::Map({
4690 let mut m = indexmap::IndexMap::new();
4691 m
4692 });
4693 let mut symbolsLength: Value = Value::Int(0);
4694 if !is_equal(&symbols, &Value::Null) {
4695 symbolsLength = get_array_length(&symbols);
4696 }
4697 let mut noSymbols: bool = is_true(&(is_equal(&symbols, &Value::Null))) || is_true(&(is_equal(&symbolsLength, &Value::Int(0))));
4698 if is_true(&Value::Bool(is_array(&response))) {
4699 {
4700 let mut i: Value = Value::Int(0);
4701 let mut __for_first_116: bool = true;
4702 while { if !__for_first_116 { i = add(&i, &Value::Int(1)); } __for_first_116 = false; is_less_than(&i, &get_array_length(&response)) } {
4703 let mut item: Value = get_value(&response, &i);
4704 let mut item: Value = get_value(&response, &i);
4705 let mut id: Value = ternary(is_true(&(is_equal(&marketIdKey, &Value::Null))), Value::Null, self.safe_string(item.clone(), marketIdKey.clone(), &[]));
4706 let mut market: Value = self.safe_market(&[id.clone(), Value::Null, Value::Null, Value::Str("swap".to_string())]);
4707 let mut symbol: Value = get_value(&market, &Value::Str("symbol".to_string()));
4708 let mut contract: Value = self.safe_bool_k(market.clone(), "contract", &[Value::Bool(false)]);
4709 if is_true(&(is_equal(&contract, &Value::Bool(true)))) && is_true(&(is_true(&noSymbols) || is_true(&(is_true(&(!is_equal(&symbols, &Value::Null))) && is_true(&self.in_array(symbol.clone(), symbols.clone())))))) {
4710 add_element_to_object(&mut tiers, &symbol, <Self as crate::exchange_generated::ExchangeBase>::parse_market_leverage_tiers(self, item.clone(), &[market.clone()]));
4711 }
4712 }
4713 }
4714 } else {
4715 let mut keys: Value = object_keys(&response);
4716 {
4717 let mut i: Value = Value::Int(0);
4718 let mut __for_first_117: bool = true;
4719 while { if !__for_first_117 { i = add(&i, &Value::Int(1)); } __for_first_117 = false; is_less_than(&i, &get_array_length(&keys)) } {
4720 let mut marketId: Value = get_value(&keys, &i);
4721 let mut marketId: Value = get_value(&keys, &i);
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.clone(), Value::Null, Value::Null, Value::Str("swap".to_string())]);
4725 let mut symbol: Value = get_value(&market, &Value::Str("symbol".to_string()));
4726 let mut contract: Value = self.safe_bool_k(market.clone(), "contract", &[Value::Bool(false)]);
4727 if is_true(&(is_equal(&contract, &Value::Bool(true)))) && is_true(&(is_true(&noSymbols) || is_true(&(is_true(&(!is_equal(&symbols, &Value::Null))) && is_true(&self.in_array(symbol.clone(), symbols.clone())))))) {
4728 add_element_to_object(&mut tiers, &symbol, <Self as crate::exchange_generated::ExchangeBase>::parse_market_leverage_tiers(self, item.clone(), &[market.clone()]));
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 !is_equal(&get_value(&self.has, &Value::Str("fetchTradingLimits".to_string())), &Value::Null) && !is_equal(&get_value(&self.has, &Value::Str("fetchTradingLimits".to_string())), &Value::Bool(false)) {
4746 if is_true(&reload) || !is_true(&(Value::Bool(in_op(&self.options, &Value::Str("limitsLoaded".to_string()))))) {
4747 let mut response: Value = self.fetch_trading_limits(&[symbols.clone()]).await;
4748 let mut symbolsArray: Value = self.require_value(symbols.clone(), &[Value::Str("loadTradingLimits() requires a symbols argument".to_string())]);
4749 let mut markets: Value = self.markets.clone();
4750 if is_equal(&markets, &Value::Null) {
4751 panic!("{}", crate::exchange_errors::exchange_error(add(&self.id, &Value::Str(" markets not loaded".to_string()))));
4752 }
4753 {
4754 let mut i: Value = Value::Int(0);
4755 let mut __for_first_118: bool = true;
4756 while { if !__for_first_118 { i = add(&i, &Value::Int(1)); } __for_first_118 = false; is_less_than(&i, &get_array_length(&symbolsArray)) } {
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(); add_element_to_object(&mut self.options, &Value::Str("limitsLoaded".to_string()), __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 is_true(&(is_equal(&percentage, &Value::Null))) && is_true(&(!is_equal(&unrealizedPnlString, &Value::Null))) && is_true(&(!is_equal(&initialMarginString, &Value::Null))) {
4779 let mut percentageString: Value = crate::precise::Precise::stringMul(&crate::precise::Precise::stringDivPrec(&unrealizedPnlString, &initialMarginString, &Value::Int(4)), &Value::Str("100".to_string()));
4781 add_element_to_object(&mut position, &Value::Str("percentage".to_string()), self.parse_number(percentageString.clone(), &[]));
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 !is_equal(&symbol, &Value::Null) {
4788 market = self.safe_value(self.markets.clone(), symbol.clone(), &[]);
4789 }
4790 if is_equal(&contractSize, &Value::Null) && !is_equal(&market, &Value::Null) {
4791 contractSize = self.safe_number_k(market.clone(), "contractSize", &[]);
4792 add_element_to_object(&mut position, &Value::Str("contractSize".to_string()), contractSize.clone());
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 symbols = self.market_symbols(&[symbols.clone()]);
4806 let mut positionsArray: Value = self.to_array(positions.clone());
4807 let mut result: Value = Value::List(vec![]);
4808 {
4809 let mut i: Value = Value::Int(0);
4810 let mut __for_first_119: bool = true;
4811 while { if !__for_first_119 { i = add(&i, &Value::Int(1)); } __for_first_119 = false; is_less_than(&i, &get_array_length(&positionsArray)) } {
4812 let mut position: Value = self.extend(<Self as crate::exchange_generated::ExchangeBase>::parse_position(self, get_value(&positionsArray, &i), &[]), &[params.clone()]);
4813 append_to_array(&mut result, position.clone());
4814 }
4815 }
4816 return self.filter_by_array_positions(result.clone(), Value::Str("symbol".to_string()), &[symbols.clone(), Value::Bool(false)]);
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 is_equal(&info, &Value::Null) {
4827 panic!("{}", crate::exchange_errors::not_supported(add(&self.id, &Value::Str(" parseADLRank() is not supported yet".to_string()))));
4828 }
4829 panic!("{}", crate::exchange_errors::not_supported(add(&self.id, &Value::Str(" parseADLRank() is not supported yet".to_string()))));
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 symbols = self.market_symbols(&[symbols.clone()]);
4841 let mut ranksArray: Value = self.to_array(ranks.clone());
4842 let mut result: Value = Value::List(vec![]);
4843 {
4844 let mut i: Value = Value::Int(0);
4845 let mut __for_first_120: bool = true;
4846 while { if !__for_first_120 { i = add(&i, &Value::Int(1)); } __for_first_120 = false; is_less_than(&i, &get_array_length(&ranksArray)) } {
4847 let mut rank: Value = self.extend(<Self as crate::exchange_generated::ExchangeBase>::parse_adl_rank(self, get_value(&ranksArray, &i), &[]), &[params.clone()]);
4848 append_to_array(&mut result, rank.clone());
4849 }
4850 }
4851 return self.filter_by_array_positions(result.clone(), Value::Str("symbol".to_string()), &[symbols.clone(), Value::Bool(false)]);
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.clone());
4862 let mut result: Value = Value::List(vec![]);
4863 {
4864 let mut i: Value = Value::Int(0);
4865 let mut __for_first_121: bool = true;
4866 while { if !__for_first_121 { i = add(&i, &Value::Int(1)); } __for_first_121 = false; is_less_than(&i, &get_array_length(&accountsArray)) } {
4867 let mut account: Value = self.extend(<Self as crate::exchange_generated::ExchangeBase>::parse_account(self, get_value(&accountsArray, &i)), &[params.clone()]);
4868 append_to_array(&mut result, account.clone());
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.clone());
4885 let mut result: Value = Value::List(vec![]);
4886 {
4887 let mut i: Value = Value::Int(0);
4888 let mut __for_first_122: bool = true;
4889 while { if !__for_first_122 { i = add(&i, &Value::Int(1)); } __for_first_122 = false; is_less_than(&i, &get_array_length(&tradesArray)) } {
4890 let mut parsed: Value = Value::Null;
4891 if is_true(&isWs) {
4892 parsed = self.parse_ws_trade(get_value(&tradesArray, &i), &[market.clone()]);
4893 } else {
4894 parsed = <Self as crate::exchange_generated::ExchangeBase>::parse_trade(self, get_value(&tradesArray, &i), &[market.clone()]);
4895 }
4896 let mut trade: Value = self.extend(parsed.clone(), &[params.clone()]);
4897 append_to_array(&mut result, trade.clone());
4898 }
4899 }
4900 result = self.sort_by2(result.clone(), Value::Str("timestamp".to_string()), Value::Str("id".to_string()), &[]);
4901 let mut symbol: Value = self.safe_string_k(market.clone(), "symbol", &[]);
4902 return self.filter_by_symbol_since_limit(result.clone(), &[symbol.clone(), since.clone(), limit.clone()]);
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.clone(), &[market.clone(), since.clone(), limit.clone(), params.clone()]);
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.clone(), &[market.clone(), since.clone(), limit.clone(), params.clone()]);
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.clone());
4942 let mut result: Value = Value::List(vec![]);
4943 {
4944 let mut i: Value = Value::Int(0);
4945 let mut __for_first_123: bool = true;
4946 while { if !__for_first_123 { i = add(&i, &Value::Int(1)); } __for_first_123 = false; is_less_than(&i, &get_array_length(&transactionsArray)) } {
4947 let mut transaction: Value = self.extend(<Self as crate::exchange_generated::ExchangeBase>::parse_transaction(self, get_value(&transactionsArray, &i), &[currency.clone()]), &[params.clone()]);
4948 append_to_array(&mut result, transaction.clone());
4949 }
4950 }
4951 result = self.sort_by(result.clone(), Value::Str("timestamp".to_string()), &[]);
4952 let mut code: Value = ternary(is_true(&(!is_equal(¤cy, &Value::Null))), get_value(¤cy, &Value::Str("code".to_string())), Value::Null);
4953 return self.filter_by_currency_since_limit(result.clone(), &[code.clone(), since.clone(), limit.clone()]);
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.clone());
4967 let mut result: Value = Value::List(vec![]);
4968 {
4969 let mut i: Value = Value::Int(0);
4970 let mut __for_first_124: bool = true;
4971 while { if !__for_first_124 { i = add(&i, &Value::Int(1)); } __for_first_124 = false; is_less_than(&i, &get_array_length(&transfersArray)) } {
4972 let mut transfer: Value = self.extend(<Self as crate::exchange_generated::ExchangeBase>::parse_transfer(self, get_value(&transfersArray, &i), &[currency.clone()]), &[params.clone()]);
4973 append_to_array(&mut result, transfer.clone());
4974 }
4975 }
4976 result = self.sort_by(result.clone(), Value::Str("timestamp".to_string()), &[]);
4977 let mut code: Value = ternary(is_true(&(!is_equal(¤cy, &Value::Null))), get_value(¤cy, &Value::Str("code".to_string())), Value::Null);
4978 return self.filter_by_currency_since_limit(result.clone(), &[code.clone(), since.clone(), limit.clone()]);
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::List(vec![]);
4992 let mut arrayData: Value = self.to_array(data.clone());
4993 {
4994 let mut i: Value = Value::Int(0);
4995 let mut __for_first_126: bool = true;
4996 while { if !__for_first_126 { i = add(&i, &Value::Int(1)); } __for_first_126 = false; is_less_than(&i, &get_array_length(&arrayData)) } {
4997 let mut itemOrItems: Value = <Self as crate::exchange_generated::ExchangeBase>::parse_ledger_entry(self, get_value(&arrayData, &i), &[currency.clone()]);
4998 if is_true(&Value::Bool(is_array(&itemOrItems))) {
4999 {
5000 let mut j: Value = Value::Int(0);
5001 let mut __for_first_125: bool = true;
5002 while { if !__for_first_125 { j = add(&j, &Value::Int(1)); } __for_first_125 = false; is_less_than(&j, &get_array_length(&itemOrItems)) } {
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.clone(), &[params.clone()]));
5008 }
5009 }
5010 }
5011 result = self.sort_by(result.clone(), Value::Str("timestamp".to_string()), &[]);
5012 let mut code: Value = ternary(is_true(&(!is_equal(¤cy, &Value::Null))), get_value(¤cy, &Value::Str("code".to_string())), Value::Null);
5013 return self.filter_by_currency_since_limit(result.clone(), &[code.clone(), since.clone(), limit.clone()]);
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
5027 fn set_headers(&self, mut headers: Value) -> Value {
5028 return headers;
5029
5030 Value::Null
5031}
5032
5033 fn currency_id(&self, mut code: Value) -> Value {
5034 if is_equal(&code, &Value::Null) {
5035 return code;
5036 }
5037 let mut currency: Value = self.safe_dict(self.currencies.clone(), code.clone(), &[]);
5038 if is_equal(¤cy, &Value::Null) {
5039 currency = self.safe_currency(code.clone(), &[]);
5040 }
5041 if !is_equal(¤cy, &Value::Null) {
5042 return get_value(¤cy, &Value::Str("id".to_string()));
5043 }
5044 return code;
5045
5046 Value::Null
5047}
5048
5049 fn market_id(&self, mut symbol: Value) -> Value {
5050 let mut market: Value = self.market(symbol.clone());
5051 if !is_equal(&market, &Value::Null) {
5052 return get_value(&market, &Value::Str("id".to_string()));
5053 }
5054 return symbol;
5055
5056 Value::Null
5057}
5058
5059 fn symbol(&self, mut symbol: Value) -> Value {
5060 if is_equal(&symbol, &Value::Null) {
5061 panic!("{}", crate::exchange_errors::arguments_required(add(&self.id, &Value::Str(" symbol() requires a symbol argument".to_string()))));
5062 }
5063 let mut market: Value = self.market(symbol.clone());
5064 return self.safe_string_k(market.clone(), "symbol", &[symbol.clone()]);
5065
5066 Value::Null
5067}
5068
5069fn handle_param_string(&self, mut params: Value, mut paramName: Value, optional_args: &[Value]) -> Value {
5072 let mut defaultValue = get_arg(optional_args, 0, Value::Null);
5073 let mut value: Value = self.safe_string(params.clone(), paramName.clone(), &[defaultValue.clone()]);
5074 if !is_equal(&value, &Value::Null) {
5075 params = self.omit(params.clone(), paramName.clone(), &[]);
5076 }
5077 return Value::List(vec![value.clone(), params.clone()]);
5078
5079 Value::Null
5080}
5081
5082fn handle_param_string2(&self, mut params: Value, mut paramName1: Value, mut paramName2: Value, optional_args: &[Value]) -> Value {
5085 let mut defaultValue = get_arg(optional_args, 0, Value::Null);
5086 let mut value: Value = self.safe_string2(params.clone(), paramName1.clone(), paramName2.clone(), &[defaultValue.clone()]);
5087 if !is_equal(&value, &Value::Null) {
5088 params = self.omit(params.clone(), Value::List(vec![paramName1.clone(), paramName2.clone()]), &[]);
5089 }
5090 return Value::List(vec![value.clone(), params.clone()]);
5091
5092 Value::Null
5093}
5094
5095 fn handle_param_integer(&self, mut params: Value, mut paramName: Value, optional_args: &[Value]) -> Value {
5096 let mut defaultValue = get_arg(optional_args, 0, Value::Null);
5097 let mut value: Value = self.safe_integer(params.clone(), paramName.clone(), &[defaultValue.clone()]);
5098 if !is_equal(&value, &Value::Null) {
5099 params = self.omit(params.clone(), paramName.clone(), &[]);
5100 }
5101 return Value::List(vec![value.clone(), params.clone()]);
5102
5103 Value::Null
5104}
5105
5106 fn handle_param_integer2(&self, mut params: Value, mut paramName1: Value, mut paramName2: Value, optional_args: &[Value]) -> Value {
5107 let mut defaultValue = get_arg(optional_args, 0, Value::Null);
5108 let mut value: Value = self.safe_integer2(params.clone(), paramName1.clone(), paramName2.clone(), &[defaultValue.clone()]);
5109 if !is_equal(&value, &Value::Null) {
5110 params = self.omit(params.clone(), Value::List(vec![paramName1.clone(), paramName2.clone()]), &[]);
5111 }
5112 return Value::List(vec![value.clone(), params.clone()]);
5113
5114 Value::Null
5115}
5116
5117 fn handle_param_bool(&self, mut params: Value, mut paramName: Value, optional_args: &[Value]) -> Value {
5118 let mut defaultValue = get_arg(optional_args, 0, Value::Null);
5119 let mut value: Value = self.safe_bool(params.clone(), paramName.clone(), &[defaultValue.clone()]);
5120 if !is_equal(&value, &Value::Null) {
5121 params = self.omit(params.clone(), paramName.clone(), &[]);
5122 }
5123 return Value::List(vec![value.clone(), params.clone()]);
5124
5125 Value::Null
5126}
5127
5128 fn handle_param_bool2(&self, mut params: Value, mut paramName1: Value, mut paramName2: Value, optional_args: &[Value]) -> Value {
5129 let mut defaultValue = get_arg(optional_args, 0, Value::Null);
5130 let mut value: Value = self.safe_bool2(params.clone(), paramName1.clone(), paramName2.clone(), &[defaultValue.clone()]);
5131 if !is_equal(&value, &Value::Null) {
5132 params = self.omit(params.clone(), Value::List(vec![paramName1.clone(), paramName2.clone()]), &[]);
5133 }
5134 return Value::List(vec![value.clone(), params.clone()]);
5135
5136 Value::Null
5137}
5138
5139fn handle_request_network(&self, mut params: Value, mut request: Value, mut exchangeSpecificKey: Value, optional_args: &[Value]) -> Value {
5148 let mut currencyCode = get_arg(optional_args, 0, Value::Null);
5149 let mut isRequired = get_arg(optional_args, 1, Value::Bool(false));
5150 let mut networkCode: Value = Value::Null;
5151 { let __destr_tmp = self.handle_network_code_and_params(params.clone()); networkCode = get_value(&__destr_tmp, &Value::Int(0)); params = get_value(&__destr_tmp, &Value::Int(1)); }
5152 if !is_equal(&networkCode, &Value::Null) {
5153 add_element_to_object(&mut request, &exchangeSpecificKey, self.network_code_to_id(networkCode.clone(), &[currencyCode.clone()]));
5154 } else if is_true(&isRequired) {
5155 panic!("{}", crate::exchange_errors::arguments_required(add(&self.id, &Value::Str(" - \"network\" param is required for this request".to_string()))));
5156 }
5157 return Value::List(vec![request.clone(), params.clone()]);
5158
5159 Value::Null
5160}
5161
5162 fn resolve_path(&self, mut path: Value, mut params: Value) -> Value {
5163 return Value::List(vec![self.implode_params(path.clone(), params.clone()), self.omit(params.clone(), self.extract_params(path.clone()), &[])]);
5164
5165 Value::Null
5166}
5167
5168 fn get_list_from_object_values(&self, mut objects: Value, mut key: Value) -> Value {
5169 let mut newArray: Value = objects.clone();
5170 if !is_true(&Value::Bool(is_array(&objects))) {
5171 newArray = self.to_array(objects.clone());
5172 }
5173 let mut results: Value = Value::List(vec![]);
5174 {
5175 let mut i: Value = Value::Int(0);
5176 let mut __for_first_127: bool = true;
5177 while { if !__for_first_127 { i = add(&i, &Value::Int(1)); } __for_first_127 = false; is_less_than(&i, &get_array_length(&newArray)) } {
5178 append_to_array(&mut results, get_value(&get_value(&newArray, &i), &key));
5179 }
5180 }
5181 return results;
5182
5183 Value::Null
5184}
5185
5186 fn get_symbols_for_market_type(&self, optional_args: &[Value]) -> Value {
5187 let mut marketType = get_arg(optional_args, 0, Value::Null);
5188 let mut subType = get_arg(optional_args, 1, Value::Null);
5189 let mut symbolWithActiveStatus = get_arg(optional_args, 2, Value::Bool(true));
5190 let mut symbolWithUnknownStatus = get_arg(optional_args, 3, Value::Bool(true));
5191 let mut filteredMarkets: Value = self.markets.clone();
5192 if !is_equal(&marketType, &Value::Null) {
5193 filteredMarkets = self.filter_by(filteredMarkets.clone(), Value::Str("type".to_string()), marketType.clone(), &[]);
5194 }
5195 if !is_equal(&subType, &Value::Null) {
5196 self.check_required_argument(Value::Str("getSymbolsForMarketType".to_string()), subType.clone(), Value::Str("subType".to_string()), &[Value::List(vec![Value::Str("linear".to_string()), Value::Str("inverse".to_string()), Value::Str("quanto".to_string())])]);
5197 filteredMarkets = self.filter_by(filteredMarkets.clone(), Value::Str("subType".to_string()), subType.clone(), &[]);
5198 }
5199 let mut activeStatuses: Value = Value::List(vec![]);
5200 if is_true(&symbolWithActiveStatus) {
5201 append_to_array(&mut activeStatuses, Value::Bool(true));
5202 }
5203 if is_true(&symbolWithUnknownStatus) {
5204 append_to_array(&mut activeStatuses, Value::Null);
5205 }
5206 filteredMarkets = self.filter_by_array(filteredMarkets.clone(), Value::Str("active".to_string()), &[activeStatuses.clone(), Value::Bool(false)]);
5207 return self.get_list_from_object_values(filteredMarkets.clone(), Value::Str("symbol".to_string()));
5208
5209 Value::Null
5210}
5211
5212 fn filter_by_array(&self, mut objects: Value, mut key: Value, optional_args: &[Value]) -> Value {
5213 let mut values = get_arg(optional_args, 0, Value::Null);
5214 let mut indexed = get_arg(optional_args, 1, Value::Bool(true));
5215 objects = self.to_array(objects.clone());
5216 if is_true(&(is_equal(&values, &Value::Null))) || is_true(&(is_equal(&values, &Value::Null))) || is_true(&(is_equal(&values, &Value::Bool(false)))) || is_true(&(is_equal(&values, &Value::Int(0)))) || is_true(&(is_equal(&values, &Value::Str("".to_string())))) {
5218 if is_true(&indexed) {
5220 return self.index_by(objects.clone(), key.clone());
5221 } else {
5222 return objects;
5223 }
5224 }
5225 let mut results: Value = Value::List(vec![]);
5226 {
5227 let mut i: Value = Value::Int(0);
5228 let mut __for_first_128: bool = true;
5229 while { if !__for_first_128 { i = add(&i, &Value::Int(1)); } __for_first_128 = false; is_less_than(&i, &get_array_length(&objects)) } {
5230 if is_true(&self.in_array(get_value(&get_value(&objects, &i), &key), values.clone())) {
5231 append_to_array(&mut results, get_value(&objects, &i));
5232 }
5233 }
5234 }
5235 if is_true(&indexed) {
5237 return self.index_by(results.clone(), key.clone());
5238 }
5239 return results;
5240
5241 Value::Null
5242}
5243
5244 fn filter_out_by_array(&self, mut objects: Value, mut key: Value, optional_args: &[Value]) -> Value {
5245 let mut values = get_arg(optional_args, 0, Value::Null);
5246 let mut indexed = get_arg(optional_args, 1, Value::Bool(true));
5247 objects = self.to_array(objects.clone());
5248 if is_true(&(is_equal(&values, &Value::Null))) || is_true(&(is_equal(&values, &Value::Null))) || is_true(&(is_equal(&values, &Value::Bool(false)))) || is_true(&(is_equal(&values, &Value::Int(0)))) || is_true(&(is_equal(&values, &Value::Str("".to_string())))) {
5250 if is_true(&indexed) {
5252 return self.index_by(objects.clone(), key.clone());
5253 } else {
5254 return objects;
5255 }
5256 }
5257 let mut results: Value = Value::List(vec![]);
5258 {
5259 let mut i: Value = Value::Int(0);
5260 let mut __for_first_129: bool = true;
5261 while { if !__for_first_129 { i = add(&i, &Value::Int(1)); } __for_first_129 = false; is_less_than(&i, &get_array_length(&objects)) } {
5262 if !is_true(&self.in_array(get_value(&get_value(&objects, &i), &key), values.clone())) {
5263 append_to_array(&mut results, get_value(&objects, &i));
5264 }
5265 }
5266 }
5267 if is_true(&indexed) {
5269 return self.index_by(results.clone(), key.clone());
5270 }
5271 return results;
5272
5273 Value::Null
5274}
5275
5276 fn fetch2(&mut self, mut path: Value, optional_args: &[Value]) -> impl ::std::future::Future<Output = Value> + Send { async move {
5277 let mut api = get_arg(optional_args, 0, Value::Str("public".to_string()));
5278 let mut method = get_arg(optional_args, 1, Value::Str("GET".to_string()));
5279 let mut params = get_arg(optional_args, 2, Value::Map({
5280 let mut m = indexmap::IndexMap::new();
5281 m
5282}));
5283 let mut headers = get_arg(optional_args, 3, Value::Null);
5284 let mut body = get_arg(optional_args, 4, Value::Null);
5285 let mut config = get_arg(optional_args, 5, Value::Map({
5286 let mut m = indexmap::IndexMap::new();
5287 m
5288}));
5289 if is_true(&self.enableRateLimit) {
5290 let mut cost: Value = self.calculate_rate_limiter_cost(api.clone(), method.clone(), path.clone(), params.clone(), &[config.clone()]);
5291 self.throttle(&[cost.clone()]).await;
5292 }
5293 let mut retries: Value = Value::Int(0);
5294 { let __destr_tmp = self.handle_option_and_params(params.clone(), path.clone(), Value::Str("maxRetriesOnFailure".to_string()), &[retries.clone()]); retries = get_value(&__destr_tmp, &Value::Int(0)); params = get_value(&__destr_tmp, &Value::Int(1)); }
5295 let mut retryDelay: Value = Value::Int(0);
5296 { let __destr_tmp = self.handle_option_and_params(params.clone(), path.clone(), Value::Str("maxRetriesOnFailureDelay".to_string()), &[retryDelay.clone()]); retryDelay = get_value(&__destr_tmp, &Value::Int(0)); params = get_value(&__destr_tmp, &Value::Int(1)); }
5297 let mut fetchData: Value = Value::Null;
5298 let mut fetchDataCacheEnabled: bool = is_greater_than(&self.fetchHistoryCacheSize, &Value::Int(0));
5299 {
5300 let mut i: Value = Value::Int(0);
5301 let mut __for_first_130: bool = true;
5302 while { if !__for_first_130 { i = add(&i, &Value::Int(1)); } __for_first_130 = false; is_less_than(&i, &add(&retries, &Value::Int(1))) } {
5303 if is_true(&fetchDataCacheEnabled) {
5304 fetchData = Value::Map({
5305 let mut m = indexmap::IndexMap::new();
5306 m.insert("request".to_string(), Value::Null);
5307 m.insert("response".to_string(), Value::Map({
5308 let mut m = indexmap::IndexMap::new();
5309 m.insert("body".to_string(), Value::Null);
5310 m
5311}));
5312 m.insert("error".to_string(), Value::Null);
5313 m
5314 });
5315 }
5316 let _try_result = futures::FutureExt::catch_unwind(std::panic::AssertUnwindSafe(async {
5317 self.set_last_rest_request_timestamp();
5318 let mut request: Value = <Self as crate::exchange_generated::ExchangeBase>::sign(self, path.clone(), &[api.clone(), method.clone(), params.clone(), headers.clone(), body.clone()]);
5319 if is_true(&fetchDataCacheEnabled) && is_true(&(!is_equal(&fetchData, &Value::Null))) {
5320 add_element_to_object(&mut fetchData, &Value::Str("request".to_string()), request.clone());
5321 }
5322 self.set_last_request(request.clone());
5323 let mut response: Value = self.fetch(get_value(&request, &Value::Str("url".to_string())), &[get_value(&request, &Value::Str("method".to_string())), get_value(&request, &Value::Str("headers".to_string())), get_value(&request, &Value::Str("body".to_string()))]).await;
5324 if is_true(&fetchDataCacheEnabled) && is_true(&(!is_equal(&fetchData, &Value::Null))) {
5325 add_element_to_object(get_value_mut(&mut fetchData, &Value::Str("response".to_string())), &Value::Str("body".to_string()), response.clone());
5326 self.add_fetch_cache(fetchData.clone());
5327 }
5328 return response.clone();
5329 #[allow(unreachable_code)] { Value::Null }})).await;
5330match _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);
5331 if is_true(&fetchDataCacheEnabled) && is_true(&(!is_equal(&fetchData, &Value::Null))) {
5332 add_element_to_object(&mut fetchData, &Value::Str("error".to_string()), e.clone());
5333 self.add_fetch_cache(fetchData.clone());
5334 }
5335 if is_true(&is_instance(&e, &Value::Str("OperationFailed".to_string()))) {
5336 if is_less_than(&i, &retries) {
5337 if is_true(&self.verbose) {
5338 let mut index: Value = add(&i, &Value::Int(1));
5339 self.log(add(&add(&add(&add(&add(&add(&Value::Str("Request failed with the error: ".to_string()), &to_string_val(&e)), &Value::Str(", retrying ".to_string())), &to_string_val(&index)), &Value::Str(" of ".to_string())), &to_string_val(&retries)), &Value::Str("...".to_string())));
5340 }
5341 if is_true(&(!is_equal(&retryDelay, &Value::Null))) && is_true(&(!is_equal(&retryDelay, &Value::Int(0)))) {
5342 self.sleep(retryDelay.clone()).await;
5343 }
5344 } else {
5345 panic!("{}", e);
5346 }
5347 } else {
5348 panic!("{}", e);
5349 }
5350 } }
5351 }
5352 }
5353 return Value::Null;
5354
5355 Value::Null
5356} }
5357
5358 fn request(&mut self, mut path: Value, optional_args: &[Value]) -> impl ::std::future::Future<Output = Value> + Send { async move {
5359 let mut api = get_arg(optional_args, 0, Value::Str("public".to_string()));
5360 let mut method = get_arg(optional_args, 1, Value::Str("GET".to_string()));
5361 let mut params = get_arg(optional_args, 2, Value::Map({
5362 let mut m = indexmap::IndexMap::new();
5363 m
5364}));
5365 let mut headers = get_arg(optional_args, 3, Value::Null);
5366 let mut body = get_arg(optional_args, 4, Value::Null);
5367 let mut config = get_arg(optional_args, 5, Value::Map({
5368 let mut m = indexmap::IndexMap::new();
5369 m
5370}));
5371 return self.fetch2(path.clone(), &[api.clone(), method.clone(), params.clone(), headers.clone(), body.clone(), config.clone()]).await;
5372
5373 Value::Null
5374} }
5375
5376 fn load_accounts(&mut self, optional_args: &[Value]) -> impl ::std::future::Future<Output = Value> + Send { async move {
5377 let mut reload = get_arg(optional_args, 0, Value::Bool(false));
5378 let mut params = get_arg(optional_args, 1, Value::Map({
5379 let mut m = indexmap::IndexMap::new();
5380 m
5381}));
5382 if is_true(&reload) {
5383 { let __t = self.fetch_accounts(&[params.clone()]).await; self.accounts = __t; }
5384 } else {
5385 if !is_equal(&self.accounts, &Value::Null) {
5386 return self.accounts.clone();
5387 } else {
5388 { let __t = self.fetch_accounts(&[params.clone()]).await; self.accounts = __t; }
5389 }
5390 }
5391 { let __t = self.index_by(self.accounts.clone(), Value::Str("id".to_string())); self.accountsById = __t; }
5392 return self.accounts.clone();
5393
5394 Value::Null
5395} }
5396
5397 fn build_ohlcvc(&self, mut trades: Value, optional_args: &[Value]) -> Value {
5398 let mut timeframe = get_arg(optional_args, 0, Value::Str("1m".to_string()));
5399 let mut since = get_arg(optional_args, 1, Value::Int(0));
5400 let mut limit = get_arg(optional_args, 2, Value::Int(2147483647));
5401 let mut ms: Value = multiply(&self.parse_timeframe(timeframe.clone()), &Value::Int(1000));
5404 let mut ohlcvs: Value = Value::List(vec![]);
5405 let mut i_timestamp: Value = Value::Int(0);
5406 let mut i_high: Value = Value::Int(2);
5408 let mut i_low: Value = Value::Int(3);
5409 let mut i_close: Value = Value::Int(4);
5410 let mut i_volume: Value = Value::Int(5);
5411 let mut i_count: Value = Value::Int(6);
5412 let mut tradesLength: Value = get_array_length(&trades);
5413 let mut oldest: Value = crate::runtime::Math::min(&tradesLength, &limit);
5414 let mut options: Value = self.safe_dict_k(self.options.clone(), "buildOHLCVC", &[Value::Map({
5415 let mut m = indexmap::IndexMap::new();
5416 m
5417})]);
5418 let mut skipZeroPrices: Value = self.safe_bool_k(options.clone(), "skipZeroPrices", &[Value::Bool(true)]);
5419 {
5420 let mut i: Value = Value::Int(0);
5421 let mut __for_first_131: bool = true;
5422 while { if !__for_first_131 { i = add(&i, &Value::Int(1)); } __for_first_131 = false; is_less_than(&i, &oldest) } {
5423 let mut trade: Value = get_value(&trades, &i);
5424 let mut trade: Value = get_value(&trades, &i);
5425 let mut ts: Value = get_value(&trade, &Value::Str("timestamp".to_string()));
5426 let mut price: Value = get_value(&trade, &Value::Str("price".to_string()));
5427 if is_true(&(is_equal(&ts, &Value::Null))) || is_true(&(is_equal(&price, &Value::Null))) {
5428 continue;
5429 }
5430 if is_less_than(&ts, &since) {
5431 continue;
5432 }
5433 if is_equal(&ts, &Value::Null) {
5434 panic!("{}", crate::exchange_errors::exchange_error(add(&self.id, &Value::Str(" buildOHLCVC() missing ts".to_string()))));
5435 }
5436 let mut openingTime: Value = multiply(&math_floor(÷(&ts, &ms)), &ms); if is_less_than(&openingTime, &since) {
5438 continue;
5439 }
5440 let mut ohlcv_length: Value = get_array_length(&ohlcvs);
5441 let mut candle: Value = subtract(&ohlcv_length, &Value::Int(1));
5442 if is_equal(&price, &Value::Null) {
5443 panic!("{}", crate::exchange_errors::arguments_required(add(&self.id, &Value::Str(" buildOHLCVC() requires a price argument".to_string()))));
5444 }
5445 if is_true(&(is_equal(&skipZeroPrices, &Value::Bool(true)))) && !is_true(&(is_greater_than(&price, &Value::Int(0)))) && !is_true(&(is_less_than(&price, &Value::Int(0)))) {
5446 continue;
5447 }
5448 let mut isFirstCandle: bool = is_equal(&candle, &negate(&Value::Int(1)));
5449 if is_true(&isFirstCandle) || is_greater_than_or_equal(&openingTime, &self.sum(&[get_value(&get_value(&ohlcvs, &candle), &i_timestamp), ms.clone()])) {
5450 append_to_array(&mut ohlcvs, Value::List(vec![openingTime.clone(), price.clone(), price.clone(), price.clone(), price.clone(), get_value(&trade, &Value::Str("amount".to_string())), Value::Int(1)]));
5452 } else {
5453 let mut prevHigh: Value = get_value(&get_value(&ohlcvs, &candle), &i_high);
5455 let mut prevLow: Value = get_value(&get_value(&ohlcvs, &candle), &i_low);
5456 let mut prevHighValue: Value = ternary(is_true(&(is_equal(&prevHigh, &Value::Null))), price.clone(), prevHigh.clone());
5457 let mut prevLowValue: Value = ternary(is_true(&(is_equal(&prevLow, &Value::Null))), price.clone(), prevLow.clone());
5458 add_element_to_object(get_value_mut(&mut ohlcvs, &candle), &i_high, crate::runtime::Math::max(&prevHighValue, &price));
5459 add_element_to_object(get_value_mut(&mut ohlcvs, &candle), &i_low, crate::runtime::Math::min(&prevLowValue, &price));
5460 add_element_to_object(get_value_mut(&mut ohlcvs, &candle), &i_close, price.clone());
5461 { let __be_tmp = self.sum(&[get_value(&get_value(&ohlcvs, &candle), &i_volume), get_value(&trade, &Value::Str("amount".to_string()))]); add_element_to_object(get_value_mut(&mut ohlcvs, &candle), &i_volume, __be_tmp); };
5462 { 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); };
5463 }
5464 }
5465 }
5466 return ohlcvs;
5467
5468 Value::Null
5469}
5470
5471 fn parse_trading_view_ohlcv(&self, mut ohlcvs: Value, optional_args: &[Value]) -> Value {
5472 let mut market = get_arg(optional_args, 0, Value::Null);
5473 let mut timeframe = get_arg(optional_args, 1, Value::Str("1m".to_string()));
5474 let mut since = get_arg(optional_args, 2, Value::Null);
5475 let mut limit = get_arg(optional_args, 3, Value::Null);
5476 let mut result: Value = self.convert_trading_view_to_ohlcv(ohlcvs.clone(), &[]);
5477 return self.parse_ohlc_vs(result.clone(), &[market.clone(), timeframe.clone(), since.clone(), limit.clone()]);
5478
5479 Value::Null
5480}
5481
5482 fn fetch_borrow_interest(&mut self, optional_args: &[Value]) -> impl ::std::future::Future<Output = Value> + Send { async move {
5483 let mut code = get_arg(optional_args, 0, Value::Null);
5484 let mut symbol = get_arg(optional_args, 1, Value::Null);
5485 let mut since = get_arg(optional_args, 2, Value::Null);
5486 let mut limit = get_arg(optional_args, 3, Value::Null);
5487 let mut params = get_arg(optional_args, 4, Value::Map({
5488 let mut m = indexmap::IndexMap::new();
5489 m
5490}));
5491 panic!("{}", crate::exchange_errors::not_supported(add(&self.id, &Value::Str(" fetchBorrowInterest() is not supported yet".to_string()))));
5492
5493 Value::Null
5494} }
5495
5496 fn fetch_ledger(&mut self, optional_args: &[Value]) -> impl ::std::future::Future<Output = Value> + Send { async move {
5497 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 {
5499 if !matches!(__v, crate::Value::Null) { return __v; }
5500 }
5501
5502 let mut code = get_arg(optional_args, 0, Value::Null);
5503 let mut since = get_arg(optional_args, 1, Value::Null);
5504 let mut limit = get_arg(optional_args, 2, Value::Null);
5505 let mut params = get_arg(optional_args, 3, Value::Map({
5506 let mut m = indexmap::IndexMap::new();
5507 m
5508}));
5509 panic!("{}", crate::exchange_errors::not_supported(add(&self.id, &Value::Str(" fetchLedger() is not supported yet".to_string()))));
5510
5511 Value::Null
5512} }
5513
5514 fn fetch_ledger_entry(&mut self, mut id: Value, optional_args: &[Value]) -> impl ::std::future::Future<Output = Value> + Send { async move {
5515 let mut code = get_arg(optional_args, 0, Value::Null);
5516 let mut params = get_arg(optional_args, 1, Value::Map({
5517 let mut m = indexmap::IndexMap::new();
5518 m
5519}));
5520 panic!("{}", crate::exchange_errors::not_supported(add(&self.id, &Value::Str(" fetchLedgerEntry() is not supported yet".to_string()))));
5521
5522 Value::Null
5523} }
5524
5525 fn parse_order_book_bid_ask(&self, mut bidask: Value, optional_args: &[Value]) -> Value {
5526 let mut priceKey = get_arg(optional_args, 0, Value::Int(0));
5527 let mut amountKey = get_arg(optional_args, 1, Value::Int(1));
5528 let mut countOrIdKey = get_arg(optional_args, 2, Value::Int(2));
5529 let mut price: Value = self.safe_float(bidask.clone(), priceKey.clone(), &[]);
5530 let mut amount: Value = self.safe_float(bidask.clone(), amountKey.clone(), &[]);
5531 let mut countOrId: Value = self.safe_integer(bidask.clone(), countOrIdKey.clone(), &[]);
5532 let mut bidAsk: Value = Value::List(vec![price.clone(), amount.clone()]);
5533 if !is_equal(&countOrId, &Value::Null) {
5534 append_to_array(&mut bidAsk, countOrId.clone());
5535 }
5536 return bidAsk;
5537
5538 Value::Null
5539}
5540
5541 fn safe_currency(&self, mut currencyId: Value, optional_args: &[Value]) -> Value {
5542 let mut currency = get_arg(optional_args, 0, Value::Null);
5543 if is_true(&(is_equal(¤cyId, &Value::Null))) && is_true(&(!is_equal(¤cy, &Value::Null))) {
5544 return currency;
5545 }
5546 if is_true(&(!is_equal(¤cyId, &Value::Null))) && is_true(&(!is_equal(&self.currencies_by_id, &Value::Null))) && is_true(&(Value::Bool(in_op(&self.currencies_by_id, ¤cyId)))) && is_true(&(!is_equal(&get_value(&self.currencies_by_id, ¤cyId), &Value::Null))) {
5547 return get_value(&self.currencies_by_id, ¤cyId);
5548 }
5549 let mut code: Value = currencyId.clone();
5550 if !is_equal(¤cyId, &Value::Null) {
5551 code = self.common_currency_code(to_upper(¤cyId));
5552 }
5553 return self.safe_currency_structure(Value::Map({
5554 let mut m = indexmap::IndexMap::new();
5555 m.insert("id".to_string(), currencyId.clone());
5556 m.insert("code".to_string(), code.clone());
5557 m.insert("precision".to_string(), Value::Null);
5558 m
5559}));
5560
5561 Value::Null
5562}
5563
5564 fn safe_market(&self, optional_args: &[Value]) -> Value {
5565 let mut marketId = get_arg(optional_args, 0, Value::Null);
5566 let mut market = get_arg(optional_args, 1, Value::Null);
5567 let mut delimiter = get_arg(optional_args, 2, Value::Null);
5568 let mut marketType = get_arg(optional_args, 3, Value::Null);
5569 if !is_equal(&marketId, &Value::Null) {
5570 if is_true(&(!is_equal(&self.markets_by_id, &Value::Null))) && is_true(&(Value::Bool(in_op(&self.markets_by_id, &marketId)))) {
5571 let mut markets: Value = get_value(&self.markets_by_id, &marketId);
5572 let mut numMarkets: Value = get_array_length(&markets);
5573 if is_equal(&numMarkets, &Value::Int(1)) {
5574 return get_value(&markets, &Value::Int(0));
5575 } else {
5576 if is_equal(&marketType, &Value::Null) {
5577 if is_equal(&market, &Value::Null) {
5578 panic!("{}", crate::exchange_errors::arguments_required(add(&add(&add(&self.id, &Value::Str(" safeMarket() requires a fourth argument for ".to_string())), &marketId), &Value::Str(" to disambiguate between different markets with the same market id".to_string()))));
5579 } else {
5580 marketType = get_value(&market, &Value::Str("type".to_string()));
5581 }
5582 }
5583 {
5584 let mut i: Value = Value::Int(0);
5585 let mut __for_first_132: bool = true;
5586 while { if !__for_first_132 { i = add(&i, &Value::Int(1)); } __for_first_132 = false; is_less_than(&i, &get_array_length(&markets)) } {
5587 let mut currentMarket: Value = get_value(&markets, &i);
5588 let mut currentMarket: Value = get_value(&markets, &i);
5589 if is_equal(&get_value(¤tMarket, &marketType), &Value::Bool(true)) {
5590 return currentMarket;
5591 }
5592 }
5593 }
5594 }
5595 } else if !is_equal(&delimiter, &Value::Null) && !is_equal(&delimiter, &Value::Str("".to_string())) {
5596 let mut parts: Value = split(&marketId, &delimiter);
5597 let mut partsLength: Value = get_array_length(&parts);
5598 let mut result: Value = self.safe_market_structure(&[Value::Map({
5599 let mut m = indexmap::IndexMap::new();
5600 m.insert("symbol".to_string(), marketId.clone());
5601 m.insert("marketId".to_string(), marketId.clone());
5602 m
5603})]);
5604 if is_equal(&result, &Value::Null) {
5605 panic!("{}", crate::exchange_errors::exchange_error(add(&self.id, &Value::Str(" safeMarket() failed to build market structure".to_string()))));
5606 }
5607 if is_equal(&partsLength, &Value::Int(2)) {
5608 let mut baseId: Value = self.safe_string(parts.clone(), Value::Int(0), &[]);
5609 let mut quoteId: Value = self.safe_string(parts.clone(), Value::Int(1), &[]);
5610 let mut base: Value = self.safe_currency_code(baseId.clone(), &[]);
5611 let mut quote: Value = self.safe_currency_code(quoteId.clone(), &[]);
5612 add_element_to_object(&mut result, &Value::Str("baseId".to_string()), baseId.clone());
5613 add_element_to_object(&mut result, &Value::Str("quoteId".to_string()), quoteId.clone());
5614 if !is_equal(&base, &Value::Null) {
5615 add_element_to_object(&mut result, &Value::Str("base".to_string()), base.clone());
5616 }
5617 if !is_equal("e, &Value::Null) {
5618 add_element_to_object(&mut result, &Value::Str("quote".to_string()), quote.clone());
5619 }
5620 if is_true(&(!is_equal(&base, &Value::Null))) && is_true(&(!is_equal("e, &Value::Null))) {
5621 add_element_to_object(&mut result, &Value::Str("symbol".to_string()), add(&add(&base, &Value::Str("/".to_string())), "e));
5622 }
5623 }
5624 return result;
5625 }
5626 }
5627 if !is_equal(&market, &Value::Null) {
5628 return market;
5629 }
5630 let mut emptyMarket: Value = self.safe_market_structure(&[Value::Map({
5631 let mut m = indexmap::IndexMap::new();
5632 m.insert("symbol".to_string(), marketId.clone());
5633 m.insert("marketId".to_string(), marketId.clone());
5634 m
5635})]);
5636 if is_equal(&emptyMarket, &Value::Null) {
5637 panic!("{}", crate::exchange_errors::exchange_error(add(&self.id, &Value::Str(" safeMarket() failed to build market structure".to_string()))));
5638 }
5639 return emptyMarket;
5640
5641 Value::Null
5642}
5643
5644 fn market_or_null(&self, optional_args: &[Value]) -> Value {
5645 let mut symbol = get_arg(optional_args, 0, Value::Null);
5646 if is_equal(&symbol, &Value::Null) {
5647 return Value::Null;
5648 }
5649 return self.market(symbol.clone());
5650
5651 Value::Null
5652}
5653
5654 fn check_required_credentials(&self, optional_args: &[Value]) -> Value {
5655 let mut error = get_arg(optional_args, 0, Value::Bool(true));
5656 let mut keys: Value = object_keys(&self.requiredCredentials);
5663 {
5664 let mut i: Value = Value::Int(0);
5665 let mut __for_first_133: bool = true;
5666 while { if !__for_first_133 { i = add(&i, &Value::Int(1)); } __for_first_133 = false; is_less_than(&i, &get_array_length(&keys)) } {
5667 let mut key: Value = get_value(&keys, &i);
5668 let mut key: Value = get_value(&keys, &i);
5669 let mut credentialValue: Value = self.prop(&key);
5670 let mut credentialMissing: bool = is_true(&(is_equal(&credentialValue, &Value::Null))) || is_true(&(is_equal(&credentialValue, &Value::Null))) || is_true(&(is_equal(&credentialValue, &Value::Bool(false)))) || is_true(&(is_equal(&credentialValue, &Value::Str("".to_string()))));
5671 if is_true(&(is_equal(&get_value(&self.requiredCredentials, &key), &Value::Bool(true)))) && is_true(&credentialMissing) {
5672 if is_true(&error) {
5673 panic!("{}", crate::exchange_errors::authentication_error(add(&add(&add(&self.id, &Value::Str(" requires \"".to_string())), &key), &Value::Str("\" credential".to_string()))));
5674 } else {
5675 return Value::Bool(false);
5676 }
5677 }
5678 }
5679 }
5680 return Value::Bool(true);
5681
5682 Value::Null
5683}
5684
5685 fn oath(&self) -> Value {
5686 if !is_equal(&self.twofa, &Value::Null) {
5687 return totp(self.twofa.clone());
5688 } else {
5689 panic!("{}", crate::exchange_errors::exchange_error(add(&self.id, &Value::Str(" exchange.twofa has not been set for 2FA Two-Factor Authentication".to_string()))));
5690 }
5691
5692 Value::Null
5693}
5694
5695 fn fetch_balance(&mut self, optional_args: &[Value]) -> impl ::std::future::Future<Output = Value> + Send { async move {
5696 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 {
5698 if !matches!(__v, crate::Value::Null) { return __v; }
5699 }
5700
5701 let mut params = get_arg(optional_args, 0, Value::Map({
5702 let mut m = indexmap::IndexMap::new();
5703 m
5704}));
5705 panic!("{}", crate::exchange_errors::not_supported(add(&self.id, &Value::Str(" fetchBalance() is not supported yet".to_string()))));
5706
5707 Value::Null
5708} }
5709
5710 fn fetch_balance_ws(&mut self, optional_args: &[Value]) -> impl ::std::future::Future<Output = Value> + Send { async move {
5711 let mut params = get_arg(optional_args, 0, Value::Map({
5712 let mut m = indexmap::IndexMap::new();
5713 m
5714}));
5715 panic!("{}", crate::exchange_errors::not_supported(add(&self.id, &Value::Str(" fetchBalanceWs() is not supported yet".to_string()))));
5716
5717 Value::Null
5718} }
5719
5720 fn parse_balance(&self, mut response: Value) -> Value {
5721 { let __v = crate::exchange::DerivedExchange::parse_balance(self, response.clone()); if !matches!(__v, crate::Value::Null) { return __v; } }
5723
5724 panic!("{}", crate::exchange_errors::not_supported(add(&self.id, &Value::Str(" parseBalance() is not supported yet".to_string()))));
5725
5726 Value::Null
5727}
5728
5729 fn watch_balance(&mut self, optional_args: &[Value]) -> impl ::std::future::Future<Output = Value> + Send { async move {
5730 let mut params = get_arg(optional_args, 0, Value::Map({
5731 let mut m = indexmap::IndexMap::new();
5732 m
5733}));
5734 panic!("{}", crate::exchange_errors::not_supported(add(&self.id, &Value::Str(" watchBalance() is not supported yet".to_string()))));
5735
5736 Value::Null
5737} }
5738
5739 fn fetch_partial_balance(&mut self, mut part: Value, optional_args: &[Value]) -> impl ::std::future::Future<Output = Value> + Send { async move {
5740 let mut params = get_arg(optional_args, 0, Value::Map({
5741 let mut m = indexmap::IndexMap::new();
5742 m
5743}));
5744 let mut balance: Value = self.fetch_balance(&[params.clone()]).await;
5745 return get_value(&balance, &part);
5746
5747 Value::Null
5748} }
5749
5750 fn fetch_free_balance(&mut self, optional_args: &[Value]) -> impl ::std::future::Future<Output = Value> + Send { async move {
5751 let mut params = get_arg(optional_args, 0, Value::Map({
5752 let mut m = indexmap::IndexMap::new();
5753 m
5754}));
5755 return self.fetch_partial_balance(Value::Str("free".to_string()), &[params.clone()]).await;
5756
5757 Value::Null
5758} }
5759
5760 fn fetch_used_balance(&mut self, optional_args: &[Value]) -> impl ::std::future::Future<Output = Value> + Send { async move {
5761 let mut params = get_arg(optional_args, 0, Value::Map({
5762 let mut m = indexmap::IndexMap::new();
5763 m
5764}));
5765 return self.fetch_partial_balance(Value::Str("used".to_string()), &[params.clone()]).await;
5766
5767 Value::Null
5768} }
5769
5770 fn fetch_total_balance(&mut self, optional_args: &[Value]) -> impl ::std::future::Future<Output = Value> + Send { async move {
5771 let mut params = get_arg(optional_args, 0, Value::Map({
5772 let mut m = indexmap::IndexMap::new();
5773 m
5774}));
5775 return self.fetch_partial_balance(Value::Str("total".to_string()), &[params.clone()]).await;
5776
5777 Value::Null
5778} }
5779
5780 fn fetch_status(&mut self, optional_args: &[Value]) -> impl ::std::future::Future<Output = Value> + Send { async move {
5781 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 {
5783 if !matches!(__v, crate::Value::Null) { return __v; }
5784 }
5785
5786 let mut params = get_arg(optional_args, 0, Value::Map({
5787 let mut m = indexmap::IndexMap::new();
5788 m
5789}));
5790 panic!("{}", crate::exchange_errors::not_supported(add(&self.id, &Value::Str(" fetchStatus() is not supported yet".to_string()))));
5791
5792 Value::Null
5793} }
5794
5795 fn fetch_transaction_fee(&mut self, mut code: Value, optional_args: &[Value]) -> impl ::std::future::Future<Output = Value> + Send { async move {
5796 let mut params = get_arg(optional_args, 0, Value::Map({
5797 let mut m = indexmap::IndexMap::new();
5798 m
5799}));
5800 if is_equal(&get_value(&self.has, &Value::Str("fetchTransactionFees".to_string())), &Value::Null) || is_equal(&get_value(&self.has, &Value::Str("fetchTransactionFees".to_string())), &Value::Bool(false)) {
5801 panic!("{}", crate::exchange_errors::not_supported(add(&self.id, &Value::Str(" fetchTransactionFee() is not supported yet".to_string()))));
5802 }
5803 return self.fetch_transaction_fees(&[Value::List(vec![code.clone()]), params.clone()]).await;
5804
5805 Value::Null
5806} }
5807
5808 fn fetch_transaction_fees(&mut self, optional_args: &[Value]) -> impl ::std::future::Future<Output = Value> + Send { async move {
5809 let mut codes = get_arg(optional_args, 0, Value::Null);
5810 let mut params = get_arg(optional_args, 1, Value::Map({
5811 let mut m = indexmap::IndexMap::new();
5812 m
5813}));
5814 panic!("{}", crate::exchange_errors::not_supported(add(&self.id, &Value::Str(" fetchTransactionFees() is not supported yet".to_string()))));
5815
5816 Value::Null
5817} }
5818
5819 fn fetch_deposit_withdraw_fees(&mut self, optional_args: &[Value]) -> impl ::std::future::Future<Output = Value> + Send { async move {
5820 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 {
5822 if !matches!(__v, crate::Value::Null) { return __v; }
5823 }
5824
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(add(&self.id, &Value::Str(" fetchDepositWithdrawFees() is not supported yet".to_string()))));
5831
5832 Value::Null
5833} }
5834
5835 fn fetch_deposit_withdraw_fee(&mut self, mut code: Value, optional_args: &[Value]) -> impl ::std::future::Future<Output = Value> + Send { async move {
5836 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 {
5838 if !matches!(__v, crate::Value::Null) { return __v; }
5839 }
5840
5841 let mut params = get_arg(optional_args, 0, Value::Map({
5842 let mut m = indexmap::IndexMap::new();
5843 m
5844}));
5845 if is_equal(&get_value(&self.has, &Value::Str("fetchDepositWithdrawFees".to_string())), &Value::Null) || is_equal(&get_value(&self.has, &Value::Str("fetchDepositWithdrawFees".to_string())), &Value::Bool(false)) {
5846 panic!("{}", crate::exchange_errors::not_supported(add(&self.id, &Value::Str(" fetchDepositWithdrawFee() is not supported yet".to_string()))));
5847 }
5848 let mut fees: Value = self.fetch_deposit_withdraw_fees(&[Value::List(vec![code.clone()]), params.clone()]).await;
5849 return self.safe_value(fees.clone(), code.clone(), &[]);
5850
5851 Value::Null
5852} }
5853
5854 fn get_supported_mapping(&self, mut key: Value, optional_args: &[Value]) -> Value {
5855 let mut mapping = get_arg(optional_args, 0, Value::Map({
5856 let mut m = indexmap::IndexMap::new();
5857 m
5858}));
5859 if is_true(&Value::Bool(in_op(&mapping, &key))) {
5860 return get_value(&mapping, &key);
5861 } else {
5862 panic!("{}", crate::exchange_errors::not_supported(add(&add(&add(&self.id, &Value::Str(" ".to_string())), &key), &Value::Str(" does not have a value in mapping".to_string()))));
5863 }
5864
5865 Value::Null
5866}
5867
5868 fn fetch_cross_borrow_rate(&mut self, mut code: Value, optional_args: &[Value]) -> impl ::std::future::Future<Output = Value> + Send { async move {
5869 let mut params = get_arg(optional_args, 0, Value::Map({
5870 let mut m = indexmap::IndexMap::new();
5871 m
5872}));
5873 self.load_markets(&[]).await;
5874 if is_equal(&get_value(&self.has, &Value::Str("fetchBorrowRates".to_string())), &Value::Null) || is_equal(&get_value(&self.has, &Value::Str("fetchBorrowRates".to_string())), &Value::Bool(false)) {
5875 panic!("{}", crate::exchange_errors::not_supported(add(&self.id, &Value::Str(" fetchCrossBorrowRate() is not supported yet".to_string()))));
5876 }
5877 let mut borrowRates: Value = self.fetch_cross_borrow_rates(&[params.clone()]).await;
5878 let mut rate: Value = self.safe_value(borrowRates.clone(), code.clone(), &[]);
5879 if is_equal(&rate, &Value::Null) {
5880 panic!("{}", crate::exchange_errors::exchange_error(add(&add(&self.id, &Value::Str(" fetchCrossBorrowRate() could not find the borrow rate for currency code ".to_string())), &code)));
5881 }
5882 return rate;
5883
5884 Value::Null
5885} }
5886
5887 fn fetch_isolated_borrow_rate(&mut self, mut symbol: Value, optional_args: &[Value]) -> impl ::std::future::Future<Output = Value> + Send { async move {
5888 let mut params = get_arg(optional_args, 0, Value::Map({
5889 let mut m = indexmap::IndexMap::new();
5890 m
5891}));
5892 self.load_markets(&[]).await;
5893 if is_equal(&get_value(&self.has, &Value::Str("fetchBorrowRates".to_string())), &Value::Null) || is_equal(&get_value(&self.has, &Value::Str("fetchBorrowRates".to_string())), &Value::Bool(false)) {
5894 panic!("{}", crate::exchange_errors::not_supported(add(&self.id, &Value::Str(" fetchIsolatedBorrowRate() is not supported yet".to_string()))));
5895 }
5896 let mut borrowRates: Value = self.fetch_isolated_borrow_rates(&[params.clone()]).await;
5897 let mut rate: Value = self.safe_dict(borrowRates.clone(), symbol.clone(), &[]);
5898 if is_equal(&rate, &Value::Null) {
5899 panic!("{}", crate::exchange_errors::exchange_error(add(&add(&self.id, &Value::Str(" fetchIsolatedBorrowRate() could not find the borrow rate for market symbol ".to_string())), &symbol)));
5900 }
5901 return rate;
5902
5903 Value::Null
5904} }
5905
5906fn require_value(&self, mut value: Value, optional_args: &[Value]) -> Value {
5909 let mut message = get_arg(optional_args, 0, Value::Null);
5910 if is_equal(&value, &Value::Null) {
5911 let mut errorMessage: Value = ternary(is_true(&(!is_equal(&message, &Value::Null))), message.clone(), Value::Str("value is required".to_string()));
5912 panic!("{}", crate::exchange_errors::arguments_required(add(&add(&self.id, &Value::Str(" ".to_string())), &errorMessage)));
5913 }
5914 return value;
5915
5916 Value::Null
5917}
5918
5919fn handle_option_and_params(&self, mut params: Value, mut methodName: Value, mut optionName: Value, optional_args: &[Value]) -> Value {
5922 let mut defaultValue = get_arg(optional_args, 0, Value::Null);
5923 let mut defaultOptionName: Value = add(&Value::Str("default".to_string()), &self.capitalize(optionName.clone())); let mut value: Value = self.safe_value2(params.clone(), optionName.clone(), defaultOptionName.clone(), &[]);
5927 if !is_equal(&value, &Value::Null) {
5928 params = self.omit(params.clone(), Value::List(vec![optionName.clone(), defaultOptionName.clone()]), &[]);
5929 } else {
5930 { let __destr_tmp = self.handle_param_string(params.clone(), Value::Str("callerMethodName".to_string()), &[methodName.clone()]); methodName = get_value(&__destr_tmp, &Value::Int(0)); params = get_value(&__destr_tmp, &Value::Int(1)); }
5932 let mut exchangeWideMethodOptions: Value = self.safe_value(self.options.clone(), methodName.clone(), &[]);
5934 if !is_equal(&exchangeWideMethodOptions, &Value::Null) {
5935 value = self.safe_value2(exchangeWideMethodOptions.clone(), optionName.clone(), defaultOptionName.clone(), &[]);
5937 }
5938 if is_equal(&value, &Value::Null) {
5939 value = self.safe_value2(self.options.clone(), optionName.clone(), defaultOptionName.clone(), &[]);
5941 }
5942 value = ternary(is_true(&(!is_equal(&value, &Value::Null))), value.clone(), defaultValue.clone());
5944 }
5945 return Value::List(vec![value.clone(), params.clone()]);
5946
5947 Value::Null
5948}
5949
5950fn handle_option_and_params2(&self, mut params: Value, mut methodName1: Value, mut optionName1: Value, mut optionName2: Value, optional_args: &[Value]) -> Value {
5953 let mut defaultValue = get_arg(optional_args, 0, Value::Null);
5954 let mut value: Value = Value::Null;
5955 { let __destr_tmp = self.handle_option_and_params(params.clone(), methodName1.clone(), optionName1.clone(), &[]); value = get_value(&__destr_tmp, &Value::Int(0)); params = get_value(&__destr_tmp, &Value::Int(1)); }
5956 if !is_equal(&value, &Value::Null) {
5957 params = self.omit(params.clone(), optionName2.clone(), &[]);
5959 return Value::List(vec![value.clone(), params.clone()]);
5960 }
5961 let mut value2: Value = Value::Null;
5963 { let __destr_tmp = self.handle_option_and_params(params.clone(), methodName1.clone(), optionName2.clone(), &[defaultValue.clone()]); value2 = get_value(&__destr_tmp, &Value::Int(0)); params = get_value(&__destr_tmp, &Value::Int(1)); }
5964 return Value::List(vec![value2.clone(), params.clone()]);
5965
5966 Value::Null
5967}
5968
5969 fn handle_option(&self, mut methodName: Value, mut optionName: Value, optional_args: &[Value]) -> Value {
5970 let mut defaultValue = get_arg(optional_args, 0, Value::Null);
5971 let mut res: Value = self.handle_option_and_params(Value::Map({
5972 let mut m = indexmap::IndexMap::new();
5973 m
5974}), methodName.clone(), optionName.clone(), &[defaultValue.clone()]);
5975 return self.safe_value(res.clone(), Value::Int(0), &[]);
5976
5977 Value::Null
5978}
5979
5980 fn handle_market_type_and_params(&self, mut methodName: Value, optional_args: &[Value]) -> Value {
5981 let mut market = get_arg(optional_args, 0, Value::Null);
5982 let mut params = get_arg(optional_args, 1, Value::Map({
5983 let mut m = indexmap::IndexMap::new();
5984 m
5985}));
5986 let mut defaultValue = get_arg(optional_args, 2, Value::Null);
5987 let mut type_var: Value = self.safe_string2(params.clone(), Value::Str("defaultType".to_string()), Value::Str("type".to_string()), &[]);
6001 if !is_equal(&type_var, &Value::Null) {
6002 params = self.omit(params.clone(), Value::List(vec![Value::Str("defaultType".to_string()), Value::Str("type".to_string())]), &[]);
6003 return Value::List(vec![type_var.clone(), params.clone()]);
6004 }
6005 if !is_equal(&market, &Value::Null) {
6007 return Value::List(vec![get_value(&market, &Value::Str("type".to_string())), params.clone()]);
6008 }
6009 if !is_equal(&defaultValue, &Value::Null) {
6011 return Value::List(vec![defaultValue.clone(), params.clone()]);
6012 }
6013 let mut methodOptions: Value = self.safe_dict(self.options.clone(), methodName.clone(), &[]);
6014 if !is_equal(&methodOptions, &Value::Null) {
6015 if is_string(&methodOptions) {
6016 return Value::List(vec![methodOptions.clone(), params.clone()]);
6017 } else {
6018 let mut typeFromMethod: Value = self.safe_string2(methodOptions.clone(), Value::Str("defaultType".to_string()), Value::Str("type".to_string()), &[]);
6019 if !is_equal(&typeFromMethod, &Value::Null) {
6020 return Value::List(vec![typeFromMethod.clone(), params.clone()]);
6021 }
6022 }
6023 }
6024 let mut defaultType: Value = self.safe_string2(self.options.clone(), Value::Str("defaultType".to_string()), Value::Str("type".to_string()), &[Value::Str("spot".to_string())]);
6025 return Value::List(vec![defaultType.clone(), params.clone()]);
6026
6027 Value::Null
6028}
6029
6030 fn handle_sub_type_and_params(&self, mut methodName: Value, optional_args: &[Value]) -> Value {
6031 let mut market = get_arg(optional_args, 0, Value::Null);
6032 let mut params = get_arg(optional_args, 1, Value::Map({
6033 let mut m = indexmap::IndexMap::new();
6034 m
6035}));
6036 let mut defaultValue = get_arg(optional_args, 2, Value::Null);
6037 let mut subType: Value = Value::Null;
6038 let mut subTypeInParams: Value = self.safe_string2(params.clone(), Value::Str("subType".to_string()), Value::Str("defaultSubType".to_string()), &[]);
6040 if !is_equal(&subTypeInParams, &Value::Null) {
6042 if is_true(&(is_equal(&subTypeInParams, &Value::Str("linear".to_string())))) || is_true(&(is_equal(&subTypeInParams, &Value::Str("inverse".to_string())))) {
6043 subType = subTypeInParams.clone();
6044 }
6045 params = self.omit(params.clone(), Value::List(vec![Value::Str("subType".to_string()), Value::Str("defaultSubType".to_string())]), &[]);
6046 } else {
6047 if !is_equal(&market, &Value::Null) {
6049 if is_equal(&get_value(&market, &Value::Str("linear".to_string())), &Value::Bool(true)) {
6050 subType = Value::Str("linear".to_string());
6051 } else if is_equal(&get_value(&market, &Value::Str("inverse".to_string())), &Value::Bool(true)) {
6052 subType = Value::Str("inverse".to_string());
6053 }
6054 }
6055 if is_equal(&subType, &Value::Null) {
6057 let mut values: Value = self.handle_option_and_params(Value::Map({
6058 let mut m = indexmap::IndexMap::new();
6059 m
6060}), methodName.clone(), Value::Str("subType".to_string()), &[defaultValue.clone()]); subType = get_value(&values, &Value::Int(0));
6062 }
6063 }
6064 return Value::List(vec![subType.clone(), params.clone()]);
6065
6066 Value::Null
6067}
6068
6069 fn handle_margin_mode_and_params(&self, mut methodName: Value, optional_args: &[Value]) -> Value {
6070 let mut params = get_arg(optional_args, 0, Value::Map({
6071 let mut m = indexmap::IndexMap::new();
6072 m
6073}));
6074 let mut defaultValue = get_arg(optional_args, 1, Value::Null);
6075 return self.handle_option_and_params(params.clone(), methodName.clone(), Value::Str("marginMode".to_string()), &[defaultValue.clone()]);
6076
6077 Value::Null
6078}
6079
6080 fn throw_exactly_matched_exception(&self, mut exact: Value, mut string: Value, mut message: Value) {
6081 if is_equal(&string, &Value::Null) {
6082 return;
6083 }
6084 if is_true(&Value::Bool(in_op(&exact, &string))) {
6085 panic!("{}", crate::exchange_errors::create_error(&crate::runtime::stringify_param(&(get_value(&exact, &string))), &crate::runtime::stringify_param(&(message))));
6086 }
6087}
6088
6089 fn throw_broadly_matched_exception(&self, mut broad: Value, mut string: Value, mut message: Value) {
6090 let mut broadKey: Value = self.find_broadly_matched_key(broad.clone(), string.clone());
6091 if !is_equal(&broadKey, &Value::Null) {
6092 panic!("{}", crate::exchange_errors::create_error(&crate::runtime::stringify_param(&(get_value(&broad, &broadKey))), &crate::runtime::stringify_param(&(message))));
6093 }
6094}
6095
6096 fn find_broadly_matched_key(&self, mut broad: Value, mut string: Value) -> Value {
6097 let mut keys: Value = object_keys(&broad);
6099 {
6100 let mut i: Value = Value::Int(0);
6101 let mut __for_first_134: bool = true;
6102 while { if !__for_first_134 { i = add(&i, &Value::Int(1)); } __for_first_134 = false; is_less_than(&i, &get_array_length(&keys)) } {
6103 let mut key: Value = get_value(&keys, &i);
6104 let mut key: Value = get_value(&keys, &i);
6105 if !is_equal(&string, &Value::Null) {
6106 if is_greater_than_or_equal(&get_index_of(&string, &key), &Value::Int(0)) {
6107 return key;
6108 }
6109 }
6110 }
6111 }
6112 return Value::Null;
6113
6114 Value::Null
6115}
6116
6117 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 {
6118 { let __v = crate::exchange::DerivedExchange::handle_errors(self, statusCode.clone(), statusText.clone(), url.clone(), method.clone(), responseHeaders.clone(), responseBody.clone(), response.clone(), requestHeaders.clone(), requestBody.clone()); if !matches!(__v, crate::Value::Null) { return __v; } }
6120
6121 return Value::Null;
6122
6123 Value::Null
6124}
6125
6126 fn calculate_rate_limiter_cost(&self, mut api: Value, mut method: Value, mut path: Value, mut params: Value, optional_args: &[Value]) -> Value {
6127 let mut config = get_arg(optional_args, 0, Value::Map({
6128 let mut m = indexmap::IndexMap::new();
6129 m
6130}));
6131 return self.safe_value_k(config.clone(), "cost", &[Value::Int(1)]);
6132
6133 Value::Null
6134}
6135
6136 fn fetch_spot_tickers(&mut self, optional_args: &[Value]) -> impl ::std::future::Future<Output = Value> + Send { async move {
6137 let mut symbols = get_arg(optional_args, 0, Value::Null);
6138 let mut params = get_arg(optional_args, 1, Value::Map({
6139 let mut m = indexmap::IndexMap::new();
6140 m
6141}));
6142 panic!("{}", crate::exchange_errors::not_supported(add(&self.id, &Value::Str(" fetchSpotTickers() is not supported yet".to_string()))));
6143
6144 Value::Null
6145} }
6146
6147 fn fetch_contract_tickers(&mut self, optional_args: &[Value]) -> impl ::std::future::Future<Output = Value> + Send { async move {
6148 let mut symbols = get_arg(optional_args, 0, Value::Null);
6149 let mut params = get_arg(optional_args, 1, Value::Map({
6150 let mut m = indexmap::IndexMap::new();
6151 m
6152}));
6153 panic!("{}", crate::exchange_errors::not_supported(add(&self.id, &Value::Str(" fetchContractTickers() is not supported yet".to_string()))));
6154
6155 Value::Null
6156} }
6157
6158 fn fetch_order_books(&mut self, optional_args: &[Value]) -> impl ::std::future::Future<Output = Value> + Send { async move {
6159 let mut symbols = get_arg(optional_args, 0, Value::Null);
6160 let mut limit = get_arg(optional_args, 1, Value::Null);
6161 let mut params = get_arg(optional_args, 2, Value::Map({
6162 let mut m = indexmap::IndexMap::new();
6163 m
6164}));
6165 panic!("{}", crate::exchange_errors::not_supported(add(&self.id, &Value::Str(" fetchOrderBooks() is not supported yet".to_string()))));
6166
6167 Value::Null
6168} }
6169
6170 fn un_watch_tickers(&mut self, optional_args: &[Value]) -> impl ::std::future::Future<Output = Value> + Send { async move {
6171 let mut symbols = get_arg(optional_args, 0, Value::Null);
6172 let mut params = get_arg(optional_args, 1, Value::Map({
6173 let mut m = indexmap::IndexMap::new();
6174 m
6175}));
6176 panic!("{}", crate::exchange_errors::not_supported(add(&self.id, &Value::Str(" unWatchTickers() is not supported yet".to_string()))));
6177
6178 Value::Null
6179} }
6180
6181 fn un_watch_funding_rate(&mut self, mut symbol: Value, optional_args: &[Value]) -> impl ::std::future::Future<Output = Value> + Send { async move {
6182 let mut params = get_arg(optional_args, 0, Value::Map({
6183 let mut m = indexmap::IndexMap::new();
6184 m
6185}));
6186 panic!("{}", crate::exchange_errors::not_supported(add(&self.id, &Value::Str(" unWatchFundingRate() is not supported yet".to_string()))));
6187
6188 Value::Null
6189} }
6190
6191 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 {
6192 let mut params = get_arg(optional_args, 0, Value::Map({
6193 let mut m = indexmap::IndexMap::new();
6194 m
6195}));
6196 panic!("{}", crate::exchange_errors::not_supported(add(&self.id, &Value::Str(" createTwapOrder() is not supported yet".to_string()))));
6197
6198 Value::Null
6199} }
6200
6201 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 {
6202 let mut amount = get_arg(optional_args, 0, Value::Null);
6203 let mut params = get_arg(optional_args, 1, Value::Map({
6204 let mut m = indexmap::IndexMap::new();
6205 m
6206}));
6207 panic!("{}", crate::exchange_errors::not_supported(add(&self.id, &Value::Str(" createConvertTrade() is not supported yet".to_string()))));
6208
6209 Value::Null
6210} }
6211
6212 fn fetch_convert_trade(&mut self, mut id: Value, optional_args: &[Value]) -> impl ::std::future::Future<Output = Value> + Send { async move {
6213 let mut code = get_arg(optional_args, 0, Value::Null);
6214 let mut params = get_arg(optional_args, 1, Value::Map({
6215 let mut m = indexmap::IndexMap::new();
6216 m
6217}));
6218 panic!("{}", crate::exchange_errors::not_supported(add(&self.id, &Value::Str(" fetchConvertTrade() is not supported yet".to_string()))));
6219
6220 Value::Null
6221} }
6222
6223 fn fetch_convert_trade_history(&mut self, optional_args: &[Value]) -> impl ::std::future::Future<Output = Value> + Send { async move {
6224 let mut code = get_arg(optional_args, 0, Value::Null);
6225 let mut since = get_arg(optional_args, 1, Value::Null);
6226 let mut limit = get_arg(optional_args, 2, Value::Null);
6227 let mut params = get_arg(optional_args, 3, Value::Map({
6228 let mut m = indexmap::IndexMap::new();
6229 m
6230}));
6231 panic!("{}", crate::exchange_errors::not_supported(add(&self.id, &Value::Str(" fetchConvertTradeHistory() is not supported yet".to_string()))));
6232
6233 Value::Null
6234} }
6235
6236 fn fetch_position_mode(&mut self, optional_args: &[Value]) -> impl ::std::future::Future<Output = Value> + Send { async move {
6237 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 {
6239 if !matches!(__v, crate::Value::Null) { return __v; }
6240 }
6241
6242 let mut symbol = get_arg(optional_args, 0, Value::Null);
6243 let mut params = get_arg(optional_args, 1, Value::Map({
6244 let mut m = indexmap::IndexMap::new();
6245 m
6246}));
6247 panic!("{}", crate::exchange_errors::not_supported(add(&self.id, &Value::Str(" fetchPositionMode() is not supported yet".to_string()))));
6248
6249 Value::Null
6250} }
6251
6252 fn fetch_adl_rank(&mut self, mut symbol: Value, optional_args: &[Value]) -> impl ::std::future::Future<Output = Value> + Send { async move {
6253 let mut params = get_arg(optional_args, 0, Value::Map({
6254 let mut m = indexmap::IndexMap::new();
6255 m
6256}));
6257 panic!("{}", crate::exchange_errors::not_supported(add(&self.id, &Value::Str(" fetchADLRank() is not supported yet".to_string()))));
6258
6259 Value::Null
6260} }
6261
6262 fn fetch_positions_adl_rank(&mut self, optional_args: &[Value]) -> impl ::std::future::Future<Output = Value> + Send { async move {
6263 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 {
6265 if !matches!(__v, crate::Value::Null) { return __v; }
6266 }
6267
6268 let mut symbols = get_arg(optional_args, 0, Value::Null);
6269 let mut params = get_arg(optional_args, 1, Value::Map({
6270 let mut m = indexmap::IndexMap::new();
6271 m
6272}));
6273 panic!("{}", crate::exchange_errors::not_supported(add(&self.id, &Value::Str(" fetchPositionsADLRank() is not supported yet".to_string()))));
6274
6275 Value::Null
6276} }
6277
6278 fn fetch_position_adl_rank(&mut self, mut symbol: Value, optional_args: &[Value]) -> impl ::std::future::Future<Output = Value> + Send { async move {
6279 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 {
6281 if !matches!(__v, crate::Value::Null) { return __v; }
6282 }
6283
6284 let mut params = get_arg(optional_args, 0, Value::Map({
6285 let mut m = indexmap::IndexMap::new();
6286 m
6287}));
6288 if !is_equal(&get_value(&self.has, &Value::Str("fetchPositionsADLRank".to_string())), &Value::Null) && !is_equal(&get_value(&self.has, &Value::Str("fetchPositionsADLRank".to_string())), &Value::Bool(false)) {
6289 self.load_markets(&[]).await;
6290 let mut market: Value = self.market(symbol.clone());
6291 symbol = get_value(&market, &Value::Str("symbol".to_string()));
6292 let mut ranks: Value = self.fetch_positions_adl_rank(&[Value::List(vec![symbol.clone()]), params.clone()]).await;
6293 let mut rank: Value = self.safe_dict(ranks.clone(), Value::Int(0), &[]);
6294 if is_equal(&rank, &Value::Null) {
6295 panic!("{}", crate::exchange_errors::null_response(add(&add(&self.id, &Value::Str(" fetchPositionsADLRank() could not find a rank for ".to_string())), &symbol)));
6296 } else {
6297 return rank;
6298 }
6299 } else {
6300 panic!("{}", crate::exchange_errors::not_supported(add(&self.id, &Value::Str(" fetchPositionsADLRank() is not supported yet".to_string()))));
6301 }
6302
6303 Value::Null
6304} }
6305
6306 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 {
6307 let mut price = get_arg(optional_args, 0, Value::Null);
6308 let mut takeProfit = get_arg(optional_args, 1, Value::Null);
6309 let mut stopLoss = get_arg(optional_args, 2, Value::Null);
6310 let mut params = get_arg(optional_args, 3, Value::Map({
6311 let mut m = indexmap::IndexMap::new();
6312 m
6313}));
6314 if is_true(&(is_equal(&takeProfit, &Value::Null))) && is_true(&(is_equal(&stopLoss, &Value::Null))) {
6315 panic!("{}", crate::exchange_errors::arguments_required(add(&self.id, &Value::Str(" createOrderWithTakeProfitAndStopLoss() requires either a takeProfit or stopLoss argument".to_string()))));
6316 }
6317 if !is_equal(&takeProfit, &Value::Null) {
6318 add_element_to_object(&mut params, &Value::Str("takeProfit".to_string()), Value::Map({
6319 let mut m = indexmap::IndexMap::new();
6320 m.insert("triggerPrice".to_string(), takeProfit.clone());
6321 m
6322}));
6323 }
6324 if !is_equal(&stopLoss, &Value::Null) {
6325 add_element_to_object(&mut params, &Value::Str("stopLoss".to_string()), Value::Map({
6326 let mut m = indexmap::IndexMap::new();
6327 m.insert("triggerPrice".to_string(), stopLoss.clone());
6328 m
6329}));
6330 }
6331 let mut takeProfitType: Value = self.safe_string_k(params.clone(), "takeProfitType", &[]);
6332 let mut takeProfitPriceType: Value = self.safe_string_k(params.clone(), "takeProfitPriceType", &[]);
6333 let mut takeProfitLimitPrice: Value = self.safe_string_k(params.clone(), "takeProfitLimitPrice", &[]);
6334 let mut takeProfitAmount: Value = self.safe_string_k(params.clone(), "takeProfitAmount", &[]);
6335 let mut stopLossType: Value = self.safe_string_k(params.clone(), "stopLossType", &[]);
6336 let mut stopLossPriceType: Value = self.safe_string_k(params.clone(), "stopLossPriceType", &[]);
6337 let mut stopLossLimitPrice: Value = self.safe_string_k(params.clone(), "stopLossLimitPrice", &[]);
6338 let mut stopLossAmount: Value = self.safe_string_k(params.clone(), "stopLossAmount", &[]);
6339 if !is_equal(&takeProfitType, &Value::Null) {
6340 add_element_to_object(get_value_mut(&mut params, &Value::Str("takeProfit".to_string())), &Value::Str("type".to_string()), takeProfitType.clone());
6341 }
6342 if !is_equal(&takeProfitPriceType, &Value::Null) {
6343 add_element_to_object(get_value_mut(&mut params, &Value::Str("takeProfit".to_string())), &Value::Str("priceType".to_string()), takeProfitPriceType.clone());
6344 }
6345 if !is_equal(&takeProfitLimitPrice, &Value::Null) {
6346 add_element_to_object(get_value_mut(&mut params, &Value::Str("takeProfit".to_string())), &Value::Str("price".to_string()), self.parse_to_numeric(takeProfitLimitPrice.clone()));
6347 }
6348 if !is_equal(&takeProfitAmount, &Value::Null) {
6349 add_element_to_object(get_value_mut(&mut params, &Value::Str("takeProfit".to_string())), &Value::Str("amount".to_string()), self.parse_to_numeric(takeProfitAmount.clone()));
6350 }
6351 if !is_equal(&stopLossType, &Value::Null) {
6352 add_element_to_object(get_value_mut(&mut params, &Value::Str("stopLoss".to_string())), &Value::Str("type".to_string()), stopLossType.clone());
6353 }
6354 if !is_equal(&stopLossPriceType, &Value::Null) {
6355 add_element_to_object(get_value_mut(&mut params, &Value::Str("stopLoss".to_string())), &Value::Str("priceType".to_string()), stopLossPriceType.clone());
6356 }
6357 if !is_equal(&stopLossLimitPrice, &Value::Null) {
6358 add_element_to_object(get_value_mut(&mut params, &Value::Str("stopLoss".to_string())), &Value::Str("price".to_string()), self.parse_to_numeric(stopLossLimitPrice.clone()));
6359 }
6360 if !is_equal(&stopLossAmount, &Value::Null) {
6361 add_element_to_object(get_value_mut(&mut params, &Value::Str("stopLoss".to_string())), &Value::Str("amount".to_string()), self.parse_to_numeric(stopLossAmount.clone()));
6362 }
6363 params = self.omit(params.clone(), Value::List(vec![Value::Str("takeProfitType".to_string()), Value::Str("takeProfitPriceType".to_string()), Value::Str("takeProfitLimitPrice".to_string()), Value::Str("takeProfitAmount".to_string()), Value::Str("stopLossType".to_string()), Value::Str("stopLossPriceType".to_string()), Value::Str("stopLossLimitPrice".to_string()), Value::Str("stopLossAmount".to_string())]), &[]);
6364 return params;
6365
6366 Value::Null
6367}
6368
6369 fn create_spot_orders(&mut self, mut orders: Value, optional_args: &[Value]) -> impl ::std::future::Future<Output = Value> + Send { async move {
6370 let mut params = get_arg(optional_args, 0, Value::Map({
6371 let mut m = indexmap::IndexMap::new();
6372 m
6373}));
6374 panic!("{}", crate::exchange_errors::not_supported(add(&self.id, &Value::Str(" createSpotOrders() is not supported yet".to_string()))));
6375
6376 Value::Null
6377} }
6378
6379 fn create_contract_orders(&mut self, mut orders: Value, optional_args: &[Value]) -> impl ::std::future::Future<Output = Value> + Send { async move {
6380 let mut params = get_arg(optional_args, 0, Value::Map({
6381 let mut m = indexmap::IndexMap::new();
6382 m
6383}));
6384 panic!("{}", crate::exchange_errors::not_supported(add(&self.id, &Value::Str(" createContractOrders() is not supported yet".to_string()))));
6385
6386 Value::Null
6387} }
6388
6389 fn cancel_spot_order(&mut self, mut id: Value, optional_args: &[Value]) -> impl ::std::future::Future<Output = Value> + Send { async move {
6390 let mut symbol = get_arg(optional_args, 0, Value::Null);
6391 let mut params = get_arg(optional_args, 1, Value::Map({
6392 let mut m = indexmap::IndexMap::new();
6393 m
6394}));
6395 panic!("{}", crate::exchange_errors::not_supported(add(&self.id, &Value::Str(" cancelSpotOrder() is not supported yet".to_string()))));
6396
6397 Value::Null
6398} }
6399
6400 fn cancel_contract_order(&mut self, mut id: Value, optional_args: &[Value]) -> impl ::std::future::Future<Output = Value> + Send { async move {
6401 let mut symbol = get_arg(optional_args, 0, Value::Null);
6402 let mut params = get_arg(optional_args, 1, Value::Map({
6403 let mut m = indexmap::IndexMap::new();
6404 m
6405}));
6406 panic!("{}", crate::exchange_errors::not_supported(add(&self.id, &Value::Str(" cancelContractOrder() is not supported yet".to_string()))));
6407
6408 Value::Null
6409} }
6410
6411 fn cancel_all_spot_orders(&mut self, optional_args: &[Value]) -> impl ::std::future::Future<Output = Value> + Send { async move {
6412 let mut symbol = get_arg(optional_args, 0, Value::Null);
6413 let mut params = get_arg(optional_args, 1, Value::Map({
6414 let mut m = indexmap::IndexMap::new();
6415 m
6416}));
6417 panic!("{}", crate::exchange_errors::not_supported(add(&self.id, &Value::Str(" cancelAllSpotOrders() is not supported yet".to_string()))));
6418
6419 Value::Null
6420} }
6421
6422 fn cancel_all_contract_orders(&mut self, optional_args: &[Value]) -> impl ::std::future::Future<Output = Value> + Send { async move {
6423 let mut symbol = get_arg(optional_args, 0, Value::Null);
6424 let mut params = get_arg(optional_args, 1, Value::Map({
6425 let mut m = indexmap::IndexMap::new();
6426 m
6427}));
6428 panic!("{}", crate::exchange_errors::not_supported(add(&self.id, &Value::Str(" cancelAllContractOrders() is not supported yet".to_string()))));
6429
6430 Value::Null
6431} }
6432
6433 fn cancel_all_orders_after(&mut self, mut timeout: Value, optional_args: &[Value]) -> impl ::std::future::Future<Output = Value> + Send { async move {
6434 let mut params = get_arg(optional_args, 0, Value::Map({
6435 let mut m = indexmap::IndexMap::new();
6436 m
6437}));
6438 panic!("{}", crate::exchange_errors::not_supported(add(&self.id, &Value::Str(" cancelAllOrdersAfter() is not supported yet".to_string()))));
6439
6440 Value::Null
6441} }
6442
6443 fn cancel_orders_for_symbols(&mut self, mut orders: Value, optional_args: &[Value]) -> impl ::std::future::Future<Output = Value> + Send { async move {
6444 let mut params = get_arg(optional_args, 0, Value::Map({
6445 let mut m = indexmap::IndexMap::new();
6446 m
6447}));
6448 panic!("{}", crate::exchange_errors::not_supported(add(&self.id, &Value::Str(" cancelOrdersForSymbols() is not supported yet".to_string()))));
6449
6450 Value::Null
6451} }
6452
6453 fn fetch_my_liquidations(&mut self, optional_args: &[Value]) -> impl ::std::future::Future<Output = Value> + Send { async move {
6454 let mut symbol = get_arg(optional_args, 0, Value::Null);
6455 let mut since = get_arg(optional_args, 1, Value::Null);
6456 let mut limit = get_arg(optional_args, 2, Value::Null);
6457 let mut params = get_arg(optional_args, 3, Value::Map({
6458 let mut m = indexmap::IndexMap::new();
6459 m
6460}));
6461 panic!("{}", crate::exchange_errors::not_supported(add(&self.id, &Value::Str(" fetchMyLiquidations() is not supported yet".to_string()))));
6462
6463 Value::Null
6464} }
6465
6466 fn fetch_liquidations(&mut self, mut symbol: Value, optional_args: &[Value]) -> impl ::std::future::Future<Output = Value> + Send { async move {
6467 let mut since = get_arg(optional_args, 0, Value::Null);
6468 let mut limit = get_arg(optional_args, 1, Value::Null);
6469 let mut params = get_arg(optional_args, 2, Value::Map({
6470 let mut m = indexmap::IndexMap::new();
6471 m
6472}));
6473 panic!("{}", crate::exchange_errors::not_supported(add(&self.id, &Value::Str(" fetchLiquidations() is not supported yet".to_string()))));
6474
6475 Value::Null
6476} }
6477
6478 fn fetch_greeks(&mut self, mut symbol: Value, optional_args: &[Value]) -> impl ::std::future::Future<Output = Value> + Send { async move {
6479 let mut params = get_arg(optional_args, 0, Value::Map({
6480 let mut m = indexmap::IndexMap::new();
6481 m
6482}));
6483 panic!("{}", crate::exchange_errors::not_supported(add(&self.id, &Value::Str(" fetchGreeks() is not supported yet".to_string()))));
6484
6485 Value::Null
6486} }
6487
6488 fn fetch_all_greeks(&mut self, optional_args: &[Value]) -> impl ::std::future::Future<Output = Value> + Send { async move {
6489 let mut symbols = get_arg(optional_args, 0, Value::Null);
6490 let mut params = get_arg(optional_args, 1, Value::Map({
6491 let mut m = indexmap::IndexMap::new();
6492 m
6493}));
6494 panic!("{}", crate::exchange_errors::not_supported(add(&self.id, &Value::Str(" fetchAllGreeks() is not supported yet".to_string()))));
6495
6496 Value::Null
6497} }
6498
6499 fn fetch_option_chain(&mut self, mut code: Value, optional_args: &[Value]) -> impl ::std::future::Future<Output = Value> + Send { async move {
6500 let mut params = get_arg(optional_args, 0, Value::Map({
6501 let mut m = indexmap::IndexMap::new();
6502 m
6503}));
6504 panic!("{}", crate::exchange_errors::not_supported(add(&self.id, &Value::Str(" fetchOptionChain() is not supported yet".to_string()))));
6505
6506 Value::Null
6507} }
6508
6509 fn fetch_option(&mut self, mut symbol: Value, optional_args: &[Value]) -> impl ::std::future::Future<Output = Value> + Send { async move {
6510 let mut params = get_arg(optional_args, 0, Value::Map({
6511 let mut m = indexmap::IndexMap::new();
6512 m
6513}));
6514 panic!("{}", crate::exchange_errors::not_supported(add(&self.id, &Value::Str(" fetchOption() is not supported yet".to_string()))));
6515
6516 Value::Null
6517} }
6518
6519 fn fetch_convert_quote(&mut self, mut fromCode: Value, mut toCode: Value, optional_args: &[Value]) -> impl ::std::future::Future<Output = Value> + Send { async move {
6520 let mut amount = get_arg(optional_args, 0, Value::Null);
6521 let mut params = get_arg(optional_args, 1, Value::Map({
6522 let mut m = indexmap::IndexMap::new();
6523 m
6524}));
6525 panic!("{}", crate::exchange_errors::not_supported(add(&self.id, &Value::Str(" fetchConvertQuote() is not supported yet".to_string()))));
6526
6527 Value::Null
6528} }
6529
6530 fn fetch_deposits_withdrawals(&mut self, optional_args: &[Value]) -> impl ::std::future::Future<Output = Value> + Send { async move {
6531 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 {
6533 if !matches!(__v, crate::Value::Null) { return __v; }
6534 }
6535
6536 let mut code = get_arg(optional_args, 0, Value::Null);
6537 let mut since = get_arg(optional_args, 1, Value::Null);
6538 let mut limit = get_arg(optional_args, 2, Value::Null);
6539 let mut params = get_arg(optional_args, 3, Value::Map({
6540 let mut m = indexmap::IndexMap::new();
6541 m
6542}));
6543 panic!("{}", crate::exchange_errors::not_supported(add(&self.id, &Value::Str(" fetchDepositsWithdrawals() is not supported yet".to_string()))));
6544
6545 Value::Null
6546} }
6547
6548 fn fetch_deposits(&mut self, optional_args: &[Value]) -> impl ::std::future::Future<Output = Value> + Send { async move {
6549 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 {
6551 if !matches!(__v, crate::Value::Null) { return __v; }
6552 }
6553
6554 let mut code = get_arg(optional_args, 0, Value::Null);
6555 let mut since = get_arg(optional_args, 1, Value::Null);
6556 let mut limit = get_arg(optional_args, 2, Value::Null);
6557 let mut params = get_arg(optional_args, 3, Value::Map({
6558 let mut m = indexmap::IndexMap::new();
6559 m
6560}));
6561 panic!("{}", crate::exchange_errors::not_supported(add(&self.id, &Value::Str(" fetchDeposits() is not supported yet".to_string()))));
6562
6563 Value::Null
6564} }
6565
6566 fn fetch_withdrawals(&mut self, optional_args: &[Value]) -> impl ::std::future::Future<Output = Value> + Send { async move {
6567 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 {
6569 if !matches!(__v, crate::Value::Null) { return __v; }
6570 }
6571
6572 let mut code = get_arg(optional_args, 0, Value::Null);
6573 let mut since = get_arg(optional_args, 1, Value::Null);
6574 let mut limit = get_arg(optional_args, 2, Value::Null);
6575 let mut params = get_arg(optional_args, 3, Value::Map({
6576 let mut m = indexmap::IndexMap::new();
6577 m
6578}));
6579 panic!("{}", crate::exchange_errors::not_supported(add(&self.id, &Value::Str(" fetchWithdrawals() is not supported yet".to_string()))));
6580
6581 Value::Null
6582} }
6583
6584 fn fetch_deposits_ws(&mut self, optional_args: &[Value]) -> impl ::std::future::Future<Output = Value> + Send { async move {
6585 let mut code = get_arg(optional_args, 0, Value::Null);
6586 let mut since = get_arg(optional_args, 1, Value::Null);
6587 let mut limit = get_arg(optional_args, 2, Value::Null);
6588 let mut params = get_arg(optional_args, 3, Value::Map({
6589 let mut m = indexmap::IndexMap::new();
6590 m
6591}));
6592 panic!("{}", crate::exchange_errors::not_supported(add(&self.id, &Value::Str(" fetchDepositsWs() is not supported yet".to_string()))));
6593
6594 Value::Null
6595} }
6596
6597 fn fetch_withdrawals_ws(&mut self, optional_args: &[Value]) -> impl ::std::future::Future<Output = Value> + Send { async move {
6598 let mut code = get_arg(optional_args, 0, Value::Null);
6599 let mut since = get_arg(optional_args, 1, Value::Null);
6600 let mut limit = get_arg(optional_args, 2, Value::Null);
6601 let mut params = get_arg(optional_args, 3, Value::Map({
6602 let mut m = indexmap::IndexMap::new();
6603 m
6604}));
6605 panic!("{}", crate::exchange_errors::not_supported(add(&self.id, &Value::Str(" fetchWithdrawalsWs() is not supported yet".to_string()))));
6606
6607 Value::Null
6608} }
6609
6610 fn fetch_funding_rate_history(&mut self, optional_args: &[Value]) -> impl ::std::future::Future<Output = Value> + Send { async move {
6611 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 {
6613 if !matches!(__v, crate::Value::Null) { return __v; }
6614 }
6615
6616 let mut symbol = get_arg(optional_args, 0, Value::Null);
6617 let mut since = get_arg(optional_args, 1, Value::Null);
6618 let mut limit = get_arg(optional_args, 2, Value::Null);
6619 let mut params = get_arg(optional_args, 3, Value::Map({
6620 let mut m = indexmap::IndexMap::new();
6621 m
6622}));
6623 panic!("{}", crate::exchange_errors::not_supported(add(&self.id, &Value::Str(" fetchFundingRateHistory() is not supported yet".to_string()))));
6624
6625 Value::Null
6626} }
6627
6628 fn fetch_funding_history(&mut self, optional_args: &[Value]) -> impl ::std::future::Future<Output = Value> + Send { async move {
6629 let mut symbol = get_arg(optional_args, 0, Value::Null);
6630 let mut since = get_arg(optional_args, 1, Value::Null);
6631 let mut limit = get_arg(optional_args, 2, Value::Null);
6632 let mut params = get_arg(optional_args, 3, Value::Map({
6633 let mut m = indexmap::IndexMap::new();
6634 m
6635}));
6636 panic!("{}", crate::exchange_errors::not_supported(add(&self.id, &Value::Str(" fetchFundingHistory() is not supported yet".to_string()))));
6637
6638 Value::Null
6639} }
6640
6641 fn parse_last_price(&self, mut price: Value, optional_args: &[Value]) -> Value {
6642 { let __v = crate::exchange::DerivedExchange::parse_last_price(self, price.clone(), crate::runtime::get_arg(optional_args, 0, crate::Value::Null)); if !matches!(__v, crate::Value::Null) { return __v; } }
6644
6645 let mut market = get_arg(optional_args, 0, Value::Null);
6646 panic!("{}", crate::exchange_errors::not_supported(add(&self.id, &Value::Str(" parseLastPrice() is not supported yet".to_string()))));
6647
6648 Value::Null
6649}
6650
6651 fn fetch_deposit_address(&mut self, mut code: Value, optional_args: &[Value]) -> impl ::std::future::Future<Output = Value> + Send { async move {
6652 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 {
6654 if !matches!(__v, crate::Value::Null) { return __v; }
6655 }
6656
6657 let mut params = get_arg(optional_args, 0, Value::Map({
6658 let mut m = indexmap::IndexMap::new();
6659 m
6660}));
6661 if !is_equal(&get_value(&self.has, &Value::Str("fetchDepositAddresses".to_string())), &Value::Null) && !is_equal(&get_value(&self.has, &Value::Str("fetchDepositAddresses".to_string())), &Value::Bool(false)) {
6662 let mut depositAddresses: Value = self.fetch_deposit_addresses(&[Value::List(vec![code.clone()]), params.clone()]).await;
6663 let mut depositAddress: Value = self.safe_value(depositAddresses.clone(), code.clone(), &[]);
6664 if is_equal(&depositAddress, &Value::Null) {
6665 panic!("{}", crate::exchange_errors::invalid_address(add(&add(&add(&self.id, &Value::Str(" fetchDepositAddress() could not find a deposit address for ".to_string())), &code), &Value::Str(", make sure you have created a corresponding deposit address in your wallet on the exchange website".to_string()))));
6666 } else {
6667 return depositAddress;
6668 }
6669 } else if !is_equal(&get_value(&self.has, &Value::Str("fetchDepositAddressesByNetwork".to_string())), &Value::Null) && !is_equal(&get_value(&self.has, &Value::Str("fetchDepositAddressesByNetwork".to_string())), &Value::Bool(false)) {
6670 let mut network: Value = self.safe_string_k(params.clone(), "network", &[]);
6671 params = self.omit(params.clone(), Value::Str("network".to_string()), &[]);
6672 let mut addressStructures: Value = self.fetch_deposit_addresses_by_network(code.clone(), &[params.clone()]).await;
6673 if !is_equal(&network, &Value::Null) {
6674 return self.safe_dict(addressStructures.clone(), network.clone(), &[]);
6675 } else {
6676 let mut keys: Value = object_keys(&addressStructures);
6677 let mut key: Value = get_value(&keys, &Value::Int(0));
6678 return self.safe_dict(addressStructures.clone(), key.clone(), &[]);
6679 }
6680 } else {
6681 panic!("{}", crate::exchange_errors::not_supported(add(&self.id, &Value::Str(" fetchDepositAddress() is not supported yet".to_string()))));
6682 }
6683
6684 Value::Null
6685} }
6686
6687 fn fetch_contract_deposit_address(&mut self, mut code: Value, optional_args: &[Value]) -> impl ::std::future::Future<Output = Value> + Send { async move {
6688 let mut params = get_arg(optional_args, 0, Value::Map({
6689 let mut m = indexmap::IndexMap::new();
6690 m
6691}));
6692 panic!("{}", crate::exchange_errors::not_supported(add(&self.id, &Value::Str(" fetchContractDepositAddress() is not supported yet".to_string()))));
6693
6694 Value::Null
6695} }
6696
6697 fn account(&self) -> Value {
6698 return Value::Map({
6699 let mut m = indexmap::IndexMap::new();
6700 m.insert("free".to_string(), Value::Null);
6701 m.insert("used".to_string(), Value::Null);
6702 m.insert("total".to_string(), Value::Null);
6703 m
6704});
6705
6706 Value::Null
6707}
6708
6709fn merge_balance_account(&self, mut result: Value, mut code: Value, mut account: Value) -> Value {
6719 if !is_true(&(Value::Bool(in_op(&result, &code)))) {
6720 add_element_to_object(&mut result, &code, account.clone());
6721 return result;
6722 }
6723 let mut fields: Value = Value::List(vec![Value::Str("free".to_string()), Value::Str("used".to_string()), Value::Str("total".to_string()), Value::Str("debt".to_string())]);
6724 {
6725 let mut i: Value = Value::Int(0);
6726 let mut __for_first_135: bool = true;
6727 while { if !__for_first_135 { i = add(&i, &Value::Int(1)); } __for_first_135 = false; is_less_than(&i, &get_array_length(&fields)) } {
6728 let mut field: Value = get_value(&fields, &i);
6729 let mut field: Value = get_value(&fields, &i);
6730 let mut current: Value = self.safe_string(get_value(&result, &code), field.clone(), &[]);
6731 let mut incoming: Value = self.safe_string(account.clone(), field.clone(), &[]);
6732 if is_equal(¤t, &Value::Null) {
6733 add_element_to_object(get_value_mut(&mut result, &code), &field, incoming.clone());
6734 } else if !is_equal(&incoming, &Value::Null) {
6735 add_element_to_object(get_value_mut(&mut result, &code), &field, crate::precise::Precise::stringAdd(¤t, &incoming));
6736 }
6737 }
6738 }
6739 return result;
6740
6741 Value::Null
6742}
6743
6744 fn common_currency_code(&self, mut code: Value) -> Value {
6745 if !is_true(&self.substituteCommonCurrencyCodes) {
6746 return code;
6747 }
6748 return self.safe_string(self.commonCurrencies.clone(), code.clone(), &[code.clone()]);
6749
6750 Value::Null
6751}
6752
6753 fn currency(&self, mut code: Value) -> Value {
6754 if is_equal(&code, &Value::Null) {
6755 panic!("{}", crate::exchange_errors::arguments_required(add(&self.id, &Value::Str(" currency() requires a code argument".to_string()))));
6756 }
6757 let mut keys: Value = object_keys(&self.currencies);
6758 let mut numCurrencies: Value = get_array_length(&keys);
6759 if is_equal(&numCurrencies, &Value::Int(0)) {
6760 panic!("{}", crate::exchange_errors::exchange_error(add(&self.id, &Value::Str(" currencies not loaded".to_string()))));
6761 }
6762 if is_string(&code) {
6763 let mut currencies: Value = self.currencies.clone();
6764 let mut currenciesById: Value = self.currencies_by_id.clone();
6765 if is_true(&Value::Bool(in_op(¤cies, &code))) {
6766 return get_value(¤cies, &code);
6767 } else if is_true(&(!is_equal(¤ciesById, &Value::Null))) && is_true(&(Value::Bool(in_op(¤ciesById, &code)))) {
6768 return get_value(¤ciesById, &code);
6769 }
6770 }
6771 panic!("{}", crate::exchange_errors::exchange_error(add(&add(&self.id, &Value::Str(" does not have currency code ".to_string())), &code)));
6772
6773 Value::Null
6774}
6775
6776 fn market(&self, mut symbol: Value) -> Value {
6777 if is_equal(&symbol, &Value::Null) {
6778 panic!("{}", crate::exchange_errors::arguments_required(add(&self.id, &Value::Str(" market() requires a symbol argument".to_string()))));
6779 }
6780 let mut markets: Value = self.markets.clone();
6781 if is_equal(&markets, &Value::Null) {
6782 panic!("{}", crate::exchange_errors::exchange_error(add(&self.id, &Value::Str(" markets not loaded".to_string()))));
6783 }
6784 let mut marketsById: Value = self.markets_by_id.clone();
6785 if is_true(&Value::Bool(in_op(&markets, &symbol))) {
6786 return get_value(&markets, &symbol);
6787 } else if is_true(&(!is_equal(&marketsById, &Value::Null))) && is_true(&(Value::Bool(in_op(&marketsById, &symbol)))) {
6788 let mut marketsList: Value = get_value(&marketsById, &symbol);
6789 let mut marketsList: Value = get_value(&marketsById, &symbol);
6790 let mut defaultType: Value = self.safe_string2(self.options.clone(), Value::Str("defaultType".to_string()), Value::Str("defaultSubType".to_string()), &[Value::Str("spot".to_string())]);
6791 {
6792 let mut i: Value = Value::Int(0);
6793 let mut __for_first_136: bool = true;
6794 while { if !__for_first_136 { i = add(&i, &Value::Int(1)); } __for_first_136 = false; is_less_than(&i, &get_array_length(&marketsList)) } {
6795 let mut market: Value = get_value(&marketsList, &i);
6796 let mut market: Value = get_value(&marketsList, &i);
6797 if is_equal(&get_value(&market, &defaultType), &Value::Bool(true)) {
6798 return market;
6799 }
6800 }
6801 }
6802 return get_value(&marketsList, &Value::Int(0));
6803 } else if is_true(&(Value::Bool(ends_with(&symbol, &Value::Str("-C".to_string()))))) || is_true(&(Value::Bool(ends_with(&symbol, &Value::Str("-P".to_string()))))) || is_true(&(Value::Bool(starts_with(&symbol, &Value::Str("C-".to_string()))))) || is_true(&(Value::Bool(starts_with(&symbol, &Value::Str("P-".to_string()))))) {
6804 return <Self as crate::exchange_generated::ExchangeBase>::create_expired_option_market(self, symbol.clone());
6805 }
6806 panic!("{}", crate::exchange_errors::bad_symbol(add(&add(&self.id, &Value::Str(" does not have market symbol ".to_string())), &symbol)));
6807
6808 Value::Null
6809}
6810
6811 fn create_expired_option_market(&self, mut symbol: Value) -> Value {
6812 { let __v = crate::exchange::DerivedExchange::create_expired_option_market(self, symbol.clone()); if !matches!(__v, crate::Value::Null) { return __v; } }
6814
6815 panic!("{}", crate::exchange_errors::not_supported(add(&self.id, &Value::Str(" createExpiredOptionMarket () is not supported yet".to_string()))));
6816
6817 Value::Null
6818}
6819
6820 fn is_leveraged_currency(&self, mut currencyCode: Value, optional_args: &[Value]) -> Value {
6821 let mut checkBaseCoin = get_arg(optional_args, 0, Value::Bool(false));
6822 let mut existingCurrencies = get_arg(optional_args, 1, Value::Null);
6823 let mut leverageSuffixes: Value = Value::List(vec![Value::Str("2L".to_string()), Value::Str("2S".to_string()), Value::Str("3L".to_string()), Value::Str("3S".to_string()), Value::Str("4L".to_string()), Value::Str("4S".to_string()), Value::Str("5L".to_string()), Value::Str("5S".to_string()), Value::Str("UP".to_string()), Value::Str("DOWN".to_string()), Value::Str("BULL".to_string()), Value::Str("BEAR".to_string())]);
6824 {
6825 let mut i: Value = Value::Int(0);
6826 let mut __for_first_137: bool = true;
6827 while { if !__for_first_137 { i = add(&i, &Value::Int(1)); } __for_first_137 = false; is_less_than(&i, &get_array_length(&leverageSuffixes)) } {
6828 let mut leverageSuffix: Value = get_value(&leverageSuffixes, &i);
6829 let mut leverageSuffix: Value = get_value(&leverageSuffixes, &i);
6830 let mut endsWithSuffix: bool = ends_with(¤cyCode, &leverageSuffix);
6831 if is_true(&endsWithSuffix) {
6832 if !is_true(&checkBaseCoin) {
6833 return Value::Bool(true);
6834 } else {
6835 let mut baseCurrencyCode: Value = replace_str(¤cyCode, &leverageSuffix, &Value::Str("".to_string()));
6837 if is_true(&(!is_equal(&existingCurrencies, &Value::Null))) && is_true(&(Value::Bool(in_op(&existingCurrencies, &baseCurrencyCode)))) {
6838 return Value::Bool(true);
6839 }
6840 }
6841 }
6842 }
6843 }
6844 return Value::Bool(false);
6845
6846 Value::Null
6847}
6848
6849 fn handle_withdraw_tag_and_params(&self, mut tag: Value, mut params: Value) -> Value {
6850 if is_true(&self.is_dictionary(tag.clone())) {
6851 params = self.extend(tag.clone(), &[params.clone()]);
6852 tag = Value::Null;
6853 }
6854 if is_equal(&tag, &Value::Null) {
6855 tag = self.safe_string_k(params.clone(), "tag", &[]);
6856 if !is_equal(&tag, &Value::Null) {
6857 params = self.omit(params.clone(), Value::Str("tag".to_string()), &[]);
6858 }
6859 }
6860 return Value::List(vec![tag.clone(), params.clone()]);
6861
6862 Value::Null
6863}
6864
6865 fn cost_to_precision(&self, mut symbol: Value, mut cost: Value) -> Value {
6866 if is_equal(&cost, &Value::Null) {
6867 return Value::Null;
6868 }
6869 let mut market: Value = self.market(symbol.clone());
6870 return self.decimal_to_precision(cost.clone(), Value::Int(crate::runtime::TRUNCATE), self.safe_string2(get_value(&market, &Value::Str("precision".to_string())), Value::Str("cost".to_string()), Value::Str("price".to_string()), &[]), &[self.precisionMode.clone(), self.paddingMode.clone()]);
6871
6872 Value::Null
6873}
6874
6875 fn price_to_precision(&self, mut symbol: Value, mut price: Value) -> Value {
6876 if is_equal(&price, &Value::Null) {
6877 return Value::Null;
6878 }
6879 let mut market: Value = self.market(symbol.clone());
6880 let mut result: Value = self.decimal_to_precision(price.clone(), Value::Int(crate::runtime::ROUND), get_value(&get_value(&market, &Value::Str("precision".to_string())), &Value::Str("price".to_string())), &[self.precisionMode.clone(), self.paddingMode.clone()]);
6881 if is_equal(&result, &Value::Str("0".to_string())) {
6882 panic!("{}", crate::exchange_errors::invalid_order(add(&add(&add(&add(&self.id, &Value::Str(" price of ".to_string())), &get_value(&market, &Value::Str("symbol".to_string()))), &Value::Str(" must be greater than minimum price precision of ".to_string())), &self.number_to_string(get_value(&get_value(&market, &Value::Str("precision".to_string())), &Value::Str("price".to_string()))))));
6883 }
6884 return result;
6885
6886 Value::Null
6887}
6888
6889 fn amount_to_precision(&self, mut symbol: Value, mut amount: Value) -> Value {
6890 if is_equal(&amount, &Value::Null) {
6891 return Value::Null;
6892 }
6893 let mut market: Value = self.market(symbol.clone());
6894 let mut result: Value = self.decimal_to_precision(amount.clone(), Value::Int(crate::runtime::TRUNCATE), get_value(&get_value(&market, &Value::Str("precision".to_string())), &Value::Str("amount".to_string())), &[self.precisionMode.clone(), self.paddingMode.clone()]);
6895 if is_equal(&result, &Value::Str("0".to_string())) {
6896 panic!("{}", crate::exchange_errors::invalid_order(add(&add(&add(&add(&self.id, &Value::Str(" amount of ".to_string())), &get_value(&market, &Value::Str("symbol".to_string()))), &Value::Str(" must be greater than minimum amount precision of ".to_string())), &self.number_to_string(get_value(&get_value(&market, &Value::Str("precision".to_string())), &Value::Str("amount".to_string()))))));
6897 }
6898 return result;
6899
6900 Value::Null
6901}
6902
6903 fn fee_to_precision(&self, mut symbol: Value, mut fee: Value) -> Value {
6904 if is_equal(&fee, &Value::Null) {
6905 return Value::Null;
6906 }
6907 let mut market: Value = self.market(symbol.clone());
6908 return self.decimal_to_precision(fee.clone(), Value::Int(crate::runtime::ROUND), get_value(&get_value(&market, &Value::Str("precision".to_string())), &Value::Str("price".to_string())), &[self.precisionMode.clone(), self.paddingMode.clone()]);
6909
6910 Value::Null
6911}
6912
6913 fn currency_to_precision(&self, mut code: Value, mut fee: Value, optional_args: &[Value]) -> Value {
6914 let mut networkCode = get_arg(optional_args, 0, Value::Null);
6915 if is_equal(&code, &Value::Null) {
6916 panic!("{}", crate::exchange_errors::arguments_required(add(&self.id, &Value::Str(" currencyToPrecision() requires a code argument".to_string()))));
6917 }
6918 let mut currency: Value = get_value(&self.currencies, &code);
6919 let mut precision: Value = self.safe_value_k(currency.clone(), "precision", &[]);
6920 if !is_equal(&networkCode, &Value::Null) {
6921 let mut networks: Value = self.safe_dict_k(currency.clone(), "networks", &[Value::Map({
6922 let mut m = indexmap::IndexMap::new();
6923 m
6924})]);
6925 let mut networkItem: Value = self.safe_dict(networks.clone(), networkCode.clone(), &[Value::Map({
6926 let mut m = indexmap::IndexMap::new();
6927 m
6928})]);
6929 precision = self.safe_value_k(networkItem.clone(), "precision", &[precision.clone()]);
6930 }
6931 if is_equal(&precision, &Value::Null) {
6932 return self.force_string(fee.clone());
6933 } else {
6934 let mut roundingMode: Value = self.safe_integer_k(self.options.clone(), "currencyToPrecisionRoundingMode", &[Value::Int(crate::runtime::ROUND)]);
6935 return self.decimal_to_precision(fee.clone(), roundingMode.clone(), precision.clone(), &[self.precisionMode.clone(), self.paddingMode.clone()]);
6936 }
6937
6938 Value::Null
6939}
6940
6941 fn force_string(&self, mut value: Value) -> Value {
6942 if !is_string(&value) {
6943 return self.number_to_string(value.clone());
6944 }
6945 return value;
6946
6947 Value::Null
6948}
6949
6950 fn is_tick_precision(&self) -> Value {
6951 return Value::Bool(is_equal(&self.precisionMode, &Value::Int(crate::runtime::TICK_SIZE)));
6952
6953 Value::Null
6954}
6955
6956 fn is_decimal_precision(&self) -> Value {
6957 return Value::Bool(is_equal(&self.precisionMode, &Value::Int(crate::runtime::DECIMAL_PLACES)));
6958
6959 Value::Null
6960}
6961
6962 fn is_significant_precision(&self) -> Value {
6963 return Value::Bool(is_equal(&self.precisionMode, &Value::Int(crate::runtime::SIGNIFICANT_DIGITS)));
6964
6965 Value::Null
6966}
6967
6968 fn safe_number(&self, mut obj: Value, mut key: Value, optional_args: &[Value]) -> Value {
6969 let mut defaultNumber = get_arg(optional_args, 0, Value::Null);
6970 let mut value: Value = self.safe_string(obj.clone(), key.clone(), &[]);
6971 return self.parse_number(value.clone(), &[defaultNumber.clone()]);
6972
6973 Value::Null
6974}
6975
6976 fn safe_number_n(&self, mut obj: Value, mut arr: Value, optional_args: &[Value]) -> Value {
6977 let mut defaultNumber = get_arg(optional_args, 0, Value::Null);
6978 let mut value: Value = self.safe_string_n(obj.clone(), arr.clone(), &[]);
6979 return self.parse_number(value.clone(), &[defaultNumber.clone()]);
6980
6981 Value::Null
6982}
6983
6984 fn parse_precision(&self, optional_args: &[Value]) -> Value {
6985 let mut precision = get_arg(optional_args, 0, Value::Null);
6986 if is_equal(&precision, &Value::Null) {
6993 return Value::Null;
6994 }
6995 let mut precisionNumber: Value = crate::runtime::parse_int(&precision);
6996 if is_equal(&precisionNumber, &Value::Int(0)) {
6997 return Value::Str("1".to_string());
6998 }
6999 if is_greater_than(&precisionNumber, &Value::Int(0)) {
7000 let mut parsedPrecision: Value = Value::Str("0.".to_string());
7001 {
7002 let mut i: Value = Value::Int(0);
7003 let mut __for_first_138: bool = true;
7004 while { if !__for_first_138 { i = add(&i, &Value::Int(1)); } __for_first_138 = false; is_less_than(&i, &subtract(&precisionNumber, &Value::Int(1))) } {
7005 parsedPrecision = add(&parsedPrecision, &Value::Str("0".to_string()));
7006 }
7007 }
7008 return add(&parsedPrecision, &Value::Str("1".to_string()));
7009 } else {
7010 let mut parsedPrecision: Value = Value::Str("1".to_string());
7011 {
7012 let mut i: Value = Value::Int(0);
7013 let mut __for_first_139: bool = true;
7014 while { if !__for_first_139 { i = add(&i, &Value::Int(1)); } __for_first_139 = false; is_less_than(&i, &subtract(&multiply(&precisionNumber, &negate(&Value::Int(1))), &Value::Int(1))) } {
7015 parsedPrecision = add(&parsedPrecision, &Value::Str("0".to_string()));
7016 }
7017 }
7018 return add(&parsedPrecision, &Value::Str("0".to_string()));
7019 }
7020
7021 Value::Null
7022}
7023
7024 fn integer_precision_to_amount(&self, mut precision: Value) -> Value {
7025 if is_equal(&precision, &Value::Null) {
7033 return Value::Null;
7034 }
7035 if is_true(&crate::precise::Precise::stringGe(&precision, &Value::Str("0".to_string()))) {
7036 return self.parse_precision(&[precision.clone()]);
7037 } else {
7038 let mut positivePrecisionString: Value = crate::precise::Precise::stringAbs(&precision);
7039 if is_equal(&positivePrecisionString, &Value::Null) {
7040 return Value::Null;
7041 }
7042 let mut positivePrecision: Value = crate::runtime::parse_int(&positivePrecisionString);
7043 let mut parsedPrecision: Value = Value::Str("1".to_string());
7044 {
7045 let mut i: Value = Value::Int(0);
7046 let mut __for_first_140: bool = true;
7047 while { if !__for_first_140 { i = add(&i, &Value::Int(1)); } __for_first_140 = false; is_less_than(&i, &subtract(&positivePrecision, &Value::Int(1))) } {
7048 parsedPrecision = add(&parsedPrecision, &Value::Str("0".to_string()));
7049 }
7050 }
7051 return add(&parsedPrecision, &Value::Str("0".to_string()));
7052 }
7053}
7054
7055 fn load_time_difference(&mut self, optional_args: &[Value]) -> impl ::std::future::Future<Output = Value> + Send { async move {
7056 let mut params = get_arg(optional_args, 0, Value::Map({
7057 let mut m = indexmap::IndexMap::new();
7058 m
7059}));
7060 let mut serverTime: Value = self.fetch_time(&[params.clone()]).await;
7061 let mut after: Value = self.milliseconds();
7062 if is_equal(&serverTime, &Value::Null) {
7063 panic!("{}", crate::exchange_errors::exchange_error(add(&self.id, &Value::Str(" loadTimeDifference() missing serverTime".to_string()))));
7064 }
7065 add_element_to_object(&mut self.options, &Value::Str("timeDifference".to_string()), subtract(&after, &serverTime));
7066 return get_value(&self.options, &Value::Str("timeDifference".to_string()));
7067
7068 Value::Null
7069} }
7070
7071 fn implode_hostname(&self, mut url: Value) -> Value {
7072 return self.implode_params(url.clone(), Value::Map({
7073 let mut m = indexmap::IndexMap::new();
7074 m.insert("hostname".to_string(), self.hostname.clone());
7075 m
7076}));
7077
7078 Value::Null
7079}
7080
7081 fn fetch_market_leverage_tiers(&mut self, mut symbol: Value, optional_args: &[Value]) -> impl ::std::future::Future<Output = Value> + Send { async move {
7082 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 {
7084 if !matches!(__v, crate::Value::Null) { return __v; }
7085 }
7086
7087 let mut params = get_arg(optional_args, 0, Value::Map({
7088 let mut m = indexmap::IndexMap::new();
7089 m
7090}));
7091 if !is_equal(&get_value(&self.has, &Value::Str("fetchLeverageTiers".to_string())), &Value::Null) && !is_equal(&get_value(&self.has, &Value::Str("fetchLeverageTiers".to_string())), &Value::Bool(false)) {
7092 let mut market: Value = self.market(symbol.clone());
7093 if !is_equal(&get_value(&market, &Value::Str("contract".to_string())), &Value::Bool(true)) {
7094 panic!("{}", crate::exchange_errors::bad_symbol(add(&self.id, &Value::Str(" fetchMarketLeverageTiers() supports contract markets only".to_string()))));
7095 }
7096 let mut tiers: Value = self.fetch_leverage_tiers(&[Value::List(vec![symbol.clone()])]).await;
7097 return self.safe_value(tiers.clone(), symbol.clone(), &[]);
7098 } else {
7099 panic!("{}", crate::exchange_errors::not_supported(add(&self.id, &Value::Str(" fetchMarketLeverageTiers() is not supported yet".to_string()))));
7100 }
7101
7102 Value::Null
7103} }
7104
7105 fn create_sub_account(&mut self, mut name: Value, optional_args: &[Value]) -> impl ::std::future::Future<Output = Value> + Send { async move {
7106 let mut params = get_arg(optional_args, 0, Value::Map({
7107 let mut m = indexmap::IndexMap::new();
7108 m
7109}));
7110 panic!("{}", crate::exchange_errors::not_supported(add(&self.id, &Value::Str(" createSubAccount() is not supported yet".to_string()))));
7111
7112 Value::Null
7113} }
7114
7115 fn safe_currency_code(&self, mut currencyId: Value, optional_args: &[Value]) -> Value {
7116 let mut currency = get_arg(optional_args, 0, Value::Null);
7117 currency = self.safe_currency(currencyId.clone(), &[currency.clone()]);
7118 return get_value(¤cy, &Value::Str("code".to_string()));
7119
7120 Value::Null
7121}
7122
7123 fn filter_by_symbol_since_limit(&self, mut array: Value, optional_args: &[Value]) -> Value {
7124 let mut symbol = get_arg(optional_args, 0, Value::Null);
7125 let mut since = get_arg(optional_args, 1, Value::Null);
7126 let mut limit = get_arg(optional_args, 2, Value::Null);
7127 let mut tail = get_arg(optional_args, 3, Value::Bool(false));
7128 return self.filter_by_value_since_limit(array.clone(), Value::Str("symbol".to_string()), &[symbol.clone(), since.clone(), limit.clone(), Value::Str("timestamp".to_string()), tail.clone()]);
7129
7130 Value::Null
7131}
7132
7133 fn filter_by_currency_since_limit(&self, mut array: Value, optional_args: &[Value]) -> Value {
7134 let mut code = get_arg(optional_args, 0, Value::Null);
7135 let mut since = get_arg(optional_args, 1, Value::Null);
7136 let mut limit = get_arg(optional_args, 2, Value::Null);
7137 let mut tail = get_arg(optional_args, 3, Value::Bool(false));
7138 return self.filter_by_value_since_limit(array.clone(), Value::Str("currency".to_string()), &[code.clone(), since.clone(), limit.clone(), Value::Str("timestamp".to_string()), tail.clone()]);
7139
7140 Value::Null
7141}
7142
7143 fn filter_by_symbols_since_limit(&self, mut array: Value, optional_args: &[Value]) -> Value {
7144 let mut symbols = get_arg(optional_args, 0, Value::Null);
7145 let mut since = get_arg(optional_args, 1, Value::Null);
7146 let mut limit = get_arg(optional_args, 2, Value::Null);
7147 let mut tail = get_arg(optional_args, 3, Value::Bool(false));
7148 let mut result: Value = self.filter_by_array(array.clone(), Value::Str("symbol".to_string()), &[symbols.clone(), Value::Bool(false)]);
7149 return self.filter_by_since_limit(result.clone(), &[since.clone(), limit.clone(), Value::Str("timestamp".to_string()), tail.clone()]);
7150
7151 Value::Null
7152}
7153
7154 fn parse_last_prices(&self, mut pricesData: Value, optional_args: &[Value]) -> Value {
7155 let mut symbols = get_arg(optional_args, 0, Value::Null);
7156 let mut params = get_arg(optional_args, 1, Value::Map({
7157 let mut m = indexmap::IndexMap::new();
7158 m
7159}));
7160 let mut results: Value = Value::List(vec![]);
7180 if is_true(&Value::Bool(is_array(&pricesData))) {
7181 {
7182 let mut i: Value = Value::Int(0);
7183 let mut __for_first_141: bool = true;
7184 while { if !__for_first_141 { i = add(&i, &Value::Int(1)); } __for_first_141 = false; is_less_than(&i, &get_array_length(&pricesData)) } {
7185 let mut priceData: Value = self.extend(<Self as crate::exchange_generated::ExchangeBase>::parse_last_price(self, get_value(&pricesData, &i), &[]), &[params.clone()]);
7186 append_to_array(&mut results, priceData.clone());
7187 }
7188 }
7189 } else {
7190 let mut marketIds: Value = object_keys(&pricesData);
7191 {
7192 let mut i: Value = Value::Int(0);
7193 let mut __for_first_142: bool = true;
7194 while { if !__for_first_142 { i = add(&i, &Value::Int(1)); } __for_first_142 = false; is_less_than(&i, &get_array_length(&marketIds)) } {
7195 let mut marketId: Value = get_value(&marketIds, &i);
7196 let mut marketId: Value = get_value(&marketIds, &i);
7197 let mut market: Value = self.safe_market(&[marketId.clone()]);
7198 let mut priceData: Value = self.extend(<Self as crate::exchange_generated::ExchangeBase>::parse_last_price(self, get_value(&pricesData, &marketId), &[market.clone()]), &[params.clone()]);
7199 append_to_array(&mut results, priceData.clone());
7200 }
7201 }
7202 }
7203 symbols = self.market_symbols(&[symbols.clone()]);
7204 return self.filter_by_array(results.clone(), Value::Str("symbol".to_string()), &[symbols.clone()]);
7205
7206 Value::Null
7207}
7208
7209 fn parse_tickers(&self, mut tickers: Value, optional_args: &[Value]) -> Value {
7210 let mut symbols = get_arg(optional_args, 0, Value::Null);
7211 let mut params = get_arg(optional_args, 1, Value::Map({
7212 let mut m = indexmap::IndexMap::new();
7213 m
7214}));
7215 let mut results: Value = Value::List(vec![]);
7238 if is_true(&Value::Bool(is_array(&tickers))) {
7239 {
7240 let mut i: Value = Value::Int(0);
7241 let mut __for_first_143: bool = true;
7242 while { if !__for_first_143 { i = add(&i, &Value::Int(1)); } __for_first_143 = false; is_less_than(&i, &get_array_length(&tickers)) } {
7243 let mut parsedTicker: Value = <Self as crate::exchange_generated::ExchangeBase>::parse_ticker(self, get_value(&tickers, &i), &[]);
7244 let mut ticker: Value = self.extend(parsedTicker.clone(), &[params.clone()]);
7245 append_to_array(&mut results, ticker.clone());
7246 }
7247 }
7248 } else {
7249 let mut marketIds: Value = object_keys(&tickers);
7250 {
7251 let mut i: Value = Value::Int(0);
7252 let mut __for_first_144: bool = true;
7253 while { if !__for_first_144 { i = add(&i, &Value::Int(1)); } __for_first_144 = false; is_less_than(&i, &get_array_length(&marketIds)) } {
7254 let mut marketId: Value = get_value(&marketIds, &i);
7255 let mut marketId: Value = get_value(&marketIds, &i);
7256 let mut market: Value = self.safe_market(&[marketId.clone()]);
7257 let mut parsed: Value = <Self as crate::exchange_generated::ExchangeBase>::parse_ticker(self, get_value(&tickers, &marketId), &[market.clone()]);
7258 let mut ticker: Value = self.extend(parsed.clone(), &[params.clone()]);
7259 append_to_array(&mut results, ticker.clone());
7260 }
7261 }
7262 }
7263 symbols = self.market_symbols(&[symbols.clone()]);
7264 return self.filter_by_array(results.clone(), Value::Str("symbol".to_string()), &[symbols.clone()]);
7265
7266 Value::Null
7267}
7268
7269 fn parse_deposit_addresses(&self, mut addresses: Value, optional_args: &[Value]) -> Value {
7270 let mut codes = get_arg(optional_args, 0, Value::Null);
7271 let mut indexed = get_arg(optional_args, 1, Value::Bool(true));
7272 let mut params = get_arg(optional_args, 2, Value::Map({
7273 let mut m = indexmap::IndexMap::new();
7274 m
7275}));
7276 let mut result: Value = Value::List(vec![]);
7277 {
7278 let mut i: Value = Value::Int(0);
7279 let mut __for_first_145: bool = true;
7280 while { if !__for_first_145 { i = add(&i, &Value::Int(1)); } __for_first_145 = false; is_less_than(&i, &get_array_length(&addresses)) } {
7281 let mut address: Value = self.extend(<Self as crate::exchange_generated::ExchangeBase>::parse_deposit_address(self, get_value(&addresses, &i), &[]), &[params.clone()]);
7282 append_to_array(&mut result, address.clone());
7283 }
7284 }
7285 if !is_equal(&codes, &Value::Null) {
7286 result = self.filter_by_array(result.clone(), Value::Str("currency".to_string()), &[codes.clone(), Value::Bool(false)]);
7287 }
7288 if is_true(&indexed) {
7289 result = self.filter_by_array(result.clone(), Value::Str("currency".to_string()), &[Value::Null, indexed.clone()]);
7290 }
7291 return result;
7292
7293 Value::Null
7294}
7295
7296 fn parse_borrow_interests(&self, mut response: Value, optional_args: &[Value]) -> Value {
7297 let mut market = get_arg(optional_args, 0, Value::Null);
7298 let mut interests: Value = Value::List(vec![]);
7299 {
7300 let mut i: Value = Value::Int(0);
7301 let mut __for_first_146: bool = true;
7302 while { if !__for_first_146 { i = add(&i, &Value::Int(1)); } __for_first_146 = false; is_less_than(&i, &get_array_length(&response)) } {
7303 let mut row: Value = get_value(&response, &i);
7304 let mut row: Value = get_value(&response, &i);
7305 append_to_array(&mut interests, <Self as crate::exchange_generated::ExchangeBase>::parse_borrow_interest(self, row.clone(), &[market.clone()]));
7306 }
7307 }
7308 return interests;
7309
7310 Value::Null
7311}
7312
7313 fn parse_borrow_rate(&self, mut info: Value, optional_args: &[Value]) -> Value {
7314 { let __v = crate::exchange::DerivedExchange::parse_borrow_rate(self, info.clone(), crate::runtime::get_arg(optional_args, 0, crate::Value::Null)); if !matches!(__v, crate::Value::Null) { return __v; } }
7316
7317 let mut currency = get_arg(optional_args, 0, Value::Null);
7318 panic!("{}", crate::exchange_errors::not_supported(add(&self.id, &Value::Str(" parseBorrowRate() is not supported yet".to_string()))));
7319
7320 Value::Null
7321}
7322
7323 fn parse_borrow_rate_history(&self, mut response: Value, mut code: Value, mut since: Value, mut limit: Value) -> Value {
7324 let mut result: Value = Value::List(vec![]);
7325 {
7326 let mut i: Value = Value::Int(0);
7327 let mut __for_first_147: bool = true;
7328 while { if !__for_first_147 { i = add(&i, &Value::Int(1)); } __for_first_147 = false; is_less_than(&i, &get_array_length(&response)) } {
7329 let mut item: Value = get_value(&response, &i);
7330 let mut item: Value = get_value(&response, &i);
7331 let mut borrowRate: Value = <Self as crate::exchange_generated::ExchangeBase>::parse_borrow_rate(self, item.clone(), &[]);
7332 append_to_array(&mut result, borrowRate.clone());
7333 }
7334 }
7335 let mut sorted: Value = self.sort_by(result.clone(), Value::Str("timestamp".to_string()), &[]);
7336 return self.filter_by_currency_since_limit(sorted.clone(), &[code.clone(), since.clone(), limit.clone()]);
7337
7338 Value::Null
7339}
7340
7341 fn parse_isolated_borrow_rates(&self, mut info: Value) -> Value {
7342 let mut result: Value = Value::Map({
7343 let mut m = indexmap::IndexMap::new();
7344 m
7345 });
7346 {
7347 let mut i: Value = Value::Int(0);
7348 let mut __for_first_148: bool = true;
7349 while { if !__for_first_148 { i = add(&i, &Value::Int(1)); } __for_first_148 = false; is_less_than(&i, &get_array_length(&info)) } {
7350 let mut item: Value = get_value(&info, &i);
7351 let mut item: Value = get_value(&info, &i);
7352 let mut borrowRate: Value = self.parse_isolated_borrow_rate(item.clone(), &[]);
7353 let mut symbol: Value = self.safe_string_k(borrowRate.clone(), "symbol", &[]);
7354 add_element_to_object(&mut result, &symbol, borrowRate.clone());
7355 }
7356 }
7357 return result;
7358
7359 Value::Null
7360}
7361
7362 fn parse_funding_rate_histories(&self, mut response: Value, optional_args: &[Value]) -> Value {
7363 let mut market = get_arg(optional_args, 0, Value::Null);
7364 let mut since = get_arg(optional_args, 1, Value::Null);
7365 let mut limit = get_arg(optional_args, 2, Value::Null);
7366 let mut rates: Value = Value::List(vec![]);
7367 {
7368 let mut i: Value = Value::Int(0);
7369 let mut __for_first_149: bool = true;
7370 while { if !__for_first_149 { i = add(&i, &Value::Int(1)); } __for_first_149 = false; is_less_than(&i, &get_array_length(&response)) } {
7371 let mut entry: Value = get_value(&response, &i);
7372 let mut entry: Value = get_value(&response, &i);
7373 append_to_array(&mut rates, <Self as crate::exchange_generated::ExchangeBase>::parse_funding_rate_history(self, entry.clone(), &[market.clone()]));
7374 }
7375 }
7376 let mut sorted: Value = self.sort_by(rates.clone(), Value::Str("timestamp".to_string()), &[]);
7377 let mut symbol: Value = ternary(is_true(&(is_equal(&market, &Value::Null))), Value::Null, get_value(&market, &Value::Str("symbol".to_string())));
7378 return self.filter_by_symbol_since_limit(sorted.clone(), &[symbol.clone(), since.clone(), limit.clone()]);
7379
7380 Value::Null
7381}
7382
7383 fn safe_symbol(&self, mut marketId: Value, optional_args: &[Value]) -> Value {
7384 let mut market = get_arg(optional_args, 0, Value::Null);
7385 let mut delimiter = get_arg(optional_args, 1, Value::Null);
7386 let mut marketType = get_arg(optional_args, 2, Value::Null);
7387 market = self.safe_market(&[marketId.clone(), market.clone(), delimiter.clone(), marketType.clone()]);
7388 return get_value(&market, &Value::Str("symbol".to_string()));
7389
7390 Value::Null
7391}
7392
7393 fn parse_funding_rate(&self, mut contract: Value, optional_args: &[Value]) -> Value {
7394 { let __v = crate::exchange::DerivedExchange::parse_funding_rate(self, contract.clone(), crate::runtime::get_arg(optional_args, 0, crate::Value::Null)); if !matches!(__v, crate::Value::Null) { return __v; } }
7396
7397 let mut market = get_arg(optional_args, 0, Value::Null);
7398 panic!("{}", crate::exchange_errors::not_supported(add(&self.id, &Value::Str(" parseFundingRate() is not supported yet".to_string()))));
7399
7400 Value::Null
7401}
7402
7403 fn parse_funding_rates(&self, mut response: Value, optional_args: &[Value]) -> Value {
7404 let mut symbols = get_arg(optional_args, 0, Value::Null);
7405 let mut fundingRates: Value = Value::Map({
7406 let mut m = indexmap::IndexMap::new();
7407 m
7408 });
7409 {
7410 let mut i: Value = Value::Int(0);
7411 let mut __for_first_150: bool = true;
7412 while { if !__for_first_150 { i = add(&i, &Value::Int(1)); } __for_first_150 = false; is_less_than(&i, &get_array_length(&response)) } {
7413 let mut entry: Value = get_value(&response, &i);
7414 let mut entry: Value = get_value(&response, &i);
7415 let mut parsed: Value = <Self as crate::exchange_generated::ExchangeBase>::parse_funding_rate(self, entry.clone(), &[]);
7416 if !is_equal(&get_value(&parsed, &Value::Str("symbol".to_string())), &Value::Null) {
7417 add_element_to_object(&mut fundingRates, &get_value(&parsed, &Value::Str("symbol".to_string())), parsed.clone());
7418 }
7419 }
7420 }
7421 return self.filter_by_array(fundingRates.clone(), Value::Str("symbol".to_string()), &[symbols.clone()]);
7422
7423 Value::Null
7424}
7425
7426 fn parse_long_short_ratio(&self, mut info: Value, optional_args: &[Value]) -> Value {
7427 let mut market = get_arg(optional_args, 0, Value::Null);
7428 panic!("{}", crate::exchange_errors::not_supported(add(&self.id, &Value::Str(" parseLongShortRatio() is not supported yet".to_string()))));
7429
7430 Value::Null
7431}
7432
7433 fn parse_long_short_ratio_history(&self, mut response: Value, optional_args: &[Value]) -> Value {
7434 let mut market = get_arg(optional_args, 0, Value::Null);
7435 let mut since = get_arg(optional_args, 1, Value::Null);
7436 let mut limit = get_arg(optional_args, 2, Value::Null);
7437 let mut rates: Value = Value::List(vec![]);
7438 {
7439 let mut i: Value = Value::Int(0);
7440 let mut __for_first_151: bool = true;
7441 while { if !__for_first_151 { i = add(&i, &Value::Int(1)); } __for_first_151 = false; is_less_than(&i, &get_array_length(&response)) } {
7442 let mut entry: Value = get_value(&response, &i);
7443 let mut entry: Value = get_value(&response, &i);
7444 append_to_array(&mut rates, self.parse_long_short_ratio(entry.clone(), &[market.clone()]));
7445 }
7446 }
7447 let mut sorted: Value = self.sort_by(rates.clone(), Value::Str("timestamp".to_string()), &[]);
7448 let mut symbol: Value = ternary(is_true(&(is_equal(&market, &Value::Null))), Value::Null, get_value(&market, &Value::Str("symbol".to_string())));
7449 return self.filter_by_symbol_since_limit(sorted.clone(), &[symbol.clone(), since.clone(), limit.clone()]);
7450
7451 Value::Null
7452}
7453
7454 fn handle_trigger_prices_and_params(&self, mut symbol: Value, mut params: Value, optional_args: &[Value]) -> Value {
7455 let mut omitParams = get_arg(optional_args, 0, Value::Bool(true));
7456 let mut triggerPrice: Value = self.safe_string2(params.clone(), Value::Str("triggerPrice".to_string()), Value::Str("stopPrice".to_string()), &[]);
7458 let mut triggerPriceStr: Value = Value::Null;
7459 let mut stopLossPrice: Value = self.safe_string_k(params.clone(), "stopLossPrice", &[]);
7460 let mut stopLossPriceStr: Value = Value::Null;
7461 let mut takeProfitPrice: Value = self.safe_string_k(params.clone(), "takeProfitPrice", &[]);
7462 let mut takeProfitPriceStr: Value = Value::Null;
7463 if !is_equal(&triggerPrice, &Value::Null) {
7465 if is_true(&omitParams) {
7466 params = self.omit(params.clone(), Value::List(vec![Value::Str("triggerPrice".to_string()), Value::Str("stopPrice".to_string())]), &[]);
7467 }
7468 triggerPriceStr = self.price_to_precision(symbol.clone(), crate::runtime::parse_float(&triggerPrice));
7469 }
7470 if !is_equal(&stopLossPrice, &Value::Null) {
7471 if is_true(&omitParams) {
7472 params = self.omit(params.clone(), Value::Str("stopLossPrice".to_string()), &[]);
7473 }
7474 stopLossPriceStr = self.price_to_precision(symbol.clone(), crate::runtime::parse_float(&stopLossPrice));
7475 }
7476 if !is_equal(&takeProfitPrice, &Value::Null) {
7477 if is_true(&omitParams) {
7478 params = self.omit(params.clone(), Value::Str("takeProfitPrice".to_string()), &[]);
7479 }
7480 takeProfitPriceStr = self.price_to_precision(symbol.clone(), crate::runtime::parse_float(&takeProfitPrice));
7481 }
7482 return Value::List(vec![triggerPriceStr.clone(), stopLossPriceStr.clone(), takeProfitPriceStr.clone(), params.clone()]);
7483
7484 Value::Null
7485}
7486
7487 fn handle_trigger_direction_and_params(&self, mut params: Value, optional_args: &[Value]) -> Value {
7488 let mut exchangeSpecificKey = get_arg(optional_args, 0, Value::Null);
7489 let mut allowEmpty = get_arg(optional_args, 1, Value::Bool(false));
7490 let mut triggerDirection: Value = self.safe_string_k(params.clone(), "triggerDirection", &[]);
7496 let mut exchangeSpecificDefined: bool = is_true(&(!is_equal(&exchangeSpecificKey, &Value::Null))) && is_true(&(Value::Bool(in_op(¶ms, &exchangeSpecificKey))));
7497 if !is_equal(&triggerDirection, &Value::Null) {
7498 params = self.omit(params.clone(), Value::Str("triggerDirection".to_string()), &[]);
7499 }
7500 if !is_true(&self.in_array(triggerDirection.clone(), Value::List(vec![Value::Str("ascending".to_string()), Value::Str("descending".to_string()), Value::Str("up".to_string()), Value::Str("down".to_string()), Value::Str("above".to_string()), Value::Str("below".to_string())]))) && !is_true(&exchangeSpecificDefined) && !is_true(&allowEmpty) {
7504 panic!("{}", crate::exchange_errors::arguments_required(add(&self.id, &Value::Str(" createOrder() : trigger orders require params[\"triggerDirection\"] to be either \"ascending\" or \"descending\"".to_string()))));
7505 }
7506 if is_equal(&triggerDirection, &Value::Str("up".to_string())) || is_equal(&triggerDirection, &Value::Str("above".to_string())) {
7508 triggerDirection = Value::Str("ascending".to_string());
7509 } else if is_equal(&triggerDirection, &Value::Str("down".to_string())) || is_equal(&triggerDirection, &Value::Str("below".to_string())) {
7510 triggerDirection = Value::Str("descending".to_string());
7511 }
7512 return Value::List(vec![triggerDirection.clone(), params.clone()]);
7513
7514 Value::Null
7515}
7516
7517 fn handle_trigger_and_params(&self, mut params: Value) -> Value {
7518 let mut isTrigger: Value = self.safe_bool2(params.clone(), Value::Str("trigger".to_string()), Value::Str("stop".to_string()), &[]);
7519 if is_equal(&isTrigger, &Value::Bool(true)) {
7520 params = self.omit(params.clone(), Value::List(vec![Value::Str("trigger".to_string()), Value::Str("stop".to_string())]), &[]);
7521 }
7522 return Value::List(vec![isTrigger.clone(), params.clone()]);
7523
7524 Value::Null
7525}
7526
7527 fn is_trigger_order(&self, mut params: Value) -> Value {
7528 return self.handle_trigger_and_params(params.clone());
7529
7530 Value::Null
7531}
7532
7533 fn is_post_only(&self, mut isMarketOrder: Value, mut exchangeSpecificParam: Value, optional_args: &[Value]) -> Value {
7534 let mut params = get_arg(optional_args, 0, Value::Map({
7535 let mut m = indexmap::IndexMap::new();
7536 m
7537}));
7538 let mut timeInForce: Value = self.safe_string_upper(params.clone(), Value::Str("timeInForce".to_string()), &[]);
7547 let mut postOnly: Value = self.safe_bool2(params.clone(), Value::Str("postOnly".to_string()), Value::Str("post_only".to_string()), &[Value::Bool(false)]);
7548 let mut ioc: bool = is_equal(&timeInForce, &Value::Str("IOC".to_string()));
7550 let mut fok: bool = is_equal(&timeInForce, &Value::Str("FOK".to_string()));
7551 let mut timeInForcePostOnly: Value = Value::Bool(is_equal(&timeInForce, &Value::Str("PO".to_string())));
7552 if !is_equal(&postOnly, &Value::Bool(true)) {
7553 postOnly = timeInForcePostOnly.clone();
7554 }
7555 if !is_equal(&postOnly, &Value::Bool(true)) {
7556 postOnly = exchangeSpecificParam.clone();
7557 }
7558 if is_equal(&postOnly, &Value::Bool(true)) {
7559 if is_true(&ioc) || is_true(&fok) {
7560 panic!("{}", crate::exchange_errors::invalid_order(add(&add(&self.id, &Value::Str(" postOnly orders cannot have timeInForce equal to ".to_string())), &timeInForce)));
7561 } else if is_true(&isMarketOrder) {
7562 panic!("{}", crate::exchange_errors::invalid_order(add(&self.id, &Value::Str(" market orders cannot be postOnly".to_string()))));
7563 } else {
7564 return Value::Bool(true);
7565 }
7566 } else {
7567 return Value::Bool(false);
7568 }
7569
7570 Value::Null
7571}
7572
7573 fn handle_post_only(&self, mut isMarketOrder: Value, mut exchangeSpecificPostOnlyOption: Value, optional_args: &[Value]) -> Value {
7574 let mut params = get_arg(optional_args, 0, Value::Map({
7575 let mut m = indexmap::IndexMap::new();
7576 m
7577}));
7578 let mut timeInForce: Value = self.safe_string_upper(params.clone(), Value::Str("timeInForce".to_string()), &[]);
7587 let mut postOnly: Value = self.safe_bool_k(params.clone(), "postOnly", &[Value::Bool(false)]);
7588 let mut ioc: bool = is_equal(&timeInForce, &Value::Str("IOC".to_string()));
7589 let mut fok: bool = is_equal(&timeInForce, &Value::Str("FOK".to_string()));
7590 let mut po: Value = Value::Bool(is_equal(&timeInForce, &Value::Str("PO".to_string())));
7591 if !is_equal(&postOnly, &Value::Bool(true)) {
7592 postOnly = po.clone();
7593 }
7594 if !is_equal(&postOnly, &Value::Bool(true)) {
7595 postOnly = exchangeSpecificPostOnlyOption.clone();
7596 }
7597 if is_equal(&postOnly, &Value::Bool(true)) {
7598 if is_true(&ioc) || is_true(&fok) {
7599 panic!("{}", crate::exchange_errors::invalid_order(add(&add(&self.id, &Value::Str(" postOnly orders cannot have timeInForce equal to ".to_string())), &timeInForce)));
7600 } else if is_true(&isMarketOrder) {
7601 panic!("{}", crate::exchange_errors::invalid_order(add(&self.id, &Value::Str(" market orders cannot be postOnly".to_string()))));
7602 } else {
7603 if is_true(&po) {
7604 params = self.omit(params.clone(), Value::Str("timeInForce".to_string()), &[]);
7605 }
7606 params = self.omit(params.clone(), Value::Str("postOnly".to_string()), &[]);
7607 return Value::List(vec![Value::Bool(true), params.clone()]);
7608 }
7609 }
7610 return Value::List(vec![Value::Bool(false), params.clone()]);
7611
7612 Value::Null
7613}
7614
7615 fn fetch_last_prices(&mut self, optional_args: &[Value]) -> impl ::std::future::Future<Output = Value> + Send { async move {
7616 let mut symbols = get_arg(optional_args, 0, Value::Null);
7617 let mut params = get_arg(optional_args, 1, Value::Map({
7618 let mut m = indexmap::IndexMap::new();
7619 m
7620}));
7621 panic!("{}", crate::exchange_errors::not_supported(add(&self.id, &Value::Str(" fetchLastPrices() is not supported yet".to_string()))));
7622
7623 Value::Null
7624} }
7625
7626 fn fetch_trading_fees(&mut self, optional_args: &[Value]) -> impl ::std::future::Future<Output = Value> + Send { async move {
7627 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 {
7629 if !matches!(__v, crate::Value::Null) { return __v; }
7630 }
7631
7632 let mut params = get_arg(optional_args, 0, Value::Map({
7633 let mut m = indexmap::IndexMap::new();
7634 m
7635}));
7636 panic!("{}", crate::exchange_errors::not_supported(add(&self.id, &Value::Str(" fetchTradingFees() is not supported yet".to_string()))));
7637
7638 Value::Null
7639} }
7640
7641 fn fetch_trading_fees_ws(&mut self, optional_args: &[Value]) -> impl ::std::future::Future<Output = Value> + Send { async move {
7642 let mut params = get_arg(optional_args, 0, Value::Map({
7643 let mut m = indexmap::IndexMap::new();
7644 m
7645}));
7646 panic!("{}", crate::exchange_errors::not_supported(add(&self.id, &Value::Str(" fetchTradingFeesWs() is not supported yet".to_string()))));
7647
7648 Value::Null
7649} }
7650
7651 fn fetch_convert_currencies(&mut self, optional_args: &[Value]) -> impl ::std::future::Future<Output = Value> + Send { async move {
7652 let mut params = get_arg(optional_args, 0, Value::Map({
7653 let mut m = indexmap::IndexMap::new();
7654 m
7655}));
7656 panic!("{}", crate::exchange_errors::not_supported(add(&self.id, &Value::Str(" fetchConvertCurrencies() is not supported yet".to_string()))));
7657
7658 Value::Null
7659} }
7660
7661 fn parse_open_interest(&self, mut interest: Value, optional_args: &[Value]) -> Value {
7662 { let __v = crate::exchange::DerivedExchange::parse_open_interest(self, interest.clone(), crate::runtime::get_arg(optional_args, 0, crate::Value::Null)); if !matches!(__v, crate::Value::Null) { return __v; } }
7664
7665 let mut market = get_arg(optional_args, 0, Value::Null);
7666 panic!("{}", crate::exchange_errors::not_supported(add(&self.id, &Value::Str(" parseOpenInterest () is not supported yet".to_string()))));
7667
7668 Value::Null
7669}
7670
7671 fn parse_open_interests(&self, mut response: Value, optional_args: &[Value]) -> Value {
7672 let mut symbols = get_arg(optional_args, 0, Value::Null);
7673 let mut result: Value = Value::Map({
7674 let mut m = indexmap::IndexMap::new();
7675 m
7676 });
7677 {
7678 let mut i: Value = Value::Int(0);
7679 let mut __for_first_152: bool = true;
7680 while { if !__for_first_152 { i = add(&i, &Value::Int(1)); } __for_first_152 = false; is_less_than(&i, &get_array_length(&response)) } {
7681 let mut entry: Value = get_value(&response, &i);
7682 let mut entry: Value = get_value(&response, &i);
7683 let mut parsed: Value = <Self as crate::exchange_generated::ExchangeBase>::parse_open_interest(self, entry.clone(), &[]);
7684 if !is_equal(&get_value(&parsed, &Value::Str("symbol".to_string())), &Value::Null) {
7685 add_element_to_object(&mut result, &get_value(&parsed, &Value::Str("symbol".to_string())), parsed.clone());
7686 }
7687 }
7688 }
7689 return self.filter_by_array(result.clone(), Value::Str("symbol".to_string()), &[symbols.clone()]);
7690
7691 Value::Null
7692}
7693
7694 fn parse_open_interests_history(&self, mut response: Value, optional_args: &[Value]) -> Value {
7695 let mut market = get_arg(optional_args, 0, Value::Null);
7696 let mut since = get_arg(optional_args, 1, Value::Null);
7697 let mut limit = get_arg(optional_args, 2, Value::Null);
7698 let mut interests: Value = Value::List(vec![]);
7699 {
7700 let mut i: Value = Value::Int(0);
7701 let mut __for_first_153: bool = true;
7702 while { if !__for_first_153 { i = add(&i, &Value::Int(1)); } __for_first_153 = false; is_less_than(&i, &get_array_length(&response)) } {
7703 let mut entry: Value = get_value(&response, &i);
7704 let mut entry: Value = get_value(&response, &i);
7705 let mut interest: Value = <Self as crate::exchange_generated::ExchangeBase>::parse_open_interest(self, entry.clone(), &[market.clone()]);
7706 append_to_array(&mut interests, interest.clone());
7707 }
7708 }
7709 let mut sorted: Value = self.sort_by(interests.clone(), Value::Str("timestamp".to_string()), &[]);
7710 let mut symbol: Value = self.safe_string_k(market.clone(), "symbol", &[]);
7711 return self.filter_by_symbol_since_limit(sorted.clone(), &[symbol.clone(), since.clone(), limit.clone()]);
7712
7713 Value::Null
7714}
7715
7716 fn fetch_funding_rate(&mut self, mut symbol: Value, optional_args: &[Value]) -> impl ::std::future::Future<Output = Value> + Send { async move {
7717 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 {
7719 if !matches!(__v, crate::Value::Null) { return __v; }
7720 }
7721
7722 let mut params = get_arg(optional_args, 0, Value::Map({
7723 let mut m = indexmap::IndexMap::new();
7724 m
7725}));
7726 if !is_equal(&get_value(&self.has, &Value::Str("fetchFundingRates".to_string())), &Value::Null) && !is_equal(&get_value(&self.has, &Value::Str("fetchFundingRates".to_string())), &Value::Bool(false)) {
7727 self.load_markets(&[]).await;
7728 let mut market: Value = self.market(symbol.clone());
7729 symbol = get_value(&market, &Value::Str("symbol".to_string()));
7730 if !is_equal(&get_value(&market, &Value::Str("contract".to_string())), &Value::Bool(true)) {
7731 panic!("{}", crate::exchange_errors::bad_symbol(add(&self.id, &Value::Str(" fetchFundingRate() supports contract markets only".to_string()))));
7732 }
7733 let mut rates: Value = self.fetch_funding_rates(&[Value::List(vec![symbol.clone()]), params.clone()]).await;
7734 let mut rate: Value = self.safe_value(rates.clone(), symbol.clone(), &[]);
7735 if is_equal(&rate, &Value::Null) {
7736 panic!("{}", crate::exchange_errors::null_response(add(&add(&self.id, &Value::Str(" fetchFundingRate () returned no data for ".to_string())), &symbol)));
7737 } else {
7738 return rate;
7739 }
7740 } else {
7741 panic!("{}", crate::exchange_errors::not_supported(add(&self.id, &Value::Str(" fetchFundingRate () is not supported yet".to_string()))));
7742 }
7743
7744 Value::Null
7745} }
7746
7747 fn fetch_funding_interval(&mut self, mut symbol: Value, optional_args: &[Value]) -> impl ::std::future::Future<Output = Value> + Send { async move {
7748 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 {
7750 if !matches!(__v, crate::Value::Null) { return __v; }
7751 }
7752
7753 let mut params = get_arg(optional_args, 0, Value::Map({
7754 let mut m = indexmap::IndexMap::new();
7755 m
7756}));
7757 if !is_equal(&get_value(&self.has, &Value::Str("fetchFundingIntervals".to_string())), &Value::Null) && !is_equal(&get_value(&self.has, &Value::Str("fetchFundingIntervals".to_string())), &Value::Bool(false)) {
7758 self.load_markets(&[]).await;
7759 let mut market: Value = self.market(symbol.clone());
7760 symbol = get_value(&market, &Value::Str("symbol".to_string()));
7761 if !is_equal(&get_value(&market, &Value::Str("contract".to_string())), &Value::Bool(true)) {
7762 panic!("{}", crate::exchange_errors::bad_symbol(add(&self.id, &Value::Str(" fetchFundingInterval() supports contract markets only".to_string()))));
7763 }
7764 let mut rates: Value = self.fetch_funding_intervals(&[Value::List(vec![symbol.clone()]), params.clone()]).await;
7765 let mut rate: Value = self.safe_value(rates.clone(), symbol.clone(), &[]);
7766 if is_equal(&rate, &Value::Null) {
7767 panic!("{}", crate::exchange_errors::null_response(add(&add(&self.id, &Value::Str(" fetchFundingInterval() returned no data for ".to_string())), &symbol)));
7768 } else {
7769 return rate;
7770 }
7771 } else {
7772 panic!("{}", crate::exchange_errors::not_supported(add(&self.id, &Value::Str(" fetchFundingInterval() is not supported yet".to_string()))));
7773 }
7774
7775 Value::Null
7776} }
7777
7778 fn fetch_mark_ohlcv(&mut self, mut symbol: Value, optional_args: &[Value]) -> impl ::std::future::Future<Output = Value> + Send { async move {
7779 let mut timeframe = get_arg(optional_args, 0, Value::Str("1m".to_string()));
7780 let mut since = get_arg(optional_args, 1, Value::Null);
7781 let mut limit = get_arg(optional_args, 2, Value::Null);
7782 let mut params = get_arg(optional_args, 3, Value::Map({
7783 let mut m = indexmap::IndexMap::new();
7784 m
7785}));
7786 if !is_equal(&get_value(&self.has, &Value::Str("fetchMarkOHLCV".to_string())), &Value::Null) && !is_equal(&get_value(&self.has, &Value::Str("fetchMarkOHLCV".to_string())), &Value::Bool(false)) {
7798 let mut request: Value = Value::Map({
7799 let mut m = indexmap::IndexMap::new();
7800 m.insert("price".to_string(), Value::Str("mark".to_string()));
7801 m
7802 });
7803 return self.fetch_ohlcv(symbol.clone(), &[timeframe.clone(), since.clone(), limit.clone(), self.extend(request.clone(), &[params.clone()])]).await;
7804 } else {
7805 panic!("{}", crate::exchange_errors::not_supported(add(&self.id, &Value::Str(" fetchMarkOHLCV () is not supported yet".to_string()))));
7806 }
7807} }
7808
7809 fn fetch_index_ohlcv(&mut self, mut symbol: Value, optional_args: &[Value]) -> impl ::std::future::Future<Output = Value> + Send { async move {
7810 let mut timeframe = get_arg(optional_args, 0, Value::Str("1m".to_string()));
7811 let mut since = get_arg(optional_args, 1, Value::Null);
7812 let mut limit = get_arg(optional_args, 2, Value::Null);
7813 let mut params = get_arg(optional_args, 3, Value::Map({
7814 let mut m = indexmap::IndexMap::new();
7815 m
7816}));
7817 if !is_equal(&get_value(&self.has, &Value::Str("fetchIndexOHLCV".to_string())), &Value::Null) && !is_equal(&get_value(&self.has, &Value::Str("fetchIndexOHLCV".to_string())), &Value::Bool(false)) {
7829 let mut request: Value = Value::Map({
7830 let mut m = indexmap::IndexMap::new();
7831 m.insert("price".to_string(), Value::Str("index".to_string()));
7832 m
7833 });
7834 return self.fetch_ohlcv(symbol.clone(), &[timeframe.clone(), since.clone(), limit.clone(), self.extend(request.clone(), &[params.clone()])]).await;
7835 } else {
7836 panic!("{}", crate::exchange_errors::not_supported(add(&self.id, &Value::Str(" fetchIndexOHLCV () is not supported yet".to_string()))));
7837 }
7838} }
7839
7840 fn fetch_premium_index_ohlcv(&mut self, mut symbol: Value, optional_args: &[Value]) -> impl ::std::future::Future<Output = Value> + Send { async move {
7841 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 {
7843 if !matches!(__v, crate::Value::Null) { return __v; }
7844 }
7845
7846 let mut timeframe = get_arg(optional_args, 0, Value::Str("1m".to_string()));
7847 let mut since = get_arg(optional_args, 1, Value::Null);
7848 let mut limit = get_arg(optional_args, 2, Value::Null);
7849 let mut params = get_arg(optional_args, 3, Value::Map({
7850 let mut m = indexmap::IndexMap::new();
7851 m
7852}));
7853 if !is_equal(&get_value(&self.has, &Value::Str("fetchPremiumIndexOHLCV".to_string())), &Value::Null) && !is_equal(&get_value(&self.has, &Value::Str("fetchPremiumIndexOHLCV".to_string())), &Value::Bool(false)) {
7865 let mut request: Value = Value::Map({
7866 let mut m = indexmap::IndexMap::new();
7867 m.insert("price".to_string(), Value::Str("premiumIndex".to_string()));
7868 m
7869 });
7870 return self.fetch_ohlcv(symbol.clone(), &[timeframe.clone(), since.clone(), limit.clone(), self.extend(request.clone(), &[params.clone()])]).await;
7871 } else {
7872 panic!("{}", crate::exchange_errors::not_supported(add(&self.id, &Value::Str(" fetchPremiumIndexOHLCV () is not supported yet".to_string()))));
7873 }
7874} }
7875
7876 fn handle_time_in_force(&self, optional_args: &[Value]) -> Value {
7877 let mut params = get_arg(optional_args, 0, Value::Map({
7878 let mut m = indexmap::IndexMap::new();
7879 m
7880}));
7881 let mut timeInForce: Value = self.safe_string_upper(params.clone(), Value::Str("timeInForce".to_string()), &[]); if !is_equal(&timeInForce, &Value::Null) {
7889 let mut exchangeValue: Value = self.safe_string(get_value(&self.options, &Value::Str("timeInForce".to_string())), timeInForce.clone(), &[]);
7890 if is_equal(&exchangeValue, &Value::Null) {
7891 panic!("{}", crate::exchange_errors::exchange_error(add(&add(&add(&self.id, &Value::Str(" does not support timeInForce \"".to_string())), &timeInForce), &Value::Str("\"".to_string()))));
7892 }
7893 return exchangeValue;
7894 }
7895 return Value::Null;
7896
7897 Value::Null
7898}
7899
7900 fn convert_type_to_account(&self, mut account: Value) -> Value {
7901 let mut accountsByType: Value = self.safe_dict_k(self.options.clone(), "accountsByType", &[Value::Map({
7909 let mut m = indexmap::IndexMap::new();
7910 m
7911})]);
7912 let mut lowercaseAccount: Value = to_lower(&account);
7913 if is_true(&Value::Bool(in_op(&accountsByType, &lowercaseAccount))) {
7914 return get_value(&accountsByType, &lowercaseAccount);
7915 }
7916 let mut markets: Value = self.markets.clone();
7917 let mut marketsById: Value = self.markets_by_id.clone();
7918 if is_true(&(is_true(&(!is_equal(&markets, &Value::Null))) && is_true(&(Value::Bool(in_op(&markets, &account)))))) || is_true(&(is_true(&(!is_equal(&marketsById, &Value::Null))) && is_true(&(Value::Bool(in_op(&marketsById, &account)))))) {
7919 let mut market: Value = self.market(account.clone());
7920 return get_value(&market, &Value::Str("id".to_string()));
7921 } else {
7922 return account;
7923 }
7924
7925 Value::Null
7926}
7927
7928 fn check_required_argument(&self, mut methodName: Value, mut argument: Value, mut argumentName: Value, optional_args: &[Value]) {
7929 let mut options = get_arg(optional_args, 0, Value::List(vec![]));
7930 let mut optionsLength: Value = get_array_length(&options);
7940 if is_true(&(is_equal(&argument, &Value::Null))) || is_true(&(is_true(&(is_greater_than(&optionsLength, &Value::Int(0)))) && is_true(&(!is_true(&(self.in_array(argument.clone(), options.clone()))))))) {
7941 let mut messageOptions: Value = join(&options, &Value::Str(", ".to_string()));
7942 let mut message: Value = add(&add(&add(&add(&add(&self.id, &Value::Str(" ".to_string())), &methodName), &Value::Str("() requires a ".to_string())), &argumentName), &Value::Str(" argument".to_string()));
7943 if !is_equal(&messageOptions, &Value::Str("".to_string())) {
7944 message = add(&message, &add(&add(&add(&Value::Str(", one of ".to_string()), &Value::Str("(".to_string())), &messageOptions), &Value::Str(")".to_string())));
7945 }
7946 panic!("{}", crate::exchange_errors::arguments_required(message));
7947 }
7948}
7949
7950 fn check_required_margin_argument(&self, mut methodName: Value, mut symbol: Value, mut marginMode: Value) {
7951 if is_true(&(is_equal(&marginMode, &Value::Str("isolated".to_string())))) && is_true(&(is_equal(&symbol, &Value::Null))) {
7959 panic!("{}", crate::exchange_errors::arguments_required(add(&add(&add(&self.id, &Value::Str(" ".to_string())), &methodName), &Value::Str("() requires a symbol argument for isolated margin".to_string()))));
7960 } else if is_true(&(is_equal(&marginMode, &Value::Str("cross".to_string())))) && is_true(&(!is_equal(&symbol, &Value::Null))) {
7961 panic!("{}", crate::exchange_errors::arguments_required(add(&add(&add(&self.id, &Value::Str(" ".to_string())), &methodName), &Value::Str("() cannot have a symbol argument for cross margin".to_string()))));
7962 }
7963}
7964
7965 fn parse_deposit_withdraw_fees(&self, mut response: Value, optional_args: &[Value]) -> Value {
7966 let mut codes = get_arg(optional_args, 0, Value::Null);
7967 let mut currencyIdKey = get_arg(optional_args, 1, Value::Null);
7968 let mut depositWithdrawFees: Value = Value::Map({
7977 let mut m = indexmap::IndexMap::new();
7978 m
7979 });
7980 let mut isArray: bool = is_array(&response);
7981 let mut responseKeys: Value = response.clone();
7982 if !is_true(&isArray) {
7983 responseKeys = object_keys(&response);
7984 }
7985 {
7986 let mut i: Value = Value::Int(0);
7987 let mut __for_first_154: bool = true;
7988 while { if !__for_first_154 { i = add(&i, &Value::Int(1)); } __for_first_154 = false; is_less_than(&i, &get_array_length(&responseKeys)) } {
7989 let mut entry: Value = get_value(&responseKeys, &i);
7990 let mut entry: Value = get_value(&responseKeys, &i);
7991 let mut dictionary: Value = ternary(is_true(&isArray), entry.clone(), get_value(&response, &entry));
7992 let mut currencyId: Value = entry.clone();
7993 if is_true(&isArray) {
7994 currencyId = ternary(is_true(&(is_equal(¤cyIdKey, &Value::Null))), Value::Null, self.safe_string(dictionary.clone(), currencyIdKey.clone(), &[]));
7995 }
7996 let mut currency: Value = self.safe_currency(currencyId.clone(), &[]);
7997 let mut code: Value = self.safe_string_k(currency.clone(), "code", &[]);
7998 if is_true(&(is_equal(&codes, &Value::Null))) || is_true(&(self.in_array(code.clone(), codes.clone()))) {
7999 add_element_to_object(&mut depositWithdrawFees, &code, <Self as crate::exchange_generated::ExchangeBase>::parse_deposit_withdraw_fee(self, dictionary.clone(), &[currency.clone()]));
8000 }
8001 }
8002 }
8003 return depositWithdrawFees;
8004
8005 Value::Null
8006}
8007
8008 fn parse_deposit_withdraw_fee(&self, mut fee: Value, optional_args: &[Value]) -> Value {
8009 { let __v = crate::exchange::DerivedExchange::parse_deposit_withdraw_fee(self, fee.clone(), crate::runtime::get_arg(optional_args, 0, crate::Value::Null)); if !matches!(__v, crate::Value::Null) { return __v; } }
8011
8012 let mut currency = get_arg(optional_args, 0, Value::Null);
8013 panic!("{}", crate::exchange_errors::not_supported(add(&self.id, &Value::Str(" parseDepositWithdrawFee() is not supported yet".to_string()))));
8014
8015 Value::Null
8016}
8017
8018 fn deposit_withdraw_fee(&self, mut info: Value) -> Value {
8019 return Value::Map({
8020 let mut m = indexmap::IndexMap::new();
8021 m.insert("info".to_string(), info.clone());
8022 m.insert("withdraw".to_string(), Value::Map({
8023 let mut m = indexmap::IndexMap::new();
8024 m.insert("fee".to_string(), Value::Null);
8025 m.insert("percentage".to_string(), Value::Null);
8026 m
8027}));
8028 m.insert("deposit".to_string(), Value::Map({
8029 let mut m = indexmap::IndexMap::new();
8030 m.insert("fee".to_string(), Value::Null);
8031 m.insert("percentage".to_string(), Value::Null);
8032 m
8033}));
8034 m.insert("networks".to_string(), Value::Map({
8035 let mut m = indexmap::IndexMap::new();
8036 m
8037}));
8038 m
8039});
8040
8041 Value::Null
8042}
8043
8044 fn assign_default_deposit_withdraw_fees(&self, mut fee: Value, optional_args: &[Value]) -> Value {
8045 let mut currency = get_arg(optional_args, 0, Value::Null);
8046 let mut networkKeys: Value = object_keys(&get_value(&fee, &Value::Str("networks".to_string())));
8055 let mut numNetworks: Value = get_array_length(&networkKeys);
8056 if is_equal(&numNetworks, &Value::Int(1)) {
8057 { let __be_tmp = get_value(&get_value(&get_value(&fee, &Value::Str("networks".to_string())), &get_value(&networkKeys, &Value::Int(0))), &Value::Str("withdraw".to_string())); add_element_to_object(&mut fee, &Value::Str("withdraw".to_string()), __be_tmp); };
8058 { let __be_tmp = get_value(&get_value(&get_value(&fee, &Value::Str("networks".to_string())), &get_value(&networkKeys, &Value::Int(0))), &Value::Str("deposit".to_string())); add_element_to_object(&mut fee, &Value::Str("deposit".to_string()), __be_tmp); };
8059 return fee;
8060 }
8061 let mut currencyCode: Value = self.safe_string_k(currency.clone(), "code", &[]);
8062 {
8063 let mut i: Value = Value::Int(0);
8064 let mut __for_first_155: bool = true;
8065 while { if !__for_first_155 { i = add(&i, &Value::Int(1)); } __for_first_155 = false; is_less_than(&i, &numNetworks) } {
8066 let mut network: Value = get_value(&networkKeys, &i);
8067 let mut network: Value = get_value(&networkKeys, &i);
8068 if is_equal(&network, ¤cyCode) {
8069 { let __be_tmp = get_value(&get_value(&get_value(&fee, &Value::Str("networks".to_string())), &get_value(&networkKeys, &i)), &Value::Str("withdraw".to_string())); add_element_to_object(&mut fee, &Value::Str("withdraw".to_string()), __be_tmp); };
8070 { let __be_tmp = get_value(&get_value(&get_value(&fee, &Value::Str("networks".to_string())), &get_value(&networkKeys, &i)), &Value::Str("deposit".to_string())); add_element_to_object(&mut fee, &Value::Str("deposit".to_string()), __be_tmp); };
8071 }
8072 }
8073 }
8074 return fee;
8075
8076 Value::Null
8077}
8078
8079 fn parse_income(&self, mut info: Value, optional_args: &[Value]) -> Value {
8080 { let __v = crate::exchange::DerivedExchange::parse_income(self, info.clone(), crate::runtime::get_arg(optional_args, 0, crate::Value::Null)); if !matches!(__v, crate::Value::Null) { return __v; } }
8082
8083 let mut market = get_arg(optional_args, 0, Value::Null);
8084 panic!("{}", crate::exchange_errors::not_supported(add(&self.id, &Value::Str(" parseIncome () is not supported yet".to_string()))));
8085
8086 Value::Null
8087}
8088
8089 fn parse_incomes(&self, mut incomes: Value, optional_args: &[Value]) -> Value {
8090 let mut market = get_arg(optional_args, 0, Value::Null);
8091 let mut since = get_arg(optional_args, 1, Value::Null);
8092 let mut limit = get_arg(optional_args, 2, Value::Null);
8093 let mut result: Value = Value::List(vec![]);
8104 {
8105 let mut i: Value = Value::Int(0);
8106 let mut __for_first_156: bool = true;
8107 while { if !__for_first_156 { i = add(&i, &Value::Int(1)); } __for_first_156 = false; is_less_than(&i, &get_array_length(&incomes)) } {
8108 let mut entry: Value = get_value(&incomes, &i);
8109 let mut entry: Value = get_value(&incomes, &i);
8110 let mut parsed: Value = <Self as crate::exchange_generated::ExchangeBase>::parse_income(self, entry.clone(), &[market.clone()]);
8111 append_to_array(&mut result, parsed.clone());
8112 }
8113 }
8114 let mut sorted: Value = self.sort_by(result.clone(), Value::Str("timestamp".to_string()), &[]);
8115 let mut symbol: Value = self.safe_string_k(market.clone(), "symbol", &[]);
8116 return self.filter_by_symbol_since_limit(sorted.clone(), &[symbol.clone(), since.clone(), limit.clone()]);
8117
8118 Value::Null
8119}
8120
8121 fn get_market_from_symbols(&self, optional_args: &[Value]) -> Value {
8122 let mut symbols = get_arg(optional_args, 0, Value::Null);
8123 if is_equal(&symbols, &Value::Null) {
8129 return Value::Null;
8130 }
8131 let mut firstMarket: Value = self.safe_string(symbols.clone(), Value::Int(0), &[]);
8132 if is_equal(&firstMarket, &Value::Null) {
8133 return Value::Null;
8134 }
8135 let mut market: Value = self.market(firstMarket.clone());
8136 return market;
8137
8138 Value::Null
8139}
8140
8141 fn parse_ws_ohlc_vs(&self, mut ohlcvs: Value, optional_args: &[Value]) -> Value {
8142 let mut market = get_arg(optional_args, 0, Value::Null);
8143 let mut timeframe = get_arg(optional_args, 1, Value::Str("1m".to_string()));
8144 let mut since = get_arg(optional_args, 2, Value::Null);
8145 let mut limit = get_arg(optional_args, 3, Value::Null);
8146 let mut results: Value = Value::List(vec![]);
8147 {
8148 let mut i: Value = Value::Int(0);
8149 let mut __for_first_157: bool = true;
8150 while { if !__for_first_157 { i = add(&i, &Value::Int(1)); } __for_first_157 = false; is_less_than(&i, &get_array_length(&ohlcvs)) } {
8151 append_to_array(&mut results, self.parse_ws_ohlcv(get_value(&ohlcvs, &i), &[market.clone()]));
8152 }
8153 }
8154 return results;
8155
8156 Value::Null
8157}
8158
8159 fn fetch_transactions(&mut self, optional_args: &[Value]) -> impl ::std::future::Future<Output = Value> + Send { async move {
8160 let mut code = get_arg(optional_args, 0, Value::Null);
8161 let mut since = get_arg(optional_args, 1, Value::Null);
8162 let mut limit = get_arg(optional_args, 2, Value::Null);
8163 let mut params = get_arg(optional_args, 3, Value::Map({
8164 let mut m = indexmap::IndexMap::new();
8165 m
8166}));
8167 if !is_equal(&get_value(&self.has, &Value::Str("fetchDepositsWithdrawals".to_string())), &Value::Null) && !is_equal(&get_value(&self.has, &Value::Str("fetchDepositsWithdrawals".to_string())), &Value::Bool(false)) {
8179 return self.fetch_deposits_withdrawals(&[code.clone(), since.clone(), limit.clone(), params.clone()]).await;
8180 } else {
8181 panic!("{}", crate::exchange_errors::not_supported(add(&self.id, &Value::Str(" fetchTransactions () is not supported yet".to_string()))));
8182 }
8183} }
8184
8185 fn filter_by_array_positions(&self, mut objects: Value, mut key: Value, optional_args: &[Value]) -> Value {
8186 let mut values = get_arg(optional_args, 0, Value::Null);
8187 let mut indexed = get_arg(optional_args, 1, Value::Bool(true));
8188 return self.filter_by_array(objects.clone(), key.clone(), &[values.clone(), indexed.clone()]);
8189
8190 Value::Null
8191}
8192
8193 fn filter_by_array_tickers(&self, mut objects: Value, mut key: Value, optional_args: &[Value]) -> Value {
8194 let mut values = get_arg(optional_args, 0, Value::Null);
8195 let mut indexed = get_arg(optional_args, 1, Value::Bool(true));
8196 return self.filter_by_array(objects.clone(), key.clone(), &[values.clone(), indexed.clone()]);
8197
8198 Value::Null
8199}
8200
8201 fn filter_by_array_adl_ranks(&self, mut objects: Value, mut key: Value, optional_args: &[Value]) -> Value {
8202 let mut values = get_arg(optional_args, 0, Value::Null);
8203 let mut indexed = get_arg(optional_args, 1, Value::Bool(true));
8204 return self.filter_by_array(objects.clone(), key.clone(), &[values.clone(), indexed.clone()]);
8205
8206 Value::Null
8207}
8208
8209 fn create_ohlcv_object(&self, mut symbol: Value, mut timeframe: Value, mut data: Value) -> Value {
8210 let mut res: Value = Value::Map({
8211 let mut m = indexmap::IndexMap::new();
8212 m
8213 });
8214 add_element_to_object(&mut res, &symbol, Value::Map({
8215 let mut m = indexmap::IndexMap::new();
8216 m
8217}));
8218 add_element_to_object(get_value_mut(&mut res, &symbol), &timeframe, data.clone());
8219 return res;
8220
8221 Value::Null
8222}
8223
8224 fn handle_max_entries_per_request_and_params(&self, mut method: Value, optional_args: &[Value]) -> Value {
8225 let mut maxEntriesPerRequest = get_arg(optional_args, 0, Value::Null);
8226 let mut params = get_arg(optional_args, 1, Value::Map({
8227 let mut m = indexmap::IndexMap::new();
8228 m
8229}));
8230 let mut newMaxEntriesPerRequest: Value = Value::Null;
8231 { let __destr_tmp = self.handle_option_and_params(params.clone(), method.clone(), Value::Str("maxEntriesPerRequest".to_string()), &[]); newMaxEntriesPerRequest = get_value(&__destr_tmp, &Value::Int(0)); params = get_value(&__destr_tmp, &Value::Int(1)); }
8232 if is_true(&(!is_equal(&newMaxEntriesPerRequest, &Value::Null))) && is_true(&(!is_equal(&newMaxEntriesPerRequest, &maxEntriesPerRequest))) {
8233 maxEntriesPerRequest = newMaxEntriesPerRequest.clone();
8234 }
8235 if is_equal(&maxEntriesPerRequest, &Value::Null) {
8236 maxEntriesPerRequest = Value::Int(1000); }
8238 return Value::List(vec![maxEntriesPerRequest.clone(), params.clone()]);
8239
8240 Value::Null
8241}
8242
8243 fn fetch_paginated_call_dynamic(&mut self, mut method: Value, optional_args: &[Value]) -> impl ::std::future::Future<Output = Value> + Send { async move {
8244 let mut symbol = get_arg(optional_args, 0, Value::Null);
8245 let mut since = get_arg(optional_args, 1, Value::Null);
8246 let mut limit = get_arg(optional_args, 2, Value::Null);
8247 let mut params = get_arg(optional_args, 3, Value::Map({
8248 let mut m = indexmap::IndexMap::new();
8249 m
8250}));
8251 let mut maxEntriesPerRequest = get_arg(optional_args, 4, Value::Null);
8252 let mut removeRepeated = get_arg(optional_args, 5, Value::Bool(true));
8253 let mut maxCalls: Value = Value::Int(10);
8254 { let __destr_tmp = self.handle_option_and_params(params.clone(), method.clone(), Value::Str("paginationCalls".to_string()), &[maxCalls.clone()]); maxCalls = get_value(&__destr_tmp, &Value::Int(0)); params = get_value(&__destr_tmp, &Value::Int(1)); }
8255 let mut maxRetries: Value = Value::Int(3);
8256 { let __destr_tmp = self.handle_option_and_params(params.clone(), method.clone(), Value::Str("maxRetries".to_string()), &[maxRetries.clone()]); maxRetries = get_value(&__destr_tmp, &Value::Int(0)); params = get_value(&__destr_tmp, &Value::Int(1)); }
8257 let mut paginationDirection: Value = Value::Null;
8258 { let __destr_tmp = self.handle_option_and_params(params.clone(), method.clone(), Value::Str("paginationDirection".to_string()), &[Value::Str("backward".to_string())]); paginationDirection = get_value(&__destr_tmp, &Value::Int(0)); params = get_value(&__destr_tmp, &Value::Int(1)); }
8259 let mut paginationTimestamp: Value = Value::Null;
8260 let mut removeRepeatedOption: Value = removeRepeated.clone();
8261 { let __destr_tmp = self.handle_option_and_params(params.clone(), method.clone(), Value::Str("removeRepeated".to_string()), &[removeRepeated.clone()]); removeRepeatedOption = get_value(&__destr_tmp, &Value::Int(0)); params = get_value(&__destr_tmp, &Value::Int(1)); }
8262 let mut calls: Value = Value::Int(0);
8263 let mut result: Value = Value::List(vec![]);
8264 let mut errors: Value = Value::Int(0);
8265 let mut until: Value = self.safe_integer_n(params.clone(), Value::List(vec![Value::Str("until".to_string()), Value::Str("untill".to_string()), Value::Str("till".to_string())]), &[]); { let __destr_tmp = self.handle_max_entries_per_request_and_params(method.clone(), &[maxEntriesPerRequest.clone(), params.clone()]); maxEntriesPerRequest = get_value(&__destr_tmp, &Value::Int(0)); params = get_value(&__destr_tmp, &Value::Int(1)); }
8267 if is_true(&(is_equal(&paginationDirection, &Value::Str("forward".to_string())))) {
8268 if is_equal(&since, &Value::Null) {
8269 panic!("{}", crate::exchange_errors::arguments_required(add(&self.id, &Value::Str(" pagination requires a since argument when paginationDirection set to forward".to_string()))));
8270 }
8271 paginationTimestamp = since.clone();
8272 }
8273 while is_true(&(is_less_than(&calls, &maxCalls))) {
8274 calls = add(&calls, &Value::Int(1));
8275 {
8276 if is_equal(&paginationDirection, &Value::Str("backward".to_string())) {
8277 if !is_equal(&paginationTimestamp, &Value::Null) {
8280 add_element_to_object(&mut params, &Value::Str("until".to_string()), subtract(&paginationTimestamp, &Value::Int(1)));
8281 }
8282 let mut response: Value = self.call_method(method.clone(), &[symbol.clone(), Value::Null, maxEntriesPerRequest.clone(), params.clone()]).await;
8283 let mut responseLength: Value = get_array_length(&response);
8284 if is_true(&self.verbose) {
8285 let mut backwardMessage: Value = add(&add(&add(&add(&add(&Value::Str("Dynamic pagination call ".to_string()), &self.number_to_string(calls.clone())), &Value::Str(" method ".to_string())), &method), &Value::Str(" response length ".to_string())), &self.number_to_string(responseLength.clone()));
8286 if !is_equal(&paginationTimestamp, &Value::Null) {
8287 backwardMessage = add(&backwardMessage, &add(&Value::Str(" timestamp ".to_string()), &self.number_to_string(paginationTimestamp.clone())));
8288 }
8289 self.log(backwardMessage.clone());
8290 }
8291 if is_equal(&responseLength, &Value::Int(0)) {
8292 break;
8293 }
8294 errors = Value::Int(0);
8295 result = self.array_concat(result.clone(), response.clone());
8296 let mut firstElement: Value = self.safe_value(response.clone(), Value::Int(0), &[]);
8297 paginationTimestamp = self.safe_integer2(firstElement.clone(), Value::Str("timestamp".to_string()), Value::Int(0), &[]);
8298 if is_equal(&paginationTimestamp, &Value::Null) {
8299 break;
8300 }
8301 if is_true(&(!is_equal(&since, &Value::Null))) && is_true(&(is_less_than_or_equal(&paginationTimestamp, &since))) {
8302 break;
8303 }
8304 } else {
8305 let mut response: Value = self.call_method(method.clone(), &[symbol.clone(), paginationTimestamp.clone(), maxEntriesPerRequest.clone(), params.clone()]).await;
8307 let mut responseLength: Value = get_array_length(&response);
8308 if is_true(&self.verbose) {
8309 let mut forwardMessage: Value = add(&add(&add(&add(&add(&Value::Str("Dynamic pagination call ".to_string()), &self.number_to_string(calls.clone())), &Value::Str(" method ".to_string())), &method), &Value::Str(" response length ".to_string())), &self.number_to_string(responseLength.clone()));
8310 if !is_equal(&paginationTimestamp, &Value::Null) {
8311 forwardMessage = add(&forwardMessage, &add(&Value::Str(" timestamp ".to_string()), &self.number_to_string(paginationTimestamp.clone())));
8312 }
8313 self.log(forwardMessage.clone());
8314 }
8315 if is_equal(&responseLength, &Value::Int(0)) {
8316 break;
8317 }
8318 errors = Value::Int(0);
8319 result = self.array_concat(result.clone(), response.clone());
8320 let mut last: Value = self.safe_value(response.clone(), subtract(&responseLength, &Value::Int(1)), &[]);
8321 let mut lastTimestamp: Value = self.safe_integer_k(last.clone(), "timestamp", &[Value::Int(0)]);
8322 if is_equal(&lastTimestamp, &Value::Null) {
8323 break;
8324 }
8325 let mut nextPaginationTimestamp: Value = add(&lastTimestamp, &Value::Int(1));
8326 paginationTimestamp = nextPaginationTimestamp.clone();
8327 if is_true(&(!is_equal(&until, &Value::Null))) && is_true(&(is_greater_than_or_equal(&nextPaginationTimestamp, &until))) {
8328 break;
8329 }
8330 }
8331 }
8332 }
8333 let mut uniqueResults: Value = result.clone();
8334 if is_true(&removeRepeatedOption) {
8335 uniqueResults = self.remove_repeated_elements_from_array(result.clone(), &[]);
8336 }
8337 let mut key: Value = ternary(is_true(&(is_equal(&method, &Value::Str("fetchOHLCV".to_string())))), Value::Int(0), Value::Str("timestamp".to_string()));
8338 let mut sortedRes: Value = self.sort_by(uniqueResults.clone(), key.clone(), &[]);
8339 return self.filter_by_since_limit(sortedRes.clone(), &[since.clone(), limit.clone(), key.clone()]);
8340
8341 Value::Null
8342} }
8343
8344 fn safe_deterministic_call(&mut self, mut method: Value, optional_args: &[Value]) -> impl ::std::future::Future<Output = Value> + Send { async move {
8345 let mut symbol = get_arg(optional_args, 0, Value::Null);
8346 let mut since = get_arg(optional_args, 1, Value::Null);
8347 let mut limit = get_arg(optional_args, 2, Value::Null);
8348 let mut timeframe = get_arg(optional_args, 3, Value::Null);
8349 let mut params = get_arg(optional_args, 4, Value::Map({
8350 let mut m = indexmap::IndexMap::new();
8351 m
8352}));
8353 let mut maxRetries: Value = Value::Int(3);
8354 { let __destr_tmp = self.handle_option_and_params(params.clone(), method.clone(), Value::Str("maxRetries".to_string()), &[maxRetries.clone()]); maxRetries = get_value(&__destr_tmp, &Value::Int(0)); params = get_value(&__destr_tmp, &Value::Int(1)); }
8355 let mut errors: Value = Value::Int(0);
8356 while is_less_than_or_equal(&errors, &maxRetries) {
8357 let _try_result = futures::FutureExt::catch_unwind(std::panic::AssertUnwindSafe(async {
8358 if is_true(&(!is_equal(&timeframe, &Value::Null) && !is_equal(&timeframe, &Value::Str("".to_string())))) && !is_equal(&method, &Value::Str("fetchFundingRateHistory".to_string())) {
8359 return self.call_method(method.clone(), &[symbol.clone(), timeframe.clone(), since.clone(), limit.clone(), params.clone()]).await;
8360 } else {
8361 return self.call_method(method.clone(), &[symbol.clone(), since.clone(), limit.clone(), params.clone()]).await;
8362 }
8363 #[allow(unreachable_code)] { Value::Null }})).await;
8364match _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);
8365 if is_true(&is_instance(&e, &Value::Str("RateLimitExceeded".to_string()))) {
8366 panic!("{}", e);
8367 }
8368 errors = add(&errors, &Value::Int(1));
8369 if is_greater_than(&errors, &maxRetries) {
8370 panic!("{}", e);
8371 }
8372 } }
8373 }
8374 return Value::List(vec![]);
8375
8376 Value::Null
8377} }
8378
8379 fn fetch_paginated_call_deterministic(&mut self, mut method: Value, optional_args: &[Value]) -> impl ::std::future::Future<Output = Value> + Send { async move {
8380 let mut symbol = get_arg(optional_args, 0, Value::Null);
8381 let mut since = get_arg(optional_args, 1, Value::Null);
8382 let mut limit = get_arg(optional_args, 2, Value::Null);
8383 let mut timeframe = get_arg(optional_args, 3, Value::Null);
8384 let mut params = get_arg(optional_args, 4, Value::Map({
8385 let mut m = indexmap::IndexMap::new();
8386 m
8387}));
8388 let mut maxEntriesPerRequest = get_arg(optional_args, 5, Value::Null);
8389 let mut maxCalls: Value = Value::Int(10);
8390 { let __destr_tmp = self.handle_option_and_params(params.clone(), method.clone(), Value::Str("paginationCalls".to_string()), &[maxCalls.clone()]); maxCalls = get_value(&__destr_tmp, &Value::Int(0)); params = get_value(&__destr_tmp, &Value::Int(1)); }
8391 { let __destr_tmp = self.handle_max_entries_per_request_and_params(method.clone(), &[maxEntriesPerRequest.clone(), params.clone()]); maxEntriesPerRequest = get_value(&__destr_tmp, &Value::Int(0)); params = get_value(&__destr_tmp, &Value::Int(1)); }
8392 params = self.omit(params.clone(), Value::Str("paginationDirection".to_string()), &[]);
8396 let mut current: Value = self.milliseconds();
8397 let mut tasks: Value = Value::List(vec![]);
8398 let mut time: Value = multiply(&self.parse_timeframe(timeframe.clone()), &Value::Int(1000));
8399 maxEntriesPerRequest = self.require_value(maxEntriesPerRequest.clone(), &[Value::Str("fetchPaginatedCallDeterministic() maxEntriesPerRequest is required".to_string())]);
8400 let mut step: Value = multiply(&time, &maxEntriesPerRequest);
8401 let mut until: Value = self.safe_integer2(params.clone(), Value::Str("until".to_string()), Value::Str("till".to_string()), &[]); let mut currentSince: Value = subtract(&subtract(¤t, &(multiply(&maxCalls, &step))), &Value::Int(1));
8403 if !is_equal(&since, &Value::Null) {
8404 if !is_equal(&until, &Value::Null) {
8405 currentSince = since.clone();
8410 } else {
8411 currentSince = crate::runtime::Math::max(¤tSince, &since);
8412 }
8413 } else {
8414 currentSince = crate::runtime::Math::max(¤tSince, &Value::Int(1241440531000)); }
8416 if !is_equal(&until, &Value::Null) {
8417 if is_equal(&since, &Value::Null) {
8418 panic!("{}", crate::exchange_errors::arguments_required(add(&self.id, &Value::Str(" fetchPaginatedCallDeterministic() requires a since argument when until is set".to_string()))));
8419 }
8420 let mut requiredCalls: Value = math_ceil(÷(&(subtract(&until, &since)), &step));
8421 if is_greater_than(&requiredCalls, &maxCalls) {
8422 panic!("{}", crate::exchange_errors::bad_request(add(&add(&add(&add(&self.id, &Value::Str(" the number of required calls is greater than the max number of calls allowed, either increase the paginationCalls or decrease the since-until gap. Current paginationCalls limit is ".to_string())), &to_string_val(&maxCalls)), &Value::Str(" required calls is ".to_string())), &to_string_val(&requiredCalls))));
8423 }
8424 }
8425 {
8426 let mut i: Value = Value::Int(0);
8427 let mut __for_first_158: bool = true;
8428 while { if !__for_first_158 { i = add(&i, &Value::Int(1)); } __for_first_158 = false; is_less_than(&i, &maxCalls) } {
8429 if is_true(&(!is_equal(&until, &Value::Null))) && is_true(&(is_greater_than_or_equal(¤tSince, &until))) {
8430 break;
8431 }
8432 if is_greater_than_or_equal(¤tSince, ¤t) {
8433 break;
8434 }
8435 append_to_array(&mut tasks, self.safe_deterministic_call(method.clone(), &[symbol.clone(), currentSince.clone(), maxEntriesPerRequest.clone(), timeframe.clone(), params.clone()]).await);
8436 currentSince = subtract(&self.sum(&[currentSince.clone(), step.clone()]), &Value::Int(1));
8437 }
8438 }
8439 let mut results: Value = promise_all(&tasks).await;
8440 let mut result: Value = Value::List(vec![]);
8441 {
8442 let mut i: Value = Value::Int(0);
8443 let mut __for_first_159: bool = true;
8444 while { if !__for_first_159 { i = add(&i, &Value::Int(1)); } __for_first_159 = false; is_less_than(&i, &get_array_length(&results)) } {
8445 result = self.array_concat(result.clone(), get_value(&results, &i));
8446 }
8447 }
8448 let mut uniqueResults: Value = self.remove_repeated_elements_from_array(result.clone(), &[]);
8449 let mut key: Value = ternary(is_true(&(is_equal(&method, &Value::Str("fetchOHLCV".to_string())))), Value::Int(0), Value::Str("timestamp".to_string()));
8450 return self.filter_by_since_limit(uniqueResults.clone(), &[since.clone(), limit.clone(), key.clone()]);
8451
8452 Value::Null
8453} }
8454
8455fn fetch_paginated_call_cursor(&mut self, mut method: Value, optional_args: &[Value]) -> impl ::std::future::Future<Output = Value> + Send { async move {
8458 let mut symbol = get_arg(optional_args, 0, Value::Null);
8459 let mut since = get_arg(optional_args, 1, Value::Null);
8460 let mut limit = get_arg(optional_args, 2, Value::Null);
8461 let mut params = get_arg(optional_args, 3, Value::Map({
8462 let mut m = indexmap::IndexMap::new();
8463 m
8464}));
8465 let mut cursorReceived = get_arg(optional_args, 4, Value::Null);
8466 let mut cursorSent = get_arg(optional_args, 5, Value::Null);
8467 let mut cursorIncrement = get_arg(optional_args, 6, Value::Null);
8468 let mut maxEntriesPerRequest = get_arg(optional_args, 7, Value::Null);
8469 let mut maxCalls: Value = Value::Int(10);
8470 { let __destr_tmp = self.handle_option_and_params(params.clone(), method.clone(), Value::Str("paginationCalls".to_string()), &[maxCalls.clone()]); maxCalls = get_value(&__destr_tmp, &Value::Int(0)); params = get_value(&__destr_tmp, &Value::Int(1)); }
8471 let mut maxRetries: Value = Value::Int(3);
8472 { let __destr_tmp = self.handle_option_and_params(params.clone(), method.clone(), Value::Str("maxRetries".to_string()), &[maxRetries.clone()]); maxRetries = get_value(&__destr_tmp, &Value::Int(0)); params = get_value(&__destr_tmp, &Value::Int(1)); }
8473 { let __destr_tmp = self.handle_max_entries_per_request_and_params(method.clone(), &[maxEntriesPerRequest.clone(), params.clone()]); maxEntriesPerRequest = get_value(&__destr_tmp, &Value::Int(0)); params = get_value(&__destr_tmp, &Value::Int(1)); }
8474 let mut cursorValue: Value = Value::Null;
8475 let mut i: Value = Value::Int(0);
8476 let mut errors: Value = Value::Int(0);
8477 let mut result: Value = Value::List(vec![]);
8478 let mut timeframe: Value = self.safe_string_k(params.clone(), "timeframe", &[]);
8479 params = self.omit(params.clone(), Value::Str("timeframe".to_string()), &[]); while is_less_than(&i, &maxCalls) {
8481 {
8482 if !is_equal(&cursorValue, &Value::Null) {
8483 if !is_equal(&cursorIncrement, &Value::Null) {
8484 cursorValue = add(&self.parse_to_int(cursorValue.clone()), &cursorIncrement);
8485 }
8486 add_element_to_object(&mut params, &cursorSent, cursorValue.clone());
8487 }
8488 let mut response: Value = Value::Null;
8489 if is_equal(&method, &Value::Str("fetchAccounts".to_string())) {
8490 response = self.call_method(method.clone(), &[params.clone()]).await;
8491 } else if is_equal(&method, &Value::Str("getLeverageTiersPaginated".to_string())) || is_equal(&method, &Value::Str("fetchPositions".to_string())) {
8492 response = self.call_method(method.clone(), &[symbol.clone(), params.clone()]).await;
8493 } else if is_equal(&method, &Value::Str("fetchOpenInterestHistory".to_string())) {
8494 if !is_string(&symbol) {
8495 panic!("{}", crate::exchange_errors::arguments_required(add(&self.id, &Value::Str(" fetchPaginatedCallCursor() requires a symbol argument".to_string()))));
8496 }
8497 if is_equal(&timeframe, &Value::Null) {
8498 panic!("{}", crate::exchange_errors::arguments_required(add(&self.id, &Value::Str(" fetchPaginatedCallCursor() requires a timeframe argument".to_string()))));
8499 }
8500 response = self.call_method(method.clone(), &[symbol.clone(), timeframe.clone(), since.clone(), maxEntriesPerRequest.clone(), params.clone()]).await;
8501 } else {
8502 response = self.call_method(method.clone(), &[symbol.clone(), since.clone(), maxEntriesPerRequest.clone(), params.clone()]).await;
8503 }
8504 errors = Value::Int(0);
8505 if is_equal(&response, &Value::Null) {
8506 panic!("{}", crate::exchange_errors::null_response(add(&self.id, &Value::Str(" fetchPaginatedCallCursor() returned empty response".to_string()))));
8507 }
8508 let mut responseLength: Value = get_array_length(&response);
8509 if is_true(&self.verbose) {
8510 let mut cursorString: Value = ternary(is_true(&(is_equal(&cursorValue, &Value::Null))), Value::Str("".to_string()), cursorValue.clone());
8511 let mut iteration: Value = (add(&i, &Value::Int(1)));
8512 let mut cursorMessage: Value = add(&add(&add(&add(&add(&add(&add(&Value::Str("Cursor pagination call ".to_string()), &to_string_val(&iteration)), &Value::Str(" method ".to_string())), &method), &Value::Str(" response length ".to_string())), &to_string_val(&responseLength)), &Value::Str(" cursor ".to_string())), &cursorString);
8513 self.log(cursorMessage.clone());
8514 }
8515 if is_equal(&responseLength, &Value::Int(0)) {
8516 break;
8517 }
8518 if !is_equal(&response, &Value::Null) {
8519 result = self.array_concat(result.clone(), response.clone());
8520 }
8521 let mut last: Value = self.safe_dict(response.clone(), subtract(&responseLength, &Value::Int(1)), &[]);
8522 cursorValue = Value::Null; {
8525 let mut j: Value = Value::Int(0);
8526 let mut __for_first_160: bool = true;
8527 while { if !__for_first_160 { j = add(&j, &Value::Int(1)); } __for_first_160 = false; is_less_than(&j, &responseLength) } {
8528 let mut index: Value = subtract(&subtract(&responseLength, &j), &Value::Int(1));
8529 let mut entry: Value = self.safe_dict(response.clone(), index.clone(), &[]);
8530 let mut info: Value = self.safe_dict_k(entry.clone(), "info", &[]);
8531 let mut cursor: Value = ternary(is_true(&(is_equal(&cursorReceived, &Value::Null))), Value::Null, self.safe_value(info.clone(), cursorReceived.clone(), &[]));
8532 if !is_equal(&cursor, &Value::Null) {
8533 cursorValue = cursor.clone();
8534 break;
8535 }
8536 }
8537 }
8538 if is_equal(&cursorValue, &Value::Null) {
8539 break;
8540 }
8541 let mut lastTimestamp: Value = self.safe_integer_k(last.clone(), "timestamp", &[]);
8542 if is_equal(&since, &Value::Null) {
8543 panic!("{}", crate::exchange_errors::arguments_required(add(&self.id, &Value::Str(" fetchPaginatedCallCursor() requires a since argument".to_string()))));
8544 }
8545 if !is_equal(&lastTimestamp, &Value::Null) && is_less_than(&lastTimestamp, &since) {
8546 break;
8547 }
8548 }
8549 i = add(&i, &Value::Int(1));
8550 }
8551 let mut sorted: Value = self.sort_cursor_paginated_result(result.clone());
8552 let mut key: Value = ternary(is_true(&(is_equal(&method, &Value::Str("fetchOHLCV".to_string())))), Value::Int(0), Value::Str("timestamp".to_string()));
8553 return self.filter_by_since_limit(sorted.clone(), &[since.clone(), limit.clone(), key.clone()]);
8554
8555 Value::Null
8556} }
8557
8558 fn fetch_paginated_call_incremental(&mut self, mut method: Value, optional_args: &[Value]) -> impl ::std::future::Future<Output = Value> + Send { async move {
8559 let mut symbol = get_arg(optional_args, 0, Value::Null);
8560 let mut since = get_arg(optional_args, 1, Value::Null);
8561 let mut limit = get_arg(optional_args, 2, Value::Null);
8562 let mut params = get_arg(optional_args, 3, Value::Map({
8563 let mut m = indexmap::IndexMap::new();
8564 m
8565}));
8566 let mut pageKey = get_arg(optional_args, 4, Value::Null);
8567 let mut maxEntriesPerRequest = get_arg(optional_args, 5, Value::Null);
8568 let mut maxCalls: Value = Value::Int(10);
8569 { let __destr_tmp = self.handle_option_and_params(params.clone(), method.clone(), Value::Str("paginationCalls".to_string()), &[maxCalls.clone()]); maxCalls = get_value(&__destr_tmp, &Value::Int(0)); params = get_value(&__destr_tmp, &Value::Int(1)); }
8570 let mut maxRetries: Value = Value::Int(3);
8571 { let __destr_tmp = self.handle_option_and_params(params.clone(), method.clone(), Value::Str("maxRetries".to_string()), &[maxRetries.clone()]); maxRetries = get_value(&__destr_tmp, &Value::Int(0)); params = get_value(&__destr_tmp, &Value::Int(1)); }
8572 { let __destr_tmp = self.handle_max_entries_per_request_and_params(method.clone(), &[maxEntriesPerRequest.clone(), params.clone()]); maxEntriesPerRequest = get_value(&__destr_tmp, &Value::Int(0)); params = get_value(&__destr_tmp, &Value::Int(1)); }
8573 let mut i: Value = Value::Int(0);
8574 let mut errors: Value = Value::Int(0);
8575 let mut result: Value = Value::List(vec![]);
8576 while is_less_than(&i, &maxCalls) {
8577 {
8578 add_element_to_object(&mut params, &pageKey, add(&i, &Value::Int(1)));
8579 let mut response: Value = self.call_method(method.clone(), &[symbol.clone(), since.clone(), maxEntriesPerRequest.clone(), params.clone()]).await;
8580 errors = Value::Int(0);
8581 let mut responseLength: Value = get_array_length(&response);
8582 if is_true(&self.verbose) {
8583 let mut iteration: Value = to_string_val(&(add(&i, &Value::Int(1))));
8584 let mut incrementalMessage: Value = add(&add(&add(&add(&add(&Value::Str("Incremental pagination call ".to_string()), &iteration), &Value::Str(" method ".to_string())), &method), &Value::Str(" response length ".to_string())), &to_string_val(&responseLength));
8585 self.log(incrementalMessage.clone());
8586 }
8587 if is_equal(&responseLength, &Value::Int(0)) {
8588 break;
8589 }
8590 result = self.array_concat(result.clone(), response.clone());
8591 }
8592 i = add(&i, &Value::Int(1));
8593 }
8594 let mut sorted: Value = self.sort_cursor_paginated_result(result.clone());
8595 let mut key: Value = ternary(is_true(&(is_equal(&method, &Value::Str("fetchOHLCV".to_string())))), Value::Int(0), Value::Str("timestamp".to_string()));
8596 return self.filter_by_since_limit(sorted.clone(), &[since.clone(), limit.clone(), key.clone()]);
8597
8598 Value::Null
8599} }
8600
8601 fn sort_cursor_paginated_result(&self, mut result: Value) -> Value {
8602 let mut first: Value = self.safe_value(result.clone(), Value::Int(0), &[]);
8603 if !is_equal(&first, &Value::Null) {
8604 if is_true(&Value::Bool(in_op(&first, &Value::Str("timestamp".to_string())))) {
8605 return self.sort_by(result.clone(), Value::Str("timestamp".to_string()), &[Value::Bool(true)]);
8606 }
8607 if is_true(&Value::Bool(in_op(&first, &Value::Str("id".to_string())))) {
8608 return self.sort_by(result.clone(), Value::Str("id".to_string()), &[Value::Bool(true)]);
8609 }
8610 }
8611 return result;
8612
8613 Value::Null
8614}
8615
8616 fn remove_repeated_elements_from_array(&self, mut input: Value, optional_args: &[Value]) -> Value {
8617 let mut fallbackToTimestamp = get_arg(optional_args, 0, Value::Bool(true));
8618 let mut uniqueDic: Value = Value::Map({
8619 let mut m = indexmap::IndexMap::new();
8620 m
8621 });
8622 let mut uniqueResult: Value = Value::List(vec![]);
8623 {
8624 let mut i: Value = Value::Int(0);
8625 let mut __for_first_161: bool = true;
8626 while { if !__for_first_161 { i = add(&i, &Value::Int(1)); } __for_first_161 = false; is_less_than(&i, &get_array_length(&input)) } {
8627 let mut entry: Value = get_value(&input, &i);
8628 let mut entry: Value = get_value(&input, &i);
8629 let mut uniqValue: Value = ternary(is_true(&fallbackToTimestamp), self.safe_string_n(entry.clone(), Value::List(vec![Value::Str("id".to_string()), Value::Str("timestamp".to_string()), Value::Int(0)]), &[]), self.safe_string_k(entry.clone(), "id", &[]));
8630 if !is_equal(&uniqValue, &Value::Null) && !is_true(&(Value::Bool(in_op(&uniqueDic, &uniqValue)))) {
8631 add_element_to_object(&mut uniqueDic, &uniqValue, Value::Int(1));
8632 append_to_array(&mut uniqueResult, entry.clone());
8633 }
8634 }
8635 }
8636 let mut valuesLength: Value = get_array_length(&uniqueResult);
8637 if is_greater_than(&valuesLength, &Value::Int(0)) {
8638 return uniqueResult;
8639 }
8640 return input;
8641
8642 Value::Null
8643}
8644
8645 fn remove_repeated_trades_from_array(&self, mut input: Value) -> Value {
8646 let mut uniqueResult: Value = Value::Map({
8647 let mut m = indexmap::IndexMap::new();
8648 m
8649 });
8650 {
8651 let mut i: Value = Value::Int(0);
8652 let mut __for_first_162: bool = true;
8653 while { if !__for_first_162 { i = add(&i, &Value::Int(1)); } __for_first_162 = false; is_less_than(&i, &get_array_length(&input)) } {
8654 let mut entry: Value = get_value(&input, &i);
8655 let mut entry: Value = get_value(&input, &i);
8656 let mut id: Value = self.safe_string_k(entry.clone(), "id", &[]);
8657 if is_equal(&id, &Value::Null) {
8658 let mut price: Value = self.safe_string_k(entry.clone(), "price", &[]);
8659 let mut amount: Value = self.safe_string_k(entry.clone(), "amount", &[]);
8660 let mut timestamp: Value = self.safe_string_k(entry.clone(), "timestamp", &[]);
8661 let mut side: Value = self.safe_string_k(entry.clone(), "side", &[]);
8662 if is_equal(×tamp, &Value::Null) {
8664 panic!("{}", crate::exchange_errors::exchange_error(add(&self.id, &Value::Str(" removeRepeatedTradesFromArray() missing timestamp".to_string()))));
8665 }
8666 id = add(&add(&add(&add(&add(&add(&add(&Value::Str("t_".to_string()), &to_string_val(×tamp)), &Value::Str("_".to_string())), &side), &Value::Str("_".to_string())), &price), &Value::Str("_".to_string())), &amount);
8667 }
8668 if !is_equal(&id, &Value::Null) && !is_true(&(Value::Bool(in_op(&uniqueResult, &id)))) {
8669 add_element_to_object(&mut uniqueResult, &id, entry.clone());
8670 }
8671 }
8672 }
8673 let mut values: Value = object_values(&uniqueResult);
8674 return values;
8675
8676 Value::Null
8677}
8678
8679 fn remove_keys_from_dict(&self, mut dict: Value, mut removeKeys: Value) -> Value {
8680 let mut keys: Value = object_keys(&dict);
8681 let mut newDict: Value = Value::Map({
8682 let mut m = indexmap::IndexMap::new();
8683 m
8684 });
8685 {
8686 let mut i: Value = Value::Int(0);
8687 let mut __for_first_163: bool = true;
8688 while { if !__for_first_163 { i = add(&i, &Value::Int(1)); } __for_first_163 = false; is_less_than(&i, &get_array_length(&keys)) } {
8689 let mut key: Value = get_value(&keys, &i);
8690 let mut key: Value = get_value(&keys, &i);
8691 if !is_true(&self.in_array(key.clone(), removeKeys.clone())) {
8692 add_element_to_object(&mut newDict, &key, get_value(&dict, &key));
8693 }
8694 }
8695 }
8696 return newDict;
8697
8698 Value::Null
8699}
8700
8701 fn handle_until_option(&self, mut key: Value, mut request: Value, mut params: Value, optional_args: &[Value]) -> Value {
8702 let mut multiplier = get_arg(optional_args, 0, Value::Int(1));
8703 let mut until: Value = self.safe_integer2(params.clone(), Value::Str("until".to_string()), Value::Str("till".to_string()), &[]);
8704 if !is_equal(&until, &Value::Null) {
8705 add_element_to_object(&mut request, &key, self.parse_to_int(multiply(&until, &multiplier)));
8706 params = self.omit(params.clone(), Value::List(vec![Value::Str("until".to_string()), Value::Str("till".to_string())]), &[]);
8707 }
8708 return Value::List(vec![request.clone(), params.clone()]);
8709
8710 Value::Null
8711}
8712
8713 fn safe_open_interest(&self, mut interest: Value, optional_args: &[Value]) -> Value {
8714 let mut market = get_arg(optional_args, 0, Value::Null);
8715 let mut symbol: Value = self.safe_string_k(interest.clone(), "symbol", &[]);
8716 if is_equal(&symbol, &Value::Null) {
8717 symbol = self.safe_string_k(market.clone(), "symbol", &[]);
8718 }
8719 return self.extend(interest.clone(), &[Value::Map({
8720 let mut m = indexmap::IndexMap::new();
8721 m.insert("symbol".to_string(), symbol.clone());
8722 m.insert("baseVolume".to_string(), self.safe_number_k(interest.clone(), "baseVolume", &[]));
8723 m.insert("quoteVolume".to_string(), self.safe_number_k(interest.clone(), "quoteVolume", &[]));
8724 m.insert("openInterestAmount".to_string(), self.safe_number_k(interest.clone(), "openInterestAmount", &[]));
8725 m.insert("openInterestValue".to_string(), self.safe_number_k(interest.clone(), "openInterestValue", &[]));
8726 m.insert("timestamp".to_string(), self.safe_integer_k(interest.clone(), "timestamp", &[]));
8727 m.insert("datetime".to_string(), self.safe_string_k(interest.clone(), "datetime", &[]));
8728 m.insert("info".to_string(), self.safe_value_k(interest.clone(), "info", &[]));
8729 m
8730})]);
8731
8732 Value::Null
8733}
8734
8735 fn parse_liquidation(&self, mut liquidation: Value, optional_args: &[Value]) -> Value {
8736 { let __v = crate::exchange::DerivedExchange::parse_liquidation(self, liquidation.clone(), crate::runtime::get_arg(optional_args, 0, crate::Value::Null)); if !matches!(__v, crate::Value::Null) { return __v; } }
8738
8739 let mut market = get_arg(optional_args, 0, Value::Null);
8740 panic!("{}", crate::exchange_errors::not_supported(add(&self.id, &Value::Str(" parseLiquidation () is not supported yet".to_string()))));
8741
8742 Value::Null
8743}
8744
8745 fn parse_liquidations(&self, mut liquidations: Value, optional_args: &[Value]) -> Value {
8746 let mut market = get_arg(optional_args, 0, Value::Null);
8747 let mut since = get_arg(optional_args, 1, Value::Null);
8748 let mut limit = get_arg(optional_args, 2, Value::Null);
8749 let mut result: Value = Value::List(vec![]);
8760 {
8761 let mut i: Value = Value::Int(0);
8762 let mut __for_first_164: bool = true;
8763 while { if !__for_first_164 { i = add(&i, &Value::Int(1)); } __for_first_164 = false; is_less_than(&i, &get_array_length(&liquidations)) } {
8764 let mut entry: Value = get_value(&liquidations, &i);
8765 let mut entry: Value = get_value(&liquidations, &i);
8766 let mut parsed: Value = <Self as crate::exchange_generated::ExchangeBase>::parse_liquidation(self, entry.clone(), &[market.clone()]);
8767 append_to_array(&mut result, parsed.clone());
8768 }
8769 }
8770 let mut sorted: Value = self.sort_by(result.clone(), Value::Str("timestamp".to_string()), &[]);
8771 let mut symbol: Value = self.safe_string_k(market.clone(), "symbol", &[]);
8772 return self.filter_by_symbol_since_limit(sorted.clone(), &[symbol.clone(), since.clone(), limit.clone()]);
8773
8774 Value::Null
8775}
8776
8777 fn parse_greeks(&self, mut greeks: Value, optional_args: &[Value]) -> Value {
8778 { let __v = crate::exchange::DerivedExchange::parse_greeks(self, greeks.clone(), crate::runtime::get_arg(optional_args, 0, crate::Value::Null)); if !matches!(__v, crate::Value::Null) { return __v; } }
8780
8781 let mut market = get_arg(optional_args, 0, Value::Null);
8782 panic!("{}", crate::exchange_errors::not_supported(add(&self.id, &Value::Str(" parseGreeks () is not supported yet".to_string()))));
8783
8784 Value::Null
8785}
8786
8787 fn parse_all_greeks(&self, mut greeks: Value, optional_args: &[Value]) -> Value {
8788 let mut symbols = get_arg(optional_args, 0, Value::Null);
8789 let mut params = get_arg(optional_args, 1, Value::Map({
8790 let mut m = indexmap::IndexMap::new();
8791 m
8792}));
8793 let mut results: Value = Value::List(vec![]);
8797 if is_true(&Value::Bool(is_array(&greeks))) {
8798 {
8799 let mut i: Value = Value::Int(0);
8800 let mut __for_first_165: bool = true;
8801 while { if !__for_first_165 { i = add(&i, &Value::Int(1)); } __for_first_165 = false; is_less_than(&i, &get_array_length(&greeks)) } {
8802 let mut parsedTicker: Value = <Self as crate::exchange_generated::ExchangeBase>::parse_greeks(self, get_value(&greeks, &i), &[]);
8803 let mut greek: Value = self.extend(parsedTicker.clone(), &[params.clone()]);
8804 append_to_array(&mut results, greek.clone());
8805 }
8806 }
8807 } else {
8808 let mut marketIds: Value = object_keys(&greeks);
8809 {
8810 let mut i: Value = Value::Int(0);
8811 let mut __for_first_166: bool = true;
8812 while { if !__for_first_166 { i = add(&i, &Value::Int(1)); } __for_first_166 = false; is_less_than(&i, &get_array_length(&marketIds)) } {
8813 let mut marketId: Value = get_value(&marketIds, &i);
8814 let mut marketId: Value = get_value(&marketIds, &i);
8815 let mut market: Value = self.safe_market(&[marketId.clone()]);
8816 let mut parsed: Value = <Self as crate::exchange_generated::ExchangeBase>::parse_greeks(self, get_value(&greeks, &marketId), &[market.clone()]);
8817 let mut greek: Value = self.extend(parsed.clone(), &[params.clone()]);
8818 append_to_array(&mut results, greek.clone());
8819 }
8820 }
8821 }
8822 symbols = self.market_symbols(&[symbols.clone()]);
8823 return self.filter_by_array(results.clone(), Value::Str("symbol".to_string()), &[symbols.clone()]);
8824
8825 Value::Null
8826}
8827
8828 fn parse_option(&self, mut chain: Value, optional_args: &[Value]) -> Value {
8829 let mut currency = get_arg(optional_args, 0, Value::Null);
8830 let mut market = get_arg(optional_args, 1, Value::Null);
8831 panic!("{}", crate::exchange_errors::not_supported(add(&self.id, &Value::Str(" parseOption () is not supported yet".to_string()))));
8832
8833 Value::Null
8834}
8835
8836 fn parse_option_chain(&self, mut response: Value, optional_args: &[Value]) -> Value {
8837 let mut currencyKey = get_arg(optional_args, 0, Value::Null);
8838 let mut symbolKey = get_arg(optional_args, 1, Value::Null);
8839 let mut optionStructures: Value = Value::Map({
8840 let mut m = indexmap::IndexMap::new();
8841 m
8842 });
8843 {
8844 let mut i: Value = Value::Int(0);
8845 let mut __for_first_167: bool = true;
8846 while { if !__for_first_167 { i = add(&i, &Value::Int(1)); } __for_first_167 = false; is_less_than(&i, &get_array_length(&response)) } {
8847 let mut info: Value = get_value(&response, &i);
8848 let mut info: Value = get_value(&response, &i);
8849 let mut currencyId: Value = ternary(is_true(&(is_equal(¤cyKey, &Value::Null))), Value::Null, self.safe_string(info.clone(), currencyKey.clone(), &[]));
8850 let mut currency: Value = self.safe_currency(currencyId.clone(), &[]);
8851 let mut marketId: Value = ternary(is_true(&(is_equal(&symbolKey, &Value::Null))), Value::Null, self.safe_string(info.clone(), symbolKey.clone(), &[]));
8852 let mut market: Value = self.safe_market(&[marketId.clone(), Value::Null, Value::Null, Value::Str("option".to_string())]);
8853 add_element_to_object(&mut optionStructures, &get_value(&market, &Value::Str("symbol".to_string())), self.parse_option(info.clone(), &[currency.clone(), market.clone()]));
8854 }
8855 }
8856 return optionStructures;
8857
8858 Value::Null
8859}
8860
8861 fn parse_margin_modes(&self, mut response: Value, optional_args: &[Value]) -> Value {
8862 let mut symbols = get_arg(optional_args, 0, Value::Null);
8863 let mut symbolKey = get_arg(optional_args, 1, Value::Null);
8864 let mut marketType = get_arg(optional_args, 2, Value::Null);
8865 let mut marginModeStructures: Value = Value::Map({
8866 let mut m = indexmap::IndexMap::new();
8867 m
8868 });
8869 if is_equal(&marketType, &Value::Null) {
8870 marketType = Value::Str("swap".to_string()); }
8872 {
8873 let mut i: Value = Value::Int(0);
8874 let mut __for_first_168: bool = true;
8875 while { if !__for_first_168 { i = add(&i, &Value::Int(1)); } __for_first_168 = false; is_less_than(&i, &get_array_length(&response)) } {
8876 let mut info: Value = get_value(&response, &i);
8877 let mut info: Value = get_value(&response, &i);
8878 let mut marketId: Value = ternary(is_true(&(is_equal(&symbolKey, &Value::Null))), Value::Null, self.safe_string(info.clone(), symbolKey.clone(), &[]));
8879 let mut market: Value = self.safe_market(&[marketId.clone(), Value::Null, Value::Null, marketType.clone()]);
8880 if is_true(&(is_equal(&symbols, &Value::Null))) || is_true(&self.in_array(get_value(&market, &Value::Str("symbol".to_string())), symbols.clone())) {
8881 add_element_to_object(&mut marginModeStructures, &get_value(&market, &Value::Str("symbol".to_string())), <Self as crate::exchange_generated::ExchangeBase>::parse_margin_mode(self, info.clone(), &[market.clone()]));
8882 }
8883 }
8884 }
8885 return marginModeStructures;
8886
8887 Value::Null
8888}
8889
8890 fn parse_margin_mode(&self, mut marginMode: Value, optional_args: &[Value]) -> Value {
8891 { let __v = crate::exchange::DerivedExchange::parse_margin_mode(self, marginMode.clone(), crate::runtime::get_arg(optional_args, 0, crate::Value::Null)); if !matches!(__v, crate::Value::Null) { return __v; } }
8893
8894 let mut market = get_arg(optional_args, 0, Value::Null);
8895 panic!("{}", crate::exchange_errors::not_supported(add(&self.id, &Value::Str(" parseMarginMode () is not supported yet".to_string()))));
8896
8897 Value::Null
8898}
8899
8900 fn parse_leverages(&self, mut response: Value, optional_args: &[Value]) -> Value {
8901 let mut symbols = get_arg(optional_args, 0, Value::Null);
8902 let mut symbolKey = get_arg(optional_args, 1, Value::Null);
8903 let mut marketType = get_arg(optional_args, 2, Value::Null);
8904 let mut leverageStructures: Value = Value::Map({
8905 let mut m = indexmap::IndexMap::new();
8906 m
8907 });
8908 if is_equal(&marketType, &Value::Null) {
8909 marketType = Value::Str("swap".to_string()); }
8911 {
8912 let mut i: Value = Value::Int(0);
8913 let mut __for_first_169: bool = true;
8914 while { if !__for_first_169 { i = add(&i, &Value::Int(1)); } __for_first_169 = false; is_less_than(&i, &get_array_length(&response)) } {
8915 let mut info: Value = get_value(&response, &i);
8916 let mut info: Value = get_value(&response, &i);
8917 let mut marketId: Value = ternary(is_true(&(is_equal(&symbolKey, &Value::Null))), Value::Null, self.safe_string(info.clone(), symbolKey.clone(), &[]));
8918 let mut market: Value = self.safe_market(&[marketId.clone(), Value::Null, Value::Null, marketType.clone()]);
8919 if is_true(&(is_equal(&symbols, &Value::Null))) || is_true(&self.in_array(get_value(&market, &Value::Str("symbol".to_string())), symbols.clone())) {
8920 add_element_to_object(&mut leverageStructures, &get_value(&market, &Value::Str("symbol".to_string())), <Self as crate::exchange_generated::ExchangeBase>::parse_leverage(self, info.clone(), &[market.clone()]));
8921 }
8922 }
8923 }
8924 return leverageStructures;
8925
8926 Value::Null
8927}
8928
8929 fn parse_leverage(&self, mut leverage: Value, optional_args: &[Value]) -> Value {
8930 { let __v = crate::exchange::DerivedExchange::parse_leverage(self, leverage.clone(), crate::runtime::get_arg(optional_args, 0, crate::Value::Null)); if !matches!(__v, crate::Value::Null) { return __v; } }
8932
8933 let mut market = get_arg(optional_args, 0, Value::Null);
8934 panic!("{}", crate::exchange_errors::not_supported(add(&self.id, &Value::Str(" parseLeverage () is not supported yet".to_string()))));
8935
8936 Value::Null
8937}
8938
8939 fn parse_conversions(&self, mut conversions: Value, optional_args: &[Value]) -> Value {
8940 let mut code = get_arg(optional_args, 0, Value::Null);
8941 let mut fromCurrencyKey = get_arg(optional_args, 1, Value::Null);
8942 let mut toCurrencyKey = get_arg(optional_args, 2, Value::Null);
8943 let mut since = get_arg(optional_args, 3, Value::Null);
8944 let mut limit = get_arg(optional_args, 4, Value::Null);
8945 let mut params = get_arg(optional_args, 5, Value::Map({
8946 let mut m = indexmap::IndexMap::new();
8947 m
8948}));
8949 let mut conversionsArray: Value = self.to_array(conversions.clone());
8950 let mut result: Value = Value::List(vec![]);
8951 let mut fromCurrency: Value = Value::Null;
8952 let mut toCurrency: Value = Value::Null;
8953 {
8954 let mut i: Value = Value::Int(0);
8955 let mut __for_first_170: bool = true;
8956 while { if !__for_first_170 { i = add(&i, &Value::Int(1)); } __for_first_170 = false; is_less_than(&i, &get_array_length(&conversionsArray)) } {
8957 let mut entry: Value = get_value(&conversionsArray, &i);
8958 let mut entry: Value = get_value(&conversionsArray, &i);
8959 let mut fromId: Value = ternary(is_true(&(is_equal(&fromCurrencyKey, &Value::Null))), Value::Null, self.safe_string(entry.clone(), fromCurrencyKey.clone(), &[]));
8960 let mut toId: Value = ternary(is_true(&(is_equal(&toCurrencyKey, &Value::Null))), Value::Null, self.safe_string(entry.clone(), toCurrencyKey.clone(), &[]));
8961 if !is_equal(&fromId, &Value::Null) {
8962 fromCurrency = self.safe_currency(fromId.clone(), &[]);
8963 }
8964 if !is_equal(&toId, &Value::Null) {
8965 toCurrency = self.safe_currency(toId.clone(), &[]);
8966 }
8967 let mut conversion: Value = self.extend(<Self as crate::exchange_generated::ExchangeBase>::parse_conversion(self, entry.clone(), &[fromCurrency.clone(), toCurrency.clone()]), &[params.clone()]);
8968 append_to_array(&mut result, conversion.clone());
8969 }
8970 }
8971 let mut sorted: Value = self.sort_by(result.clone(), Value::Str("timestamp".to_string()), &[]);
8972 let mut currency: Value = Value::Null;
8973 if !is_equal(&code, &Value::Null) {
8974 currency = self.safe_currency(code.clone(), &[]);
8975 if is_equal(¤cy, &Value::Null) {
8976 panic!("{}", crate::exchange_errors::exchange_error(add(&self.id, &Value::Str(" parseConversions() could not resolve currency".to_string()))));
8977 }
8978 code = get_value(¤cy, &Value::Str("code".to_string()));
8979 }
8980 if is_equal(&code, &Value::Null) {
8981 return self.filter_by_since_limit(sorted.clone(), &[since.clone(), limit.clone()]);
8982 }
8983 let mut fromConversion: Value = self.filter_by(sorted.clone(), Value::Str("fromCurrency".to_string()), code.clone(), &[]);
8984 let mut toConversion: Value = self.filter_by(sorted.clone(), Value::Str("toCurrency".to_string()), code.clone(), &[]);
8985 let mut both: Value = self.array_concat(fromConversion.clone(), toConversion.clone());
8986 return self.filter_by_since_limit(both.clone(), &[since.clone(), limit.clone()]);
8987
8988 Value::Null
8989}
8990
8991 fn parse_conversion(&self, mut conversion: Value, optional_args: &[Value]) -> Value {
8992 { 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; } }
8994
8995 let mut fromCurrency = get_arg(optional_args, 0, Value::Null);
8996 let mut toCurrency = get_arg(optional_args, 1, Value::Null);
8997 if is_equal(&conversion, &Value::Null) {
8998 panic!("{}", crate::exchange_errors::not_supported(add(&self.id, &Value::Str(" parseConversion () is not supported yet".to_string()))));
8999 }
9000 panic!("{}", crate::exchange_errors::not_supported(add(&self.id, &Value::Str(" parseConversion () is not supported yet".to_string()))));
9001
9002 Value::Null
9003}
9004
9005 fn convert_expire_date(&self, mut date: Value) -> Value {
9006 if is_equal(&date, &Value::Null) {
9007 return Value::Null;
9008 }
9009 let mut year: Value = slice(&date, &Value::Int(0), &Value::Int(2));
9011 let mut month: Value = slice(&date, &Value::Int(2), &Value::Int(4));
9012 let mut day: Value = slice(&date, &Value::Int(4), &Value::Int(6));
9013 let mut reconstructedDate: Value = add(&add(&add(&add(&add(&add(&Value::Str("20".to_string()), &year), &Value::Str("-".to_string())), &month), &Value::Str("-".to_string())), &day), &Value::Str("T00:00:00Z".to_string()));
9014 return reconstructedDate;
9015
9016 Value::Null
9017}
9018
9019 fn convert_expire_date_to_market_id_date(&self, mut date: Value) -> Value {
9020 if is_equal(&date, &Value::Null) {
9021 return Value::Null;
9022 }
9023 let mut year: Value = slice(&date, &Value::Int(0), &Value::Int(2));
9025 let mut monthRaw: Value = slice(&date, &Value::Int(2), &Value::Int(4));
9026 let mut month: Value = Value::Null;
9027 let mut day: Value = slice(&date, &Value::Int(4), &Value::Int(6));
9028 if is_equal(&monthRaw, &Value::Str("01".to_string())) {
9029 month = Value::Str("JAN".to_string());
9030 } else if is_equal(&monthRaw, &Value::Str("02".to_string())) {
9031 month = Value::Str("FEB".to_string());
9032 } else if is_equal(&monthRaw, &Value::Str("03".to_string())) {
9033 month = Value::Str("MAR".to_string());
9034 } else if is_equal(&monthRaw, &Value::Str("04".to_string())) {
9035 month = Value::Str("APR".to_string());
9036 } else if is_equal(&monthRaw, &Value::Str("05".to_string())) {
9037 month = Value::Str("MAY".to_string());
9038 } else if is_equal(&monthRaw, &Value::Str("06".to_string())) {
9039 month = Value::Str("JUN".to_string());
9040 } else if is_equal(&monthRaw, &Value::Str("07".to_string())) {
9041 month = Value::Str("JUL".to_string());
9042 } else if is_equal(&monthRaw, &Value::Str("08".to_string())) {
9043 month = Value::Str("AUG".to_string());
9044 } else if is_equal(&monthRaw, &Value::Str("09".to_string())) {
9045 month = Value::Str("SEP".to_string());
9046 } else if is_equal(&monthRaw, &Value::Str("10".to_string())) {
9047 month = Value::Str("OCT".to_string());
9048 } else if is_equal(&monthRaw, &Value::Str("11".to_string())) {
9049 month = Value::Str("NOV".to_string());
9050 } else if is_equal(&monthRaw, &Value::Str("12".to_string())) {
9051 month = Value::Str("DEC".to_string());
9052 }
9053 let mut reconstructedDate: Value = add(&add(&day, &month), &year);
9054 return reconstructedDate;
9055
9056 Value::Null
9057}
9058
9059 fn convert_market_id_expire_date(&self, mut date: Value) -> Value {
9060 if is_equal(&date, &Value::Null) {
9061 return Value::Null;
9062 }
9063 let mut monthMappping: Value = Value::Map({
9065 let mut m = indexmap::IndexMap::new();
9066 m.insert("JAN".to_string(), Value::Str("01".to_string()));
9067 m.insert("FEB".to_string(), Value::Str("02".to_string()));
9068 m.insert("MAR".to_string(), Value::Str("03".to_string()));
9069 m.insert("APR".to_string(), Value::Str("04".to_string()));
9070 m.insert("MAY".to_string(), Value::Str("05".to_string()));
9071 m.insert("JUN".to_string(), Value::Str("06".to_string()));
9072 m.insert("JUL".to_string(), Value::Str("07".to_string()));
9073 m.insert("AUG".to_string(), Value::Str("08".to_string()));
9074 m.insert("SEP".to_string(), Value::Str("09".to_string()));
9075 m.insert("OCT".to_string(), Value::Str("10".to_string()));
9076 m.insert("NOV".to_string(), Value::Str("11".to_string()));
9077 m.insert("DEC".to_string(), Value::Str("12".to_string()));
9078 m
9079 });
9080 if is_equal(&get_array_length(&date), &Value::Int(6)) {
9082 date = add(&Value::Str("0".to_string()), &date);
9083 }
9084 let mut year: Value = slice(&date, &Value::Int(0), &Value::Int(2));
9085 let mut monthName: Value = slice(&date, &Value::Int(2), &Value::Int(5));
9086 let mut month: Value = self.safe_string(monthMappping.clone(), monthName.clone(), &[]);
9087 let mut day: Value = slice(&date, &Value::Int(5), &Value::Int(7));
9088 let mut reconstructedDate: Value = add(&add(&day, &month), &year);
9089 return reconstructedDate;
9090
9091 Value::Null
9092}
9093
9094 fn load_markets_and_sign_in(&mut self) -> impl ::std::future::Future<Output = Value> + Send { async move {
9095 promise_all(&Value::List(vec![self.load_markets(&[]).await, self.sign_in(&[]).await])).await;
9096
9097 Value::Null
9098} }
9099
9100 fn parse_margin_modification(&self, mut data: Value, optional_args: &[Value]) -> Value {
9101 { 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; } }
9103
9104 let mut market = get_arg(optional_args, 0, Value::Null);
9105 if is_equal(&data, &Value::Null) {
9106 panic!("{}", crate::exchange_errors::not_supported(add(&self.id, &Value::Str(" parseMarginModification() is not supported yet".to_string()))));
9107 }
9108 panic!("{}", crate::exchange_errors::not_supported(add(&self.id, &Value::Str(" parseMarginModification() is not supported yet".to_string()))));
9109
9110 Value::Null
9111}
9112
9113 fn parse_margin_modifications(&self, mut response: Value, optional_args: &[Value]) -> Value {
9114 let mut symbols = get_arg(optional_args, 0, Value::Null);
9115 let mut symbolKey = get_arg(optional_args, 1, Value::Null);
9116 let mut marketType = get_arg(optional_args, 2, Value::Null);
9117 let mut marginModifications: Value = Value::List(vec![]);
9118 if is_equal(&response, &Value::Null) {
9119 return marginModifications;
9120 }
9121 {
9122 let mut i: Value = Value::Int(0);
9123 let mut __for_first_171: bool = true;
9124 while { if !__for_first_171 { i = add(&i, &Value::Int(1)); } __for_first_171 = false; is_less_than(&i, &get_array_length(&response)) } {
9125 let mut info: Value = get_value(&response, &i);
9126 let mut info: Value = get_value(&response, &i);
9127 let mut marketId: Value = ternary(is_true(&(is_equal(&symbolKey, &Value::Null))), Value::Null, self.safe_string(info.clone(), symbolKey.clone(), &[]));
9128 let mut market: Value = self.safe_market(&[marketId.clone(), Value::Null, Value::Null, marketType.clone()]);
9129 if is_true(&(is_equal(&symbols, &Value::Null))) || is_true(&self.in_array(get_value(&market, &Value::Str("symbol".to_string())), symbols.clone())) {
9130 append_to_array(&mut marginModifications, <Self as crate::exchange_generated::ExchangeBase>::parse_margin_modification(self, info.clone(), &[market.clone()]));
9131 }
9132 }
9133 }
9134 return marginModifications;
9135
9136 Value::Null
9137}
9138
9139 fn fetch_transfer(&mut self, mut id: Value, optional_args: &[Value]) -> impl ::std::future::Future<Output = Value> + Send { async move {
9140 let mut code = get_arg(optional_args, 0, Value::Null);
9141 let mut params = get_arg(optional_args, 1, Value::Map({
9142 let mut m = indexmap::IndexMap::new();
9143 m
9144}));
9145 panic!("{}", crate::exchange_errors::not_supported(add(&self.id, &Value::Str(" fetchTransfer () is not supported yet".to_string()))));
9146
9147 Value::Null
9148} }
9149
9150 fn fetch_transfers(&mut self, optional_args: &[Value]) -> impl ::std::future::Future<Output = Value> + Send { async move {
9151 let mut code = get_arg(optional_args, 0, Value::Null);
9152 let mut since = get_arg(optional_args, 1, Value::Null);
9153 let mut limit = get_arg(optional_args, 2, Value::Null);
9154 let mut params = get_arg(optional_args, 3, Value::Map({
9155 let mut m = indexmap::IndexMap::new();
9156 m
9157}));
9158 panic!("{}", crate::exchange_errors::not_supported(add(&self.id, &Value::Str(" fetchTransfers () is not supported yet".to_string()))));
9159
9160 Value::Null
9161} }
9162
9163 fn un_watch_ohlcv(&mut self, mut symbol: Value, optional_args: &[Value]) -> impl ::std::future::Future<Output = Value> + Send { async move {
9164 let mut timeframe = get_arg(optional_args, 0, Value::Str("1m".to_string()));
9165 let mut params = get_arg(optional_args, 1, Value::Map({
9166 let mut m = indexmap::IndexMap::new();
9167 m
9168}));
9169 panic!("{}", crate::exchange_errors::not_supported(add(&self.id, &Value::Str(" unWatchOHLCV () is not supported yet".to_string()))));
9170
9171 Value::Null
9172} }
9173
9174 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 {
9175 let mut tag = get_arg(optional_args, 0, Value::Null);
9176 let mut params = get_arg(optional_args, 1, Value::Map({
9177 let mut m = indexmap::IndexMap::new();
9178 m
9179}));
9180 panic!("{}", crate::exchange_errors::not_supported(add(&self.id, &Value::Str(" withdrawWs () is not supported yet".to_string()))));
9181
9182 Value::Null
9183} }
9184
9185 fn un_watch_my_trades(&mut self, optional_args: &[Value]) -> impl ::std::future::Future<Output = Value> + Send { async move {
9186 let mut symbol = get_arg(optional_args, 0, Value::Null);
9187 let mut params = get_arg(optional_args, 1, Value::Map({
9188 let mut m = indexmap::IndexMap::new();
9189 m
9190}));
9191 panic!("{}", crate::exchange_errors::not_supported(add(&self.id, &Value::Str(" unWatchMyTrades () is not supported yet".to_string()))));
9192
9193 Value::Null
9194} }
9195
9196 fn fetch_orders_by_status_ws(&mut self, mut status: Value, optional_args: &[Value]) -> impl ::std::future::Future<Output = Value> + Send { async move {
9197 let mut symbol = get_arg(optional_args, 0, Value::Null);
9198 let mut since = get_arg(optional_args, 1, Value::Null);
9199 let mut limit = get_arg(optional_args, 2, Value::Null);
9200 let mut params = get_arg(optional_args, 3, Value::Map({
9201 let mut m = indexmap::IndexMap::new();
9202 m
9203}));
9204 panic!("{}", crate::exchange_errors::not_supported(add(&self.id, &Value::Str(" fetchOrdersByStatusWs () is not supported yet".to_string()))));
9205
9206 Value::Null
9207} }
9208
9209 fn un_watch_bids_asks(&mut self, optional_args: &[Value]) -> impl ::std::future::Future<Output = Value> + Send { async move {
9210 let mut symbols = get_arg(optional_args, 0, Value::Null);
9211 let mut params = get_arg(optional_args, 1, Value::Map({
9212 let mut m = indexmap::IndexMap::new();
9213 m
9214}));
9215 panic!("{}", crate::exchange_errors::not_supported(add(&self.id, &Value::Str(" unWatchBidsAsks () is not supported yet".to_string()))));
9216
9217 Value::Null
9218} }
9219
9220 fn clean_unsubscription(&self, mut client: Value, mut subHash: Value, mut unsubHash: Value, optional_args: &[Value]) {
9221 let mut subHashIsPrefix = get_arg(optional_args, 0, Value::Bool(false));
9222 if is_true(&(!is_equal(&unsubHash, &Value::Null))) && is_true(&(Value::Bool(in_op(&get_value(&client, &Value::Str("subscriptions".to_string())), &unsubHash)))) {
9223 remove(&mut get_value(&client, &Value::Str("subscriptions".to_string())), &unsubHash);
9224 }
9225 if !is_true(&subHashIsPrefix) {
9226 if is_true(&(!is_equal(&subHash, &Value::Null))) && is_true(&(Value::Bool(in_op(&get_value(&client, &Value::Str("subscriptions".to_string())), &subHash)))) {
9227 remove(&mut get_value(&client, &Value::Str("subscriptions".to_string())), &subHash);
9228 }
9229 if is_true(&(!is_equal(&subHash, &Value::Null))) && is_true(&(Value::Bool(in_op(&get_value(&client, &Value::Str("futures".to_string())), &subHash)))) {
9230 let mut error = crate::exchange_errors::unsubscribe_error(add(&add(&self.id, &Value::Str(" ".to_string())), &subHash));
9231 client.reject(&[Value::from(error.clone()), subHash.clone()]);
9232 }
9233 } else {
9234 let mut clientSubscriptions: Value = object_keys(&get_value(&client, &Value::Str("subscriptions".to_string())));
9235 {
9236 let mut i: Value = Value::Int(0);
9237 let mut __for_first_172: bool = true;
9238 while { if !__for_first_172 { i = add(&i, &Value::Int(1)); } __for_first_172 = false; is_less_than(&i, &get_array_length(&clientSubscriptions)) } {
9239 let mut sub: Value = get_value(&clientSubscriptions, &i);
9240 let mut sub: Value = get_value(&clientSubscriptions, &i);
9241 if is_true(&(!is_equal(&sub, &Value::Null))) && is_true(&(!is_equal(&subHash, &Value::Null))) && is_true(&Value::Bool(starts_with(&sub, &subHash))) {
9242 remove(&mut get_value(&client, &Value::Str("subscriptions".to_string())), &sub);
9243 }
9244 }
9245 }
9246 let mut clientFutures: Value = object_keys(&get_value(&client, &Value::Str("futures".to_string())));
9247 {
9248 let mut i: Value = Value::Int(0);
9249 let mut __for_first_173: bool = true;
9250 while { if !__for_first_173 { i = add(&i, &Value::Int(1)); } __for_first_173 = false; is_less_than(&i, &get_array_length(&clientFutures)) } {
9251 let mut future: Value = get_value(&clientFutures, &i);
9252 let mut future: Value = get_value(&clientFutures, &i);
9253 if is_true(&(!is_equal(&future, &Value::Null))) && is_true(&(!is_equal(&subHash, &Value::Null))) && is_true(&Value::Bool(starts_with(&future, &subHash))) {
9254 let mut error = crate::exchange_errors::unsubscribe_error(add(&add(&self.id, &Value::Str(" ".to_string())), &future));
9255 client.reject(&[Value::from(error.clone()), future.clone()]);
9256 }
9257 }
9258 }
9259 }
9260 client.resolve(&[Value::Bool(true), unsubHash.clone()]);
9261}
9262
9263 fn clean_cache(&mut self, mut subscription: Value) {
9264 let mut topic: Value = self.safe_string_k(subscription.clone(), "topic", &[]);
9265 let mut symbols: Value = self.safe_list_k(subscription.clone(), "symbols", &[Value::List(vec![])]);
9266 let mut symbolsLength: Value = get_array_length(&symbols);
9267 if is_equal(&topic, &Value::Str("ohlcv".to_string())) {
9268 let mut symbolsAndTimeframes: Value = self.safe_list_k(subscription.clone(), "symbolsAndTimeframes", &[Value::List(vec![])]);
9269 {
9270 let mut i: Value = Value::Int(0);
9271 let mut __for_first_174: bool = true;
9272 while { if !__for_first_174 { i = add(&i, &Value::Int(1)); } __for_first_174 = false; is_less_than(&i, &get_array_length(&symbolsAndTimeframes)) } {
9273 let mut symbolAndTimeFrame: Value = get_value(&symbolsAndTimeframes, &i);
9274 let mut symbolAndTimeFrame: Value = get_value(&symbolsAndTimeframes, &i);
9275 let mut symbol: Value = self.safe_string(symbolAndTimeFrame.clone(), Value::Int(0), &[]);
9276 let mut timeframe: Value = self.safe_string(symbolAndTimeFrame.clone(), Value::Int(1), &[]);
9277 if is_equal(&symbol, &Value::Null) {
9278 panic!("{}", crate::exchange_errors::arguments_required(add(&self.id, &Value::Str(" cleanCache() requires a symbol argument".to_string()))));
9279 }
9280 if is_equal(&timeframe, &Value::Null) {
9281 panic!("{}", crate::exchange_errors::arguments_required(add(&self.id, &Value::Str(" cleanCache() requires a timeframe argument".to_string()))));
9282 }
9283 if is_true(&(!is_equal(&self.ohlcvs, &Value::Null))) && is_true(&(Value::Bool(in_op(&self.ohlcvs, &symbol)))) {
9284 if is_true(&Value::Bool(in_op(&get_value(&self.ohlcvs, &symbol), &timeframe))) {
9285 remove(&mut get_value(&self.ohlcvs, &symbol), &timeframe);
9286 }
9287 }
9288 }
9289 }
9290 } else if is_greater_than(&symbolsLength, &Value::Int(0)) {
9291 {
9292 let mut i: Value = Value::Int(0);
9293 let mut __for_first_175: bool = true;
9294 while { if !__for_first_175 { i = add(&i, &Value::Int(1)); } __for_first_175 = false; is_less_than(&i, &get_array_length(&symbols)) } {
9295 let mut symbol: Value = get_value(&symbols, &i);
9296 let mut symbol: Value = get_value(&symbols, &i);
9297 if is_equal(&topic, &Value::Str("trades".to_string())) {
9298 if is_true(&Value::Bool(in_op(&self.trades, &symbol))) {
9299 remove(&mut self.trades.clone(), &symbol);
9300 }
9301 } else if is_equal(&topic, &Value::Str("orderbook".to_string())) {
9302 if is_true(&Value::Bool(in_op(&self.orderbooks, &symbol))) {
9303 remove(&mut self.orderbooks.clone(), &symbol);
9304 }
9305 } else if is_equal(&topic, &Value::Str("ticker".to_string())) {
9306 if is_true(&Value::Bool(in_op(&self.tickers, &symbol))) {
9307 remove(&mut self.tickers.clone(), &symbol);
9308 }
9309 } else if is_equal(&topic, &Value::Str("bidsasks".to_string())) {
9310 if is_true(&Value::Bool(in_op(&self.bidsasks, &symbol))) {
9311 remove(&mut self.bidsasks.clone(), &symbol);
9312 }
9313 }
9314 }
9315 }
9316 } else {
9317 if is_equal(&topic, &Value::Str("myTrades".to_string())) && is_true(&(!is_equal(&self.myTrades, &Value::Null))) {
9318 self.myTrades = Value::Null;
9319 } else if is_equal(&topic, &Value::Str("orders".to_string())) && is_true(&(!is_equal(&self.orders, &Value::Null))) {
9320 self.orders = Value::Null;
9321 } else if is_equal(&topic, &Value::Str("positions".to_string())) && is_true(&(!is_equal(&self.positions, &Value::Null))) {
9322 self.positions = Value::Null;
9323 let mut clients: Value = object_values(&self.clients);
9324 {
9325 let mut i: Value = Value::Int(0);
9326 let mut __for_first_176: bool = true;
9327 while { if !__for_first_176 { i = add(&i, &Value::Int(1)); } __for_first_176 = false; is_less_than(&i, &get_array_length(&clients)) } {
9328 let mut client: Value = get_value(&clients, &i);
9329 let mut client: Value = get_value(&clients, &i);
9330 let mut futures: Value = get_value(&client, &Value::Str("futures".to_string()));
9331 if is_true(&(!is_equal(&futures, &Value::Null))) && is_true(&(Value::Bool(in_op(&futures, &Value::Str("fetchPositionsSnapshot".to_string()))))) {
9332 remove(&mut futures, &Value::Str("fetchPositionsSnapshot".to_string()));
9333 }
9334 }
9335 }
9336 } else if is_true(&(is_equal(&topic, &Value::Str("ticker".to_string())) || is_equal(&topic, &Value::Str("markPrice".to_string())))) && is_true(&(!is_equal(&self.tickers, &Value::Null))) {
9337 let mut tickerSymbols: Value = object_keys(&self.tickers);
9338 {
9339 let mut i: Value = Value::Int(0);
9340 let mut __for_first_177: bool = true;
9341 while { if !__for_first_177 { i = add(&i, &Value::Int(1)); } __for_first_177 = false; is_less_than(&i, &get_array_length(&tickerSymbols)) } {
9342 let mut tickerSymbol: Value = get_value(&tickerSymbols, &i);
9343 let mut tickerSymbol: Value = get_value(&tickerSymbols, &i);
9344 if is_true(&Value::Bool(in_op(&self.tickers, &tickerSymbol))) {
9345 remove(&mut self.tickers.clone(), &tickerSymbol);
9346 }
9347 }
9348 }
9349 } else if is_equal(&topic, &Value::Str("bidsasks".to_string())) && is_true(&(!is_equal(&self.bidsasks, &Value::Null))) {
9350 let mut bidsaskSymbols: Value = object_keys(&self.bidsasks);
9351 {
9352 let mut i: Value = Value::Int(0);
9353 let mut __for_first_178: bool = true;
9354 while { if !__for_first_178 { i = add(&i, &Value::Int(1)); } __for_first_178 = false; is_less_than(&i, &get_array_length(&bidsaskSymbols)) } {
9355 let mut bidsaskSymbol: Value = get_value(&bidsaskSymbols, &i);
9356 let mut bidsaskSymbol: Value = get_value(&bidsaskSymbols, &i);
9357 if is_true(&Value::Bool(in_op(&self.bidsasks, &bidsaskSymbol))) {
9358 remove(&mut self.bidsasks.clone(), &bidsaskSymbol);
9359 }
9360 }
9361 }
9362 }
9363 }
9364}
9365
9366 fn timeframe_from_milliseconds(&self, mut ms: Value) -> Value {
9367 if is_less_than_or_equal(&ms, &Value::Int(0)) {
9368 return Value::Str("".to_string());
9369 }
9370 let mut second: Value = Value::Int(1000);
9371 let mut minute: Value = multiply(&Value::Int(60), &second);
9372 let mut hour: Value = multiply(&Value::Int(60), &minute);
9373 let mut day: Value = multiply(&Value::Int(24), &hour);
9374 let mut week: Value = multiply(&Value::Int(7), &day);
9375 if is_equal(&mod_val(&ms, &week), &Value::Int(0)) {
9376 return add(&(divide(&ms, &week)), &Value::Str("w".to_string()));
9377 }
9378 if is_equal(&mod_val(&ms, &day), &Value::Int(0)) {
9379 return add(&(divide(&ms, &day)), &Value::Str("d".to_string()));
9380 }
9381 if is_equal(&mod_val(&ms, &hour), &Value::Int(0)) {
9382 return add(&(divide(&ms, &hour)), &Value::Str("h".to_string()));
9383 }
9384 if is_equal(&mod_val(&ms, &minute), &Value::Int(0)) {
9385 return add(&(divide(&ms, &minute)), &Value::Str("m".to_string()));
9386 }
9387 if is_equal(&mod_val(&ms, &second), &Value::Int(0)) {
9388 return add(&(divide(&ms, &second)), &Value::Str("s".to_string()));
9389 }
9390 return Value::Str("".to_string());
9391
9392 Value::Null
9393}
9394
9395 fn is_uta_enabled(&mut self, optional_args: &[Value]) -> impl ::std::future::Future<Output = Value> + Send { async move {
9396 let mut params = get_arg(optional_args, 0, Value::Map({
9397 let mut m = indexmap::IndexMap::new();
9398 m
9399}));
9400 return Value::Bool(false);
9401
9402 Value::Null
9403} }
9404 fn close_position(&mut self, mut symbol: Value, optional_args: &[Value]) -> impl ::std::future::Future<Output = Value> + Send { async move {
9405 let mut side = get_arg(optional_args, 0, Value::Null);
9406 let mut params = get_arg(optional_args, 1, Value::Map({
9407 let mut m = indexmap::IndexMap::new();
9408 m
9409}));
9410 panic!("{}", crate::exchange_errors::not_supported(add(&self.id, &Value::Str(" closePosition() is not supported yet".to_string()))));
9411
9412 Value::Null
9413} }
9414
9415 fn close_all_positions(&mut self, optional_args: &[Value]) -> impl ::std::future::Future<Output = Value> + Send { async move {
9416 let mut params = get_arg(optional_args, 0, Value::Map({
9417 let mut m = indexmap::IndexMap::new();
9418 m
9419}));
9420 panic!("{}", crate::exchange_errors::not_supported(add(&self.id, &Value::Str(" closeAllPositions() is not supported yet".to_string()))));
9421
9422 Value::Null
9423} }
9424
9425 fn edit_orders(&mut self, mut orders: Value, optional_args: &[Value]) -> impl ::std::future::Future<Output = Value> + Send { async move {
9426 let mut params = get_arg(optional_args, 0, Value::Map({
9427 let mut m = indexmap::IndexMap::new();
9428 m
9429}));
9430 panic!("{}", crate::exchange_errors::not_supported(add(&self.id, &Value::Str(" editOrders() is not supported yet".to_string()))));
9431
9432 Value::Null
9433} }
9434
9435 fn fetch_canceled_and_closed_orders(&mut self, optional_args: &[Value]) -> impl ::std::future::Future<Output = Value> + Send { async move {
9436 let mut symbol = get_arg(optional_args, 0, Value::Null);
9437 let mut since = get_arg(optional_args, 1, Value::Null);
9438 let mut limit = get_arg(optional_args, 2, Value::Null);
9439 let mut params = get_arg(optional_args, 3, Value::Map({
9440 let mut m = indexmap::IndexMap::new();
9441 m
9442}));
9443 panic!("{}", crate::exchange_errors::not_supported(add(&self.id, &Value::Str(" fetchCanceledAndClosedOrders() is not supported yet".to_string()))));
9444
9445 Value::Null
9446} }
9447
9448 fn fetch_position_history(&mut self, mut symbol: Value, optional_args: &[Value]) -> impl ::std::future::Future<Output = Value> + Send { async move {
9449 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 {
9451 if !matches!(__v, crate::Value::Null) { return __v; }
9452 }
9453
9454 let mut since = get_arg(optional_args, 0, Value::Null);
9455 let mut limit = get_arg(optional_args, 1, Value::Null);
9456 let mut params = get_arg(optional_args, 2, Value::Map({
9457 let mut m = indexmap::IndexMap::new();
9458 m
9459}));
9460 if !is_equal(&get_value(&self.has, &Value::Str("fetchPositionsHistory".to_string())), &Value::Null) && !is_equal(&get_value(&self.has, &Value::Str("fetchPositionsHistory".to_string())), &Value::Bool(false)) {
9471 let mut positions: Value = self.fetch_positions_history(&[Value::List(vec![symbol.clone()]), since.clone(), limit.clone(), params.clone()]).await;
9472 return positions;
9473 } else {
9474 panic!("{}", crate::exchange_errors::not_supported(add(&self.id, &Value::Str(" fetchPositionHistory () is not supported yet".to_string()))));
9475 }
9476} }
9477
9478 fn fetch_positions_history(&mut self, optional_args: &[Value]) -> impl ::std::future::Future<Output = Value> + Send { async move {
9479 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 {
9481 if !matches!(__v, crate::Value::Null) { return __v; }
9482 }
9483
9484 let mut symbols = get_arg(optional_args, 0, Value::Null);
9485 let mut since = get_arg(optional_args, 1, Value::Null);
9486 let mut limit = get_arg(optional_args, 2, Value::Null);
9487 let mut params = get_arg(optional_args, 3, Value::Map({
9488 let mut m = indexmap::IndexMap::new();
9489 m
9490}));
9491 panic!("{}", crate::exchange_errors::not_supported(add(&self.id, &Value::Str(" fetchPositionsHistory () is not supported yet".to_string()))));
9492
9493 Value::Null
9494} }
9495
9496 fn fetch_positions_risk(&mut self, optional_args: &[Value]) -> impl ::std::future::Future<Output = Value> + Send { async move {
9497 let mut symbols = get_arg(optional_args, 0, Value::Null);
9498 let mut params = get_arg(optional_args, 1, Value::Map({
9499 let mut m = indexmap::IndexMap::new();
9500 m
9501}));
9502 panic!("{}", crate::exchange_errors::not_supported(add(&self.id, &Value::Str(" fetchPositionsRisk() is not supported yet".to_string()))));
9503
9504 Value::Null
9505} }
9506
9507 fn fetch_positions_for_symbol(&mut self, mut symbol: Value, optional_args: &[Value]) -> impl ::std::future::Future<Output = Value> + Send { async move {
9508 let mut params = get_arg(optional_args, 0, Value::Map({
9509 let mut m = indexmap::IndexMap::new();
9510 m
9511}));
9512 panic!("{}", crate::exchange_errors::not_supported(add(&self.id, &Value::Str(" fetchPositionsForSymbol() is not supported yet".to_string()))));
9513
9514 Value::Null
9515} }
9516
9517 fn fetch_positions_for_symbol_ws(&mut self, mut symbol: Value, optional_args: &[Value]) -> impl ::std::future::Future<Output = Value> + Send { async move {
9518 let mut params = get_arg(optional_args, 0, Value::Map({
9519 let mut m = indexmap::IndexMap::new();
9520 m
9521}));
9522 panic!("{}", crate::exchange_errors::not_supported(add(&self.id, &Value::Str(" fetchPositionsForSymbol() is not supported yet".to_string()))));
9523
9524 Value::Null
9525} }
9526
9527 fn watch_position(&mut self, optional_args: &[Value]) -> impl ::std::future::Future<Output = Value> + Send { async move {
9528 let mut symbol = get_arg(optional_args, 0, Value::Null);
9529 let mut params = get_arg(optional_args, 1, Value::Map({
9530 let mut m = indexmap::IndexMap::new();
9531 m
9532}));
9533 panic!("{}", crate::exchange_errors::not_supported(add(&self.id, &Value::Str(" watchPosition() is not supported yet".to_string()))));
9534
9535 Value::Null
9536} }
9537
9538 fn watch_my_trades_for_symbols(&mut self, mut symbols: Value, optional_args: &[Value]) -> impl ::std::future::Future<Output = Value> + Send { async move {
9539 let mut since = get_arg(optional_args, 0, Value::Null);
9540 let mut limit = get_arg(optional_args, 1, Value::Null);
9541 let mut params = get_arg(optional_args, 2, Value::Map({
9542 let mut m = indexmap::IndexMap::new();
9543 m
9544}));
9545 panic!("{}", crate::exchange_errors::not_supported(add(&self.id, &Value::Str(" watchMyTradesForSymbols() is not supported yet".to_string()))));
9546
9547 Value::Null
9548} }
9549
9550 fn watch_trades_for_symbols(&mut self, mut symbols: Value, optional_args: &[Value]) -> impl ::std::future::Future<Output = Value> + Send { async move {
9551 let mut since = get_arg(optional_args, 0, Value::Null);
9552 let mut limit = get_arg(optional_args, 1, Value::Null);
9553 let mut params = get_arg(optional_args, 2, Value::Map({
9554 let mut m = indexmap::IndexMap::new();
9555 m
9556}));
9557 panic!("{}", crate::exchange_errors::not_supported(add(&self.id, &Value::Str(" watchTradesForSymbols() is not supported yet".to_string()))));
9558
9559 Value::Null
9560} }
9561
9562 fn fetch_bids_asks(&mut self, optional_args: &[Value]) -> impl ::std::future::Future<Output = Value> + Send { async move {
9563 let mut symbols = get_arg(optional_args, 0, Value::Null);
9564 let mut params = get_arg(optional_args, 1, Value::Map({
9565 let mut m = indexmap::IndexMap::new();
9566 m
9567}));
9568 panic!("{}", crate::exchange_errors::not_supported(add(&self.id, &Value::Str(" fetchBidsAsks() is not supported yet".to_string()))));
9569
9570 Value::Null
9571} }
9572
9573 fn fetch_mark_price(&mut self, mut symbol: Value, optional_args: &[Value]) -> impl ::std::future::Future<Output = Value> + Send { async move {
9574 let mut params = get_arg(optional_args, 0, Value::Map({
9575 let mut m = indexmap::IndexMap::new();
9576 m
9577}));
9578 if !is_equal(&get_value(&self.has, &Value::Str("fetchMarkPrices".to_string())), &Value::Null) && !is_equal(&get_value(&self.has, &Value::Str("fetchMarkPrices".to_string())), &Value::Bool(false)) {
9579 self.load_markets(&[]).await;
9580 let mut market: Value = self.market(symbol.clone());
9581 symbol = get_value(&market, &Value::Str("symbol".to_string()));
9582 let mut tickers: Value = self.fetch_mark_prices(&[Value::List(vec![symbol.clone()]), params.clone()]).await;
9583 let mut ticker: Value = self.safe_dict(tickers.clone(), symbol.clone(), &[]);
9584 if is_equal(&ticker, &Value::Null) {
9585 panic!("{}", crate::exchange_errors::null_response(add(&add(&self.id, &Value::Str(" fetchMarkPrices() could not find a ticker for ".to_string())), &symbol)));
9586 } else {
9587 return ticker;
9588 }
9589 } else {
9590 panic!("{}", crate::exchange_errors::not_supported(add(&self.id, &Value::Str(" fetchMarkPrices() is not supported yet".to_string()))));
9591 }
9592
9593 Value::Null
9594} }
9595
9596 fn fetch_mark_prices(&mut self, optional_args: &[Value]) -> impl ::std::future::Future<Output = Value> + Send { async move {
9597 let mut symbols = get_arg(optional_args, 0, Value::Null);
9598 let mut params = get_arg(optional_args, 1, Value::Map({
9599 let mut m = indexmap::IndexMap::new();
9600 m
9601}));
9602 panic!("{}", crate::exchange_errors::not_supported(add(&self.id, &Value::Str(" fetchMarkPrices() is not supported yet".to_string()))));
9603
9604 Value::Null
9605} }
9606
9607 fn watch_bids_asks(&mut self, optional_args: &[Value]) -> impl ::std::future::Future<Output = Value> + Send { async move {
9608 let mut symbols = get_arg(optional_args, 0, Value::Null);
9609 let mut params = get_arg(optional_args, 1, Value::Map({
9610 let mut m = indexmap::IndexMap::new();
9611 m
9612}));
9613 panic!("{}", crate::exchange_errors::not_supported(add(&self.id, &Value::Str(" watchBidsAsks() is not supported yet".to_string()))));
9614
9615 Value::Null
9616} }
9617
9618 fn watch_mark_price(&mut self, mut symbol: Value, optional_args: &[Value]) -> impl ::std::future::Future<Output = Value> + Send { async move {
9619 let mut params = get_arg(optional_args, 0, Value::Map({
9620 let mut m = indexmap::IndexMap::new();
9621 m
9622}));
9623 panic!("{}", crate::exchange_errors::not_supported(add(&self.id, &Value::Str(" watchMarkPrice () is not supported yet".to_string()))));
9624
9625 Value::Null
9626} }
9627
9628 fn watch_mark_prices(&mut self, optional_args: &[Value]) -> impl ::std::future::Future<Output = Value> + Send { async move {
9629 let mut symbols = get_arg(optional_args, 0, Value::Null);
9630 let mut params = get_arg(optional_args, 1, Value::Map({
9631 let mut m = indexmap::IndexMap::new();
9632 m
9633}));
9634 panic!("{}", crate::exchange_errors::not_supported(add(&self.id, &Value::Str(" watchMarkPrices () is not supported yet".to_string()))));
9635
9636 Value::Null
9637} }
9638
9639 fn fetch_l3_order_book(&mut self, mut symbol: Value, optional_args: &[Value]) -> impl ::std::future::Future<Output = Value> + Send { async move {
9640 let mut limit = get_arg(optional_args, 0, Value::Null);
9641 let mut params = get_arg(optional_args, 1, Value::Map({
9642 let mut m = indexmap::IndexMap::new();
9643 m
9644}));
9645 panic!("{}", crate::exchange_errors::bad_request(add(&self.id, &Value::Str(" fetchL3OrderBook() is not supported yet".to_string()))));
9646
9647 Value::Null
9648} }
9649
9650 fn watch_order_book_for_symbols(&mut self, mut symbols: Value, optional_args: &[Value]) -> impl ::std::future::Future<Output = Value> + Send { async move {
9651 let mut limit = get_arg(optional_args, 0, Value::Null);
9652 let mut params = get_arg(optional_args, 1, Value::Map({
9653 let mut m = indexmap::IndexMap::new();
9654 m
9655}));
9656 panic!("{}", crate::exchange_errors::not_supported(add(&self.id, &Value::Str(" watchOrderBookForSymbols() is not supported yet".to_string()))));
9657
9658 Value::Null
9659} }
9660
9661 fn watch_orders_for_symbols(&mut self, mut symbols: Value, optional_args: &[Value]) -> impl ::std::future::Future<Output = Value> + Send { async move {
9662 let mut since = get_arg(optional_args, 0, Value::Null);
9663 let mut limit = get_arg(optional_args, 1, Value::Null);
9664 let mut params = get_arg(optional_args, 2, Value::Map({
9665 let mut m = indexmap::IndexMap::new();
9666 m
9667}));
9668 panic!("{}", crate::exchange_errors::not_supported(add(&self.id, &Value::Str(" watchOrdersForSymbols() is not supported yet".to_string()))));
9669
9670 Value::Null
9671} }
9672
9673 fn cancel_all_orders_ws(&mut self, optional_args: &[Value]) -> impl ::std::future::Future<Output = Value> + Send { async move {
9674 let mut symbol = get_arg(optional_args, 0, Value::Null);
9675 let mut params = get_arg(optional_args, 1, Value::Map({
9676 let mut m = indexmap::IndexMap::new();
9677 m
9678}));
9679 panic!("{}", crate::exchange_errors::not_supported(add(&self.id, &Value::Str(" cancelAllOrdersWs() is not supported yet".to_string()))));
9680
9681 Value::Null
9682} }
9683
9684 fn cancel_order_ws(&mut self, mut id: Value, optional_args: &[Value]) -> impl ::std::future::Future<Output = Value> + Send { async move {
9685 let mut symbol = get_arg(optional_args, 0, Value::Null);
9686 let mut params = get_arg(optional_args, 1, Value::Map({
9687 let mut m = indexmap::IndexMap::new();
9688 m
9689}));
9690 panic!("{}", crate::exchange_errors::not_supported(add(&self.id, &Value::Str(" cancelOrderWs() is not supported yet".to_string()))));
9691
9692 Value::Null
9693} }
9694
9695 fn cancel_orders_ws(&mut self, mut ids: Value, optional_args: &[Value]) -> impl ::std::future::Future<Output = Value> + Send { async move {
9696 let mut symbol = get_arg(optional_args, 0, Value::Null);
9697 let mut params = get_arg(optional_args, 1, Value::Map({
9698 let mut m = indexmap::IndexMap::new();
9699 m
9700}));
9701 panic!("{}", crate::exchange_errors::not_supported(add(&self.id, &Value::Str(" cancelOrdersWs() is not supported yet".to_string()))));
9702
9703 Value::Null
9704} }
9705
9706 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 {
9707 let mut params = get_arg(optional_args, 0, Value::Map({
9708 let mut m = indexmap::IndexMap::new();
9709 m
9710}));
9711 return self.create_order_ws(symbol.clone(), Value::Str("limit".to_string()), Value::Str("buy".to_string()), amount.clone(), &[price.clone(), params.clone()]).await;
9712
9713 Value::Null
9714} }
9715
9716 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 {
9717 let mut params = get_arg(optional_args, 0, Value::Map({
9718 let mut m = indexmap::IndexMap::new();
9719 m
9720}));
9721 return self.create_order_ws(symbol.clone(), Value::Str("limit".to_string()), side.clone(), amount.clone(), &[price.clone(), params.clone()]).await;
9722
9723 Value::Null
9724} }
9725
9726 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 {
9727 let mut params = get_arg(optional_args, 0, Value::Map({
9728 let mut m = indexmap::IndexMap::new();
9729 m
9730}));
9731 return self.create_order_ws(symbol.clone(), Value::Str("limit".to_string()), Value::Str("sell".to_string()), amount.clone(), &[price.clone(), params.clone()]).await;
9732
9733 Value::Null
9734} }
9735
9736 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 {
9737 let mut params = get_arg(optional_args, 0, Value::Map({
9738 let mut m = indexmap::IndexMap::new();
9739 m
9740}));
9741 return self.create_order_ws(symbol.clone(), Value::Str("market".to_string()), Value::Str("buy".to_string()), amount.clone(), &[Value::Null, params.clone()]).await;
9742
9743 Value::Null
9744} }
9745
9746 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 {
9747 let mut params = get_arg(optional_args, 0, Value::Map({
9748 let mut m = indexmap::IndexMap::new();
9749 m
9750}));
9751 if is_true(&(!is_equal(&get_value(&self.has, &Value::Str("createMarketOrderWithCostWs".to_string())), &Value::Null) && !is_equal(&get_value(&self.has, &Value::Str("createMarketOrderWithCostWs".to_string())), &Value::Bool(false)))) || is_true(&(is_true(&(!is_equal(&get_value(&self.has, &Value::Str("createMarketBuyOrderWithCostWs".to_string())), &Value::Null) && !is_equal(&get_value(&self.has, &Value::Str("createMarketBuyOrderWithCostWs".to_string())), &Value::Bool(false)))) && is_true(&(!is_equal(&get_value(&self.has, &Value::Str("createMarketSellOrderWithCostWs".to_string())), &Value::Null) && !is_equal(&get_value(&self.has, &Value::Str("createMarketSellOrderWithCostWs".to_string())), &Value::Bool(false)))))) {
9762 return self.create_order_ws(symbol.clone(), Value::Str("market".to_string()), side.clone(), cost.clone(), &[Value::Int(1), params.clone()]).await;
9763 }
9764 panic!("{}", crate::exchange_errors::not_supported(add(&self.id, &Value::Str(" createMarketOrderWithCostWs() is not supported yet".to_string()))));
9765
9766 Value::Null
9767} }
9768
9769 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 {
9770 let mut price = get_arg(optional_args, 0, Value::Null);
9771 let mut params = get_arg(optional_args, 1, Value::Map({
9772 let mut m = indexmap::IndexMap::new();
9773 m
9774}));
9775 return self.create_order_ws(symbol.clone(), Value::Str("market".to_string()), side.clone(), amount.clone(), &[price.clone(), params.clone()]).await;
9776
9777 Value::Null
9778} }
9779
9780 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 {
9781 let mut params = get_arg(optional_args, 0, Value::Map({
9782 let mut m = indexmap::IndexMap::new();
9783 m
9784}));
9785 return self.create_order_ws(symbol.clone(), Value::Str("market".to_string()), Value::Str("sell".to_string()), amount.clone(), &[Value::Null, params.clone()]).await;
9786
9787 Value::Null
9788} }
9789
9790 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 {
9791 let mut price = get_arg(optional_args, 0, Value::Null);
9792 let mut takeProfit = get_arg(optional_args, 1, Value::Null);
9793 let mut stopLoss = get_arg(optional_args, 2, Value::Null);
9794 let mut params = get_arg(optional_args, 3, Value::Map({
9795 let mut m = indexmap::IndexMap::new();
9796 m
9797}));
9798 params = self.set_take_profit_and_stop_loss_params(symbol.clone(), type_var.clone(), side.clone(), amount.clone(), &[price.clone(), takeProfit.clone(), stopLoss.clone(), params.clone()]);
9821 if !is_equal(&get_value(&self.has, &Value::Str("createOrderWithTakeProfitAndStopLossWs".to_string())), &Value::Null) && !is_equal(&get_value(&self.has, &Value::Str("createOrderWithTakeProfitAndStopLossWs".to_string())), &Value::Bool(false)) {
9822 return self.create_order_ws(symbol.clone(), type_var.clone(), side.clone(), amount.clone(), &[price.clone(), params.clone()]).await;
9823 }
9824 panic!("{}", crate::exchange_errors::not_supported(add(&self.id, &Value::Str(" createOrderWithTakeProfitAndStopLossWs() is not supported yet".to_string()))));
9825
9826 Value::Null
9827} }
9828
9829 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 {
9830 let mut price = get_arg(optional_args, 0, Value::Null);
9831 let mut params = get_arg(optional_args, 1, Value::Map({
9832 let mut m = indexmap::IndexMap::new();
9833 m
9834}));
9835 panic!("{}", crate::exchange_errors::not_supported(add(&self.id, &Value::Str(" createOrderWs() is not supported yet".to_string()))));
9836
9837 Value::Null
9838} }
9839
9840 fn create_orders_ws(&mut self, mut orders: Value, optional_args: &[Value]) -> impl ::std::future::Future<Output = Value> + Send { async move {
9841 let mut params = get_arg(optional_args, 0, Value::Map({
9842 let mut m = indexmap::IndexMap::new();
9843 m
9844}));
9845 panic!("{}", crate::exchange_errors::not_supported(add(&self.id, &Value::Str(" createOrdersWs () is not supported yet".to_string()))));
9846
9847 Value::Null
9848} }
9849
9850 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 {
9851 let mut price = get_arg(optional_args, 0, Value::Null);
9852 let mut params = get_arg(optional_args, 1, Value::Map({
9853 let mut m = indexmap::IndexMap::new();
9854 m
9855}));
9856 if is_equal(&get_value(&self.has, &Value::Str("createPostOnlyOrderWs".to_string())), &Value::Null) || is_equal(&get_value(&self.has, &Value::Str("createPostOnlyOrderWs".to_string())), &Value::Bool(false)) {
9857 panic!("{}", crate::exchange_errors::not_supported(add(&self.id, &Value::Str(" createPostOnlyOrderWs() is not supported yet".to_string()))));
9858 }
9859 let mut query: Value = self.extend(params.clone(), &[Value::Map({
9860 let mut m = indexmap::IndexMap::new();
9861 m.insert("postOnly".to_string(), Value::Bool(true));
9862 m
9863 })]);
9864 return self.create_order_ws(symbol.clone(), type_var.clone(), side.clone(), amount.clone(), &[price.clone(), query.clone()]).await;
9865
9866 Value::Null
9867} }
9868
9869 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 {
9870 let mut price = get_arg(optional_args, 0, Value::Null);
9871 let mut params = get_arg(optional_args, 1, Value::Map({
9872 let mut m = indexmap::IndexMap::new();
9873 m
9874}));
9875 if is_equal(&get_value(&self.has, &Value::Str("createReduceOnlyOrderWs".to_string())), &Value::Null) || is_equal(&get_value(&self.has, &Value::Str("createReduceOnlyOrderWs".to_string())), &Value::Bool(false)) {
9876 panic!("{}", crate::exchange_errors::not_supported(add(&self.id, &Value::Str(" createReduceOnlyOrderWs() is not supported yet".to_string()))));
9877 }
9878 let mut query: Value = self.extend(params.clone(), &[Value::Map({
9879 let mut m = indexmap::IndexMap::new();
9880 m.insert("reduceOnly".to_string(), Value::Bool(true));
9881 m
9882 })]);
9883 return self.create_order_ws(symbol.clone(), type_var.clone(), side.clone(), amount.clone(), &[price.clone(), query.clone()]).await;
9884
9885 Value::Null
9886} }
9887
9888 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 {
9889 let mut params = get_arg(optional_args, 0, Value::Map({
9890 let mut m = indexmap::IndexMap::new();
9891 m
9892}));
9893 if is_equal(&get_value(&self.has, &Value::Str("createStopLimitOrderWs".to_string())), &Value::Null) || is_equal(&get_value(&self.has, &Value::Str("createStopLimitOrderWs".to_string())), &Value::Bool(false)) {
9894 panic!("{}", crate::exchange_errors::not_supported(add(&self.id, &Value::Str(" createStopLimitOrderWs() is not supported yet".to_string()))));
9895 }
9896 let mut query: Value = self.extend(params.clone(), &[Value::Map({
9897 let mut m = indexmap::IndexMap::new();
9898 m.insert("stopPrice".to_string(), triggerPrice.clone());
9899 m
9900 })]);
9901 return self.create_order_ws(symbol.clone(), Value::Str("limit".to_string()), side.clone(), amount.clone(), &[price.clone(), query.clone()]).await;
9902
9903 Value::Null
9904} }
9905
9906 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 {
9907 let mut price = get_arg(optional_args, 0, Value::Null);
9908 let mut stopLossPrice = get_arg(optional_args, 1, Value::Null);
9909 let mut params = get_arg(optional_args, 2, Value::Map({
9910 let mut m = indexmap::IndexMap::new();
9911 m
9912}));
9913 if is_equal(&stopLossPrice, &Value::Null) {
9927 panic!("{}", crate::exchange_errors::arguments_required(add(&self.id, &Value::Str(" createStopLossOrderWs() requires a stopLossPrice argument".to_string()))));
9928 }
9929 params = self.extend(params.clone(), &[Value::Map({
9930 let mut m = indexmap::IndexMap::new();
9931 m.insert("stopLossPrice".to_string(), stopLossPrice.clone());
9932 m
9933 })]);
9934 if !is_equal(&get_value(&self.has, &Value::Str("createStopLossOrderWs".to_string())), &Value::Null) && !is_equal(&get_value(&self.has, &Value::Str("createStopLossOrderWs".to_string())), &Value::Bool(false)) {
9935 return self.create_order_ws(symbol.clone(), type_var.clone(), side.clone(), amount.clone(), &[price.clone(), params.clone()]).await;
9936 }
9937 panic!("{}", crate::exchange_errors::not_supported(add(&self.id, &Value::Str(" createStopLossOrderWs() is not supported yet".to_string()))));
9938
9939 Value::Null
9940} }
9941
9942 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 {
9943 let mut params = get_arg(optional_args, 0, Value::Map({
9944 let mut m = indexmap::IndexMap::new();
9945 m
9946}));
9947 if is_equal(&get_value(&self.has, &Value::Str("createStopMarketOrderWs".to_string())), &Value::Null) || is_equal(&get_value(&self.has, &Value::Str("createStopMarketOrderWs".to_string())), &Value::Bool(false)) {
9948 panic!("{}", crate::exchange_errors::not_supported(add(&self.id, &Value::Str(" createStopMarketOrderWs() is not supported yet".to_string()))));
9949 }
9950 let mut query: Value = self.extend(params.clone(), &[Value::Map({
9951 let mut m = indexmap::IndexMap::new();
9952 m.insert("stopPrice".to_string(), triggerPrice.clone());
9953 m
9954 })]);
9955 return self.create_order_ws(symbol.clone(), Value::Str("market".to_string()), side.clone(), amount.clone(), &[Value::Null, query.clone()]).await;
9956
9957 Value::Null
9958} }
9959
9960 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 {
9961 let mut price = get_arg(optional_args, 0, Value::Null);
9962 let mut triggerPrice = get_arg(optional_args, 1, Value::Null);
9963 let mut params = get_arg(optional_args, 2, Value::Map({
9964 let mut m = indexmap::IndexMap::new();
9965 m
9966}));
9967 if is_equal(&get_value(&self.has, &Value::Str("createStopOrderWs".to_string())), &Value::Null) || is_equal(&get_value(&self.has, &Value::Str("createStopOrderWs".to_string())), &Value::Bool(false)) {
9968 panic!("{}", crate::exchange_errors::not_supported(add(&self.id, &Value::Str(" createStopOrderWs() is not supported yet".to_string()))));
9969 }
9970 if is_equal(&triggerPrice, &Value::Null) {
9971 panic!("{}", crate::exchange_errors::arguments_required(add(&self.id, &Value::Str(" createStopOrderWs() requires a stopPrice argument".to_string()))));
9972 }
9973 let mut query: Value = self.extend(params.clone(), &[Value::Map({
9974 let mut m = indexmap::IndexMap::new();
9975 m.insert("stopPrice".to_string(), triggerPrice.clone());
9976 m
9977 })]);
9978 return self.create_order_ws(symbol.clone(), type_var.clone(), side.clone(), amount.clone(), &[price.clone(), query.clone()]).await;
9979
9980 Value::Null
9981} }
9982
9983 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 {
9984 let mut price = get_arg(optional_args, 0, Value::Null);
9985 let mut takeProfitPrice = get_arg(optional_args, 1, Value::Null);
9986 let mut params = get_arg(optional_args, 2, Value::Map({
9987 let mut m = indexmap::IndexMap::new();
9988 m
9989}));
9990 if is_equal(&takeProfitPrice, &Value::Null) {
10004 panic!("{}", crate::exchange_errors::arguments_required(add(&self.id, &Value::Str(" createTakeProfitOrderWs() requires a takeProfitPrice argument".to_string()))));
10005 }
10006 params = self.extend(params.clone(), &[Value::Map({
10007 let mut m = indexmap::IndexMap::new();
10008 m.insert("takeProfitPrice".to_string(), takeProfitPrice.clone());
10009 m
10010 })]);
10011 if !is_equal(&get_value(&self.has, &Value::Str("createTakeProfitOrderWs".to_string())), &Value::Null) && !is_equal(&get_value(&self.has, &Value::Str("createTakeProfitOrderWs".to_string())), &Value::Bool(false)) {
10012 return self.create_order_ws(symbol.clone(), type_var.clone(), side.clone(), amount.clone(), &[price.clone(), params.clone()]).await;
10013 }
10014 panic!("{}", crate::exchange_errors::not_supported(add(&self.id, &Value::Str(" createTakeProfitOrderWs() is not supported yet".to_string()))));
10015
10016 Value::Null
10017} }
10018
10019 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 {
10020 let mut price = get_arg(optional_args, 0, Value::Null);
10021 let mut trailingAmount = get_arg(optional_args, 1, Value::Null);
10022 let mut trailingTriggerPrice = get_arg(optional_args, 2, Value::Null);
10023 let mut params = get_arg(optional_args, 3, Value::Map({
10024 let mut m = indexmap::IndexMap::new();
10025 m
10026}));
10027 if is_equal(&trailingAmount, &Value::Null) {
10042 panic!("{}", crate::exchange_errors::arguments_required(add(&self.id, &Value::Str(" createTrailingAmountOrderWs() requires a trailingAmount argument".to_string()))));
10043 }
10044 add_element_to_object(&mut params, &Value::Str("trailingAmount".to_string()), trailingAmount.clone());
10045 if !is_equal(&trailingTriggerPrice, &Value::Null) {
10046 add_element_to_object(&mut params, &Value::Str("trailingTriggerPrice".to_string()), trailingTriggerPrice.clone());
10047 }
10048 if !is_equal(&get_value(&self.has, &Value::Str("createTrailingAmountOrderWs".to_string())), &Value::Null) && !is_equal(&get_value(&self.has, &Value::Str("createTrailingAmountOrderWs".to_string())), &Value::Bool(false)) {
10049 return self.create_order_ws(symbol.clone(), type_var.clone(), side.clone(), amount.clone(), &[price.clone(), params.clone()]).await;
10050 }
10051 panic!("{}", crate::exchange_errors::not_supported(add(&self.id, &Value::Str(" createTrailingAmountOrderWs() is not supported yet".to_string()))));
10052
10053 Value::Null
10054} }
10055
10056 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 {
10057 let mut price = get_arg(optional_args, 0, Value::Null);
10058 let mut trailingPercent = get_arg(optional_args, 1, Value::Null);
10059 let mut trailingTriggerPrice = get_arg(optional_args, 2, Value::Null);
10060 let mut params = get_arg(optional_args, 3, Value::Map({
10061 let mut m = indexmap::IndexMap::new();
10062 m
10063}));
10064 if is_equal(&trailingPercent, &Value::Null) {
10079 panic!("{}", crate::exchange_errors::arguments_required(add(&self.id, &Value::Str(" createTrailingPercentOrderWs() requires a trailingPercent argument".to_string()))));
10080 }
10081 add_element_to_object(&mut params, &Value::Str("trailingPercent".to_string()), trailingPercent.clone());
10082 if !is_equal(&trailingTriggerPrice, &Value::Null) {
10083 add_element_to_object(&mut params, &Value::Str("trailingTriggerPrice".to_string()), trailingTriggerPrice.clone());
10084 }
10085 if !is_equal(&get_value(&self.has, &Value::Str("createTrailingPercentOrderWs".to_string())), &Value::Null) && !is_equal(&get_value(&self.has, &Value::Str("createTrailingPercentOrderWs".to_string())), &Value::Bool(false)) {
10086 return self.create_order_ws(symbol.clone(), type_var.clone(), side.clone(), amount.clone(), &[price.clone(), params.clone()]).await;
10087 }
10088 panic!("{}", crate::exchange_errors::not_supported(add(&self.id, &Value::Str(" createTrailingPercentOrderWs() is not supported yet".to_string()))));
10089
10090 Value::Null
10091} }
10092
10093 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 {
10094 let mut price = get_arg(optional_args, 0, Value::Null);
10095 let mut triggerPrice = get_arg(optional_args, 1, Value::Null);
10096 let mut params = get_arg(optional_args, 2, Value::Map({
10097 let mut m = indexmap::IndexMap::new();
10098 m
10099}));
10100 if is_equal(&triggerPrice, &Value::Null) {
10114 panic!("{}", crate::exchange_errors::arguments_required(add(&self.id, &Value::Str(" createTriggerOrderWs() requires a triggerPrice argument".to_string()))));
10115 }
10116 params = self.extend(params.clone(), &[Value::Map({
10117 let mut m = indexmap::IndexMap::new();
10118 m.insert("triggerPrice".to_string(), triggerPrice.clone());
10119 m
10120 })]);
10121 if !is_equal(&get_value(&self.has, &Value::Str("createTriggerOrderWs".to_string())), &Value::Null) && !is_equal(&get_value(&self.has, &Value::Str("createTriggerOrderWs".to_string())), &Value::Bool(false)) {
10122 return self.create_order_ws(symbol.clone(), type_var.clone(), side.clone(), amount.clone(), &[price.clone(), params.clone()]).await;
10123 }
10124 panic!("{}", crate::exchange_errors::not_supported(add(&self.id, &Value::Str(" createTriggerOrderWs() is not supported yet".to_string()))));
10125
10126 Value::Null
10127} }
10128
10129 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 {
10130 let mut amount = get_arg(optional_args, 0, Value::Null);
10131 let mut price = get_arg(optional_args, 1, Value::Null);
10132 let mut params = get_arg(optional_args, 2, Value::Map({
10133 let mut m = indexmap::IndexMap::new();
10134 m
10135}));
10136 self.cancel_order_ws(id.clone(), &[symbol.clone()]).await;
10137 return self.create_order_ws(symbol.clone(), type_var.clone(), side.clone(), amount.clone(), &[price.clone(), params.clone()]).await;
10138
10139 Value::Null
10140} }
10141
10142 fn fetch_closed_orders_ws(&mut self, optional_args: &[Value]) -> impl ::std::future::Future<Output = Value> + Send { async move {
10143 let mut symbol = get_arg(optional_args, 0, Value::Null);
10144 let mut since = get_arg(optional_args, 1, Value::Null);
10145 let mut limit = get_arg(optional_args, 2, Value::Null);
10146 let mut params = get_arg(optional_args, 3, Value::Map({
10147 let mut m = indexmap::IndexMap::new();
10148 m
10149}));
10150 if !is_equal(&get_value(&self.has, &Value::Str("fetchOrdersWs".to_string())), &Value::Null) && !is_equal(&get_value(&self.has, &Value::Str("fetchOrdersWs".to_string())), &Value::Bool(false)) {
10151 let mut orders: Value = self.fetch_orders_ws(&[symbol.clone(), since.clone(), limit.clone(), params.clone()]).await;
10152 return self.filter_by(orders.clone(), Value::Str("status".to_string()), Value::Str("closed".to_string()), &[]);
10153 }
10154 panic!("{}", crate::exchange_errors::not_supported(add(&self.id, &Value::Str(" fetchClosedOrdersWs() is not supported yet".to_string()))));
10155
10156 Value::Null
10157} }
10158
10159 fn fetch_my_trades_ws(&mut self, optional_args: &[Value]) -> impl ::std::future::Future<Output = Value> + Send { async move {
10160 let mut symbol = get_arg(optional_args, 0, Value::Null);
10161 let mut since = get_arg(optional_args, 1, Value::Null);
10162 let mut limit = get_arg(optional_args, 2, Value::Null);
10163 let mut params = get_arg(optional_args, 3, Value::Map({
10164 let mut m = indexmap::IndexMap::new();
10165 m
10166}));
10167 panic!("{}", crate::exchange_errors::not_supported(add(&self.id, &Value::Str(" fetchMyTradesWs() is not supported yet".to_string()))));
10168
10169 Value::Null
10170} }
10171
10172 fn fetch_open_orders_ws(&mut self, optional_args: &[Value]) -> impl ::std::future::Future<Output = Value> + Send { async move {
10173 let mut symbol = get_arg(optional_args, 0, Value::Null);
10174 let mut since = get_arg(optional_args, 1, Value::Null);
10175 let mut limit = get_arg(optional_args, 2, Value::Null);
10176 let mut params = get_arg(optional_args, 3, Value::Map({
10177 let mut m = indexmap::IndexMap::new();
10178 m
10179}));
10180 if !is_equal(&get_value(&self.has, &Value::Str("fetchOrdersWs".to_string())), &Value::Null) && !is_equal(&get_value(&self.has, &Value::Str("fetchOrdersWs".to_string())), &Value::Bool(false)) {
10181 let mut orders: Value = self.fetch_orders_ws(&[symbol.clone(), since.clone(), limit.clone(), params.clone()]).await;
10182 return self.filter_by(orders.clone(), Value::Str("status".to_string()), Value::Str("open".to_string()), &[]);
10183 }
10184 panic!("{}", crate::exchange_errors::not_supported(add(&self.id, &Value::Str(" fetchOpenOrdersWs() is not supported yet".to_string()))));
10185
10186 Value::Null
10187} }
10188
10189 fn fetch_order_book_ws(&mut self, mut symbol: Value, optional_args: &[Value]) -> impl ::std::future::Future<Output = Value> + Send { async move {
10190 let mut limit = get_arg(optional_args, 0, Value::Null);
10191 let mut params = get_arg(optional_args, 1, Value::Map({
10192 let mut m = indexmap::IndexMap::new();
10193 m
10194}));
10195 panic!("{}", crate::exchange_errors::not_supported(add(&self.id, &Value::Str(" fetchOrderBookWs() is not supported yet".to_string()))));
10196
10197 Value::Null
10198} }
10199
10200 fn fetch_order_ws(&mut self, mut id: Value, optional_args: &[Value]) -> impl ::std::future::Future<Output = Value> + Send { async move {
10201 let mut symbol = get_arg(optional_args, 0, Value::Null);
10202 let mut params = get_arg(optional_args, 1, Value::Map({
10203 let mut m = indexmap::IndexMap::new();
10204 m
10205}));
10206 panic!("{}", crate::exchange_errors::not_supported(add(&self.id, &Value::Str(" fetchOrderWs() is not supported yet".to_string()))));
10207
10208 Value::Null
10209} }
10210
10211 fn fetch_orders_ws(&mut self, optional_args: &[Value]) -> impl ::std::future::Future<Output = Value> + Send { async move {
10212 let mut symbol = get_arg(optional_args, 0, Value::Null);
10213 let mut since = get_arg(optional_args, 1, Value::Null);
10214 let mut limit = get_arg(optional_args, 2, Value::Null);
10215 let mut params = get_arg(optional_args, 3, Value::Map({
10216 let mut m = indexmap::IndexMap::new();
10217 m
10218}));
10219 panic!("{}", crate::exchange_errors::not_supported(add(&self.id, &Value::Str(" fetchOrdersWs() is not supported yet".to_string()))));
10220
10221 Value::Null
10222} }
10223
10224 fn fetch_position_ws(&mut self, mut symbol: Value, optional_args: &[Value]) -> impl ::std::future::Future<Output = Value> + Send { async move {
10225 let mut params = get_arg(optional_args, 0, Value::Map({
10226 let mut m = indexmap::IndexMap::new();
10227 m
10228}));
10229 panic!("{}", crate::exchange_errors::not_supported(add(&self.id, &Value::Str(" fetchPositionWs() is not supported yet".to_string()))));
10230
10231 Value::Null
10232} }
10233
10234 fn fetch_positions_ws(&mut self, optional_args: &[Value]) -> impl ::std::future::Future<Output = Value> + Send { async move {
10235 let mut symbols = get_arg(optional_args, 0, Value::Null);
10236 let mut params = get_arg(optional_args, 1, Value::Map({
10237 let mut m = indexmap::IndexMap::new();
10238 m
10239}));
10240 panic!("{}", crate::exchange_errors::not_supported(add(&self.id, &Value::Str(" fetchPositions() is not supported yet".to_string()))));
10241
10242 Value::Null
10243} }
10244
10245 fn fetch_ticker_ws(&mut self, mut symbol: Value, optional_args: &[Value]) -> impl ::std::future::Future<Output = Value> + Send { async move {
10246 let mut params = get_arg(optional_args, 0, Value::Map({
10247 let mut m = indexmap::IndexMap::new();
10248 m
10249}));
10250 if !is_equal(&get_value(&self.has, &Value::Str("fetchTickersWs".to_string())), &Value::Null) && !is_equal(&get_value(&self.has, &Value::Str("fetchTickersWs".to_string())), &Value::Bool(false)) {
10251 self.load_markets(&[]).await;
10252 let mut market: Value = self.market(symbol.clone());
10253 symbol = get_value(&market, &Value::Str("symbol".to_string()));
10254 let mut tickers: Value = self.fetch_tickers_ws(&[Value::List(vec![symbol.clone()]), params.clone()]).await;
10255 let mut ticker: Value = self.safe_dict(tickers.clone(), symbol.clone(), &[]);
10256 if is_equal(&ticker, &Value::Null) {
10257 panic!("{}", crate::exchange_errors::null_response(add(&add(&self.id, &Value::Str(" fetchTickerWs() could not find a ticker for ".to_string())), &symbol)));
10258 } else {
10259 return ticker;
10260 }
10261 } else {
10262 panic!("{}", crate::exchange_errors::not_supported(add(&self.id, &Value::Str(" fetchTickerWs() is not supported yet".to_string()))));
10263 }
10264
10265 Value::Null
10266} }
10267
10268 fn fetch_tickers_ws(&mut self, optional_args: &[Value]) -> impl ::std::future::Future<Output = Value> + Send { async move {
10269 let mut symbols = get_arg(optional_args, 0, Value::Null);
10270 let mut params = get_arg(optional_args, 1, Value::Map({
10271 let mut m = indexmap::IndexMap::new();
10272 m
10273}));
10274 panic!("{}", crate::exchange_errors::not_supported(add(&self.id, &Value::Str(" fetchTickersWs() is not supported yet".to_string()))));
10275
10276 Value::Null
10277} }
10278
10279 fn fetch_trades_ws(&mut self, mut symbol: Value, optional_args: &[Value]) -> impl ::std::future::Future<Output = Value> + Send { async move {
10280 let mut since = get_arg(optional_args, 0, Value::Null);
10281 let mut limit = get_arg(optional_args, 1, Value::Null);
10282 let mut params = get_arg(optional_args, 2, Value::Map({
10283 let mut m = indexmap::IndexMap::new();
10284 m
10285}));
10286 panic!("{}", crate::exchange_errors::not_supported(add(&self.id, &Value::Str(" fetchTradesWs() is not supported yet".to_string()))));
10287
10288 Value::Null
10289} }
10290
10291
10292 fn fetch_trades(&mut self, mut symbol: Value, optional_args: &[Value]) -> impl ::std::future::Future<Output = Value> + Send { async move {
10293 if let Some(__v) = self.dispatch_to_derived("fetch_trades", { let mut __args: Vec<crate::Value> = Vec::new(); __args.push(symbol.clone()); __args.extend_from_slice(optional_args); __args }).await {
10295 if !matches!(__v, crate::Value::Null) { return __v; }
10296 }
10297
10298 let mut since = get_arg(optional_args, 0, Value::Null);
10299 let mut limit = get_arg(optional_args, 1, Value::Null);
10300 let mut params = get_arg(optional_args, 2, Value::Map({
10301 let mut m = indexmap::IndexMap::new();
10302 m
10303}));
10304 panic!("{}", crate::exchange_errors::not_supported(add(&self.id, &Value::Str(" fetchTrades() is not supported yet".to_string()))));
10305
10306 Value::Null
10307} }
10308
10309 fn watch_trades(&mut self, mut symbol: Value, optional_args: &[Value]) -> impl ::std::future::Future<Output = Value> + Send { async move {
10310 let mut since = get_arg(optional_args, 0, Value::Null);
10311 let mut limit = get_arg(optional_args, 1, Value::Null);
10312 let mut params = get_arg(optional_args, 2, Value::Map({
10313 let mut m = indexmap::IndexMap::new();
10314 m
10315}));
10316 panic!("{}", crate::exchange_errors::not_supported(add(&self.id, &Value::Str(" watchTrades() is not supported yet".to_string()))));
10317
10318 Value::Null
10319} }
10320
10321 fn fetch_order_book(&mut self, mut symbol: Value, optional_args: &[Value]) -> impl ::std::future::Future<Output = Value> + Send { async move {
10322 if let Some(__v) = self.dispatch_to_derived("fetch_order_book", { let mut __args: Vec<crate::Value> = Vec::new(); __args.push(symbol.clone()); __args.extend_from_slice(optional_args); __args }).await {
10324 if !matches!(__v, crate::Value::Null) { return __v; }
10325 }
10326
10327 let mut limit = 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(add(&self.id, &Value::Str(" fetchOrderBook() is not supported yet".to_string()))));
10333
10334 Value::Null
10335} }
10336
10337 fn fetch_rest_order_book_safe(&mut self, mut symbol: Value, optional_args: &[Value]) -> impl ::std::future::Future<Output = Value> + Send { async move {
10338 let mut limit = get_arg(optional_args, 0, Value::Null);
10339 let mut params = get_arg(optional_args, 1, Value::Map({
10340 let mut m = indexmap::IndexMap::new();
10341 m
10342}));
10343 let mut fetchSnapshotMaxRetries: Value = self.handle_option(Value::Str("watchOrderBook".to_string()), Value::Str("maxRetries".to_string()), &[Value::Int(3)]);
10344 {
10345 let mut i: Value = Value::Int(0);
10346 let mut __for_first_179: bool = true;
10347 while { if !__for_first_179 { i = add(&i, &Value::Int(1)); } __for_first_179 = false; is_less_than(&i, &fetchSnapshotMaxRetries) } {
10348 let _try_result = futures::FutureExt::catch_unwind(std::panic::AssertUnwindSafe(async {
10349 let mut orderBook: Value = self.fetch_order_book(symbol.clone(), &[limit.clone(), params.clone()]).await;
10350 return orderBook.clone();
10351 #[allow(unreachable_code)] { Value::Null }})).await;
10352match _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);
10353 if is_equal(&(add(&i, &Value::Int(1))), &fetchSnapshotMaxRetries) {
10354 panic!("{}", e);
10355 }
10356 } }
10357 }
10358 }
10359 return Value::Null;
10360
10361 Value::Null
10362} }
10363
10364 fn watch_order_book(&mut self, mut symbol: Value, optional_args: &[Value]) -> impl ::std::future::Future<Output = Value> + Send { async move {
10365 let mut limit = get_arg(optional_args, 0, Value::Null);
10366 let mut params = get_arg(optional_args, 1, Value::Map({
10367 let mut m = indexmap::IndexMap::new();
10368 m
10369}));
10370 panic!("{}", crate::exchange_errors::not_supported(add(&self.id, &Value::Str(" watchOrderBook() is not supported yet".to_string()))));
10371
10372 Value::Null
10373} }
10374
10375 fn fetch_open_interest(&mut self, mut symbol: Value, optional_args: &[Value]) -> impl ::std::future::Future<Output = Value> + Send { async move {
10376 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 {
10378 if !matches!(__v, crate::Value::Null) { return __v; }
10379 }
10380
10381 let mut params = get_arg(optional_args, 0, Value::Map({
10382 let mut m = indexmap::IndexMap::new();
10383 m
10384}));
10385 if !is_equal(&get_value(&self.has, &Value::Str("fetchOpenInterests".to_string())), &Value::Null) && !is_equal(&get_value(&self.has, &Value::Str("fetchOpenInterests".to_string())), &Value::Bool(false)) {
10386 let mut openInterests: Value = self.fetch_open_interests(&[Value::List(vec![symbol.clone()]), params.clone()]).await;
10387 return self.safe_dict(openInterests.clone(), symbol.clone(), &[]);
10388 } else {
10389 panic!("{}", crate::exchange_errors::not_supported(add(&self.id, &Value::Str(" fetchOpenInterest() is not supported yet".to_string()))));
10390 }
10391
10392 Value::Null
10393} }
10394
10395 fn fetch_l2_order_book(&mut self, mut symbol: Value, optional_args: &[Value]) -> impl ::std::future::Future<Output = Value> + Send { async move {
10396 let mut limit = get_arg(optional_args, 0, Value::Null);
10397 let mut params = get_arg(optional_args, 1, Value::Map({
10398 let mut m = indexmap::IndexMap::new();
10399 m
10400}));
10401 let mut orderbook: Value = self.fetch_order_book(symbol.clone(), &[limit.clone(), params.clone()]).await;
10402 return self.extend(orderbook.clone(), &[Value::Map({
10403 let mut m = indexmap::IndexMap::new();
10404 m.insert("asks".to_string(), self.sort_by(self.aggregate(get_value(&orderbook, &Value::Str("asks".to_string()))), Value::Int(0), &[]));
10405 m.insert("bids".to_string(), self.sort_by(self.aggregate(get_value(&orderbook, &Value::Str("bids".to_string()))), Value::Int(0), &[Value::Bool(true)]));
10406 m
10407})]);
10408
10409 Value::Null
10410} }
10411
10412 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 {
10413 let mut price = get_arg(optional_args, 0, Value::Null);
10414 let mut params = get_arg(optional_args, 1, Value::Map({
10415 let mut m = indexmap::IndexMap::new();
10416 m
10417}));
10418 return self.edit_limit_order(id.clone(), symbol.clone(), Value::Str("buy".to_string()), amount.clone(), &[price.clone(), params.clone()]).await;
10419
10420 Value::Null
10421} }
10422
10423 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 {
10424 let mut price = get_arg(optional_args, 0, Value::Null);
10425 let mut params = get_arg(optional_args, 1, Value::Map({
10426 let mut m = indexmap::IndexMap::new();
10427 m
10428}));
10429 return self.edit_limit_order(id.clone(), symbol.clone(), Value::Str("sell".to_string()), amount.clone(), &[price.clone(), params.clone()]).await;
10430
10431 Value::Null
10432} }
10433
10434 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 {
10435 let mut price = get_arg(optional_args, 0, Value::Null);
10436 let mut params = get_arg(optional_args, 1, Value::Map({
10437 let mut m = indexmap::IndexMap::new();
10438 m
10439}));
10440 return self.edit_order(id.clone(), symbol.clone(), Value::Str("limit".to_string()), side.clone(), &[amount.clone(), price.clone(), params.clone()]).await;
10441
10442 Value::Null
10443} }
10444
10445 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 {
10446 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 {
10448 if !matches!(__v, crate::Value::Null) { return __v; }
10449 }
10450
10451 let mut amount = get_arg(optional_args, 0, Value::Null);
10452 let mut price = get_arg(optional_args, 1, Value::Null);
10453 let mut params = get_arg(optional_args, 2, Value::Map({
10454 let mut m = indexmap::IndexMap::new();
10455 m
10456}));
10457 self.cancel_order(id.clone(), &[symbol.clone()]).await;
10458 return self.create_order(symbol.clone(), type_var.clone(), side.clone(), amount.clone(), &[price.clone(), params.clone()]).await;
10459
10460 Value::Null
10461} }
10462
10463 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 {
10464 let mut amount = get_arg(optional_args, 0, Value::Null);
10465 let mut price = get_arg(optional_args, 1, Value::Null);
10466 let mut params = get_arg(optional_args, 2, Value::Map({
10467 let mut m = indexmap::IndexMap::new();
10468 m
10469}));
10470 let mut extendedParams: Value = self.extend(params.clone(), &[Value::Map({
10471 let mut m = indexmap::IndexMap::new();
10472 m.insert("clientOrderId".to_string(), clientOrderId.clone());
10473 m
10474 })]);
10475 return self.edit_order(Value::Str("".to_string()), symbol.clone(), type_var.clone(), side.clone(), &[amount.clone(), price.clone(), extendedParams.clone()]).await;
10476
10477 Value::Null
10478} }
10479
10480 fn fetch_position(&mut self, mut symbol: Value, optional_args: &[Value]) -> impl ::std::future::Future<Output = Value> + Send { async move {
10481 if let Some(__v) = self.dispatch_to_derived("fetch_position", { let mut __args: Vec<crate::Value> = Vec::new(); __args.push(symbol.clone()); __args.extend_from_slice(optional_args); __args }).await {
10483 if !matches!(__v, crate::Value::Null) { return __v; }
10484 }
10485
10486 let mut params = get_arg(optional_args, 0, Value::Map({
10487 let mut m = indexmap::IndexMap::new();
10488 m
10489}));
10490 panic!("{}", crate::exchange_errors::not_supported(add(&self.id, &Value::Str(" fetchPosition() is not supported yet".to_string()))));
10491
10492 Value::Null
10493} }
10494
10495 fn watch_positions(&mut self, optional_args: &[Value]) -> impl ::std::future::Future<Output = Value> + Send { async move {
10496 let mut symbols = get_arg(optional_args, 0, Value::Null);
10497 let mut since = get_arg(optional_args, 1, Value::Null);
10498 let mut limit = get_arg(optional_args, 2, Value::Null);
10499 let mut params = get_arg(optional_args, 3, Value::Map({
10500 let mut m = indexmap::IndexMap::new();
10501 m
10502}));
10503 panic!("{}", crate::exchange_errors::not_supported(add(&self.id, &Value::Str(" watchPositions() is not supported yet".to_string()))));
10504
10505 Value::Null
10506} }
10507
10508 fn watch_position_for_symbols(&mut self, optional_args: &[Value]) -> impl ::std::future::Future<Output = Value> + Send { async move {
10509 let mut symbols = get_arg(optional_args, 0, Value::Null);
10510 let mut since = get_arg(optional_args, 1, Value::Null);
10511 let mut limit = get_arg(optional_args, 2, Value::Null);
10512 let mut params = get_arg(optional_args, 3, Value::Map({
10513 let mut m = indexmap::IndexMap::new();
10514 m
10515}));
10516 return self.watch_positions(&[symbols.clone(), since.clone(), limit.clone(), params.clone()]).await;
10517
10518 Value::Null
10519} }
10520
10521 fn fetch_positions(&mut self, optional_args: &[Value]) -> impl ::std::future::Future<Output = Value> + Send { async move {
10522 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 {
10524 if !matches!(__v, crate::Value::Null) { return __v; }
10525 }
10526
10527 let mut symbols = get_arg(optional_args, 0, Value::Null);
10528 let mut params = get_arg(optional_args, 1, Value::Map({
10529 let mut m = indexmap::IndexMap::new();
10530 m
10531}));
10532 panic!("{}", crate::exchange_errors::not_supported(add(&self.id, &Value::Str(" fetchPositions() is not supported yet".to_string()))));
10533
10534 Value::Null
10535} }
10536
10537 fn fetch_ticker(&mut self, mut symbol: Value, optional_args: &[Value]) -> impl ::std::future::Future<Output = Value> + Send { async move {
10538 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 {
10540 if !matches!(__v, crate::Value::Null) { return __v; }
10541 }
10542
10543 let mut params = get_arg(optional_args, 0, Value::Map({
10544 let mut m = indexmap::IndexMap::new();
10545 m
10546}));
10547 if !is_equal(&get_value(&self.has, &Value::Str("fetchTickers".to_string())), &Value::Null) && !is_equal(&get_value(&self.has, &Value::Str("fetchTickers".to_string())), &Value::Bool(false)) {
10548 self.load_markets(&[]).await;
10549 let mut market: Value = self.market(symbol.clone());
10550 symbol = get_value(&market, &Value::Str("symbol".to_string()));
10551 let mut tickers: Value = self.fetch_tickers(&[Value::List(vec![symbol.clone()]), params.clone()]).await;
10552 let mut ticker: Value = self.safe_dict(tickers.clone(), symbol.clone(), &[]);
10553 if is_equal(&ticker, &Value::Null) {
10554 panic!("{}", crate::exchange_errors::null_response(add(&add(&self.id, &Value::Str(" fetchTickers() could not find a ticker for ".to_string())), &symbol)));
10555 } else {
10556 return ticker;
10557 }
10558 } else {
10559 panic!("{}", crate::exchange_errors::not_supported(add(&self.id, &Value::Str(" fetchTicker() is not supported yet".to_string()))));
10560 }
10561
10562 Value::Null
10563} }
10564
10565 fn watch_ticker(&mut self, mut symbol: Value, optional_args: &[Value]) -> impl ::std::future::Future<Output = Value> + Send { async move {
10566 let mut params = get_arg(optional_args, 0, Value::Map({
10567 let mut m = indexmap::IndexMap::new();
10568 m
10569}));
10570 panic!("{}", crate::exchange_errors::not_supported(add(&self.id, &Value::Str(" watchTicker() is not supported yet".to_string()))));
10571
10572 Value::Null
10573} }
10574
10575 fn fetch_tickers(&mut self, optional_args: &[Value]) -> impl ::std::future::Future<Output = Value> + Send { async move {
10576 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 {
10578 if !matches!(__v, crate::Value::Null) { return __v; }
10579 }
10580
10581 let mut symbols = get_arg(optional_args, 0, Value::Null);
10582 let mut params = get_arg(optional_args, 1, Value::Map({
10583 let mut m = indexmap::IndexMap::new();
10584 m
10585}));
10586 panic!("{}", crate::exchange_errors::not_supported(add(&self.id, &Value::Str(" fetchTickers() is not supported yet".to_string()))));
10587
10588 Value::Null
10589} }
10590
10591 fn watch_tickers(&mut self, optional_args: &[Value]) -> impl ::std::future::Future<Output = Value> + Send { async move {
10592 let mut symbols = get_arg(optional_args, 0, Value::Null);
10593 let mut params = get_arg(optional_args, 1, Value::Map({
10594 let mut m = indexmap::IndexMap::new();
10595 m
10596}));
10597 panic!("{}", crate::exchange_errors::not_supported(add(&self.id, &Value::Str(" watchTickers() is not supported yet".to_string()))));
10598
10599 Value::Null
10600} }
10601
10602 fn fetch_order(&mut self, mut id: Value, optional_args: &[Value]) -> impl ::std::future::Future<Output = Value> + Send { async move {
10603 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 {
10605 if !matches!(__v, crate::Value::Null) { return __v; }
10606 }
10607
10608 let mut symbol = get_arg(optional_args, 0, Value::Null);
10609 let mut params = get_arg(optional_args, 1, Value::Map({
10610 let mut m = indexmap::IndexMap::new();
10611 m
10612}));
10613 panic!("{}", crate::exchange_errors::not_supported(add(&self.id, &Value::Str(" fetchOrder() is not supported yet".to_string()))));
10614
10615 Value::Null
10616} }
10617
10618fn fetch_order_with_client_order_id(&mut self, mut clientOrderId: Value, optional_args: &[Value]) -> impl ::std::future::Future<Output = Value> + Send { async move {
10628 let mut symbol = get_arg(optional_args, 0, Value::Null);
10629 let mut params = get_arg(optional_args, 1, Value::Map({
10630 let mut m = indexmap::IndexMap::new();
10631 m
10632}));
10633 let mut extendedParams: Value = self.extend(params.clone(), &[Value::Map({
10634 let mut m = indexmap::IndexMap::new();
10635 m.insert("clientOrderId".to_string(), clientOrderId.clone());
10636 m
10637 })]);
10638 return self.fetch_order(Value::Str("".to_string()), &[symbol.clone(), extendedParams.clone()]).await;
10639
10640 Value::Null
10641} }
10642
10643 fn fetch_order_status(&mut self, mut id: Value, optional_args: &[Value]) -> impl ::std::future::Future<Output = Value> + Send { async move {
10644 let mut symbol = get_arg(optional_args, 0, Value::Null);
10645 let mut params = get_arg(optional_args, 1, Value::Map({
10646 let mut m = indexmap::IndexMap::new();
10647 m
10648}));
10649 let mut order: Value = self.fetch_order(id.clone(), &[symbol.clone(), params.clone()]).await;
10652 return get_value(&order, &Value::Str("status".to_string()));
10653
10654 Value::Null
10655} }
10656
10657 fn fetch_unified_order(&mut self, mut order: Value, optional_args: &[Value]) -> impl ::std::future::Future<Output = Value> + Send { async move {
10658 let mut params = get_arg(optional_args, 0, Value::Map({
10659 let mut m = indexmap::IndexMap::new();
10660 m
10661}));
10662 return self.fetch_order(self.safe_string_k(order.clone(), "id", &[]), &[self.safe_string_k(order.clone(), "symbol", &[]), params.clone()]).await;
10663
10664 Value::Null
10665} }
10666
10667 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 {
10668 if let Some(__v) = self.dispatch_to_derived("create_order", { let mut __args: Vec<crate::Value> = Vec::new(); __args.push(symbol.clone()); __args.push(type_var.clone()); __args.push(side.clone()); __args.push(amount.clone()); __args.extend_from_slice(optional_args); __args }).await {
10670 if !matches!(__v, crate::Value::Null) { return __v; }
10671 }
10672
10673 let mut price = get_arg(optional_args, 0, Value::Null);
10674 let mut params = get_arg(optional_args, 1, Value::Map({
10675 let mut m = indexmap::IndexMap::new();
10676 m
10677}));
10678 panic!("{}", crate::exchange_errors::not_supported(add(&self.id, &Value::Str(" createOrder() is not supported yet".to_string()))));
10679
10680 Value::Null
10681} }
10682
10683 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 {
10684 let mut price = get_arg(optional_args, 0, Value::Null);
10685 let mut trailingAmount = get_arg(optional_args, 1, Value::Null);
10686 let mut trailingTriggerPrice = get_arg(optional_args, 2, Value::Null);
10687 let mut params = get_arg(optional_args, 3, Value::Map({
10688 let mut m = indexmap::IndexMap::new();
10689 m
10690}));
10691 if is_equal(&trailingAmount, &Value::Null) {
10706 panic!("{}", crate::exchange_errors::arguments_required(add(&self.id, &Value::Str(" createTrailingAmountOrder() requires a trailingAmount argument".to_string()))));
10707 }
10708 add_element_to_object(&mut params, &Value::Str("trailingAmount".to_string()), trailingAmount.clone());
10709 if !is_equal(&trailingTriggerPrice, &Value::Null) {
10710 add_element_to_object(&mut params, &Value::Str("trailingTriggerPrice".to_string()), trailingTriggerPrice.clone());
10711 }
10712 if !is_equal(&get_value(&self.has, &Value::Str("createTrailingAmountOrder".to_string())), &Value::Null) && !is_equal(&get_value(&self.has, &Value::Str("createTrailingAmountOrder".to_string())), &Value::Bool(false)) {
10713 return self.create_order(symbol.clone(), type_var.clone(), side.clone(), amount.clone(), &[price.clone(), params.clone()]).await;
10714 }
10715 panic!("{}", crate::exchange_errors::not_supported(add(&self.id, &Value::Str(" createTrailingAmountOrder() is not supported yet".to_string()))));
10716
10717 Value::Null
10718} }
10719
10720 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 {
10721 let mut price = get_arg(optional_args, 0, Value::Null);
10722 let mut trailingPercent = get_arg(optional_args, 1, Value::Null);
10723 let mut trailingTriggerPrice = get_arg(optional_args, 2, Value::Null);
10724 let mut params = get_arg(optional_args, 3, Value::Map({
10725 let mut m = indexmap::IndexMap::new();
10726 m
10727}));
10728 if is_equal(&trailingPercent, &Value::Null) {
10743 panic!("{}", crate::exchange_errors::arguments_required(add(&self.id, &Value::Str(" createTrailingPercentOrder() requires a trailingPercent argument".to_string()))));
10744 }
10745 add_element_to_object(&mut params, &Value::Str("trailingPercent".to_string()), trailingPercent.clone());
10746 if !is_equal(&trailingTriggerPrice, &Value::Null) {
10747 add_element_to_object(&mut params, &Value::Str("trailingTriggerPrice".to_string()), trailingTriggerPrice.clone());
10748 }
10749 if !is_equal(&get_value(&self.has, &Value::Str("createTrailingPercentOrder".to_string())), &Value::Null) && !is_equal(&get_value(&self.has, &Value::Str("createTrailingPercentOrder".to_string())), &Value::Bool(false)) {
10750 return self.create_order(symbol.clone(), type_var.clone(), side.clone(), amount.clone(), &[price.clone(), params.clone()]).await;
10751 }
10752 panic!("{}", crate::exchange_errors::not_supported(add(&self.id, &Value::Str(" createTrailingPercentOrder() is not supported yet".to_string()))));
10753
10754 Value::Null
10755} }
10756
10757 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 {
10758 let mut params = get_arg(optional_args, 0, Value::Map({
10759 let mut m = indexmap::IndexMap::new();
10760 m
10761}));
10762 if is_true(&(!is_equal(&get_value(&self.has, &Value::Str("createMarketOrderWithCost".to_string())), &Value::Null) && !is_equal(&get_value(&self.has, &Value::Str("createMarketOrderWithCost".to_string())), &Value::Bool(false)))) || is_true(&(is_true(&(!is_equal(&get_value(&self.has, &Value::Str("createMarketBuyOrderWithCost".to_string())), &Value::Null) && !is_equal(&get_value(&self.has, &Value::Str("createMarketBuyOrderWithCost".to_string())), &Value::Bool(false)))) && is_true(&(!is_equal(&get_value(&self.has, &Value::Str("createMarketSellOrderWithCost".to_string())), &Value::Null) && !is_equal(&get_value(&self.has, &Value::Str("createMarketSellOrderWithCost".to_string())), &Value::Bool(false)))))) {
10773 return self.create_order(symbol.clone(), Value::Str("market".to_string()), side.clone(), cost.clone(), &[Value::Int(1), params.clone()]).await;
10774 }
10775 panic!("{}", crate::exchange_errors::not_supported(add(&self.id, &Value::Str(" createMarketOrderWithCost() is not supported yet".to_string()))));
10776
10777 Value::Null
10778} }
10779
10780 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 {
10781 let mut params = get_arg(optional_args, 0, Value::Map({
10782 let mut m = indexmap::IndexMap::new();
10783 m
10784}));
10785 if is_true(&(is_equal(&get_value(&self.options, &Value::Str("createMarketBuyOrderRequiresPrice".to_string())), &Value::Bool(true)))) || is_true(&(!is_equal(&get_value(&self.has, &Value::Str("createMarketBuyOrderWithCost".to_string())), &Value::Null) && !is_equal(&get_value(&self.has, &Value::Str("createMarketBuyOrderWithCost".to_string())), &Value::Bool(false)))) {
10795 return self.create_order(symbol.clone(), Value::Str("market".to_string()), Value::Str("buy".to_string()), cost.clone(), &[Value::Int(1), params.clone()]).await;
10796 }
10797 panic!("{}", crate::exchange_errors::not_supported(add(&self.id, &Value::Str(" createMarketBuyOrderWithCost() is not supported yet".to_string()))));
10798
10799 Value::Null
10800} }
10801
10802 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 {
10803 let mut params = get_arg(optional_args, 0, Value::Map({
10804 let mut m = indexmap::IndexMap::new();
10805 m
10806}));
10807 if is_true(&(is_equal(&get_value(&self.options, &Value::Str("createMarketSellOrderRequiresPrice".to_string())), &Value::Bool(true)))) || is_true(&(!is_equal(&get_value(&self.has, &Value::Str("createMarketSellOrderWithCost".to_string())), &Value::Null) && !is_equal(&get_value(&self.has, &Value::Str("createMarketSellOrderWithCost".to_string())), &Value::Bool(false)))) {
10817 return self.create_order(symbol.clone(), Value::Str("market".to_string()), Value::Str("sell".to_string()), cost.clone(), &[Value::Int(1), params.clone()]).await;
10818 }
10819 panic!("{}", crate::exchange_errors::not_supported(add(&self.id, &Value::Str(" createMarketSellOrderWithCost() is not supported yet".to_string()))));
10820
10821 Value::Null
10822} }
10823
10824 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 {
10825 let mut price = get_arg(optional_args, 0, Value::Null);
10826 let mut triggerPrice = get_arg(optional_args, 1, Value::Null);
10827 let mut params = get_arg(optional_args, 2, Value::Map({
10828 let mut m = indexmap::IndexMap::new();
10829 m
10830}));
10831 if is_equal(&triggerPrice, &Value::Null) {
10845 panic!("{}", crate::exchange_errors::arguments_required(add(&self.id, &Value::Str(" createTriggerOrder() requires a triggerPrice argument".to_string()))));
10846 }
10847 params = self.extend(params.clone(), &[Value::Map({
10848 let mut m = indexmap::IndexMap::new();
10849 m.insert("triggerPrice".to_string(), triggerPrice.clone());
10850 m
10851 })]);
10852 if !is_equal(&get_value(&self.has, &Value::Str("createTriggerOrder".to_string())), &Value::Null) && !is_equal(&get_value(&self.has, &Value::Str("createTriggerOrder".to_string())), &Value::Bool(false)) {
10853 return self.create_order(symbol.clone(), type_var.clone(), side.clone(), amount.clone(), &[price.clone(), params.clone()]).await;
10854 }
10855 panic!("{}", crate::exchange_errors::not_supported(add(&self.id, &Value::Str(" createTriggerOrder() is not supported yet".to_string()))));
10856
10857 Value::Null
10858} }
10859
10860 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 {
10861 let mut price = get_arg(optional_args, 0, Value::Null);
10862 let mut stopLossPrice = get_arg(optional_args, 1, Value::Null);
10863 let mut params = get_arg(optional_args, 2, Value::Map({
10864 let mut m = indexmap::IndexMap::new();
10865 m
10866}));
10867 if is_equal(&stopLossPrice, &Value::Null) {
10881 panic!("{}", crate::exchange_errors::arguments_required(add(&self.id, &Value::Str(" createStopLossOrder() requires a stopLossPrice argument".to_string()))));
10882 }
10883 params = self.extend(params.clone(), &[Value::Map({
10884 let mut m = indexmap::IndexMap::new();
10885 m.insert("stopLossPrice".to_string(), stopLossPrice.clone());
10886 m
10887 })]);
10888 if !is_equal(&get_value(&self.has, &Value::Str("createStopLossOrder".to_string())), &Value::Null) && !is_equal(&get_value(&self.has, &Value::Str("createStopLossOrder".to_string())), &Value::Bool(false)) {
10889 return self.create_order(symbol.clone(), type_var.clone(), side.clone(), amount.clone(), &[price.clone(), params.clone()]).await;
10890 }
10891 panic!("{}", crate::exchange_errors::not_supported(add(&self.id, &Value::Str(" createStopLossOrder() is not supported yet".to_string()))));
10892
10893 Value::Null
10894} }
10895
10896 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 {
10897 let mut price = get_arg(optional_args, 0, Value::Null);
10898 let mut takeProfitPrice = get_arg(optional_args, 1, Value::Null);
10899 let mut params = get_arg(optional_args, 2, Value::Map({
10900 let mut m = indexmap::IndexMap::new();
10901 m
10902}));
10903 if is_equal(&takeProfitPrice, &Value::Null) {
10917 panic!("{}", crate::exchange_errors::arguments_required(add(&self.id, &Value::Str(" createTakeProfitOrder() requires a takeProfitPrice argument".to_string()))));
10918 }
10919 params = self.extend(params.clone(), &[Value::Map({
10920 let mut m = indexmap::IndexMap::new();
10921 m.insert("takeProfitPrice".to_string(), takeProfitPrice.clone());
10922 m
10923 })]);
10924 if !is_equal(&get_value(&self.has, &Value::Str("createTakeProfitOrder".to_string())), &Value::Null) && !is_equal(&get_value(&self.has, &Value::Str("createTakeProfitOrder".to_string())), &Value::Bool(false)) {
10925 return self.create_order(symbol.clone(), type_var.clone(), side.clone(), amount.clone(), &[price.clone(), params.clone()]).await;
10926 }
10927 panic!("{}", crate::exchange_errors::not_supported(add(&self.id, &Value::Str(" createTakeProfitOrder() is not supported yet".to_string()))));
10928
10929 Value::Null
10930} }
10931
10932 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 {
10933 let mut price = get_arg(optional_args, 0, Value::Null);
10934 let mut takeProfit = get_arg(optional_args, 1, Value::Null);
10935 let mut stopLoss = get_arg(optional_args, 2, Value::Null);
10936 let mut params = get_arg(optional_args, 3, Value::Map({
10937 let mut m = indexmap::IndexMap::new();
10938 m
10939}));
10940 params = self.set_take_profit_and_stop_loss_params(symbol.clone(), type_var.clone(), side.clone(), amount.clone(), &[price.clone(), takeProfit.clone(), stopLoss.clone(), params.clone()]);
10963 if !is_equal(&get_value(&self.has, &Value::Str("createOrderWithTakeProfitAndStopLoss".to_string())), &Value::Null) && !is_equal(&get_value(&self.has, &Value::Str("createOrderWithTakeProfitAndStopLoss".to_string())), &Value::Bool(false)) {
10964 return self.create_order(symbol.clone(), type_var.clone(), side.clone(), amount.clone(), &[price.clone(), params.clone()]).await;
10965 }
10966 panic!("{}", crate::exchange_errors::not_supported(add(&self.id, &Value::Str(" createOrderWithTakeProfitAndStopLoss() is not supported yet".to_string()))));
10967
10968 Value::Null
10969} }
10970
10971 fn create_orders(&mut self, mut orders: Value, optional_args: &[Value]) -> impl ::std::future::Future<Output = Value> + Send { async move {
10972 if let Some(__v) = self.dispatch_to_derived("create_orders", { let mut __args: Vec<crate::Value> = Vec::new(); __args.push(orders.clone()); __args.extend_from_slice(optional_args); __args }).await {
10974 if !matches!(__v, crate::Value::Null) { return __v; }
10975 }
10976
10977 let mut params = get_arg(optional_args, 0, Value::Map({
10978 let mut m = indexmap::IndexMap::new();
10979 m
10980}));
10981 panic!("{}", crate::exchange_errors::not_supported(add(&self.id, &Value::Str(" createOrders() is not supported yet".to_string()))));
10982
10983 Value::Null
10984} }
10985
10986 fn cancel_order(&mut self, mut id: Value, optional_args: &[Value]) -> impl ::std::future::Future<Output = Value> + Send { async move {
10987 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 {
10989 if !matches!(__v, crate::Value::Null) { return __v; }
10990 }
10991
10992 let mut symbol = get_arg(optional_args, 0, Value::Null);
10993 let mut params = get_arg(optional_args, 1, Value::Map({
10994 let mut m = indexmap::IndexMap::new();
10995 m
10996}));
10997 panic!("{}", crate::exchange_errors::not_supported(add(&self.id, &Value::Str(" cancelOrder() is not supported yet".to_string()))));
10998
10999 Value::Null
11000} }
11001
11002fn cancel_order_with_client_order_id(&mut self, mut clientOrderId: Value, optional_args: &[Value]) -> impl ::std::future::Future<Output = Value> + Send { async move {
11012 let mut symbol = get_arg(optional_args, 0, Value::Null);
11013 let mut params = get_arg(optional_args, 1, Value::Map({
11014 let mut m = indexmap::IndexMap::new();
11015 m
11016}));
11017 let mut extendedParams: Value = self.extend(params.clone(), &[Value::Map({
11018 let mut m = indexmap::IndexMap::new();
11019 m.insert("clientOrderId".to_string(), clientOrderId.clone());
11020 m
11021 })]);
11022 return self.cancel_order(Value::Str("".to_string()), &[symbol.clone(), extendedParams.clone()]).await;
11023
11024 Value::Null
11025} }
11026
11027 fn cancel_orders(&mut self, mut ids: Value, optional_args: &[Value]) -> impl ::std::future::Future<Output = Value> + Send { async move {
11028 if let Some(__v) = self.dispatch_to_derived("cancel_orders", { let mut __args: Vec<crate::Value> = Vec::new(); __args.push(ids.clone()); __args.extend_from_slice(optional_args); __args }).await {
11030 if !matches!(__v, crate::Value::Null) { return __v; }
11031 }
11032
11033 let mut symbol = get_arg(optional_args, 0, Value::Null);
11034 let mut params = get_arg(optional_args, 1, Value::Map({
11035 let mut m = indexmap::IndexMap::new();
11036 m
11037}));
11038 panic!("{}", crate::exchange_errors::not_supported(add(&self.id, &Value::Str(" cancelOrders() is not supported yet".to_string()))));
11039
11040 Value::Null
11041} }
11042
11043fn cancel_orders_with_client_order_ids(&mut self, mut clientOrderIds: Value, optional_args: &[Value]) -> impl ::std::future::Future<Output = Value> + Send { async move {
11053 let mut symbol = get_arg(optional_args, 0, Value::Null);
11054 let mut params = get_arg(optional_args, 1, Value::Map({
11055 let mut m = indexmap::IndexMap::new();
11056 m
11057}));
11058 let mut extendedParams: Value = self.extend(params.clone(), &[Value::Map({
11059 let mut m = indexmap::IndexMap::new();
11060 m.insert("clientOrderIds".to_string(), clientOrderIds.clone());
11061 m
11062 })]);
11063 return self.cancel_orders(Value::List(vec![]), &[symbol.clone(), extendedParams.clone()]).await;
11064
11065 Value::Null
11066} }
11067
11068 fn cancel_all_orders(&mut self, optional_args: &[Value]) -> impl ::std::future::Future<Output = Value> + Send { async move {
11069 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 {
11071 if !matches!(__v, crate::Value::Null) { return __v; }
11072 }
11073
11074 let mut symbol = get_arg(optional_args, 0, Value::Null);
11075 let mut params = get_arg(optional_args, 1, Value::Map({
11076 let mut m = indexmap::IndexMap::new();
11077 m
11078}));
11079 panic!("{}", crate::exchange_errors::not_supported(add(&self.id, &Value::Str(" cancelAllOrders() is not supported yet".to_string()))));
11080
11081 Value::Null
11082} }
11083
11084 fn cancel_unified_order(&mut self, mut order: Value, optional_args: &[Value]) -> impl ::std::future::Future<Output = Value> + Send { async move {
11085 let mut params = get_arg(optional_args, 0, Value::Map({
11086 let mut m = indexmap::IndexMap::new();
11087 m
11088}));
11089 return self.cancel_order(self.safe_string_k(order.clone(), "id", &[]), &[self.safe_string_k(order.clone(), "symbol", &[]), params.clone()]).await;
11090
11091 Value::Null
11092} }
11093
11094 fn fetch_orders(&mut self, optional_args: &[Value]) -> impl ::std::future::Future<Output = Value> + Send { async move {
11095 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 {
11097 if !matches!(__v, crate::Value::Null) { return __v; }
11098 }
11099
11100 let mut symbol = get_arg(optional_args, 0, Value::Null);
11101 let mut since = get_arg(optional_args, 1, Value::Null);
11102 let mut limit = get_arg(optional_args, 2, Value::Null);
11103 let mut params = get_arg(optional_args, 3, Value::Map({
11104 let mut m = indexmap::IndexMap::new();
11105 m
11106}));
11107 if is_true(&(!is_equal(&get_value(&self.has, &Value::Str("fetchOpenOrders".to_string())), &Value::Null) && !is_equal(&get_value(&self.has, &Value::Str("fetchOpenOrders".to_string())), &Value::Bool(false)))) && is_true(&(!is_equal(&get_value(&self.has, &Value::Str("fetchClosedOrders".to_string())), &Value::Null) && !is_equal(&get_value(&self.has, &Value::Str("fetchClosedOrders".to_string())), &Value::Bool(false)))) {
11108 panic!("{}", crate::exchange_errors::not_supported(add(&self.id, &Value::Str(" fetchOrders() is not supported yet, consider using fetchOpenOrders() and fetchClosedOrders() instead".to_string()))));
11109 }
11110 panic!("{}", crate::exchange_errors::not_supported(add(&self.id, &Value::Str(" fetchOrders() is not supported yet".to_string()))));
11111
11112 Value::Null
11113} }
11114
11115 fn fetch_order_trades(&mut self, mut id: Value, optional_args: &[Value]) -> impl ::std::future::Future<Output = Value> + Send { async move {
11116 let mut symbol = get_arg(optional_args, 0, Value::Null);
11117 let mut since = get_arg(optional_args, 1, Value::Null);
11118 let mut limit = get_arg(optional_args, 2, Value::Null);
11119 let mut params = get_arg(optional_args, 3, Value::Map({
11120 let mut m = indexmap::IndexMap::new();
11121 m
11122}));
11123 panic!("{}", crate::exchange_errors::not_supported(add(&self.id, &Value::Str(" fetchOrderTrades() is not supported yet".to_string()))));
11124
11125 Value::Null
11126} }
11127
11128 fn watch_orders(&mut self, optional_args: &[Value]) -> impl ::std::future::Future<Output = Value> + Send { async move {
11129 let mut symbol = get_arg(optional_args, 0, Value::Null);
11130 let mut since = get_arg(optional_args, 1, Value::Null);
11131 let mut limit = get_arg(optional_args, 2, Value::Null);
11132 let mut params = get_arg(optional_args, 3, Value::Map({
11133 let mut m = indexmap::IndexMap::new();
11134 m
11135}));
11136 panic!("{}", crate::exchange_errors::not_supported(add(&self.id, &Value::Str(" watchOrders() is not supported yet".to_string()))));
11137
11138 Value::Null
11139} }
11140
11141 fn fetch_open_orders(&mut self, optional_args: &[Value]) -> impl ::std::future::Future<Output = Value> + Send { async move {
11142 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 {
11144 if !matches!(__v, crate::Value::Null) { return __v; }
11145 }
11146
11147 let mut symbol = get_arg(optional_args, 0, Value::Null);
11148 let mut since = get_arg(optional_args, 1, Value::Null);
11149 let mut limit = get_arg(optional_args, 2, Value::Null);
11150 let mut params = get_arg(optional_args, 3, Value::Map({
11151 let mut m = indexmap::IndexMap::new();
11152 m
11153}));
11154 if !is_equal(&get_value(&self.has, &Value::Str("fetchOrders".to_string())), &Value::Null) && !is_equal(&get_value(&self.has, &Value::Str("fetchOrders".to_string())), &Value::Bool(false)) {
11155 let mut orders: Value = self.fetch_orders(&[symbol.clone(), since.clone(), limit.clone(), params.clone()]).await;
11156 return self.filter_by(orders.clone(), Value::Str("status".to_string()), Value::Str("open".to_string()), &[]);
11157 }
11158 panic!("{}", crate::exchange_errors::not_supported(add(&self.id, &Value::Str(" fetchOpenOrders() is not supported yet".to_string()))));
11159
11160 Value::Null
11161} }
11162
11163 fn fetch_closed_orders(&mut self, optional_args: &[Value]) -> impl ::std::future::Future<Output = Value> + Send { async move {
11164 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 {
11166 if !matches!(__v, crate::Value::Null) { return __v; }
11167 }
11168
11169 let mut symbol = get_arg(optional_args, 0, Value::Null);
11170 let mut since = get_arg(optional_args, 1, Value::Null);
11171 let mut limit = get_arg(optional_args, 2, Value::Null);
11172 let mut params = get_arg(optional_args, 3, Value::Map({
11173 let mut m = indexmap::IndexMap::new();
11174 m
11175}));
11176 if !is_equal(&get_value(&self.has, &Value::Str("fetchOrders".to_string())), &Value::Null) && !is_equal(&get_value(&self.has, &Value::Str("fetchOrders".to_string())), &Value::Bool(false)) {
11177 let mut orders: Value = self.fetch_orders(&[symbol.clone(), since.clone(), limit.clone(), params.clone()]).await;
11178 return self.filter_by(orders.clone(), Value::Str("status".to_string()), Value::Str("closed".to_string()), &[]);
11179 }
11180 panic!("{}", crate::exchange_errors::not_supported(add(&self.id, &Value::Str(" fetchClosedOrders() is not supported yet".to_string()))));
11181
11182 Value::Null
11183} }
11184
11185 fn fetch_canceled_orders(&mut self, optional_args: &[Value]) -> impl ::std::future::Future<Output = Value> + Send { async move {
11186 let mut symbol = get_arg(optional_args, 0, Value::Null);
11187 let mut since = get_arg(optional_args, 1, Value::Null);
11188 let mut limit = get_arg(optional_args, 2, Value::Null);
11189 let mut params = get_arg(optional_args, 3, Value::Map({
11190 let mut m = indexmap::IndexMap::new();
11191 m
11192}));
11193 panic!("{}", crate::exchange_errors::not_supported(add(&self.id, &Value::Str(" fetchCanceledOrders() is not supported yet".to_string()))));
11194
11195 Value::Null
11196} }
11197
11198 fn fetch_my_trades(&mut self, optional_args: &[Value]) -> impl ::std::future::Future<Output = Value> + Send { async move {
11199 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 {
11201 if !matches!(__v, crate::Value::Null) { return __v; }
11202 }
11203
11204 let mut symbol = get_arg(optional_args, 0, Value::Null);
11205 let mut since = get_arg(optional_args, 1, Value::Null);
11206 let mut limit = get_arg(optional_args, 2, Value::Null);
11207 let mut params = get_arg(optional_args, 3, Value::Map({
11208 let mut m = indexmap::IndexMap::new();
11209 m
11210}));
11211 panic!("{}", crate::exchange_errors::not_supported(add(&self.id, &Value::Str(" fetchMyTrades() is not supported yet".to_string()))));
11212
11213 Value::Null
11214} }
11215
11216 fn watch_my_trades(&mut self, optional_args: &[Value]) -> impl ::std::future::Future<Output = Value> + Send { async move {
11217 let mut symbol = get_arg(optional_args, 0, Value::Null);
11218 let mut since = get_arg(optional_args, 1, Value::Null);
11219 let mut limit = get_arg(optional_args, 2, Value::Null);
11220 let mut params = get_arg(optional_args, 3, Value::Map({
11221 let mut m = indexmap::IndexMap::new();
11222 m
11223}));
11224 panic!("{}", crate::exchange_errors::not_supported(add(&self.id, &Value::Str(" watchMyTrades() is not supported yet".to_string()))));
11225
11226 Value::Null
11227} }
11228
11229 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 {
11230 let mut params = get_arg(optional_args, 0, Value::Map({
11231 let mut m = indexmap::IndexMap::new();
11232 m
11233}));
11234 return self.create_order(symbol.clone(), Value::Str("limit".to_string()), side.clone(), amount.clone(), &[price.clone(), params.clone()]).await;
11235
11236 Value::Null
11237} }
11238
11239 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 {
11240 let mut price = get_arg(optional_args, 0, Value::Null);
11241 let mut params = get_arg(optional_args, 1, Value::Map({
11242 let mut m = indexmap::IndexMap::new();
11243 m
11244}));
11245 return self.create_order(symbol.clone(), Value::Str("market".to_string()), side.clone(), amount.clone(), &[price.clone(), params.clone()]).await;
11246
11247 Value::Null
11248} }
11249
11250 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 {
11251 let mut params = get_arg(optional_args, 0, Value::Map({
11252 let mut m = indexmap::IndexMap::new();
11253 m
11254}));
11255 return self.create_order(symbol.clone(), Value::Str("limit".to_string()), Value::Str("buy".to_string()), amount.clone(), &[price.clone(), params.clone()]).await;
11256
11257 Value::Null
11258} }
11259
11260 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 {
11261 let mut params = get_arg(optional_args, 0, Value::Map({
11262 let mut m = indexmap::IndexMap::new();
11263 m
11264}));
11265 return self.create_order(symbol.clone(), Value::Str("limit".to_string()), Value::Str("sell".to_string()), amount.clone(), &[price.clone(), params.clone()]).await;
11266
11267 Value::Null
11268} }
11269
11270 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 {
11271 let mut params = get_arg(optional_args, 0, Value::Map({
11272 let mut m = indexmap::IndexMap::new();
11273 m
11274}));
11275 return self.create_order(symbol.clone(), Value::Str("market".to_string()), Value::Str("buy".to_string()), amount.clone(), &[Value::Null, params.clone()]).await;
11276
11277 Value::Null
11278} }
11279
11280 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 {
11281 let mut params = get_arg(optional_args, 0, Value::Map({
11282 let mut m = indexmap::IndexMap::new();
11283 m
11284}));
11285 return self.create_order(symbol.clone(), Value::Str("market".to_string()), Value::Str("sell".to_string()), amount.clone(), &[Value::Null, params.clone()]).await;
11286
11287 Value::Null
11288} }
11289
11290 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 {
11291 let mut price = get_arg(optional_args, 0, Value::Null);
11292 let mut params = get_arg(optional_args, 1, Value::Map({
11293 let mut m = indexmap::IndexMap::new();
11294 m
11295}));
11296 if is_equal(&get_value(&self.has, &Value::Str("createPostOnlyOrder".to_string())), &Value::Null) || is_equal(&get_value(&self.has, &Value::Str("createPostOnlyOrder".to_string())), &Value::Bool(false)) {
11297 panic!("{}", crate::exchange_errors::not_supported(add(&self.id, &Value::Str(" createPostOnlyOrder() is not supported yet".to_string()))));
11298 }
11299 let mut query: Value = self.extend(params.clone(), &[Value::Map({
11300 let mut m = indexmap::IndexMap::new();
11301 m.insert("postOnly".to_string(), Value::Bool(true));
11302 m
11303 })]);
11304 return self.create_order(symbol.clone(), type_var.clone(), side.clone(), amount.clone(), &[price.clone(), query.clone()]).await;
11305
11306 Value::Null
11307} }
11308
11309 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 {
11310 let mut price = get_arg(optional_args, 0, Value::Null);
11311 let mut params = get_arg(optional_args, 1, Value::Map({
11312 let mut m = indexmap::IndexMap::new();
11313 m
11314}));
11315 if is_equal(&get_value(&self.has, &Value::Str("createReduceOnlyOrder".to_string())), &Value::Null) || is_equal(&get_value(&self.has, &Value::Str("createReduceOnlyOrder".to_string())), &Value::Bool(false)) {
11316 panic!("{}", crate::exchange_errors::not_supported(add(&self.id, &Value::Str(" createReduceOnlyOrder() is not supported yet".to_string()))));
11317 }
11318 let mut query: Value = self.extend(params.clone(), &[Value::Map({
11319 let mut m = indexmap::IndexMap::new();
11320 m.insert("reduceOnly".to_string(), Value::Bool(true));
11321 m
11322 })]);
11323 return self.create_order(symbol.clone(), type_var.clone(), side.clone(), amount.clone(), &[price.clone(), query.clone()]).await;
11324
11325 Value::Null
11326} }
11327
11328 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 {
11329 let mut price = get_arg(optional_args, 0, Value::Null);
11330 let mut triggerPrice = get_arg(optional_args, 1, Value::Null);
11331 let mut params = get_arg(optional_args, 2, Value::Map({
11332 let mut m = indexmap::IndexMap::new();
11333 m
11334}));
11335 if is_equal(&get_value(&self.has, &Value::Str("createStopOrder".to_string())), &Value::Null) || is_equal(&get_value(&self.has, &Value::Str("createStopOrder".to_string())), &Value::Bool(false)) {
11336 panic!("{}", crate::exchange_errors::not_supported(add(&self.id, &Value::Str(" createStopOrder() is not supported yet".to_string()))));
11337 }
11338 if is_equal(&triggerPrice, &Value::Null) {
11339 panic!("{}", crate::exchange_errors::arguments_required(add(&self.id, &Value::Str(" create_stop_order() requires a stopPrice argument".to_string()))));
11340 }
11341 let mut query: Value = self.extend(params.clone(), &[Value::Map({
11342 let mut m = indexmap::IndexMap::new();
11343 m.insert("stopPrice".to_string(), triggerPrice.clone());
11344 m
11345 })]);
11346 return self.create_order(symbol.clone(), type_var.clone(), side.clone(), amount.clone(), &[price.clone(), query.clone()]).await;
11347
11348 Value::Null
11349} }
11350
11351 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 {
11352 let mut params = get_arg(optional_args, 0, Value::Map({
11353 let mut m = indexmap::IndexMap::new();
11354 m
11355}));
11356 if is_equal(&get_value(&self.has, &Value::Str("createStopLimitOrder".to_string())), &Value::Null) || is_equal(&get_value(&self.has, &Value::Str("createStopLimitOrder".to_string())), &Value::Bool(false)) {
11357 panic!("{}", crate::exchange_errors::not_supported(add(&self.id, &Value::Str(" createStopLimitOrder() is not supported yet".to_string()))));
11358 }
11359 let mut query: Value = self.extend(params.clone(), &[Value::Map({
11360 let mut m = indexmap::IndexMap::new();
11361 m.insert("stopPrice".to_string(), triggerPrice.clone());
11362 m
11363 })]);
11364 return self.create_order(symbol.clone(), Value::Str("limit".to_string()), side.clone(), amount.clone(), &[price.clone(), query.clone()]).await;
11365
11366 Value::Null
11367} }
11368
11369 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 {
11370 let mut params = get_arg(optional_args, 0, Value::Map({
11371 let mut m = indexmap::IndexMap::new();
11372 m
11373}));
11374 if is_equal(&get_value(&self.has, &Value::Str("createStopMarketOrder".to_string())), &Value::Null) || is_equal(&get_value(&self.has, &Value::Str("createStopMarketOrder".to_string())), &Value::Bool(false)) {
11375 panic!("{}", crate::exchange_errors::not_supported(add(&self.id, &Value::Str(" createStopMarketOrder() is not supported yet".to_string()))));
11376 }
11377 let mut query: Value = self.extend(params.clone(), &[Value::Map({
11378 let mut m = indexmap::IndexMap::new();
11379 m.insert("stopPrice".to_string(), triggerPrice.clone());
11380 m
11381 })]);
11382 return self.create_order(symbol.clone(), Value::Str("market".to_string()), side.clone(), amount.clone(), &[Value::Null, query.clone()]).await;
11383
11384 Value::Null
11385} }
11386
11387 fn fetch_trading_fee(&mut self, mut symbol: Value, optional_args: &[Value]) -> impl ::std::future::Future<Output = Value> + Send { async move {
11388 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 {
11390 if !matches!(__v, crate::Value::Null) { return __v; }
11391 }
11392
11393 let mut params = get_arg(optional_args, 0, Value::Map({
11394 let mut m = indexmap::IndexMap::new();
11395 m
11396}));
11397 if is_equal(&get_value(&self.has, &Value::Str("fetchTradingFees".to_string())), &Value::Null) || is_equal(&get_value(&self.has, &Value::Str("fetchTradingFees".to_string())), &Value::Bool(false)) {
11398 panic!("{}", crate::exchange_errors::not_supported(add(&self.id, &Value::Str(" fetchTradingFee() is not supported yet".to_string()))));
11399 }
11400 let mut fees: Value = self.fetch_trading_fees(&[params.clone()]).await;
11401 return self.safe_dict(fees.clone(), symbol.clone(), &[]);
11402
11403 Value::Null
11404} }
11405 fn call_dynamic_base<'a>(&'a mut self, method: &'a str, args: Vec<crate::Value>)
11407 -> std::pin::Pin<Box<dyn std::future::Future<Output = crate::Value> + Send + 'a>>
11408 {
11409 Box::pin(async move {
11410 match method {
11411 "account" => self.account(),
11412 "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)),
11413 "add_margin" => self.add_margin(args.get(0).cloned().unwrap_or(crate::Value::Null), args.get(1).cloned().unwrap_or(crate::Value::Null), &args.get(2..).unwrap_or(&[]).to_vec()[..]).await,
11414 "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)),
11415 "arrays_concat" => self.arrays_concat(args.get(0).cloned().unwrap_or(crate::Value::Null)),
11416 "assign_default_deposit_withdraw_fees" => self.assign_default_deposit_withdraw_fees(args.get(0).cloned().unwrap_or(crate::Value::Null), &args.get(1..).unwrap_or(&[]).to_vec()[..]),
11417 "borrow_cross_margin" => self.borrow_cross_margin(args.get(0).cloned().unwrap_or(crate::Value::Null), args.get(1).cloned().unwrap_or(crate::Value::Null), &args.get(2..).unwrap_or(&[]).to_vec()[..]).await,
11418 "borrow_isolated_margin" => self.borrow_isolated_margin(args.get(0).cloned().unwrap_or(crate::Value::Null), args.get(1).cloned().unwrap_or(crate::Value::Null), args.get(2).cloned().unwrap_or(crate::Value::Null), &args.get(3..).unwrap_or(&[]).to_vec()[..]).await,
11419 "borrow_margin" => self.borrow_margin(args.get(0).cloned().unwrap_or(crate::Value::Null), args.get(1).cloned().unwrap_or(crate::Value::Null), &args.get(2..).unwrap_or(&[]).to_vec()[..]).await,
11420 "build_ohlcvc" => self.build_ohlcvc(args.get(0).cloned().unwrap_or(crate::Value::Null), &args.get(1..).unwrap_or(&[]).to_vec()[..]),
11421 "calculate_fee" => self.calculate_fee(args.get(0).cloned().unwrap_or(crate::Value::Null), args.get(1).cloned().unwrap_or(crate::Value::Null), args.get(2).cloned().unwrap_or(crate::Value::Null), args.get(3).cloned().unwrap_or(crate::Value::Null), args.get(4).cloned().unwrap_or(crate::Value::Null), &args.get(5..).unwrap_or(&[]).to_vec()[..]),
11422 "calculate_fee_with_rate" => self.calculate_fee_with_rate(args.get(0).cloned().unwrap_or(crate::Value::Null), args.get(1).cloned().unwrap_or(crate::Value::Null), args.get(2).cloned().unwrap_or(crate::Value::Null), args.get(3).cloned().unwrap_or(crate::Value::Null), args.get(4).cloned().unwrap_or(crate::Value::Null), &args.get(5..).unwrap_or(&[]).to_vec()[..]),
11423 "calculate_rate_limiter_cost" => self.calculate_rate_limiter_cost(args.get(0).cloned().unwrap_or(crate::Value::Null), args.get(1).cloned().unwrap_or(crate::Value::Null), args.get(2).cloned().unwrap_or(crate::Value::Null), args.get(3).cloned().unwrap_or(crate::Value::Null), &args.get(4..).unwrap_or(&[]).to_vec()[..]),
11424 "call_method" => self.call_method(args.get(0).cloned().unwrap_or(crate::Value::Null), &args.get(1..).unwrap_or(&[]).to_vec()[..]).await,
11425 "cancel_all_contract_orders" => self.cancel_all_contract_orders(&args.get(0..).unwrap_or(&[]).to_vec()[..]).await,
11426 "cancel_all_orders" => self.cancel_all_orders(&args.get(0..).unwrap_or(&[]).to_vec()[..]).await,
11427 "cancel_all_orders_after" => self.cancel_all_orders_after(args.get(0).cloned().unwrap_or(crate::Value::Null), &args.get(1..).unwrap_or(&[]).to_vec()[..]).await,
11428 "cancel_all_orders_ws" => self.cancel_all_orders_ws(&args.get(0..).unwrap_or(&[]).to_vec()[..]).await,
11429 "cancel_all_spot_orders" => self.cancel_all_spot_orders(&args.get(0..).unwrap_or(&[]).to_vec()[..]).await,
11430 "cancel_contract_order" => self.cancel_contract_order(args.get(0).cloned().unwrap_or(crate::Value::Null), &args.get(1..).unwrap_or(&[]).to_vec()[..]).await,
11431 "cancel_order" => self.cancel_order(args.get(0).cloned().unwrap_or(crate::Value::Null), &args.get(1..).unwrap_or(&[]).to_vec()[..]).await,
11432 "cancel_order_with_client_order_id" => self.cancel_order_with_client_order_id(args.get(0).cloned().unwrap_or(crate::Value::Null), &args.get(1..).unwrap_or(&[]).to_vec()[..]).await,
11433 "cancel_order_ws" => self.cancel_order_ws(args.get(0).cloned().unwrap_or(crate::Value::Null), &args.get(1..).unwrap_or(&[]).to_vec()[..]).await,
11434 "cancel_orders" => self.cancel_orders(args.get(0).cloned().unwrap_or(crate::Value::Null), &args.get(1..).unwrap_or(&[]).to_vec()[..]).await,
11435 "cancel_orders_for_symbols" => self.cancel_orders_for_symbols(args.get(0).cloned().unwrap_or(crate::Value::Null), &args.get(1..).unwrap_or(&[]).to_vec()[..]).await,
11436 "cancel_orders_with_client_order_ids" => self.cancel_orders_with_client_order_ids(args.get(0).cloned().unwrap_or(crate::Value::Null), &args.get(1..).unwrap_or(&[]).to_vec()[..]).await,
11437 "cancel_orders_ws" => self.cancel_orders_ws(args.get(0).cloned().unwrap_or(crate::Value::Null), &args.get(1..).unwrap_or(&[]).to_vec()[..]).await,
11438 "cancel_spot_order" => self.cancel_spot_order(args.get(0).cloned().unwrap_or(crate::Value::Null), &args.get(1..).unwrap_or(&[]).to_vec()[..]).await,
11439 "cancel_unified_order" => self.cancel_unified_order(args.get(0).cloned().unwrap_or(crate::Value::Null), &args.get(1..).unwrap_or(&[]).to_vec()[..]).await,
11440 "check_address" => self.check_address(&args.get(0..).unwrap_or(&[]).to_vec()[..]),
11441 "check_proxy_settings" => self.check_proxy_settings(&args.get(0..).unwrap_or(&[]).to_vec()[..]),
11442 "check_proxy_url_settings" => self.check_proxy_url_settings(&args.get(0..).unwrap_or(&[]).to_vec()[..]),
11443 "check_required_credentials" => self.check_required_credentials(&args.get(0..).unwrap_or(&[]).to_vec()[..]),
11444 "check_ws_proxy_settings" => self.check_ws_proxy_settings(),
11445 "close_all_positions" => self.close_all_positions(&args.get(0..).unwrap_or(&[]).to_vec()[..]).await,
11446 "close_position" => self.close_position(args.get(0).cloned().unwrap_or(crate::Value::Null), &args.get(1..).unwrap_or(&[]).to_vec()[..]).await,
11447 "common_currency_code" => self.common_currency_code(args.get(0).cloned().unwrap_or(crate::Value::Null)),
11448 "convert_expire_date" => self.convert_expire_date(args.get(0).cloned().unwrap_or(crate::Value::Null)),
11449 "convert_expire_date_to_market_id_date" => self.convert_expire_date_to_market_id_date(args.get(0).cloned().unwrap_or(crate::Value::Null)),
11450 "convert_market_id_expire_date" => self.convert_market_id_expire_date(args.get(0).cloned().unwrap_or(crate::Value::Null)),
11451 "convert_ohlcv_to_trading_view" => self.convert_ohlcv_to_trading_view(args.get(0).cloned().unwrap_or(crate::Value::Null), &args.get(1..).unwrap_or(&[]).to_vec()[..]),
11452 "convert_trading_view_to_ohlcv" => self.convert_trading_view_to_ohlcv(args.get(0).cloned().unwrap_or(crate::Value::Null), &args.get(1..).unwrap_or(&[]).to_vec()[..]),
11453 "convert_type_to_account" => self.convert_type_to_account(args.get(0).cloned().unwrap_or(crate::Value::Null)),
11454 "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)),
11455 "create_ccxt_trade_id" => self.create_ccxt_trade_id(&args.get(0..).unwrap_or(&[]).to_vec()[..]),
11456 "create_contract_orders" => self.create_contract_orders(args.get(0).cloned().unwrap_or(crate::Value::Null), &args.get(1..).unwrap_or(&[]).to_vec()[..]).await,
11457 "create_convert_trade" => self.create_convert_trade(args.get(0).cloned().unwrap_or(crate::Value::Null), args.get(1).cloned().unwrap_or(crate::Value::Null), args.get(2).cloned().unwrap_or(crate::Value::Null), &args.get(3..).unwrap_or(&[]).to_vec()[..]).await,
11458 "create_deposit_address" => self.create_deposit_address(args.get(0).cloned().unwrap_or(crate::Value::Null), &args.get(1..).unwrap_or(&[]).to_vec()[..]).await,
11459 "create_expired_option_market" => <Self as crate::exchange_generated::ExchangeBase>::create_expired_option_market(self, args.get(0).cloned().unwrap_or(crate::Value::Null)),
11460 "create_limit_buy_order" => self.create_limit_buy_order(args.get(0).cloned().unwrap_or(crate::Value::Null), args.get(1).cloned().unwrap_or(crate::Value::Null), args.get(2).cloned().unwrap_or(crate::Value::Null), &args.get(3..).unwrap_or(&[]).to_vec()[..]).await,
11461 "create_limit_buy_order_ws" => self.create_limit_buy_order_ws(args.get(0).cloned().unwrap_or(crate::Value::Null), args.get(1).cloned().unwrap_or(crate::Value::Null), args.get(2).cloned().unwrap_or(crate::Value::Null), &args.get(3..).unwrap_or(&[]).to_vec()[..]).await,
11462 "create_limit_order" => self.create_limit_order(args.get(0).cloned().unwrap_or(crate::Value::Null), args.get(1).cloned().unwrap_or(crate::Value::Null), args.get(2).cloned().unwrap_or(crate::Value::Null), args.get(3).cloned().unwrap_or(crate::Value::Null), &args.get(4..).unwrap_or(&[]).to_vec()[..]).await,
11463 "create_limit_order_ws" => self.create_limit_order_ws(args.get(0).cloned().unwrap_or(crate::Value::Null), args.get(1).cloned().unwrap_or(crate::Value::Null), args.get(2).cloned().unwrap_or(crate::Value::Null), args.get(3).cloned().unwrap_or(crate::Value::Null), &args.get(4..).unwrap_or(&[]).to_vec()[..]).await,
11464 "create_limit_sell_order" => self.create_limit_sell_order(args.get(0).cloned().unwrap_or(crate::Value::Null), args.get(1).cloned().unwrap_or(crate::Value::Null), args.get(2).cloned().unwrap_or(crate::Value::Null), &args.get(3..).unwrap_or(&[]).to_vec()[..]).await,
11465 "create_limit_sell_order_ws" => self.create_limit_sell_order_ws(args.get(0).cloned().unwrap_or(crate::Value::Null), args.get(1).cloned().unwrap_or(crate::Value::Null), args.get(2).cloned().unwrap_or(crate::Value::Null), &args.get(3..).unwrap_or(&[]).to_vec()[..]).await,
11466 "create_market_buy_order" => self.create_market_buy_order(args.get(0).cloned().unwrap_or(crate::Value::Null), args.get(1).cloned().unwrap_or(crate::Value::Null), &args.get(2..).unwrap_or(&[]).to_vec()[..]).await,
11467 "create_market_buy_order_with_cost" => self.create_market_buy_order_with_cost(args.get(0).cloned().unwrap_or(crate::Value::Null), args.get(1).cloned().unwrap_or(crate::Value::Null), &args.get(2..).unwrap_or(&[]).to_vec()[..]).await,
11468 "create_market_buy_order_ws" => self.create_market_buy_order_ws(args.get(0).cloned().unwrap_or(crate::Value::Null), args.get(1).cloned().unwrap_or(crate::Value::Null), &args.get(2..).unwrap_or(&[]).to_vec()[..]).await,
11469 "create_market_order" => self.create_market_order(args.get(0).cloned().unwrap_or(crate::Value::Null), args.get(1).cloned().unwrap_or(crate::Value::Null), args.get(2).cloned().unwrap_or(crate::Value::Null), &args.get(3..).unwrap_or(&[]).to_vec()[..]).await,
11470 "create_market_order_with_cost" => self.create_market_order_with_cost(args.get(0).cloned().unwrap_or(crate::Value::Null), args.get(1).cloned().unwrap_or(crate::Value::Null), args.get(2).cloned().unwrap_or(crate::Value::Null), &args.get(3..).unwrap_or(&[]).to_vec()[..]).await,
11471 "create_market_order_with_cost_ws" => self.create_market_order_with_cost_ws(args.get(0).cloned().unwrap_or(crate::Value::Null), args.get(1).cloned().unwrap_or(crate::Value::Null), args.get(2).cloned().unwrap_or(crate::Value::Null), &args.get(3..).unwrap_or(&[]).to_vec()[..]).await,
11472 "create_market_order_ws" => self.create_market_order_ws(args.get(0).cloned().unwrap_or(crate::Value::Null), args.get(1).cloned().unwrap_or(crate::Value::Null), args.get(2).cloned().unwrap_or(crate::Value::Null), &args.get(3..).unwrap_or(&[]).to_vec()[..]).await,
11473 "create_market_sell_order" => self.create_market_sell_order(args.get(0).cloned().unwrap_or(crate::Value::Null), args.get(1).cloned().unwrap_or(crate::Value::Null), &args.get(2..).unwrap_or(&[]).to_vec()[..]).await,
11474 "create_market_sell_order_with_cost" => self.create_market_sell_order_with_cost(args.get(0).cloned().unwrap_or(crate::Value::Null), args.get(1).cloned().unwrap_or(crate::Value::Null), &args.get(2..).unwrap_or(&[]).to_vec()[..]).await,
11475 "create_market_sell_order_ws" => self.create_market_sell_order_ws(args.get(0).cloned().unwrap_or(crate::Value::Null), args.get(1).cloned().unwrap_or(crate::Value::Null), &args.get(2..).unwrap_or(&[]).to_vec()[..]).await,
11476 "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)),
11477 "create_order" => self.create_order(args.get(0).cloned().unwrap_or(crate::Value::Null), args.get(1).cloned().unwrap_or(crate::Value::Null), args.get(2).cloned().unwrap_or(crate::Value::Null), args.get(3).cloned().unwrap_or(crate::Value::Null), &args.get(4..).unwrap_or(&[]).to_vec()[..]).await,
11478 "create_order_with_take_profit_and_stop_loss" => self.create_order_with_take_profit_and_stop_loss(args.get(0).cloned().unwrap_or(crate::Value::Null), args.get(1).cloned().unwrap_or(crate::Value::Null), args.get(2).cloned().unwrap_or(crate::Value::Null), args.get(3).cloned().unwrap_or(crate::Value::Null), &args.get(4..).unwrap_or(&[]).to_vec()[..]).await,
11479 "create_order_with_take_profit_and_stop_loss_ws" => self.create_order_with_take_profit_and_stop_loss_ws(args.get(0).cloned().unwrap_or(crate::Value::Null), args.get(1).cloned().unwrap_or(crate::Value::Null), args.get(2).cloned().unwrap_or(crate::Value::Null), args.get(3).cloned().unwrap_or(crate::Value::Null), &args.get(4..).unwrap_or(&[]).to_vec()[..]).await,
11480 "create_order_ws" => self.create_order_ws(args.get(0).cloned().unwrap_or(crate::Value::Null), args.get(1).cloned().unwrap_or(crate::Value::Null), args.get(2).cloned().unwrap_or(crate::Value::Null), args.get(3).cloned().unwrap_or(crate::Value::Null), &args.get(4..).unwrap_or(&[]).to_vec()[..]).await,
11481 "create_orders" => self.create_orders(args.get(0).cloned().unwrap_or(crate::Value::Null), &args.get(1..).unwrap_or(&[]).to_vec()[..]).await,
11482 "create_orders_ws" => self.create_orders_ws(args.get(0).cloned().unwrap_or(crate::Value::Null), &args.get(1..).unwrap_or(&[]).to_vec()[..]).await,
11483 "create_post_only_order" => self.create_post_only_order(args.get(0).cloned().unwrap_or(crate::Value::Null), args.get(1).cloned().unwrap_or(crate::Value::Null), args.get(2).cloned().unwrap_or(crate::Value::Null), args.get(3).cloned().unwrap_or(crate::Value::Null), &args.get(4..).unwrap_or(&[]).to_vec()[..]).await,
11484 "create_post_only_order_ws" => self.create_post_only_order_ws(args.get(0).cloned().unwrap_or(crate::Value::Null), args.get(1).cloned().unwrap_or(crate::Value::Null), args.get(2).cloned().unwrap_or(crate::Value::Null), args.get(3).cloned().unwrap_or(crate::Value::Null), &args.get(4..).unwrap_or(&[]).to_vec()[..]).await,
11485 "create_reduce_only_order" => self.create_reduce_only_order(args.get(0).cloned().unwrap_or(crate::Value::Null), args.get(1).cloned().unwrap_or(crate::Value::Null), args.get(2).cloned().unwrap_or(crate::Value::Null), args.get(3).cloned().unwrap_or(crate::Value::Null), &args.get(4..).unwrap_or(&[]).to_vec()[..]).await,
11486 "create_reduce_only_order_ws" => self.create_reduce_only_order_ws(args.get(0).cloned().unwrap_or(crate::Value::Null), args.get(1).cloned().unwrap_or(crate::Value::Null), args.get(2).cloned().unwrap_or(crate::Value::Null), args.get(3).cloned().unwrap_or(crate::Value::Null), &args.get(4..).unwrap_or(&[]).to_vec()[..]).await,
11487 "create_spot_orders" => self.create_spot_orders(args.get(0).cloned().unwrap_or(crate::Value::Null), &args.get(1..).unwrap_or(&[]).to_vec()[..]).await,
11488 "create_stop_limit_order" => self.create_stop_limit_order(args.get(0).cloned().unwrap_or(crate::Value::Null), args.get(1).cloned().unwrap_or(crate::Value::Null), args.get(2).cloned().unwrap_or(crate::Value::Null), args.get(3).cloned().unwrap_or(crate::Value::Null), args.get(4).cloned().unwrap_or(crate::Value::Null), &args.get(5..).unwrap_or(&[]).to_vec()[..]).await,
11489 "create_stop_limit_order_ws" => self.create_stop_limit_order_ws(args.get(0).cloned().unwrap_or(crate::Value::Null), args.get(1).cloned().unwrap_or(crate::Value::Null), args.get(2).cloned().unwrap_or(crate::Value::Null), args.get(3).cloned().unwrap_or(crate::Value::Null), args.get(4).cloned().unwrap_or(crate::Value::Null), &args.get(5..).unwrap_or(&[]).to_vec()[..]).await,
11490 "create_stop_loss_order" => self.create_stop_loss_order(args.get(0).cloned().unwrap_or(crate::Value::Null), args.get(1).cloned().unwrap_or(crate::Value::Null), args.get(2).cloned().unwrap_or(crate::Value::Null), args.get(3).cloned().unwrap_or(crate::Value::Null), &args.get(4..).unwrap_or(&[]).to_vec()[..]).await,
11491 "create_stop_loss_order_ws" => self.create_stop_loss_order_ws(args.get(0).cloned().unwrap_or(crate::Value::Null), args.get(1).cloned().unwrap_or(crate::Value::Null), args.get(2).cloned().unwrap_or(crate::Value::Null), args.get(3).cloned().unwrap_or(crate::Value::Null), &args.get(4..).unwrap_or(&[]).to_vec()[..]).await,
11492 "create_stop_market_order" => self.create_stop_market_order(args.get(0).cloned().unwrap_or(crate::Value::Null), args.get(1).cloned().unwrap_or(crate::Value::Null), args.get(2).cloned().unwrap_or(crate::Value::Null), args.get(3).cloned().unwrap_or(crate::Value::Null), &args.get(4..).unwrap_or(&[]).to_vec()[..]).await,
11493 "create_stop_market_order_ws" => self.create_stop_market_order_ws(args.get(0).cloned().unwrap_or(crate::Value::Null), args.get(1).cloned().unwrap_or(crate::Value::Null), args.get(2).cloned().unwrap_or(crate::Value::Null), args.get(3).cloned().unwrap_or(crate::Value::Null), &args.get(4..).unwrap_or(&[]).to_vec()[..]).await,
11494 "create_stop_order" => self.create_stop_order(args.get(0).cloned().unwrap_or(crate::Value::Null), args.get(1).cloned().unwrap_or(crate::Value::Null), args.get(2).cloned().unwrap_or(crate::Value::Null), args.get(3).cloned().unwrap_or(crate::Value::Null), &args.get(4..).unwrap_or(&[]).to_vec()[..]).await,
11495 "create_stop_order_ws" => self.create_stop_order_ws(args.get(0).cloned().unwrap_or(crate::Value::Null), args.get(1).cloned().unwrap_or(crate::Value::Null), args.get(2).cloned().unwrap_or(crate::Value::Null), args.get(3).cloned().unwrap_or(crate::Value::Null), &args.get(4..).unwrap_or(&[]).to_vec()[..]).await,
11496 "create_sub_account" => self.create_sub_account(args.get(0).cloned().unwrap_or(crate::Value::Null), &args.get(1..).unwrap_or(&[]).to_vec()[..]).await,
11497 "create_take_profit_order" => self.create_take_profit_order(args.get(0).cloned().unwrap_or(crate::Value::Null), args.get(1).cloned().unwrap_or(crate::Value::Null), args.get(2).cloned().unwrap_or(crate::Value::Null), args.get(3).cloned().unwrap_or(crate::Value::Null), &args.get(4..).unwrap_or(&[]).to_vec()[..]).await,
11498 "create_take_profit_order_ws" => self.create_take_profit_order_ws(args.get(0).cloned().unwrap_or(crate::Value::Null), args.get(1).cloned().unwrap_or(crate::Value::Null), args.get(2).cloned().unwrap_or(crate::Value::Null), args.get(3).cloned().unwrap_or(crate::Value::Null), &args.get(4..).unwrap_or(&[]).to_vec()[..]).await,
11499 "create_trailing_amount_order" => self.create_trailing_amount_order(args.get(0).cloned().unwrap_or(crate::Value::Null), args.get(1).cloned().unwrap_or(crate::Value::Null), args.get(2).cloned().unwrap_or(crate::Value::Null), args.get(3).cloned().unwrap_or(crate::Value::Null), &args.get(4..).unwrap_or(&[]).to_vec()[..]).await,
11500 "create_trailing_amount_order_ws" => self.create_trailing_amount_order_ws(args.get(0).cloned().unwrap_or(crate::Value::Null), args.get(1).cloned().unwrap_or(crate::Value::Null), args.get(2).cloned().unwrap_or(crate::Value::Null), args.get(3).cloned().unwrap_or(crate::Value::Null), &args.get(4..).unwrap_or(&[]).to_vec()[..]).await,
11501 "create_trailing_percent_order" => self.create_trailing_percent_order(args.get(0).cloned().unwrap_or(crate::Value::Null), args.get(1).cloned().unwrap_or(crate::Value::Null), args.get(2).cloned().unwrap_or(crate::Value::Null), args.get(3).cloned().unwrap_or(crate::Value::Null), &args.get(4..).unwrap_or(&[]).to_vec()[..]).await,
11502 "create_trailing_percent_order_ws" => self.create_trailing_percent_order_ws(args.get(0).cloned().unwrap_or(crate::Value::Null), args.get(1).cloned().unwrap_or(crate::Value::Null), args.get(2).cloned().unwrap_or(crate::Value::Null), args.get(3).cloned().unwrap_or(crate::Value::Null), &args.get(4..).unwrap_or(&[]).to_vec()[..]).await,
11503 "create_trigger_order" => self.create_trigger_order(args.get(0).cloned().unwrap_or(crate::Value::Null), args.get(1).cloned().unwrap_or(crate::Value::Null), args.get(2).cloned().unwrap_or(crate::Value::Null), args.get(3).cloned().unwrap_or(crate::Value::Null), &args.get(4..).unwrap_or(&[]).to_vec()[..]).await,
11504 "create_trigger_order_ws" => self.create_trigger_order_ws(args.get(0).cloned().unwrap_or(crate::Value::Null), args.get(1).cloned().unwrap_or(crate::Value::Null), args.get(2).cloned().unwrap_or(crate::Value::Null), args.get(3).cloned().unwrap_or(crate::Value::Null), &args.get(4..).unwrap_or(&[]).to_vec()[..]).await,
11505 "create_twap_order" => self.create_twap_order(args.get(0).cloned().unwrap_or(crate::Value::Null), args.get(1).cloned().unwrap_or(crate::Value::Null), args.get(2).cloned().unwrap_or(crate::Value::Null), args.get(3).cloned().unwrap_or(crate::Value::Null), &args.get(4..).unwrap_or(&[]).to_vec()[..]).await,
11506 "currency" => self.currency(args.get(0).cloned().unwrap_or(crate::Value::Null)),
11507 "currency_id" => self.currency_id(args.get(0).cloned().unwrap_or(crate::Value::Null)),
11508 "currency_ids" => self.currency_ids(&args.get(0..).unwrap_or(&[]).to_vec()[..]),
11509 "currency_to_precision" => self.currency_to_precision(args.get(0).cloned().unwrap_or(crate::Value::Null), args.get(1).cloned().unwrap_or(crate::Value::Null), &args.get(2..).unwrap_or(&[]).to_vec()[..]),
11510 "default_network_code" => self.default_network_code(args.get(0).cloned().unwrap_or(crate::Value::Null)),
11511 "deposit_withdraw_fee" => self.deposit_withdraw_fee(args.get(0).cloned().unwrap_or(crate::Value::Null)),
11512 "edit_limit_buy_order" => self.edit_limit_buy_order(args.get(0).cloned().unwrap_or(crate::Value::Null), args.get(1).cloned().unwrap_or(crate::Value::Null), args.get(2).cloned().unwrap_or(crate::Value::Null), &args.get(3..).unwrap_or(&[]).to_vec()[..]).await,
11513 "edit_limit_order" => self.edit_limit_order(args.get(0).cloned().unwrap_or(crate::Value::Null), args.get(1).cloned().unwrap_or(crate::Value::Null), args.get(2).cloned().unwrap_or(crate::Value::Null), args.get(3).cloned().unwrap_or(crate::Value::Null), &args.get(4..).unwrap_or(&[]).to_vec()[..]).await,
11514 "edit_limit_sell_order" => self.edit_limit_sell_order(args.get(0).cloned().unwrap_or(crate::Value::Null), args.get(1).cloned().unwrap_or(crate::Value::Null), args.get(2).cloned().unwrap_or(crate::Value::Null), &args.get(3..).unwrap_or(&[]).to_vec()[..]).await,
11515 "edit_order" => self.edit_order(args.get(0).cloned().unwrap_or(crate::Value::Null), args.get(1).cloned().unwrap_or(crate::Value::Null), args.get(2).cloned().unwrap_or(crate::Value::Null), args.get(3).cloned().unwrap_or(crate::Value::Null), &args.get(4..).unwrap_or(&[]).to_vec()[..]).await,
11516 "edit_order_with_client_order_id" => self.edit_order_with_client_order_id(args.get(0).cloned().unwrap_or(crate::Value::Null), args.get(1).cloned().unwrap_or(crate::Value::Null), args.get(2).cloned().unwrap_or(crate::Value::Null), args.get(3).cloned().unwrap_or(crate::Value::Null), &args.get(4..).unwrap_or(&[]).to_vec()[..]).await,
11517 "edit_order_ws" => self.edit_order_ws(args.get(0).cloned().unwrap_or(crate::Value::Null), args.get(1).cloned().unwrap_or(crate::Value::Null), args.get(2).cloned().unwrap_or(crate::Value::Null), args.get(3).cloned().unwrap_or(crate::Value::Null), &args.get(4..).unwrap_or(&[]).to_vec()[..]).await,
11518 "edit_orders" => self.edit_orders(args.get(0).cloned().unwrap_or(crate::Value::Null), &args.get(1..).unwrap_or(&[]).to_vec()[..]).await,
11519 "feature_value" => self.feature_value(args.get(0).cloned().unwrap_or(crate::Value::Null), &args.get(1..).unwrap_or(&[]).to_vec()[..]),
11520 "feature_value_by_type" => self.feature_value_by_type(args.get(0).cloned().unwrap_or(crate::Value::Null), args.get(1).cloned().unwrap_or(crate::Value::Null), &args.get(2..).unwrap_or(&[]).to_vec()[..]),
11521 "features_mapper" => self.features_mapper(args.get(0).cloned().unwrap_or(crate::Value::Null), args.get(1).cloned().unwrap_or(crate::Value::Null), &args.get(2..).unwrap_or(&[]).to_vec()[..]),
11522 "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)),
11523 "fetch" => self.fetch(args.get(0).cloned().unwrap_or(crate::Value::Null), &args.get(1..).unwrap_or(&[]).to_vec()[..]).await,
11524 "fetch2" => self.fetch2(args.get(0).cloned().unwrap_or(crate::Value::Null), &args.get(1..).unwrap_or(&[]).to_vec()[..]).await,
11525 "fetch_accounts" => self.fetch_accounts(&args.get(0..).unwrap_or(&[]).to_vec()[..]).await,
11526 "fetch_adl_rank" => self.fetch_adl_rank(args.get(0).cloned().unwrap_or(crate::Value::Null), &args.get(1..).unwrap_or(&[]).to_vec()[..]).await,
11527 "fetch_all_greeks" => self.fetch_all_greeks(&args.get(0..).unwrap_or(&[]).to_vec()[..]).await,
11528 "fetch_balance" => self.fetch_balance(&args.get(0..).unwrap_or(&[]).to_vec()[..]).await,
11529 "fetch_balance_ws" => self.fetch_balance_ws(&args.get(0..).unwrap_or(&[]).to_vec()[..]).await,
11530 "fetch_bids_asks" => self.fetch_bids_asks(&args.get(0..).unwrap_or(&[]).to_vec()[..]).await,
11531 "fetch_borrow_interest" => self.fetch_borrow_interest(&args.get(0..).unwrap_or(&[]).to_vec()[..]).await,
11532 "fetch_borrow_rate" => self.fetch_borrow_rate(args.get(0).cloned().unwrap_or(crate::Value::Null), args.get(1).cloned().unwrap_or(crate::Value::Null), &args.get(2..).unwrap_or(&[]).to_vec()[..]).await,
11533 "fetch_canceled_and_closed_orders" => self.fetch_canceled_and_closed_orders(&args.get(0..).unwrap_or(&[]).to_vec()[..]).await,
11534 "fetch_canceled_orders" => self.fetch_canceled_orders(&args.get(0..).unwrap_or(&[]).to_vec()[..]).await,
11535 "fetch_closed_orders" => self.fetch_closed_orders(&args.get(0..).unwrap_or(&[]).to_vec()[..]).await,
11536 "fetch_closed_orders_ws" => self.fetch_closed_orders_ws(&args.get(0..).unwrap_or(&[]).to_vec()[..]).await,
11537 "fetch_contract_deposit_address" => self.fetch_contract_deposit_address(args.get(0).cloned().unwrap_or(crate::Value::Null), &args.get(1..).unwrap_or(&[]).to_vec()[..]).await,
11538 "fetch_contract_ohlcv" => self.fetch_contract_ohlcv(args.get(0).cloned().unwrap_or(crate::Value::Null), &args.get(1..).unwrap_or(&[]).to_vec()[..]).await,
11539 "fetch_contract_tickers" => self.fetch_contract_tickers(&args.get(0..).unwrap_or(&[]).to_vec()[..]).await,
11540 "fetch_convert_currencies" => self.fetch_convert_currencies(&args.get(0..).unwrap_or(&[]).to_vec()[..]).await,
11541 "fetch_convert_quote" => self.fetch_convert_quote(args.get(0).cloned().unwrap_or(crate::Value::Null), args.get(1).cloned().unwrap_or(crate::Value::Null), &args.get(2..).unwrap_or(&[]).to_vec()[..]).await,
11542 "fetch_convert_trade" => self.fetch_convert_trade(args.get(0).cloned().unwrap_or(crate::Value::Null), &args.get(1..).unwrap_or(&[]).to_vec()[..]).await,
11543 "fetch_convert_trade_history" => self.fetch_convert_trade_history(&args.get(0..).unwrap_or(&[]).to_vec()[..]).await,
11544 "fetch_cross_borrow_rate" => self.fetch_cross_borrow_rate(args.get(0).cloned().unwrap_or(crate::Value::Null), &args.get(1..).unwrap_or(&[]).to_vec()[..]).await,
11545 "fetch_cross_borrow_rates" => self.fetch_cross_borrow_rates(&args.get(0..).unwrap_or(&[]).to_vec()[..]).await,
11546 "fetch_deposit_address" => self.fetch_deposit_address(args.get(0).cloned().unwrap_or(crate::Value::Null), &args.get(1..).unwrap_or(&[]).to_vec()[..]).await,
11547 "fetch_deposit_addresses" => self.fetch_deposit_addresses(&args.get(0..).unwrap_or(&[]).to_vec()[..]).await,
11548 "fetch_deposit_addresses_by_network" => self.fetch_deposit_addresses_by_network(args.get(0).cloned().unwrap_or(crate::Value::Null), &args.get(1..).unwrap_or(&[]).to_vec()[..]).await,
11549 "fetch_deposit_withdraw_fee" => self.fetch_deposit_withdraw_fee(args.get(0).cloned().unwrap_or(crate::Value::Null), &args.get(1..).unwrap_or(&[]).to_vec()[..]).await,
11550 "fetch_deposit_withdraw_fees" => self.fetch_deposit_withdraw_fees(&args.get(0..).unwrap_or(&[]).to_vec()[..]).await,
11551 "fetch_deposits" => self.fetch_deposits(&args.get(0..).unwrap_or(&[]).to_vec()[..]).await,
11552 "fetch_deposits_withdrawals" => self.fetch_deposits_withdrawals(&args.get(0..).unwrap_or(&[]).to_vec()[..]).await,
11553 "fetch_deposits_ws" => self.fetch_deposits_ws(&args.get(0..).unwrap_or(&[]).to_vec()[..]).await,
11554 "fetch_free_balance" => self.fetch_free_balance(&args.get(0..).unwrap_or(&[]).to_vec()[..]).await,
11555 "fetch_funding_history" => self.fetch_funding_history(&args.get(0..).unwrap_or(&[]).to_vec()[..]).await,
11556 "fetch_funding_interval" => self.fetch_funding_interval(args.get(0).cloned().unwrap_or(crate::Value::Null), &args.get(1..).unwrap_or(&[]).to_vec()[..]).await,
11557 "fetch_funding_intervals" => self.fetch_funding_intervals(&args.get(0..).unwrap_or(&[]).to_vec()[..]).await,
11558 "fetch_funding_rate" => self.fetch_funding_rate(args.get(0).cloned().unwrap_or(crate::Value::Null), &args.get(1..).unwrap_or(&[]).to_vec()[..]).await,
11559 "fetch_funding_rate_history" => self.fetch_funding_rate_history(&args.get(0..).unwrap_or(&[]).to_vec()[..]).await,
11560 "fetch_funding_rates" => self.fetch_funding_rates(&args.get(0..).unwrap_or(&[]).to_vec()[..]).await,
11561 "fetch_greeks" => self.fetch_greeks(args.get(0).cloned().unwrap_or(crate::Value::Null), &args.get(1..).unwrap_or(&[]).to_vec()[..]).await,
11562 "fetch_index_ohlcv" => self.fetch_index_ohlcv(args.get(0).cloned().unwrap_or(crate::Value::Null), &args.get(1..).unwrap_or(&[]).to_vec()[..]).await,
11563 "fetch_isolated_borrow_rate" => self.fetch_isolated_borrow_rate(args.get(0).cloned().unwrap_or(crate::Value::Null), &args.get(1..).unwrap_or(&[]).to_vec()[..]).await,
11564 "fetch_isolated_borrow_rates" => self.fetch_isolated_borrow_rates(&args.get(0..).unwrap_or(&[]).to_vec()[..]).await,
11565 "fetch_l2_order_book" => self.fetch_l2_order_book(args.get(0).cloned().unwrap_or(crate::Value::Null), &args.get(1..).unwrap_or(&[]).to_vec()[..]).await,
11566 "fetch_l3_order_book" => self.fetch_l3_order_book(args.get(0).cloned().unwrap_or(crate::Value::Null), &args.get(1..).unwrap_or(&[]).to_vec()[..]).await,
11567 "fetch_last_prices" => self.fetch_last_prices(&args.get(0..).unwrap_or(&[]).to_vec()[..]).await,
11568 "fetch_ledger" => self.fetch_ledger(&args.get(0..).unwrap_or(&[]).to_vec()[..]).await,
11569 "fetch_ledger_entry" => self.fetch_ledger_entry(args.get(0).cloned().unwrap_or(crate::Value::Null), &args.get(1..).unwrap_or(&[]).to_vec()[..]).await,
11570 "fetch_leverage" => self.fetch_leverage(args.get(0).cloned().unwrap_or(crate::Value::Null), &args.get(1..).unwrap_or(&[]).to_vec()[..]).await,
11571 "fetch_leverage_tiers" => self.fetch_leverage_tiers(&args.get(0..).unwrap_or(&[]).to_vec()[..]).await,
11572 "fetch_leverages" => self.fetch_leverages(&args.get(0..).unwrap_or(&[]).to_vec()[..]).await,
11573 "fetch_liquidations" => self.fetch_liquidations(args.get(0).cloned().unwrap_or(crate::Value::Null), &args.get(1..).unwrap_or(&[]).to_vec()[..]).await,
11574 "fetch_long_short_ratio" => self.fetch_long_short_ratio(args.get(0).cloned().unwrap_or(crate::Value::Null), &args.get(1..).unwrap_or(&[]).to_vec()[..]).await,
11575 "fetch_long_short_ratio_history" => self.fetch_long_short_ratio_history(&args.get(0..).unwrap_or(&[]).to_vec()[..]).await,
11576 "fetch_margin_adjustment_history" => self.fetch_margin_adjustment_history(&args.get(0..).unwrap_or(&[]).to_vec()[..]).await,
11577 "fetch_margin_mode" => self.fetch_margin_mode(args.get(0).cloned().unwrap_or(crate::Value::Null), &args.get(1..).unwrap_or(&[]).to_vec()[..]).await,
11578 "fetch_margin_modes" => self.fetch_margin_modes(&args.get(0..).unwrap_or(&[]).to_vec()[..]).await,
11579 "fetch_mark_ohlcv" => self.fetch_mark_ohlcv(args.get(0).cloned().unwrap_or(crate::Value::Null), &args.get(1..).unwrap_or(&[]).to_vec()[..]).await,
11580 "fetch_mark_price" => self.fetch_mark_price(args.get(0).cloned().unwrap_or(crate::Value::Null), &args.get(1..).unwrap_or(&[]).to_vec()[..]).await,
11581 "fetch_mark_prices" => self.fetch_mark_prices(&args.get(0..).unwrap_or(&[]).to_vec()[..]).await,
11582 "fetch_market_leverage_tiers" => self.fetch_market_leverage_tiers(args.get(0).cloned().unwrap_or(crate::Value::Null), &args.get(1..).unwrap_or(&[]).to_vec()[..]).await,
11583 "fetch_my_liquidations" => self.fetch_my_liquidations(&args.get(0..).unwrap_or(&[]).to_vec()[..]).await,
11584 "fetch_my_trades" => self.fetch_my_trades(&args.get(0..).unwrap_or(&[]).to_vec()[..]).await,
11585 "fetch_my_trades_ws" => self.fetch_my_trades_ws(&args.get(0..).unwrap_or(&[]).to_vec()[..]).await,
11586 "fetch_ohlcv" => self.fetch_ohlcv(args.get(0).cloned().unwrap_or(crate::Value::Null), &args.get(1..).unwrap_or(&[]).to_vec()[..]).await,
11587 "fetch_ohlcv_ws" => self.fetch_ohlcv_ws(args.get(0).cloned().unwrap_or(crate::Value::Null), &args.get(1..).unwrap_or(&[]).to_vec()[..]).await,
11588 "fetch_open_interest" => self.fetch_open_interest(args.get(0).cloned().unwrap_or(crate::Value::Null), &args.get(1..).unwrap_or(&[]).to_vec()[..]).await,
11589 "fetch_open_interest_history" => self.fetch_open_interest_history(args.get(0).cloned().unwrap_or(crate::Value::Null), &args.get(1..).unwrap_or(&[]).to_vec()[..]).await,
11590 "fetch_open_interests" => self.fetch_open_interests(&args.get(0..).unwrap_or(&[]).to_vec()[..]).await,
11591 "fetch_open_orders" => self.fetch_open_orders(&args.get(0..).unwrap_or(&[]).to_vec()[..]).await,
11592 "fetch_open_orders_ws" => self.fetch_open_orders_ws(&args.get(0..).unwrap_or(&[]).to_vec()[..]).await,
11593 "fetch_option" => self.fetch_option(args.get(0).cloned().unwrap_or(crate::Value::Null), &args.get(1..).unwrap_or(&[]).to_vec()[..]).await,
11594 "fetch_option_chain" => self.fetch_option_chain(args.get(0).cloned().unwrap_or(crate::Value::Null), &args.get(1..).unwrap_or(&[]).to_vec()[..]).await,
11595 "fetch_order" => self.fetch_order(args.get(0).cloned().unwrap_or(crate::Value::Null), &args.get(1..).unwrap_or(&[]).to_vec()[..]).await,
11596 "fetch_order_book" => self.fetch_order_book(args.get(0).cloned().unwrap_or(crate::Value::Null), &args.get(1..).unwrap_or(&[]).to_vec()[..]).await,
11597 "fetch_order_book_ws" => self.fetch_order_book_ws(args.get(0).cloned().unwrap_or(crate::Value::Null), &args.get(1..).unwrap_or(&[]).to_vec()[..]).await,
11598 "fetch_order_books" => self.fetch_order_books(&args.get(0..).unwrap_or(&[]).to_vec()[..]).await,
11599 "fetch_order_status" => self.fetch_order_status(args.get(0).cloned().unwrap_or(crate::Value::Null), &args.get(1..).unwrap_or(&[]).to_vec()[..]).await,
11600 "fetch_order_trades" => self.fetch_order_trades(args.get(0).cloned().unwrap_or(crate::Value::Null), &args.get(1..).unwrap_or(&[]).to_vec()[..]).await,
11601 "fetch_order_with_client_order_id" => self.fetch_order_with_client_order_id(args.get(0).cloned().unwrap_or(crate::Value::Null), &args.get(1..).unwrap_or(&[]).to_vec()[..]).await,
11602 "fetch_order_ws" => self.fetch_order_ws(args.get(0).cloned().unwrap_or(crate::Value::Null), &args.get(1..).unwrap_or(&[]).to_vec()[..]).await,
11603 "fetch_orders" => self.fetch_orders(&args.get(0..).unwrap_or(&[]).to_vec()[..]).await,
11604 "fetch_orders_by_status_ws" => self.fetch_orders_by_status_ws(args.get(0).cloned().unwrap_or(crate::Value::Null), &args.get(1..).unwrap_or(&[]).to_vec()[..]).await,
11605 "fetch_orders_ws" => self.fetch_orders_ws(&args.get(0..).unwrap_or(&[]).to_vec()[..]).await,
11606 "fetch_paginated_call_cursor" => self.fetch_paginated_call_cursor(args.get(0).cloned().unwrap_or(crate::Value::Null), &args.get(1..).unwrap_or(&[]).to_vec()[..]).await,
11607 "fetch_paginated_call_deterministic" => self.fetch_paginated_call_deterministic(args.get(0).cloned().unwrap_or(crate::Value::Null), &args.get(1..).unwrap_or(&[]).to_vec()[..]).await,
11608 "fetch_paginated_call_dynamic" => self.fetch_paginated_call_dynamic(args.get(0).cloned().unwrap_or(crate::Value::Null), &args.get(1..).unwrap_or(&[]).to_vec()[..]).await,
11609 "fetch_paginated_call_incremental" => self.fetch_paginated_call_incremental(args.get(0).cloned().unwrap_or(crate::Value::Null), &args.get(1..).unwrap_or(&[]).to_vec()[..]).await,
11610 "fetch_partial_balance" => self.fetch_partial_balance(args.get(0).cloned().unwrap_or(crate::Value::Null), &args.get(1..).unwrap_or(&[]).to_vec()[..]).await,
11611 "fetch_payment_methods" => self.fetch_payment_methods(&args.get(0..).unwrap_or(&[]).to_vec()[..]).await,
11612 "fetch_position" => self.fetch_position(args.get(0).cloned().unwrap_or(crate::Value::Null), &args.get(1..).unwrap_or(&[]).to_vec()[..]).await,
11613 "fetch_position_adl_rank" => self.fetch_position_adl_rank(args.get(0).cloned().unwrap_or(crate::Value::Null), &args.get(1..).unwrap_or(&[]).to_vec()[..]).await,
11614 "fetch_position_history" => self.fetch_position_history(args.get(0).cloned().unwrap_or(crate::Value::Null), &args.get(1..).unwrap_or(&[]).to_vec()[..]).await,
11615 "fetch_position_mode" => self.fetch_position_mode(&args.get(0..).unwrap_or(&[]).to_vec()[..]).await,
11616 "fetch_position_ws" => self.fetch_position_ws(args.get(0).cloned().unwrap_or(crate::Value::Null), &args.get(1..).unwrap_or(&[]).to_vec()[..]).await,
11617 "fetch_positions" => self.fetch_positions(&args.get(0..).unwrap_or(&[]).to_vec()[..]).await,
11618 "fetch_positions_adl_rank" => self.fetch_positions_adl_rank(&args.get(0..).unwrap_or(&[]).to_vec()[..]).await,
11619 "fetch_positions_for_symbol" => self.fetch_positions_for_symbol(args.get(0).cloned().unwrap_or(crate::Value::Null), &args.get(1..).unwrap_or(&[]).to_vec()[..]).await,
11620 "fetch_positions_for_symbol_ws" => self.fetch_positions_for_symbol_ws(args.get(0).cloned().unwrap_or(crate::Value::Null), &args.get(1..).unwrap_or(&[]).to_vec()[..]).await,
11621 "fetch_positions_history" => self.fetch_positions_history(&args.get(0..).unwrap_or(&[]).to_vec()[..]).await,
11622 "fetch_positions_risk" => self.fetch_positions_risk(&args.get(0..).unwrap_or(&[]).to_vec()[..]).await,
11623 "fetch_positions_ws" => self.fetch_positions_ws(&args.get(0..).unwrap_or(&[]).to_vec()[..]).await,
11624 "fetch_premium_index_ohlcv" => self.fetch_premium_index_ohlcv(args.get(0).cloned().unwrap_or(crate::Value::Null), &args.get(1..).unwrap_or(&[]).to_vec()[..]).await,
11625 "fetch_rest_order_book_safe" => self.fetch_rest_order_book_safe(args.get(0).cloned().unwrap_or(crate::Value::Null), &args.get(1..).unwrap_or(&[]).to_vec()[..]).await,
11626 "fetch_spot_ohlcv" => self.fetch_spot_ohlcv(args.get(0).cloned().unwrap_or(crate::Value::Null), &args.get(1..).unwrap_or(&[]).to_vec()[..]).await,
11627 "fetch_spot_tickers" => self.fetch_spot_tickers(&args.get(0..).unwrap_or(&[]).to_vec()[..]).await,
11628 "fetch_status" => self.fetch_status(&args.get(0..).unwrap_or(&[]).to_vec()[..]).await,
11629 "fetch_ticker" => self.fetch_ticker(args.get(0).cloned().unwrap_or(crate::Value::Null), &args.get(1..).unwrap_or(&[]).to_vec()[..]).await,
11630 "fetch_ticker_ws" => self.fetch_ticker_ws(args.get(0).cloned().unwrap_or(crate::Value::Null), &args.get(1..).unwrap_or(&[]).to_vec()[..]).await,
11631 "fetch_tickers" => self.fetch_tickers(&args.get(0..).unwrap_or(&[]).to_vec()[..]).await,
11632 "fetch_tickers_ws" => self.fetch_tickers_ws(&args.get(0..).unwrap_or(&[]).to_vec()[..]).await,
11633 "fetch_time" => self.fetch_time(&args.get(0..).unwrap_or(&[]).to_vec()[..]).await,
11634 "fetch_total_balance" => self.fetch_total_balance(&args.get(0..).unwrap_or(&[]).to_vec()[..]).await,
11635 "fetch_trades" => self.fetch_trades(args.get(0).cloned().unwrap_or(crate::Value::Null), &args.get(1..).unwrap_or(&[]).to_vec()[..]).await,
11636 "fetch_trades_ws" => self.fetch_trades_ws(args.get(0).cloned().unwrap_or(crate::Value::Null), &args.get(1..).unwrap_or(&[]).to_vec()[..]).await,
11637 "fetch_trading_fee" => self.fetch_trading_fee(args.get(0).cloned().unwrap_or(crate::Value::Null), &args.get(1..).unwrap_or(&[]).to_vec()[..]).await,
11638 "fetch_trading_fees" => self.fetch_trading_fees(&args.get(0..).unwrap_or(&[]).to_vec()[..]).await,
11639 "fetch_trading_fees_ws" => self.fetch_trading_fees_ws(&args.get(0..).unwrap_or(&[]).to_vec()[..]).await,
11640 "fetch_trading_limits" => self.fetch_trading_limits(&args.get(0..).unwrap_or(&[]).to_vec()[..]).await,
11641 "fetch_transaction_fee" => self.fetch_transaction_fee(args.get(0).cloned().unwrap_or(crate::Value::Null), &args.get(1..).unwrap_or(&[]).to_vec()[..]).await,
11642 "fetch_transaction_fees" => self.fetch_transaction_fees(&args.get(0..).unwrap_or(&[]).to_vec()[..]).await,
11643 "fetch_transactions" => self.fetch_transactions(&args.get(0..).unwrap_or(&[]).to_vec()[..]).await,
11644 "fetch_transfer" => self.fetch_transfer(args.get(0).cloned().unwrap_or(crate::Value::Null), &args.get(1..).unwrap_or(&[]).to_vec()[..]).await,
11645 "fetch_transfers" => self.fetch_transfers(&args.get(0..).unwrap_or(&[]).to_vec()[..]).await,
11646 "fetch_unified_order" => self.fetch_unified_order(args.get(0).cloned().unwrap_or(crate::Value::Null), &args.get(1..).unwrap_or(&[]).to_vec()[..]).await,
11647 "fetch_used_balance" => self.fetch_used_balance(&args.get(0..).unwrap_or(&[]).to_vec()[..]).await,
11648 "fetch_web_endpoint" => self.fetch_web_endpoint(args.get(0).cloned().unwrap_or(crate::Value::Null), args.get(1).cloned().unwrap_or(crate::Value::Null), args.get(2).cloned().unwrap_or(crate::Value::Null), &args.get(3..).unwrap_or(&[]).to_vec()[..]).await,
11649 "fetch_withdrawals" => self.fetch_withdrawals(&args.get(0..).unwrap_or(&[]).to_vec()[..]).await,
11650 "fetch_withdrawals_ws" => self.fetch_withdrawals_ws(&args.get(0..).unwrap_or(&[]).to_vec()[..]).await,
11651 "filter_by_array" => self.filter_by_array(args.get(0).cloned().unwrap_or(crate::Value::Null), args.get(1).cloned().unwrap_or(crate::Value::Null), &args.get(2..).unwrap_or(&[]).to_vec()[..]),
11652 "filter_by_array_adl_ranks" => self.filter_by_array_adl_ranks(args.get(0).cloned().unwrap_or(crate::Value::Null), args.get(1).cloned().unwrap_or(crate::Value::Null), &args.get(2..).unwrap_or(&[]).to_vec()[..]),
11653 "filter_by_array_positions" => self.filter_by_array_positions(args.get(0).cloned().unwrap_or(crate::Value::Null), args.get(1).cloned().unwrap_or(crate::Value::Null), &args.get(2..).unwrap_or(&[]).to_vec()[..]),
11654 "filter_by_array_tickers" => self.filter_by_array_tickers(args.get(0).cloned().unwrap_or(crate::Value::Null), args.get(1).cloned().unwrap_or(crate::Value::Null), &args.get(2..).unwrap_or(&[]).to_vec()[..]),
11655 "filter_by_currency_since_limit" => self.filter_by_currency_since_limit(args.get(0).cloned().unwrap_or(crate::Value::Null), &args.get(1..).unwrap_or(&[]).to_vec()[..]),
11656 "filter_by_key" => self.filter_by_key(args.get(0).cloned().unwrap_or(crate::Value::Null), args.get(1).cloned().unwrap_or(crate::Value::Null), &args.get(2..).unwrap_or(&[]).to_vec()[..]),
11657 "filter_by_limit" => self.filter_by_limit(args.get(0).cloned().unwrap_or(crate::Value::Null), &args.get(1..).unwrap_or(&[]).to_vec()[..]),
11658 "filter_by_since_limit" => self.filter_by_since_limit(args.get(0).cloned().unwrap_or(crate::Value::Null), &args.get(1..).unwrap_or(&[]).to_vec()[..]),
11659 "filter_by_symbol" => self.filter_by_symbol(args.get(0).cloned().unwrap_or(crate::Value::Null), &args.get(1..).unwrap_or(&[]).to_vec()[..]),
11660 "filter_by_symbol_since_limit" => self.filter_by_symbol_since_limit(args.get(0).cloned().unwrap_or(crate::Value::Null), &args.get(1..).unwrap_or(&[]).to_vec()[..]),
11661 "filter_by_symbols_since_limit" => self.filter_by_symbols_since_limit(args.get(0).cloned().unwrap_or(crate::Value::Null), &args.get(1..).unwrap_or(&[]).to_vec()[..]),
11662 "filter_by_value_since_limit" => self.filter_by_value_since_limit(args.get(0).cloned().unwrap_or(crate::Value::Null), args.get(1).cloned().unwrap_or(crate::Value::Null), &args.get(2..).unwrap_or(&[]).to_vec()[..]),
11663 "filter_out_by_array" => self.filter_out_by_array(args.get(0).cloned().unwrap_or(crate::Value::Null), args.get(1).cloned().unwrap_or(crate::Value::Null), &args.get(2..).unwrap_or(&[]).to_vec()[..]),
11664 "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)),
11665 "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)),
11666 "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)),
11667 "find_timeframe" => self.find_timeframe(args.get(0).cloned().unwrap_or(crate::Value::Null), &args.get(1..).unwrap_or(&[]).to_vec()[..]),
11668 "force_string" => self.force_string(args.get(0).cloned().unwrap_or(crate::Value::Null)),
11669 "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)),
11670 "get_default_options" => self.get_default_options(),
11671 "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)),
11672 "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)),
11673 "get_market_from_symbols" => self.get_market_from_symbols(&args.get(0..).unwrap_or(&[]).to_vec()[..]),
11674 "get_supported_mapping" => self.get_supported_mapping(args.get(0).cloned().unwrap_or(crate::Value::Null), &args.get(1..).unwrap_or(&[]).to_vec()[..]),
11675 "get_symbols_for_market_type" => self.get_symbols_for_market_type(&args.get(0..).unwrap_or(&[]).to_vec()[..]),
11676 "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)),
11677 "handle_margin_mode_and_params" => self.handle_margin_mode_and_params(args.get(0).cloned().unwrap_or(crate::Value::Null), &args.get(1..).unwrap_or(&[]).to_vec()[..]),
11678 "handle_market_type_and_params" => self.handle_market_type_and_params(args.get(0).cloned().unwrap_or(crate::Value::Null), &args.get(1..).unwrap_or(&[]).to_vec()[..]),
11679 "handle_max_entries_per_request_and_params" => self.handle_max_entries_per_request_and_params(args.get(0).cloned().unwrap_or(crate::Value::Null), &args.get(1..).unwrap_or(&[]).to_vec()[..]),
11680 "handle_network_code_and_params" => self.handle_network_code_and_params(args.get(0).cloned().unwrap_or(crate::Value::Null)),
11681 "handle_option" => self.handle_option(args.get(0).cloned().unwrap_or(crate::Value::Null), args.get(1).cloned().unwrap_or(crate::Value::Null), &args.get(2..).unwrap_or(&[]).to_vec()[..]),
11682 "handle_option_and_params" => self.handle_option_and_params(args.get(0).cloned().unwrap_or(crate::Value::Null), args.get(1).cloned().unwrap_or(crate::Value::Null), args.get(2).cloned().unwrap_or(crate::Value::Null), &args.get(3..).unwrap_or(&[]).to_vec()[..]),
11683 "handle_option_and_params2" => self.handle_option_and_params2(args.get(0).cloned().unwrap_or(crate::Value::Null), args.get(1).cloned().unwrap_or(crate::Value::Null), args.get(2).cloned().unwrap_or(crate::Value::Null), args.get(3).cloned().unwrap_or(crate::Value::Null), &args.get(4..).unwrap_or(&[]).to_vec()[..]),
11684 "handle_param_bool" => self.handle_param_bool(args.get(0).cloned().unwrap_or(crate::Value::Null), args.get(1).cloned().unwrap_or(crate::Value::Null), &args.get(2..).unwrap_or(&[]).to_vec()[..]),
11685 "handle_param_bool2" => self.handle_param_bool2(args.get(0).cloned().unwrap_or(crate::Value::Null), args.get(1).cloned().unwrap_or(crate::Value::Null), args.get(2).cloned().unwrap_or(crate::Value::Null), &args.get(3..).unwrap_or(&[]).to_vec()[..]),
11686 "handle_param_integer" => self.handle_param_integer(args.get(0).cloned().unwrap_or(crate::Value::Null), args.get(1).cloned().unwrap_or(crate::Value::Null), &args.get(2..).unwrap_or(&[]).to_vec()[..]),
11687 "handle_param_integer2" => self.handle_param_integer2(args.get(0).cloned().unwrap_or(crate::Value::Null), args.get(1).cloned().unwrap_or(crate::Value::Null), args.get(2).cloned().unwrap_or(crate::Value::Null), &args.get(3..).unwrap_or(&[]).to_vec()[..]),
11688 "handle_param_string" => self.handle_param_string(args.get(0).cloned().unwrap_or(crate::Value::Null), args.get(1).cloned().unwrap_or(crate::Value::Null), &args.get(2..).unwrap_or(&[]).to_vec()[..]),
11689 "handle_param_string2" => self.handle_param_string2(args.get(0).cloned().unwrap_or(crate::Value::Null), args.get(1).cloned().unwrap_or(crate::Value::Null), args.get(2).cloned().unwrap_or(crate::Value::Null), &args.get(3..).unwrap_or(&[]).to_vec()[..]),
11690 "handle_post_only" => self.handle_post_only(args.get(0).cloned().unwrap_or(crate::Value::Null), args.get(1).cloned().unwrap_or(crate::Value::Null), &args.get(2..).unwrap_or(&[]).to_vec()[..]),
11691 "handle_request_network" => self.handle_request_network(args.get(0).cloned().unwrap_or(crate::Value::Null), args.get(1).cloned().unwrap_or(crate::Value::Null), args.get(2).cloned().unwrap_or(crate::Value::Null), &args.get(3..).unwrap_or(&[]).to_vec()[..]),
11692 "handle_sub_type_and_params" => self.handle_sub_type_and_params(args.get(0).cloned().unwrap_or(crate::Value::Null), &args.get(1..).unwrap_or(&[]).to_vec()[..]),
11693 "handle_time_in_force" => self.handle_time_in_force(&args.get(0..).unwrap_or(&[]).to_vec()[..]),
11694 "handle_trigger_and_params" => self.handle_trigger_and_params(args.get(0).cloned().unwrap_or(crate::Value::Null)),
11695 "handle_trigger_direction_and_params" => self.handle_trigger_direction_and_params(args.get(0).cloned().unwrap_or(crate::Value::Null), &args.get(1..).unwrap_or(&[]).to_vec()[..]),
11696 "handle_trigger_prices_and_params" => self.handle_trigger_prices_and_params(args.get(0).cloned().unwrap_or(crate::Value::Null), args.get(1).cloned().unwrap_or(crate::Value::Null), &args.get(2..).unwrap_or(&[]).to_vec()[..]),
11697 "handle_until_option" => self.handle_until_option(args.get(0).cloned().unwrap_or(crate::Value::Null), args.get(1).cloned().unwrap_or(crate::Value::Null), args.get(2).cloned().unwrap_or(crate::Value::Null), &args.get(3..).unwrap_or(&[]).to_vec()[..]),
11698 "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)),
11699 "implode_hostname" => self.implode_hostname(args.get(0).cloned().unwrap_or(crate::Value::Null)),
11700 "integer_precision_to_amount" => self.integer_precision_to_amount(args.get(0).cloned().unwrap_or(crate::Value::Null)),
11701 "invert_flat_string_dictionary" => self.invert_flat_string_dictionary(args.get(0).cloned().unwrap_or(crate::Value::Null)),
11702 "is_decimal_precision" => self.is_decimal_precision(),
11703 "is_empty_string" => self.is_empty_string(args.get(0).cloned().unwrap_or(crate::Value::Null)),
11704 "is_leveraged_currency" => self.is_leveraged_currency(args.get(0).cloned().unwrap_or(crate::Value::Null), &args.get(1..).unwrap_or(&[]).to_vec()[..]),
11705 "is_post_only" => self.is_post_only(args.get(0).cloned().unwrap_or(crate::Value::Null), args.get(1).cloned().unwrap_or(crate::Value::Null), &args.get(2..).unwrap_or(&[]).to_vec()[..]),
11706 "is_round_number" => self.is_round_number(args.get(0).cloned().unwrap_or(crate::Value::Null)),
11707 "is_significant_precision" => self.is_significant_precision(),
11708 "is_tick_precision" => self.is_tick_precision(),
11709 "is_trigger_order" => self.is_trigger_order(args.get(0).cloned().unwrap_or(crate::Value::Null)),
11710 "is_uta_enabled" => self.is_uta_enabled(&args.get(0..).unwrap_or(&[]).to_vec()[..]).await,
11711 "load_accounts" => self.load_accounts(&args.get(0..).unwrap_or(&[]).to_vec()[..]).await,
11712 "load_markets" => self.load_markets(&args.get(0..).unwrap_or(&[]).to_vec()[..]).await,
11713 "load_markets_and_sign_in" => self.load_markets_and_sign_in().await,
11714 "load_time_difference" => self.load_time_difference(&args.get(0..).unwrap_or(&[]).to_vec()[..]).await,
11715 "load_trading_limits" => self.load_trading_limits(&args.get(0..).unwrap_or(&[]).to_vec()[..]).await,
11716 "market" => self.market(args.get(0).cloned().unwrap_or(crate::Value::Null)),
11717 "market_codes" => self.market_codes(&args.get(0..).unwrap_or(&[]).to_vec()[..]),
11718 "market_id" => self.market_id(args.get(0).cloned().unwrap_or(crate::Value::Null)),
11719 "market_ids" => self.market_ids(&args.get(0..).unwrap_or(&[]).to_vec()[..]),
11720 "market_or_null" => self.market_or_null(&args.get(0..).unwrap_or(&[]).to_vec()[..]),
11721 "market_symbols" => self.market_symbols(&args.get(0..).unwrap_or(&[]).to_vec()[..]),
11722 "markets_for_symbols" => self.markets_for_symbols(&args.get(0..).unwrap_or(&[]).to_vec()[..]),
11723 "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)),
11724 "network_code_to_id" => self.network_code_to_id(args.get(0).cloned().unwrap_or(crate::Value::Null), &args.get(1..).unwrap_or(&[]).to_vec()[..]),
11725 "network_id_to_code" => self.network_id_to_code(&args.get(0..).unwrap_or(&[]).to_vec()[..]),
11726 "nonce" => <Self as crate::exchange_generated::ExchangeBase>::nonce(self),
11727 "oath" => self.oath(),
11728 "orderbook_checksum_message" => self.orderbook_checksum_message(args.get(0).cloned().unwrap_or(crate::Value::Null)),
11729 "parse_account" => <Self as crate::exchange_generated::ExchangeBase>::parse_account(self, args.get(0).cloned().unwrap_or(crate::Value::Null)),
11730 "parse_accounts" => self.parse_accounts(args.get(0).cloned().unwrap_or(crate::Value::Null), &args.get(1..).unwrap_or(&[]).to_vec()[..]),
11731 "parse_adl_rank" => <Self as crate::exchange_generated::ExchangeBase>::parse_adl_rank(self, args.get(0).cloned().unwrap_or(crate::Value::Null), &args.get(1..).unwrap_or(&[]).to_vec()[..]),
11732 "parse_adl_ranks" => self.parse_adl_ranks(args.get(0).cloned().unwrap_or(crate::Value::Null), &args.get(1..).unwrap_or(&[]).to_vec()[..]),
11733 "parse_all_greeks" => self.parse_all_greeks(args.get(0).cloned().unwrap_or(crate::Value::Null), &args.get(1..).unwrap_or(&[]).to_vec()[..]),
11734 "parse_balance" => <Self as crate::exchange_generated::ExchangeBase>::parse_balance(self, args.get(0).cloned().unwrap_or(crate::Value::Null)),
11735 "parse_borrow_interest" => <Self as crate::exchange_generated::ExchangeBase>::parse_borrow_interest(self, args.get(0).cloned().unwrap_or(crate::Value::Null), &args.get(1..).unwrap_or(&[]).to_vec()[..]),
11736 "parse_borrow_interests" => self.parse_borrow_interests(args.get(0).cloned().unwrap_or(crate::Value::Null), &args.get(1..).unwrap_or(&[]).to_vec()[..]),
11737 "parse_borrow_rate" => <Self as crate::exchange_generated::ExchangeBase>::parse_borrow_rate(self, args.get(0).cloned().unwrap_or(crate::Value::Null), &args.get(1..).unwrap_or(&[]).to_vec()[..]),
11738 "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)),
11739 "parse_conversion" => <Self as crate::exchange_generated::ExchangeBase>::parse_conversion(self, args.get(0).cloned().unwrap_or(crate::Value::Null), &args.get(1..).unwrap_or(&[]).to_vec()[..]),
11740 "parse_conversions" => self.parse_conversions(args.get(0).cloned().unwrap_or(crate::Value::Null), &args.get(1..).unwrap_or(&[]).to_vec()[..]),
11741 "parse_currencies" => self.parse_currencies(args.get(0).cloned().unwrap_or(crate::Value::Null)),
11742 "parse_currency" => <Self as crate::exchange_generated::ExchangeBase>::parse_currency(self, args.get(0).cloned().unwrap_or(crate::Value::Null)),
11743 "parse_deposit_address" => <Self as crate::exchange_generated::ExchangeBase>::parse_deposit_address(self, args.get(0).cloned().unwrap_or(crate::Value::Null), &args.get(1..).unwrap_or(&[]).to_vec()[..]),
11744 "parse_deposit_addresses" => self.parse_deposit_addresses(args.get(0).cloned().unwrap_or(crate::Value::Null), &args.get(1..).unwrap_or(&[]).to_vec()[..]),
11745 "parse_deposit_withdraw_fee" => <Self as crate::exchange_generated::ExchangeBase>::parse_deposit_withdraw_fee(self, args.get(0).cloned().unwrap_or(crate::Value::Null), &args.get(1..).unwrap_or(&[]).to_vec()[..]),
11746 "parse_deposit_withdraw_fees" => self.parse_deposit_withdraw_fees(args.get(0).cloned().unwrap_or(crate::Value::Null), &args.get(1..).unwrap_or(&[]).to_vec()[..]),
11747 "parse_fee_numeric" => self.parse_fee_numeric(args.get(0).cloned().unwrap_or(crate::Value::Null)),
11748 "parse_funding_rate" => <Self as crate::exchange_generated::ExchangeBase>::parse_funding_rate(self, args.get(0).cloned().unwrap_or(crate::Value::Null), &args.get(1..).unwrap_or(&[]).to_vec()[..]),
11749 "parse_funding_rate_histories" => self.parse_funding_rate_histories(args.get(0).cloned().unwrap_or(crate::Value::Null), &args.get(1..).unwrap_or(&[]).to_vec()[..]),
11750 "parse_funding_rate_history" => <Self as crate::exchange_generated::ExchangeBase>::parse_funding_rate_history(self, args.get(0).cloned().unwrap_or(crate::Value::Null), &args.get(1..).unwrap_or(&[]).to_vec()[..]),
11751 "parse_funding_rates" => self.parse_funding_rates(args.get(0).cloned().unwrap_or(crate::Value::Null), &args.get(1..).unwrap_or(&[]).to_vec()[..]),
11752 "parse_greeks" => <Self as crate::exchange_generated::ExchangeBase>::parse_greeks(self, args.get(0).cloned().unwrap_or(crate::Value::Null), &args.get(1..).unwrap_or(&[]).to_vec()[..]),
11753 "parse_income" => <Self as crate::exchange_generated::ExchangeBase>::parse_income(self, args.get(0).cloned().unwrap_or(crate::Value::Null), &args.get(1..).unwrap_or(&[]).to_vec()[..]),
11754 "parse_incomes" => self.parse_incomes(args.get(0).cloned().unwrap_or(crate::Value::Null), &args.get(1..).unwrap_or(&[]).to_vec()[..]),
11755 "parse_isolated_borrow_rate" => self.parse_isolated_borrow_rate(args.get(0).cloned().unwrap_or(crate::Value::Null), &args.get(1..).unwrap_or(&[]).to_vec()[..]),
11756 "parse_isolated_borrow_rates" => self.parse_isolated_borrow_rates(args.get(0).cloned().unwrap_or(crate::Value::Null)),
11757 "parse_last_price" => <Self as crate::exchange_generated::ExchangeBase>::parse_last_price(self, args.get(0).cloned().unwrap_or(crate::Value::Null), &args.get(1..).unwrap_or(&[]).to_vec()[..]),
11758 "parse_last_prices" => self.parse_last_prices(args.get(0).cloned().unwrap_or(crate::Value::Null), &args.get(1..).unwrap_or(&[]).to_vec()[..]),
11759 "parse_ledger" => self.parse_ledger(args.get(0).cloned().unwrap_or(crate::Value::Null), &args.get(1..).unwrap_or(&[]).to_vec()[..]),
11760 "parse_ledger_entry" => <Self as crate::exchange_generated::ExchangeBase>::parse_ledger_entry(self, args.get(0).cloned().unwrap_or(crate::Value::Null), &args.get(1..).unwrap_or(&[]).to_vec()[..]),
11761 "parse_leverage" => <Self as crate::exchange_generated::ExchangeBase>::parse_leverage(self, args.get(0).cloned().unwrap_or(crate::Value::Null), &args.get(1..).unwrap_or(&[]).to_vec()[..]),
11762 "parse_leverage_tiers" => self.parse_leverage_tiers(args.get(0).cloned().unwrap_or(crate::Value::Null), &args.get(1..).unwrap_or(&[]).to_vec()[..]),
11763 "parse_leverages" => self.parse_leverages(args.get(0).cloned().unwrap_or(crate::Value::Null), &args.get(1..).unwrap_or(&[]).to_vec()[..]),
11764 "parse_liquidation" => <Self as crate::exchange_generated::ExchangeBase>::parse_liquidation(self, args.get(0).cloned().unwrap_or(crate::Value::Null), &args.get(1..).unwrap_or(&[]).to_vec()[..]),
11765 "parse_liquidations" => self.parse_liquidations(args.get(0).cloned().unwrap_or(crate::Value::Null), &args.get(1..).unwrap_or(&[]).to_vec()[..]),
11766 "parse_long_short_ratio" => self.parse_long_short_ratio(args.get(0).cloned().unwrap_or(crate::Value::Null), &args.get(1..).unwrap_or(&[]).to_vec()[..]),
11767 "parse_long_short_ratio_history" => self.parse_long_short_ratio_history(args.get(0).cloned().unwrap_or(crate::Value::Null), &args.get(1..).unwrap_or(&[]).to_vec()[..]),
11768 "parse_margin_mode" => <Self as crate::exchange_generated::ExchangeBase>::parse_margin_mode(self, args.get(0).cloned().unwrap_or(crate::Value::Null), &args.get(1..).unwrap_or(&[]).to_vec()[..]),
11769 "parse_margin_modes" => self.parse_margin_modes(args.get(0).cloned().unwrap_or(crate::Value::Null), &args.get(1..).unwrap_or(&[]).to_vec()[..]),
11770 "parse_margin_modification" => <Self as crate::exchange_generated::ExchangeBase>::parse_margin_modification(self, args.get(0).cloned().unwrap_or(crate::Value::Null), &args.get(1..).unwrap_or(&[]).to_vec()[..]),
11771 "parse_margin_modifications" => self.parse_margin_modifications(args.get(0).cloned().unwrap_or(crate::Value::Null), &args.get(1..).unwrap_or(&[]).to_vec()[..]),
11772 "parse_market" => <Self as crate::exchange_generated::ExchangeBase>::parse_market(self, args.get(0).cloned().unwrap_or(crate::Value::Null)),
11773 "parse_market_leverage_tiers" => <Self as crate::exchange_generated::ExchangeBase>::parse_market_leverage_tiers(self, args.get(0).cloned().unwrap_or(crate::Value::Null), &args.get(1..).unwrap_or(&[]).to_vec()[..]),
11774 "parse_markets" => self.parse_markets(args.get(0).cloned().unwrap_or(crate::Value::Null)),
11775 "parse_ohlc_vs" => self.parse_ohlc_vs(args.get(0).cloned().unwrap_or(crate::Value::Null), &args.get(1..).unwrap_or(&[]).to_vec()[..]),
11776 "parse_ohlcv" => <Self as crate::exchange_generated::ExchangeBase>::parse_ohlcv(self, args.get(0).cloned().unwrap_or(crate::Value::Null), &args.get(1..).unwrap_or(&[]).to_vec()[..]),
11777 "parse_open_interest" => <Self as crate::exchange_generated::ExchangeBase>::parse_open_interest(self, args.get(0).cloned().unwrap_or(crate::Value::Null), &args.get(1..).unwrap_or(&[]).to_vec()[..]),
11778 "parse_open_interests" => self.parse_open_interests(args.get(0).cloned().unwrap_or(crate::Value::Null), &args.get(1..).unwrap_or(&[]).to_vec()[..]),
11779 "parse_open_interests_history" => self.parse_open_interests_history(args.get(0).cloned().unwrap_or(crate::Value::Null), &args.get(1..).unwrap_or(&[]).to_vec()[..]),
11780 "parse_option" => self.parse_option(args.get(0).cloned().unwrap_or(crate::Value::Null), &args.get(1..).unwrap_or(&[]).to_vec()[..]),
11781 "parse_option_chain" => self.parse_option_chain(args.get(0).cloned().unwrap_or(crate::Value::Null), &args.get(1..).unwrap_or(&[]).to_vec()[..]),
11782 "parse_order" => <Self as crate::exchange_generated::ExchangeBase>::parse_order(self, args.get(0).cloned().unwrap_or(crate::Value::Null), &args.get(1..).unwrap_or(&[]).to_vec()[..]),
11783 "parse_order_book" => <Self as crate::exchange_generated::ExchangeBase>::parse_order_book(self, args.get(0).cloned().unwrap_or(crate::Value::Null), args.get(1).cloned().unwrap_or(crate::Value::Null), &args.get(2..).unwrap_or(&[]).to_vec()[..]),
11784 "parse_order_book_bid_ask" => self.parse_order_book_bid_ask(args.get(0).cloned().unwrap_or(crate::Value::Null), &args.get(1..).unwrap_or(&[]).to_vec()[..]),
11785 "parse_order_book_bids_asks" => self.parse_order_book_bids_asks(args.get(0).cloned().unwrap_or(crate::Value::Null), &args.get(1..).unwrap_or(&[]).to_vec()[..]),
11786 "parse_orders" => self.parse_orders(args.get(0).cloned().unwrap_or(crate::Value::Null), &args.get(1..).unwrap_or(&[]).to_vec()[..]),
11787 "parse_position" => <Self as crate::exchange_generated::ExchangeBase>::parse_position(self, args.get(0).cloned().unwrap_or(crate::Value::Null), &args.get(1..).unwrap_or(&[]).to_vec()[..]),
11788 "parse_positions" => self.parse_positions(args.get(0).cloned().unwrap_or(crate::Value::Null), &args.get(1..).unwrap_or(&[]).to_vec()[..]),
11789 "parse_precision" => self.parse_precision(&args.get(0..).unwrap_or(&[]).to_vec()[..]),
11790 "parse_ticker" => <Self as crate::exchange_generated::ExchangeBase>::parse_ticker(self, args.get(0).cloned().unwrap_or(crate::Value::Null), &args.get(1..).unwrap_or(&[]).to_vec()[..]),
11791 "parse_tickers" => self.parse_tickers(args.get(0).cloned().unwrap_or(crate::Value::Null), &args.get(1..).unwrap_or(&[]).to_vec()[..]),
11792 "parse_to_int" => self.parse_to_int(args.get(0).cloned().unwrap_or(crate::Value::Null)),
11793 "parse_to_numeric" => self.parse_to_numeric(args.get(0).cloned().unwrap_or(crate::Value::Null)),
11794 "parse_trade" => <Self as crate::exchange_generated::ExchangeBase>::parse_trade(self, args.get(0).cloned().unwrap_or(crate::Value::Null), &args.get(1..).unwrap_or(&[]).to_vec()[..]),
11795 "parse_trades" => self.parse_trades(args.get(0).cloned().unwrap_or(crate::Value::Null), &args.get(1..).unwrap_or(&[]).to_vec()[..]),
11796 "parse_trades_helper" => self.parse_trades_helper(args.get(0).cloned().unwrap_or(crate::Value::Null), args.get(1).cloned().unwrap_or(crate::Value::Null), &args.get(2..).unwrap_or(&[]).to_vec()[..]),
11797 "parse_trading_view_ohlcv" => self.parse_trading_view_ohlcv(args.get(0).cloned().unwrap_or(crate::Value::Null), &args.get(1..).unwrap_or(&[]).to_vec()[..]),
11798 "parse_transaction" => <Self as crate::exchange_generated::ExchangeBase>::parse_transaction(self, args.get(0).cloned().unwrap_or(crate::Value::Null), &args.get(1..).unwrap_or(&[]).to_vec()[..]),
11799 "parse_transactions" => self.parse_transactions(args.get(0).cloned().unwrap_or(crate::Value::Null), &args.get(1..).unwrap_or(&[]).to_vec()[..]),
11800 "parse_transfer" => <Self as crate::exchange_generated::ExchangeBase>::parse_transfer(self, args.get(0).cloned().unwrap_or(crate::Value::Null), &args.get(1..).unwrap_or(&[]).to_vec()[..]),
11801 "parse_transfers" => self.parse_transfers(args.get(0).cloned().unwrap_or(crate::Value::Null), &args.get(1..).unwrap_or(&[]).to_vec()[..]),
11802 "parse_ws_ohlc_vs" => self.parse_ws_ohlc_vs(args.get(0).cloned().unwrap_or(crate::Value::Null), &args.get(1..).unwrap_or(&[]).to_vec()[..]),
11803 "parse_ws_ohlcv" => self.parse_ws_ohlcv(args.get(0).cloned().unwrap_or(crate::Value::Null), &args.get(1..).unwrap_or(&[]).to_vec()[..]),
11804 "parse_ws_order" => self.parse_ws_order(args.get(0).cloned().unwrap_or(crate::Value::Null), &args.get(1..).unwrap_or(&[]).to_vec()[..]),
11805 "parse_ws_order_trade" => self.parse_ws_order_trade(args.get(0).cloned().unwrap_or(crate::Value::Null), &args.get(1..).unwrap_or(&[]).to_vec()[..]),
11806 "parse_ws_trade" => self.parse_ws_trade(args.get(0).cloned().unwrap_or(crate::Value::Null), &args.get(1..).unwrap_or(&[]).to_vec()[..]),
11807 "parse_ws_trades" => self.parse_ws_trades(args.get(0).cloned().unwrap_or(crate::Value::Null), &args.get(1..).unwrap_or(&[]).to_vec()[..]),
11808 "parsed_fee_and_fees" => self.parsed_fee_and_fees(args.get(0).cloned().unwrap_or(crate::Value::Null)),
11809 "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)),
11810 "prioritized_network_aliases" => self.prioritized_network_aliases(&args.get(0..).unwrap_or(&[]).to_vec()[..]),
11811 "reduce_fees_by_currency" => self.reduce_fees_by_currency(args.get(0).cloned().unwrap_or(crate::Value::Null)),
11812 "reduce_margin" => self.reduce_margin(args.get(0).cloned().unwrap_or(crate::Value::Null), args.get(1).cloned().unwrap_or(crate::Value::Null), &args.get(2..).unwrap_or(&[]).to_vec()[..]).await,
11813 "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)),
11814 "remove_repeated_elements_from_array" => self.remove_repeated_elements_from_array(args.get(0).cloned().unwrap_or(crate::Value::Null), &args.get(1..).unwrap_or(&[]).to_vec()[..]),
11815 "remove_repeated_trades_from_array" => self.remove_repeated_trades_from_array(args.get(0).cloned().unwrap_or(crate::Value::Null)),
11816 "repay_cross_margin" => self.repay_cross_margin(args.get(0).cloned().unwrap_or(crate::Value::Null), args.get(1).cloned().unwrap_or(crate::Value::Null), &args.get(2..).unwrap_or(&[]).to_vec()[..]).await,
11817 "repay_isolated_margin" => self.repay_isolated_margin(args.get(0).cloned().unwrap_or(crate::Value::Null), args.get(1).cloned().unwrap_or(crate::Value::Null), args.get(2).cloned().unwrap_or(crate::Value::Null), &args.get(3..).unwrap_or(&[]).to_vec()[..]).await,
11818 "repay_margin" => self.repay_margin(args.get(0).cloned().unwrap_or(crate::Value::Null), args.get(1).cloned().unwrap_or(crate::Value::Null), &args.get(2..).unwrap_or(&[]).to_vec()[..]).await,
11819 "request" => self.request(args.get(0).cloned().unwrap_or(crate::Value::Null), &args.get(1..).unwrap_or(&[]).to_vec()[..]).await,
11820 "require_value" => self.require_value(args.get(0).cloned().unwrap_or(crate::Value::Null), &args.get(1..).unwrap_or(&[]).to_vec()[..]),
11821 "resolve_path" => self.resolve_path(args.get(0).cloned().unwrap_or(crate::Value::Null), args.get(1).cloned().unwrap_or(crate::Value::Null)),
11822 "safe_balance" => self.safe_balance(args.get(0).cloned().unwrap_or(crate::Value::Null)),
11823 "safe_bool" => self.safe_bool(args.get(0).cloned().unwrap_or(crate::Value::Null), args.get(1).cloned().unwrap_or(crate::Value::Null), &args.get(2..).unwrap_or(&[]).to_vec()[..]),
11824 "safe_bool2" => self.safe_bool2(args.get(0).cloned().unwrap_or(crate::Value::Null), args.get(1).cloned().unwrap_or(crate::Value::Null), args.get(2).cloned().unwrap_or(crate::Value::Null), &args.get(3..).unwrap_or(&[]).to_vec()[..]),
11825 "safe_bool_n" => self.safe_bool_n(args.get(0).cloned().unwrap_or(crate::Value::Null), args.get(1).cloned().unwrap_or(crate::Value::Null), &args.get(2..).unwrap_or(&[]).to_vec()[..]),
11826 "safe_currency" => self.safe_currency(args.get(0).cloned().unwrap_or(crate::Value::Null), &args.get(1..).unwrap_or(&[]).to_vec()[..]),
11827 "safe_currency_code" => self.safe_currency_code(args.get(0).cloned().unwrap_or(crate::Value::Null), &args.get(1..).unwrap_or(&[]).to_vec()[..]),
11828 "safe_currency_structure" => self.safe_currency_structure(args.get(0).cloned().unwrap_or(crate::Value::Null)),
11829 "safe_deterministic_call" => self.safe_deterministic_call(args.get(0).cloned().unwrap_or(crate::Value::Null), &args.get(1..).unwrap_or(&[]).to_vec()[..]).await,
11830 "safe_dict" => self.safe_dict(args.get(0).cloned().unwrap_or(crate::Value::Null), args.get(1).cloned().unwrap_or(crate::Value::Null), &args.get(2..).unwrap_or(&[]).to_vec()[..]),
11831 "safe_dict2" => self.safe_dict2(args.get(0).cloned().unwrap_or(crate::Value::Null), args.get(1).cloned().unwrap_or(crate::Value::Null), args.get(2).cloned().unwrap_or(crate::Value::Null), &args.get(3..).unwrap_or(&[]).to_vec()[..]),
11832 "safe_dict_n" => self.safe_dict_n(args.get(0).cloned().unwrap_or(crate::Value::Null), args.get(1).cloned().unwrap_or(crate::Value::Null), &args.get(2..).unwrap_or(&[]).to_vec()[..]),
11833 "safe_integer_omit_zero" => self.safe_integer_omit_zero(args.get(0).cloned().unwrap_or(crate::Value::Null), args.get(1).cloned().unwrap_or(crate::Value::Null), &args.get(2..).unwrap_or(&[]).to_vec()[..]),
11834 "safe_ledger_entry" => self.safe_ledger_entry(args.get(0).cloned().unwrap_or(crate::Value::Null), &args.get(1..).unwrap_or(&[]).to_vec()[..]),
11835 "safe_liquidation" => self.safe_liquidation(args.get(0).cloned().unwrap_or(crate::Value::Null), &args.get(1..).unwrap_or(&[]).to_vec()[..]),
11836 "safe_list" => self.safe_list(args.get(0).cloned().unwrap_or(crate::Value::Null), args.get(1).cloned().unwrap_or(crate::Value::Null), &args.get(2..).unwrap_or(&[]).to_vec()[..]),
11837 "safe_list2" => self.safe_list2(args.get(0).cloned().unwrap_or(crate::Value::Null), args.get(1).cloned().unwrap_or(crate::Value::Null), args.get(2).cloned().unwrap_or(crate::Value::Null), &args.get(3..).unwrap_or(&[]).to_vec()[..]),
11838 "safe_list_n" => self.safe_list_n(args.get(0).cloned().unwrap_or(crate::Value::Null), args.get(1).cloned().unwrap_or(crate::Value::Null), &args.get(2..).unwrap_or(&[]).to_vec()[..]),
11839 "safe_market" => self.safe_market(&args.get(0..).unwrap_or(&[]).to_vec()[..]),
11840 "safe_market_structure" => self.safe_market_structure(&args.get(0..).unwrap_or(&[]).to_vec()[..]),
11841 "safe_network" => self.safe_network(args.get(0).cloned().unwrap_or(crate::Value::Null)),
11842 "safe_number" => self.safe_number(args.get(0).cloned().unwrap_or(crate::Value::Null), args.get(1).cloned().unwrap_or(crate::Value::Null), &args.get(2..).unwrap_or(&[]).to_vec()[..]),
11843 "safe_number2" => self.safe_number2(args.get(0).cloned().unwrap_or(crate::Value::Null), args.get(1).cloned().unwrap_or(crate::Value::Null), args.get(2).cloned().unwrap_or(crate::Value::Null), &args.get(3..).unwrap_or(&[]).to_vec()[..]),
11844 "safe_number_n" => self.safe_number_n(args.get(0).cloned().unwrap_or(crate::Value::Null), args.get(1).cloned().unwrap_or(crate::Value::Null), &args.get(2..).unwrap_or(&[]).to_vec()[..]),
11845 "safe_number_omit_zero" => self.safe_number_omit_zero(args.get(0).cloned().unwrap_or(crate::Value::Null), args.get(1).cloned().unwrap_or(crate::Value::Null), &args.get(2..).unwrap_or(&[]).to_vec()[..]),
11846 "safe_open_interest" => self.safe_open_interest(args.get(0).cloned().unwrap_or(crate::Value::Null), &args.get(1..).unwrap_or(&[]).to_vec()[..]),
11847 "safe_order" => self.safe_order(args.get(0).cloned().unwrap_or(crate::Value::Null), &args.get(1..).unwrap_or(&[]).to_vec()[..]),
11848 "safe_position" => self.safe_position(args.get(0).cloned().unwrap_or(crate::Value::Null)),
11849 "safe_symbol" => self.safe_symbol(args.get(0).cloned().unwrap_or(crate::Value::Null), &args.get(1..).unwrap_or(&[]).to_vec()[..]),
11850 "safe_ticker" => self.safe_ticker(args.get(0).cloned().unwrap_or(crate::Value::Null), &args.get(1..).unwrap_or(&[]).to_vec()[..]),
11851 "safe_trade" => self.safe_trade(args.get(0).cloned().unwrap_or(crate::Value::Null), &args.get(1..).unwrap_or(&[]).to_vec()[..]),
11852 "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)),
11853 "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)),
11854 "select_network_key_from_networks" => self.select_network_key_from_networks(args.get(0).cloned().unwrap_or(crate::Value::Null), args.get(1).cloned().unwrap_or(crate::Value::Null), args.get(2).cloned().unwrap_or(crate::Value::Null), &args.get(3..).unwrap_or(&[]).to_vec()[..]),
11855 "set_headers" => self.set_headers(args.get(0).cloned().unwrap_or(crate::Value::Null)),
11856 "set_leverage" => self.set_leverage(args.get(0).cloned().unwrap_or(crate::Value::Null), &args.get(1..).unwrap_or(&[]).to_vec()[..]).await,
11857 "set_margin" => self.set_margin(args.get(0).cloned().unwrap_or(crate::Value::Null), args.get(1).cloned().unwrap_or(crate::Value::Null), &args.get(2..).unwrap_or(&[]).to_vec()[..]).await,
11858 "set_margin_mode" => self.set_margin_mode(args.get(0).cloned().unwrap_or(crate::Value::Null), &args.get(1..).unwrap_or(&[]).to_vec()[..]).await,
11859 "set_markets" => self.set_markets(args.get(0).cloned().unwrap_or(crate::Value::Null), &args.get(1..).unwrap_or(&[]).to_vec()[..]),
11860 "set_markets_from_exchange" => self.set_markets_from_exchange(args.get(0).cloned().unwrap_or(crate::Value::Null)),
11861 "set_position_mode" => self.set_position_mode(args.get(0).cloned().unwrap_or(crate::Value::Null), &args.get(1..).unwrap_or(&[]).to_vec()[..]).await,
11862 "set_take_profit_and_stop_loss_params" => self.set_take_profit_and_stop_loss_params(args.get(0).cloned().unwrap_or(crate::Value::Null), args.get(1).cloned().unwrap_or(crate::Value::Null), args.get(2).cloned().unwrap_or(crate::Value::Null), args.get(3).cloned().unwrap_or(crate::Value::Null), &args.get(4..).unwrap_or(&[]).to_vec()[..]),
11863 "sign" => <Self as crate::exchange_generated::ExchangeBase>::sign(self, args.get(0).cloned().unwrap_or(crate::Value::Null), &args.get(1..).unwrap_or(&[]).to_vec()[..]),
11864 "sign_in" => self.sign_in(&args.get(0..).unwrap_or(&[]).to_vec()[..]).await,
11865 "sort_cursor_paginated_result" => self.sort_cursor_paginated_result(args.get(0).cloned().unwrap_or(crate::Value::Null)),
11866 "string_to_base16" => self.string_to_base16(args.get(0).cloned().unwrap_or(crate::Value::Null)),
11867 "symbol" => self.symbol(args.get(0).cloned().unwrap_or(crate::Value::Null)),
11868 "timeframe_from_milliseconds" => self.timeframe_from_milliseconds(args.get(0).cloned().unwrap_or(crate::Value::Null)),
11869 "transfer" => self.transfer(args.get(0).cloned().unwrap_or(crate::Value::Null), args.get(1).cloned().unwrap_or(crate::Value::Null), args.get(2).cloned().unwrap_or(crate::Value::Null), args.get(3).cloned().unwrap_or(crate::Value::Null), &args.get(4..).unwrap_or(&[]).to_vec()[..]).await,
11870 "un_watch_bids_asks" => self.un_watch_bids_asks(&args.get(0..).unwrap_or(&[]).to_vec()[..]).await,
11871 "un_watch_funding_rate" => self.un_watch_funding_rate(args.get(0).cloned().unwrap_or(crate::Value::Null), &args.get(1..).unwrap_or(&[]).to_vec()[..]).await,
11872 "un_watch_funding_rates" => self.un_watch_funding_rates(&args.get(0..).unwrap_or(&[]).to_vec()[..]).await,
11873 "un_watch_mark_price" => self.un_watch_mark_price(args.get(0).cloned().unwrap_or(crate::Value::Null), &args.get(1..).unwrap_or(&[]).to_vec()[..]).await,
11874 "un_watch_mark_prices" => self.un_watch_mark_prices(&args.get(0..).unwrap_or(&[]).to_vec()[..]).await,
11875 "un_watch_my_trades" => self.un_watch_my_trades(&args.get(0..).unwrap_or(&[]).to_vec()[..]).await,
11876 "un_watch_ohlcv" => self.un_watch_ohlcv(args.get(0).cloned().unwrap_or(crate::Value::Null), &args.get(1..).unwrap_or(&[]).to_vec()[..]).await,
11877 "un_watch_ohlcv_for_symbols" => self.un_watch_ohlcv_for_symbols(args.get(0).cloned().unwrap_or(crate::Value::Null), &args.get(1..).unwrap_or(&[]).to_vec()[..]).await,
11878 "un_watch_order_book" => self.un_watch_order_book(args.get(0).cloned().unwrap_or(crate::Value::Null), &args.get(1..).unwrap_or(&[]).to_vec()[..]).await,
11879 "un_watch_order_book_for_symbols" => self.un_watch_order_book_for_symbols(args.get(0).cloned().unwrap_or(crate::Value::Null), &args.get(1..).unwrap_or(&[]).to_vec()[..]).await,
11880 "un_watch_orders" => self.un_watch_orders(&args.get(0..).unwrap_or(&[]).to_vec()[..]).await,
11881 "un_watch_positions" => self.un_watch_positions(&args.get(0..).unwrap_or(&[]).to_vec()[..]).await,
11882 "un_watch_ticker" => self.un_watch_ticker(args.get(0).cloned().unwrap_or(crate::Value::Null), &args.get(1..).unwrap_or(&[]).to_vec()[..]).await,
11883 "un_watch_tickers" => self.un_watch_tickers(&args.get(0..).unwrap_or(&[]).to_vec()[..]).await,
11884 "un_watch_trades" => self.un_watch_trades(args.get(0).cloned().unwrap_or(crate::Value::Null), &args.get(1..).unwrap_or(&[]).to_vec()[..]).await,
11885 "un_watch_trades_for_symbols" => self.un_watch_trades_for_symbols(args.get(0).cloned().unwrap_or(crate::Value::Null), &args.get(1..).unwrap_or(&[]).to_vec()[..]).await,
11886 "url_encoder_for_proxy_url" => self.url_encoder_for_proxy_url(args.get(0).cloned().unwrap_or(crate::Value::Null)),
11887 "watch_balance" => self.watch_balance(&args.get(0..).unwrap_or(&[]).to_vec()[..]).await,
11888 "watch_bids_asks" => self.watch_bids_asks(&args.get(0..).unwrap_or(&[]).to_vec()[..]).await,
11889 "watch_funding_rate" => self.watch_funding_rate(args.get(0).cloned().unwrap_or(crate::Value::Null), &args.get(1..).unwrap_or(&[]).to_vec()[..]).await,
11890 "watch_funding_rates" => self.watch_funding_rates(&args.get(0..).unwrap_or(&[]).to_vec()[..]).await,
11891 "watch_funding_rates_for_symbols" => self.watch_funding_rates_for_symbols(args.get(0).cloned().unwrap_or(crate::Value::Null), &args.get(1..).unwrap_or(&[]).to_vec()[..]).await,
11892 "watch_liquidations" => self.watch_liquidations(args.get(0).cloned().unwrap_or(crate::Value::Null), &args.get(1..).unwrap_or(&[]).to_vec()[..]).await,
11893 "watch_liquidations_for_symbols" => self.watch_liquidations_for_symbols(args.get(0).cloned().unwrap_or(crate::Value::Null), &args.get(1..).unwrap_or(&[]).to_vec()[..]).await,
11894 "watch_mark_price" => self.watch_mark_price(args.get(0).cloned().unwrap_or(crate::Value::Null), &args.get(1..).unwrap_or(&[]).to_vec()[..]).await,
11895 "watch_mark_prices" => self.watch_mark_prices(&args.get(0..).unwrap_or(&[]).to_vec()[..]).await,
11896 "watch_my_liquidations" => self.watch_my_liquidations(args.get(0).cloned().unwrap_or(crate::Value::Null), &args.get(1..).unwrap_or(&[]).to_vec()[..]).await,
11897 "watch_my_liquidations_for_symbols" => self.watch_my_liquidations_for_symbols(args.get(0).cloned().unwrap_or(crate::Value::Null), &args.get(1..).unwrap_or(&[]).to_vec()[..]).await,
11898 "watch_my_trades" => self.watch_my_trades(&args.get(0..).unwrap_or(&[]).to_vec()[..]).await,
11899 "watch_my_trades_for_symbols" => self.watch_my_trades_for_symbols(args.get(0).cloned().unwrap_or(crate::Value::Null), &args.get(1..).unwrap_or(&[]).to_vec()[..]).await,
11900 "watch_ohlcv" => self.watch_ohlcv(args.get(0).cloned().unwrap_or(crate::Value::Null), &args.get(1..).unwrap_or(&[]).to_vec()[..]).await,
11901 "watch_ohlcv_for_symbols" => self.watch_ohlcv_for_symbols(args.get(0).cloned().unwrap_or(crate::Value::Null), &args.get(1..).unwrap_or(&[]).to_vec()[..]).await,
11902 "watch_order_book" => self.watch_order_book(args.get(0).cloned().unwrap_or(crate::Value::Null), &args.get(1..).unwrap_or(&[]).to_vec()[..]).await,
11903 "watch_order_book_for_symbols" => self.watch_order_book_for_symbols(args.get(0).cloned().unwrap_or(crate::Value::Null), &args.get(1..).unwrap_or(&[]).to_vec()[..]).await,
11904 "watch_orders" => self.watch_orders(&args.get(0..).unwrap_or(&[]).to_vec()[..]).await,
11905 "watch_orders_for_symbols" => self.watch_orders_for_symbols(args.get(0).cloned().unwrap_or(crate::Value::Null), &args.get(1..).unwrap_or(&[]).to_vec()[..]).await,
11906 "watch_position" => self.watch_position(&args.get(0..).unwrap_or(&[]).to_vec()[..]).await,
11907 "watch_position_for_symbols" => self.watch_position_for_symbols(&args.get(0..).unwrap_or(&[]).to_vec()[..]).await,
11908 "watch_positions" => self.watch_positions(&args.get(0..).unwrap_or(&[]).to_vec()[..]).await,
11909 "watch_ticker" => self.watch_ticker(args.get(0).cloned().unwrap_or(crate::Value::Null), &args.get(1..).unwrap_or(&[]).to_vec()[..]).await,
11910 "watch_tickers" => self.watch_tickers(&args.get(0..).unwrap_or(&[]).to_vec()[..]).await,
11911 "watch_trades" => self.watch_trades(args.get(0).cloned().unwrap_or(crate::Value::Null), &args.get(1..).unwrap_or(&[]).to_vec()[..]).await,
11912 "watch_trades_for_symbols" => self.watch_trades_for_symbols(args.get(0).cloned().unwrap_or(crate::Value::Null), &args.get(1..).unwrap_or(&[]).to_vec()[..]).await,
11913 "withdraw" => self.withdraw(args.get(0).cloned().unwrap_or(crate::Value::Null), args.get(1).cloned().unwrap_or(crate::Value::Null), args.get(2).cloned().unwrap_or(crate::Value::Null), &args.get(3..).unwrap_or(&[]).to_vec()[..]).await,
11914 "withdraw_ws" => self.withdraw_ws(args.get(0).cloned().unwrap_or(crate::Value::Null), args.get(1).cloned().unwrap_or(crate::Value::Null), args.get(2).cloned().unwrap_or(crate::Value::Null), &args.get(3..).unwrap_or(&[]).to_vec()[..]).await,
11915 _ => {
11923 if self.internals.implicit_api.is_empty() {
11924 self.build_implicit_api();
11925 }
11926 if self.internals.implicit_api.contains_key(method) {
11927 self.call_method(crate::Value::Str(method.to_string()), &args[..]).await
11928 } else {
11929 crate::Value::Null
11930 }
11931 }
11932 }
11933 })
11934 }
11935}